From d0c2f90af8df600204636a701f8f279c17d6959c Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 27 Oct 2008 17:05:12 +0000 Subject: Substantially change Randpool's reseed logic. Now when a reseed is requested, Randpool will first do a fast poll on each entropy source that has been registered. It will count these poll results towards the collected entropy count, with a maximum of 96 contributed bits of entropy per poll (only /dev/random reaches this, others measure at 50-60 bits typically), and a maximum of 256 for sum contribution of the fast polls. Then it will attempt slow polls of all devices until it thinks enough entropy has been collected (using the rather naive entropy_estimate function). It will count any slow poll for no more than 256 bits (100 or so is typical for every poll but /dev/random), and will attempt to collect at least 512 bits of (estimated/guessed) entropy. This tends to cause Randpool to use significantly more sources. Previously it was common, especially on systems with a /dev/random, for only one or a few sources to be used. This change helps assure that even if /dev/random and company are broken or compromised the RNG output remains secure (assuming at least some amount of entropy unguessable by the attacker can be collected via other sources). Also change AutoSeeded_RNG do an automatic poll/seed when it is created. --- src/entropy/buf_es/buf_es.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/entropy/buf_es') diff --git a/src/entropy/buf_es/buf_es.cpp b/src/entropy/buf_es/buf_es.cpp index 19f30e22c..4a88d67bd 100644 --- a/src/entropy/buf_es/buf_es.cpp +++ b/src/entropy/buf_es/buf_es.cpp @@ -13,10 +13,9 @@ namespace Botan { /************************************************* * Buffered_EntropySource Constructor * *************************************************/ -Buffered_EntropySource::Buffered_EntropySource() : buffer(256) +Buffered_EntropySource::Buffered_EntropySource() : buffer(128) { read_pos = write_pos = 0; - done_slow_poll = false; } /************************************************* @@ -24,8 +23,6 @@ Buffered_EntropySource::Buffered_EntropySource() : buffer(256) *************************************************/ u32bit Buffered_EntropySource::fast_poll(byte out[], u32bit length) { - if(!done_slow_poll) { do_slow_poll(); done_slow_poll = true; } - do_fast_poll(); return copy_out(out, length, buffer.size() / 4); } @@ -36,7 +33,6 @@ u32bit Buffered_EntropySource::fast_poll(byte out[], u32bit length) u32bit Buffered_EntropySource::slow_poll(byte out[], u32bit length) { do_slow_poll(); - done_slow_poll = true; return copy_out(out, length, buffer.size()); } -- cgit v1.2.3