Re-introduction of key slot chekcs

Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 6e73d12..c7186af 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -1002,6 +1002,10 @@
 
     if( slot->lock_count != 1 )
     {
+#if defined(MBEDTLS_TEST_HOOKS)
+        if( *mbedtls_test_hook_value != NULL )
+            ( *mbedtls_test_hook_value )( slot->lock_count == 1, __FILE__, __LINE__ );
+#endif
         status = PSA_ERROR_CORRUPTION_DETECTED;
     }
 
diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c
index 4131e3c..256408d 100644
--- a/library/psa_crypto_slot_management.c
+++ b/library/psa_crypto_slot_management.c
@@ -34,6 +34,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include "mbedtls/error.h"
 #if defined(MBEDTLS_PLATFORM_C)
 #include "mbedtls/platform.h"
 #else
@@ -412,6 +413,13 @@
         return( PSA_SUCCESS );
     }
 
+    slot->lock_count = 1;
+
+#if defined(MBEDTLS_TEST_HOOKS)
+    if( *mbedtls_test_hook_value != NULL )
+        ( *mbedtls_test_hook_value )( slot->lock_count > 0, __FILE__, __LINE__  );
+#endif
+
     return( PSA_ERROR_CORRUPTION_DETECTED );
 }