mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-27 02:14:15 +01:00
Add a few tests for persistent attributes
psa_set_key_lifetime and psa_set_key_id aren't pure setters: they also set the other attribute in some conditions. Add dedicated tests for this behavior.
This commit is contained in:
parent
9de5eb0a2f
commit
dd835cbea6
@ -4,6 +4,21 @@ static_checks:
|
||||
PSA key attributes structure
|
||||
attributes_set_get:0x6963:PSA_KEY_LIFETIME_PERSISTENT:PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT:PSA_ALG_CCM:PSA_KEY_TYPE_AES:128
|
||||
|
||||
PSA key attributes: id only
|
||||
persistence_attributes:0x1234:-1:-1:0x1234:PSA_KEY_LIFETIME_PERSISTENT
|
||||
|
||||
PSA key attributes: lifetime=3 only
|
||||
persistence_attributes:-1:3:-1:0:3
|
||||
|
||||
PSA key attributes: id then back to volatile
|
||||
persistence_attributes:0x1234:PSA_KEY_LIFETIME_VOLATILE:-1:0:PSA_KEY_LIFETIME_VOLATILE
|
||||
|
||||
PSA key attributes: id then lifetime
|
||||
persistence_attributes:0x1234:3:-1:0x1234:3
|
||||
|
||||
PSA key attributes: lifetime then id
|
||||
persistence_attributes:0x1234:3:0x1235:0x1235:3
|
||||
|
||||
PSA import/export raw: 0 bytes
|
||||
import_export:"":PSA_KEY_TYPE_RAW_DATA:0:PSA_KEY_USAGE_EXPORT:0:0:PSA_SUCCESS:1
|
||||
|
||||
|
@ -1204,6 +1204,29 @@ void attributes_set_get( int id_arg, int lifetime_arg,
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void persistence_attributes( int id1_arg, int lifetime_arg, int id2_arg,
|
||||
int expected_id_arg, int expected_lifetime_arg )
|
||||
{
|
||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
psa_key_id_t id1 = id1_arg;
|
||||
psa_key_lifetime_t lifetime = lifetime_arg;
|
||||
psa_key_id_t id2 = id2_arg;
|
||||
psa_key_id_t expected_id = expected_id_arg;
|
||||
psa_key_lifetime_t expected_lifetime = expected_lifetime_arg;
|
||||
|
||||
if( id1_arg != -1 )
|
||||
psa_set_key_id( &attributes, id1 );
|
||||
if( lifetime_arg != -1 )
|
||||
psa_set_key_lifetime( &attributes, lifetime );
|
||||
if( id2_arg != -1 )
|
||||
psa_set_key_id( &attributes, id2 );
|
||||
|
||||
TEST_EQUAL( psa_get_key_id( &attributes ), expected_id );
|
||||
TEST_EQUAL( psa_get_key_lifetime( &attributes ), expected_lifetime );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void import( data_t *data, int type_arg,
|
||||
int attr_bits_arg,
|
||||
|
Loading…
Reference in New Issue
Block a user