Improve parameter checking in psa_export_public_key_iop_setup()

Signed-off-by: Waleed Elmelegy <[email protected]>
This commit is contained in:
Waleed Elmelegy
2024-11-27 16:08:01 +00:00
parent b30233f6c3
commit 84cc90f63a
+7 -2
View File
@@ -1714,18 +1714,23 @@ psa_status_t psa_export_public_key_iop_setup(psa_export_public_key_iop_t *operat
}
private_key_attributes = slot->attr;
if (status != PSA_SUCCESS) {
private_key_type = psa_get_key_type(&private_key_attributes);
if (!PSA_KEY_TYPE_IS_KEY_PAIR(private_key_type)) {
status = PSA_ERROR_INVALID_ARGUMENT;
goto exit;
}
private_key_type = psa_get_key_type(&private_key_attributes);
if (!PSA_KEY_TYPE_IS_ECC_KEY_PAIR(private_key_type)) {
status = PSA_ERROR_NOT_SUPPORTED;
goto exit;
}
key_size = PSA_EXPORT_KEY_OUTPUT_SIZE(private_key_type,
psa_get_key_bits(&private_key_attributes));
if (key_size == 0) {
status = PSA_ERROR_INVALID_ARGUMENT;
goto exit;
}