source: trunk/src-cryptopp/emsa2.h

Last change on this file was e230cb0, checked in by David Stainton <dstainton415@…>, at 2016-10-12T13:27:29Z

Add cryptopp from tag CRYPTOPP_5_6_5

  • Property mode set to 100644
File size: 2.2 KB
Line 
1// emsa2.h - written and placed in the public domain by Wei Dai
2
3//! \file emsa2.h
4//! \brief Classes and functions for various padding schemes used in public key algorithms
5
6#ifndef CRYPTOPP_EMSA2_H
7#define CRYPTOPP_EMSA2_H
8
9#include "cryptlib.h"
10#include "pubkey.h"
11#include "misc.h"
12
13#ifdef CRYPTOPP_IS_DLL
14# include "sha.h"
15#endif
16
17NAMESPACE_BEGIN(CryptoPP)
18
19template <class H> class EMSA2HashId
20{
21public:
22        static const byte id;
23};
24
25template <class BASE>
26class EMSA2HashIdLookup : public BASE
27{
28public:
29        struct HashIdentifierLookup
30        {
31                template <class H> struct HashIdentifierLookup2
32                {
33                        static HashIdentifier Lookup()
34                        {
35                                return HashIdentifier(&EMSA2HashId<H>::id, 1);
36                        }
37                };
38        };
39};
40
41// EMSA2HashId can be instantiated with the following classes.
42class SHA1;
43class SHA224;
44class SHA256;
45class SHA384;
46class SHA512;
47class RIPEMD128;
48class RIPEMD160;
49class Whirlpool;
50// end of list
51
52#ifdef CRYPTOPP_IS_DLL
53CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA1>;
54CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA224>;
55CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA256>;
56CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA384>;
57CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA512>;
58#endif
59
60//! _
61class CRYPTOPP_DLL EMSA2Pad : public EMSA2HashIdLookup<PK_DeterministicSignatureMessageEncodingMethod>
62{
63public:
64        CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA2";}
65
66        size_t MinRepresentativeBitLength(size_t hashIdentifierLength, size_t digestLength) const
67                {CRYPTOPP_UNUSED(hashIdentifierLength); return 8*digestLength + 31;}
68
69        void ComputeMessageRepresentative(RandomNumberGenerator &rng,
70                const byte *recoverableMessage, size_t recoverableMessageLength,
71                HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
72                byte *representative, size_t representativeBitLength) const;
73};
74
75//! EMSA2, for use with RWSS and RSA_ISO
76/*! Only the following hash functions are supported by this signature standard:
77        \dontinclude emsa2.h
78        \skip EMSA2HashId can be instantiated
79        \until end of list
80*/
81struct P1363_EMSA2 : public SignatureStandard
82{
83        typedef EMSA2Pad SignatureMessageEncodingMethod;
84};
85
86NAMESPACE_END
87
88#endif
Note: See TracBrowser for help on using the repository browser.