16#ifndef OPENVPN_OPENSSL_UTIL_RAND_H
17#define OPENVPN_OPENSSL_UTIL_RAND_H
19#include <openssl/rand.h>
32 std::string
name()
const override
34 return "OpenSSLRandom";
38 void rand_bytes(
unsigned char *buf,
size_t size)
override
41 throw rand_error_openssl(
"rand_bytes");
54 return is_safe_conversion<int>(size) ? RAND_bytes(buf,
static_cast<int>(size)) == 1 :
false;
void rand_bytes(unsigned char *buf, size_t size) override
Fill a buffer with random bytes.
OPENVPN_EXCEPTION(rand_error_openssl)
bool rndbytes(unsigned char *buf, size_t size)
std::string name() const override
Get the name of the random number generation algorithm.
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.