diff options
author | jsing <> | 2024-08-31 12:43:58 +0000 |
---|---|---|
committer | jsing <> | 2024-08-31 12:43:58 +0000 |
commit | 4d860a7d33bdb05e5782330d5085fda5e809bd72 (patch) | |
tree | ce0f04393328694fbea716953d4d7ed39d8db04c /src/lib/libcrypto/cryptlib.c | |
parent | 2049348fa6a328167273a9ddbd4a308041e0fe16 (diff) | |
download | openbsd-4d860a7d33bdb05e5782330d5085fda5e809bd72.tar.gz openbsd-4d860a7d33bdb05e5782330d5085fda5e809bd72.tar.bz2 openbsd-4d860a7d33bdb05e5782330d5085fda5e809bd72.zip |
Make OPENSSL_cpu_caps() machine independent.
OPENSSL_cpu_caps() is currently machine dependent and exposes CPUID data
on amd64 and i386. However, what it is really used for is to indicate
whether specific algorithms are accelerated on the given hardware. Change
OPENSSL_cpu_caps() so that it returns a machine indepent value, which
decouples it from amd64/i386 and will allow it to be used appropriately
on other platforms in the future.
ok tb@
Diffstat (limited to 'src/lib/libcrypto/cryptlib.c')
-rw-r--r-- | src/lib/libcrypto/cryptlib.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c index b9ea39285d..d929b0daaa 100644 --- a/src/lib/libcrypto/cryptlib.c +++ b/src/lib/libcrypto/cryptlib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cryptlib.c,v 1.52 2024/07/09 07:16:44 beck Exp $ */ | 1 | /* $OpenBSD: cryptlib.c,v 1.53 2024/08/31 12:43:58 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 | * |
@@ -125,6 +125,10 @@ | |||
125 | #include <openssl/crypto.h> | 125 | #include <openssl/crypto.h> |
126 | 126 | ||
127 | #include "crypto_local.h" | 127 | #include "crypto_local.h" |
128 | #include "x86_arch.h" | ||
129 | |||
130 | /* Machine independent capabilities. */ | ||
131 | uint64_t crypto_cpu_caps; | ||
128 | 132 | ||
129 | static void (*locking_callback)(int mode, int type, | 133 | static void (*locking_callback)(int mode, int type, |
130 | const char *file, int line) = NULL; | 134 | const char *file, int line) = NULL; |
@@ -330,13 +334,6 @@ CRYPTO_THREADID_hash(const CRYPTO_THREADID *id) | |||
330 | 334 | ||
331 | uint64_t OPENSSL_ia32cap_P; | 335 | uint64_t OPENSSL_ia32cap_P; |
332 | 336 | ||
333 | uint64_t | ||
334 | OPENSSL_cpu_caps(void) | ||
335 | { | ||
336 | return OPENSSL_ia32cap_P; | ||
337 | } | ||
338 | LCRYPTO_ALIAS(OPENSSL_cpu_caps); | ||
339 | |||
340 | #if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) | 337 | #if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) |
341 | #define OPENSSL_CPUID_SETUP | 338 | #define OPENSSL_CPUID_SETUP |
342 | void | 339 | void |
@@ -349,16 +346,12 @@ OPENSSL_cpuid_setup(void) | |||
349 | return; | 346 | return; |
350 | trigger = 1; | 347 | trigger = 1; |
351 | OPENSSL_ia32cap_P = OPENSSL_ia32_cpuid(); | 348 | OPENSSL_ia32cap_P = OPENSSL_ia32_cpuid(); |
349 | |||
350 | if ((OPENSSL_ia32cap_P & CPUCAP_MASK_AESNI) != 0) | ||
351 | crypto_cpu_caps |= CRYPTO_CPU_CAPS_ACCELERATED_AES; | ||
352 | } | 352 | } |
353 | #endif | 353 | #endif |
354 | 354 | ||
355 | #else | ||
356 | uint64_t | ||
357 | OPENSSL_cpu_caps(void) | ||
358 | { | ||
359 | return 0; | ||
360 | } | ||
361 | LCRYPTO_ALIAS(OPENSSL_cpu_caps); | ||
362 | #endif | 355 | #endif |
363 | 356 | ||
364 | #if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ) | 357 | #if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ) |
@@ -368,6 +361,13 @@ OPENSSL_cpuid_setup(void) | |||
368 | } | 361 | } |
369 | #endif | 362 | #endif |
370 | 363 | ||
364 | uint64_t | ||
365 | OPENSSL_cpu_caps(void) | ||
366 | { | ||
367 | return crypto_cpu_caps; | ||
368 | } | ||
369 | LCRYPTO_ALIAS(OPENSSL_cpu_caps); | ||
370 | |||
371 | static void | 371 | static void |
372 | OPENSSL_showfatal(const char *fmta, ...) | 372 | OPENSSL_showfatal(const char *fmta, ...) |
373 | { | 373 | { |