From 9fe52b4c66b17ca20d6e89f97ea00d36ce86086e Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sun, 15 Jun 2025 14:18:31 +0000 Subject: Provide machine dependent CPU capabilities for i386. This indicates if AES-NI is available via CRYPTO_CPU_CAPS_I386_AES. ok tb@ --- src/lib/libcrypto/arch/i386/crypto_arch.h | 10 +++++++++- src/lib/libcrypto/arch/i386/crypto_cpu_caps.c | 10 ++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libcrypto/arch/i386/crypto_arch.h b/src/lib/libcrypto/arch/i386/crypto_arch.h index 3df3963d0b..a693bd20d8 100644 --- a/src/lib/libcrypto/arch/i386/crypto_arch.h +++ b/src/lib/libcrypto/arch/i386/crypto_arch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_arch.h,v 1.4 2025/02/14 12:01:58 jsing Exp $ */ +/* $OpenBSD: crypto_arch.h,v 1.5 2025/06/15 14:18:31 jsing Exp $ */ /* * Copyright (c) 2024 Joel Sing * @@ -15,12 +15,20 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + #ifndef HEADER_CRYPTO_ARCH_H #define HEADER_CRYPTO_ARCH_H #define HAVE_CRYPTO_CPU_CAPS_INIT #define HAVE_CRYPTO_CPU_CAPS_IA32 +#ifndef __ASSEMBLER__ +extern uint64_t crypto_cpu_caps_i386; +#endif + +#define CRYPTO_CPU_CAPS_I386_AES (1ULL << 0) + #ifndef OPENSSL_NO_ASM #define HAVE_AES_CBC_ENCRYPT_INTERNAL diff --git a/src/lib/libcrypto/arch/i386/crypto_cpu_caps.c b/src/lib/libcrypto/arch/i386/crypto_cpu_caps.c index 6bb77411af..01981ace55 100644 --- a/src/lib/libcrypto/arch/i386/crypto_cpu_caps.c +++ b/src/lib/libcrypto/arch/i386/crypto_cpu_caps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_cpu_caps.c,v 1.3 2024/11/12 13:14:57 jsing Exp $ */ +/* $OpenBSD: crypto_cpu_caps.c,v 1.4 2025/06/15 14:18:31 jsing Exp $ */ /* * Copyright (c) 2024 Joel Sing * @@ -19,11 +19,15 @@ #include +#include "crypto_arch.h" #include "x86_arch.h" /* Legacy architecture specific capabilities, used by perlasm. */ uint64_t OPENSSL_ia32cap_P; +/* Machine dependent CPU capabilities. */ +uint64_t crypto_cpu_caps_i386; + /* Machine independent CPU capabilities. */ extern uint64_t crypto_cpu_caps; @@ -92,8 +96,10 @@ crypto_cpu_caps_init(void) if ((edx & IA32CAP_MASK0_SSE2) != 0) caps |= CPUCAP_MASK_SSE2; - if ((ecx & IA32CAP_MASK1_AESNI) != 0) + if ((ecx & IA32CAP_MASK1_AESNI) != 0) { caps |= CPUCAP_MASK_AESNI; + crypto_cpu_caps_i386 |= CRYPTO_CPU_CAPS_I386_AES; + } if ((ecx & IA32CAP_MASK1_PCLMUL) != 0) caps |= CPUCAP_MASK_PCLMUL; if ((ecx & IA32CAP_MASK1_SSSE3) != 0) -- cgit v1.2.3-55-g6feb