aboutsummaryrefslogtreecommitdiffstats
path: root/checks/bench.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-05-05 00:41:30 +0000
committerlloyd <[email protected]>2010-05-05 00:41:30 +0000
commit1bebe3df43f1f60ef64102ef808ce66f34f9a578 (patch)
treeebb3d0f61d91dcd9834e068dfd57109b94052f8f /checks/bench.cpp
parent1e10b45b171fde455d32ed34a3aafa0bf90f3b4e (diff)
Prevent crash if asked to benchmark unknown block cipher with a mode
(eg "NoSuchCipher/CBC")
Diffstat (limited to 'checks/bench.cpp')
-rw-r--r--checks/bench.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/checks/bench.cpp b/checks/bench.cpp
index cfb44070d..d3f9be391 100644
--- a/checks/bench.cpp
+++ b/checks/bench.cpp
@@ -179,10 +179,17 @@ bool bench_algo(const std::string& algo,
std::string cipher = algo_parts[0];
- u32bit cipher_keylen =
- af.prototype_block_cipher(cipher)->MAXIMUM_KEYLENGTH;
- u32bit cipher_ivlen =
- af.prototype_block_cipher(cipher)->BLOCK_SIZE;
+ const Botan::BlockCipher* proto_cipher =
+ af.prototype_block_cipher(cipher);
+
+ if(!proto_cipher)
+ {
+ std::cout << "Unknown algorithm " << cipher << "\n";
+ return false;
+ }
+
+ u32bit cipher_keylen = proto_cipher->MAXIMUM_KEYLENGTH;
+ u32bit cipher_ivlen = proto_cipher->BLOCK_SIZE;
if(algo_parts[1] == "XTS")
cipher_keylen *= 2; // hack!