-/* $OpenBSD: cryptlib.c,v 1.52 2024/07/09 07:16:44 beck Exp $ */
+/* $OpenBSD: cryptlib.c,v 1.53 2024/08/31 12:43:58 jsing Exp $ */
/* ====================================================================
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
*
#include <openssl/crypto.h>
#include "crypto_local.h"
+#include "x86_arch.h"
+
+/* Machine independent capabilities. */
+uint64_t crypto_cpu_caps;
static void (*locking_callback)(int mode, int type,
const char *file, int line) = NULL;
uint64_t OPENSSL_ia32cap_P;
-uint64_t
-OPENSSL_cpu_caps(void)
-{
- return OPENSSL_ia32cap_P;
-}
-LCRYPTO_ALIAS(OPENSSL_cpu_caps);
-
#if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM)
#define OPENSSL_CPUID_SETUP
void
return;
trigger = 1;
OPENSSL_ia32cap_P = OPENSSL_ia32_cpuid();
+
+ if ((OPENSSL_ia32cap_P & CPUCAP_MASK_AESNI) != 0)
+ crypto_cpu_caps |= CRYPTO_CPU_CAPS_ACCELERATED_AES;
}
#endif
-#else
-uint64_t
-OPENSSL_cpu_caps(void)
-{
- return 0;
-}
-LCRYPTO_ALIAS(OPENSSL_cpu_caps);
#endif
#if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ)
}
#endif
+uint64_t
+OPENSSL_cpu_caps(void)
+{
+ return crypto_cpu_caps;
+}
+LCRYPTO_ALIAS(OPENSSL_cpu_caps);
+
static void
OPENSSL_showfatal(const char *fmta, ...)
{
-/* $OpenBSD: crypto.h,v 1.74 2024/04/10 15:13:23 beck Exp $ */
+/* $OpenBSD: crypto.h,v 1.75 2024/08/31 12:43:58 jsing Exp $ */
/* ====================================================================
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
*
void OpenSSLDie(const char *file, int line, const char *assertion);
#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
-uint64_t OPENSSL_cpu_caps(void);
-
int FIPS_mode(void);
int FIPS_mode_set(int r);
int OPENSSL_init_crypto(uint64_t opts, const void *settings);
void OPENSSL_cleanup(void);
+/*
+ * CPU capabilities.
+ */
+#define CRYPTO_CPU_CAPS_ACCELERATED_AES 0x00000001ULL
+
+uint64_t OPENSSL_cpu_caps(void);
+
/*
* OpenSSL helpfully put OPENSSL_gmtime() here because all other time related
* functions are in asn1.h.