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
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.
Tiger
Definition: tiger.h:10
RIPEMD-160
Definition: ripemd.h:10
message encoding method for public key encryption
Definition: pubkey.h:104
interface for random number generators
Definition: cryptlib.h:668
Base class for public key signature standard classes. These classes are used to select from variants ...
Definition: pubkey.h:1600
EME-PKCS1-v1_5
Definition: pkcspad.h:14
used to return decoding results
Definition: cryptlib.h:197
implements the SHA-512 standard
Definition: sha.h:44
PKCS #1 version 1.5, for use with RSAES and RSASS.
Definition: pkcspad.h:86
Base class for public key encryption standard classes. These classes are used to select from variants...
Definition: pubkey.h:1597
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
Definition: arc4.h:8
interface for retrieving values given their names
Definition: cryptlib.h:224