aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/selftest/selftest.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/selftest/selftest.cpp b/src/selftest/selftest.cpp
index 215569cbb..93af4f1b7 100644
--- a/src/selftest/selftest.cpp
+++ b/src/selftest/selftest.cpp
@@ -49,8 +49,9 @@ algorithm_kat(const SCAN_Name& algo_name,
const std::string input = search_map(vars, std::string("input"));
const std::string output = search_map(vars, std::string("output"));
- const std::string key = search_map(vars, std::string("key"));
- const std::string iv = search_map(vars, std::string("iv"));
+
+ SymmetricKey key(search_map(vars, std::string("key")));
+ InitializationVector iv(search_map(vars, std::string("iv")));
for(u32bit i = 0; i != providers.size(); ++i)
{
@@ -96,10 +97,18 @@ algorithm_kat(const SCAN_Name& algo_name,
}
enc->set_key(key);
- enc->set_iv(iv);
+
+ if(enc->valid_iv_length(iv.length()))
+ enc->set_iv(iv);
+ else if(!enc->valid_iv_length(0))
+ throw Invalid_IV_Length(algo, iv.length());
dec->set_key(key);
- dec->set_iv(iv);
+
+ if(dec->valid_iv_length(iv.length()))
+ dec->set_iv(iv);
+ else if(!dec->valid_iv_length(0))
+ throw Invalid_IV_Length(algo, iv.length());
bool enc_ok = test_filter_kat(enc, input, output);
bool dec_ok = test_filter_kat(dec, output, input);