diff options
author | jsing <> | 2024-10-17 14:27:57 +0000 |
---|---|---|
committer | jsing <> | 2024-10-17 14:27:57 +0000 |
commit | 978d3a277baeb25c75e71e4d12342c47d1764205 (patch) | |
tree | 9a374ab05acc812ea22b6eb26d787771e956e515 | |
parent | 3f67c2a09f63d9b79af4479ddb350c665f82747f (diff) | |
download | openbsd-978d3a277baeb25c75e71e4d12342c47d1764205.tar.gz openbsd-978d3a277baeb25c75e71e4d12342c47d1764205.tar.bz2 openbsd-978d3a277baeb25c75e71e4d12342c47d1764205.zip |
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@
-rw-r--r-- | src/lib/libcrypto/cryptlib.c | 12 | ||||
-rw-r--r-- | src/lib/libcrypto/crypto_init.c | 7 | ||||
-rw-r--r-- | src/lib/libcrypto/crypto_internal.h | 4 |
3 files changed, 18 insertions, 5 deletions
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c index fe15135ed9..60f14eba12 100644 --- a/src/lib/libcrypto/cryptlib.c +++ b/src/lib/libcrypto/cryptlib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cryptlib.c,v 1.55 2024/10/17 14:09:29 jsing Exp $ */ | 1 | /* $OpenBSD: cryptlib.c,v 1.56 2024/10/17 14:27:57 jsing Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -124,6 +124,8 @@ | |||
124 | #include <openssl/opensslconf.h> | 124 | #include <openssl/opensslconf.h> |
125 | #include <openssl/crypto.h> | 125 | #include <openssl/crypto.h> |
126 | 126 | ||
127 | #include "cryptlib.h" | ||
128 | #include "crypto_internal.h" | ||
127 | #include "crypto_local.h" | 129 | #include "crypto_local.h" |
128 | #include "x86_arch.h" | 130 | #include "x86_arch.h" |
129 | 131 | ||
@@ -369,6 +371,14 @@ OPENSSL_cpuid_setup(void) | |||
369 | } | 371 | } |
370 | #endif | 372 | #endif |
371 | 373 | ||
374 | #ifndef HAVE_CRYPTO_CPU_CAPS_INIT | ||
375 | void | ||
376 | crypto_cpu_caps_init(void) | ||
377 | { | ||
378 | OPENSSL_cpuid_setup(); | ||
379 | } | ||
380 | #endif | ||
381 | |||
372 | uint64_t | 382 | uint64_t |
373 | OPENSSL_cpu_caps(void) | 383 | OPENSSL_cpu_caps(void) |
374 | { | 384 | { |
diff --git a/src/lib/libcrypto/crypto_init.c b/src/lib/libcrypto/crypto_init.c index d2d06f87df..6016d1ae40 100644 --- a/src/lib/libcrypto/crypto_init.c +++ b/src/lib/libcrypto/crypto_init.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: crypto_init.c,v 1.21 2024/04/10 14:51:02 beck Exp $ */ | 1 | /* $OpenBSD: crypto_init.c,v 1.22 2024/10/17 14:27:57 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> |
4 | * | 4 | * |
@@ -27,7 +27,7 @@ | |||
27 | #include <openssl/objects.h> | 27 | #include <openssl/objects.h> |
28 | #include <openssl/x509v3.h> | 28 | #include <openssl/x509v3.h> |
29 | 29 | ||
30 | #include "cryptlib.h" | 30 | #include "crypto_internal.h" |
31 | #include "x509_issuer_cache.h" | 31 | #include "x509_issuer_cache.h" |
32 | 32 | ||
33 | int OpenSSL_config(const char *); | 33 | int OpenSSL_config(const char *); |
@@ -48,7 +48,8 @@ OPENSSL_init_crypto_internal(void) | |||
48 | { | 48 | { |
49 | crypto_init_thread = pthread_self(); | 49 | crypto_init_thread = pthread_self(); |
50 | 50 | ||
51 | OPENSSL_cpuid_setup(); | 51 | crypto_cpu_caps_init(); |
52 | |||
52 | ERR_load_crypto_strings(); | 53 | ERR_load_crypto_strings(); |
53 | } | 54 | } |
54 | 55 | ||
diff --git a/src/lib/libcrypto/crypto_internal.h b/src/lib/libcrypto/crypto_internal.h index fc617472ad..2c2e63cc0d 100644 --- a/src/lib/libcrypto/crypto_internal.h +++ b/src/lib/libcrypto/crypto_internal.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: crypto_internal.h,v 1.12 2024/09/06 09:57:32 tb Exp $ */ | 1 | /* $OpenBSD: crypto_internal.h,v 1.13 2024/10/17 14:27:57 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -220,6 +220,8 @@ crypto_ror_u64(uint64_t v, size_t shift) | |||
220 | } | 220 | } |
221 | #endif | 221 | #endif |
222 | 222 | ||
223 | void crypto_cpu_caps_init(void); | ||
224 | |||
223 | uint64_t crypto_cpu_caps_ia32(void); | 225 | uint64_t crypto_cpu_caps_ia32(void); |
224 | 226 | ||
225 | #endif | 227 | #endif |