[pkg-opensc-commit] [libp11] 213/239: Get public exponent from public key, if private key doesn't contain it.

Eric Dorland eric at moszumanska.debian.org
Sat Oct 17 06:21:35 UTC 2015


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

eric pushed a commit to branch master
in repository libp11.

commit a9b220d26f41d475856d1dce45ab86239f5962cc
Author: Anton Fedorov <datacompboy at call2ru.com>
Date:   Fri Aug 16 00:41:49 2013 +0700

    Get public exponent from public key, if private key doesn't contain it.
---
 src/p11_rsa.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/p11_rsa.c b/src/p11_rsa.c
index f555bc0..4a93af0 100644
--- a/src/p11_rsa.c
+++ b/src/p11_rsa.c
@@ -57,6 +57,32 @@ static int pkcs11_get_rsa_private(PKCS11_KEY * key, EVP_PKEY * pk)
 		return -1;
 	}
 
+	if (BN_is_zero(rsa->e)) {
+		PKCS11_TOKEN_private * token = PRIVTOKEN(KEY2TOKEN(key));
+		int ki;
+		BIGNUM* pubmod = NULL;
+		for(ki = token->nprkeys; ki < token->nkeys; ki++) {
+			PKCS11_KEY* pubkey = token->keys + ki;
+
+			if(key_getattr_bn(pubkey, CKA_MODULUS, &pubmod)) {
+				continue;
+			}
+			if(BN_cmp(rsa->n, pubmod)) { // Modulus not same -- this public from another key
+				continue;
+			}
+
+			// If modulus are same -- we found required key, extract public exponent from it
+			if(key_getattr_bn(pubkey, CKA_PUBLIC_EXPONENT, &rsa->e)) {
+				continue;
+			}
+			if (BN_is_zero(rsa->e)) {
+				continue;
+			}
+			break;
+		}
+		if(pubmod!=NULL) BN_free(pubmod);
+	}
+
 	/* If the key is not extractable, create a key object
 	 * that will use the card's functions to sign & decrypt */
 	if (sensitive || !extractable) {

-- 
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