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
15 namespace Botan {
16
17 /**
18 HMAC_RNG - based on the design described in "On Extract-then-Expand
19 Key Derivation Functions and an HMAC-based KDF" by Hugo Krawczyk
20 (henceforce, 'E-t-E')
21
22 However it actually can be parameterized with any two MAC functions,
23 not restricted to HMAC (this variation is also described in Krawczyk's
24 paper), for instance one could use HMAC(SHA-512) as the extractor
25 and CMAC(AES-256) as the PRF.
26 */
27 class 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 */
43 HMAC_RNG(MessageAuthenticationCode* extractor,
44 MessageAuthenticationCode* prf);
45
46 ~HMAC_RNG();
47 private:
48 MessageAuthenticationCode* extractor;
49 MessageAuthenticationCode* prf;
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
Botan::HMAC_RNG::is_seeded
bool is_seeded() const
Definition: hmac_rng.h:31
Botan::RandomNumberGenerator
Definition: rng.h:20
Botan::HMAC_RNG
Definition: hmac_rng.h:27
Botan::EntropySource
Definition: entropy_src.h:122
Botan::MessageAuthenticationCode
Definition: mac.h:20
Botan::byte
unsigned char byte
Definition: types.h:22
Botan
Definition: algo_base.h:14
Botan::SecureVector< byte >
Botan::u32bit
unsigned int u32bit
Definition: types.h:32