aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/libstate/entropy_srcs.cpp18
-rw-r--r--src/lib/rng/x931_rng/x931_rng.cpp7
2 files changed, 15 insertions, 10 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;
}
}
diff --git a/src/lib/rng/x931_rng/x931_rng.cpp b/src/lib/rng/x931_rng/x931_rng.cpp
index dbf09b367..a77ac2ca8 100644
--- a/src/lib/rng/x931_rng/x931_rng.cpp
+++ b/src/lib/rng/x931_rng/x931_rng.cpp
@@ -14,7 +14,12 @@ namespace Botan {
void ANSI_X931_RNG::randomize(byte out[], size_t length)
{
if(!is_seeded())
- throw PRNG_Unseeded(name());
+ {
+ reseed(BOTAN_RNG_RESEED_POLL_BITS);
+
+ if(!is_seeded())
+ throw PRNG_Unseeded(name());
+ }
while(length)
{