From 42c3d8f3aa593c224174558fd6f3d2709e08f7d0 Mon Sep 17 00:00:00 2001 From: weidai Date: Wed, 16 Jul 2003 01:53:45 +0000 Subject: added support for using encoding parameters and key derivation parameters git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@98 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- oaep.h | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'oaep.h') diff --git a/oaep.h b/oaep.h index 018f688..cda1a9e 100644 --- a/oaep.h +++ b/oaep.h @@ -6,19 +6,32 @@ NAMESPACE_BEGIN(CryptoPP) -extern byte OAEP_P_DEFAULT[]; // defined in misc.cpp +//! EME-OAEP, 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; -/// EME-OAEP, for use with RSAES -template -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 OAEP : public OAEP_Base, public EncryptionStandard { public: static std::string StaticAlgorithmName() {return std::string("OAEP-") + MGF::StaticAlgorithmName() + "(" + H::StaticAlgorithmName() + ")";} - typedef OAEP EncryptionMessageEncodingMethod; + typedef OAEP 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; -- cgit v1.2.1