diff options
| author | kenjiro <> | 2026-08-30 12:19:37 +0000 |
|---|---|---|
| committer | kenjiro <> | 2026-08-30 12:19:37 +0000 |
| commit | 5931045c664b500427fb54c31fab4de3e92bb159 (patch) | |
| tree | 6bcb237ddd3233dde465de629eee51c4c1a0ed2c /src | |
| parent | 6b13eef79d2dc54c1b0203f967b3fc8b8971df78 (diff) | |
| download | openbsd-5931045c664b500427fb54c31fab4de3e92bb159.tar.gz openbsd-5931045c664b500427fb54c31fab4de3e92bb159.tar.bz2 openbsd-5931045c664b500427fb54c31fab4de3e92bb159.zip | |
Make CRYPTO_cleanup_all_ex_data() a compatibility no-op
The ex_data callback registry is process-wide, but this API could free
it while other threads were still using libcrypto, resulting in a
use-after-free.
Retain the public symbol as a compatibility no-op and mark it
deprecated. Move the actual cleanup to an internal function called by
OPENSSL_cleanup(). Replace the in-tree callers with OPENSSL_cleanup()
at final shutdown to preserve cleanup behavior and coverage.
Document both APIs and the requirement that OPENSSL_cleanup() only be
called after all threads and components have stopped using libcrypto.
ok tb
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/crypto.h | 5 | ||||
| -rw-r--r-- | src/lib/libcrypto/crypto_ex_data.c | 15 | ||||
| -rw-r--r-- | src/lib/libcrypto/crypto_init.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/crypto_internal.h | 3 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/CRYPTO_set_ex_data.3 | 27 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/OPENSSL_init_crypto.3 | 35 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/dsa/dsatest.c | 7 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/ec/ectest.c | 5 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/ecdsa/ecdsatest.c | 5 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/evp/evptest.c | 6 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/exdata/exdata_test.c | 5 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/pbkdf2/pbkdf2.c | 6 | ||||
| -rw-r--r-- | src/regress/lib/libssl/ssl/ssltest.c | 8 | ||||
| -rw-r--r-- | src/usr.bin/openssl/openssl.c | 9 |
14 files changed, 93 insertions, 47 deletions
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h index 9fcf868403..2a121dda85 100644 --- a/src/lib/libcrypto/crypto.h +++ b/src/lib/libcrypto/crypto.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: crypto.h,v 1.80 2025/09/28 07:52:53 tb Exp $ */ | 1 | /* $OpenBSD: crypto.h,v 1.81 2026/08/30 12:19:37 kenjiro 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 | * |
| @@ -305,8 +305,7 @@ void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); | |||
| 305 | * (relative to the class type involved) */ | 305 | * (relative to the class type involved) */ |
| 306 | int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); | 306 | int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); |
| 307 | void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx); | 307 | void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx); |
| 308 | /* This function cleans up all "ex_data" state. It mustn't be called under | 308 | /* Deprecated no-op retained for compatibility. */ |
| 309 | * potential race-conditions. */ | ||
| 310 | void CRYPTO_cleanup_all_ex_data(void); | 309 | void CRYPTO_cleanup_all_ex_data(void); |
| 311 | 310 | ||
| 312 | void CRYPTO_lock(int mode, int type, const char *file, int line); | 311 | void CRYPTO_lock(int mode, int type, const char *file, int line); |
diff --git a/src/lib/libcrypto/crypto_ex_data.c b/src/lib/libcrypto/crypto_ex_data.c index 233905f888..2066098653 100644 --- a/src/lib/libcrypto/crypto_ex_data.c +++ b/src/lib/libcrypto/crypto_ex_data.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: crypto_ex_data.c,v 1.6 2025/06/15 15:58:56 tb Exp $ */ | 1 | /* $OpenBSD: crypto_ex_data.c,v 1.7 2026/08/30 12:19:37 kenjiro Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -19,6 +19,8 @@ | |||
| 19 | 19 | ||
| 20 | #include <openssl/crypto.h> | 20 | #include <openssl/crypto.h> |
| 21 | 21 | ||
| 22 | #include "crypto_internal.h" | ||
| 23 | |||
| 22 | #define CRYPTO_EX_DATA_MAX_INDEX 32 | 24 | #define CRYPTO_EX_DATA_MAX_INDEX 32 |
| 23 | 25 | ||
| 24 | struct crypto_ex_data { | 26 | struct crypto_ex_data { |
| @@ -151,6 +153,16 @@ LCRYPTO_ALIAS(CRYPTO_get_ex_new_index); | |||
| 151 | void | 153 | void |
| 152 | CRYPTO_cleanup_all_ex_data(void) | 154 | CRYPTO_cleanup_all_ex_data(void) |
| 153 | { | 155 | { |
| 156 | } | ||
| 157 | LCRYPTO_ALIAS(CRYPTO_cleanup_all_ex_data); | ||
| 158 | |||
| 159 | /* | ||
| 160 | * Free process-wide ex_data state during OPENSSL_cleanup(). The caller must | ||
| 161 | * ensure that no other thread is using libcrypto. | ||
| 162 | */ | ||
| 163 | void | ||
| 164 | crypto_ex_data_cleanup(void) | ||
| 165 | { | ||
| 154 | struct crypto_ex_data_class *class; | 166 | struct crypto_ex_data_class *class; |
| 155 | int i, j; | 167 | int i, j; |
| 156 | 168 | ||
| @@ -173,7 +185,6 @@ CRYPTO_cleanup_all_ex_data(void) | |||
| 173 | free(classes); | 185 | free(classes); |
| 174 | classes = NULL; | 186 | classes = NULL; |
| 175 | } | 187 | } |
| 176 | LCRYPTO_ALIAS(CRYPTO_cleanup_all_ex_data); | ||
| 177 | 188 | ||
| 178 | static void | 189 | static void |
| 179 | crypto_ex_data_clear(CRYPTO_EX_DATA *exdata) | 190 | crypto_ex_data_clear(CRYPTO_EX_DATA *exdata) |
diff --git a/src/lib/libcrypto/crypto_init.c b/src/lib/libcrypto/crypto_init.c index ae4914e358..5b7ce3d4fa 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.26 2025/06/11 07:41:12 tb Exp $ */ | 1 | /* $OpenBSD: crypto_init.c,v 1.27 2026/08/30 12:19:37 kenjiro Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> |
| 4 | * | 4 | * |
| @@ -107,7 +107,7 @@ OPENSSL_cleanup(void) | |||
| 107 | /* This currently calls init... */ | 107 | /* This currently calls init... */ |
| 108 | ERR_free_strings(); | 108 | ERR_free_strings(); |
| 109 | 109 | ||
| 110 | CRYPTO_cleanup_all_ex_data(); | 110 | crypto_ex_data_cleanup(); |
| 111 | EVP_cleanup(); | 111 | EVP_cleanup(); |
| 112 | 112 | ||
| 113 | X509_VERIFY_PARAM_table_cleanup(); | 113 | X509_VERIFY_PARAM_table_cleanup(); |
diff --git a/src/lib/libcrypto/crypto_internal.h b/src/lib/libcrypto/crypto_internal.h index 058245e95e..2dce750724 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.16 2025/07/22 09:18:02 jsing Exp $ */ | 1 | /* $OpenBSD: crypto_internal.h,v 1.17 2026/08/30 12:19:37 kenjiro Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -299,5 +299,6 @@ crypto_ror_u64(uint64_t v, size_t shift) | |||
| 299 | #endif | 299 | #endif |
| 300 | 300 | ||
| 301 | void crypto_cpu_caps_init(void); | 301 | void crypto_cpu_caps_init(void); |
| 302 | void crypto_ex_data_cleanup(void); | ||
| 302 | 303 | ||
| 303 | #endif | 304 | #endif |
diff --git a/src/lib/libcrypto/man/CRYPTO_set_ex_data.3 b/src/lib/libcrypto/man/CRYPTO_set_ex_data.3 index ae2b04b528..00b5785533 100644 --- a/src/lib/libcrypto/man/CRYPTO_set_ex_data.3 +++ b/src/lib/libcrypto/man/CRYPTO_set_ex_data.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: CRYPTO_set_ex_data.3,v 1.17 2026/08/23 04:46:31 jsg Exp $ | 1 | .\" $OpenBSD: CRYPTO_set_ex_data.3,v 1.18 2026/08/30 12:19:37 kenjiro Exp $ |
| 2 | .\" | 2 | .\" |
| 3 | .\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org> | 3 | .\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org> |
| 4 | .\" | 4 | .\" |
| @@ -14,7 +14,7 @@ | |||
| 14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | .\" | 16 | .\" |
| 17 | .Dd $Mdocdate: August 23 2026 $ | 17 | .Dd $Mdocdate: August 30 2026 $ |
| 18 | .Dt CRYPTO_SET_EX_DATA 3 | 18 | .Dt CRYPTO_SET_EX_DATA 3 |
| 19 | .Os | 19 | .Os |
| 20 | .Sh NAME | 20 | .Sh NAME |
| @@ -25,7 +25,8 @@ | |||
| 25 | .Nm CRYPTO_new_ex_data , | 25 | .Nm CRYPTO_new_ex_data , |
| 26 | .Nm CRYPTO_set_ex_data , | 26 | .Nm CRYPTO_set_ex_data , |
| 27 | .Nm CRYPTO_get_ex_data , | 27 | .Nm CRYPTO_get_ex_data , |
| 28 | .Nm CRYPTO_free_ex_data | 28 | .Nm CRYPTO_free_ex_data , |
| 29 | .Nm CRYPTO_cleanup_all_ex_data | ||
| 29 | .Nd low-level functions for application specific data | 30 | .Nd low-level functions for application specific data |
| 30 | .Sh SYNOPSIS | 31 | .Sh SYNOPSIS |
| 31 | .Lb libcrypto | 32 | .Lb libcrypto |
| @@ -89,6 +90,8 @@ | |||
| 89 | .Fa "void *parent" | 90 | .Fa "void *parent" |
| 90 | .Fa "CRYPTO_EX_DATA *ad" | 91 | .Fa "CRYPTO_EX_DATA *ad" |
| 91 | .Fc | 92 | .Fc |
| 93 | .Ft void | ||
| 94 | .Fn CRYPTO_cleanup_all_ex_data void | ||
| 92 | .Sh DESCRIPTION | 95 | .Sh DESCRIPTION |
| 93 | The library implements the functions documented in the | 96 | The library implements the functions documented in the |
| 94 | .Xr RSA_get_ex_new_index 3 | 97 | .Xr RSA_get_ex_new_index 3 |
| @@ -342,6 +345,20 @@ Despite its name, | |||
| 342 | does not free | 345 | does not free |
| 343 | .Fa ad | 346 | .Fa ad |
| 344 | itself. | 347 | itself. |
| 348 | .Pp | ||
| 349 | .Fn CRYPTO_cleanup_all_ex_data | ||
| 350 | is deprecated and has no effect. | ||
| 351 | It is retained for source and binary compatibility only. | ||
| 352 | Application programs should not call it after individual operations, | ||
| 353 | from individual library components, or during process shutdown. | ||
| 354 | No replacement call is needed. | ||
| 355 | .Pp | ||
| 356 | In particular, | ||
| 357 | .Xr OPENSSL_cleanup 3 | ||
| 358 | is not a replacement for | ||
| 359 | .Fn CRYPTO_cleanup_all_ex_data . | ||
| 360 | It tears down process-wide library state and is only intended for final | ||
| 361 | shutdown after all threads using libcrypto have stopped. | ||
| 345 | .Sh RETURN VALUES | 362 | .Sh RETURN VALUES |
| 346 | .Fn CRYPTO_get_ex_new_index | 363 | .Fn CRYPTO_get_ex_new_index |
| 347 | returns a new index equal to or greater than 1 | 364 | returns a new index equal to or greater than 1 |
| @@ -425,6 +442,10 @@ and | |||
| 425 | .Fn CRYPTO_EX_dup | 442 | .Fn CRYPTO_EX_dup |
| 426 | first appeared in OpenSSL 0.9.5 and have been available since | 443 | first appeared in OpenSSL 0.9.5 and have been available since |
| 427 | .Ox 2.7 . | 444 | .Ox 2.7 . |
| 445 | .Pp | ||
| 446 | .Fn CRYPTO_cleanup_all_ex_data | ||
| 447 | first appeared in OpenSSL 0.9.7 and has been available since | ||
| 448 | .Ox 3.2 . | ||
| 428 | .Sh CAVEATS | 449 | .Sh CAVEATS |
| 429 | If a program installs callback functions, the last call to | 450 | If a program installs callback functions, the last call to |
| 430 | .Fn CRYPTO_get_ex_new_index | 451 | .Fn CRYPTO_get_ex_new_index |
diff --git a/src/lib/libcrypto/man/OPENSSL_init_crypto.3 b/src/lib/libcrypto/man/OPENSSL_init_crypto.3 index 5c29d55aa9..24756bc396 100644 --- a/src/lib/libcrypto/man/OPENSSL_init_crypto.3 +++ b/src/lib/libcrypto/man/OPENSSL_init_crypto.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: OPENSSL_init_crypto.3,v 1.7 2025/06/09 12:43:53 schwarze Exp $ | 1 | .\" $OpenBSD: OPENSSL_init_crypto.3,v 1.8 2026/08/30 12:19:37 kenjiro Exp $ |
| 2 | .\" Copyright (c) 2018, 2020 Ingo Schwarze <schwarze@openbsd.org> | 2 | .\" Copyright (c) 2018, 2020 Ingo Schwarze <schwarze@openbsd.org> |
| 3 | .\" | 3 | .\" |
| 4 | .\" Permission to use, copy, modify, and distribute this software for any | 4 | .\" Permission to use, copy, modify, and distribute this software for any |
| @@ -13,13 +13,14 @@ | |||
| 13 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 13 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 14 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | .\" | 15 | .\" |
| 16 | .Dd $Mdocdate: June 9 2025 $ | 16 | .Dd $Mdocdate: August 30 2026 $ |
| 17 | .Dt OPENSSL_INIT_CRYPTO 3 | 17 | .Dt OPENSSL_INIT_CRYPTO 3 |
| 18 | .Os | 18 | .Os |
| 19 | .Sh NAME | 19 | .Sh NAME |
| 20 | .Nm OPENSSL_init_crypto , | 20 | .Nm OPENSSL_init_crypto , |
| 21 | .Nm OPENSSL_init | 21 | .Nm OPENSSL_init , |
| 22 | .Nd initialise the crypto library | 22 | .Nm OPENSSL_cleanup |
| 23 | .Nd initialise and shut down the crypto library | ||
| 23 | .Sh SYNOPSIS | 24 | .Sh SYNOPSIS |
| 24 | .Lb libcrypto | 25 | .Lb libcrypto |
| 25 | .In openssl/crypto.h | 26 | .In openssl/crypto.h |
| @@ -30,8 +31,13 @@ | |||
| 30 | .Fc | 31 | .Fc |
| 31 | .Ft void | 32 | .Ft void |
| 32 | .Fn OPENSSL_init void | 33 | .Fn OPENSSL_init void |
| 34 | .Ft void | ||
| 35 | .Fn OPENSSL_cleanup void | ||
| 33 | .Sh DESCRIPTION | 36 | .Sh DESCRIPTION |
| 34 | These functions are deprecated. | 37 | .Fn OPENSSL_init_crypto |
| 38 | and | ||
| 39 | .Fn OPENSSL_init | ||
| 40 | are deprecated. | ||
| 35 | It is never useful for an application program | 41 | It is never useful for an application program |
| 36 | to call either of them explicitly. | 42 | to call either of them explicitly. |
| 37 | .Pp | 43 | .Pp |
| @@ -84,6 +90,21 @@ the first one have any effect. | |||
| 84 | .Pp | 90 | .Pp |
| 85 | .Fn OPENSSL_init | 91 | .Fn OPENSSL_init |
| 86 | has no effect at all. | 92 | has no effect at all. |
| 93 | .Pp | ||
| 94 | .Fn OPENSSL_cleanup | ||
| 95 | frees process-wide resources allocated by libcrypto. | ||
| 96 | It is intended exclusively for the final shutdown of libcrypto in a process. | ||
| 97 | Before calling it, the application has to ensure that all other threads | ||
| 98 | that may use libcrypto have stopped and that no library component will use | ||
| 99 | libcrypto again. | ||
| 100 | After it returns, libcrypto cannot be reinitialized and no libcrypto or | ||
| 101 | libssl function may be called. | ||
| 102 | .Pp | ||
| 103 | .Fn OPENSSL_cleanup | ||
| 104 | is not a replacement for deprecated cleanup functions such as | ||
| 105 | .Xr CRYPTO_cleanup_all_ex_data 3 | ||
| 106 | and must not be called after individual cryptographic operations or when an | ||
| 107 | individual library component is finished with libcrypto. | ||
| 87 | .Sh RETURN VALUES | 108 | .Sh RETURN VALUES |
| 88 | .Fn OPENSSL_init_crypto | 109 | .Fn OPENSSL_init_crypto |
| 89 | is intended to return 1 on success or 0 on error. | 110 | is intended to return 1 on success or 0 on error. |
| @@ -101,6 +122,10 @@ It stopped having any effect in OpenSSL 1.1.1 and in | |||
| 101 | .Fn OPENSSL_init_crypto | 122 | .Fn OPENSSL_init_crypto |
| 102 | first appeared in OpenSSL 1.1.0 and has been available since | 123 | first appeared in OpenSSL 1.1.0 and has been available since |
| 103 | .Ox 6.3 . | 124 | .Ox 6.3 . |
| 125 | .Pp | ||
| 126 | .Fn OPENSSL_cleanup | ||
| 127 | first appeared in OpenSSL 1.1.0 and has been available since | ||
| 128 | .Ox 7.2 . | ||
| 104 | .Sh BUGS | 129 | .Sh BUGS |
| 105 | .Fn OPENSSL_init_crypto | 130 | .Fn OPENSSL_init_crypto |
| 106 | silently ignores almost all kinds of errors. | 131 | silently ignores almost all kinds of errors. |
diff --git a/src/regress/lib/libcrypto/dsa/dsatest.c b/src/regress/lib/libcrypto/dsa/dsatest.c index 3a761961f0..79c83e04bc 100644 --- a/src/regress/lib/libcrypto/dsa/dsatest.c +++ b/src/regress/lib/libcrypto/dsa/dsatest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: dsatest.c,v 1.11 2024/02/29 20:04:43 tb Exp $ */ | 1 | /* $OpenBSD: dsatest.c,v 1.12 2026/08/30 12:19:37 kenjiro Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -193,11 +193,10 @@ end: | |||
| 193 | if (!ret) | 193 | if (!ret) |
| 194 | ERR_print_errors(bio_err); | 194 | ERR_print_errors(bio_err); |
| 195 | DSA_free(dsa); | 195 | DSA_free(dsa); |
| 196 | CRYPTO_cleanup_all_ex_data(); | ||
| 197 | ERR_remove_thread_state(NULL); | ||
| 198 | ERR_free_strings(); | ||
| 199 | BIO_free(bio_err); | 196 | BIO_free(bio_err); |
| 200 | bio_err = NULL; | 197 | bio_err = NULL; |
| 198 | ERR_remove_thread_state(NULL); | ||
| 199 | OPENSSL_cleanup(); | ||
| 201 | 200 | ||
| 202 | return !ret; | 201 | return !ret; |
| 203 | } | 202 | } |
diff --git a/src/regress/lib/libcrypto/ec/ectest.c b/src/regress/lib/libcrypto/ec/ectest.c index 3e81954174..edfc9ada46 100644 --- a/src/regress/lib/libcrypto/ec/ectest.c +++ b/src/regress/lib/libcrypto/ec/ectest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ectest.c,v 1.36 2025/07/23 07:40:07 tb Exp $ */ | 1 | /* $OpenBSD: ectest.c,v 1.37 2026/08/30 12:19:37 kenjiro Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -668,9 +668,8 @@ main(int argc, char *argv[]) | |||
| 668 | 668 | ||
| 669 | prime_field_tests(); | 669 | prime_field_tests(); |
| 670 | 670 | ||
| 671 | CRYPTO_cleanup_all_ex_data(); | ||
| 672 | ERR_free_strings(); | ||
| 673 | ERR_remove_thread_state(NULL); | 671 | ERR_remove_thread_state(NULL); |
| 672 | OPENSSL_cleanup(); | ||
| 674 | 673 | ||
| 675 | return 0; | 674 | return 0; |
| 676 | } | 675 | } |
diff --git a/src/regress/lib/libcrypto/ecdsa/ecdsatest.c b/src/regress/lib/libcrypto/ecdsa/ecdsatest.c index ef724c74b5..cfc1317bda 100644 --- a/src/regress/lib/libcrypto/ecdsa/ecdsatest.c +++ b/src/regress/lib/libcrypto/ecdsa/ecdsatest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ecdsatest.c,v 1.18 2023/11/19 13:11:06 tb Exp $ */ | 1 | /* $OpenBSD: ecdsatest.c,v 1.19 2026/08/30 12:19:37 kenjiro Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -337,9 +337,8 @@ main(void) | |||
| 337 | ERR_print_errors_fp(stdout); | 337 | ERR_print_errors_fp(stdout); |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | CRYPTO_cleanup_all_ex_data(); | ||
| 341 | ERR_remove_thread_state(NULL); | 340 | ERR_remove_thread_state(NULL); |
| 342 | ERR_free_strings(); | 341 | OPENSSL_cleanup(); |
| 343 | 342 | ||
| 344 | return failed; | 343 | return failed; |
| 345 | } | 344 | } |
diff --git a/src/regress/lib/libcrypto/evp/evptest.c b/src/regress/lib/libcrypto/evp/evptest.c index 6c47e38a5f..b83ef33ce9 100644 --- a/src/regress/lib/libcrypto/evp/evptest.c +++ b/src/regress/lib/libcrypto/evp/evptest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: evptest.c,v 1.15 2024/03/30 09:49:59 tb Exp $ */ | 1 | /* $OpenBSD: evptest.c,v 1.16 2026/08/30 12:19:37 kenjiro Exp $ */ |
| 2 | /* Written by Ben Laurie, 2001 */ | 2 | /* Written by Ben Laurie, 2001 */ |
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. | 4 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. |
| @@ -431,10 +431,8 @@ main(int argc, char **argv) | |||
| 431 | } | 431 | } |
| 432 | fclose(f); | 432 | fclose(f); |
| 433 | 433 | ||
| 434 | EVP_cleanup(); | ||
| 435 | CRYPTO_cleanup_all_ex_data(); | ||
| 436 | ERR_remove_thread_state(NULL); | 434 | ERR_remove_thread_state(NULL); |
| 437 | ERR_free_strings(); | 435 | OPENSSL_cleanup(); |
| 438 | 436 | ||
| 439 | return 0; | 437 | return 0; |
| 440 | } | 438 | } |
diff --git a/src/regress/lib/libcrypto/exdata/exdata_test.c b/src/regress/lib/libcrypto/exdata/exdata_test.c index a82cb4a66c..7c283470f1 100644 --- a/src/regress/lib/libcrypto/exdata/exdata_test.c +++ b/src/regress/lib/libcrypto/exdata/exdata_test.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: exdata_test.c,v 1.3 2024/10/02 14:12:21 jsing Exp $ */ | 1 | /* $OpenBSD: exdata_test.c,v 1.4 2026/08/30 12:19:37 kenjiro Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -264,8 +264,7 @@ main(int argc, char **argv) | |||
| 264 | failed |= ex_data_test(); | 264 | failed |= ex_data_test(); |
| 265 | failed |= ex_new_index_test(); | 265 | failed |= ex_new_index_test(); |
| 266 | 266 | ||
| 267 | /* Force a clean up. */ | 267 | OPENSSL_cleanup(); |
| 268 | CRYPTO_cleanup_all_ex_data(); | ||
| 269 | 268 | ||
| 270 | return failed; | 269 | return failed; |
| 271 | } | 270 | } |
diff --git a/src/regress/lib/libcrypto/pbkdf2/pbkdf2.c b/src/regress/lib/libcrypto/pbkdf2/pbkdf2.c index 33b683f0a0..4a11126c34 100644 --- a/src/regress/lib/libcrypto/pbkdf2/pbkdf2.c +++ b/src/regress/lib/libcrypto/pbkdf2/pbkdf2.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: pbkdf2.c,v 1.3 2023/11/19 13:11:06 tb Exp $ */ | 1 | /* $OpenBSD: pbkdf2.c,v 1.4 2026/08/30 12:19:37 kenjiro Exp $ */ |
| 2 | /* Written by Christian Heimes, 2013 */ | 2 | /* Written by Christian Heimes, 2013 */ |
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2013 The OpenSSL Project. All rights reserved. | 4 | * Copyright (c) 2013 The OpenSSL Project. All rights reserved. |
| @@ -196,9 +196,7 @@ main(int argc,char **argv) | |||
| 196 | test_p5_pbkdf2(n, "sha512", test, sha512_results[n]); | 196 | test_p5_pbkdf2(n, "sha512", test, sha512_results[n]); |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | EVP_cleanup(); | ||
| 200 | CRYPTO_cleanup_all_ex_data(); | ||
| 201 | ERR_remove_thread_state(NULL); | 199 | ERR_remove_thread_state(NULL); |
| 202 | ERR_free_strings(); | 200 | OPENSSL_cleanup(); |
| 203 | return 0; | 201 | return 0; |
| 204 | } | 202 | } |
diff --git a/src/regress/lib/libssl/ssl/ssltest.c b/src/regress/lib/libssl/ssl/ssltest.c index 27adeeaf17..3bc5f99617 100644 --- a/src/regress/lib/libssl/ssl/ssltest.c +++ b/src/regress/lib/libssl/ssl/ssltest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssltest.c,v 1.45 2024/03/01 03:45:16 tb Exp $ */ | 1 | /* $OpenBSD: ssltest.c,v 1.46 2026/08/30 12:19:37 kenjiro Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -759,11 +759,9 @@ end: | |||
| 759 | SSL_CTX_free(c_ctx); | 759 | SSL_CTX_free(c_ctx); |
| 760 | BIO_free(bio_stdout); | 760 | BIO_free(bio_stdout); |
| 761 | 761 | ||
| 762 | CRYPTO_cleanup_all_ex_data(); | ||
| 763 | ERR_free_strings(); | ||
| 764 | ERR_remove_thread_state(NULL); | ||
| 765 | EVP_cleanup(); | ||
| 766 | BIO_free(bio_err); | 762 | BIO_free(bio_err); |
| 763 | ERR_remove_thread_state(NULL); | ||
| 764 | OPENSSL_cleanup(); | ||
| 767 | 765 | ||
| 768 | exit(ret); | 766 | exit(ret); |
| 769 | return ret; | 767 | return ret; |
diff --git a/src/usr.bin/openssl/openssl.c b/src/usr.bin/openssl/openssl.c index 056912a9ed..b9d63fa43a 100644 --- a/src/usr.bin/openssl/openssl.c +++ b/src/usr.bin/openssl/openssl.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: openssl.c,v 1.41 2026/01/02 00:14:24 kenjiro Exp $ */ | 1 | /* $OpenBSD: openssl.c,v 1.42 2026/08/30 12:19:37 kenjiro Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -360,10 +360,6 @@ openssl_shutdown(void) | |||
| 360 | CONF_modules_unload(1); | 360 | CONF_modules_unload(1); |
| 361 | destroy_ui(); | 361 | destroy_ui(); |
| 362 | OBJ_cleanup(); | 362 | OBJ_cleanup(); |
| 363 | EVP_cleanup(); | ||
| 364 | CRYPTO_cleanup_all_ex_data(); | ||
| 365 | ERR_remove_thread_state(NULL); | ||
| 366 | ERR_free_strings(); | ||
| 367 | } | 363 | } |
| 368 | 364 | ||
| 369 | int | 365 | int |
| @@ -461,6 +457,9 @@ main(int argc, char **argv) | |||
| 461 | BIO_free(bio_err); | 457 | BIO_free(bio_err); |
| 462 | bio_err = NULL; | 458 | bio_err = NULL; |
| 463 | } | 459 | } |
| 460 | ERR_remove_thread_state(NULL); | ||
| 461 | OPENSSL_cleanup(); | ||
| 462 | |||
| 464 | return (ret); | 463 | return (ret); |
| 465 | } | 464 | } |
| 466 | 465 | ||
