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 NAMESPACE_BEGIN(CryptoPP)
00008 
00009 //! <a href="http://www.weidai.com/scan-mirror/ca.html#cem_PKCS1-1.5">EME-PKCS1-v1_5</a>
00010 class PKCS_EncryptionPaddingScheme : public PK_EncryptionMessageEncodingMethod
00011 {
00012 public:
00013         static const char * StaticAlgorithmName() {return "EME-PKCS1-v1_5";}
00014 
00015         unsigned int MaxUnpaddedLength(unsigned int paddedLength) const;
00016         void Pad(RandomNumberGenerator &rng, const byte *raw, unsigned int inputLength, byte *padded, unsigned int paddedLength) const;
00017         DecodingResult Unpad(const byte *padded, unsigned int paddedLength, byte *raw) const;
00018 };
00019 
00020 template <class H> struct PKCS_DigestDecoration
00021 {
00022         static const byte decoration[];
00023         static const unsigned int length;
00024 };
00025 
00026 //! <a href="http://www.weidai.com/scan-mirror/sig.html#sem_PKCS1-1.5">EMSA-PKCS1-v1_5</a>
00027 class PKCS1v15_SignatureMessageEncodingMethod : public PK_DeterministicSignatureMessageEncodingMethod
00028 {
00029 public:
00030         static const char * StaticAlgorithmName() {return "EMSA-PKCS1-v1_5";}
00031 
00032         void ComputeMessageRepresentative(RandomNumberGenerator &rng, 
00033                 const byte *recoverableMessage, unsigned int recoverableMessageLength,
00034                 HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
00035                 byte *representative, unsigned int representativeBitLength) const;
00036 
00037         struct HashIdentifierLookup
00038         {
00039                 template <class H> struct HashIdentifierLookup2
00040                 {
00041                         static HashIdentifier Lookup()
00042                         {
00043                                 return HashIdentifier(PKCS_DigestDecoration<H>::decoration, PKCS_DigestDecoration<H>::length);
00044                         }
00045                 };
00046         };
00047 };
00048 
00049 //! PKCS #1 version 1.5, for use with RSAES and RSASS
00050 /*! The following hash functions are supported for signature: SHA, MD2, MD5, RIPEMD160, SHA256, SHA384, SHA512. */
00051 struct PKCS1v15 : public SignatureStandard, public EncryptionStandard
00052 {
00053         typedef PKCS_EncryptionPaddingScheme EncryptionMessageEncodingMethod;
00054         typedef PKCS1v15_SignatureMessageEncodingMethod SignatureMessageEncodingMethod;
00055 };
00056 
00057 // PKCS_DecoratedHashModule can be instantiated with the following
00058 // classes as specified in PKCS#1 v2.0 and P1363a
00059 class SHA;
00060 class MD2;
00061 class MD5;
00062 class RIPEMD160;
00063 class Tiger;
00064 class SHA256;
00065 class SHA384;
00066 class SHA512;
00067 
00068 NAMESPACE_END
00069 
00070 #endif

Generated on Sun Mar 14 20:44:27 2004 for Crypto++ by doxygen 1.3.6-20040222