Provide crypto_cpu_caps_init() as a CPU capability detection entry point.
authorjsing <jsing@openbsd.org>
Thu, 17 Oct 2024 14:27:57 +0000 (14:27 +0000)
committerjsing <jsing@openbsd.org>
Thu, 17 Oct 2024 14:27:57 +0000 (14:27 +0000)
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
lib/libcrypto/crypto_init.c
lib/libcrypto/crypto_internal.h

index fe15135..60f14eb 100644 (file)
@@ -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.
  *
 #include <openssl/opensslconf.h>
 #include <openssl/crypto.h>
 
+#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)
 {
index d2d06f8..6016d1a 100644 (file)
@@ -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 <beck@openbsd.org>
  *
@@ -27,7 +27,7 @@
 #include <openssl/objects.h>
 #include <openssl/x509v3.h>
 
-#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();
 }
 
index fc61747..2c2e63c 100644 (file)
@@ -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 <jsing@openbsd.org>
  *
@@ -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