Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

pkcspad.h

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 //! <a href="http://www.weidai.com/scan-mirror/ca.html#cem_PKCS1-1.5">EME-PKCS1-v1_5</a>
00014 class PKCS_EncryptionPaddingScheme : public PK_EncryptionMessageEncodingMethod
00015 {
00016 public:
00017         static const char * StaticAlgorithmName() {return "EME-PKCS1-v1_5";}
00018 
00019         unsigned int MaxUnpaddedLength(unsigned int paddedLength) const;
00020         void Pad(RandomNumberGenerator &rng, const byte *raw, unsigned int inputLength, byte *padded, unsigned int paddedLength, const NameValuePairs &parameters) const;
00021         DecodingResult Unpad(const byte *padded, unsigned int paddedLength, byte *raw, const NameValuePairs &parameters) 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 // PKCS_DigestDecoration can be instantiated with the following
00032 // classes as specified in PKCS#1 v2.0 and P1363a
00033 class SHA;
00034 class MD2;
00035 class MD5;
00036 class RIPEMD160;
00037 class Tiger;
00038 class SHA256;
00039 class SHA384;
00040 class SHA512;
00041 // end of list
00042 
00043 //! <a href="http://www.weidai.com/scan-mirror/sig.html#sem_PKCS1-1.5">EMSA-PKCS1-v1_5</a>
00044 class CRYPTOPP_DLL PKCS1v15_SignatureMessageEncodingMethod : public PK_DeterministicSignatureMessageEncodingMethod
00045 {
00046 public:
00047         static const char * StaticAlgorithmName() {return "EMSA-PKCS1-v1_5";}
00048 
00049         void ComputeMessageRepresentative(RandomNumberGenerator &rng, 
00050                 const byte *recoverableMessage, unsigned int recoverableMessageLength,
00051                 HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
00052                 byte *representative, unsigned int representativeBitLength) const;
00053 
00054         struct HashIdentifierLookup
00055         {
00056                 template <class H> struct HashIdentifierLookup2
00057                 {
00058                         static HashIdentifier Lookup()
00059                         {
00060                                 return HashIdentifier(PKCS_DigestDecoration<H>::decoration, PKCS_DigestDecoration<H>::length);
00061                         }
00062                 };
00063         };
00064 };
00065 
00066 //! PKCS #1 version 1.5, for use with RSAES and RSASS
00067 /*! Only the following hash functions are supported by this signature standard:
00068         \dontinclude pkcspad.h
00069         \skip can be instantiated
00070         \until end of list
00071 */
00072 struct PKCS1v15 : public SignatureStandard, public EncryptionStandard
00073 {
00074         typedef PKCS_EncryptionPaddingScheme EncryptionMessageEncodingMethod;
00075         typedef PKCS1v15_SignatureMessageEncodingMethod SignatureMessageEncodingMethod;
00076 };
00077 
00078 #ifdef CRYPTOPP_IS_DLL
00079 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA>;
00080 #endif
00081 
00082 NAMESPACE_END
00083 
00084 #endif

Generated on Wed Nov 17 21:26:08 2004 for Crypto++ by  doxygen 1.3.9.1