7#include <botan/processor_rng.h>
9#include <botan/assert.h>
10#include <botan/exceptn.h>
11#include <botan/internal/hwrng.h>
12#include <botan/internal/loadstor.h>
18uint64_t read_hwrng() {
23 throw PRNG_Unseeded(
"Processor RNG instruction failed to produce output within expected iterations");
37void Processor_RNG::fill_bytes_with_input(std::span<uint8_t> out, std::span<const uint8_t> in) {
41 while(out.size() >= 8) {
48 const auto hwrng_bytes =
store_le(read_hwrng());
49 copy_mem(out, std::span{hwrng_bytes}.first(out.size()));
55 throw Invalid_State(
"Current CPU does not support RNG instruction");
std::string to_string() const
std::string name() const override
std::optional< uint64_t > read()
constexpr void copy_mem(T *out, const T *in, size_t n)
constexpr auto store_le(ParamTs &&... params)