[pkg-opensc-commit] [opensc] 225/295: pkcs11-tool: fixed RSA-X-509 corner case test

Eric Dorland eric at moszumanska.debian.org
Sat Jun 24 21:11:34 UTC 2017


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

eric pushed a commit to branch master
in repository opensc.

commit c2fa66f1fbdc5c5fec98028a75f4550b6ec55033
Author: Frank Morgner <frankmorgner at gmail.com>
Date:   Mon Apr 3 13:37:56 2017 +0200

    pkcs11-tool: fixed RSA-X-509 corner case test
    
    For testing RSA-X-509, we are generating random bytes for signing. It
    may happen that the modulus is smaller than the random number
    generated, which triggers an error in the card. With this change, we
    are setting the most significant byte to 0x00 to assure the random
    number is smaller than the modulus.
---
 src/tools/pkcs11-tool.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c
index c500af6..ef5d2a6 100644
--- a/src/tools/pkcs11-tool.c
+++ b/src/tools/pkcs11-tool.c
@@ -4257,6 +4257,11 @@ static int test_signature(CK_SESSION_HANDLE sess)
 
 	pseudo_randomize(data, dataLen);
 
+	if (firstMechType == CKM_RSA_X_509) {
+		/* make sure our data is smaller than the modulus */
+		data[0] = 0x00;
+	}
+
 	ck_mech.mechanism = firstMechType;
 	rv = p11->C_SignInit(sess, &ck_mech, privKeyObject);
 	/* mechanism not implemented, don't test */

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



More information about the pkg-opensc-commit mailing list