diff options
Diffstat (limited to 'src/lib/libcrypto/crypto_init.c')
| -rw-r--r-- | src/lib/libcrypto/crypto_init.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/lib/libcrypto/crypto_init.c b/src/lib/libcrypto/crypto_init.c index 6016d1ae40..ae4914e358 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.22 2024/10/17 14:27:57 jsing Exp $ */ | 1 | /* $OpenBSD: crypto_init.c,v 1.26 2025/06/11 07:41:12 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> |
| 4 | * | 4 | * |
| @@ -22,12 +22,12 @@ | |||
| 22 | 22 | ||
| 23 | #include <openssl/asn1.h> | 23 | #include <openssl/asn1.h> |
| 24 | #include <openssl/conf.h> | 24 | #include <openssl/conf.h> |
| 25 | #include <openssl/err.h> | ||
| 26 | #include <openssl/evp.h> | 25 | #include <openssl/evp.h> |
| 27 | #include <openssl/objects.h> | 26 | #include <openssl/objects.h> |
| 28 | #include <openssl/x509v3.h> | 27 | #include <openssl/x509v3.h> |
| 29 | 28 | ||
| 30 | #include "crypto_internal.h" | 29 | #include "crypto_internal.h" |
| 30 | #include "err_local.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 *); |
| @@ -37,6 +37,30 @@ static pthread_once_t crypto_init_once = PTHREAD_ONCE_INIT; | |||
| 37 | static pthread_t crypto_init_thread; | 37 | static pthread_t crypto_init_thread; |
| 38 | static int crypto_init_cleaned_up; | 38 | static int crypto_init_cleaned_up; |
| 39 | 39 | ||
| 40 | void openssl_init_crypto_constructor(void) __attribute__((constructor)); | ||
| 41 | |||
| 42 | #ifndef HAVE_CRYPTO_CPU_CAPS_INIT | ||
| 43 | void | ||
| 44 | crypto_cpu_caps_init(void) | ||
| 45 | { | ||
| 46 | } | ||
| 47 | #endif | ||
| 48 | |||
| 49 | /* | ||
| 50 | * This function is invoked as a constructor when the library is loaded. The | ||
| 51 | * code run from here must not allocate memory or trigger signals. The only | ||
| 52 | * safe code is to read data and update global variables. | ||
| 53 | */ | ||
| 54 | void | ||
| 55 | openssl_init_crypto_constructor(void) | ||
| 56 | { | ||
| 57 | crypto_cpu_caps_init(); | ||
| 58 | } | ||
| 59 | |||
| 60 | /* | ||
| 61 | * This is used by various configure scripts to check availability of libcrypto, | ||
| 62 | * so we need to keep it. | ||
| 63 | */ | ||
| 40 | void | 64 | void |
| 41 | OPENSSL_init(void) | 65 | OPENSSL_init(void) |
| 42 | { | 66 | { |
| @@ -48,8 +72,6 @@ OPENSSL_init_crypto_internal(void) | |||
| 48 | { | 72 | { |
| 49 | crypto_init_thread = pthread_self(); | 73 | crypto_init_thread = pthread_self(); |
| 50 | 74 | ||
| 51 | crypto_cpu_caps_init(); | ||
| 52 | |||
| 53 | ERR_load_crypto_strings(); | 75 | ERR_load_crypto_strings(); |
| 54 | } | 76 | } |
| 55 | 77 | ||
