In psa_asymmetric_encrypt, allow public keys

The code was accepting key pairs only, even though encryption doesn't
require the private key.
This commit is contained in:
Gilles Peskine 2018-06-29 19:17:49 +02:00 committed by itayzafrir
parent 6b530867e4
commit 35da9a2f2e

View file

@ -2115,7 +2115,8 @@ psa_status_t psa_asymmetric_encrypt( psa_key_slot_t key,
status = psa_get_key_from_slot( key, &slot, PSA_KEY_USAGE_ENCRYPT, alg );
if( status != PSA_SUCCESS )
return( status );
if( ! PSA_KEY_TYPE_IS_KEYPAIR( slot->type ) )
if( ! ( PSA_KEY_TYPE_IS_PUBLIC_KEY( slot->type ) ||
PSA_KEY_TYPE_IS_KEYPAIR( slot->type ) ) )
return( PSA_ERROR_INVALID_ARGUMENT );
#if defined(MBEDTLS_RSA_C)