Fix checks for key type in psa_export_public_key_iop_setup()

Key type must be a key pair or public-key if not we return
PSA_ERROR_INVALID_ARGUMENT.

The key type must be ECC key as this is what we support for
now otherwise we return PSA_ERROR_NOT_SUPPORTED.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
This commit is contained in:
Waleed Elmelegy 2024-12-03 13:52:28 +00:00
parent 4cffd5d4f3
commit f466a284c1

View File

@ -1717,12 +1717,14 @@ psa_status_t psa_export_public_key_iop_setup(psa_export_public_key_iop_t *operat
private_key_type = psa_get_key_type(&private_key_attributes); private_key_type = psa_get_key_type(&private_key_attributes);
if (!PSA_KEY_TYPE_IS_KEY_PAIR(private_key_type)) { if (!PSA_KEY_TYPE_IS_KEY_PAIR(private_key_type) &&
!PSA_KEY_TYPE_IS_PUBLIC_KEY(private_key_type)) {
status = PSA_ERROR_INVALID_ARGUMENT; status = PSA_ERROR_INVALID_ARGUMENT;
goto exit; goto exit;
} }
if (!PSA_KEY_TYPE_IS_ECC_KEY_PAIR(private_key_type)) { if (!PSA_KEY_TYPE_IS_ECC_KEY_PAIR(private_key_type) &&
!PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(private_key_type)) {
status = PSA_ERROR_NOT_SUPPORTED; status = PSA_ERROR_NOT_SUPPORTED;
goto exit; goto exit;
} }