aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/rng/hmac_drbg/hmac_drbg.cpp12
-rw-r--r--src/lib/rng/hmac_drbg/hmac_drbg.h3
2 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.cpp b/src/lib/rng/hmac_drbg/hmac_drbg.cpp
index af0565120..22236c0cb 100644
--- a/src/lib/rng/hmac_drbg/hmac_drbg.cpp
+++ b/src/lib/rng/hmac_drbg/hmac_drbg.cpp
@@ -20,6 +20,18 @@ HMAC_DRBG::HMAC_DRBG(MessageAuthenticationCode* mac,
m_mac->set_key(std::vector<byte>(m_mac->output_length(), 0x00));
}
+HMAC_DRBG::HMAC_DRBG(const std::string& mac_name,
+ RandomNumberGenerator* prng) :
+ m_prng(prng),
+ m_V(m_mac->output_length(), 0x01),
+ m_reseed_counter(0)
+ {
+ m_mac = MessageAuthenticationCode::create(mac_name);
+ if(!m_mac)
+ throw Algorithm_Not_Found(mac_name);
+ m_mac->set_key(std::vector<byte>(m_mac->output_length(), 0x00));
+ }
+
void HMAC_DRBG::randomize(byte out[], size_t length)
{
if(!is_seeded() || m_reseed_counter > BOTAN_RNG_MAX_OUTPUT_BEFORE_RESEED)
diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.h b/src/lib/rng/hmac_drbg/hmac_drbg.h
index 2fefdef0d..c9d0e3d20 100644
--- a/src/lib/rng/hmac_drbg/hmac_drbg.h
+++ b/src/lib/rng/hmac_drbg/hmac_drbg.h
@@ -35,6 +35,9 @@ class BOTAN_DLL HMAC_DRBG : public RandomNumberGenerator
HMAC_DRBG(MessageAuthenticationCode* mac,
RandomNumberGenerator* underlying_rng = nullptr);
+ HMAC_DRBG(const std::string& mac,
+ RandomNumberGenerator* underlying_rng = nullptr);
+
private:
void update(const byte input[], size_t input_len);