mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 20:45:37 +01:00
Replace psa_make_key_persistent by id/lifetime setters in tests
Remove all internal uses of psa_make_key_persistent.
This commit is contained in:
parent
dc8219a10d
commit
c87af66325
@ -1096,7 +1096,7 @@ static int test_operations_on_invalid_handle( psa_key_handle_t handle )
|
|||||||
size_t length;
|
size_t length;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
|
|
||||||
psa_make_key_persistent( &attributes, 0x6964, PSA_KEY_LIFETIME_PERSISTENT );
|
psa_set_key_id( &attributes, 0x6964 );
|
||||||
psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
|
psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
|
||||||
psa_set_key_algorithm( &attributes, PSA_ALG_CTR );
|
psa_set_key_algorithm( &attributes, PSA_ALG_CTR );
|
||||||
psa_set_key_type( &attributes, PSA_KEY_TYPE_AES );
|
psa_set_key_type( &attributes, PSA_KEY_TYPE_AES );
|
||||||
@ -1179,7 +1179,8 @@ void attributes_set_get( int id_arg, int lifetime_arg,
|
|||||||
TEST_EQUAL( psa_get_key_type( &attributes ), 0 );
|
TEST_EQUAL( psa_get_key_type( &attributes ), 0 );
|
||||||
TEST_EQUAL( psa_get_key_bits( &attributes ), 0 );
|
TEST_EQUAL( psa_get_key_bits( &attributes ), 0 );
|
||||||
|
|
||||||
psa_make_key_persistent( &attributes, id, lifetime );
|
psa_set_key_id( &attributes, id );
|
||||||
|
psa_set_key_lifetime( &attributes, lifetime );
|
||||||
psa_set_key_usage_flags( &attributes, usage_flags );
|
psa_set_key_usage_flags( &attributes, usage_flags );
|
||||||
psa_set_key_algorithm( &attributes, alg );
|
psa_set_key_algorithm( &attributes, alg );
|
||||||
psa_set_key_type( &attributes, type );
|
psa_set_key_type( &attributes, type );
|
||||||
@ -4883,7 +4884,7 @@ void persistent_key_load_key_from_storage( data_t *data,
|
|||||||
|
|
||||||
PSA_ASSERT( psa_crypto_init() );
|
PSA_ASSERT( psa_crypto_init() );
|
||||||
|
|
||||||
psa_make_key_persistent( &attributes, key_id, PSA_KEY_LIFETIME_PERSISTENT );
|
psa_set_key_id( &attributes, key_id );
|
||||||
psa_set_key_usage_flags( &attributes, usage_flags );
|
psa_set_key_usage_flags( &attributes, usage_flags );
|
||||||
psa_set_key_algorithm( &attributes, alg );
|
psa_set_key_algorithm( &attributes, alg );
|
||||||
psa_set_key_type( &attributes, type );
|
psa_set_key_type( &attributes, type );
|
||||||
|
@ -96,7 +96,7 @@ void save_large_persistent_key( int data_too_large, int expected_status )
|
|||||||
|
|
||||||
PSA_ASSERT( psa_crypto_init() );
|
PSA_ASSERT( psa_crypto_init() );
|
||||||
|
|
||||||
psa_make_key_persistent( &attributes, key_id, PSA_KEY_LIFETIME_PERSISTENT );
|
psa_set_key_id( &attributes, key_id );
|
||||||
psa_set_key_type( &attributes, PSA_KEY_TYPE_RAW_DATA );
|
psa_set_key_type( &attributes, PSA_KEY_TYPE_RAW_DATA );
|
||||||
|
|
||||||
TEST_EQUAL( psa_import_key( &attributes, &handle,
|
TEST_EQUAL( psa_import_key( &attributes, &handle,
|
||||||
@ -123,7 +123,7 @@ void persistent_key_destroy( int key_id_arg, int restart,
|
|||||||
|
|
||||||
PSA_ASSERT( psa_crypto_init() );
|
PSA_ASSERT( psa_crypto_init() );
|
||||||
|
|
||||||
psa_make_key_persistent( &attributes, key_id, PSA_KEY_LIFETIME_PERSISTENT );
|
psa_set_key_id( &attributes, key_id );
|
||||||
psa_set_key_type( &attributes, first_type );
|
psa_set_key_type( &attributes, first_type );
|
||||||
|
|
||||||
PSA_ASSERT( psa_import_key( &attributes, &handle,
|
PSA_ASSERT( psa_import_key( &attributes, &handle,
|
||||||
@ -153,7 +153,7 @@ void persistent_key_destroy( int key_id_arg, int restart,
|
|||||||
PSA_ASSERT( psa_crypto_init() );
|
PSA_ASSERT( psa_crypto_init() );
|
||||||
|
|
||||||
/* Create another key in the same slot */
|
/* Create another key in the same slot */
|
||||||
psa_make_key_persistent( &attributes, key_id, PSA_KEY_LIFETIME_PERSISTENT );
|
psa_set_key_id( &attributes, key_id );
|
||||||
psa_set_key_type( &attributes, second_type );
|
psa_set_key_type( &attributes, second_type );
|
||||||
PSA_ASSERT( psa_import_key( &attributes, &handle,
|
PSA_ASSERT( psa_import_key( &attributes, &handle,
|
||||||
second_data->x, second_data->len ) );
|
second_data->x, second_data->len ) );
|
||||||
@ -175,7 +175,7 @@ void persistent_key_import( int key_id_arg, int type_arg, data_t *data,
|
|||||||
|
|
||||||
PSA_ASSERT( psa_crypto_init() );
|
PSA_ASSERT( psa_crypto_init() );
|
||||||
|
|
||||||
psa_make_key_persistent( &attributes, key_id, PSA_KEY_LIFETIME_PERSISTENT );
|
psa_set_key_id( &attributes, key_id );
|
||||||
psa_set_key_type( &attributes, type );
|
psa_set_key_type( &attributes, type );
|
||||||
TEST_EQUAL( psa_import_key( &attributes, &handle, data->x, data->len ),
|
TEST_EQUAL( psa_import_key( &attributes, &handle, data->x, data->len ),
|
||||||
expected_status );
|
expected_status );
|
||||||
@ -228,7 +228,7 @@ void import_export_persistent_key( data_t *data, int type_arg,
|
|||||||
|
|
||||||
PSA_ASSERT( psa_crypto_init( ) );
|
PSA_ASSERT( psa_crypto_init( ) );
|
||||||
|
|
||||||
psa_make_key_persistent( &attributes, key_id, PSA_KEY_LIFETIME_PERSISTENT );
|
psa_set_key_id( &attributes, key_id );
|
||||||
psa_set_key_type( &attributes, type );
|
psa_set_key_type( &attributes, type );
|
||||||
psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_EXPORT );
|
psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_EXPORT );
|
||||||
|
|
||||||
|
@ -127,7 +127,8 @@ void persistent_slot_lifecycle( int lifetime_arg, int id_arg,
|
|||||||
PSA_ASSERT( psa_crypto_init( ) );
|
PSA_ASSERT( psa_crypto_init( ) );
|
||||||
|
|
||||||
/* Get a handle and import a key. */
|
/* Get a handle and import a key. */
|
||||||
psa_make_key_persistent( &attributes, id, lifetime );
|
psa_set_key_id( &attributes, id );
|
||||||
|
psa_set_key_lifetime( &attributes, lifetime );
|
||||||
psa_set_key_type( &attributes, type );
|
psa_set_key_type( &attributes, type );
|
||||||
psa_set_key_usage_flags( &attributes, usage_flags );
|
psa_set_key_usage_flags( &attributes, usage_flags );
|
||||||
psa_set_key_algorithm( &attributes, alg );
|
psa_set_key_algorithm( &attributes, alg );
|
||||||
@ -205,7 +206,8 @@ void create_existent( int lifetime_arg, int id_arg,
|
|||||||
PSA_ASSERT( psa_crypto_init( ) );
|
PSA_ASSERT( psa_crypto_init( ) );
|
||||||
|
|
||||||
/* Create a key. */
|
/* Create a key. */
|
||||||
psa_make_key_persistent( &attributes, id, lifetime );
|
psa_set_key_id( &attributes, id );
|
||||||
|
psa_set_key_lifetime( &attributes, lifetime );
|
||||||
psa_set_key_type( &attributes, type1 );
|
psa_set_key_type( &attributes, type1 );
|
||||||
psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_EXPORT );
|
psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_EXPORT );
|
||||||
psa_set_key_algorithm( &attributes, 0 );
|
psa_set_key_algorithm( &attributes, 0 );
|
||||||
@ -283,7 +285,8 @@ void create_fail( int lifetime_arg, int id_arg,
|
|||||||
|
|
||||||
PSA_ASSERT( psa_crypto_init( ) );
|
PSA_ASSERT( psa_crypto_init( ) );
|
||||||
|
|
||||||
psa_make_key_persistent( &attributes, id, lifetime );
|
psa_set_key_id( &attributes, id );
|
||||||
|
psa_set_key_lifetime( &attributes, lifetime );
|
||||||
psa_set_key_type( &attributes, PSA_KEY_TYPE_RAW_DATA );
|
psa_set_key_type( &attributes, PSA_KEY_TYPE_RAW_DATA );
|
||||||
TEST_EQUAL( psa_import_key( &attributes, &handle,
|
TEST_EQUAL( psa_import_key( &attributes, &handle,
|
||||||
material, sizeof( material ) ),
|
material, sizeof( material ) ),
|
||||||
@ -330,8 +333,10 @@ void copy_across_lifetimes( int source_lifetime_arg, int source_id_arg,
|
|||||||
|
|
||||||
/* Populate the source slot. */
|
/* Populate the source slot. */
|
||||||
if( source_lifetime != PSA_KEY_LIFETIME_VOLATILE )
|
if( source_lifetime != PSA_KEY_LIFETIME_VOLATILE )
|
||||||
psa_make_key_persistent( &source_attributes,
|
{
|
||||||
source_id, source_lifetime );
|
psa_set_key_id( &source_attributes, source_id );
|
||||||
|
psa_set_key_lifetime( &source_attributes, source_lifetime );
|
||||||
|
}
|
||||||
psa_set_key_type( &source_attributes, source_type );
|
psa_set_key_type( &source_attributes, source_type );
|
||||||
psa_set_key_usage_flags( &source_attributes, source_usage );
|
psa_set_key_usage_flags( &source_attributes, source_usage );
|
||||||
psa_set_key_algorithm( &source_attributes, source_alg );
|
psa_set_key_algorithm( &source_attributes, source_alg );
|
||||||
@ -342,8 +347,10 @@ void copy_across_lifetimes( int source_lifetime_arg, int source_id_arg,
|
|||||||
|
|
||||||
/* Prepare the target slot. */
|
/* Prepare the target slot. */
|
||||||
if( target_lifetime != PSA_KEY_LIFETIME_VOLATILE )
|
if( target_lifetime != PSA_KEY_LIFETIME_VOLATILE )
|
||||||
psa_make_key_persistent( &target_attributes,
|
{
|
||||||
target_id, target_lifetime );
|
psa_set_key_id( &target_attributes, target_id );
|
||||||
|
psa_set_key_lifetime( &target_attributes, target_lifetime );
|
||||||
|
}
|
||||||
psa_set_key_usage_flags( &target_attributes, target_usage );
|
psa_set_key_usage_flags( &target_attributes, target_usage );
|
||||||
psa_set_key_algorithm( &target_attributes, target_alg );
|
psa_set_key_algorithm( &target_attributes, target_alg );
|
||||||
|
|
||||||
@ -434,8 +441,10 @@ void copy_to_occupied( int source_lifetime_arg, int source_id_arg,
|
|||||||
|
|
||||||
/* Populate the source slot. */
|
/* Populate the source slot. */
|
||||||
if( source_lifetime != PSA_KEY_LIFETIME_VOLATILE )
|
if( source_lifetime != PSA_KEY_LIFETIME_VOLATILE )
|
||||||
psa_make_key_persistent( &attributes,
|
{
|
||||||
source_id, source_lifetime );
|
psa_set_key_id( &attributes, source_id );
|
||||||
|
psa_set_key_lifetime( &attributes, source_lifetime );
|
||||||
|
}
|
||||||
psa_set_key_type( &attributes, source_type );
|
psa_set_key_type( &attributes, source_type );
|
||||||
psa_set_key_usage_flags( &attributes, source_usage );
|
psa_set_key_usage_flags( &attributes, source_usage );
|
||||||
psa_set_key_algorithm( &attributes, source_alg );
|
psa_set_key_algorithm( &attributes, source_alg );
|
||||||
@ -449,7 +458,8 @@ void copy_to_occupied( int source_lifetime_arg, int source_id_arg,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
psa_make_key_persistent( &attributes1, target_id, target_lifetime );
|
psa_set_key_id( &attributes1, target_id );
|
||||||
|
psa_set_key_lifetime( &attributes1, target_lifetime );
|
||||||
psa_set_key_type( &attributes1, target_type );
|
psa_set_key_type( &attributes1, target_type );
|
||||||
psa_set_key_usage_flags( &attributes1, target_usage );
|
psa_set_key_usage_flags( &attributes1, target_usage );
|
||||||
psa_set_key_algorithm( &attributes1, target_alg );
|
psa_set_key_algorithm( &attributes1, target_alg );
|
||||||
@ -459,7 +469,8 @@ void copy_to_occupied( int source_lifetime_arg, int source_id_arg,
|
|||||||
PSA_ASSERT( psa_get_key_attributes( target_handle, &attributes1 ) );
|
PSA_ASSERT( psa_get_key_attributes( target_handle, &attributes1 ) );
|
||||||
|
|
||||||
/* Make a copy attempt. */
|
/* Make a copy attempt. */
|
||||||
psa_make_key_persistent( &attributes, target_id, target_lifetime );
|
psa_set_key_id( &attributes, target_id );
|
||||||
|
psa_set_key_lifetime( &attributes, target_lifetime );
|
||||||
TEST_EQUAL( psa_copy_key( source_handle,
|
TEST_EQUAL( psa_copy_key( source_handle,
|
||||||
&attributes, &new_handle ),
|
&attributes, &new_handle ),
|
||||||
PSA_ERROR_ALREADY_EXISTS );
|
PSA_ERROR_ALREADY_EXISTS );
|
||||||
|
Loading…
Reference in New Issue
Block a user