Botan 1.10.17
hmac_rng.h
Go to the documentation of this file.
1/*
2* HMAC RNG
3* (C) 2008 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#ifndef BOTAN_HMAC_RNG_H__
9#define BOTAN_HMAC_RNG_H__
10
11#include <botan/mac.h>
12#include <botan/rng.h>
13#include <vector>
14
15namespace Botan {
16
17/**
18HMAC_RNG - based on the design described in "On Extract-then-Expand
19Key Derivation Functions and an HMAC-based KDF" by Hugo Krawczyk
20(henceforce, 'E-t-E')
21
22However it actually can be parameterized with any two MAC functions,
23not restricted to HMAC (this variation is also described in Krawczyk's
24paper), for instance one could use HMAC(SHA-512) as the extractor
25and CMAC(AES-256) as the PRF.
26*/
27class BOTAN_DLL HMAC_RNG : public RandomNumberGenerator
28 {
29 public:
30 void randomize(byte buf[], size_t len);
31 bool is_seeded() const { return seeded; }
32 void clear();
33 std::string name() const;
34
35 void reseed(size_t poll_bits);
36 void add_entropy_source(EntropySource* es);
37 void add_entropy(const byte[], size_t);
38
39 /**
40 * @param extractor a MAC used for extracting the entropy
41 * @param prf a MAC used as a PRF using HKDF construction
42 */
45
46 ~HMAC_RNG();
47 private:
50
51 std::vector<EntropySource*> entropy_sources;
52 bool seeded;
53
54 SecureVector<byte> K, io_buffer;
55 size_t output_since_reseed;
56 u32bit counter;
57 };
58
59}
60
61#endif
HMAC_RNG(MessageAuthenticationCode *extractor, MessageAuthenticationCode *prf)
Definition hmac_rng.cpp:169
void randomize(byte buf[], size_t len)
Definition hmac_rng.cpp:38
bool is_seeded() const
Definition hmac_rng.h:31
unsigned int u32bit
Definition types.h:32