summaryrefslogtreecommitdiff
path: root/datatest.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-05 08:53:50 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-05 08:53:50 +0000
commit77d342339b3149f02aaa3521a27b6216468d43dc (patch)
tree548b001016c5f93e2811ac4067c9b18ca36354e4 /datatest.cpp
parent15b0c807eb736f7f3800a514fc9a099466654ab9 (diff)
downloadcryptopp-77d342339b3149f02aaa3521a27b6216468d43dc.tar.gz
fix bug when AuthenticatedDecryptionFilter::MAC_AT_BEGIN is not specified
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@439 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'datatest.cpp')
-rw-r--r--datatest.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/datatest.cpp b/datatest.cpp
index 0ae50dd..a028244 100644
--- a/datatest.cpp
+++ b/datatest.cpp
@@ -397,7 +397,8 @@ void TestAuthenticatedSymmetricCipher(TestData &v, const NameValuePairs &overrid
std::string encrypted, decrypted;
AuthenticatedEncryptionFilter ef(*asc1, new StringSink(encrypted));
- AuthenticatedDecryptionFilter df(*asc2, new StringSink(decrypted), AuthenticatedDecryptionFilter::MAC_AT_BEGIN);
+ bool macAtBegin = !GlobalRNG().GenerateBit(); // test both ways randomly
+ AuthenticatedDecryptionFilter df(*asc2, new StringSink(decrypted), macAtBegin ? AuthenticatedDecryptionFilter::MAC_AT_BEGIN : 0);
if (asc1->NeedsPrespecifiedDataLengths())
{
@@ -407,10 +408,13 @@ void TestAuthenticatedSymmetricCipher(TestData &v, const NameValuePairs &overrid
StringStore sh(header), sp(plaintext), sc(ciphertext), sf(footer), sm(mac);
- sm.TransferTo(df);
+ if (macAtBegin)
+ sm.TransferTo(df);
sh.CopyTo(df, LWORD_MAX, "AAD");
sc.TransferTo(df);
sf.CopyTo(df, LWORD_MAX, "AAD");
+ if (!macAtBegin)
+ sm.TransferTo(df);
df.MessageEnd();
sh.TransferTo(ef, sh.MaxRetrievable()/2+1, "AAD");