mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 00:35:50 +01:00
tests: psa: Fix export related tests
Fix some export related tests that were relying on the fact that the size of the output buffer was checked after other parameters. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
e907e55f39
commit
1e87d5ba1d
@ -244,7 +244,7 @@ import_export_public_key:"70076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fb
|
||||
|
||||
PSA import/export-public: cannot export-public a symmetric key
|
||||
depends_on:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C
|
||||
import_export_public_key:"2b7e151628aed2a6abf7158809cf4f3c":PSA_KEY_TYPE_AES:PSA_ALG_CBC_NO_PADDING:0:PSA_ERROR_INVALID_ARGUMENT:""
|
||||
import_export_public_key:"2b7e151628aed2a6abf7158809cf4f3c":PSA_KEY_TYPE_AES:PSA_ALG_CBC_NO_PADDING:0:PSA_ERROR_INVALID_ARGUMENT:"2b7e151628aed2a6abf7158809cf4f3c"
|
||||
|
||||
PSA import/export EC secp256r1 public key: good
|
||||
depends_on:PSA_WANT_ALG_ECDSA:PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY:MBEDTLS_PK_PARSE_C:MBEDTLS_PK_WRITE_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
|
@ -1028,19 +1028,21 @@ static int exercise_export_key( mbedtls_svc_key_id_t key,
|
||||
|
||||
PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
|
||||
|
||||
exported_size = PSA_EXPORT_KEY_OUTPUT_SIZE(
|
||||
psa_get_key_type( &attributes ),
|
||||
psa_get_key_bits( &attributes ) );
|
||||
ASSERT_ALLOC( exported, exported_size );
|
||||
|
||||
if( ( usage & PSA_KEY_USAGE_EXPORT ) == 0 &&
|
||||
! PSA_KEY_TYPE_IS_PUBLIC_KEY( psa_get_key_type( &attributes ) ) )
|
||||
{
|
||||
TEST_EQUAL( psa_export_key( key, NULL, 0, &exported_length ),
|
||||
TEST_EQUAL( psa_export_key( key, exported,
|
||||
exported_size, &exported_length ),
|
||||
PSA_ERROR_NOT_PERMITTED );
|
||||
ok = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
exported_size = PSA_EXPORT_KEY_OUTPUT_SIZE( psa_get_key_type( &attributes ),
|
||||
psa_get_key_bits( &attributes ) );
|
||||
ASSERT_ALLOC( exported, exported_size );
|
||||
|
||||
PSA_ASSERT( psa_export_key( key,
|
||||
exported, exported_size,
|
||||
&exported_length ) );
|
||||
@ -1071,9 +1073,16 @@ static int exercise_export_public_key( mbedtls_svc_key_id_t key )
|
||||
PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
|
||||
if( ! PSA_KEY_TYPE_IS_ASYMMETRIC( psa_get_key_type( &attributes ) ) )
|
||||
{
|
||||
TEST_EQUAL( psa_export_public_key( key, NULL, 0, &exported_length ),
|
||||
exported_size = PSA_EXPORT_KEY_OUTPUT_SIZE(
|
||||
psa_get_key_type( &attributes ),
|
||||
psa_get_key_bits( &attributes ) );
|
||||
ASSERT_ALLOC( exported, exported_size );
|
||||
|
||||
TEST_EQUAL( psa_export_public_key( key, exported,
|
||||
exported_size, &exported_length ),
|
||||
PSA_ERROR_INVALID_ARGUMENT );
|
||||
return( 1 );
|
||||
ok = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
public_type = PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(
|
||||
|
@ -343,9 +343,9 @@ void persistent_slot_lifecycle( int lifetime_arg, int owner_id_arg, int id_arg,
|
||||
psa_get_key_type( &read_attributes ) );
|
||||
TEST_EQUAL( psa_get_key_bits( &attributes ),
|
||||
psa_get_key_bits( &read_attributes ) );
|
||||
ASSERT_ALLOC( reexported, key_data->len );
|
||||
if( usage_flags & PSA_KEY_USAGE_EXPORT )
|
||||
{
|
||||
ASSERT_ALLOC( reexported, key_data->len );
|
||||
PSA_ASSERT( psa_export_key( id, reexported, key_data->len,
|
||||
&reexported_length ) );
|
||||
ASSERT_COMPARE( key_data->x, key_data->len,
|
||||
@ -353,7 +353,8 @@ void persistent_slot_lifecycle( int lifetime_arg, int owner_id_arg, int id_arg,
|
||||
}
|
||||
else
|
||||
{
|
||||
TEST_EQUAL( psa_export_key( id, NULL, 0, &reexported_length ),
|
||||
TEST_EQUAL( psa_export_key( id, reexported,
|
||||
key_data->len, &reexported_length ),
|
||||
PSA_ERROR_NOT_PERMITTED );
|
||||
}
|
||||
PSA_ASSERT( psa_close_key( handle ) );
|
||||
|
Loading…
Reference in New Issue
Block a user