aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/entropy/proc_walk/proc_walk.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-07-03 14:36:55 -0400
committerJack Lloyd <[email protected]>2016-07-17 10:43:41 -0400
commitcae7a66072905bc264ecf0805a8738a674ff2986 (patch)
treef10d8a79a6ce4be3992da74c6bd1e66a10709d0f /src/lib/entropy/proc_walk/proc_walk.cpp
parentee1b5c7e8513b3b97efa87720154d8ca24774eba (diff)
Revamp entropy polling
Remove Entropy_Accumulator, instead have entropy sources directly add entropy to the RNG.
Diffstat (limited to 'src/lib/entropy/proc_walk/proc_walk.cpp')
-rw-r--r--src/lib/entropy/proc_walk/proc_walk.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/entropy/proc_walk/proc_walk.cpp b/src/lib/entropy/proc_walk/proc_walk.cpp
index c59a8227b..a0c3f830a 100644
--- a/src/lib/entropy/proc_walk/proc_walk.cpp
+++ b/src/lib/entropy/proc_walk/proc_walk.cpp
@@ -110,7 +110,7 @@ int Directory_Walker::next_fd()
}
-void ProcWalking_EntropySource::poll(Entropy_Accumulator& accum)
+size_t ProcWalking_EntropySource::poll(RandomNumberGenerator& rng)
{
const size_t MAX_FILES_READ_PER_POLL = 2048;
@@ -121,6 +121,8 @@ void ProcWalking_EntropySource::poll(Entropy_Accumulator& accum)
m_buf.resize(4096);
+ size_t bits = 0;
+
for(size_t i = 0; i != MAX_FILES_READ_PER_POLL; ++i)
{
int fd = m_dir->next_fd();
@@ -136,11 +138,15 @@ void ProcWalking_EntropySource::poll(Entropy_Accumulator& accum)
::close(fd);
if(got > 0)
- accum.add(m_buf.data(), got, BOTAN_ENTROPY_ESTIMATE_SYSTEM_TEXT);
+ {
+ rng.add_entropy(m_buf.data(), static_cast<size_t>(got));
+ }
- if(accum.polling_finished())
+ if(bits > 128)
break;
}
+
+ return bits;
}
}