aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-12-29 10:59:22 -0500
committerJack Lloyd <[email protected]>2017-12-29 10:59:22 -0500
commitaec291d6b487c96dea4bb29de6273101710d3e1c (patch)
tree42a8c2891705593a5221e217b91be37c780f5ac0
parent133237c08df7f679091a99c529fe6b97c6692c78 (diff)
Test output_length of cipher modes
-rw-r--r--src/tests/test_modes.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/tests/test_modes.cpp b/src/tests/test_modes.cpp
index 74e1b3da3..f66a50220 100644
--- a/src/tests/test_modes.cpp
+++ b/src/tests/test_modes.cpp
@@ -61,6 +61,19 @@ class Cipher_Mode_Tests final : public Text_Based_Test
result.test_eq("mode not authenticated", enc->authenticated(), false);
+ if(algo.find("/CBC"))
+ {
+ // can't test equal due to CBC padding
+ result.test_lte("output_length", enc->output_length(input.size()), expected.size());
+ result.test_gte("output_length", dec->output_length(expected.size()), input.size());
+ }
+ else
+ {
+ // assume all other modes are not expanding (currently true)
+ result.test_eq("output_length", enc->output_length(input.size()), expected.size());
+ result.test_eq("output_length", dec->output_length(expected.size()), input.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());