framework-pkcs15: Fix PKCS#11 semantics while encoding EC pubkey params

This commit is contained in:
Jakub Jelen 2021-03-23 12:00:18 +01:00 committed by Jakub Jelen
parent 7d0abdc192
commit 9cc942fd47
1 changed files with 3 additions and 1 deletions

View File

@ -5582,16 +5582,18 @@ get_ec_pubkey_params(struct sc_pkcs15_pubkey *key, CK_ATTRIBUTE_PTR attr)
return sc_to_cryptoki_error(r, NULL);
}
attr->ulValueLen = (unsigned long)value_size;
if (attr->pValue == NULL_PTR) {
attr->ulValueLen = (unsigned long)value_size;
free(value);
return CKR_OK;
}
if (attr->ulValueLen < (unsigned long)value_size) {
attr->ulValueLen = (unsigned long)value_size;
free(value);
return CKR_BUFFER_TOO_SMALL;
}
attr->ulValueLen = (unsigned long)value_size;
memcpy(attr->pValue, value, value_size);
free(value);
return CKR_OK;