From d1e5ce62e68c787da0af62280a95e3b3f3205ea3 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Fri, 29 Jan 2016 17:19:58 -0500 Subject: Fix buffer sizes in speed. Avoid repeated MAC keyings --- src/cli/speed.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp index 2db8e5128..28501f0c0 100644 --- a/src/cli/speed.cpp +++ b/src/cli/speed.cpp @@ -457,7 +457,7 @@ class Speed final : public Command const std::chrono::milliseconds runtime, size_t buf_size) { - Botan::secure_vector buffer = rng().random_vec(buf_size * 1024); + Botan::secure_vector buffer = rng().random_vec(buf_size); Timer encrypt_timer(cipher.name(), provider, "encrypt", buffer.size()); @@ -476,7 +476,7 @@ class Speed final : public Command const std::chrono::milliseconds runtime, size_t buf_size) { - Botan::secure_vector buffer = rng().random_vec(buf_size * 1024); + Botan::secure_vector buffer = rng().random_vec(buf_size); Timer timer(hash.name(), provider, "hash", buffer.size()); timer.run_until_elapsed(runtime, [&] { hash.update(buffer); }); @@ -488,17 +488,13 @@ class Speed final : public Command const std::chrono::milliseconds runtime, size_t buf_size) { - Botan::secure_vector buffer = rng().random_vec(buf_size * 1024); - - Timer timer(mac.name(), provider, "mac", buffer.size()); + Botan::secure_vector buffer = rng().random_vec(buf_size); - while(timer.under(runtime)) - { - const Botan::SymmetricKey key(rng(), mac.maximum_keylength()); - mac.set_key(key); - timer.run([&] { mac.update(buffer); }); - } + const Botan::SymmetricKey key(rng(), mac.maximum_keylength()); + mac.set_key(key); + Timer timer(mac.name(), provider, "mac", buffer.size()); + timer.run_until_elapsed(runtime, [&] { mac.update(buffer); }); output() << Timer::result_string_bps(timer); } @@ -545,7 +541,7 @@ class Speed final : public Command Botan::secure_vector buffer(buf_size); rng.add_entropy(buffer.data(), buffer.size()); - size_t bits = rng.reseed(256); + rng.reseed(256); Timer timer(rng_name, "", "generate", buffer.size()); timer.run_until_elapsed(runtime, [&] { rng.randomize(buffer.data(), buffer.size()); }); -- cgit v1.2.3