Botan  1.10.9
auto_rng.h
Go to the documentation of this file.
1 /*
2 * Auto Seeded RNG
3 * (C) 2008 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_AUTO_SEEDING_RNG_H__
9 #define BOTAN_AUTO_SEEDING_RNG_H__
10 
11 #include <botan/rng.h>
12 #include <botan/libstate.h>
13 #include <string>
14 
15 namespace Botan {
16 
17 /**
18 * An automatically seeded PRNG
19 */
20 class BOTAN_DLL AutoSeeded_RNG : public RandomNumberGenerator
21  {
22  public:
23  void randomize(byte out[], size_t len)
24  { rng->randomize(out, len); }
25 
26  bool is_seeded() const { return rng->is_seeded(); }
27 
28  void clear() { rng->clear(); }
29 
30  std::string name() const { return rng->name(); }
31 
32  void reseed(size_t poll_bits = 256) { rng->reseed(poll_bits); }
33 
35  { rng->add_entropy_source(es); }
36 
37  void add_entropy(const byte in[], size_t len)
38  { rng->add_entropy(in, len); }
39 
41  private:
43  };
44 
45 }
46 
47 #endif
RandomNumberGenerator & global_rng()
Definition: libstate.cpp:183
void randomize(byte out[], size_t len)
Definition: auto_rng.h:23
void add_entropy(const byte in[], size_t len)
Definition: auto_rng.h:37
unsigned char byte
Definition: types.h:22
RandomNumberGenerator * rng
Definition: global_rng.cpp:165
Library_State & global_state()
std::string name() const
Definition: auto_rng.h:30
void reseed(size_t poll_bits=256)
Definition: auto_rng.h:32
void add_entropy_source(EntropySource *es)
Definition: auto_rng.h:34
bool is_seeded() const
Definition: auto_rng.h:26