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/interface/include/tfm_sst_defs.h b/interface/include/tfm_sst_defs.h
index 09d3b44..a008c73 100644
--- a/interface/include/tfm_sst_defs.h
+++ b/interface/include/tfm_sst_defs.h
@@ -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
*
@@ -8,43 +8,52 @@
#ifndef __TFM_SST_DEFS_H__
#define __TFM_SST_DEFS_H__
+#include <limits.h>
+#include "psa_protected_storage.h"
+#include "tfm_api.h"
+
#ifdef __cplusplus
extern "C" {
#endif
-#include <inttypes.h>
-#include <limits.h>
-#include "psa_sst_api.h"
+/* The return value is shared with the TF-M partition status value.
+ * The SST return codes shouldn't overlap with predefined TF-M status values.
+ */
+#define TFM_SST_ERR_OFFSET (TFM_PARTITION_SPECIFIC_ERROR_MIN)
-/*!
- * \struct tfm_sst_token_t
+/**
+ * \enum tfm_sst_err_t
*
- * \brief Structure to store the asset's token.
+ * \brief TF-M Secure Storage service error types
*
*/
-struct tfm_sst_token_t {
- const uint8_t *token; /*!< Pointer to the asset's token to be used to
- * generate the asset key to encrypt and decrypt
- * the asset data. This is an optional parameter
- * that has to be NULL in case the token is not
- * provied.
- */
- uint32_t token_size; /*!< Token size. In case the token is not provided
- * the token size has to be 0.
- */
+enum tfm_sst_err_t {
+ TFM_SST_ERR_SUCCESS = 0,
+ TFM_SST_ERR_WRITE_ONCE = TFM_SST_ERR_OFFSET,
+ TFM_SST_ERR_FLAGS_NOT_SUPPORTED,
+ TFM_SST_ERR_INSUFFICIENT_SPACE,
+ TFM_SST_ERR_STORAGE_FAILURE,
+ TFM_SST_ERR_UID_NOT_FOUND,
+ TFM_SST_ERR_INCORRECT_SIZE,
+ TFM_SST_ERR_OFFSET_INVALID,
+ TFM_SST_ERR_INVALID_ARGUMENT,
+ TFM_SST_ERR_DATA_CORRUPT,
+ TFM_SST_ERR_AUTH_FAILED,
+ TFM_SST_ERR_OPERATION_FAILED,
+ TFM_SST_ERR_NOT_SUPPORTED,
+ /* Add an invalid return code which forces the size of the type as well */
+ TFM_SST_ERR_INVALID = INT_MAX
};
-/*!
- * \struct tfm_sst_buf_t
- *
- * \brief Structure to store data information to read/write from/to asset.
- *
+/**
+ * \brief A macro to translate TF-M API return values including the offset
+ * needed by TF-M, to the corresponding PSA value.
*/
-struct tfm_sst_buf_t {
- uint8_t *data; /*!< Address of input/output data */
- uint32_t size; /*!< Size of input/output data */
- uint32_t offset; /*!< Offset within asset */
-};
+#define TFM_SST_PSA_RETURN(err) ( \
+ (err) == TFM_SST_ERR_SUCCESS ? err : \
+ (err) >= TFM_SST_ERR_WRITE_ONCE ? ((err) - (TFM_SST_ERR_WRITE_ONCE - 1)) : \
+ TFM_SST_ERR_INVALID \
+)
#ifdef __cplusplus
}