8 #include <botan/internal/rdrand.h>
9 #include <botan/cpuid.h>
11 #if !defined(BOTAN_USE_GCC_INLINE_ASM)
12 #include <immintrin.h>
36 const size_t POLL_UPPER_BOUND = 96;
37 const size_t RDRAND_POLLS = 32;
38 const double ENTROPY_PER_POLL =
39 static_cast<double>(POLL_UPPER_BOUND) / (RDRAND_POLLS * 4);
41 for(
size_t i = 0; i != RDRAND_POLLS; ++i)
45 #if BOTAN_USE_GCC_INLINE_ASM
49 asm(
".byte 0x0F, 0xC7, 0xF0; adcl $0,%1" :
50 "=a" (
r),
"=r" (cf) :
"0" (
r),
"1" (cf) :
"cc");
52 int cf = _rdrand32_step(&r);
56 accum.
add(r, ENTROPY_PER_POLL);
void add(const void *bytes, size_t length, double entropy_bits_per_byte)
void poll(Entropy_Accumulator &accum)