Botan 3.13.0
Crypto and TLS for C&
system_rng.h
Go to the documentation of this file.
1/*
2* System RNG interface
3* (C) 2014,2015 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_SYSTEM_RNG_H_
9#define BOTAN_SYSTEM_RNG_H_
10
11#include <botan/rng.h>
12
13namespace Botan {
14
15/**
16* Return a shared reference to a global PRNG instance provided by the
17* operating system. For instance might be instantiated by /dev/urandom
18* or CryptGenRandom.
19*/
21
22/**
23* Instantiable reference to the system RNG.
24*/
26 public:
27 /**
28 * Return the name of this RNG type
29 * @return the name of this RNG type
30 */
31 std::string name() const override { return system_rng().name(); }
32
33 /**
34 * Test whether this RNG has been seeded
35 * @return true if this RNG is seeded and ready for use
36 */
37 bool is_seeded() const override { return system_rng().is_seeded(); }
38
39 /**
40 * Test whether this RNG accepts externally provided input
41 * @return false if this RNG is known to ignore provided inputs
42 */
43 bool accepts_input() const override { return system_rng().accepts_input(); }
44
45 /**
46 * Clear all internally held values of this RNG
47 */
48 void clear() override { system_rng().clear(); }
49
50 protected:
51 /**
52 * Fill the output buffer, first incorporating the provided input
53 * @param out the buffer to fill
54 * @param in additional input to incorporate
55 */
56 void fill_bytes_with_input(std::span<uint8_t> out, std::span<const uint8_t> in) override {
58 }
59};
60
61} // namespace Botan
62
63#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
virtual bool accepts_input() const =0
virtual bool is_seeded() const =0
virtual std::string name() const =0
void randomize_with_input(std::span< uint8_t > output, std::span< const uint8_t > input)
Definition rng.h:148
bool accepts_input() const override
Definition system_rng.h:43
bool is_seeded() const override
Definition system_rng.h:37
void clear() override
Definition system_rng.h:48
void fill_bytes_with_input(std::span< uint8_t > out, std::span< const uint8_t > in) override
Definition system_rng.h:56
std::string name() const override
Definition system_rng.h:31
RandomNumberGenerator & system_rng()