File indexing completed on 2025-01-18 09:55:02
0001
0002
0003
0004
0005
0006 #ifndef CRYPTOPP_EMSA2_H
0007 #define CRYPTOPP_EMSA2_H
0008
0009 #include "cryptlib.h"
0010 #include "pubkey.h"
0011 #include "hashfwd.h"
0012 #include "misc.h"
0013
0014 #ifdef CRYPTOPP_IS_DLL
0015 # include "sha.h"
0016 #endif
0017
0018 NAMESPACE_BEGIN(CryptoPP)
0019
0020
0021
0022
0023 template <class H> class EMSA2HashId
0024 {
0025 public:
0026 static const byte id;
0027 };
0028
0029
0030
0031
0032 template <class BASE>
0033 class EMSA2HashIdLookup : public BASE
0034 {
0035 public:
0036 struct HashIdentifierLookup
0037 {
0038 template <class H> struct HashIdentifierLookup2
0039 {
0040 static HashIdentifier Lookup()
0041 {
0042 return HashIdentifier(&EMSA2HashId<H>::id, 1);
0043 }
0044 };
0045 };
0046 };
0047
0048
0049
0050
0051 #ifdef CRYPTOPP_IS_DLL
0052 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA1>;
0053 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA224>;
0054 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA256>;
0055 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA384>;
0056 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA512>;
0057 #endif
0058
0059
0060
0061 #if defined(__clang__)
0062 template<> const byte EMSA2HashId<SHA1>::id;
0063 template<> const byte EMSA2HashId<SHA224>::id;
0064 template<> const byte EMSA2HashId<SHA256>::id;
0065 template<> const byte EMSA2HashId<SHA384>::id;
0066 template<> const byte EMSA2HashId<SHA512>::id;
0067 #endif
0068
0069
0070
0071 class CRYPTOPP_DLL EMSA2Pad : public EMSA2HashIdLookup<PK_DeterministicSignatureMessageEncodingMethod>
0072 {
0073 public:
0074 CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "EMSA2";}
0075
0076 size_t MinRepresentativeBitLength(size_t hashIdentifierLength, size_t digestLength) const
0077 {CRYPTOPP_UNUSED(hashIdentifierLength); return 8*digestLength + 31;}
0078
0079 void ComputeMessageRepresentative(RandomNumberGenerator &rng,
0080 const byte *recoverableMessage, size_t recoverableMessageLength,
0081 HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
0082 byte *representative, size_t representativeBitLength) const;
0083 };
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 struct P1363_EMSA2 : public SignatureStandard
0095 {
0096 typedef EMSA2Pad SignatureMessageEncodingMethod;
0097 };
0098
0099 NAMESPACE_END
0100
0101 #endif