From b761d24c0b5d0d9ad512e141f454aa88f53007e5 Mon Sep 17 00:00:00 2001 From: jsing Date: Thu, 17 Oct 2024 14:27:57 +0000 Subject: [PATCH] Provide crypto_cpu_caps_init() as a CPU capability detection entry point. This can be overridden on a per-architecture basis. The default version calls OPENSSL_cpuid_setup(), which will be eventually replaced/removed. ok joshua@ tb@ --- lib/libcrypto/cryptlib.c | 12 +++++++++++- lib/libcrypto/crypto_init.c | 7 ++++--- lib/libcrypto/crypto_internal.h | 4 +++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/libcrypto/cryptlib.c b/lib/libcrypto/cryptlib.c index fe15135ed98..60f14eba125 100644 --- a/lib/libcrypto/cryptlib.c +++ b/lib/libcrypto/cryptlib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptlib.c,v 1.55 2024/10/17 14:09:29 jsing Exp $ */ +/* $OpenBSD: cryptlib.c,v 1.56 2024/10/17 14:27:57 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * @@ -124,6 +124,8 @@ #include #include +#include "cryptlib.h" +#include "crypto_internal.h" #include "crypto_local.h" #include "x86_arch.h" @@ -369,6 +371,14 @@ OPENSSL_cpuid_setup(void) } #endif +#ifndef HAVE_CRYPTO_CPU_CAPS_INIT +void +crypto_cpu_caps_init(void) +{ + OPENSSL_cpuid_setup(); +} +#endif + uint64_t OPENSSL_cpu_caps(void) { diff --git a/lib/libcrypto/crypto_init.c b/lib/libcrypto/crypto_init.c index d2d06f87df3..6016d1ae409 100644 --- a/lib/libcrypto/crypto_init.c +++ b/lib/libcrypto/crypto_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_init.c,v 1.21 2024/04/10 14:51:02 beck Exp $ */ +/* $OpenBSD: crypto_init.c,v 1.22 2024/10/17 14:27:57 jsing Exp $ */ /* * Copyright (c) 2018 Bob Beck * @@ -27,7 +27,7 @@ #include #include -#include "cryptlib.h" +#include "crypto_internal.h" #include "x509_issuer_cache.h" int OpenSSL_config(const char *); @@ -48,7 +48,8 @@ OPENSSL_init_crypto_internal(void) { crypto_init_thread = pthread_self(); - OPENSSL_cpuid_setup(); + crypto_cpu_caps_init(); + ERR_load_crypto_strings(); } diff --git a/lib/libcrypto/crypto_internal.h b/lib/libcrypto/crypto_internal.h index fc617472ad6..2c2e63cc0d2 100644 --- a/lib/libcrypto/crypto_internal.h +++ b/lib/libcrypto/crypto_internal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_internal.h,v 1.12 2024/09/06 09:57:32 tb Exp $ */ +/* $OpenBSD: crypto_internal.h,v 1.13 2024/10/17 14:27:57 jsing Exp $ */ /* * Copyright (c) 2023 Joel Sing * @@ -220,6 +220,8 @@ crypto_ror_u64(uint64_t v, size_t shift) } #endif +void crypto_cpu_caps_init(void); + uint64_t crypto_cpu_caps_ia32(void); #endif -- 2.20.1