blob: b9ea064c30902f2fc6298ae631fbfc164b69e3f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*************************************************
* HMAC RNG *
* (C) 2008 Jack Lloyd *
*************************************************/
#ifndef BOTAN_HMAC_RNG_H__
#define BOTAN_HMAC_RNG_H__
#include <botan/mac.h>
#include <botan/rng.h>
#include <vector>
namespace Botan {
/**
HMAC_RNG - based on the design described in "On Extract-then-Expand
Key Derivation Functions and an HMAC-based KDF" by Hugo Krawczyk
(henceforce, 'E-t-E')
However it actually can be parameterized with any two MAC functions,
not restricted to HMAC (this variation is also described in Krawczyk's
paper), for instance one could use HMAC(SHA-512) as the extractor
and CMAC(AES-256) as the PRF.
*/
class BOTAN_DLL HMAC_RNG : public RandomNumberGenerator
{
public:
void randomize(byte buf[], u32bit len);
bool is_seeded() const;
void clear() throw();
std::string name() const;
void reseed();
void add_entropy_source(EntropySource* es);
void add_entropy(const byte[], u32bit);
HMAC_RNG(MessageAuthenticationCode* extractor,
MessageAuthenticationCode* prf);
~HMAC_RNG();
private:
void reseed_with_input(const byte input[], u32bit length);
MessageAuthenticationCode* extractor;
MessageAuthenticationCode* prf;
std::vector<EntropySource*> entropy_sources;
u32bit entropy;
SecureVector<byte> K, io_buffer;
u32bit counter, source_index;
};
}
#endif
|