From d18ae25f28e72831dc3c51f78e0735342540098b Mon Sep 17 00:00:00 2001 From: beck <> Date: Sat, 17 Mar 2018 16:20:01 +0000 Subject: Bring in compatibility for OpenSSL 1.1 style init functions. This adds OPENSSL_init_crypto and OPENSSL_init_ssl, as well thread safety modifications for the existing LibreSSL init functions. The initialization routines are called automatically by the normal entry points into the library, as in newer OpenSSL ok jsing@, nits by tb@ and deraadt@ --- src/lib/libcrypto/engine/eng_all.c | 20 +++++++++++++++----- src/lib/libcrypto/engine/eng_lib.c | 5 ++++- 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'src/lib/libcrypto/engine') diff --git a/src/lib/libcrypto/engine/eng_all.c b/src/lib/libcrypto/engine/eng_all.c index 7640cf7fcd..403ca6865d 100644 --- a/src/lib/libcrypto/engine/eng_all.c +++ b/src/lib/libcrypto/engine/eng_all.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_all.c,v 1.29 2015/07/19 22:34:27 doug Exp $ */ +/* $OpenBSD: eng_all.c,v 1.30 2018/03/17 16:20:01 beck Exp $ */ /* Written by Richard Levitte for the OpenSSL * project 2000. */ @@ -56,17 +56,16 @@ * */ +#include + #include #include "cryptlib.h" #include "eng_int.h" void -ENGINE_load_builtin_engines(void) +ENGINE_load_builtin_engines_internal(void) { - /* Some ENGINEs need this */ - OPENSSL_cpuid_setup(); - #ifndef OPENSSL_NO_STATIC_ENGINE #ifndef OPENSSL_NO_HW #ifndef OPENSSL_NO_HW_PADLOCK @@ -76,3 +75,14 @@ ENGINE_load_builtin_engines(void) #endif ENGINE_register_all_complete(); } + +void +ENGINE_load_builtin_engines(void) +{ + static pthread_once_t once = PTHREAD_ONCE_INIT; + + /* Prayer and clean living lets you ignore errors, OpenSSL style */ + (void) OPENSSL_init_crypto(0, NULL); + + (void) pthread_once(&once, ENGINE_load_builtin_engines_internal); +} diff --git a/src/lib/libcrypto/engine/eng_lib.c b/src/lib/libcrypto/engine/eng_lib.c index d2da29fe69..11ad771109 100644 --- a/src/lib/libcrypto/engine/eng_lib.c +++ b/src/lib/libcrypto/engine/eng_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_lib.c,v 1.12 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: eng_lib.c,v 1.13 2018/03/17 16:20:01 beck Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -70,6 +70,9 @@ ENGINE_new(void) { ENGINE *ret; + if (!OPENSSL_init_crypto(0, NULL)) + return NULL; + ret = malloc(sizeof(ENGINE)); if (ret == NULL) { ENGINEerror(ERR_R_MALLOC_FAILURE); -- cgit v1.2.3-55-g6feb