diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2009-03-03 03:28:39 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2009-03-03 03:28:39 +0000 |
commit | f1b1bf3d0dea2032f9ce5f9b3d29b7ed5d22a32a (patch) | |
tree | bbbd178df43bdc71503320cd87f5ec0c84c9d494 /cryptlib.cpp | |
parent | 94ee86bbf6d35476281a7012136e7c74c1693231 (diff) | |
download | cryptopp-f1b1bf3d0dea2032f9ce5f9b3d29b7ed5d22a32a.tar.gz |
tweaks/fixes for 5.6
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@435 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'cryptlib.cpp')
-rw-r--r-- | cryptlib.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cryptlib.cpp b/cryptlib.cpp index 1d0a002..b84a085 100644 --- a/cryptlib.cpp +++ b/cryptlib.cpp @@ -205,6 +205,24 @@ void AuthenticatedSymmetricCipher::SpecifyDataLengths(lword headerLength, lword UncheckedSpecifyDataLengths(headerLength, messageLength, footerLength); } +void AuthenticatedSymmetricCipher::EncryptAndAuthenticate(byte *ciphertext, byte *mac, size_t macSize, const byte *iv, int ivLength, const byte *header, size_t headerLength, const byte *message, size_t messageLength) +{ + Resynchronize(iv, ivLength); + SpecifyDataLengths(headerLength, messageLength); + Update(header, headerLength); + ProcessString(ciphertext, message, messageLength); + TruncatedFinal(mac, macSize); +} + +bool AuthenticatedSymmetricCipher::DecryptAndVerify(byte *message, const byte *mac, size_t macLength, const byte *iv, int ivLength, const byte *header, size_t headerLength, const byte *ciphertext, size_t ciphertextLength) +{ + Resynchronize(iv, ivLength); + SpecifyDataLengths(headerLength, ciphertextLength); + Update(header, headerLength); + ProcessString(message, ciphertext, ciphertextLength); + return TruncatedVerify(mac, macLength); +} + unsigned int RandomNumberGenerator::GenerateBit() { return GenerateByte() & 1; |