summaryrefslogtreecommitdiff
path: root/lib/libcrypto/rsa
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2018-04-14 07:09:22 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2018-04-14 07:09:22 +0000
commit364b319f72ecb5c2f1e58716cf073863162c78a8 (patch)
treee0e394a7d929b9512916d0dd247c4548f2dbc111 /lib/libcrypto/rsa
parentbd42a3afb2194d71f6df46c3bf36231d249dc9d6 (diff)
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 'lib/libcrypto/rsa')
-rw-r--r--lib/libcrypto/rsa/rsa_lib.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/libcrypto/rsa/rsa_lib.c b/lib/libcrypto/rsa/rsa_lib.c
index 544846f8252..84e1dc7eaf7 100644
--- a/lib/libcrypto/rsa/rsa_lib.c
+++ b/lib/libcrypto/rsa/rsa_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsa_lib.c,v 1.36 2018/02/20 17:42:32 tb Exp $ */
+/* $OpenBSD: rsa_lib.c,v 1.37 2018/04/14 07:09:21 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -114,10 +114,8 @@ RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
if (mtmp->finish)
mtmp->finish(rsa);
#ifndef OPENSSL_NO_ENGINE
- if (rsa->engine) {
- ENGINE_finish(rsa->engine);
- rsa->engine = NULL;
- }
+ ENGINE_finish(rsa->engine);
+ rsa->engine = NULL;
#endif
rsa->meth = meth;
if (meth->init)
@@ -149,7 +147,7 @@ RSA_new_method(ENGINE *engine)
ret->engine = ENGINE_get_default_RSA();
if (ret->engine) {
ret->meth = ENGINE_get_RSA(ret->engine);
- if (!ret->meth) {
+ if (ret->meth == NULL) {
RSAerror(ERR_R_ENGINE_LIB);
ENGINE_finish(ret->engine);
free(ret);
@@ -177,8 +175,7 @@ RSA_new_method(ENGINE *engine)
ret->flags = ret->meth->flags & ~RSA_FLAG_NON_FIPS_ALLOW;
if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data)) {
#ifndef OPENSSL_NO_ENGINE
- if (ret->engine)
- ENGINE_finish(ret->engine);
+ ENGINE_finish(ret->engine);
#endif
free(ret);
return NULL;
@@ -186,8 +183,7 @@ RSA_new_method(ENGINE *engine)
if (ret->meth->init != NULL && !ret->meth->init(ret)) {
#ifndef OPENSSL_NO_ENGINE
- if (ret->engine)
- ENGINE_finish(ret->engine);
+ ENGINE_finish(ret->engine);
#endif
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
free(ret);
@@ -211,8 +207,7 @@ RSA_free(RSA *r)
if (r->meth->finish)
r->meth->finish(r);
#ifndef OPENSSL_NO_ENGINE
- if (r->engine)
- ENGINE_finish(r->engine);
+ ENGINE_finish(r->engine);
#endif
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data);