Test psa_import_key: test for size in attributes
Add tests where psa_import_key is called with attributes specifying an
incorrect size.
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index c194396..cddcb2e 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -1204,18 +1204,22 @@
/* END_CASE */
/* BEGIN_CASE */
-void import( data_t *data, int type_arg, int expected_status_arg )
+void import( data_t *data, int type_arg,
+ int attr_bits_arg,
+ int expected_status_arg )
{
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_attributes_t got_attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_handle_t handle = 0;
psa_key_type_t type = type_arg;
+ size_t attr_bits = attr_bits_arg;
psa_status_t expected_status = expected_status_arg;
psa_status_t status;
PSA_ASSERT( psa_crypto_init( ) );
psa_set_key_type( &attributes, type );
+ psa_set_key_bits( &attributes, attr_bits );
status = psa_import_key( &attributes, &handle, data->x, data->len );
TEST_EQUAL( status, expected_status );
if( status != PSA_SUCCESS )
@@ -1223,6 +1227,8 @@
PSA_ASSERT( psa_get_key_attributes( handle, &got_attributes ) );
TEST_EQUAL( psa_get_key_type( &got_attributes ), type );
+ if( attr_bits != 0 )
+ TEST_EQUAL( attr_bits, got_attributes.bits );
PSA_ASSERT( psa_destroy_key( handle ) );
test_operations_on_invalid_handle( handle );