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 <[email protected]>
This commit is contained in:
Waleed Elmelegy
2024-12-09 18:12:16 +00:00
parent 4cffd5d4f3
commit f466a284c1
+4 -2
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);
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;
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;
goto exit;
}