5 #ifndef CRYPTOPP_PKCSPAD_CPP // SunCC workaround: compiler could cause this file to be included twice 6 #define CRYPTOPP_PKCSPAD_CPP 16 template<> const
byte PKCS_DigestDecoration<
Weak1::MD2>::decoration[] = {0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x02,0x05,0x00,0x04,0x10};
19 template<>
const byte PKCS_DigestDecoration<Weak1::MD5>::decoration[] = {0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x04,0x10};
22 template<>
const byte PKCS_DigestDecoration<RIPEMD160>::decoration[] = {0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x24,0x03,0x02,0x01,0x05,0x00,0x04,0x14};
25 template<>
const byte PKCS_DigestDecoration<Tiger>::decoration[] = {0x30,0x29,0x30,0x0D,0x06,0x09,0x2B,0x06,0x01,0x04,0x01,0xDA,0x47,0x0C,0x02,0x05,0x00,0x04,0x18};
29 #ifndef CRYPTOPP_IS_DLL 30 template<>
const byte PKCS_DigestDecoration<SHA1>::decoration[] = {0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14};
33 template<>
const byte PKCS_DigestDecoration<SHA224>::decoration[] = {0x30,0x2d,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x04,0x05,0x00,0x04,0x1c};
36 template<>
const byte PKCS_DigestDecoration<SHA256>::decoration[] = {0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20};
39 template<>
const byte PKCS_DigestDecoration<SHA384>::decoration[] = {0x30,0x41,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30};
42 template<>
const byte PKCS_DigestDecoration<SHA512>::decoration[] = {0x30,0x51,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0x04,0x40};
63 if (pkcsBlockLen % 8 != 0)
73 for (
unsigned i = 1; i < pkcsBlockLen-inputLen-1; i++)
76 pkcsBlock[pkcsBlockLen-inputLen-1] = 0;
77 memcpy(pkcsBlock+pkcsBlockLen-inputLen, input, inputLen);
87 if (pkcsBlockLen % 8 != 0)
89 invalid = (pkcsBlock[0] != 0) || invalid;
95 invalid = (pkcsBlock[0] != 2) || invalid;
99 while (i<pkcsBlockLen && pkcsBlock[i++]) {
103 size_t outputLen = pkcsBlockLen - i;
104 invalid = (outputLen > maxOutputLen) || invalid;
109 memcpy (output, pkcsBlock+i, outputLen);
115 #ifndef CRYPTOPP_IMPORTS 118 const byte *recoverableMessage,
size_t recoverableMessageLength,
120 byte *representative,
size_t representativeBitLength)
const 126 size_t pkcsBlockLen = representativeBitLength;
128 if (pkcsBlockLen % 8 != 0)
130 representative[0] = 0;
135 representative[0] = 1;
138 byte *pPadding = representative + 1;
139 byte *pDigest = representative + pkcsBlockLen - digestSize;
140 byte *pHashId = pDigest - hashIdentifier.second;
141 byte *pSeparator = pHashId - 1;
144 memset(pPadding, 0xff, pSeparator-pPadding);
146 memcpy(pHashId, hashIdentifier.first, hashIdentifier.second);
void ComputeMessageRepresentative(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, byte *representative, size_t representativeBitLength) const
Utility functions for the Crypto++ library.
Classes and functions for various padding schemes used in public key algorithms.
#define NAMESPACE_BEGIN(x)
virtual word32 GenerateWord32(word32 min=0, word32 max=0xffffffffUL)
Generate a random 32 bit word in the range min to max, inclusive.
Interface for random number generators.
Returns a decoding results.
Classes for PKCS padding schemes.
void Pad(RandomNumberGenerator &rng, const byte *raw, size_t inputLength, byte *padded, size_t paddedLength, const NameValuePairs ¶meters) const
T1 SaturatingSubtract(const T1 &a, const T2 &b)
Performs a saturating subtract clamped at 0.
DecodingResult Unpad(const byte *padded, size_t paddedLength, byte *raw, const NameValuePairs ¶meters) const
#define CRYPTOPP_ASSERT(exp)
void * memcpy(void *a, const void *b, size_t c)
#define CRYPTOPP_UNUSED(x)
Debugging and diagnostic assertions.
PKCS#1 decoration data structure.
std::vector< char * > parameters
size_t MaxUnpaddedLength(size_t paddedLength) const
max size of unpadded message in bytes, given max size of padded message in bits (1 less than size of ...
std::pair< const byte *, unsigned int > HashIdentifier
Interface for retrieving values given their names.