diff options
author | lloyd <[email protected]> | 2010-05-05 00:41:30 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-05-05 00:41:30 +0000 |
commit | 1bebe3df43f1f60ef64102ef808ce66f34f9a578 (patch) | |
tree | ebb3d0f61d91dcd9834e068dfd57109b94052f8f /checks | |
parent | 1e10b45b171fde455d32ed34a3aafa0bf90f3b4e (diff) |
Prevent crash if asked to benchmark unknown block cipher with a mode
(eg "NoSuchCipher/CBC")
Diffstat (limited to 'checks')
-rw-r--r-- | checks/bench.cpp | 15 |
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! |