6 #ifndef CRYPTOPP_IMPORTS 18 word32 counter = counterStart;
21 filter.
Put(input, inputLength);
23 filter.
Put(derivationParams, derivationParamsLength);
30 byte *representative,
size_t representativeBitLength)
const 34 return VerifyBufsEqual(representative, computedRepresentative, computedRepresentative.
size());
39 byte *representative,
size_t representativeBitLength)
const 43 hash, hashIdentifier, messageEmpty, representative, representativeBitLength, recoveredMessage);
58 if (maxRecoverableLength == 0)
59 {
throw NotImplemented(
"TF_SignerBase: this algorithm does not support message recovery or the key is too short");}
60 if (recoverableMessageLength > maxRecoverableLength)
61 throw InvalidArgument(
"TF_SignerBase: the recoverable message part is too long for the given key and algorithm");
66 recoverableMessage, recoverableMessageLength,
81 SecByteBlock representative(MessageRepresentativeLength());
85 representative, MessageRepresentativeBitLength());
89 size_t signatureLength = SignatureLength();
90 GetTrapdoorFunctionInterface().CalculateRandomizedInverse(rng, r).Encode(signature, signatureLength);
91 return signatureLength;
104 Integer x = GetTrapdoorFunctionInterface().ApplyFunction(
Integer(signature, signatureLength));
105 if (x.
BitCount() > MessageRepresentativeBitLength())
142 if (ciphertextLength != FixedCiphertextLength())
143 throw InvalidArgument(AlgorithmName() +
": ciphertext length of " +
IntToString(ciphertextLength) +
" doesn't match the required length of " +
IntToString(FixedCiphertextLength()) +
" for this key");
146 Integer x = GetTrapdoorFunctionInterface().CalculateInverse(rng,
Integer(ciphertext, ciphertextLength));
150 return GetMessageEncodingInterface().Unpad(paddedBlock, PaddedBlockBitLength(), plaintext, parameters);
155 if (plaintextLength > FixedMaxPlaintextLength())
157 if (FixedMaxPlaintextLength() < 1)
158 throw InvalidArgument(AlgorithmName() +
": this key is too short to encrypt any messages");
160 throw InvalidArgument(AlgorithmName() +
": message length of " +
IntToString(plaintextLength) +
" exceeds the maximum of " +
IntToString(FixedMaxPlaintextLength()) +
" for this public key");
164 GetMessageEncodingInterface().Pad(rng, plaintext, plaintextLength, paddedBlock, PaddedBlockBitLength(), parameters);
165 GetTrapdoorFunctionInterface().ApplyRandomizedFunction(rng,
Integer(paddedBlock, paddedBlock.
size())).Encode(ciphertext, FixedCiphertextLength());
An invalid argument was detected.
bool VerifyAndRestart(PK_MessageAccumulator &messageAccumulator) const
Check whether messageAccumulator contains a valid signature and message, and restart messageAccumulat...
void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const byte *recoverableMessage, size_t recoverableMessageLength) const
Input a recoverable message to an accumulator.
void Encode(byte *output, size_t outputLen, Signedness sign=UNSIGNED) const
Encode in big-endian format.
virtual bool VerifyMessageRepresentative(HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, byte *representative, size_t representativeBitLength) const =0
size_t BitsToBytes(size_t bitCount)
Returns the number of 8-bit bytes or octets required for the specified number of bits.
virtual DecodingResult RecoverMessageFromRepresentative(HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, byte *representative, size_t representativeBitLength, byte *recoveredMessage) const
DecodingResult RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &recoveryAccumulator) const
Recover a message from its signature.
virtual size_t MinRepresentativeBitLength(size_t hashIdentifierLength, size_t digestLength) const
SecByteBlock m_recoverableMessage
#define NAMESPACE_BEGIN(x)
virtual void ProcessRecoverableMessage(HashTransformation &hash, const byte *recoverableMessage, size_t recoverableMessageLength, const byte *presignature, size_t presignatureLength, SecByteBlock &semisignature) const
Interface for message encoding method for public key signature schemes.
size_type size() const
Provides the count of elements in the SecBlock.
virtual void ComputeMessageRepresentative(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, byte *representative, size_t representativeBitLength) const =0
Library configuration file.
Interface for random number generators.
size_t messageLength
Recovered message length if isValidCoding is true, undefined otherwise.
void New(size_type newSize)
Change size without preserving contents.
virtual size_t MaxRecoverableLength(size_t representativeBitLength, size_t hashIdentifierLength, size_t digestLength) const
void Encrypt(RandomNumberGenerator &rng, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs ¶meters=g_nullNameValuePairs) const
Encrypt a byte string.
unsigned int BitCount() const
Determines the number of bits required to represent the Integer.
Copy input to a memory buffer.
Returns a decoding results.
Xor input to a memory buffer.
A method was called which was not implemented.
Filter wrapper for HashTransformation.
Exception throw when the private or public key is too short to sign or verify.
void P1363_MGF1KDF2_Common(HashTransformation &hash, byte *output, size_t outputLength, const byte *input, size_t inputLength, const byte *derivationParams, size_t derivationParamsLength, bool mask, unsigned int counterStart)
size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart=true) const
Sign and restart messageAccumulator.
Interface for message encoding method for public key signature schemes.
void Assign(const T *ptr, size_type len)
Set contents and size from an array.
Multiple precision integer with arithmetic operations.
size_t AvailableSize()
Provides the size remaining in the Sink.
virtual HashTransformation & AccessHash()=0
Implementation of BufferedTransformation's attachment interface.
Interface for accumulating messages to be signed or verified.
bool VerifyMessageRepresentative(HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, byte *representative, size_t representativeBitLength) const
#define CRYPTOPP_UNUSED(x)
RandomNumberGenerator & NullRNG()
Random Number Generator that does not produce random numbers.
SecByteBlock m_representative
std::string IntToString(T value, unsigned int base=10)
Converts a value to a string.
Multiple precision integer with arithmetic operations.
static const Integer &CRYPTOPP_API Zero()
Integer representing 0.
std::vector< char * > parameters
bool isValidCoding
Flag to indicate the decoding is valid.
std::pair< const byte *, unsigned int > HashIdentifier
bool VerifyMessageRepresentative(HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, byte *representative, size_t representativeBitLength) const
void InputSignature(PK_MessageAccumulator &messageAccumulator, const byte *signature, size_t signatureLength) const
Input signature into a message accumulator.
SecByteBlock m_semisignature
unsigned int ByteCount() const
Determines the number of bytes required to represent the Integer.
bool VerifyBufsEqual(const byte *buf, const byte *mask, size_t count)
Performs a near constant-time comparison of two equally sized buffers.
Interface for retrieving values given their names.
DecodingResult Decrypt(RandomNumberGenerator &rng, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs ¶meters=g_nullNameValuePairs) const
Decrypt a byte string.