Skip to content

Commit

Permalink
Make sure it is an SPKI
Browse files Browse the repository at this point in the history
 On branch verify-pubkey-as-spki-2
 Changes to be committed:
	modified:   framework-pkcs15.c
  • Loading branch information
dengert authored and frankmorgner committed Apr 26, 2017
1 parent 4049283 commit 35bae65
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/pkcs11/framework-pkcs15.c
Original file line number Diff line number Diff line change
Expand Up @@ -4005,8 +4005,13 @@ pkcs15_pubkey_get_attribute(struct sc_pkcs11_session *session, void *object, CK_
unsigned char *value = NULL;
size_t len;

if (sc_pkcs15_encode_pubkey(context, pubkey->pub_data, &value, &len))
return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_GetAttributeValue");
if (attr->type != CKA_SPKI) {
if (sc_pkcs15_encode_pubkey(context, pubkey->pub_data, &value, &len))
return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_GetAttributeValue");
} else {
if (sc_pkcs15_encode_pubkey_as_spki(context, pubkey->pub_data, &value, &len))
return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_GetAttributeValue");
}

if (attr->pValue == NULL_PTR) {
attr->ulValueLen = len;
Expand All @@ -4023,7 +4028,7 @@ pkcs15_pubkey_get_attribute(struct sc_pkcs11_session *session, void *object, CK_

free(value);
}
else if (pubkey->base.p15_object && pubkey->base.p15_object->content.value && pubkey->base.p15_object->content.len) {
else if (attr->type != CKA_SPKI && pubkey->base.p15_object && pubkey->base.p15_object->content.value && pubkey->base.p15_object->content.len) {
check_attribute_buffer(attr, pubkey->base.p15_object->content.len);
memcpy(attr->pValue, pubkey->base.p15_object->content.value, pubkey->base.p15_object->content.len);
}
Expand Down

0 comments on commit 35bae65

Please sign in to comment.