From 0de44edde1d623388fff567bc69cefae884ceba0 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 10 May 2017 13:50:36 -0400 Subject: [PATCH] Remove EncryptBlockCipher The test mode EncryptBlockCipher is not needed. datatest.cpp is versatile enough to handle variable block sizes under test mode Encrypt --- TestVectors/Readme.txt | 1 - datatest.cpp | 7 +++---- regtest2.cpp | 1 + 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/TestVectors/Readme.txt b/TestVectors/Readme.txt index df33ee84..ec7a761f 100644 --- a/TestVectors/Readme.txt +++ b/TestVectors/Readme.txt @@ -82,6 +82,5 @@ NotVerify - signature/digest/MAC verification should not pass DeterministicSign - sign message using given seed, and the resulting signature should equal the given signature Encrypt - plaintext encrypts to ciphertext -EncryptBlockSize - plaintext encrypts to ciphertext under a key and blocksize DecryptMatch - ciphertext decrypts to plaintext (more to come here) diff --git a/datatest.cpp b/datatest.cpp index 95f7da3b..5289642c 100644 --- a/datatest.cpp +++ b/datatest.cpp @@ -363,7 +363,7 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) TestDataNameValuePairs testDataPairs(v); CombinedNameValuePairs pairs(overrideParameters, testDataPairs); - if (test == "Encrypt" || test == "EncryptBlockSize" || test == "EncryptXorDigest" || test == "Resync" || test == "EncryptionMCT" || test == "DecryptionMCT") + if (test == "Encrypt" || test == "EncryptXorDigest" || test == "Resync" || test == "EncryptionMCT" || test == "DecryptionMCT") { static member_ptr encryptor, decryptor; static std::string lastName; @@ -375,9 +375,8 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) lastName = name; } - int blockSize = 0; - if (test == "EncryptBlockSize" && !pairs.GetValue(Name::BlockSize(), blockSize)) - SignalTestFailure(); + // Most block ciphers don't specify this. Kalyna and Threefish use it. + int blockSize = pairs.GetIntValueWithDefault(Name::BlockSize(), 0); ConstByteArrayParameter iv; if (pairs.GetValue(Name::IV(), iv) && iv.size() != encryptor->IVSize() && (int)iv.size() != blockSize) diff --git a/regtest2.cpp b/regtest2.cpp index b5528869..0e9d3d2d 100644 --- a/regtest2.cpp +++ b/regtest2.cpp @@ -135,6 +135,7 @@ void RegisterFactories2() RegisterSymmetricCipherDefaultFactories >(); RegisterSymmetricCipherDefaultFactories >(); RegisterSymmetricCipherDefaultFactories >(); // Test Vectors + RegisterSymmetricCipherDefaultFactories >(); // Test Vectors RegisterSymmetricCipherDefaultFactories >(); // Benchmarks RegisterDefaultFactoryFor >();