diff options
author | lloyd <[email protected]> | 2009-01-31 12:14:53 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-01-31 12:14:53 +0000 |
commit | 2ceccebc5ee5ccc1f30ea57584479e638e6e38d4 (patch) | |
tree | 7c2f30621c8adb652ba7744f027d7584614eb895 /src/entropy | |
parent | 0f01c1e26394fabdb6eee7442bc657f159eccfef (diff) |
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.
Diffstat (limited to 'src/entropy')
-rw-r--r-- | src/entropy/dev_random/es_dev.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
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<u32bit>(got); - - if(ret > length) - return 0; - - return ret; + return static_cast<u32bit>(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<u32bit>(accum.desired_remaining_bits() / 8, 16); - u32bit go_get = std::min<u32bit>(accum.desired_remaining_bits() / 8, 32); + u32bit read_wait_ms = go_get / 16; MemoryRegion<byte>& 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) { |