[pkg-opensc-commit] [opensc] 16/23: [pkcs11-tool] Do not use modLenBytes before validating

Eric Dorland eric at moszumanska.debian.org
Sun Jul 23 18:23:11 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 12fe5b5e6774f7bc41977e195de18389366d35a0
Author: Jakub Jelen <jjelen at redhat.com>
Date:   Mon Jun 26 17:58:41 2017 +0200

    [pkcs11-tool] Do not use modLenBytes before validating
---
 src/tools/pkcs11-tool.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c
index 47abaa5..665318c 100644
--- a/src/tools/pkcs11-tool.c
+++ b/src/tools/pkcs11-tool.c
@@ -4431,7 +4431,7 @@ static int test_signature(CK_SESSION_HANDLE sess)
 			modLenBytes, i);
 	}
 
-	/* 4rd test: the other signature keys */
+	/* 4th test: the other signature keys */
 
 	for (i = 0; mechTypes[i] != 0xffffff; i++)
 		if (mechTypes[i] == firstMechType)
@@ -4445,16 +4445,6 @@ static int test_signature(CK_SESSION_HANDLE sess)
 		modLenBits = get_private_key_length(sess, privKeyObject);
 		modLenBytes = (modLenBits + 7) / 8;
 
-		/* Fill in data[0] and dataLens[0] */
-		dataLen = modLenBytes;
-		data[0] = 0x00;
-		data[1] = 0x01;
-		memset(data + 2, 0xFF, dataLen - 3 - dataLens[1]);
-		data[dataLen - 36] = 0x00;
-		memcpy(data + (dataLen - dataLens[1]), datas[1], dataLens[1]);
-		datas[0] = data;
-		dataLens[0] = dataLen;
-
 		printf("  testing key %d (%u bits%s%s) with 1 signature mechanism",
 				(int) (j-1),
 				(int) modLenBits,
@@ -4479,6 +4469,16 @@ static int test_signature(CK_SESSION_HANDLE sess)
 			printf("\n");
 		}
 
+		/* Fill in data[0] and dataLens[0] */
+		dataLen = modLenBytes;
+		data[0] = 0x00;
+		data[1] = 0x01;
+		memset(data + 2, 0xFF, dataLen - 3 - dataLens[1]);
+		data[dataLen - 36] = 0x00;
+		memcpy(data + (dataLen - dataLens[1]), datas[1], dataLens[1]);
+		datas[0] = data;
+		dataLens[0] = dataLen;
+
 		errors += sign_verify_openssl(sess, &ck_mech, privKeyObject,
 			datas[i], dataLens[i], verifyData, sizeof(verifyData),
 			modLenBytes, i);

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