5 #ifndef CRYPTOPP_IMPORTS 15 size_t
OAEP_Base::MaxUnpaddedLength(
size_t paddedLength)
const 25 if (oaepBlockLen % 8 != 0)
34 const size_t seedLen = hLen, dbLen = oaepBlockLen-seedLen;
35 byte *
const maskedSeed = oaepBlock;
36 byte *
const maskedDB = oaepBlock+seedLen;
39 parameters.
GetValue(Name::EncodingParameters(), encodingParameters);
43 memset(maskedDB+hLen, 0, dbLen-hLen-inputLength-1);
44 maskedDB[dbLen-inputLength-1] = 0x01;
45 memcpy(maskedDB+dbLen-inputLength, input, inputLength);
58 if (oaepBlockLen % 8 != 0)
60 invalid = (oaepBlock[0] != 0) || invalid;
67 const size_t seedLen = hLen, dbLen = oaepBlockLen-seedLen;
69 invalid = (oaepBlockLen < 2*hLen+1) || invalid;
72 byte *
const maskedSeed = t;
73 byte *
const maskedDB = t+seedLen;
80 parameters.
GetValue(Name::EncodingParameters(), encodingParameters);
83 byte *M = std::find(maskedDB+hLen, maskedDB+dbLen, 0x01);
84 invalid = (M == maskedDB+dbLen) || invalid;
85 invalid = (std::find_if(maskedDB+hLen, M, std::bind2nd(std::not_equal_to<byte>(),
byte(0))) != M) || invalid;
86 invalid = !pHash->
VerifyDigest(maskedDB, encodingParameters.
begin(), encodingParameters.
size()) || invalid;
92 memcpy(output, M, maskedDB+dbLen-M);
Used to pass byte array input as part of a NameValuePairs object.
void Pad(RandomNumberGenerator &rng, const byte *raw, size_t inputLength, byte *padded, size_t paddedLength, const NameValuePairs ¶meters) const
virtual void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
#define NAMESPACE_BEGIN(x)
Classes for automatic resource management.
size_t size() const
Length of the memory block.
Interface for random number generators.
DecodingResult Unpad(const byte *padded, size_t paddedLength, byte *raw, const NameValuePairs ¶meters) const
const byte * begin() const
Pointer to the first byte in the memory block.
Pointer that overloads operator ->
Returns a decoding results.
bool GetValue(const char *name, T &value) const
Get a named value.
virtual void GenerateAndMask(HashTransformation &hash, byte *output, size_t outputLength, const byte *input, size_t inputLength, bool mask=true) const =0
Generate and apply mask.
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 ...
T1 SaturatingSubtract(const T1 &a, const T2 &b)
Performs a saturating subtract clamped at 0.
#define CRYPTOPP_ASSERT(exp)
virtual HashTransformation * NewHash() const =0
void * memcpy(void *a, const void *b, size_t c)
std::vector< char * > parameters
virtual MaskGeneratingFunction * NewMGF() const =0
Interface for retrieving values given their names.