aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/rng
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-09-22 11:48:32 -0400
committerJack Lloyd <[email protected]>2015-09-22 11:48:32 -0400
commitac9689990da914cd58788dab9d5e0d7bebb72e30 (patch)
tree5353ffefb5a39b51b3779f4014d76e44761fc5ba /src/lib/rng
parentff7e648c4ca979f740424997decba98a64d9e442 (diff)
Add HMAC_DRBG constructor taking a name for the MAC instead of an obj
Diffstat (limited to 'src/lib/rng')
-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);