summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/engine
diff options
context:
space:
mode:
authorbeck <>2018-03-17 16:20:01 +0000
committerbeck <>2018-03-17 16:20:01 +0000
commitd18ae25f28e72831dc3c51f78e0735342540098b (patch)
tree12cc674e7652f4d67e57ec9e1882e6e824b4808d /src/lib/libcrypto/engine
parent736fdc7bedf7fe8b17717032f7380c5c6e247d0d (diff)
downloadopenbsd-d18ae25f28e72831dc3c51f78e0735342540098b.tar.gz
openbsd-d18ae25f28e72831dc3c51f78e0735342540098b.tar.bz2
openbsd-d18ae25f28e72831dc3c51f78e0735342540098b.zip
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@
Diffstat (limited to 'src/lib/libcrypto/engine')
-rw-r--r--src/lib/libcrypto/engine/eng_all.c20
-rw-r--r--src/lib/libcrypto/engine/eng_lib.c5
2 files changed, 19 insertions, 6 deletions
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 @@
1/* $OpenBSD: eng_all.c,v 1.29 2015/07/19 22:34:27 doug Exp $ */ 1/* $OpenBSD: eng_all.c,v 1.30 2018/03/17 16:20:01 beck Exp $ */
2/* Written by Richard Levitte <richard@levitte.org> for the OpenSSL 2/* Written by Richard Levitte <richard@levitte.org> for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -56,17 +56,16 @@
56 * 56 *
57 */ 57 */
58 58
59#include <pthread.h>
60
59#include <openssl/opensslconf.h> 61#include <openssl/opensslconf.h>
60 62
61#include "cryptlib.h" 63#include "cryptlib.h"
62#include "eng_int.h" 64#include "eng_int.h"
63 65
64void 66void
65ENGINE_load_builtin_engines(void) 67ENGINE_load_builtin_engines_internal(void)
66{ 68{
67 /* Some ENGINEs need this */
68 OPENSSL_cpuid_setup();
69
70#ifndef OPENSSL_NO_STATIC_ENGINE 69#ifndef OPENSSL_NO_STATIC_ENGINE
71#ifndef OPENSSL_NO_HW 70#ifndef OPENSSL_NO_HW
72#ifndef OPENSSL_NO_HW_PADLOCK 71#ifndef OPENSSL_NO_HW_PADLOCK
@@ -76,3 +75,14 @@ ENGINE_load_builtin_engines(void)
76#endif 75#endif
77 ENGINE_register_all_complete(); 76 ENGINE_register_all_complete();
78} 77}
78
79void
80ENGINE_load_builtin_engines(void)
81{
82 static pthread_once_t once = PTHREAD_ONCE_INIT;
83
84 /* Prayer and clean living lets you ignore errors, OpenSSL style */
85 (void) OPENSSL_init_crypto(0, NULL);
86
87 (void) pthread_once(&once, ENGINE_load_builtin_engines_internal);
88}
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 @@
1/* $OpenBSD: eng_lib.c,v 1.12 2017/01/29 17:49:23 beck Exp $ */ 1/* $OpenBSD: eng_lib.c,v 1.13 2018/03/17 16:20:01 beck Exp $ */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL 2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -70,6 +70,9 @@ ENGINE_new(void)
70{ 70{
71 ENGINE *ret; 71 ENGINE *ret;
72 72
73 if (!OPENSSL_init_crypto(0, NULL))
74 return NULL;
75
73 ret = malloc(sizeof(ENGINE)); 76 ret = malloc(sizeof(ENGINE));
74 if (ret == NULL) { 77 if (ret == NULL) {
75 ENGINEerror(ERR_R_MALLOC_FAILURE); 78 ENGINEerror(ERR_R_MALLOC_FAILURE);