1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Merge pull request #5038 from mprse/issue_4551_2x

Backport 2.x: Fix psa_generate_key(): return PSA_ERROR_INVALID_ARGUMENT for public key #5037
This commit is contained in:
Gilles Peskine
2021-10-18 10:39:26 +02:00
committed by GitHub
6 changed files with 133 additions and 77 deletions

View File

@ -5230,6 +5230,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 )