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/evp/c_all.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/lib/libcrypto/evp/c_all.c') diff --git a/src/lib/libcrypto/evp/c_all.c b/src/lib/libcrypto/evp/c_all.c index 8ab93fece8..87657eded3 100644 --- a/src/lib/libcrypto/evp/c_all.c +++ b/src/lib/libcrypto/evp/c_all.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_all.c,v 1.21 2017/03/01 13:53:58 jsing Exp $ */ +/* $OpenBSD: c_all.c,v 1.22 2018/03/17 16:20:01 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,6 +57,7 @@ */ #include +#include #include @@ -66,8 +67,8 @@ #include "cryptlib.h" -void -OpenSSL_add_all_ciphers(void) +static void +OpenSSL_add_all_ciphers_internal(void) { #ifndef OPENSSL_NO_DES EVP_add_cipher(EVP_des_cfb()); @@ -226,7 +227,14 @@ OpenSSL_add_all_ciphers(void) } void -OpenSSL_add_all_digests(void) +OpenSSL_add_all_ciphers(void) +{ + static pthread_once_t add_all_ciphers_once = PTHREAD_ONCE_INIT; + (void) pthread_once(&add_all_ciphers_once, OpenSSL_add_all_ciphers_internal); +} + +static void +OpenSSL_add_all_digests_internal(void) { #ifndef OPENSSL_NO_MD4 EVP_add_digest(EVP_md4()); @@ -283,6 +291,13 @@ OpenSSL_add_all_digests(void) #endif } +void +OpenSSL_add_all_digests(void) +{ + static pthread_once_t add_all_digests_once = PTHREAD_ONCE_INIT; + (void) pthread_once(&add_all_digests_once, OpenSSL_add_all_digests_internal); +} + void OPENSSL_add_all_algorithms_noconf(void) { -- cgit v1.2.3-55-g6feb