[pkg-opensc-commit] [opensc] 54/295: pkcs11-tool: re-login if pincache is disabled or expired

Eric Dorland eric at moszumanska.debian.org
Sat Jun 24 21:11:15 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 1bc09ddafa7e7c44a62226b2c2380e558bee9360
Author: Nuno Goncalves <nunojpg at gmail.com>
Date:   Mon Jul 25 00:07:47 2016 +0200

    pkcs11-tool: re-login if pincache is disabled or expired
    
    Signed-off-by: Nuno Goncalves <nunojpg at gmail.com>
    
    closes #839
---
 src/tools/pkcs11-tool.c | 41 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c
index 061dec7..d4383ac 100644
--- a/src/tools/pkcs11-tool.c
+++ b/src/tools/pkcs11-tool.c
@@ -292,6 +292,7 @@ static char *		opt_key_type = NULL;
 static char *		opt_sig_format = NULL;
 static int		opt_is_private = 0;
 static int		opt_test_hotplug = 0;
+static int		opt_login = 0;
 static int		opt_login_type = -1;
 static int		opt_key_usage_sign = 0;
 static int		opt_key_usage_decrypt = 0;
@@ -434,7 +435,6 @@ int main(int argc, char * argv[])
 	int do_test_fork = 0;
 #endif
 	int need_session = 0;
-	int opt_login = 0;
 	int do_init_token = 0;
 	int do_init_pin = 0;
 	int do_change_pin = 0;
@@ -3948,8 +3948,17 @@ static int test_signature(CK_SESSION_HANDLE sess)
 	if (rv != CKR_OK)
 		p11_fatal("C_OpenSession", rv);
 	if ((sessionInfo.state & CKS_RO_USER_FUNCTIONS) == 0) {
-		printf("Signatures: not logged in, skipping signature tests\n");
-		return errors;
+		if (opt_login) {
+			int r;
+			r = login(sess, CKU_CONTEXT_SPECIFIC);
+			if (r != 0){
+				printf("Signatures: failed to login, skipping signature tests\n");
+				return errors;
+			}
+		} else {
+			printf("Signatures: not logged in, skipping signature tests\n");
+			return errors;
+		}
 	}
 
 	if (!find_mechanism(sessionInfo.slotID, CKF_SIGN | CKF_HW, mechTypes, mechTypes_num, &firstMechType)) {
@@ -4261,8 +4270,17 @@ static int test_verify(CK_SESSION_HANDLE sess)
 	if (rv != CKR_OK)
 		p11_fatal("C_OpenSession", rv);
 	if ((sessionInfo.state & CKS_RO_USER_FUNCTIONS) == 0) {
-		printf("Verify: not logged in, skipping verify tests\n");
-		return errors;
+		if (opt_login) {
+			int r;
+			r = login(sess, CKU_CONTEXT_SPECIFIC);
+			if (r != 0){
+				printf("Verify: failed to login, skipping verify tests\n");
+				return errors;
+			}
+		} else {
+			printf("Verify: not logged in, skipping verify tests\n");
+			return errors;
+		}
 	}
 
 	if (!find_mechanism(sessionInfo.slotID, CKF_VERIFY, NULL, 0, &first_mech_type)) {
@@ -4582,8 +4600,17 @@ static int test_decrypt(CK_SESSION_HANDLE sess)
 	if (rv != CKR_OK)
 		p11_fatal("C_OpenSession", rv);
 	if ((sessionInfo.state & CKS_RO_USER_FUNCTIONS) == 0) {
-		printf("Decryption: not logged in, skipping decryption tests\n");
-		return errors;
+		if (opt_login) {
+			int r;
+			r = login(sess, CKU_CONTEXT_SPECIFIC);
+			if (r != 0){
+				printf("Decryption: failed to login, skipping decryption tests\n");
+				return errors;
+			}
+		} else {
+			printf("Decryption: not logged in, skipping decryption tests\n");
+			return errors;
+		}
 	}
 
 	num_mechs = get_mechanisms(sessionInfo.slotID, &mechs, CKF_DECRYPT);

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