diff options
Diffstat (limited to 'src/lib/libcrypto/engine/eng_aesni.c')
-rw-r--r-- | src/lib/libcrypto/engine/eng_aesni.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/lib/libcrypto/engine/eng_aesni.c b/src/lib/libcrypto/engine/eng_aesni.c index 5f9a36236a..92794f6086 100644 --- a/src/lib/libcrypto/engine/eng_aesni.c +++ b/src/lib/libcrypto/engine/eng_aesni.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_aesni.c,v 1.8 2015/02/10 09:46:30 miod Exp $ */ | 1 | /* $OpenBSD: eng_aesni.c,v 1.9 2016/11/04 17:30:30 miod Exp $ */ |
2 | /* | 2 | /* |
3 | * Support for Intel AES-NI intruction set | 3 | * Support for Intel AES-NI intruction set |
4 | * Author: Huang Ying <ying.huang@intel.com> | 4 | * Author: Huang Ying <ying.huang@intel.com> |
@@ -93,10 +93,11 @@ | |||
93 | defined(_M_AMD64) || defined(_M_X64) || \ | 93 | defined(_M_AMD64) || defined(_M_X64) || \ |
94 | defined(OPENSSL_IA32_SSE2)) && !defined(OPENSSL_NO_ASM) && !defined(__i386__) | 94 | defined(OPENSSL_IA32_SSE2)) && !defined(OPENSSL_NO_ASM) && !defined(__i386__) |
95 | #define COMPILE_HW_AESNI | 95 | #define COMPILE_HW_AESNI |
96 | #include "x86_arch.h" | ||
96 | #endif | 97 | #endif |
97 | static ENGINE *ENGINE_aesni (void); | 98 | static ENGINE *ENGINE_aesni(void); |
98 | 99 | ||
99 | void ENGINE_load_aesni (void) | 100 | void ENGINE_load_aesni(void) |
100 | { | 101 | { |
101 | /* On non-x86 CPUs it just returns. */ | 102 | /* On non-x86 CPUs it just returns. */ |
102 | #ifdef COMPILE_HW_AESNI | 103 | #ifdef COMPILE_HW_AESNI |
@@ -302,20 +303,13 @@ aesni_ofb128_encrypt(const unsigned char *in, unsigned char *out, | |||
302 | } | 303 | } |
303 | /* ===== Engine "management" functions ===== */ | 304 | /* ===== Engine "management" functions ===== */ |
304 | 305 | ||
305 | typedef unsigned long long IA32CAP; | ||
306 | |||
307 | /* Prepare the ENGINE structure for registration */ | 306 | /* Prepare the ENGINE structure for registration */ |
308 | static int | 307 | static int |
309 | aesni_bind_helper(ENGINE *e) | 308 | aesni_bind_helper(ENGINE *e) |
310 | { | 309 | { |
311 | int engage; | 310 | int engage; |
312 | 311 | ||
313 | if (sizeof(OPENSSL_ia32cap_P) > 4) { | 312 | engage = (OPENSSL_cpu_caps() & CPUCAP_MASK_AESNI) != 0; |
314 | engage = ((IA32CAP)OPENSSL_ia32cap_P >> 57) & 1; | ||
315 | } else { | ||
316 | IA32CAP OPENSSL_ia32_cpuid(void); | ||
317 | engage = (OPENSSL_ia32_cpuid() >> 57) & 1; | ||
318 | } | ||
319 | 313 | ||
320 | /* Register everything or return with an error */ | 314 | /* Register everything or return with an error */ |
321 | if (!ENGINE_set_id(e, aesni_id) || | 315 | if (!ENGINE_set_id(e, aesni_id) || |