Botan  1.11.15
src/lib/rng/hmac_drbg/hmac_drbg.h
Go to the documentation of this file.
00001 /*
00002 * HMAC_DRBG (SP800-90A)
00003 * (C) 2014 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_HMAC_DRBG_H__
00009 #define BOTAN_HMAC_DRBG_H__
00010 
00011 #include <botan/rng.h>
00012 #include <botan/mac.h>
00013 
00014 namespace Botan {
00015 
00016 /**
00017 * HMAC_DRBG (SP800-90A)
00018 */
00019 class BOTAN_DLL HMAC_DRBG : public RandomNumberGenerator
00020    {
00021    public:
00022       void randomize(byte buf[], size_t buf_len);
00023       bool is_seeded() const;
00024       void clear();
00025       std::string name() const;
00026 
00027       void reseed(size_t poll_bits);
00028 
00029       void add_entropy(const byte input[], size_t input_len);
00030 
00031       /**
00032       * @param mac the underlying mac function (eg HMAC(SHA-512))
00033       * @param underlying_rng RNG used generating inputs (eg HMAC_RNG)
00034       */
00035       HMAC_DRBG(MessageAuthenticationCode* mac,
00036                 RandomNumberGenerator* underlying_rng);
00037 
00038    private:
00039       void update(const byte input[], size_t input_len);
00040 
00041       std::unique_ptr<MessageAuthenticationCode> m_mac;
00042       std::unique_ptr<RandomNumberGenerator> m_prng;
00043 
00044       secure_vector<byte> m_V;
00045       size_t m_reseed_counter;
00046    };
00047 
00048 }
00049 
00050 #endif