Crypto++  5.6.3
Free C++ class library of cryptographic schemes
emsa2.h
Go to the documentation of this file.
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 
17 NAMESPACE_BEGIN(CryptoPP)
18 
19 template <class H> class EMSA2HashId
20 {
21 public:
22  static const byte id;
23 };
24 
25 template <class BASE>
26 class EMSA2HashIdLookup : public BASE
27 {
28 public:
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.
42 class SHA1;
43 class RIPEMD160;
44 class RIPEMD128;
45 class SHA256;
46 class SHA384;
47 class SHA512;
48 class Whirlpool;
49 class SHA224;
50 // end of list
51 
52 #ifdef CRYPTOPP_IS_DLL
53 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA1>;
54 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA224>;
55 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA256>;
56 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA384>;
57 CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA512>;
58 #endif
59 
60 //! _
61 class CRYPTOPP_DLL EMSA2Pad : public EMSA2HashIdLookup<PK_DeterministicSignatureMessageEncodingMethod>
62 {
63 public:
64  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 */
82 {
84 };
85 
86 NAMESPACE_END
87 
88 #endif
implements the SHA-384 standard
Definition: sha.h:65
Utility functions for the Crypto++ library.
implements the SHA-256 standard
Definition: sha.h:32
This file contains helper classes/functions for implementing public key algorithms.
Abstract base classes that provide a uniform interface to this library.
RIPEMD-160
Definition: ripemd.h:15
Interface for random number generators.
Definition: cryptlib.h:1176
_
Definition: emsa2.h:61
Base class for public key signature standard classes.
Definition: pubkey.h:2058
EMSA2, for use with RWSS and RSA_ISO.
Definition: emsa2.h:81
Whirlpool
Definition: whrlpool.h:10
implements the SHA-512 standard
Definition: sha.h:56
SHA-1
Definition: sha.h:21
Classes for SHA-1 and SHA-2 family of message digests.
Interface for hash functions and data processing part of MACs.
Definition: cryptlib.h:912
Crypto++ library namespace.
implements the SHA-224 standard
Definition: sha.h:44