summaryrefslogtreecommitdiff
path: root/datatest.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-28 03:08:27 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-28 03:08:27 +0000
commitfcec4bd3021b0124d8a38c19246735340a0e1cd0 (patch)
treeedc665bb430df13f81c30b87dcc021223804c80a /datatest.cpp
parent56096382619053be6c753901ae3cf850606f3473 (diff)
downloadcryptopp-fcec4bd3021b0124d8a38c19246735340a0e1cd0.tar.gz
fix EC2N skipping of optional seed, switch to public domain MARS code, deliver vc80.pdb to OutDir
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@461 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'datatest.cpp')
-rw-r--r--datatest.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/datatest.cpp b/datatest.cpp
index d23d5d9..04b4e72 100644
--- a/datatest.cpp
+++ b/datatest.cpp
@@ -306,7 +306,7 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters)
TestDataNameValuePairs testDataPairs(v);
CombinedNameValuePairs pairs(overrideParameters, testDataPairs);
- if (test == "Encrypt" || test == "EncryptXorDigest" || test == "Resync")
+ if (test == "Encrypt" || test == "EncryptXorDigest" || test == "Resync" || test == "EncryptionMCT" || test == "DecryptionMCT")
{
static member_ptr<SymmetricCipher> encryptor, decryptor;
static std::string lastName;
@@ -339,7 +339,46 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters)
encryptor->Seek(seek);
decryptor->Seek(seek);
}
+
std::string encrypted, xorDigest, ciphertext, ciphertextXorDigest;
+ if (test == "EncryptionMCT" || test == "DecryptionMCT")
+ {
+ SymmetricCipher *cipher = encryptor.get();
+ SecByteBlock buf((byte *)plaintext.data(), plaintext.size()), keybuf((byte *)key.data(), key.size());
+
+ if (test == "DecryptionMCT")
+ {
+ cipher = decryptor.get();
+ ciphertext = GetDecodedDatum(v, "Ciphertext");
+ buf.Assign((byte *)ciphertext.data(), ciphertext.size());
+ }
+
+ for (int i=0; i<400; i++)
+ {
+ encrypted.reserve(10000 * plaintext.size());
+ for (int j=0; j<10000; j++)
+ {
+ cipher->ProcessString(buf.begin(), buf.size());
+ encrypted.append((char *)buf.begin(), buf.size());
+ }
+
+ encrypted.erase(0, encrypted.size() - keybuf.size());
+ xorbuf(keybuf.begin(), (const byte *)encrypted.data(), keybuf.size());
+ cipher->SetKey(keybuf, keybuf.size());
+ }
+ encrypted.assign((char *)buf.begin(), buf.size());
+ ciphertext = GetDecodedDatum(v, test == "EncryptionMCT" ? "Ciphertext" : "Plaintext");
+ if (encrypted != ciphertext)
+ {
+ std::cout << "incorrectly encrypted: ";
+ StringSource xx(encrypted, false, new HexEncoder(new FileSink(std::cout)));
+ xx.Pump(256); xx.Flush(false);
+ std::cout << "\n";
+ SignalTestFailure();
+ }
+ return;
+ }
+
StringSource ss(plaintext, false, new StreamTransformationFilter(*encryptor, new StringSink(encrypted), StreamTransformationFilter::NO_PADDING));
ss.Pump(plaintext.size()/2 + 1);
ss.PumpAll();