diff --git a/datatest.cpp b/datatest.cpp index afec7d20..9468b480 100644 --- a/datatest.cpp +++ b/datatest.cpp @@ -94,19 +94,6 @@ void RandomizedTransfer(BufferedTransformation &source, BufferedTransformation & } } -void RandomizedTransfer(std::string &source, BufferedTransformation &target, bool finish, const std::string &channel=DEFAULT_CHANNEL) -{ - StringStore store(source); - while (store.MaxRetrievable() > (finish ? 0 : 4096)) - { - byte buf[4096+64]; - size_t start = Test::GlobalRNG().GenerateWord32(0, 63); - size_t len = Test::GlobalRNG().GenerateWord32(1, UnsignedMin(4096U, 3*store.MaxRetrievable()/2)); - len = store.Get(buf+start, len); - target.ChannelPut(channel, buf+start, len); - } -} - void PutDecodedDatumInto(const TestData &data, const char *name, BufferedTransformation &target) { std::string s1 = GetRequiredDatum(data, name), s2; @@ -502,6 +489,7 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) xorbuf(reinterpret_cast(&keybuf[0]), reinterpret_cast(&encrypted[0]), keybuf.size()); cipher->SetKey(reinterpret_cast(&keybuf[0]), keybuf.size()); } + encrypted.assign(buf.begin(), buf.end()); ciphertext = GetDecodedDatum(v, test == "EncryptionMCT" ? "Ciphertext" : "Plaintext"); if (encrypted != ciphertext) @@ -518,12 +506,14 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) StreamTransformationFilter encFilter(*encryptor, new StringSink(encrypted), static_cast(paddingScheme)); - // StringStore pstore(plaintext); - RandomizedTransfer(plaintext, encFilter, true); + StringStore pstore(plaintext); + RandomizedTransfer(pstore, encFilter, true); encFilter.MessageEnd(); if (test != "EncryptXorDigest") + { ciphertext = GetDecodedDatum(v, "Ciphertext"); + } else { ciphertextXorDigest = GetDecodedDatum(v, "CiphertextXorDigest"); @@ -544,8 +534,8 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) StreamTransformationFilter decFilter(*decryptor, new StringSink(decrypted), static_cast(paddingScheme)); - // StringStore cstore(encrypted); - RandomizedTransfer(encrypted, decFilter, true); + StringStore cstore(encrypted); + RandomizedTransfer(cstore, decFilter, true); decFilter.MessageEnd(); if (decrypted != plaintext) @@ -556,8 +546,6 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) std::cout << "\n"; SignalTestFailure(); } - - encrypted.clear(); decrypted.clear(); } else { diff --git a/test.cpp b/test.cpp index 654b4256..94aba161 100644 --- a/test.cpp +++ b/test.cpp @@ -125,11 +125,7 @@ ANONYMOUS_NAMESPACE_BEGIN #if (CRYPTOPP_USE_AES_GENERATOR) OFB_Mode::Encryption s_globalRNG; #else -# if defined(CRYPTOPP_WIN32_AVAILABLE) NonblockingRng s_globalRNG; -# else -BlockingRng s_globalRNG; -# endif #endif NAMESPACE_END