diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 507d165a8..4903fa947 100755 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -113,8 +113,11 @@ int wc_RNG_GenerateByte(RNG* rng, byte* b) #ifdef HAVE_INTEL_RDGEN static int wc_InitRng_IntelRD(void) ; - static int wc_GenerateSeed_IntelRD(OS_Seed* os, byte* output, word32 sz) ; + #if defined(HAVE_HASHDRBG) || defined(NO_RC4) + static int wc_GenerateSeed_IntelRD(OS_Seed* os, byte* output, word32 sz) ; + #else static int wc_GenerateRand_IntelRD(OS_Seed* os, byte* output, word32 sz) ; + #endif static word32 cpuid_check = 0 ; static word32 cpuid_flags = 0 ; #define CPUID_RDRAND 0x4 @@ -759,18 +762,14 @@ static int wc_InitRng_IntelRD() if(cpuid_check==0) { if(cpuid_flag(1, 0, ECX, 30)){ cpuid_flags |= CPUID_RDRAND ;} if(cpuid_flag(7, 0, EBX, 18)){ cpuid_flags |= CPUID_RDSEED ;} - cpuid_check = 1 ; + cpuid_check = 1 ; } return 1 ; } -static inline int IntelRDrand32(unsigned int *rnd) -{ - int rdrand; unsigned char ok ; - __asm__ volatile("rdrand %0; setc %1":"=r"(rdrand), "=qm"(ok)); - *rnd = rdrand ; - return ok ; -} +#define INTELRD_RETRY 10 + +#if defined(HAVE_HASHDRBG) || defined(NO_RC4) static inline int IntelRDseed32(unsigned int *seed) { @@ -784,15 +783,6 @@ static inline int IntelRDseed32(unsigned int *seed) return 1; } -#define INTELRD_RETRY 10 -static inline int IntelRDrand32_r(unsigned int *rnd) -{ - int i ; - for(i=0; i