Skip to content

Commit 17061a4

Browse files
Add test function for effective key attributes
We're going to create some edge cases where the attributes of a key are not bitwise identical to the attributes passed during creation. Have a test function ready for that.
1 parent 3034bdb commit 17061a4

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

tests/suites/test_suite_psa_crypto.function

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,14 +1647,20 @@ exit:
16471647
/* END_CASE */
16481648

16491649
/* BEGIN_CASE */
1650-
void check_key_policy( int type_arg, int bits_arg,
1651-
int usage_arg, int alg_arg )
1650+
void effective_key_attributes( int type_arg, int expected_type_arg,
1651+
int bits_arg, int expected_bits_arg,
1652+
int usage_arg, int expected_usage_arg,
1653+
int alg_arg, int expected_alg_arg )
16521654
{
16531655
psa_key_handle_t handle = 0;
16541656
psa_key_type_t key_type = type_arg;
1657+
psa_key_type_t expected_key_type = expected_type_arg;
16551658
size_t bits = bits_arg;
1659+
size_t expected_bits = expected_bits_arg;
16561660
psa_algorithm_t alg = alg_arg;
1661+
psa_algorithm_t expected_alg = expected_alg_arg;
16571662
psa_key_usage_t usage = usage_arg;
1663+
psa_key_usage_t expected_usage = expected_usage_arg;
16581664
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
16591665

16601666
PSA_ASSERT( psa_crypto_init( ) );
@@ -1668,10 +1674,10 @@ void check_key_policy( int type_arg, int bits_arg,
16681674
psa_reset_key_attributes( &attributes );
16691675

16701676
PSA_ASSERT( psa_get_key_attributes( handle, &attributes ) );
1671-
TEST_EQUAL( psa_get_key_type( &attributes ), key_type );
1672-
TEST_EQUAL( psa_get_key_bits( &attributes ), bits );
1673-
TEST_EQUAL( psa_get_key_usage_flags( &attributes ), usage );
1674-
TEST_EQUAL( psa_get_key_algorithm( &attributes ), alg );
1677+
TEST_EQUAL( psa_get_key_type( &attributes ), expected_key_type );
1678+
TEST_EQUAL( psa_get_key_bits( &attributes ), expected_bits );
1679+
TEST_EQUAL( psa_get_key_usage_flags( &attributes ), expected_usage );
1680+
TEST_EQUAL( psa_get_key_algorithm( &attributes ), expected_alg );
16751681

16761682
exit:
16771683
psa_destroy_key( handle );
@@ -1680,6 +1686,16 @@ exit:
16801686
}
16811687
/* END_CASE */
16821688

1689+
/* BEGIN_CASE */
1690+
void check_key_policy( int type_arg, int bits_arg,
1691+
int usage_arg, int alg_arg )
1692+
{
1693+
test_effective_key_attributes( type_arg, type_arg, bits_arg, bits_arg,
1694+
usage_arg, usage_arg, alg_arg, alg_arg );
1695+
goto exit;
1696+
}
1697+
/* END_CASE */
1698+
16831699
/* BEGIN_CASE */
16841700
void key_attributes_init( )
16851701
{

0 commit comments

Comments
 (0)