diff options
Diffstat (limited to 'src/crypto/rand/hwrand.c')
-rw-r--r-- | src/crypto/rand/hwrand.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/crypto/rand/hwrand.c b/src/crypto/rand/hwrand.c index f0bbccd..5f81f09 100644 --- a/src/crypto/rand/hwrand.c +++ b/src/crypto/rand/hwrand.c @@ -15,28 +15,23 @@ #include <openssl/rand.h> #include <assert.h> +#include <stdlib.h> #include <string.h> #include <openssl/cpu.h> -#include "internal.h" - #if defined(OPENSSL_X86_64) && !defined(OPENSSL_NO_ASM) +int CRYPTO_have_hwrand(void) { + return (OPENSSL_ia32cap_P[1] & (1u << 30)) != 0; +} + /* These functions are defined in asm/rdrand-x86_64.pl */ extern int CRYPTO_rdrand(uint8_t out[8]); extern int CRYPTO_rdrand_multiple8_buf(uint8_t *buf, size_t len); -static int have_rdrand(void) { - return (OPENSSL_ia32cap_P[1] & (1u << 30)) != 0; -} - int CRYPTO_hwrand(uint8_t *buf, size_t len) { - if (!have_rdrand()) { - return 0; - } - const size_t len_multiple8 = len & ~7; if (!CRYPTO_rdrand_multiple8_buf(buf, len_multiple8)) { return 0; @@ -58,8 +53,12 @@ int CRYPTO_hwrand(uint8_t *buf, size_t len) { #else -int CRYPTO_hwrand(uint8_t *buf, size_t len) { +int CRYPTO_have_hwrand(void) { return 0; } +void CRYPTO_hwrand(uint8_t *buf, size_t len) { + abort(); +} + #endif |