aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-01-29 17:19:58 -0500
committerJack Lloyd <[email protected]>2016-01-29 17:19:58 -0500
commitd1e5ce62e68c787da0af62280a95e3b3f3205ea3 (patch)
tree5fa39ca1c519531f7840a6dda61f50978fc52eac
parentc811650072534165ccf3c79cd4da81ffe0612cd0 (diff)
Fix buffer sizes in speed. Avoid repeated MAC keyings
-rw-r--r--src/cli/speed.cpp20
1 files 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<uint8_t> buffer = rng().random_vec(buf_size * 1024);
+ Botan::secure_vector<uint8_t> 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<uint8_t> buffer = rng().random_vec(buf_size * 1024);
+ Botan::secure_vector<uint8_t> 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<uint8_t> buffer = rng().random_vec(buf_size * 1024);
-
- Timer timer(mac.name(), provider, "mac", buffer.size());
+ Botan::secure_vector<uint8_t> 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<uint8_t> 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()); });