psa: Fix error code when creating/registering a key with invalid id
When creating a persistent key or registering a key
with an invalid key identifier return
PSA_ERROR_INVALID_ARGUMENT instead of
PSA_ERROR_INVALID_HANDLE.
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 9c8e108..f9169aa 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -1624,9 +1624,8 @@
}
else
{
- status = psa_validate_key_id( psa_get_key_id( attributes ), 0 );
- if( status != PSA_SUCCESS )
- return( status );
+ if( !psa_is_valid_key_id( psa_get_key_id( attributes ), 0 ) )
+ return( PSA_ERROR_INVALID_ARGUMENT );
}
status = psa_validate_key_policy( &attributes->core.policy );