Crypto++
pkcspad.h
1 #ifndef CRYPTOPP_PKCSPAD_H
2 #define CRYPTOPP_PKCSPAD_H
3 
4 #include "cryptlib.h"
5 #include "pubkey.h"
6 
7 #ifdef CRYPTOPP_IS_DLL
8 #include "sha.h"
9 #endif
10 
11 NAMESPACE_BEGIN(CryptoPP)
12 
13 //! <a href="http://www.weidai.com/scan-mirror/ca.html#cem_PKCS1-1.5">EME-PKCS1-v1_5</a>
15 {
16 public:
17  static const char * StaticAlgorithmName() {return "EME-PKCS1-v1_5";}
18 
19  size_t MaxUnpaddedLength(size_t paddedLength) const;
20  void Pad(RandomNumberGenerator &rng, const byte *raw, size_t inputLength, byte *padded, size_t paddedLength, const NameValuePairs &parameters) const;
21  DecodingResult Unpad(const byte *padded, size_t paddedLength, byte *raw, const NameValuePairs &parameters) const;
22 };
23 
24 template <class H> class PKCS_DigestDecoration
25 {
26 public:
27  static const byte decoration[];
28  static const unsigned int length;
29 };
30 
31 // PKCS_DigestDecoration can be instantiated with the following
32 // classes as specified in PKCS#1 v2.0 and P1363a
33 class SHA1;
34 class RIPEMD160;
35 class Tiger;
36 class SHA224;
37 class SHA256;
38 class SHA384;
39 class SHA512;
40 namespace Weak1 {
41 class MD2;
42 class MD5;
43 }
44 // end of list
45 
46 #ifdef CRYPTOPP_IS_DLL
47 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA1>;
48 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA224>;
49 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA256>;
50 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA384>;
51 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA512>;
52 #endif
53 
54 //! <a href="http://www.weidai.com/scan-mirror/sig.html#sem_PKCS1-1.5">EMSA-PKCS1-v1_5</a>
56 {
57 public:
58  static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA-PKCS1-v1_5";}
59 
60  size_t MinRepresentativeBitLength(size_t hashIdentifierSize, size_t digestSize) const
61  {return 8 * (digestSize + hashIdentifierSize + 10);}
62 
63  void ComputeMessageRepresentative(RandomNumberGenerator &rng,
64  const byte *recoverableMessage, size_t recoverableMessageLength,
65  HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
66  byte *representative, size_t representativeBitLength) const;
67 
69  {
70  template <class H> struct HashIdentifierLookup2
71  {
72  static HashIdentifier Lookup()
73  {
75  }
76  };
77  };
78 };
79 
80 //! PKCS #1 version 1.5, for use with RSAES and RSASS
81 /*! Only the following hash functions are supported by this signature standard:
82  \dontinclude pkcspad.h
83  \skip can be instantiated
84  \until end of list
85 */
87 {
90 };
91 
92 NAMESPACE_END
93 
94 #endif