Crypto++  5.6.3
Free C++ class library of cryptographic schemes
pkcspad.h
1 // pkcspad.h - written and placed in the public domain by Wei Dai
2 
3 //! \headerfile pkcspad.h
4 //! \brief Classes for PKCS padding schemes
5 
6 #ifndef CRYPTOPP_PKCSPAD_H
7 #define CRYPTOPP_PKCSPAD_H
8 
9 #include "cryptlib.h"
10 #include "pubkey.h"
11 
12 #ifdef CRYPTOPP_IS_DLL
13 #include "sha.h"
14 #endif
15 
16 NAMESPACE_BEGIN(CryptoPP)
17 
18 //! <a href="http://www.weidai.com/scan-mirror/ca.html#cem_PKCS1-1.5">EME-PKCS1-v1_5</a>
20 {
21 public:
22  static const char * StaticAlgorithmName() {return "EME-PKCS1-v1_5";}
23 
24  size_t MaxUnpaddedLength(size_t paddedLength) const;
25  void Pad(RandomNumberGenerator &rng, const byte *raw, size_t inputLength, byte *padded, size_t paddedLength, const NameValuePairs &parameters) const;
26  DecodingResult Unpad(const byte *padded, size_t paddedLength, byte *raw, const NameValuePairs &parameters) const;
27 };
28 
29 template <class H> class PKCS_DigestDecoration
30 {
31 public:
32  static const byte decoration[];
33  static const unsigned int length;
34 };
35 
36 // PKCS_DigestDecoration can be instantiated with the following
37 // classes as specified in PKCS#1 v2.0 and P1363a
38 class SHA1;
39 class RIPEMD160;
40 class Tiger;
41 class SHA224;
42 class SHA256;
43 class SHA384;
44 class SHA512;
45 namespace Weak1 {
46 class MD2;
47 class MD5;
48 }
49 // end of list
50 
51 #ifdef CRYPTOPP_IS_DLL
52 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA1>;
53 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA224>;
54 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA256>;
55 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA384>;
56 CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA512>;
57 #endif
58 
59 //! <a href="http://www.weidai.com/scan-mirror/sig.html#sem_PKCS1-1.5">EMSA-PKCS1-v1_5</a>
61 {
62 public:
63  static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA-PKCS1-v1_5";}
64 
65  size_t MinRepresentativeBitLength(size_t hashIdentifierSize, size_t digestSize) const
66  {return 8 * (digestSize + hashIdentifierSize + 10);}
67 
68  void ComputeMessageRepresentative(RandomNumberGenerator &rng,
69  const byte *recoverableMessage, size_t recoverableMessageLength,
70  HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
71  byte *representative, size_t representativeBitLength) const;
72 
74  {
75  template <class H> struct HashIdentifierLookup2
76  {
77  static HashIdentifier Lookup()
78  {
80  }
81  };
82  };
83 };
84 
85 //! PKCS #1 version 1.5, for use with RSAES and RSASS
86 /*! Only the following hash functions are supported by this signature standard:
87  \dontinclude pkcspad.h
88  \skip can be instantiated
89  \until end of list
90 */
92 {
95 };
96 
97 NAMESPACE_END
98 
99 #endif
implements the SHA-384 standard
Definition: sha.h:65
implements the SHA-256 standard
Definition: sha.h:32
This file contains helper classes/functions for implementing public key algorithms.
Tiger
Definition: tiger.h:10
Abstract base classes that provide a uniform interface to this library.
RIPEMD-160
Definition: ripemd.h:15
Message encoding method for public key encryption.
Definition: pubkey.h:215
Interface for random number generators.
Definition: cryptlib.h:1186
Base class for public key signature standard classes.
Definition: pubkey.h:2146
Classes for PKCS padding schemes.
Definition: pkcspad.h:19
Returns a decoding results.
Definition: cryptlib.h:236
Interface for message encoding method for public key signature schemes.
Definition: pubkey.h:408
implements the SHA-512 standard
Definition: sha.h:56
PKCS #1 version 1.5, for use with RSAES and RSASS.
Definition: pkcspad.h:91
Base class for public key encryption standard classes.
Definition: pubkey.h:2141
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:922
Crypto++ library namespace.
implements the SHA-224 standard
Definition: sha.h:44
Interface for retrieving values given their names.
Definition: cryptlib.h:277