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