Botan  1.11.31
auto_rng.h
Go to the documentation of this file.
1 /*
2 * Auto Seeded RNG
3 * (C) 2008,2016 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_AUTO_SEEDING_RNG_H__
9 #define BOTAN_AUTO_SEEDING_RNG_H__
10 
11 #include <botan/rng.h>
12 
13 namespace Botan {
14 
15 class Stateful_RNG;
16 
17 /**
18 * A userspace PRNG
19 */
20 class BOTAN_DLL AutoSeeded_RNG final : public RandomNumberGenerator
21  {
22  public:
23  void randomize(byte out[], size_t len) override;
24 
25  void randomize_with_input(byte output[], size_t output_len,
26  const byte input[], size_t input_len) override;
27 
28  bool is_seeded() const override;
29 
30  void force_reseed();
31 
32  size_t reseed(Entropy_Sources& srcs,
33  size_t poll_bits = BOTAN_RNG_RESEED_POLL_BITS,
34  std::chrono::milliseconds poll_timeout = BOTAN_RNG_RESEED_DEFAULT_TIMEOUT) override;
35 
36  void add_entropy(const byte in[], size_t len) override;
37 
38  std::string name() const override;
39 
40  void clear() override;
41 
42  /**
43  * If no RNG or entropy sources are provided to AutoSeeded_RNG, it uses the system RNG
44  * (if available) or else a default group of entropy sources (all other systems) to
45  * gather seed material.
46  */
47  AutoSeeded_RNG(size_t reseed_interval = BOTAN_RNG_DEFAULT_RESEED_INTERVAL);
48 
49  AutoSeeded_RNG(RandomNumberGenerator& underlying_rng,
50  size_t reseed_interval = BOTAN_RNG_DEFAULT_RESEED_INTERVAL);
51 
52  AutoSeeded_RNG(Entropy_Sources& entropy_sources,
53  size_t reseed_interval = BOTAN_RNG_DEFAULT_RESEED_INTERVAL);
54 
55  AutoSeeded_RNG(RandomNumberGenerator& underlying_rng,
56  Entropy_Sources& entropy_sources,
57  size_t reseed_interval = BOTAN_RNG_DEFAULT_RESEED_INTERVAL);
58 
59  ~AutoSeeded_RNG();
60 
61  private:
62  std::unique_ptr<Stateful_RNG> m_rng;
63  };
64 
65 }
66 
67 #endif
Definition: alg_id.cpp:13
std::uint8_t byte
Definition: types.h:31