20#include <xrpl/basics/contract.h>
21#include <xrpl/beast/utility/instrumentation.h>
22#include <xrpl/crypto/csprng.h>
24#include <openssl/rand.h>
34 Throw<std::runtime_error>(
"CSPRNG: Initial polling failed");
40#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
56 for (
auto& e : entropy)
66 entropy.
size() *
sizeof(std::random_device::result_type),
69 if (buffer !=
nullptr && count != 0)
70 RAND_add(buffer, count, 0);
79#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || !defined(OPENSSL_THREADS)
84 RAND_bytes(
reinterpret_cast<unsigned char*
>(ptr), count);
87 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.