aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_modes.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-12-29 11:01:44 -0500
committerJack Lloyd <[email protected]>2017-12-29 11:01:44 -0500
commit994db72e812421cd1c81f93ce43625d3dcd551e2 (patch)
treebf5f1d5d51a18c90c83056eb8923509d405cdcf8 /src/tests/test_modes.cpp
parentaec291d6b487c96dea4bb29de6273101710d3e1c (diff)
Check that Cipher_Mode::start with invalid nonce size throws
Diffstat (limited to 'src/tests/test_modes.cpp')
-rw-r--r--src/tests/test_modes.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/tests/test_modes.cpp b/src/tests/test_modes.cpp
index f66a50220..ea773c22b 100644
--- a/src/tests/test_modes.cpp
+++ b/src/tests/test_modes.cpp
@@ -74,6 +74,12 @@ class Cipher_Mode_Tests final : public Text_Based_Test
result.test_eq("output_length", dec->output_length(expected.size()), input.size());
}
+ // Test that disallowed nonce sizes result in an exception
+ const size_t large_nonce_size = 65000;
+ result.test_eq("Large nonce not allowed", enc->valid_nonce_length(large_nonce_size), false);
+ result.test_throws("Large nonce causes exception",
+ [&enc]() { enc->start(nullptr, large_nonce_size); });
+
// Test to make sure reset() resets what we need it to
enc->set_key(mutate_vec(key));
Botan::secure_vector<uint8_t> garbage = Test::rng().random_vec(enc->update_granularity());