summaryrefslogtreecommitdiff
path: root/cryptlib.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cryptlib.cpp')
-rw-r--r--cryptlib.cpp18
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;