Reverting comments deleted in previous PR
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 8312c07..a8f3674 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -1000,6 +1000,13 @@
{
psa_status_t status = psa_remove_key_data_from_memory( slot );
+ /*
+ * As the return error code may not be handled in case of multiple errors,
+ * do our best to report an unexpected lock counter: if available call
+ * MBEDTLS_TEST_HOOK_TEST_ASSERT that may terminate execution (if called as
+ * part of the execution of a test suite this will stop the test suite
+ * execution).
+ */
if( slot->lock_count != 1 )
{
MBEDTLS_TEST_HOOK_TEST_ASSERT( slot->lock_count == 1 );
diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c
index cb10f6e..49e6b87 100644
--- a/library/psa_crypto_slot_management.c
+++ b/library/psa_crypto_slot_management.c
@@ -412,6 +412,13 @@
return( PSA_SUCCESS );
}
+ /*
+ * As the return error code may not be handled in case of multiple errors,
+ * do our best to report if the lock counter is equal to zero: if available
+ * call MBEDTLS_TEST_HOOK_TEST_ASSERT that may terminate execution (if called
+ * as part of the execution of a unit test suite this will stop the test
+ * suite execution).
+ */
MBEDTLS_TEST_HOOK_TEST_ASSERT( slot->lock_count > 0 );
return( PSA_ERROR_CORRUPTION_DETECTED );
}