File indexing completed on 2025-01-18 09:55:05
0001
0002
0003
0004
0005
0006
0007 #ifndef CRYPTOPP_OAEP_H
0008 #define CRYPTOPP_OAEP_H
0009
0010 #include "cryptlib.h"
0011 #include "pubkey.h"
0012 #include "sha.h"
0013
0014 NAMESPACE_BEGIN(CryptoPP)
0015
0016
0017
0018 class CRYPTOPP_DLL OAEP_Base : public PK_EncryptionMessageEncodingMethod
0019 {
0020 public:
0021 bool ParameterSupported(const char *name) const {return strcmp(name, Name::EncodingParameters()) == 0;}
0022 size_t MaxUnpaddedLength(size_t paddedLength) const;
0023 void Pad(RandomNumberGenerator &rng, const byte *raw, size_t inputLength, byte *padded, size_t paddedLength, const NameValuePairs ¶meters) const;
0024 DecodingResult Unpad(const byte *padded, size_t paddedLength, byte *raw, const NameValuePairs ¶meters) const;
0025
0026 protected:
0027 virtual unsigned int DigestSize() const =0;
0028 virtual HashTransformation * NewHash() const =0;
0029 virtual MaskGeneratingFunction * NewMGF() const =0;
0030 };
0031
0032
0033
0034
0035
0036
0037 template <class H, class MGF=P1363_MGF1>
0038 class OAEP : public OAEP_Base, public EncryptionStandard
0039 {
0040 public:
0041 static std::string CRYPTOPP_API StaticAlgorithmName() {return std::string("OAEP-") + MGF::StaticAlgorithmName() + "(" + H::StaticAlgorithmName() + ")";}
0042 typedef OAEP<H, MGF> EncryptionMessageEncodingMethod;
0043
0044 protected:
0045 unsigned int DigestSize() const {return H::DIGESTSIZE;}
0046 HashTransformation * NewHash() const {return new H;}
0047 MaskGeneratingFunction * NewMGF() const {return new MGF;}
0048 };
0049
0050 CRYPTOPP_DLL_TEMPLATE_CLASS OAEP<SHA1>;
0051
0052 NAMESPACE_END
0053
0054 #endif