aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_stream.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-11-26 11:38:01 -0500
committerJack Lloyd <[email protected]>2016-11-26 11:38:01 -0500
commit345f0881bc44b7a8344ea943e96b1dad4a8d484b (patch)
treed7d30b2e13abe660713eafed3e034ebf1494e7f8 /src/tests/test_stream.cpp
parentd695dfadc0daf8290d344f82697d456fd011d153 (diff)
Add test for various functions previously missed (T::clone, PBKDF::name, AEAD::output_length)
Fix a bug in CCM, GCM, and OCB decryption which caused `output_length(tag_size())` to fail even though empty plaintexts are certainly defined for all three modes.
Diffstat (limited to 'src/tests/test_stream.cpp')
-rw-r--r--src/tests/test_stream.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/tests/test_stream.cpp b/src/tests/test_stream.cpp
index d53777593..0af0be12c 100644
--- a/src/tests/test_stream.cpp
+++ b/src/tests/test_stream.cpp
@@ -47,7 +47,7 @@ class Stream_Cipher_Tests : public Text_Based_Test
if(!cipher)
{
- result.note_missing(algo + " from " + provider_ask);
+ result.test_failure("Stream " + algo + " supported by " + provider_ask + " but not found");
continue;
}
@@ -58,6 +58,8 @@ class Stream_Cipher_Tests : public Text_Based_Test
if(nonce.size())
{
+ if(!cipher->valid_iv_length(nonce.size()))
+ throw Test_Error("Invalid nonce for " + algo);
cipher->set_iv(nonce.data(), nonce.size());
}
else
@@ -67,12 +69,20 @@ class Stream_Cipher_Tests : public Text_Based_Test
* null/empty nonce. Call set_iv with such a nonce to make sure
* set_iv accepts it.
*/
+ if(!cipher->valid_iv_length(0))
+ throw Test_Error("Stream cipher " + algo + " requires nonce but none provided");
cipher->set_iv(nullptr, 0);
}
if (seek != 0)
cipher->seek(seek);
+ // Test that clone works and does not affect parent object
+ std::unique_ptr<Botan::StreamCipher> clone(cipher->clone());
+ result.confirm("Clone has different pointer", cipher.get() != clone.get());
+ result.test_eq("Clone has same name", cipher->name(), clone->name());
+ clone->set_key(Test::rng().random_vec(cipher->maximum_keylength()));
+
std::vector<uint8_t> buf = input;
cipher->encrypt(buf);