summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ecdh
diff options
context:
space:
mode:
authortb <>2018-04-14 07:09:21 +0000
committertb <>2018-04-14 07:09:21 +0000
commita32b35170819e9b07e0183d19aee21b9a246943b (patch)
tree83fef660683163befc47beedefbc0b11b71b2756 /src/lib/libcrypto/ecdh
parent7eaeb0d1b3ae143b8adb8634c48219a657764be9 (diff)
downloadopenbsd-a32b35170819e9b07e0183d19aee21b9a246943b.tar.gz
openbsd-a32b35170819e9b07e0183d19aee21b9a246943b.tar.bz2
openbsd-a32b35170819e9b07e0183d19aee21b9a246943b.zip
make ENGINE_finish() succeed on NULL and simplify callers as in
OpenSSL commit 7c96dbcdab9 by Rich Salz. This cleans up the caller side quite a bit and reduces the number of lines enclosed in #ifndef OPENSSL_NO_ENGINE. codesearch.debian.net shows that almost nothing checks the return value of ENGINE_finish(). While there, replace a few nearby 'if (!ptr)' with 'if (ptr == NULL)'. ok jsing, tested by & ok inoguchi
Diffstat (limited to 'src/lib/libcrypto/ecdh')
-rw-r--r--src/lib/libcrypto/ecdh/ech_lib.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/lib/libcrypto/ecdh/ech_lib.c b/src/lib/libcrypto/ecdh/ech_lib.c
index 2846a88612..cc8edafa07 100644
--- a/src/lib/libcrypto/ecdh/ech_lib.c
+++ b/src/lib/libcrypto/ecdh/ech_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ech_lib.c,v 1.13 2017/05/02 03:59:44 deraadt Exp $ */ 1/* $OpenBSD: ech_lib.c,v 1.14 2018/04/14 07:09:21 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -109,10 +109,8 @@ ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth)
109 return 0; 109 return 0;
110 110
111#ifndef OPENSSL_NO_ENGINE 111#ifndef OPENSSL_NO_ENGINE
112 if (ecdh->engine) { 112 ENGINE_finish(ecdh->engine);
113 ENGINE_finish(ecdh->engine); 113 ecdh->engine = NULL;
114 ecdh->engine = NULL;
115 }
116#endif 114#endif
117 ecdh->meth = meth; 115 ecdh->meth = meth;
118 return 1; 116 return 1;
@@ -138,7 +136,7 @@ ECDH_DATA_new_method(ENGINE *engine)
138 ret->engine = ENGINE_get_default_ECDH(); 136 ret->engine = ENGINE_get_default_ECDH();
139 if (ret->engine) { 137 if (ret->engine) {
140 ret->meth = ENGINE_get_ECDH(ret->engine); 138 ret->meth = ENGINE_get_ECDH(ret->engine);
141 if (!ret->meth) { 139 if (ret->meth == NULL) {
142 ECDHerror(ERR_R_ENGINE_LIB); 140 ECDHerror(ERR_R_ENGINE_LIB);
143 ENGINE_finish(ret->engine); 141 ENGINE_finish(ret->engine);
144 free(ret); 142 free(ret);
@@ -176,8 +174,7 @@ ecdh_data_free(void *data)
176 ECDH_DATA *r = (ECDH_DATA *)data; 174 ECDH_DATA *r = (ECDH_DATA *)data;
177 175
178#ifndef OPENSSL_NO_ENGINE 176#ifndef OPENSSL_NO_ENGINE
179 if (r->engine) 177 ENGINE_finish(r->engine);
180 ENGINE_finish(r->engine);
181#endif 178#endif
182 179
183 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDH, r, &r->ex_data); 180 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDH, r, &r->ex_data);