14#ifndef OPENVPN_RANDOM_MTRANDAPI_H
15#define OPENVPN_RANDOM_MTRANDAPI_H
43 MTRand(
const rand_type::result_type seed)
49 std::string
name()
const override
55 void rand_bytes(
unsigned char *buf,
size_t size)
override
58 throw mtrand_error(
"rand_bytes failed");
68 rand_type::result_type
rand()
83 return seed.
rand_get<rand_type::result_type>();
88 std::random_device rd;
90 rand_type::result_type
ret;
static rand_type::result_type gen_seed(RandomAPI &seed)
static rand_type::result_type gen_seed()
bool rand_bytes_noexcept(unsigned char *buf, size_t size) override
Fill a buffer with random bytes without throwing exceptions.
std::string name() const override
Get the name of the random number generation algorithm.
OPENVPN_EXCEPTION(mtrand_error)
std::mt19937_64 rand_type
void rand_bytes(unsigned char *buf, size_t size) override
Fill a buffer with random bytes.
MTRand(const rand_type::result_type seed)
rand_type::result_type rand()
bool rndbytes(unsigned char *buf, size_t size)
RandomByteStore< rand_type > rbs
Abstract base class for random number generators.
T rand_get()
Create a data object filled with random bytes.
unsigned char get_byte(RAND_TYPE &rng)
void fill(T &obj, RAND_TYPE &rng)
Abstract base class for pseudo random number generators.
Implementation of the base classes for random number generators.