7#include <botan/auto_rng.h>
9#include <botan/hmac_drbg.h>
10#include <botan/internal/loadstor.h>
12#if defined(BOTAN_HAS_ENTROPY_SOURCE)
13 #include <botan/entropy_src.h>
16#if defined(BOTAN_HAS_SYSTEM_RNG)
17 #include <botan/system_rng.h>
24std::unique_ptr<MessageAuthenticationCode> auto_rng_hmac() {
25 const std::string possible_auto_rng_hmacs[] = {
30 for(
const auto& hmac : possible_auto_rng_hmacs) {
45 m_rng = std::make_unique<HMAC_DRBG>(auto_rng_hmac(), underlying_rng, reseed_interval);
51 m_rng = std::make_unique<HMAC_DRBG>(auto_rng_hmac(), entropy_sources, reseed_interval);
58 size_t reseed_interval) {
59 m_rng = std::make_unique<HMAC_DRBG>(auto_rng_hmac(), underlying_rng, entropy_sources, reseed_interval);
65#if defined(BOTAN_HAS_SYSTEM_RNG)
66 m_rng = std::make_unique<HMAC_DRBG>(auto_rng_hmac(),
system_rng(), reseed_interval);
67#elif defined(BOTAN_HAS_ENTROPY_SOURCE)
71 throw Not_Implemented(
"AutoSeeded_RNG default constructor not available due to no RNG or entropy sources");
78 m_rng->force_reseed();
81 if(!m_rng->is_seeded()) {
87 return m_rng->is_seeded();
99 return m_rng->reseed(srcs, poll_bits, poll_timeout);
102void AutoSeeded_RNG::fill_bytes_with_input(std::span<uint8_t> out, std::span<const uint8_t> in) {
104 m_rng->randomize_with_ts_input(out);
106 m_rng->randomize_with_input(out, in);
std::string name() const override
~AutoSeeded_RNG() override
AutoSeeded_RNG(size_t reseed_interval=BOTAN_RNG_DEFAULT_RESEED_INTERVAL)
bool is_seeded() const override
size_t reseed(Entropy_Sources &srcs, size_t poll_bits=BOTAN_RNG_RESEED_POLL_BITS, std::chrono::milliseconds poll_timeout=BOTAN_RNG_RESEED_DEFAULT_TIMEOUT) override
static Entropy_Sources & global_sources()
static std::unique_ptr< MessageAuthenticationCode > create(std::string_view algo_spec, std::string_view provider="")
RandomNumberGenerator & system_rng()