aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/libstate/entropy_srcs.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-02-13 18:59:49 +0000
committerlloyd <[email protected]>2014-02-13 18:59:49 +0000
commit241499ab648e27961f83c7c9724360657d8cf93b (patch)
tree26f450a27abace2d98aa6ec74ed15e58a42ef157 /src/lib/libstate/entropy_srcs.cpp
parentc123180d2cdce837706eeffedc4e6105be0b2a5e (diff)
Change X9.31 to automatically reseed if randomize is called while unseeded.
If no entropy sources at all are enabled in the build, throw an exception immediately rather than having the poll mysteriously fail.
Diffstat (limited to 'src/lib/libstate/entropy_srcs.cpp')
-rw-r--r--src/lib/libstate/entropy_srcs.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/lib/libstate/entropy_srcs.cpp b/src/lib/libstate/entropy_srcs.cpp
index b6dc6b559..44bf7b2e2 100644
--- a/src/lib/libstate/entropy_srcs.cpp
+++ b/src/lib/libstate/entropy_srcs.cpp
@@ -106,16 +106,16 @@ void Library_State::poll_available_sources(class Entropy_Accumulator& accum)
const size_t poll_bits = accum.desired_remaining_bits();
- if(!m_sources.empty())
+ if(m_sources.empty())
+ throw std::runtime_error("No entropy sources enabled at build time, poll failed");
+
+ size_t poll_attempt = 0;
+
+ while(!accum.polling_goal_achieved() && poll_attempt < poll_bits)
{
- size_t poll_attempt = 0;
-
- while(!accum.polling_goal_achieved() && poll_attempt < poll_bits)
- {
- const size_t src_idx = poll_attempt % m_sources.size();
- m_sources[src_idx]->poll(accum);
- ++poll_attempt;
- }
+ const size_t src_idx = poll_attempt % m_sources.size();
+ m_sources[src_idx]->poll(accum);
+ ++poll_attempt;
}
}