aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/rng/hmac_drbg/hmac_drbg.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-03-21 22:16:46 +0000
committerlloyd <[email protected]>2014-03-21 22:16:46 +0000
commit0e2b9db6eecb07d01b4756b8fa0a3307670715b6 (patch)
treebe45ca028434e55065ac70da7290e42747bebd48 /src/lib/rng/hmac_drbg/hmac_drbg.h
parentb4407e3d2191a166dfd0e71006180431726f3fc6 (diff)
Add HMAC_DRBG
Diffstat (limited to 'src/lib/rng/hmac_drbg/hmac_drbg.h')
-rw-r--r--src/lib/rng/hmac_drbg/hmac_drbg.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/lib/rng/hmac_drbg/hmac_drbg.h b/src/lib/rng/hmac_drbg/hmac_drbg.h
new file mode 100644
index 000000000..43729c7fa
--- /dev/null
+++ b/src/lib/rng/hmac_drbg/hmac_drbg.h
@@ -0,0 +1,50 @@
+/*
+* HMAC_DRBG (SP800-90A)
+* (C) 2014 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_HMAC_DRBG_H__
+#define BOTAN_HMAC_DRBG_H__
+
+#include <botan/rng.h>
+#include <botan/mac.h>
+
+namespace Botan {
+
+/**
+* HMAC_DRBG (SP800-90A)
+*/
+class BOTAN_DLL HMAC_DRBG : public RandomNumberGenerator
+ {
+ public:
+ void randomize(byte buf[], size_t buf_len);
+ bool is_seeded() const;
+ void clear();
+ std::string name() const;
+
+ void reseed(size_t poll_bits);
+
+ void add_entropy(const byte input[], size_t input_len);
+
+ /**
+ * @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);
+
+ 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_K, m_V;
+ size_t m_reseed_counter;
+ };
+
+}
+
+#endif