diff options
author | lloyd <[email protected]> | 2014-03-22 19:16:24 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-03-22 19:16:24 +0000 |
commit | 8ce4a125a6eaf012821852ce629ead2466a2fde8 (patch) | |
tree | 2902f436b55e22fecf31be72467f44477ed49f57 /src/lib/rng/hmac_rng/hmac_rng.cpp | |
parent | 6b043baa4f421e9d00272f3e0d93b7e40cac6b77 (diff) |
Simpify HMAC_RNG reseeding process. Actually update HMAC_DRBG reseed counter.
Diffstat (limited to 'src/lib/rng/hmac_rng/hmac_rng.cpp')
-rw-r--r-- | src/lib/rng/hmac_rng/hmac_rng.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/rng/hmac_rng/hmac_rng.cpp b/src/lib/rng/hmac_rng/hmac_rng.cpp index 98ae6439e..7d8b54e84 100644 --- a/src/lib/rng/hmac_rng/hmac_rng.cpp +++ b/src/lib/rng/hmac_rng/hmac_rng.cpp @@ -128,7 +128,15 @@ void HMAC_RNG::reseed(size_t poll_bits) a bad poll doesn't wipe us out. */ - Entropy_Accumulator_BufferedComputation accum(*m_extractor, poll_bits); + double bits_collected = 0; + + Entropy_Accumulator accum( + [&](const byte in[], size_t in_len, double entropy_estimate) + { + m_extractor->update(in, in_len); + bits_collected += entropy_estimate; + return (bits_collected >= poll_bits); + }); global_state().poll_available_sources(accum); @@ -162,8 +170,8 @@ void HMAC_RNG::reseed(size_t poll_bits) m_counter = 0; m_collected_entropy_estimate = - std::min(m_collected_entropy_estimate + accum.bits_collected(), - m_extractor->output_length() * 8); + std::min<size_t>(m_collected_entropy_estimate + bits_collected, + m_extractor->output_length() * 8); m_output_since_reseed = 0; } |