SST: Replace SST APIs with PSA PS APIs

Refactors the SST non-secure interfaces, secure API, veneers and
manifest to implement the PSA Protected Storage specification. Adds a
stub implementation for the new SST APIs; another patch will add the
final implementation.

Change-Id: Id62eb82c9d33afd2114962ab1994d567cd81e4f7
Signed-off-by: Jamie Fox <jamie.fox@arm.com>
diff --git a/test/framework/non_secure_suites.c b/test/framework/non_secure_suites.c
index 496dc4f..35890d9 100644
--- a/test/framework/non_secure_suites.c
+++ b/test/framework/non_secure_suites.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -35,6 +35,8 @@
 
 #ifdef SERVICES_TEST_NS
     /* List test cases which compliant with level 1 isolation */
+
+#ifndef PSA_PROTECTED_STORAGE
     /* Non-secure SST test cases */
     {&register_testsuite_ns_sst_interface, 0, 0, 0},
 
@@ -47,6 +49,7 @@
 #endif /* TFM_PARTITION_TEST_SST */
 
 #endif /* TFM_NS_CLIENT_IDENTIFICATION */
+#endif /* !PSA_PROTECTED_STORAGE */
 
     /* Non-secure Audit Logging test cases */
     {&register_testsuite_ns_audit_interface, 0, 0, 0},
diff --git a/test/framework/secure_suites.c b/test/framework/secure_suites.c
index 1dde38d..181f1b1 100644
--- a/test/framework/secure_suites.c
+++ b/test/framework/secure_suites.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -16,8 +16,6 @@
 #include "test/suites/invert/secure/invert_s_tests.h"
 #include "test/suites/crypto/secure/crypto_s_tests.h"
 
-#include "secure_fw/services/secure_storage/sst_object_system.h"
-
 static struct test_suite_t test_suites[] = {
 #if TFM_LVL == 3
 #ifdef SERVICES_TEST_S
@@ -30,6 +28,8 @@
 
 #ifdef SERVICES_TEST_S
     /* List test cases which compliant with level 1 isolation */
+
+#ifndef PSA_PROTECTED_STORAGE
     /* Secure SST test cases */
     {&register_testsuite_s_sst_sec_interface, 0, 0, 0},
     {&register_testsuite_s_sst_reliability, 0, 0, 0},
@@ -37,6 +37,7 @@
 #if defined(SST_ROLLBACK_PROTECTION) && defined(SST_ENCRYPTION)
     {&register_testsuite_s_rollback_protection, 0, 0, 0},
 #endif
+#endif /* !PSA_PROTECTED_STORAGE */
 
     /* Secure Audit Logging test cases */
     {&register_testsuite_s_audit_interface, 0, 0, 0},
@@ -63,14 +64,12 @@
      */
 }
 
-#if TFM_LVL == 1
 static void tear_down_integ_test(void)
 {
-    /* Leave the SST area clean after execute the tests */
-    sst_system_wipe_all();
-    sst_system_prepare();
+    /* Left empty intentionally, currently implemented
+     * test suites require no tear down
+     */
 }
-#endif /* TFM_LVL == 1 */
 
 void start_integ_test(void)
 {
@@ -78,7 +77,5 @@
     integ_test("Secure",
                test_suites,
                sizeof(test_suites)/sizeof(test_suites[0]));
-#if TFM_LVL == 1
     tear_down_integ_test();
-#endif /* TFM_LVL == 1 */
 }
diff --git a/test/framework/test_framework_helpers.c b/test/framework/test_framework_helpers.c
index d9870f4..7423325 100755
--- a/test/framework/test_framework_helpers.c
+++ b/test/framework/test_framework_helpers.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -9,27 +9,37 @@
 
 #include <stdio.h>
 
