1
#ifndef CRYPTOPP_PKCSPAD_H
2
#define CRYPTOPP_PKCSPAD_H
11
NAMESPACE_BEGIN(CryptoPP)
13
//! <a href="http://www.weidai.com/scan-mirror/ca.html#cem_PKCS1-1.5">EME-PKCS1-v1_5</a>
14
class PKCS_EncryptionPaddingScheme : public PK_EncryptionMessageEncodingMethod
17
static const char * StaticAlgorithmName() {return "EME-PKCS1-v1_5";}
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 ¶meters) const;
21
DecodingResult Unpad(const byte *padded, size_t paddedLength, byte *raw, const NameValuePairs ¶meters) const;
24
template <class H> class PKCS_DigestDecoration
27
static const byte decoration[];
28
static const unsigned int length;
31
// PKCS_DigestDecoration can be instantiated with the following
32
// classes as specified in PKCS#1 v2.0 and P1363a
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>;
54
//! <a href="http://www.weidai.com/scan-mirror/sig.html#sem_PKCS1-1.5">EMSA-PKCS1-v1_5</a>
55
class CRYPTOPP_DLL PKCS1v15_SignatureMessageEncodingMethod : public PK_DeterministicSignatureMessageEncodingMethod
58
static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA-PKCS1-v1_5";}
60
size_t MinRepresentativeBitLength(size_t hashIdentifierSize, size_t digestSize) const
61
{return 8 * (digestSize + hashIdentifierSize + 10);}
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;
68
struct HashIdentifierLookup
70
template <class H> struct HashIdentifierLookup2
72
static HashIdentifier Lookup()
74
return HashIdentifier(PKCS_DigestDecoration<H>::decoration, PKCS_DigestDecoration<H>::length);
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
86
struct PKCS1v15 : public SignatureStandard, public EncryptionStandard
88
typedef PKCS_EncryptionPaddingScheme EncryptionMessageEncodingMethod;
89
typedef PKCS1v15_SignatureMessageEncodingMethod SignatureMessageEncodingMethod;