16#ifndef OPENVPN_OPENSSL_UTIL_RAND_H
17#define OPENVPN_OPENSSL_UTIL_RAND_H
19#include <openssl/rand.h>
34 std::string
name()
const override
36 return "OpenSSLRandom";
40 void rand_bytes(
unsigned char *buf,
size_t size)
override
43 throw rand_error_openssl(
"rand_bytes");
56 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.
RCPtr< OpenSSLRandom > Ptr
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.