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:
randomize(byte out[],size_t len)23       void randomize(byte out[], size_t len)
24          { rng->randomize(out, len); }
25 
is_seeded()26       bool is_seeded() const { return rng->is_seeded(); }
27 
clear()28       void clear() { rng->clear(); }
29 
name()30       std::string name() const { return rng->name(); }
31 
32       void reseed(size_t poll_bits = 256) { rng->reseed(poll_bits); }
33 
add_entropy_source(EntropySource * es)34       void add_entropy_source(EntropySource* es)
35          { rng->add_entropy_source(es); }
36 
add_entropy(const byte in[],size_t len)37       void add_entropy(const byte in[], size_t len)
38          { rng->add_entropy(in, len); }
39 
AutoSeeded_RNG()40       AutoSeeded_RNG() { rng = &global_state().global_rng(); }
41    private:
42       RandomNumberGenerator* rng;
43    };
44 
45 }
46 
47 #endif
48