emsa2.h

Go to the documentation of this file.
00001 #ifndef CRYPTOPP_EMSA2_H
00002 #define CRYPTOPP_EMSA2_H
00003 
00004 /** \file
00005         This file contains various padding schemes for public key algorithms.
00006 */
00007 
00008 #include "cryptlib.h"
00009 #include "pubkey.h"
00010 
00011 #ifdef CRYPTOPP_IS_DLL
00012 #include "sha.h"
00013 #endif
00014 
00015 NAMESPACE_BEGIN(CryptoPP)
00016 
00017 template <class H> class EMSA2HashId
00018 {
00019 public:
00020         static const byte id;
00021 };
00022 
00023 template <class BASE>
00024 class EMSA2HashIdLookup : public BASE
00025 {
00026 public:
00027         struct HashIdentifierLookup
00028         {
00029                 template <class H> struct HashIdentifierLookup2
00030                 {
00031                         static HashIdentifier Lookup()
00032                         {
00033                                 return HashIdentifier(&EMSA2HashId<H>::id, 1);
00034                         }
00035                 };
00036         };
00037 };
00038 
00039 // EMSA2HashId can be instantiated with the following classes.
00040 class SHA1;
00041 class RIPEMD160;
00042 class RIPEMD128;
00043 class SHA256;
00044 class SHA384;
00045 class SHA512;
00046 class Whirlpool;
00047 class SHA224;
00048 // end of list
00049 
00050 #ifdef CRYPTOPP_IS_DLL
00051 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA1>;
00052 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA224>;
00053 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA256>;
00054 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA384>;
00055 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA512>;
00056 #endif
00057 
00058 //! _
00059 class CRYPTOPP_DLL EMSA2Pad : public EMSA2HashIdLookup<PK_DeterministicSignatureMessageEncodingMethod>
00060 {
00061 public:
00062         static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA2";}
00063         
00064         size_t MinRepresentativeBitLength(size_t hashIdentifierLength, size_t digestLength) const
00065                 {return 8*digestLength + 31;}
00066 
00067         void ComputeMessageRepresentative(RandomNumberGenerator &rng, 
00068                 const byte *recoverableMessage, size_t recoverableMessageLength,
00069                 HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
00070                 byte *representative, size_t representativeBitLength) const;
00071 };
00072 
00073 //! EMSA2, for use with RWSS and RSA_ISO
00074 /*! Only the following hash functions are supported by this signature standard:
00075         \dontinclude emsa2.h
00076         \skip EMSA2HashId can be instantiated
00077         \until end of list
00078 */
00079 struct P1363_EMSA2 : public SignatureStandard
00080 {
00081         typedef EMSA2Pad SignatureMessageEncodingMethod;
00082 };
00083 
00084 NAMESPACE_END
00085 
00086 #endif

Generated on Sat Dec 23 02:07:07 2006 for Crypto++ by  doxygen 1.5.1-p1