aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/rng/hmac_drbg/hmac_drbg.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/rng/hmac_drbg/hmac_drbg.h')
-rw-r--r--src/lib/rng/hmac_drbg/hmac_drbg.h39
1 files changed, 17 insertions, 22 deletions
diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.h b/src/lib/rng/hmac_drbg/hmac_drbg.h
index bd2d18d47..0e294dbdb 100644
--- a/src/lib/rng/hmac_drbg/hmac_drbg.h
+++ b/src/lib/rng/hmac_drbg/hmac_drbg.h
@@ -1,6 +1,6 @@
/*
* HMAC_DRBG (SP800-90A)
-* (C) 2014,2015 Jack Lloyd
+* (C) 2014,2015,2016 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
@@ -14,40 +14,35 @@
namespace Botan {
/**
-* HMAC_DRBG (SP800-90A)
+* HMAC_DRBG from NIST SP800-90A
*/
-class BOTAN_DLL HMAC_DRBG : public RandomNumberGenerator
+class BOTAN_DLL HMAC_DRBG final : public Stateful_RNG
{
public:
- void randomize(byte buf[], size_t buf_len) override;
- bool is_seeded() const override;
- void clear() override;
- std::string name() const override;
+ /**
+ * Initialize an HMAC_DRBG instance with the given hash function
+ */
+ HMAC_DRBG(const std::string& hmac_hash,
+ size_t max_output_before_reseed = BOTAN_RNG_DEFAULT_MAX_OUTPUT_BEFORE_RESEED);
- size_t reseed_with_sources(Entropy_Sources& srcs,
- size_t poll_bits,
- std::chrono::milliseconds poll_timeout) override;
+ HMAC_DRBG(MessageAuthenticationCode* hmac,
+ size_t max_output_before_reseed = BOTAN_RNG_DEFAULT_MAX_OUTPUT_BEFORE_RESEED);
- void add_entropy(const byte input[], size_t input_len) override;
+ std::string name() const override;
- /**
- * @param mac the underlying mac function (eg HMAC(SHA-512))
- * @param underlying_rng RNG used generating inputs (eg HMAC_RNG)
- */
- HMAC_DRBG(MessageAuthenticationCode* mac,
- RandomNumberGenerator* underlying_rng = nullptr);
+ void clear() override;
- HMAC_DRBG(const std::string& mac,
- RandomNumberGenerator* underlying_rng = nullptr);
+ void randomize(byte output[], size_t output_len) override;
+ void randomize_with_input(byte output[], size_t output_len,
+ const byte input[], size_t input_len) override;
+
+ void add_entropy(const byte input[], size_t input_len) override;
private:
void update(const byte input[], size_t input_len);
std::unique_ptr<MessageAuthenticationCode> m_mac;
- std::unique_ptr<RandomNumberGenerator> m_prng;
-
secure_vector<byte> m_V;
- size_t m_reseed_counter;
};
}