9#ifndef BOTAN_RANDOM_NUMBER_GENERATOR_H_
10#define BOTAN_RANDOM_NUMBER_GENERATOR_H_
12#include <botan/concepts.h>
13#include <botan/exceptn.h>
14#include <botan/mutex.h>
15#include <botan/secmem.h>
53 void randomize(std::span<uint8_t> output) { this->fill_bytes_with_input(output, {}); }
76 void add_entropy(std::span<const uint8_t> input) { this->fill_bytes_with_input({}, input); }
84 requires std::is_standard_layout<T>::value && std::is_trivial<T>::value
86 this->add_entropy(
reinterpret_cast<const uint8_t*
>(&t),
sizeof(
T));
106 this->fill_bytes_with_input(output, input);
110 this->randomize_with_input(std::span(output, output_len), std::span(input, input_len));
127 void randomize_with_ts_input(std::span<uint8_t> output);
130 this->randomize_with_ts_input(std::span(output, output_len));
136 virtual std::string
name()
const = 0;
180 void random_vec(std::span<uint8_t> v) { this->randomize(v); }
190 template <concepts::resizable_
byte_buffer T>
204 template <concepts::resizable_
byte_buffer T = secure_vector<u
int8_t>>
205 requires std::default_initializable<T>
208 random_vec(result, bytes);
215 template <
size_t bytes>
217 std::array<uint8_t, bytes> result;
230 this->fill_bytes_with_input(std::span(&
b, 1), {});
240 uint8_t
b = this->next_byte();
242 b = this->next_byte();
292 std::string
name()
const override {
return "Null_RNG"; }
295 void fill_bytes_with_input(std::span<uint8_t> output, std::span<const uint8_t> )
override;
bool accepts_input() const override
std::string name() const override
bool is_seeded() const override
void randomize(std::span< uint8_t > output)
std::array< uint8_t, bytes > random_array()
virtual bool accepts_input() const =0
T random_vec(size_t bytes)
virtual ~RandomNumberGenerator()=default
RandomNumberGenerator()=default
void add_entropy(std::span< const uint8_t > input)
void randomize(uint8_t output[], size_t length)
uint8_t next_nonzero_byte()
void random_vec(T &v, size_t bytes)
RandomNumberGenerator & operator=(const RandomNumberGenerator &rng)=delete
virtual bool is_seeded() const =0
void randomize_with_ts_input(uint8_t output[], size_t output_len)
void add_entropy(const uint8_t input[], size_t length)
virtual std::string name() const =0
void add_entropy_T(const T &t)
void random_vec(std::span< uint8_t > v)
virtual void fill_bytes_with_input(std::span< uint8_t > output, std::span< const uint8_t > input)=0
void randomize_with_input(std::span< uint8_t > output, std::span< const uint8_t > input)
RandomNumberGenerator(const RandomNumberGenerator &rng)=delete
void randomize_with_input(uint8_t output[], size_t output_len, const uint8_t input[], size_t input_len)
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_RNG_RESEED_DEFAULT_TIMEOUT
#define BOTAN_RNG_RESEED_POLL_BITS
RandomNumberGenerator RNG