/src/Botan-3.4.0/build/include/public/botan/system_rng.h
Line | Count | Source (jump to first uncovered line) |
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 | | |
13 | | namespace 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 | | */ |
20 | | BOTAN_PUBLIC_API(2, 0) RandomNumberGenerator& system_rng(); |
21 | | |
22 | | /* |
23 | | * Instantiable reference to the system RNG. |
24 | | */ |
25 | | class BOTAN_PUBLIC_API(2, 0) System_RNG final : public RandomNumberGenerator { |
26 | | public: |
27 | 0 | std::string name() const override { return system_rng().name(); } |
28 | | |
29 | 0 | bool is_seeded() const override { return system_rng().is_seeded(); } |
30 | | |
31 | 0 | bool accepts_input() const override { return system_rng().accepts_input(); } |
32 | | |
33 | 0 | void clear() override { system_rng().clear(); } |
34 | | |
35 | | protected: |
36 | 0 | void fill_bytes_with_input(std::span<uint8_t> out, std::span<const uint8_t> in) override { |
37 | 0 | system_rng().randomize_with_input(out, in); |
38 | 0 | } |
39 | | }; |
40 | | |
41 | | } // namespace Botan |
42 | | |
43 | | #endif |