58 #if (defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
59 defined(__x86_64) || defined(__x86_64__) || \
60 defined(_M_AMD64) || defined (_M_X64)) && defined(OPENSSL_CPUID_OBJ)
62 size_t OPENSSL_ia32_rdrand(
void);
64 static int get_random_bytes (
unsigned char *buf,
int num)
68 while (num>=(
int)
sizeof(
size_t)) {
69 if ((rnd = OPENSSL_ia32_rdrand()) == 0)
return 0;
71 *((
size_t *)buf) = rnd;
72 buf +=
sizeof(size_t);
73 num -=
sizeof(size_t);
76 if ((rnd = OPENSSL_ia32_rdrand()) == 0)
return 0;
78 memcpy (buf,&rnd,num);
84 static int random_status (
void)
97 static int rdrand_init(
ENGINE *
e)
100 static const char *engine_e_rdrand_id =
"rdrand";
101 static const char *engine_e_rdrand_name =
"Intel RDRAND engine";
103 static int bind_helper(
ENGINE *
e)
114 static ENGINE *ENGINE_rdrand(
void)
119 if(!bind_helper(ret))
131 if (OPENSSL_ia32cap_P[1] & (1<<(62-32)))
133 ENGINE *toadd = ENGINE_rdrand();