-/* $OpenBSD: cryptlib.c,v 1.53 2024/08/31 12:43:58 jsing Exp $ */
+/* $OpenBSD: cryptlib.c,v 1.54 2024/09/06 09:57:32 tb Exp $ */
/* ====================================================================
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
*
uint64_t OPENSSL_ia32cap_P;
+uint64_t
+crypto_cpu_caps_ia32(void)
+{
+ return OPENSSL_ia32cap_P;
+}
+
#if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM)
#define OPENSSL_CPUID_SETUP
void
}
#endif
+#else
+uint64_t
+crypto_cpu_caps_ia32(void)
+{
+ return 0;
+}
#endif
#if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ)
-/* $OpenBSD: crypto_internal.h,v 1.11 2024/08/11 13:02:39 jsing Exp $ */
+/* $OpenBSD: crypto_internal.h,v 1.12 2024/09/06 09:57:32 tb Exp $ */
/*
* Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
*
}
#endif
+uint64_t crypto_cpu_caps_ia32(void);
+
#endif
-/* $OpenBSD: e_aes.c,v 1.58 2024/04/09 13:52:41 beck Exp $ */
+/* $OpenBSD: e_aes.c,v 1.59 2024/09/06 09:57:32 tb Exp $ */
/* ====================================================================
* Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.
*
#include <openssl/opensslconf.h>
+#include "crypto_internal.h"
+
#ifndef OPENSSL_NO_AES
#include <openssl/aes.h>
#include <openssl/err.h>
#include "x86_arch.h"
#ifdef VPAES_ASM
-#define VPAES_CAPABLE (OPENSSL_cpu_caps() & CPUCAP_MASK_SSSE3)
+#define VPAES_CAPABLE (crypto_cpu_caps_ia32() & CPUCAP_MASK_SSSE3)
#endif
#ifdef BSAES_ASM
#define BSAES_CAPABLE VPAES_CAPABLE
/*
* AES-NI section
*/
-#define AESNI_CAPABLE (OPENSSL_cpu_caps() & CPUCAP_MASK_AESNI)
+#define AESNI_CAPABLE (crypto_cpu_caps_ia32() & CPUCAP_MASK_AESNI)
int aesni_set_encrypt_key(const unsigned char *userKey, int bits,
AES_KEY *key);
-/* $OpenBSD: gcm128.c,v 1.26 2023/08/10 07:18:43 jsing Exp $ */
+/* $OpenBSD: gcm128.c,v 1.27 2024/09/06 09:57:32 tb Exp $ */
/* ====================================================================
* Copyright (c) 2010 The OpenSSL Project. All rights reserved.
*
#define OPENSSL_FIPSAPI
+#include <string.h>
+
#include <openssl/crypto.h>
+
+#include "crypto_internal.h"
#include "modes_local.h"
-#include <string.h>
#ifndef MODES_DEBUG
# ifndef NDEBUG
# if defined(GHASH_ASM_X86_OR_64)
# if !defined(GHASH_ASM_X86) || defined(OPENSSL_IA32_SSE2)
/* check FXSR and PCLMULQDQ bits */
- if ((OPENSSL_cpu_caps() & (CPUCAP_MASK_FXSR | CPUCAP_MASK_PCLMUL)) ==
+ if ((crypto_cpu_caps_ia32() & (CPUCAP_MASK_FXSR | CPUCAP_MASK_PCLMUL)) ==
(CPUCAP_MASK_FXSR | CPUCAP_MASK_PCLMUL)) {
gcm_init_clmul(ctx->Htable, ctx->H.u);
ctx->gmult = gcm_gmult_clmul;
gcm_init_4bit(ctx->Htable, ctx->H.u);
# if defined(GHASH_ASM_X86) /* x86 only */
# if defined(OPENSSL_IA32_SSE2)
- if (OPENSSL_cpu_caps() & CPUCAP_MASK_SSE) { /* check SSE bit */
+ if (crypto_cpu_caps_ia32() & CPUCAP_MASK_SSE) { /* check SSE bit */
# else
- if (OPENSSL_cpu_caps() & CPUCAP_MASK_MMX) { /* check MMX bit */
+ if (crypto_cpu_caps_ia32() & CPUCAP_MASK_MMX) { /* check MMX bit */
# endif
ctx->gmult = gcm_gmult_4bit_mmx;
ctx->ghash = gcm_ghash_4bit_mmx;