aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-06-16 14:28:40 +0000
committerlloyd <[email protected]>2010-06-16 14:28:40 +0000
commit4ec179fa73b94d940138e0862a7025d815aa831e (patch)
treec75751258517c0b9e3158f878851a70d02fd2248 /src
parent64301bf302c486e454f9dae112f581cfc5ca2294 (diff)
In the cipher KAT selftest, query if the IV length we got was
supported before setting it. If it's not, then check if a 0 length IV is supported (eg, ECB mode). If neither is true, throw Invalid_IV_Length.
Diffstat (limited to 'src')
-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);