-const char *sst_err_to_str(enum psa_sst_err_t err)
+const char *psa_ps_status_to_str(psa_ps_status_t status)
 {
-    switch (err) {
-    case PSA_SST_ERR_SUCCESS:
-        return "PSA_SST_ERR_SUCCESS";
-    case PSA_SST_ERR_ASSET_NOT_PREPARED:
-        return "PSA_SST_ERR_ASSET_NOT_PREPARED";
-    case PSA_SST_ERR_ASSET_NOT_FOUND:
-        return "PSA_SST_ERR_ASSET_NOT_FOUND";
-    case PSA_SST_ERR_PARAM_ERROR:
-        return "PSA_SST_ERR_PARAM_ERROR";
-    case PSA_SST_ERR_STORAGE_SYSTEM_FULL:
-        return "PSA_SST_ERR_STORAGE_SYSTEM_FULL";
-    case PSA_SST_ERR_SYSTEM_ERROR:
-        return "PSA_SST_ERR_SYSTEM_ERROR";
-    case PSA_SST_ERR_FORCE_INT_SIZE:
-        return "PSA_SST_ERR_FORCE_INT_SIZE";
-    /* default:  The default is not defined intentionally to force the
-     *           compiler to check that all the enumeration values are
-     *           covered in the switch.
-     */
+    switch (status) {
+    case PSA_PS_SUCCESS:
+        return "PSA_PS_SUCCESS";
+    case PSA_PS_ERROR_WRITE_ONCE:
+        return "PSA_PS_ERROR_WRITE_ONCE";
+    case PSA_PS_ERROR_FLAGS_NOT_SUPPORTED:
+        return "PSA_PS_ERROR_FLAGS_NOT_SUPPORTED";
+    case PSA_PS_ERROR_INSUFFICIENT_SPACE:
+        return "PSA_PS_ERROR_INSUFFICIENT_SPACE";
+    case PSA_PS_ERROR_STORAGE_FAILURE:
+        return "PSA_PS_ERROR_STORAGE_FAILURE";
+    case PSA_PS_ERROR_UID_NOT_FOUND:
+        return "PSA_PS_ERROR_UID_NOT_FOUND";
+    case PSA_PS_ERROR_INCORRECT_SIZE:
+        return "PSA_PS_ERROR_INCORRECT_SIZE";
+    case PSA_PS_ERROR_OFFSET_INVALID:
+        return "PSA_PS_ERROR_OFFSET_INVALID";
+    case PSA_PS_ERROR_INVALID_ARGUMENT:
+        return "PSA_PS_ERROR_INVALID_ARGUMENT";
+    case PSA_PS_ERROR_DATA_CORRUPT:
+        return "PSA_PS_ERROR_DATA_CORRUPT";
+    case PSA_PS_ERROR_AUTH_FAILED:
+        return "PSA_PS_ERROR_AUTH_FAILED";
+    case PSA_PS_ERROR_OPERATION_FAILED:
+        return "PSA_PS_ERROR_OPERATION_FAILED";
+    case PSA_PS_ERROR_NOT_SUPPORTED:
+        return "PSA_PS_ERROR_NOT_SUPPORTED";
+    default:
+        return "Unknown error";
     }
 }
 
diff --git a/test/framework/test_framework_helpers.h b/test/framework/test_framework_helpers.h
index c0e7a7a..03eb3dc 100755
--- a/test/framework/test_framework_helpers.h
+++ b/test/framework/test_framework_helpers.h
@@ -1,22 +1,21 @@
 /*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
  */
 
-#ifndef __HELPERS_H__
-#define __HELPERS_H__
+#ifndef __TEST_FRAMEWORK_HELPERS_H__
+#define __TEST_FRAMEWORK_HELPERS_H__
+
+#include <stdint.h>
+#include "psa_protected_storage.h"
+#include "test_framework.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include <stdint.h>
-#include "tfm_sst_defs.h"
-#include "secure_fw/services/secure_storage/sst_asset_management.h"
-#include "test_framework.h"
-
 enum serial_color_t {
     BLACK = 0,
     RED = 1,
@@ -29,13 +28,13 @@
 };
 
 /**
- * \brief Translates psa_sst_err_t into a string.
+ * \brief Translates psa_ps_status_t into a string.
  *
- * \param[in] err  psa_sst_err_t error value.
+ * \param[in] err  psa_ps_status_t status value.
  *
- * \return psa_sst_err_t as string.
+ * \return psa_ps_status_t as string.
  */
-const char *sst_err_to_str(enum psa_sst_err_t err);
+const char *psa_ps_status_to_str(psa_ps_status_t status);
 
 /**
  * \brief Translates asset permissions into a string.
@@ -59,4 +58,4 @@
 }
 #endif
 
-#endif /* __HELPERS_H__ */
+#endif /* __TEST_FRAMEWORK_HELPERS_H__ */