diff options
author | weidai <weidai11@users.noreply.github.com> | 2003-07-16 01:53:45 +0000 |
---|---|---|
committer | weidai <weidai11@users.noreply.github.com> | 2003-07-16 01:53:45 +0000 |
commit | 38b49e454399c81aac16279f78a834de26245bec (patch) | |
tree | 1f90c9ea7a31679b5c416408a3ffeba23e87d165 /oaep.h | |
parent | 8cd6a9256d78953d6e99097fb4508a077e8e2ebe (diff) | |
download | cryptopp-git-38b49e454399c81aac16279f78a834de26245bec.tar.gz |
added support for using encoding parameters and key derivation parameters
Diffstat (limited to 'oaep.h')
-rw-r--r-- | oaep.h | 29 |
1 files changed, 21 insertions, 8 deletions
@@ -6,19 +6,32 @@ NAMESPACE_BEGIN(CryptoPP) -extern byte OAEP_P_DEFAULT[]; // defined in misc.cpp +//! <a href="http://www.weidai.com/scan-mirror/ca.html#cem_OAEP-MGF1">EME-OAEP</a>, for use with RSAES +class CRYPTOPP_DLL OAEP_Base : public PK_EncryptionMessageEncodingMethod +{ +public: + bool ParameterSupported(const char *name) const {return strcmp(name, Name::EncodingParameters()) == 0;} + unsigned int MaxUnpaddedLength(unsigned int paddedLength) const; + void Pad(RandomNumberGenerator &rng, const byte *raw, unsigned int inputLength, byte *padded, unsigned int paddedLength, const NameValuePairs ¶meters) const; + DecodingResult Unpad(const byte *padded, unsigned int paddedLength, byte *raw, const NameValuePairs ¶meters) const; -/// <a href="http://www.weidai.com/scan-mirror/ca.html#cem_OAEP-MGF1">EME-OAEP</a>, for use with RSAES -template <class H, class MGF=P1363_MGF1, byte *P=OAEP_P_DEFAULT, unsigned int PLen=0> -class OAEP : public PK_EncryptionMessageEncodingMethod, public EncryptionStandard +protected: + virtual unsigned int DigestSize() const =0; + virtual HashTransformation * NewHash() const =0; + virtual MaskGeneratingFunction * NewMGF() const =0; +}; + +template <class H, class MGF=P1363_MGF1> +class OAEP : public OAEP_Base, public EncryptionStandard { public: static std::string StaticAlgorithmName() {return std::string("OAEP-") + MGF::StaticAlgorithmName() + "(" + H::StaticAlgorithmName() + ")";} - typedef OAEP<H, MGF, P, PLen> EncryptionMessageEncodingMethod; + typedef OAEP<H, MGF> EncryptionMessageEncodingMethod; - unsigned int MaxUnpaddedLength(unsigned int paddedLength) const; - void Pad(RandomNumberGenerator &rng, const byte *raw, unsigned int inputLength, byte *padded, unsigned int paddedLength) const; - DecodingResult Unpad(const byte *padded, unsigned int paddedLength, byte *raw) const; +protected: + unsigned int DigestSize() const {return H::DIGESTSIZE;} + HashTransformation * NewHash() const {return new H;} + MaskGeneratingFunction * NewMGF() const {return new MGF;} }; CRYPTOPP_DLL_TEMPLATE_CLASS OAEP<SHA>; |