00001
00002
00003
00004
00005
00006 #ifndef CRYPTOPP_EMSA2_H
00007 #define CRYPTOPP_EMSA2_H
00008
00009 #include "cryptlib.h"
00010 #include "pubkey.h"
00011 #include "misc.h"
00012
00013 #ifdef CRYPTOPP_IS_DLL
00014 #include "sha.h"
00015 #endif
00016
00017 NAMESPACE_BEGIN(CryptoPP)
00018
00019 template <class H> class EMSA2HashId
00020 {
00021 public:
00022 static const byte id;
00023 };
00024
00025 template <class BASE>
00026 class EMSA2HashIdLookup : public BASE
00027 {
00028 public:
00029 struct HashIdentifierLookup
00030 {
00031 template <class H> struct HashIdentifierLookup2
00032 {
00033 static HashIdentifier Lookup()
00034 {
00035 return HashIdentifier(&EMSA2HashId<H>::id, 1);
00036 }
00037 };
00038 };
00039 };
00040
00041
00042 class SHA1;
00043 class RIPEMD160;
00044 class RIPEMD128;
00045 class SHA256;
00046 class SHA384;
00047 class SHA512;
00048 class Whirlpool;
00049 class SHA224;
00050
00051
00052 #ifdef CRYPTOPP_IS_DLL
00053 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA1>;
00054 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA224>;
00055 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA256>;
00056 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA384>;
00057 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA512>;
00058 #endif
00059
00060
00061 class CRYPTOPP_DLL EMSA2Pad : public EMSA2HashIdLookup<PK_DeterministicSignatureMessageEncodingMethod>
00062 {
00063 public:
00064 static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA2";}
00065
00066 size_t MinRepresentativeBitLength(size_t hashIdentifierLength, size_t digestLength) const
00067 {CRYPTOPP_UNUSED(hashIdentifierLength); return 8*digestLength + 31;}
00068
00069 void ComputeMessageRepresentative(RandomNumberGenerator &rng,
00070 const byte *recoverableMessage, size_t recoverableMessageLength,
00071 HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
00072 byte *representative, size_t representativeBitLength) const;
00073 };
00074
00075
00076
00077
00078
00079
00080
00081 struct P1363_EMSA2 : public SignatureStandard
00082 {
00083 typedef EMSA2Pad SignatureMessageEncodingMethod;
00084 };
00085
00086 NAMESPACE_END
00087
00088 #endif