diff options
author | lloyd <[email protected]> | 2014-03-22 14:16:19 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-03-22 14:16:19 +0000 |
commit | 6b043baa4f421e9d00272f3e0d93b7e40cac6b77 (patch) | |
tree | 293d9974f3fd8375e36e5826a44062039a51245e /src/lib/rng/hmac_drbg/hmac_drbg.cpp | |
parent | ee0698f8046d634dcfe6407227178e40475594b7 (diff) |
Add RFC 6979 nonce generator. Also some HMAC_DRBG cleanups.
Diffstat (limited to 'src/lib/rng/hmac_drbg/hmac_drbg.cpp')
-rw-r--r-- | src/lib/rng/hmac_drbg/hmac_drbg.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.cpp b/src/lib/rng/hmac_drbg/hmac_drbg.cpp index 3227841f0..96bd791ee 100644 --- a/src/lib/rng/hmac_drbg/hmac_drbg.cpp +++ b/src/lib/rng/hmac_drbg/hmac_drbg.cpp @@ -66,20 +66,23 @@ void HMAC_DRBG::update(const byte input[], size_t input_len) void HMAC_DRBG::reseed(size_t poll_bits) { - m_prng->reseed(poll_bits); - - if(m_prng->is_seeded()) + if(m_prng) { - secure_vector<byte> input = m_prng->random_vec(m_mac->output_length()); - update(&input[0], input.size()); - m_reseed_counter = 1; + m_prng->reseed(poll_bits); + + if(m_prng->is_seeded()) + { + secure_vector<byte> input = m_prng->random_vec(m_mac->output_length()); + update(&input[0], input.size()); + m_reseed_counter = 1; + } } } void HMAC_DRBG::add_entropy(const byte input[], size_t length) { - // Should we also poll the underlying PRNG here? update(input, length); + m_reseed_counter = 1; } bool HMAC_DRBG::is_seeded() const @@ -89,10 +92,12 @@ bool HMAC_DRBG::is_seeded() const void HMAC_DRBG::clear() { - m_mac->clear(); - m_prng->clear(); zeroise(m_V); - zeroise(m_K); + + m_mac->clear(); + + if(m_prng) + m_prng->clear(); } std::string HMAC_DRBG::name() const |