diff options
author | Jack Lloyd <[email protected]> | 2016-07-01 08:46:10 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-07-17 10:43:41 -0400 |
commit | 4db84ab7e8a4328bca04966f77cae47712bbf427 (patch) | |
tree | 080414561b1d446b2950c4fc436bc206cf345996 /src/lib/rng | |
parent | 9e6013809d63f3365023e6047fa31865db4e556d (diff) |
Move poll logic to Entropy_Sources
Diffstat (limited to 'src/lib/rng')
-rw-r--r-- | src/lib/rng/rng.cpp | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/src/lib/rng/rng.cpp b/src/lib/rng/rng.cpp index 8144ac293..923b417dc 100644 --- a/src/lib/rng/rng.cpp +++ b/src/lib/rng/rng.cpp @@ -39,21 +39,7 @@ size_t RandomNumberGenerator::reseed_with_sources(Entropy_Sources& srcs, size_t poll_bits, std::chrono::milliseconds poll_timeout) { - typedef std::chrono::system_clock clock; - - auto deadline = clock::now() + poll_timeout; - - double bits_collected = 0; - - Entropy_Accumulator accum([&](const byte in[], size_t in_len, double entropy_estimate) { - add_entropy(in, in_len); - bits_collected += entropy_estimate; - return (bits_collected >= poll_bits || clock::now() > deadline); - }); - - srcs.poll(accum); - - return bits_collected; + return srcs.poll(*this, poll_bits, poll_timeout); } Stateful_RNG::Stateful_RNG(size_t bytes_before_reseed) : m_bytes_before_reseed(bytes_before_reseed) |