aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-10-25 11:03:04 -0400
committerJack Lloyd <[email protected]>2017-10-25 11:03:04 -0400
commit056fc571a26012587e0411950f038d5c81aaf2b4 (patch)
treebd3ed99c82f70cf01618e2d22172c80a28647eb7 /src
parentb3755350c7fde9cfa7c2fa5c3f1bf3b09388132e (diff)
Round block cipher buffer sizes to multiple of block size
Previously --buf-size was taken as a multiple of the block size, ie --buf-size=5 tested over 5 blocks (rather than 5 bytes, as the output claimed.)
Diffstat (limited to 'src')
-rw-r--r--src/cli/speed.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp
index 9539e22ec..fa8a09fd7 100644
--- a/src/cli/speed.cpp
+++ b/src/cli/speed.cpp
@@ -989,9 +989,19 @@ class Speed final : public Command
const Botan::SymmetricKey key(rng(), cipher.maximum_keylength());
ks_timer.run([&]() { cipher.set_key(key); });
- for(auto buf_size : buf_sizes)
+ const size_t bs = cipher.block_size();
+ std::set<size_t> buf_sizes_in_blocks;
+ for(size_t buf_size : buf_sizes)
+ {
+ if(buf_size % bs == 0)
+ buf_sizes_in_blocks.insert(buf_size);
+ else
+ buf_sizes_in_blocks.insert(buf_size + bs - (buf_size % bs));
+ }
+
+ for(size_t buf_size : buf_sizes_in_blocks)
{
- std::vector<uint8_t> buffer(buf_size * cipher.block_size());
+ std::vector<uint8_t> buffer(buf_size);
Timer encrypt_timer(cipher.name(), buffer.size(), "encrypt", provider, buf_size);
Timer decrypt_timer(cipher.name(), buffer.size(), "decrypt", provider, buf_size);