diff options
| author | Jeffrey Walton <noloader@gmail.com> | 2017-05-04 19:11:24 -0400 |
|---|---|---|
| committer | Jeffrey Walton <noloader@gmail.com> | 2017-05-04 19:11:24 -0400 |
| commit | 5c1de7b5a5676a136e00eb2c2a8fcc18aded5bb9 (patch) | |
| tree | c88d146217f3f3d22b71b8c395824f25152dfe2b /datatest.cpp | |
| parent | 9614307ab7f4a4a420b665ac6c798d80c96cdaad (diff) | |
| download | cryptopp-git-5c1de7b5a5676a136e00eb2c2a8fcc18aded5bb9.tar.gz | |
Add variable block size support to test and benchmarks
CRYPTOPP_COVERAGE was added at 9614307ab7f4a4a4 to increase code coverage support. This commit enables additional validation routines when CRYPTOPP_COVERAGE is in effect.
Diffstat (limited to 'datatest.cpp')
| -rw-r--r-- | datatest.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/datatest.cpp b/datatest.cpp index 90c6a1df..94a45149 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 == "EncryptXorDigest" || test == "Resync" || test == "EncryptionMCT" || test == "DecryptionMCT")
+ if (test == "Encrypt" || test == "EncryptBlockSize" || test == "EncryptXorDigest" || test == "Resync" || test == "EncryptionMCT" || test == "DecryptionMCT")
{
static member_ptr<SymmetricCipher> encryptor, decryptor;
static std::string lastName;
@@ -375,8 +375,12 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) lastName = name;
}
+ int blockSize = 0;
+ if (test == "EncryptBlockSize" && !pairs.GetValue(Name::BlockSize(), blockSize))
+ SignalTestFailure();
+
ConstByteArrayParameter iv;
- if (pairs.GetValue(Name::IV(), iv) && iv.size() != encryptor->IVSize())
+ if (pairs.GetValue(Name::IV(), iv) && iv.size() != encryptor->IVSize() && iv.size() != blockSize)
SignalTestFailure();
if (test == "Resync")
@@ -427,7 +431,7 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) ciphertext = GetDecodedDatum(v, test == "EncryptionMCT" ? "Ciphertext" : "Plaintext");
if (encrypted != ciphertext)
{
- std::cout << "incorrectly encrypted: ";
+ std::cout << "\nincorrectly encrypted: ";
StringSource xx(encrypted, false, new HexEncoder(new FileSink(std::cout)));
xx.Pump(256); xx.Flush(false);
std::cout << "\n";
@@ -459,7 +463,7 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) }
if (test != "EncryptXorDigest" ? encrypted != ciphertext : xorDigest != ciphertextXorDigest)
{
- std::cout << "incorrectly encrypted: ";
+ std::cout << "\nincorrectly encrypted: ";
StringSource xx(encrypted, false, new HexEncoder(new FileSink(std::cout)));
xx.Pump(2048); xx.Flush(false);
std::cout << "\n";
@@ -471,7 +475,7 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) decFilter.MessageEnd();
if (decrypted != plaintext)
{
- std::cout << "incorrectly decrypted: ";
+ std::cout << "\nincorrectly decrypted: ";
StringSource xx(decrypted, false, new HexEncoder(new FileSink(std::cout)));
xx.Pump(256); xx.Flush(false);
std::cout << "\n";
@@ -480,7 +484,7 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) }
else
{
- std::cout << "unexpected test name\n";
+ std::cout << "\nunexpected test name\n";
SignalTestError();
}
}
@@ -538,7 +542,7 @@ void TestAuthenticatedSymmetricCipher(TestData &v, const NameValuePairs &overrid if (test == "Encrypt" && encrypted != ciphertext+mac)
{
- std::cout << "incorrectly encrypted: ";
+ std::cout << "\nincorrectly encrypted: ";
StringSource xx(encrypted, false, new HexEncoder(new FileSink(std::cout)));
xx.Pump(2048); xx.Flush(false);
std::cout << "\n";
@@ -546,7 +550,7 @@ void TestAuthenticatedSymmetricCipher(TestData &v, const NameValuePairs &overrid }
if (test == "Encrypt" && decrypted != plaintext)
{
- std::cout << "incorrectly decrypted: ";
+ std::cout << "\nincorrectly decrypted: ";
StringSource xx(decrypted, false, new HexEncoder(new FileSink(std::cout)));
xx.Pump(256); xx.Flush(false);
std::cout << "\n";
@@ -555,18 +559,18 @@ void TestAuthenticatedSymmetricCipher(TestData &v, const NameValuePairs &overrid if (ciphertext.size()+mac.size()-plaintext.size() != asc1->DigestSize())
{
- std::cout << "bad MAC size\n";
+ std::cout << "\nbad MAC size\n";
SignalTestFailure();
}
if (df.GetLastResult() != (test == "Encrypt"))
{
- std::cout << "MAC incorrectly verified\n";
+ std::cout << "\nMAC incorrectly verified\n";
SignalTestFailure();
}
}
else
{
- std::cout << "unexpected test name\n";
+ std::cout << "\nunexpected test name\n";
SignalTestError();
}
}
|
