diff options
author | weidai <weidai11@users.noreply.github.com> | 2010-06-18 01:18:22 +0000 |
---|---|---|
committer | weidai <weidai11@users.noreply.github.com> | 2010-06-18 01:18:22 +0000 |
commit | 8af9520702f19e037458d3059ee0fafef2643875 (patch) | |
tree | 8011b0f0ccb51f655eb7ef93a34d39ecf8747370 /pubkey.cpp | |
parent | 0980f652669124cce6b5840380ebe9a4ffaea39f (diff) | |
download | cryptopp-git-8af9520702f19e037458d3059ee0fafef2643875.tar.gz |
check ciphertext length in TF_DecryptorBase::Decrypt()
Diffstat (limited to 'pubkey.cpp')
-rw-r--r-- | pubkey.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -134,8 +134,11 @@ DecodingResult TF_VerifierBase::RecoverAndRestart(byte *recoveredMessage, PK_Mes DecodingResult TF_DecryptorBase::Decrypt(RandomNumberGenerator &rng, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs ¶meters) const { + if (ciphertextLength != FixedCiphertextLength()) + throw InvalidArgument(AlgorithmName() + ": ciphertext length of " + IntToString(ciphertextLength) + " doesn't match the required length of " + IntToString(FixedCiphertextLength()) + " for this key"); + SecByteBlock paddedBlock(PaddedBlockByteLength()); - Integer x = GetTrapdoorFunctionInterface().CalculateInverse(rng, Integer(ciphertext, FixedCiphertextLength())); + Integer x = GetTrapdoorFunctionInterface().CalculateInverse(rng, Integer(ciphertext, ciphertextLength)); if (x.ByteCount() > paddedBlock.size()) x = Integer::Zero(); // don't return false here to prevent timing attack x.Encode(paddedBlock, paddedBlock.size()); |