1#include <xrpl/basics/contract.h>
2#include <xrpl/crypto/csprng.h>
4#include <openssl/rand.h>
5#include <openssl/ssl.h>
19 Throw<std::runtime_error>(
"CSPRNG: Initial polling failed");
25#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
41 for (
auto& e : entropy)
51 entropy.
size() *
sizeof(std::random_device::result_type),
54 if (buffer !=
nullptr && count != 0)
55 RAND_add(buffer, count, 0);
64#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || !defined(OPENSSL_THREADS)
69 RAND_bytes(
reinterpret_cast<unsigned char*
>(ptr), count);
72 Throw<std::runtime_error>(
"CSPRNG: Insufficient entropy");
A cryptographically secure random number engine.
std::uint64_t result_type
result_type operator()()
Generate a random integer.
void mix_entropy(void *buffer=nullptr, std::size_t count=0)
Mix entropy into the pool.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
csprng_engine & crypto_prng()
The default cryptographically secure PRNG.