00001
00002
00003
00004
00005
00006 #ifndef CRYPTOPP_PKCSPAD_H
00007 #define CRYPTOPP_PKCSPAD_H
00008
00009 #include "cryptlib.h"
00010 #include "pubkey.h"
00011
00012 #ifdef CRYPTOPP_IS_DLL
00013 #include "sha.h"
00014 #endif
00015
00016 NAMESPACE_BEGIN(CryptoPP)
00017
00018
00019 class PKCS_EncryptionPaddingScheme : public PK_EncryptionMessageEncodingMethod
00020 {
00021 public:
00022 static const char * StaticAlgorithmName() {return "EME-PKCS1-v1_5";}
00023
00024 size_t MaxUnpaddedLength(size_t paddedLength) const;
00025 void Pad(RandomNumberGenerator &rng, const byte *raw, size_t inputLength, byte *padded, size_t paddedLength, const NameValuePairs ¶meters) const;
00026 DecodingResult Unpad(const byte *padded, size_t paddedLength, byte *raw, const NameValuePairs ¶meters) const;
00027 };
00028
00029 template <class H> class PKCS_DigestDecoration
00030 {
00031 public:
00032 static const byte decoration[];
00033 static const unsigned int length;
00034 };
00035
00036
00037
00038 class SHA1;
00039 class RIPEMD160;
00040 class Tiger;
00041 class SHA224;
00042 class SHA256;
00043 class SHA384;
00044 class SHA512;
00045 namespace Weak1 {
00046 class MD2;
00047 class MD5;
00048 }
00049
00050
00051 #ifdef CRYPTOPP_IS_DLL
00052 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA1>;
00053 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA224>;
00054 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA256>;
00055 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA384>;
00056 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA512>;
00057 #endif
00058
00059
00060 class CRYPTOPP_DLL PKCS1v15_SignatureMessageEncodingMethod : public PK_DeterministicSignatureMessageEncodingMethod
00061 {
00062 public:
00063 static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA-PKCS1-v1_5";}
00064
00065 size_t MinRepresentativeBitLength(size_t hashIdentifierSize, size_t digestSize) const
00066 {return 8 * (digestSize + hashIdentifierSize + 10);}
00067
00068 void ComputeMessageRepresentative(RandomNumberGenerator &rng,
00069 const byte *recoverableMessage, size_t recoverableMessageLength,
00070 HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
00071 byte *representative, size_t representativeBitLength) const;
00072
00073 struct HashIdentifierLookup
00074 {
00075 template <class H> struct HashIdentifierLookup2
00076 {
00077 static HashIdentifier Lookup()
00078 {
00079 return HashIdentifier(PKCS_DigestDecoration<H>::decoration, PKCS_DigestDecoration<H>::length);
00080 }
00081 };
00082 };
00083 };
00084
00085
00086
00087
00088
00089
00090
00091 struct PKCS1v15 : public SignatureStandard, public EncryptionStandard
00092 {
00093 typedef PKCS_EncryptionPaddingScheme EncryptionMessageEncodingMethod;
00094 typedef PKCS1v15_SignatureMessageEncodingMethod SignatureMessageEncodingMethod;
00095 };
00096
00097 NAMESPACE_END
00098
00099 #endif