Botan 3.0.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*/
20BOTAN_PUBLIC_API(2,0) RandomNumberGenerator& system_rng();
21
22/*
23* Instantiable reference to the system RNG.
24*/
26 {
27 public:
28 std::string name() const override { return system_rng().name(); }
29
30 bool is_seeded() const override { return system_rng().is_seeded(); }
31
32 bool accepts_input() const override { return system_rng().accepts_input(); }
33
34 void clear() override { system_rng().clear(); }
35
36 protected:
37 void fill_bytes_with_input(std::span<uint8_t> out, std::span<const uint8_t> in) override
38 { system_rng().randomize_with_input(out, in); }
39
40 };
41
42}
43
44#endif
virtual bool accepts_input() const =0
virtual bool is_seeded() const =0
virtual std::string name() const =0
void randomize_with_input(uint8_t output[], size_t output_len, const uint8_t input[], size_t input_len)
Definition: rng.h:108
bool accepts_input() const override
Definition: system_rng.h:32
bool is_seeded() const override
Definition: system_rng.h:30
void clear() override
Definition: system_rng.h:34
void fill_bytes_with_input(std::span< uint8_t > out, std::span< const uint8_t > in) override
Definition: system_rng.h:37
std::string name() const override
Definition: system_rng.h:28
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: alg_id.cpp:12
RandomNumberGenerator & system_rng()
Definition: system_rng.cpp:376