12#ifndef OPENVPN_RANDOM_DEVURAND_H
13#define OPENVPN_RANDOM_DEVURAND_H
37 throw dev_urand_error(
"init failed");
41 std::string
name()
const override
47 void rand_bytes(
unsigned char *buf,
size_t size)
override
50 throw dev_urand_error(
"rand_bytes failed");
61 bool rndbytes(
unsigned char *buf, ssize_t size)
63 const ssize_t actual = ::read(
dev_urandom(), buf, size);
64 return size == actual;
bool rndbytes(unsigned char *buf, ssize_t size)
std::string name() const override
Get the name of the random number generation algorithm.
OPENVPN_EXCEPTION(dev_urand_error)
void rand_bytes(unsigned char *buf, size_t size) override
Fill a buffer with random bytes.
bool rand_bytes_noexcept(unsigned char *buf, size_t size) override
Fill a buffer with random bytes without throwing exceptions.
Abstract base class for cryptographically strong random number generators.
Implementation of the base classes for random number generators.