diff options
author | lloyd <[email protected]> | 2009-01-27 06:27:40 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-01-27 06:27:40 +0000 |
commit | 092c6d68006a2d953d8b622ce2c181a6394aed4e (patch) | |
tree | b10582379b69bd2cd4e4af0b66597342f0d28b72 /src/rng | |
parent | 497e3656c1141098ab76dc0fb7922e9e9d5b6bc8 (diff) |
Have Entropy_Accumulator dump everything into a BufferedComputation.
Since both Randpool and HMAC_RNG fed the input into a MAC anyway, this
works nicely. (It would be nicer to use tr1::function but, argh, don't
want to fully depend on TR1 quite yet. C++0x cannot come soon enough).
This avoids requiring to do run length encoding, it just dumps everything
as-is into the MAC. This ensures the buffer is not a potential narrow pipe
for the entropy (for instance, one might imagine an entropy source which
outputs one random byte every 16 bytes, and the rest some repeating pattern -
using a 16 byte buffer, you would only get 8 bits of entropy total, no matter
how many times you sampled).
Diffstat (limited to 'src/rng')
-rw-r--r-- | src/rng/hmac_rng/hmac_rng.cpp | 4 | ||||
-rw-r--r-- | src/rng/randpool/randpool.cpp | 4 |
2 files changed, 3 insertions, 5 deletions
diff --git a/src/rng/hmac_rng/hmac_rng.cpp b/src/rng/hmac_rng/hmac_rng.cpp index f495dda4d..ffdfdc60d 100644 --- a/src/rng/hmac_rng/hmac_rng.cpp +++ b/src/rng/hmac_rng/hmac_rng.cpp @@ -69,7 +69,7 @@ void HMAC_RNG::reseed_with_input(u32bit poll_bits, feedback of the current PRK value, into the extractor function. */ - Entropy_Accumulator accum(poll_bits); + Entropy_Accumulator accum(*extractor, poll_bits); for(u32bit i = 0; i < entropy_sources.size(); ++i) { @@ -83,8 +83,6 @@ void HMAC_RNG::reseed_with_input(u32bit poll_bits, if(input_length) accum.add(input, input_length, 1); - extractor->update(accum.get_entropy_buffer()); - /* It is necessary to feed forward poll data. Otherwise, a good poll (collecting a large amount of conditional entropy) followed by a diff --git a/src/rng/randpool/randpool.cpp b/src/rng/randpool/randpool.cpp index 1a111e20e..41a8ca23a 100644 --- a/src/rng/randpool/randpool.cpp +++ b/src/rng/randpool/randpool.cpp @@ -101,7 +101,7 @@ void Randpool::mix_pool() */ void Randpool::reseed(u32bit poll_bits) { - Entropy_Accumulator accum(poll_bits); + Entropy_Accumulator accum(*mac, poll_bits); for(u32bit i = 0; i != entropy_sources.size(); ++i) { @@ -111,7 +111,7 @@ void Randpool::reseed(u32bit poll_bits) break; } - SecureVector<byte> mac_val = mac->process(accum.get_entropy_buffer()); + SecureVector<byte> mac_val = mac->final(); xor_buf(pool, mac_val, mac_val.size()); mix_pool(); |