Close or destroy keys explicitly in tests
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index acc2f8c..22eec33 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -1291,6 +1291,7 @@
psa_set_key_type( &attributes, type );
status = psa_import_key( &attributes, p, length, &handle );
TEST_EQUAL( status, expected_status );
+
if( status == PSA_SUCCESS )
PSA_ASSERT( psa_destroy_key( handle ) );
@@ -2100,6 +2101,9 @@
TEST_EQUAL( psa_copy_key( source_handle,
&target_attributes, &target_handle ),
expected_status_arg );
+
+ PSA_ASSERT( psa_destroy_key( source_handle ) );
+
exit:
psa_reset_key_attributes( &source_attributes );
psa_reset_key_attributes( &target_attributes );
@@ -2587,6 +2591,8 @@
PSA_ERROR_BAD_STATE );
PSA_ASSERT( psa_mac_abort( &operation ) );
+ PSA_ASSERT( psa_destroy_key( handle ) );
+
exit:
PSA_DONE( );
}
@@ -2908,6 +2914,8 @@
PSA_ERROR_BAD_STATE );
PSA_ASSERT( psa_cipher_abort( &operation ) );
+ PSA_ASSERT( psa_destroy_key( handle ) );
+
exit:
PSA_DONE( );
}
@@ -5016,6 +5024,7 @@
}
/* Shutdown and restart */
+ PSA_ASSERT( psa_close_key( handle ) );
PSA_DONE();
PSA_ASSERT( psa_crypto_init() );