Merge pull request #642 from mouse07410/master
Fix public key access and attributes
This commit is contained in:
commit
e96d3ccf66
|
@ -3878,10 +3878,14 @@ pkcs15_pubkey_get_attribute(struct sc_pkcs11_session *session, void *object, CK_
|
||||||
*(CK_OBJECT_CLASS*)attr->pValue = CKO_PUBLIC_KEY;
|
*(CK_OBJECT_CLASS*)attr->pValue = CKO_PUBLIC_KEY;
|
||||||
break;
|
break;
|
||||||
case CKA_TOKEN:
|
case CKA_TOKEN:
|
||||||
case CKA_SENSITIVE:
|
|
||||||
check_attribute_buffer(attr, sizeof(CK_BBOOL));
|
check_attribute_buffer(attr, sizeof(CK_BBOOL));
|
||||||
*(CK_BBOOL*)attr->pValue = TRUE;
|
*(CK_BBOOL*)attr->pValue = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case CKA_SENSITIVE:
|
||||||
|
/* By PKCS#11 v2.20 public key cannot have SENSITIVE attr TRUE */
|
||||||
|
check_attribute_buffer(attr, sizeof(CK_BBOOL));
|
||||||
|
*(CK_BBOOL*)attr->pValue = FALSE;
|
||||||
|
break;
|
||||||
case CKA_LOCAL:
|
case CKA_LOCAL:
|
||||||
check_attribute_buffer(attr, sizeof(CK_BBOOL));
|
check_attribute_buffer(attr, sizeof(CK_BBOOL));
|
||||||
if (pubkey->pub_info)
|
if (pubkey->pub_info)
|
||||||
|
|
|
@ -688,9 +688,7 @@ static int read_public_key(void)
|
||||||
if (r >= 0) {
|
if (r >= 0) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf("Reading public key with ID '%s'\n", opt_pubkey);
|
printf("Reading public key with ID '%s'\n", opt_pubkey);
|
||||||
r = authenticate(obj);
|
r = sc_pkcs15_read_pubkey(p15card, obj, &pubkey);
|
||||||
if (r >= 0)
|
|
||||||
r = sc_pkcs15_read_pubkey(p15card, obj, &pubkey);
|
|
||||||
} else if (r == SC_ERROR_OBJECT_NOT_FOUND) {
|
} else if (r == SC_ERROR_OBJECT_NOT_FOUND) {
|
||||||
/* No pubkey - try if there's a certificate */
|
/* No pubkey - try if there's a certificate */
|
||||||
r = sc_pkcs15_find_cert_by_id(p15card, &id, &obj);
|
r = sc_pkcs15_find_cert_by_id(p15card, &id, &obj);
|
||||||
|
|
Loading…
Reference in New Issue