pkcs11-tool: fix #124; thanks to Thomas Harnings: for the signature tests cannot be used private key without corresponding public key or certificate

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4247 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
viktor.tarasov 2010-04-17 19:59:32 +00:00
parent 7813ba7130
commit ce485e4895
1 changed files with 15 additions and 1 deletions

View File

@ -2576,6 +2576,11 @@ static int test_signature(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
printf(" -- can't be used for signature, skipping\n");
continue;
}
modLenBytes = (get_private_key_length(sess, privKeyObject) + 7) / 8;
if(!modLenBytes) {
printf(" -- can't be used for signature, skipping: can't obtain modulus\n");
continue;
}
printf("\n");
break;
}
@ -2736,8 +2741,13 @@ static int test_signature(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
printf(" -- can't be used to sign/verify, skipping\n");
continue;
}
else
else if (!modLenBytes) {
printf(" -- can't be used to sign/verify, skipping: can't obtain modulus\n");
continue;
}
else {
printf("\n");
}
errors += sign_verify_openssl(slot, sess, &ck_mech, privKeyObject,
datas[i], dataLens[i], verifyData, sizeof(verifyData),
@ -2890,6 +2900,10 @@ static int test_verify(CK_SLOT_ID slot, CK_SESSION_HANDLE sess)
}
key_len = (get_private_key_length(sess, priv_key) + 7) / 8;
if(!key_len) {
printf(" -- can't get the modulus length, skipping\n");
continue;
}
errors += sign_verify(slot, sess, priv_key, key_len, pub_key, i != 0);
}