2
* Entropy Source Using Intel's rdseed instruction
3
* (C) 2015 Jack Lloyd, Daniel Neus
5
* Botan is released under the Simplified BSD License (see license.txt)
8
#include <botan/internal/rdseed.h>
9
#include <botan/cpuid.h>
11
#if !defined(BOTAN_USE_GCC_INLINE_ASM)
12
#include <immintrin.h>
17
BOTAN_FUNC_ISA("rdseed")
18
size_t Intel_Rdseed::poll(RandomNumberGenerator& rng) {
19
if(CPUID::has_rdseed())
21
for(size_t p = 0; p != BOTAN_ENTROPY_INTEL_RNG_POLLS; ++p)
23
for(size_t i = 0; i != BOTAN_ENTROPY_RDSEED_RETRIES; ++i)
27
#if defined(BOTAN_USE_GCC_INLINE_ASM)
30
// Encoding of rdseed %eax
31
asm(".byte 0x0F, 0xC7, 0xF8; adcl $0,%1" :
32
"=a" (r), "=r" (cf) : "0" (r), "1" (cf) : "cc");
34
int cf = _rdseed32_step(&r);