summaryrefslogtreecommitdiff
path: root/oaep.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-07-16 01:53:45 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-07-16 01:53:45 +0000
commit42c3d8f3aa593c224174558fd6f3d2709e08f7d0 (patch)
tree1f90c9ea7a31679b5c416408a3ffeba23e87d165 /oaep.h
parent09326fa9f564c09ebecff7c56d0e33555dec65b6 (diff)
downloadcryptopp-42c3d8f3aa593c224174558fd6f3d2709e08f7d0.tar.gz
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
Diffstat (limited to 'oaep.h')
-rw-r--r--oaep.h29
1 files changed, 21 insertions, 8 deletions
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
+//! <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 &parameters) const;
+ DecodingResult Unpad(const byte *padded, unsigned int paddedLength, byte *raw, const NameValuePairs &parameters) 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>;