diff options
-rw-r--r-- | src/cli/cli.h | 2 | ||||
-rw-r--r-- | src/cli/speed.cpp | 14 | ||||
-rw-r--r-- | src/tests/test_entropy.cpp | 6 |
3 files changed, 12 insertions, 10 deletions
diff --git a/src/cli/cli.h b/src/cli/cli.h index c2609bc55..11cc8add7 100644 --- a/src/cli/cli.h +++ b/src/cli/cli.h @@ -443,7 +443,7 @@ class Command while(in.good()) { in.read(reinterpret_cast<char*>(buf.data()), buf.size()); - consumer_fn(buf.data(), in.gcount()); + consumer_fn(buf.data(), static_cast<size_t>(in.gcount())); } } diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp index ffe10844e..c767b2a55 100644 --- a/src/cli/speed.cpp +++ b/src/cli/speed.cpp @@ -597,13 +597,14 @@ class Speed final : public Command for(auto src : srcs.enabled_sources()) { - size_t entropy_bits = 0, samples = 0; + double entropy_bits = 0.0; + size_t samples = 0; std::vector<size_t> entropy; Botan::Entropy_Accumulator accum( - [&](const uint8_t buf[], size_t buf_len, size_t buf_entropy) -> bool { - entropy.insert(entropy.end(), buf, buf + buf_len); - entropy_bits += buf_entropy; + [&](const uint8_t buf[], size_t buf_len, double buf_entropy) -> bool { + entropy.insert(entropy.end(), buf, buf + buf_len); + entropy_bits += buf_entropy; samples += 1; return (samples > 1024 || entropy_bits > 1024 || clock::now() > deadline); }); @@ -623,8 +624,9 @@ class Speed final : public Command } #endif - output() << "Entropy source " << src << " output " << entropy.size() - << " bytes in " << timer.milliseconds() << " ms"; + output() << "Entropy source " << src << " output " << entropy.size() << " bytes" + << " estimated entropy " << entropy_bits + << " in " << timer.milliseconds() << " ms"; #if defined(BOTAN_HAS_COMPRESSION) if(compressed.size() > 0) diff --git a/src/tests/test_entropy.cpp b/src/tests/test_entropy.cpp index 201dd02b5..406dc7c41 100644 --- a/src/tests/test_entropy.cpp +++ b/src/tests/test_entropy.cpp @@ -40,10 +40,10 @@ class Entropy_Source_Tests : public Test { std::vector<uint8_t> entropy; size_t samples = 0; - size_t entropy_estimate = 0; + double entropy_estimate = 0.0; Botan::Entropy_Accumulator accum( - [&](const uint8_t buf[], size_t buf_len, size_t buf_entropy) -> bool { + [&](const uint8_t buf[], size_t buf_len, double buf_entropy) -> bool { entropy.insert(entropy.end(), buf, buf + buf_len); entropy_estimate += buf_entropy; ++samples; @@ -93,7 +93,7 @@ class Entropy_Source_Tests : public Test comp1_size = compressed.size(); result.test_gte(comp_algo + " compressed entropy better than advertised", - compressed.size() * 8, entropy_estimate); + compressed.size() * 8, static_cast<size_t>(entropy_estimate)); } catch(std::exception& e) { |