aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/rng/hmac_drbg
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-06-30 13:15:30 -0400
committerJack Lloyd <[email protected]>2016-07-17 10:43:40 -0400
commit93922f20f04058ec624f7db3c74d8aa5a3d06440 (patch)
tree81144cfacced43c68c4385683ee0c123a1987042 /src/lib/rng/hmac_drbg
parent4c5847412d41756aab738a3746666cfaffe5d4af (diff)
Add Stateful_RNG
Handles fork checking for HMAC_RNG and HMAC_DRBG AutoSeeded_RNG change - switch to HMAC_DRBG as default. Start removing the io buffer from entropy poller. Update default RNG poll bits to 256. Fix McEliece test, was using wrong RNG API. Update docs.
Diffstat (limited to 'src/lib/rng/hmac_drbg')
-rw-r--r--src/lib/rng/hmac_drbg/hmac_drbg.cpp14
-rw-r--r--src/lib/rng/hmac_drbg/hmac_drbg.h10
2 files changed, 17 insertions, 7 deletions
diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.cpp b/src/lib/rng/hmac_drbg/hmac_drbg.cpp
index 201a9f39b..6fdd7daf9 100644
--- a/src/lib/rng/hmac_drbg/hmac_drbg.cpp
+++ b/src/lib/rng/hmac_drbg/hmac_drbg.cpp
@@ -10,9 +10,14 @@
namespace Botan {
-HMAC_DRBG::HMAC_DRBG(const std::string& hmac_hash) :
- HMAC_DRBG(hmac_hash, BOTAN_RNG_MAX_OUTPUT_BEFORE_RESEED)
- {}
+HMAC_DRBG::HMAC_DRBG(MessageAuthenticationCode* hmac,
+ size_t max_bytes_before_reseed) :
+ Stateful_RNG(max_bytes_before_reseed),
+ m_mac(hmac)
+ {
+ m_V.resize(m_mac->output_length());
+ clear();
+ }
HMAC_DRBG::HMAC_DRBG(const std::string& hmac_hash,
size_t max_bytes_before_reseed) :
@@ -27,12 +32,13 @@ HMAC_DRBG::HMAC_DRBG(const std::string& hmac_hash,
}
m_V.resize(m_mac->output_length());
-
clear();
}
void HMAC_DRBG::clear()
{
+ Stateful_RNG::clear();
+
for(size_t i = 0; i != m_V.size(); ++i)
m_V[i] = 0x01;
m_mac->set_key(std::vector<byte>(m_mac->output_length(), 0x00));
diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.h b/src/lib/rng/hmac_drbg/hmac_drbg.h
index f52ae9de1..8ee598470 100644
--- a/src/lib/rng/hmac_drbg/hmac_drbg.h
+++ b/src/lib/rng/hmac_drbg/hmac_drbg.h
@@ -19,10 +19,14 @@ namespace Botan {
class BOTAN_DLL HMAC_DRBG final : public Stateful_RNG
{
public:
- HMAC_DRBG(const std::string& hmac_hash);
-
+ /**
+ * Initialize an HMAC_DRBG instance with the given hash function
+ */
HMAC_DRBG(const std::string& hmac_hash,
- size_t max_bytes_before_reseed);
+ size_t max_bytes_before_reseed = BOTAN_RNG_MAX_OUTPUT_BEFORE_RESEED);
+
+ HMAC_DRBG(MessageAuthenticationCode* hmac,
+ size_t max_bytes_before_reseed = BOTAN_RNG_MAX_OUTPUT_BEFORE_RESEED);
std::string name() const override;