aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/entropy/proc_walk
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/entropy/proc_walk')
-rw-r--r--src/lib/entropy/proc_walk/proc_walk.cpp12
-rw-r--r--src/lib/entropy/proc_walk/proc_walk.h2
2 files changed, 10 insertions, 4 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;
}
}
diff --git a/src/lib/entropy/proc_walk/proc_walk.h b/src/lib/entropy/proc_walk/proc_walk.h
index f6db8185a..369b52699 100644
--- a/src/lib/entropy/proc_walk/proc_walk.h
+++ b/src/lib/entropy/proc_walk/proc_walk.h
@@ -28,7 +28,7 @@ class ProcWalking_EntropySource final : public Entropy_Source
public:
std::string name() const override { return "proc_walk"; }
- void poll(Entropy_Accumulator& accum) override;
+ size_t poll(RandomNumberGenerator& rng) override;
ProcWalking_EntropySource(const std::string& root_dir) :
m_path(root_dir), m_dir(nullptr) {}