Enrollment algorithm in policy: add support in psa_copy_key tests
Add parameters to psa_copy_key tests for the enrollment algorithm (alg2).
This commit only tests with alg2=0, which is equivalent to not setting
an enrollment algorithm.
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index 8cf30c8..aaa3189 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -1987,16 +1987,20 @@
/* END_CASE */
/* BEGIN_CASE */
-void copy_success( int source_usage_arg, int source_alg_arg,
+void copy_success( int source_usage_arg,
+ int source_alg_arg, int source_alg2_arg,
int type_arg, data_t *material,
int copy_attributes,
- int target_usage_arg, int target_alg_arg,
- int expected_usage_arg, int expected_alg_arg )
+ int target_usage_arg,
+ int target_alg_arg, int target_alg2_arg,
+ int expected_usage_arg,
+ int expected_alg_arg, int expected_alg2_arg )
{
psa_key_attributes_t source_attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_attributes_t target_attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_usage_t expected_usage = expected_usage_arg;
psa_algorithm_t expected_alg = expected_alg_arg;
+ psa_algorithm_t expected_alg2 = expected_alg2_arg;
psa_key_handle_t source_handle = 0;
psa_key_handle_t target_handle = 0;
uint8_t *export_buffer = NULL;
@@ -2006,6 +2010,7 @@
/* Prepare the source key. */
psa_set_key_usage_flags( &source_attributes, source_usage_arg );
psa_set_key_algorithm( &source_attributes, source_alg_arg );
+ psa_set_key_enrollment_algorithm( &source_attributes, source_alg2_arg );
psa_set_key_type( &source_attributes, type_arg );
PSA_ASSERT( psa_import_key( &source_attributes,
material->x, material->len,
@@ -2019,6 +2024,8 @@
psa_set_key_usage_flags( &target_attributes, target_usage_arg );
if( target_alg_arg != -1 )
psa_set_key_algorithm( &target_attributes, target_alg_arg );
+ if( target_alg2_arg != -1 )
+ psa_set_key_enrollment_algorithm( &target_attributes, target_alg2_arg );
/* Copy the key. */
PSA_ASSERT( psa_copy_key( source_handle,
@@ -2035,6 +2042,8 @@
psa_get_key_bits( &target_attributes ) );
TEST_EQUAL( expected_usage, psa_get_key_usage_flags( &target_attributes ) );
TEST_EQUAL( expected_alg, psa_get_key_algorithm( &target_attributes ) );
+ TEST_EQUAL( expected_alg2,
+ psa_get_key_enrollment_algorithm( &target_attributes ) );
if( expected_usage & PSA_KEY_USAGE_EXPORT )
{
size_t length;
@@ -2046,6 +2055,8 @@
}
if( ! exercise_key( target_handle, expected_usage, expected_alg ) )
goto exit;
+ if( ! exercise_key( target_handle, expected_usage, expected_alg2 ) )
+ goto exit;
PSA_ASSERT( psa_close_key( target_handle ) );
@@ -2058,10 +2069,12 @@
/* END_CASE */
/* BEGIN_CASE */
-void copy_fail( int source_usage_arg, int source_alg_arg,
+void copy_fail( int source_usage_arg,
+ int source_alg_arg, int source_alg2_arg,
int type_arg, data_t *material,
int target_type_arg, int target_bits_arg,
- int target_usage_arg, int target_alg_arg,
+ int target_usage_arg,
+ int target_alg_arg, int target_alg2_arg,
int expected_status_arg )
{
psa_key_attributes_t source_attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -2074,6 +2087,7 @@
/* Prepare the source key. */
psa_set_key_usage_flags( &source_attributes, source_usage_arg );
psa_set_key_algorithm( &source_attributes, source_alg_arg );
+ psa_set_key_enrollment_algorithm( &source_attributes, source_alg2_arg );
psa_set_key_type( &source_attributes, type_arg );
PSA_ASSERT( psa_import_key( &source_attributes,
material->x, material->len,
@@ -2084,6 +2098,7 @@
psa_set_key_bits( &target_attributes, target_bits_arg );
psa_set_key_usage_flags( &target_attributes, target_usage_arg );
psa_set_key_algorithm( &target_attributes, target_alg_arg );
+ psa_set_key_enrollment_algorithm( &target_attributes, target_alg2_arg );
/* Try to copy the key. */
TEST_EQUAL( psa_copy_key( source_handle,