aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/rng/hmac_drbg
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-11-24 17:51:59 -0500
committerJack Lloyd <[email protected]>2015-11-24 17:51:59 -0500
commit5f208fab1890e2ad64b52306eccd82f031425c7a (patch)
tree6bbbf1408e10538e441e3d603d80ebb2cabc6a78 /src/lib/rng/hmac_drbg
parentbf59ffc4de374d7b27b7ab400789ab2723131b7a (diff)
New reseed_with_sources call on RNGs
Provides an easier way for an application to configure a list of entropy sources they'd like to use, or add a custom entropy source to their seeding. Exposes some toggles for the global/default entropy sources to build.h Adds basic entropy tests which runs the polls and does sanity checking on the results, including compression tests if available. These are less useful for the CSPRNG outputs but a good check for the ones producing plain ASCII like the /proc reader.
Diffstat (limited to 'src/lib/rng/hmac_drbg')
-rw-r--r--src/lib/rng/hmac_drbg/hmac_drbg.cpp10
-rw-r--r--src/lib/rng/hmac_drbg/hmac_drbg.h4
2 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.cpp b/src/lib/rng/hmac_drbg/hmac_drbg.cpp
index ad731b6b3..67325ee1b 100644
--- a/src/lib/rng/hmac_drbg/hmac_drbg.cpp
+++ b/src/lib/rng/hmac_drbg/hmac_drbg.cpp
@@ -78,11 +78,13 @@ void HMAC_DRBG::update(const byte input[], size_t input_len)
}
}
-void HMAC_DRBG::reseed(size_t poll_bits)
+size_t HMAC_DRBG::reseed_with_sources(Entropy_Sources& srcs,
+ size_t poll_bits,
+ std::chrono::milliseconds poll_timeout)
{
if(m_prng)
{
- m_prng->reseed(poll_bits);
+ size_t bits = m_prng->reseed_with_sources(srcs, poll_bits, poll_timeout);
if(m_prng->is_seeded())
{
@@ -90,7 +92,11 @@ void HMAC_DRBG::reseed(size_t poll_bits)
update(input.data(), input.size());
m_reseed_counter = 1;
}
+
+ return bits;
}
+
+ return 0;
}
void HMAC_DRBG::add_entropy(const byte input[], size_t length)
diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.h b/src/lib/rng/hmac_drbg/hmac_drbg.h
index c9d0e3d20..bd2d18d47 100644
--- a/src/lib/rng/hmac_drbg/hmac_drbg.h
+++ b/src/lib/rng/hmac_drbg/hmac_drbg.h
@@ -24,7 +24,9 @@ class BOTAN_DLL HMAC_DRBG : public RandomNumberGenerator
void clear() override;
std::string name() const override;
- void reseed(size_t poll_bits) override;
+ size_t reseed_with_sources(Entropy_Sources& srcs,
+ size_t poll_bits,
+ std::chrono::milliseconds poll_timeout) override;
void add_entropy(const byte input[], size_t input_len) override;