Add lifetime metadata tests
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
c9d86a05ce
commit
607eb7e411
@ -367,6 +367,7 @@ enumerate
|
||||
'asymmetric_encryption_algorithm': [],
|
||||
'pake_algorithm': [self.pake_algorithms],
|
||||
'other_algorithm': [],
|
||||
'lifetime': [],
|
||||
} #type: Dict[str, List[Set[str]]]
|
||||
self.arguments_for['mac_length'] += ['1', '63']
|
||||
self.arguments_for['min_mac_length'] += ['1', '63']
|
||||
|
@ -344,3 +344,33 @@ ecc_key_family:PSA_ECC_FAMILY_TWISTED_EDWARDS
|
||||
|
||||
DH group family: RFC 7919
|
||||
dh_key_family:PSA_DH_FAMILY_RFC7919
|
||||
|
||||
Lifetime: VOLATILE
|
||||
lifetime:PSA_KEY_LIFETIME_VOLATILE:KEY_LIFETIME_IS_VOLATILE:PSA_KEY_PERSISTENCE_VOLATILE:PSA_KEY_LOCATION_LOCAL_STORAGE
|
||||
|
||||
Lifetime: PERSISTENT
|
||||
lifetime:PSA_KEY_LIFETIME_PERSISTENT:0:PSA_KEY_PERSISTENCE_DEFAULT:PSA_KEY_LOCATION_LOCAL_STORAGE
|
||||
|
||||
Lifetime: volatile, local storage
|
||||
lifetime:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_PERSISTENCE_VOLATILE, PSA_KEY_LOCATION_LOCAL_STORAGE):KEY_LIFETIME_IS_VOLATILE:PSA_KEY_PERSISTENCE_VOLATILE:PSA_KEY_LOCATION_LOCAL_STORAGE
|
||||
|
||||
Lifetime: default, local storage
|
||||
lifetime:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_PERSISTENCE_DEFAULT, PSA_KEY_LOCATION_LOCAL_STORAGE):0:PSA_KEY_PERSISTENCE_DEFAULT:PSA_KEY_LOCATION_LOCAL_STORAGE
|
||||
|
||||
Lifetime: 2, local storage
|
||||
lifetime:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(2, PSA_KEY_LOCATION_LOCAL_STORAGE):0:2:PSA_KEY_LOCATION_LOCAL_STORAGE
|
||||
|
||||
Lifetime: 254, local storage
|
||||
lifetime:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(254, PSA_KEY_LOCATION_LOCAL_STORAGE):0:254:PSA_KEY_LOCATION_LOCAL_STORAGE
|
||||
|
||||
Lifetime: volatile, 0x123456
|
||||
lifetime:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_PERSISTENCE_VOLATILE, 0x123456):KEY_LIFETIME_IS_VOLATILE:PSA_KEY_PERSISTENCE_VOLATILE:0x123456
|
||||
|
||||
Lifetime: default, 0x123456
|
||||
lifetime:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(PSA_KEY_PERSISTENCE_DEFAULT, 0x123456):0:PSA_KEY_PERSISTENCE_DEFAULT:0x123456
|
||||
|
||||
Lifetime: 2, 0x123456
|
||||
lifetime:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(2, 0x123456):0:2:0x123456
|
||||
|
||||
Lifetime: 254, 0x123456
|
||||
lifetime:PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(254, 0x123456):0:254:0x123456
|
||||
|
@ -55,6 +55,11 @@
|
||||
#define KEY_TYPE_IS_ECC ( 1u << 6 )
|
||||
#define KEY_TYPE_IS_DH ( 1u << 7 )
|
||||
|
||||
/* Flags for lifetime classification macros. There is a flag for every
|
||||
* lifetime classification macro PSA_KEY_LIFETIME_IS_xxx. The name of the
|
||||
* flag is the name of the classification macro without the PSA_ prefix. */
|
||||
#define KEY_LIFETIME_IS_VOLATILE ( 1u << 0 )
|
||||
|
||||
#define TEST_CLASSIFICATION_MACRO( flag, alg, flags ) \
|
||||
TEST_ASSERT( PSA_##flag( alg ) == !! ( ( flags ) & flag ) )
|
||||
|
||||
@ -665,3 +670,19 @@ void dh_key_family( int group_arg )
|
||||
TEST_EQUAL( PSA_KEY_TYPE_DH_GET_FAMILY( pair_type ), group );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void lifetime( int lifetime_arg, int classification_flags,
|
||||
int persistence_arg, int location_arg )
|
||||
{
|
||||
psa_key_lifetime_t lifetime = lifetime_arg;
|
||||
psa_key_persistence_t persistence = persistence_arg;
|
||||
psa_key_location_t location = location_arg;
|
||||
unsigned flags = classification_flags;
|
||||
|
||||
TEST_CLASSIFICATION_MACRO( KEY_LIFETIME_IS_VOLATILE, lifetime, flags );
|
||||
|
||||
TEST_EQUAL( PSA_KEY_LIFETIME_GET_PERSISTENCE( lifetime ), persistence );
|
||||
TEST_EQUAL( PSA_KEY_LIFETIME_GET_LOCATION( lifetime ), location );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
Loading…
Reference in New Issue
Block a user