Merge pull request #5037 from mprse/issue_4551

Fix psa_generate_key(): return PSA_ERROR_INVALID_ARGUMENT for public key
This commit is contained in:
Gilles Peskine 2021-10-18 10:39:21 +02:00 committed by GitHub
commit 7637ab0d8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 67 additions and 11 deletions

View file

@ -5703,6 +5703,10 @@ psa_status_t psa_generate_key( const psa_key_attributes_t *attributes,
if( psa_get_key_bits( attributes ) == 0 )
return( PSA_ERROR_INVALID_ARGUMENT );
/* Reject any attempt to create a public key. */
if( PSA_KEY_TYPE_IS_PUBLIC_KEY(attributes->core.type) )
return( PSA_ERROR_INVALID_ARGUMENT );
status = psa_start_key_creation( PSA_KEY_CREATION_GENERATE, attributes,
&slot, &driver );
if( status != PSA_SUCCESS )