9#include <botan/internal/rdseed.h>
11#include <botan/internal/cpuid.h>
32 const size_t RDSEED_RETRIES = 1024;
34 for(
size_t i = 0; i != RDSEED_RETRIES; ++i) {
38#if defined(BOTAN_USE_GCC_INLINE_ASM)
39 asm(
"rdseed %0; adcl $0,%1" :
"=r"(r),
"=r"(cf) :
"0"(r),
"1"(cf) :
"cc");
41 cf = _rdseed32_step(&r);
59 const size_t RDSEED_BYTES = 1024;
60 static_assert(RDSEED_BYTES % 4 == 0,
"Bad RDSEED configuration");
62 if(CPUID::has_rdseed()) {
64 seed.reserve(RDSEED_BYTES / 4);
66 for(
size_t p = 0; p != RDSEED_BYTES / 4; ++p) {
75 if(!read_rdseed(seed)) {
81 rng.
add_entropy(
reinterpret_cast<const uint8_t*
>(seed.data()), seed.size() *
sizeof(uint32_t));
size_t poll(RandomNumberGenerator &rng) override
void add_entropy(std::span< const uint8_t > input)
#define BOTAN_FUNC_ISA(isa)
std::vector< T, secure_allocator< T > > secure_vector