Crypto++
emsa2.h
Go to the documentation of this file.
1 #ifndef CRYPTOPP_EMSA2_H
2 #define CRYPTOPP_EMSA2_H
3 
4 /** \file
5  This file contains various padding schemes for public key algorithms.
6 */
7 
8 #include "cryptlib.h"
9 #include "pubkey.h"
10 
11 #ifdef CRYPTOPP_IS_DLL
12 #include "sha.h"
13 #endif
14 
15 NAMESPACE_BEGIN(CryptoPP)
16 
17 template <class H> class EMSA2HashId
18 {
19 public:
20  static const byte id;
21 };
22 
23 template <class BASE>
24 class EMSA2HashIdLookup : public BASE
25 {
26 public:
28  {
29  template <class H> struct HashIdentifierLookup2
30  {
31  static HashIdentifier Lookup()
32  {
33  return HashIdentifier(&EMSA2HashId<H>::id, 1);
34  }
35  };
36  };
37 };
38 
39 // EMSA2HashId can be instantiated with the following classes.
40 class SHA1;
41 class RIPEMD160;
42 class RIPEMD128;
43 class SHA256;
44 class SHA384;
45 class SHA512;
46 class Whirlpool;
47 class SHA224;
48 // end of list
49 
50 #ifdef CRYPTOPP_IS_DLL
51 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA1>;
52 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA224>;
53 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA256>;
54 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA384>;
55 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA512>;
56 #endif
57 
58 //! _
59 class CRYPTOPP_DLL EMSA2Pad : public EMSA2HashIdLookup<PK_DeterministicSignatureMessageEncodingMethod>
60 {
61 public:
62  static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA2";}
63 
64  size_t MinRepresentativeBitLength(size_t hashIdentifierLength, size_t digestLength) const
65  {return 8*digestLength + 31;}
66 
67  void ComputeMessageRepresentative(RandomNumberGenerator &rng,
68  const byte *recoverableMessage, size_t recoverableMessageLength,
69  HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
70  byte *representative, size_t representativeBitLength) const;
71 };
72 
73 //! EMSA2, for use with RWSS and RSA_ISO
74 /*! Only the following hash functions are supported by this signature standard:
75  \dontinclude emsa2.h
76  \skip EMSA2HashId can be instantiated
77  \until end of list
78 */
80 {
82 };
83 
84 NAMESPACE_END
85 
86 #endif
implements the SHA-384 standard
Definition: sha.h:53
implements the SHA-256 standard
Definition: sha.h:20
This file contains helper classes/functions for implementing public key algorithms.
RIPEMD-160
Definition: ripemd.h:10
interface for random number generators
Definition: cryptlib.h:668
_
Definition: emsa2.h:59
Base class for public key signature standard classes. These classes are used to select from variants ...
Definition: pubkey.h:1600
EMSA2, for use with RWSS and RSA_ISO.
Definition: emsa2.h:79
Whirlpool
Definition: whrlpool.h:10
implements the SHA-512 standard
Definition: sha.h:44
SHA-1
Definition: sha.h:9
interface for hash functions and data processing part of MACs
Definition: cryptlib.h:530
implements the SHA-224 standard
Definition: sha.h:32