From f1b1bf3d0dea2032f9ce5f9b3d29b7ed5d22a32a Mon Sep 17 00:00:00 2001 From: weidai Date: Tue, 3 Mar 2009 03:28:39 +0000 Subject: tweaks/fixes for 5.6 git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@435 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- cryptlib.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'cryptlib.cpp') 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; -- cgit v1.2.1