[pkg-opensc-commit] [libp11] 10/13: Fixed error handling in RSA key generation

Eric Dorland eric at moszumanska.debian.org
Mon May 22 03:43:01 UTC 2017


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to annotated tag libp11-0.4.5
in repository libp11.

commit 2cd0d7c6c46fe8962496e7e0c5a44a2aa20d7c67
Author: Michał Trojnara <Michal.Trojnara at stunnel.org>
Date:   Sat Mar 11 11:55:19 2017 +0100

    Fixed error handling in RSA key generation
---
 src/p11_key.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/p11_key.c b/src/p11_key.c
index dded14a..16101bd 100644
--- a/src/p11_key.c
+++ b/src/p11_key.c
@@ -139,8 +139,8 @@ int pkcs11_generate_key(PKCS11_TOKEN *token, int algorithm, unsigned int bits,
 	RSA *rsa;
 	BIO *err;
 #if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
-	BIGNUM *exp = NULL;
-	BN_GENCB *gencb = NULL;
+	BIGNUM *exp;
+	BN_GENCB *gencb;
 #endif
 	int rc;
 
@@ -156,15 +156,15 @@ int pkcs11_generate_key(PKCS11_TOKEN *token, int algorithm, unsigned int bits,
 	rsa = RSA_new();
 	gencb = BN_GENCB_new();
 	if (gencb)
-	    BN_GENCB_set(gencb, NULL, err);
-
-	if ( rsa == NULL  || exp == NULL || gencb == NULL
-	    || !BN_set_word(exp, RSA_F4) || !RSA_generate_key_ex(rsa, bits, exp, gencb)) {
+		BN_GENCB_set(gencb, NULL, err);
+	if (rsa == NULL || exp == NULL || gencb == NULL ||
+			!BN_set_word(exp, RSA_F4) ||
+			!RSA_generate_key_ex(rsa, bits, exp, gencb)) {
 		RSA_free(rsa);
+		rsa = NULL;
 	}
 	BN_GENCB_free(gencb);
 	BN_free(exp);
-
 #else
 	rsa = RSA_generate_key(bits, RSA_F4, NULL, err);
 #endif

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/libp11.git



More information about the pkg-opensc-commit mailing list