From 2ceccebc5ee5ccc1f30ea57584479e638e6e38d4 Mon Sep 17 00:00:00 2001 From: lloyd Date: Sat, 31 Jan 2009 12:14:53 +0000 Subject: Change the max amount read from /dev/*random to 128 bits. Also, change the wait time to bits/16 milliseconds. For instance if 64 bits of entropy are requested, the reader will wait at most 4 ms in the select loop. --- src/entropy/dev_random/es_dev.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/entropy') diff --git a/src/entropy/dev_random/es_dev.cpp b/src/entropy/dev_random/es_dev.cpp index 60e1a4df6..89f981373 100644 --- a/src/entropy/dev_random/es_dev.cpp +++ b/src/entropy/dev_random/es_dev.cpp @@ -51,12 +51,7 @@ u32bit Device_EntropySource::Device_Reader::get(byte out[], u32bit length, if(got <= 0) return 0; - const u32bit ret = static_cast(got); - - if(ret > length) - return 0; - - return ret; + return static_cast(got); } /** @@ -106,16 +101,16 @@ Device_EntropySource::~Device_EntropySource() */ void Device_EntropySource::poll(Entropy_Accumulator& accum) { - const u32bit MAX_READ_WAIT_MILLISECONDS = 50; + u32bit go_get = std::min(accum.desired_remaining_bits() / 8, 16); - u32bit go_get = std::min(accum.desired_remaining_bits() / 8, 32); + u32bit read_wait_ms = go_get / 16; MemoryRegion& io_buffer = accum.get_io_buffer(go_get); for(size_t i = 0; i != devices.size(); ++i) { u32bit got = devices[i].get(io_buffer.begin(), io_buffer.size(), - MAX_READ_WAIT_MILLISECONDS); + read_wait_ms); if(got) { -- cgit v1.2.3