mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-05-05 21:42:21 +00:00
fix key lifetime set implementation , tests accordingly
This commit is contained in:
parent
ba178511f4
commit
5d7ec2033d
|
@ -1297,8 +1297,8 @@ psa_status_t psa_set_key_lifetime(psa_key_slot_t key,
|
||||||
return( PSA_ERROR_INVALID_ARGUMENT );
|
return( PSA_ERROR_INVALID_ARGUMENT );
|
||||||
|
|
||||||
slot = &global_data.key_slots[key];
|
slot = &global_data.key_slots[key];
|
||||||
if( slot->type == PSA_KEY_TYPE_NONE )
|
if( slot->type != PSA_KEY_TYPE_NONE )
|
||||||
return( PSA_ERROR_EMPTY_SLOT );
|
return( PSA_ERROR_OCCUPIED_SLOT );
|
||||||
|
|
||||||
if ( lifetime != PSA_KEY_LIFETIME_VOLATILE )
|
if ( lifetime != PSA_KEY_LIFETIME_VOLATILE )
|
||||||
return( PSA_ERROR_NOT_SUPPORTED );
|
return( PSA_ERROR_NOT_SUPPORTED );
|
||||||
|
|
|
@ -90,9 +90,6 @@ key_lifetime:PSA_KEY_LIFETIME_VOLATILE
|
||||||
PSA Key Lifetime set fail, invalid key slot
|
PSA Key Lifetime set fail, invalid key slot
|
||||||
key_lifetime_set_fail:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT
|
key_lifetime_set_fail:0:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_INVALID_ARGUMENT
|
||||||
|
|
||||||
PSA Key Lifetime set fail, unoccupied key slot
|
|
||||||
key_lifetime_set_fail:2:PSA_KEY_LIFETIME_VOLATILE:PSA_ERROR_EMPTY_SLOT
|
|
||||||
|
|
||||||
PSA Key Lifetime set fail, can not change write_once lifetime
|
PSA Key Lifetime set fail, can not change write_once lifetime
|
||||||
key_lifetime_set_fail:1:PSA_KEY_LIFETIME_WRITE_ONCE:PSA_ERROR_NOT_SUPPORTED
|
key_lifetime_set_fail:1:PSA_KEY_LIFETIME_WRITE_ONCE:PSA_ERROR_NOT_SUPPORTED
|
||||||
|
|
||||||
|
|
|
@ -374,11 +374,11 @@ void key_lifetime( int lifetime_arg )
|
||||||
|
|
||||||
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
|
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
|
||||||
|
|
||||||
TEST_ASSERT( psa_import_key( key_slot, key_type,
|
|
||||||
key, sizeof( key ) ) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_set_key_lifetime( key_slot,
|
TEST_ASSERT( psa_set_key_lifetime( key_slot,
|
||||||
lifetime_set ) == PSA_SUCCESS );
|
lifetime_set ) == PSA_SUCCESS );
|
||||||
|
|
||||||
|
TEST_ASSERT( psa_import_key( key_slot, key_type,
|
||||||
|
key, sizeof( key ) ) == PSA_SUCCESS );
|
||||||
|
|
||||||
TEST_ASSERT( psa_get_key_lifetime( key_slot,
|
TEST_ASSERT( psa_get_key_lifetime( key_slot,
|
||||||
&lifetime_get ) == PSA_SUCCESS );
|
&lifetime_get ) == PSA_SUCCESS );
|
||||||
|
@ -396,19 +396,12 @@ exit:
|
||||||
void key_lifetime_set_fail( int key_slot_arg, int lifetime_arg, int expected_status_arg )
|
void key_lifetime_set_fail( int key_slot_arg, int lifetime_arg, int expected_status_arg )
|
||||||
{
|
{
|
||||||
int key_slot = 1;
|
int key_slot = 1;
|
||||||
psa_key_type_t key_type = PSA_ALG_CBC_BASE;
|
|
||||||
unsigned char key[32] = {0};
|
|
||||||
psa_key_lifetime_t lifetime_set = (psa_key_lifetime_t) lifetime_arg;
|
psa_key_lifetime_t lifetime_set = (psa_key_lifetime_t) lifetime_arg;
|
||||||
psa_status_t actual_status;
|
psa_status_t actual_status;
|
||||||
psa_status_t expected_status = expected_status_arg;
|
psa_status_t expected_status = expected_status_arg;
|
||||||
|
|
||||||
memset( key, 0x2a, sizeof( key ) );
|
|
||||||
|
|
||||||
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
|
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
|
||||||
|
|
||||||
TEST_ASSERT( psa_import_key( key_slot, key_type,
|
|
||||||
key, sizeof( key ) ) == PSA_SUCCESS );
|
|
||||||
|
|
||||||
actual_status = psa_set_key_lifetime( key_slot_arg, lifetime_set );
|
actual_status = psa_set_key_lifetime( key_slot_arg, lifetime_set );
|
||||||
|
|
||||||
if( actual_status == PSA_SUCCESS )
|
if( actual_status == PSA_SUCCESS )
|
||||||
|
|
Loading…
Reference in a new issue