SST: Replace TFM SST errors by PSA PS errors
This patch replaces all TFM SST errors by PSA PS errors in the code as
the TF-M framework does not require any offset when using the
uniform secure function signature feature.
Change-Id: Iab314c001edc77e6fb1b8bb1641548c0a6c00a77
Signed-off-by: Marc Moreno <marc.morenoberengue@arm.com>
diff --git a/interface/include/tfm_sst_defs.h b/interface/include/tfm_sst_defs.h
index 1d54043..9132cce 100644
--- a/interface/include/tfm_sst_defs.h
+++ b/interface/include/tfm_sst_defs.h
@@ -8,53 +8,10 @@
#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
-/* 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)
-
-/**
- * \enum tfm_sst_err_t
- *
- * \brief TF-M Secure Storage service error types
- *
- */
-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
-};
-
-/**
- * \brief A macro to translate TF-M API return values including the offset
- * needed by TF-M, to the corresponding PSA value.
- */
-#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 \
-)
-
/* Invalid UID */
#define TFM_SST_INVALID_UID 0
diff --git a/interface/src/tfm_sst_api.c b/interface/src/tfm_sst_api.c
index 5102b2f..0678dd4 100644
--- a/interface/src/tfm_sst_api.c
+++ b/interface/src/tfm_sst_api.c
@@ -8,7 +8,6 @@
#include "psa_protected_storage.h"
#include "tfm_ns_lock.h"
-#include "tfm_sst_defs.h"
#include "tfm_veneers.h"
#define IOVEC_LEN(x) (uint32_t)(sizeof(x)/sizeof(x[0]))
@@ -19,7 +18,7 @@
psa_ps_create_flags_t create_flags)
{
psa_status_t status;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) },
@@ -38,7 +37,7 @@
return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_PSA_RETURN(err);
+ return err;
}
psa_ps_status_t psa_ps_get(psa_ps_uid_t uid,
@@ -47,7 +46,7 @@
void *p_data)
{
psa_status_t status;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) },
@@ -67,13 +66,13 @@
return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_PSA_RETURN(err);
+ return err;
}
psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
{
psa_status_t status;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) }
@@ -92,13 +91,13 @@
return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_PSA_RETURN(err);
+ return err;
}
psa_ps_status_t psa_ps_remove(psa_ps_uid_t uid)
{
psa_status_t status;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) }
@@ -116,7 +115,7 @@
return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_PSA_RETURN(err);
+ return err;
}
psa_ps_status_t psa_ps_create(psa_ps_uid_t uid, uint32_t size,
diff --git a/secure_fw/services/secure_storage/crypto/sst_crypto_interface.c b/secure_fw/services/secure_storage/crypto/sst_crypto_interface.c
index 4d9e561..75b5ff5 100644
--- a/secure_fw/services/secure_storage/crypto/sst_crypto_interface.c
+++ b/secure_fw/services/secure_storage/crypto/sst_crypto_interface.c
@@ -29,7 +29,7 @@
/* Static buffer to be used by mbedtls for memory allocation */
static uint8_t mbedtls_mem_buf[SST_MBEDTLS_MEM_BUF_LEN];
-enum tfm_sst_err_t sst_crypto_init(void)
+psa_ps_status_t sst_crypto_init(void)
{
mbedtls_gcm_free(&sst_crypto_gcm_ctx);
@@ -44,10 +44,10 @@
* are void. When integrated with crypto engine or service
* a return value may be required.
*/
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_crypto_getkey(uint8_t *key, size_t key_len)
+psa_ps_status_t sst_crypto_getkey(uint8_t *key, size_t key_len)
{
enum tfm_plat_err_t err;
@@ -61,23 +61,23 @@
*/
err = tfm_plat_get_crypto_huk(key, key_len);
if (err != TFM_PLAT_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_crypto_setkey(const uint8_t *key, size_t key_len)
+psa_ps_status_t sst_crypto_setkey(const uint8_t *key, size_t key_len)
{
int32_t err;
err = mbedtls_gcm_setkey(&sst_crypto_gcm_ctx, MBEDTLS_CIPHER_ID_AES,
key, key_len*8);
if (err != 0) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
void sst_crypto_set_iv(const union sst_crypto_t *crypto)
@@ -128,11 +128,10 @@
}
-enum tfm_sst_err_t sst_crypto_encrypt_and_tag(
- union sst_crypto_t *crypto,
- const uint8_t *add, size_t add_len,
- const uint8_t *in, uint8_t *out,
- size_t len)
+psa_ps_status_t sst_crypto_encrypt_and_tag(union sst_crypto_t *crypto,
+ const uint8_t *add, size_t add_len,
+ const uint8_t *in, uint8_t *out,
+ size_t len)
{
int32_t err;
@@ -141,17 +140,16 @@
add_len, in, out, SST_TAG_LEN_BYTES,
crypto->ref.tag);
if (err != 0) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_crypto_auth_and_decrypt(
- const union sst_crypto_t *crypto,
- const uint8_t *add, size_t add_len,
- const uint8_t *in, uint8_t *out,
- size_t len)
+psa_ps_status_t sst_crypto_auth_and_decrypt(const union sst_crypto_t *crypto,
+ const uint8_t *add, size_t add_len,
+ const uint8_t *in, uint8_t *out,
+ size_t len)
{
int32_t err;
@@ -160,25 +158,24 @@
crypto->ref.tag, SST_TAG_LEN_BYTES,
in, out);
if (err != 0) {
- return TFM_SST_ERR_AUTH_FAILED;
+ return PSA_PS_ERROR_AUTH_FAILED;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_crypto_generate_auth_tag(union sst_crypto_t *crypto,
- const uint8_t *add,
- uint32_t add_len)
+psa_ps_status_t sst_crypto_generate_auth_tag(union sst_crypto_t *crypto,
+ const uint8_t *add,
+ uint32_t add_len)
{
- enum tfm_sst_err_t ret;
+ psa_ps_status_t ret;
ret = sst_crypto_encrypt_and_tag(crypto, add, add_len, 0, 0, 0);
return ret;
}
-enum tfm_sst_err_t sst_crypto_authenticate(
- const union sst_crypto_t *crypto,
- const uint8_t *add, uint32_t add_len)
+psa_ps_status_t sst_crypto_authenticate(const union sst_crypto_t *crypto,
+ const uint8_t *add, uint32_t add_len)
{
uint32_t ret;
diff --git a/secure_fw/services/secure_storage/crypto/sst_crypto_interface.h b/secure_fw/services/secure_storage/crypto/sst_crypto_interface.h
index afad788..e941901 100644
--- a/secure_fw/services/secure_storage/crypto/sst_crypto_interface.h
+++ b/secure_fw/services/secure_storage/crypto/sst_crypto_interface.h
@@ -14,7 +14,7 @@
#include <stddef.h>
#include <stdint.h>
-#include "tfm_sst_defs.h"
+#include "psa_protected_storage.h"
#define SST_KEY_LEN_BITS 128
#define SST_TAG_LEN_BYTES 16
@@ -36,9 +36,9 @@
/**
* \brief Initializes the crypto engine.
*
- * \return Returns values as described in \ref tfm_sst_err_t
+ * \return Returns values as described in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_crypto_init(void);
+psa_ps_status_t sst_crypto_init(void);
/**
* \brief Gets a key for specific client id
@@ -46,9 +46,9 @@
* \param[out] key Cryptographic key
* \param[in] key_len Key len
*
- * \return Returns values as described in \ref tfm_sst_err_t
+ * \return Returns values as described in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_crypto_getkey(uint8_t *key, size_t key_len);
+psa_ps_status_t sst_crypto_getkey(uint8_t *key, size_t key_len);
/**
* \brief Sets key for crypto operations
@@ -56,9 +56,9 @@
* \param[in] key Cryptographic key
* \param[in] key_len Key len
*
- * \return Returns values as described in \ref tfm_sst_err_t
+ * \return Returns values as described in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_crypto_setkey(const uint8_t *key, size_t key_len);
+psa_ps_status_t sst_crypto_setkey(const uint8_t *key, size_t key_len);
/**
* \brief Encrypts and tag the given plain text data.
@@ -70,14 +70,14 @@
* \param[out] out Buffer pointer to store the encrypted data
* \param[in] len Input and output buffer lengths
*
- * \return Returns values as described in \ref tfm_sst_err_t
+ * \return Returns values as described in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_crypto_encrypt_and_tag(union sst_crypto_t *crypto,
- const uint8_t *add,
- size_t add_len,
- const uint8_t *in,
- uint8_t *out,
- size_t len);
+psa_ps_status_t sst_crypto_encrypt_and_tag(union sst_crypto_t *crypto,
+ const uint8_t *add,
+ size_t add_len,
+ const uint8_t *in,
+ uint8_t *out,
+ size_t len);
/**
* \brief Decrypts and checks the given encrypted data.
@@ -89,14 +89,14 @@
* \param[out] out Buffer pointer to store the encrypted data
* \param[in] len Input and output buffer lengths
*
- * \return Returns values as described in \ref tfm_sst_err_t
+ * \return Returns values as described in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_crypto_auth_and_decrypt(const union sst_crypto_t *crypto,
- const uint8_t *add,
- size_t add_len,
- const uint8_t *in,
- uint8_t *out,
- size_t len);
+psa_ps_status_t sst_crypto_auth_and_decrypt(const union sst_crypto_t *crypto,
+ const uint8_t *add,
+ size_t add_len,
+ const uint8_t *in,
+ uint8_t *out,
+ size_t len);
/**
* \brief Generates authentication MAC value for give data
@@ -105,11 +105,11 @@
* \param[in] add Starting address of the data to authenticate
* \param[in] add_len Length of data to authenticate
*
- * \return Returns values as described in \ref tfm_sst_err_t
+ * \return Returns values as described in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_crypto_generate_auth_tag(union sst_crypto_t *crypto,
- const uint8_t *add,
- uint32_t add_len);
+psa_ps_status_t sst_crypto_generate_auth_tag(union sst_crypto_t *crypto,
+ const uint8_t *add,
+ uint32_t add_len);
/**
* \brief Authenticate give data against the tag
@@ -118,11 +118,11 @@
* \param[in] add Starting address of the data to authenticate
* \param[in] add_len Length of data to authenticate
*
- * \return Returns values as described in \ref tfm_sst_err_t
+ * \return Returns values as described in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_crypto_authenticate(const union sst_crypto_t *crypto,
- const uint8_t *add,
- uint32_t add_len);
+psa_ps_status_t sst_crypto_authenticate(const union sst_crypto_t *crypto,
+ const uint8_t *add,
+ uint32_t add_len);
/**
* \brief Provides current IV value to crypto layer
diff --git a/secure_fw/services/secure_storage/flash/sst_flash.c b/secure_fw/services/secure_storage/flash/sst_flash.c
index e094673..e5fa4f8 100644
--- a/secure_fw/services/secure_storage/flash/sst_flash.c
+++ b/secure_fw/services/secure_storage/flash/sst_flash.c
@@ -48,34 +48,34 @@
}
#ifdef SST_RAM_FS
-static enum tfm_sst_err_t flash_init(void)
+static psa_ps_status_t flash_init(void)
{
/* Nothing needs to be done in case of Flash emulated in RAM */
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-static enum tfm_sst_err_t flash_read(uint32_t flash_addr, uint32_t size,
- uint8_t *buff)
+static psa_ps_status_t flash_read(uint32_t flash_addr, uint32_t size,
+ uint8_t *buff)
{
uint32_t idx = flash_addr - SST_FLASH_AREA_ADDR;
sst_utils_memcpy(buff, &block_data[idx], size);
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-static enum tfm_sst_err_t flash_write(uint32_t flash_addr, uint32_t size,
- const uint8_t *buff)
+static psa_ps_status_t flash_write(uint32_t flash_addr, uint32_t size,
+ const uint8_t *buff)
{
uint32_t idx = flash_addr - SST_FLASH_AREA_ADDR;
sst_utils_memcpy(&block_data[idx], buff, size);
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-static enum tfm_sst_err_t flash_erase(uint32_t flash_addr)
+static psa_ps_status_t flash_erase(uint32_t flash_addr)
{
uint32_t idx = flash_addr - SST_FLASH_AREA_ADDR;
@@ -83,67 +83,67 @@
SST_FLASH_DEFAULT_VAL,
SST_BLOCK_SIZE);
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
#else
-static enum tfm_sst_err_t flash_init(void)
+static psa_ps_status_t flash_init(void)
{
int32_t err;
err = FLASH_DEV_NAME.Initialize(NULL);
- if(err != ARM_DRIVER_OK) {
- return TFM_SST_ERR_STORAGE_FAILURE;
+ if (err != ARM_DRIVER_OK) {
+ return PSA_PS_ERROR_STORAGE_FAILURE;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-static enum tfm_sst_err_t flash_read(uint32_t flash_addr, uint32_t size,
- uint8_t *buff)
+static psa_ps_status_t flash_read(uint32_t flash_addr, uint32_t size,
+ uint8_t *buff)
{
int32_t err;
err = FLASH_DEV_NAME.ReadData(flash_addr, buff, size);
if (err != ARM_DRIVER_OK) {
- return TFM_SST_ERR_STORAGE_FAILURE;
+ return PSA_PS_ERROR_STORAGE_FAILURE;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-static enum tfm_sst_err_t flash_write(uint32_t flash_addr, uint32_t size,
- const uint8_t *buff)
+static psa_ps_status_t flash_write(uint32_t flash_addr, uint32_t size,
+ const uint8_t *buff)
{
int32_t err;
err = FLASH_DEV_NAME.ProgramData(flash_addr, buff, size);
if (err != ARM_DRIVER_OK) {
- return TFM_SST_ERR_STORAGE_FAILURE;
+ return PSA_PS_ERROR_STORAGE_FAILURE;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-static enum tfm_sst_err_t flash_erase(uint32_t flash_addr)
+static psa_ps_status_t flash_erase(uint32_t flash_addr)
{
int32_t err;
err = FLASH_DEV_NAME.EraseSector(flash_addr);
if (err != ARM_DRIVER_OK) {
- return TFM_SST_ERR_STORAGE_FAILURE;
+ return PSA_PS_ERROR_STORAGE_FAILURE;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
#endif /* SST_RAM_FS */
-enum tfm_sst_err_t sst_flash_init(void)
+psa_ps_status_t sst_flash_init(void)
{
return flash_init();
}
-enum tfm_sst_err_t sst_flash_read(uint32_t block_id, uint8_t *buff,
- uint32_t offset, uint32_t size)
+psa_ps_status_t sst_flash_read(uint32_t block_id, uint8_t *buff,
+ uint32_t offset, uint32_t size)
{
uint32_t flash_addr;
@@ -155,8 +155,8 @@
return flash_read(flash_addr, size, buff);
}
-enum tfm_sst_err_t sst_flash_write(uint32_t block_id, const uint8_t *buff,
- uint32_t offset, uint32_t size)
+psa_ps_status_t sst_flash_write(uint32_t block_id, const uint8_t *buff,
+ uint32_t offset, uint32_t size)
{
uint32_t flash_addr;
@@ -168,13 +168,13 @@
return flash_write(flash_addr, size, buff);
}
-enum tfm_sst_err_t sst_flash_block_to_block_move(uint32_t dst_block,
- uint32_t dst_offset,
- uint32_t src_block,
- uint32_t src_offset,
- uint32_t size)
+psa_ps_status_t sst_flash_block_to_block_move(uint32_t dst_block,
+ uint32_t dst_offset,
+ uint32_t src_block,
+ uint32_t src_offset,
+ uint32_t size)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint8_t dst_block_data_copy[MAX_BLOCK_DATA_COPY];
uint32_t dst_flash_addr;
uint32_t src_flash_addr;
@@ -196,13 +196,13 @@
* destination content.
*/
err = flash_read(src_flash_addr, bytes_to_move, dst_block_data_copy);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
/* Writes in flash the in-memory block content after modification */
err = flash_write(dst_flash_addr, bytes_to_move, dst_block_data_copy);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -214,10 +214,10 @@
dst_flash_addr += bytes_to_move;
};
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_flash_erase_block(uint32_t block_id)
+psa_ps_status_t sst_flash_erase_block(uint32_t block_id)
{
uint32_t flash_addr;
diff --git a/secure_fw/services/secure_storage/flash/sst_flash.h b/secure_fw/services/secure_storage/flash/sst_flash.h
index 3206c45..b461b07 100644
--- a/secure_fw/services/secure_storage/flash/sst_flash.h
+++ b/secure_fw/services/secure_storage/flash/sst_flash.h
@@ -9,7 +9,7 @@
#define __SST_FLASH_H__
#include <stdint.h>
-#include "tfm_sst_defs.h"
+#include "psa_protected_storage.h"
#include "flash_layout.h"
#ifdef __cplusplus
@@ -50,10 +50,10 @@
/**
* \brief Initialize the Flash Interface.
*
- * \return Returns TFM_SST_ERR_SUCCESS if the function is executed correctly.
- * Otherwise, it returns TFM_SST_ERR_STORAGE_FAILURE.
+ * \return Returns PSA_PS_SUCCESS if the function is executed correctly.
+ * Otherwise, it returns PSA_PS_ERROR_STORAGE_FAILURE.
*/
-enum tfm_sst_err_t sst_flash_init(void);
+psa_ps_status_t sst_flash_init(void);
/**
* \brief Reads block data from the position specified by block ID and offset.
@@ -67,11 +67,11 @@
* the range of address, based on blockid + offset + size, are always
* valid in the memory.
*
- * \return Returns TFM_SST_ERR_SUCCESS if the function is executed correctly.
- * Otherwise, it returns TFM_SST_ERR_STORAGE_FAILURE.
+ * \return Returns PSA_PS_SUCCESS if the function is executed correctly.
+ * Otherwise, it returns PSA_PS_ERROR_STORAGE_FAILURE.
*/
-enum tfm_sst_err_t sst_flash_read(uint32_t block_id, uint8_t *buff,
- uint32_t offset, uint32_t size);
+psa_ps_status_t sst_flash_read(uint32_t block_id, uint8_t *buff,
+ uint32_t offset, uint32_t size);
/**
* \brief Writes block data to the position specified by block ID and offset.
@@ -85,11 +85,11 @@
* the range of address, based on blockid + offset + size, are always
* valid in the memory.
*
- * \return Returns TFM_SST_ERR_SUCCESS if the function is executed correctly.
- * Otherwise, it returns TFM_SST_ERR_STORAGE_FAILURE.
+ * \return Returns PSA_PS_SUCCESS if the function is executed correctly.
+ * Otherwise, it returns PSA_PS_ERROR_STORAGE_FAILURE.
*/
-enum tfm_sst_err_t sst_flash_write(uint32_t block_id, const uint8_t *buff,
- uint32_t offset, uint32_t size);
+psa_ps_status_t sst_flash_write(uint32_t block_id, const uint8_t *buff,
+ uint32_t offset, uint32_t size);
/**
* \brief Moves data from src block ID to destination block ID.
@@ -108,14 +108,14 @@
* It also considers that the destination block is already erased and
* ready to be written.
*
- * \return Returns TFM_SST_ERR_SUCCESS if the function is executed correctly.
- * Otherwise, it returns TFM_SST_ERR_STORAGE_FAILURE.
+ * \return Returns PSA_PS_SUCCESS if the function is executed correctly.
+ * Otherwise, it returns PSA_PS_ERROR_STORAGE_FAILURE.
*/
-enum tfm_sst_err_t sst_flash_block_to_block_move(uint32_t dst_block,
- uint32_t dst_offset,
- uint32_t src_block,
- uint32_t src_offset,
- uint32_t size);
+psa_ps_status_t sst_flash_block_to_block_move(uint32_t dst_block,
+ uint32_t dst_offset,
+ uint32_t src_block,
+ uint32_t src_offset,
+ uint32_t size);
/**
* \brief Erases block ID data.
@@ -124,10 +124,10 @@
*
* \note This function considers all input values valids.
*
- * \return Returns TFM_SST_ERR_SUCCESS if the function is executed correctly.
- * Otherwise, it returns TFM_SST_ERR_STORAGE_FAILURE.
+ * \return Returns PSA_PS_SUCCESS if the function is executed correctly.
+ * Otherwise, it returns PSA_PS_ERROR_STORAGE_FAILURE.
*/
-enum tfm_sst_err_t sst_flash_erase_block(uint32_t block_id);
+psa_ps_status_t sst_flash_erase_block(uint32_t block_id);
#ifdef __cplusplus
}
diff --git a/secure_fw/services/secure_storage/flash_fs/sst_flash_fs.c b/secure_fw/services/secure_storage/flash_fs/sst_flash_fs.c
index da8c27f..d1d65a3 100644
--- a/secure_fw/services/secure_storage/flash_fs/sst_flash_fs.c
+++ b/secure_fw/services/secure_storage/flash_fs/sst_flash_fs.c
@@ -17,24 +17,24 @@
#define SST_FLASH_FS_INIT_FILE 0
-static enum tfm_sst_err_t sst_flash_fs_file_write_aligned_data(
+static psa_ps_status_t sst_flash_fs_file_write_aligned_data(
const struct sst_file_meta_t *file_meta,
uint32_t offset,
uint32_t size,
const uint8_t *data)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t f_offset;
#if (SST_FLASH_PROGRAM_UNIT != 1)
/* Check if offset is aligned with SST_FLASH_PROGRAM_UNIT */
if (GET_ALIGNED_FLASH_BYTES(offset) != offset) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
+ return PSA_PS_ERROR_INVALID_ARGUMENT;
}
/* Check if size is aligned with SST_FLASH_PROGRAM_UNIT */
if (GET_ALIGNED_FLASH_BYTES(size) != size) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
+ return PSA_PS_ERROR_INVALID_ARGUMENT;
}
#endif /* (SST_FLASH_PROGRAM_UNIT != 1) */
@@ -46,65 +46,65 @@
return err;
}
-enum tfm_sst_err_t sst_flash_fs_prepare(void)
+psa_ps_status_t sst_flash_fs_prepare(void)
{
/* Initialize metadata block with the valid/active metablock */
return sst_flash_fs_mblock_init();
}
-enum tfm_sst_err_t sst_flash_fs_wipe_all(void)
+psa_ps_status_t sst_flash_fs_wipe_all(void)
{
/* Clean and initialize the metadata block */
return sst_flash_fs_mblock_reset_metablock();
}
-enum tfm_sst_err_t sst_flash_fs_file_exist(uint32_t fid)
+psa_ps_status_t sst_flash_fs_file_exist(uint32_t fid)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t idx;
err = sst_flash_fs_mblock_get_file_idx(fid, &idx);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_UID_NOT_FOUND;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_UID_NOT_FOUND;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_flash_fs_file_create(uint32_t fid,
- uint32_t max_size,
- uint32_t data_size,
- const uint8_t *data)
+psa_ps_status_t sst_flash_fs_file_create(uint32_t fid,
+ uint32_t max_size,
+ uint32_t data_size,
+ const uint8_t *data)
{
struct sst_block_meta_t block_meta;
uint32_t cur_phys_block;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t idx;
struct sst_file_meta_t file_meta;
/* Check if file already exists */
err = sst_flash_fs_mblock_get_file_idx(fid, &idx);
- if (err == TFM_SST_ERR_SUCCESS) {
+ if (err == PSA_PS_SUCCESS) {
/* If it exits return an error as needs to be removed first */
- return TFM_SST_ERR_INVALID_ARGUMENT;
+ return PSA_PS_ERROR_INVALID_ARGUMENT;
}
/* Check if max_size is aligned with SST_FLASH_PROGRAM_UNIT */
if (GET_ALIGNED_FLASH_BYTES(max_size) != max_size) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
+ return PSA_PS_ERROR_INVALID_ARGUMENT;
}
/* Try to reserve an file based on the input parameters */
err = sst_flash_fs_mblock_reserve_file(fid, max_size, &idx,
&file_meta, &block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
/* Check if data needs to be stored in the new file */
if (data_size != 0) {
if ((data_size > max_size) || (data == NULL)) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
+ return PSA_PS_ERROR_INVALID_ARGUMENT;
}
/* Write the content into scratch data block */
@@ -112,16 +112,16 @@
SST_FLASH_FS_INIT_FILE,
data_size,
data);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Add current size the file metadata */
file_meta.cur_size = data_size;
err = sst_flash_fs_dblock_cp_remaining_data(&block_meta, &file_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
cur_phys_block = block_meta.phy_id;
@@ -138,20 +138,20 @@
/* Update metadata block information */
err = sst_flash_fs_mblock_update_scratch_block_meta(file_meta.lblock,
&block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Add file metadata in the metadata block */
err = sst_flash_fs_mblock_update_scratch_file_meta(idx, &file_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Copy rest of the file metadata entries */
err = sst_flash_fs_mblock_cp_remaining_file_meta(idx);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* The file data in the logical block 0 is stored in same physical block
@@ -164,8 +164,8 @@
*/
if ((file_meta.lblock != SST_LOGICAL_DBLOCK0) || (data_size == 0)) {
err = sst_flash_fs_mblock_migrate_lb0_data_to_scratch();
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
}
@@ -175,69 +175,68 @@
return err;
}
-enum tfm_sst_err_t sst_flash_fs_file_get_info(uint32_t fid,
- struct sst_file_info_t *info)
+psa_ps_status_t sst_flash_fs_file_get_info(uint32_t fid,
+ struct sst_file_info_t *info)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t idx;
struct sst_file_meta_t tmp_metadata;
/* Get the meta data index */
err = sst_flash_fs_mblock_get_file_idx(fid, &idx);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_UID_NOT_FOUND;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_UID_NOT_FOUND;
}
/* Read file metadata */
err = sst_flash_fs_mblock_read_file_meta(idx, &tmp_metadata);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
/* Check if index is still referring to same file */
if (fid != tmp_metadata.id) {
- return TFM_SST_ERR_UID_NOT_FOUND;
+ return PSA_PS_ERROR_UID_NOT_FOUND;
}
info->size_max = tmp_metadata.max_size;
info->size_current = tmp_metadata.cur_size;
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_flash_fs_file_write(uint32_t fid, uint32_t size,
- uint32_t offset,
- const uint8_t *data)
+psa_ps_status_t sst_flash_fs_file_write(uint32_t fid, uint32_t size,
+ uint32_t offset, const uint8_t *data)
{
struct sst_block_meta_t block_meta;
uint32_t cur_phys_block;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t idx;
struct sst_file_meta_t file_meta;
/* Get the file index */
err = sst_flash_fs_mblock_get_file_idx(fid, &idx);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_UID_NOT_FOUND;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_UID_NOT_FOUND;
}
/* Read file metadata */
err = sst_flash_fs_mblock_read_file_meta(idx, &file_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_UID_NOT_FOUND;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_UID_NOT_FOUND;
}
/* Read block metadata */
err = sst_flash_fs_mblock_read_block_metadata(file_meta.lblock,
&block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Write the content into scratch data block */
err = sst_flash_fs_file_write_aligned_data(&file_meta, offset, size, data);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
if (size > file_meta.cur_size) {
@@ -246,8 +245,8 @@
}
err = sst_flash_fs_dblock_cp_remaining_data(&block_meta, &file_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
cur_phys_block = block_meta.phy_id;
@@ -262,20 +261,20 @@
/* Update block metadata in scratch metadata block */
err = sst_flash_fs_mblock_update_scratch_block_meta(file_meta.lblock,
&block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Update file metadata to reflect new attributes */
err = sst_flash_fs_mblock_update_scratch_file_meta(idx, &file_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Copy rest of the file metadata entries */
err = sst_flash_fs_mblock_cp_remaining_file_meta(idx);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* The file data in the logical block 0 is stored in same physical block
@@ -288,8 +287,8 @@
*/
if (file_meta.lblock != SST_LOGICAL_DBLOCK0) {
err = sst_flash_fs_mblock_migrate_lb0_data_to_scratch();
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
}
@@ -301,13 +300,13 @@
return err;
}
-enum tfm_sst_err_t sst_flash_fs_file_delete(uint32_t fid)
+psa_ps_status_t sst_flash_fs_file_delete(uint32_t fid)
{
uint32_t del_file_data_idx;
uint32_t del_file_lblock;
uint32_t del_file_idx;
uint32_t del_file_max_size;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t src_offset = SST_BLOCK_SIZE;
uint32_t nbr_bytes_to_move = 0;
uint32_t idx;
@@ -315,17 +314,17 @@
/* Get the file index */
err = sst_flash_fs_mblock_get_file_idx(fid, &del_file_idx);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_UID_NOT_FOUND;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_UID_NOT_FOUND;
}
err = sst_flash_fs_mblock_read_file_meta(del_file_idx, &file_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
- if (sst_utils_validate_fid(file_meta.id) != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_UID_NOT_FOUND;
+ if (sst_utils_validate_fid(file_meta.id) != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_UID_NOT_FOUND;
}
/* Save logical block, data_index and max_size to be used later on */
@@ -351,7 +350,7 @@
/* Read file meta for the given file index */
err = sst_flash_fs_mblock_read_file_meta(idx, &file_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -388,7 +387,7 @@
err = sst_flash_fs_dblock_compact_block(del_file_lblock, del_file_max_size,
src_offset, del_file_data_idx,
nbr_bytes_to_move);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -402,8 +401,8 @@
*/
if (del_file_lblock != SST_LOGICAL_DBLOCK0) {
err = sst_flash_fs_mblock_migrate_lb0_data_to_scratch();
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
}
@@ -415,41 +414,41 @@
return err;
}
-enum tfm_sst_err_t sst_flash_fs_file_read(uint32_t fid, uint32_t size,
- uint32_t offset, uint8_t *data)
+psa_ps_status_t sst_flash_fs_file_read(uint32_t fid, uint32_t size,
+ uint32_t offset, uint8_t *data)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t idx;
struct sst_file_meta_t tmp_metadata;
/* Get the file index */
err = sst_flash_fs_mblock_get_file_idx(fid, &idx);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_UID_NOT_FOUND;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_UID_NOT_FOUND;
}
/* Read file metadata */
err = sst_flash_fs_mblock_read_file_meta(idx, &tmp_metadata);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Check if index is still referring to same file */
if (fid != tmp_metadata.id) {
- return TFM_SST_ERR_UID_NOT_FOUND;
+ return PSA_PS_ERROR_UID_NOT_FOUND;
}
/* Boundary check the incoming request */
err = sst_utils_check_contained_in(tmp_metadata.cur_size, offset, size);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
/* Read the file from flash */
err = sst_flash_fs_dblock_read_file(&tmp_metadata, offset, size, data);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
diff --git a/secure_fw/services/secure_storage/flash_fs/sst_flash_fs.h b/secure_fw/services/secure_storage/flash_fs/sst_flash_fs.h
index c7e556d..8694b22b 100644
--- a/secure_fw/services/secure_storage/flash_fs/sst_flash_fs.h
+++ b/secure_fw/services/secure_storage/flash_fs/sst_flash_fs.h
@@ -17,7 +17,7 @@
*/
#include <stdint.h>
-#include "tfm_sst_defs.h"
+#include "psa_protected_storage.h"
/*!
* \struct sst_file_info_t
@@ -38,27 +38,27 @@
/**
* \brief Prepares the filesystem to accept operations on the files.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_prepare(void);
+psa_ps_status_t sst_flash_fs_prepare(void);
/**
* \brief Wipes all files from the filesystem.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_wipe_all(void);
+psa_ps_status_t sst_flash_fs_wipe_all(void);
/**
* \brief Checks if a file exists in the filesystem.
*
* \param[in] fid File ID
*
- * \return Returns TFM_SST_ERR_SUCCESS if the file exists. If file does not
- * exist, it returns TFM_SST_ERR_UID_NOT_FOUND. Otherwise, it returns
- * error code as specified in \ref tfm_sst_err_t.
+ * \return Returns PSA_PS_SUCCESS if the file exists. If file does not
+ * exist, it returns PSA_PS_ERROR_UID_NOT_FOUND. Otherwise, it returns
+ * error code as specified in \ref psa_ps_status_t.
*/
-enum tfm_sst_err_t sst_flash_fs_file_exist(uint32_t fid);
+psa_ps_status_t sst_flash_fs_file_exist(uint32_t fid);
/**
* \brief Creates a file in the filesystem.
@@ -71,14 +71,15 @@
* This parameter is set to NULL when the file is empty
* after the creation.
*
- * \return Returns TFM_SST_ERR_SUCCESS if the file has been created correctly.
- * If fid is in used, it returns TFM_SST_ERR_INVALID_ARGUMENT.
- * Otherwise, it returns error code as specified in \ref tfm_sst_err_t.
+ * \return Returns PSA_PS_SUCCESS if the file has been created correctly.
+ * If fid is in used, it returns PSA_PS_ERROR_INVALID_ARGUMENT.
+ * Otherwise, it returns error code as specified in
+ * \ref psa_ps_status_t.
*/
-enum tfm_sst_err_t sst_flash_fs_file_create(uint32_t fid,
- uint32_t max_size,
- uint32_t data_size,
- const uint8_t *data);
+psa_ps_status_t sst_flash_fs_file_create(uint32_t fid,
+ uint32_t max_size,
+ uint32_t data_size,
+ const uint8_t *data);
/**
* \brief Gets the file information referenced by the file ID.
@@ -87,10 +88,10 @@
* \param[out] info Pointer to the information structure to store the
* file information values \ref sst_file_info_t
*
- * \return Returns error code specified in \ref tfm_sst_err_t
+ * \return Returns error code specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_file_get_info(uint32_t fid,
- struct sst_file_info_t *info);
+psa_ps_status_t sst_flash_fs_file_get_info(uint32_t fid,
+ struct sst_file_info_t *info);
/**
* \brief Writes data to an existing file.
@@ -100,12 +101,12 @@
* \param[in] offset Offset in the file
* \param[in] data Pointer to buffer containing data to be written
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_file_write(uint32_t fid,
- uint32_t size,
- uint32_t offset,
- const uint8_t *data);
+psa_ps_status_t sst_flash_fs_file_write(uint32_t fid,
+ uint32_t size,
+ uint32_t offset,
+ const uint8_t *data);
/**
* \brief Reads data from an existing file.
@@ -115,21 +116,21 @@
* \param[in] offset Offset in the file
* \param[out] data Pointer to buffer to store the data
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_file_read(uint32_t fid,
- uint32_t size,
- uint32_t offset,
- uint8_t *data);
+psa_ps_status_t sst_flash_fs_file_read(uint32_t fid,
+ uint32_t size,
+ uint32_t offset,
+ uint8_t *data);
/**
* \brief Deletes file referenced by the file ID.
*
* \param[in] fid File ID
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_file_delete(uint32_t fid);
+psa_ps_status_t sst_flash_fs_file_delete(uint32_t fid);
#ifdef __cplusplus
}
diff --git a/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_dblock.c b/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_dblock.c
index 755d8c0..fa2e409 100644
--- a/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_dblock.c
+++ b/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_dblock.c
@@ -20,29 +20,29 @@
static uint32_t sst_dblock_lo_to_phy(uint32_t lblock)
{
struct sst_block_meta_t block_meta;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
err = sst_flash_fs_mblock_read_block_metadata(lblock, &block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return SST_BLOCK_INVALID_ID;
}
return block_meta.phy_id;
}
-enum tfm_sst_err_t sst_flash_fs_dblock_compact_block(uint32_t lblock,
- uint32_t free_size,
- uint32_t src_offset,
- uint32_t dst_offset,
- uint32_t size)
+psa_ps_status_t sst_flash_fs_dblock_compact_block(uint32_t lblock,
+ uint32_t free_size,
+ uint32_t src_offset,
+ uint32_t dst_offset,
+ uint32_t size)
{
struct sst_block_meta_t block_meta;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t scratch_id = 0;
/* Read current block meta */
err = sst_flash_fs_mblock_read_block_metadata(lblock, &block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -60,8 +60,8 @@
err = sst_flash_block_to_block_move(scratch_id, dst_offset,
block_meta.phy_id, src_offset,
size);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
}
@@ -74,8 +74,8 @@
block_meta.phy_id,
block_meta.data_start,
(dst_offset-block_meta.data_start));
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
}
@@ -90,7 +90,7 @@
/* Update block metadata in scratch metadata block */
err = sst_flash_fs_mblock_update_scratch_block_meta(lblock, &block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
/* Swap back the data block as there was an issue in the process */
sst_flash_fs_mblock_set_data_scratch(scratch_id, lblock);
return err;
@@ -99,9 +99,9 @@
return err;
}
-enum tfm_sst_err_t sst_flash_fs_dblock_cp_data_to_scratch(uint32_t lblock,
- uint32_t offset,
- uint32_t size)
+psa_ps_status_t sst_flash_fs_dblock_cp_data_to_scratch(uint32_t lblock,
+ uint32_t offset,
+ uint32_t size)
{
uint32_t phys_block;
uint32_t scratch_id;
@@ -109,7 +109,7 @@
/* Get physical block ID from where to read the data */
phys_block = sst_dblock_lo_to_phy(lblock);
if (phys_block == SST_BLOCK_INVALID_ID) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Get the scratch data block ID to write the data */
@@ -121,8 +121,7 @@
size);
}
-enum tfm_sst_err_t sst_flash_fs_dblock_read_file(
- struct sst_file_meta_t *file_meta,
+psa_ps_status_t sst_flash_fs_dblock_read_file(struct sst_file_meta_t *file_meta,
uint32_t offset,
uint32_t size,
uint8_t *buf)
@@ -132,7 +131,7 @@
phys_block = sst_dblock_lo_to_phy(file_meta->lblock);
if (phys_block == SST_BLOCK_INVALID_ID) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
pos = (file_meta->data_idx + offset);
@@ -140,10 +139,10 @@
return sst_flash_read(phys_block, buf, pos, size);
}
-enum tfm_sst_err_t sst_flash_fs_dblock_write_file(uint32_t lblock,
- uint32_t offset,
- uint32_t size,
- const uint8_t *data)
+psa_ps_status_t sst_flash_fs_dblock_write_file(uint32_t lblock,
+ uint32_t offset,
+ uint32_t size,
+ const uint8_t *data)
{
uint32_t scratch_id;
@@ -152,12 +151,12 @@
return sst_flash_write(scratch_id, data, offset, size);
}
-enum tfm_sst_err_t sst_flash_fs_dblock_cp_remaining_data(
+psa_ps_status_t sst_flash_fs_dblock_cp_remaining_data(
const struct sst_block_meta_t *block_meta,
const struct sst_file_meta_t *file_meta)
{
uint32_t after_file_offset;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t scratch_id;
uint32_t wrt_bytes;
@@ -172,7 +171,7 @@
block_meta->phy_id,
block_meta->data_start,
wrt_bytes);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
diff --git a/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_dblock.h b/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_dblock.h
index 5fb168b..05a682b 100644
--- a/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_dblock.h
+++ b/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_dblock.h
@@ -10,7 +10,7 @@
#include <stdint.h>
#include "sst_flash_fs_mblock.h"
-#include "tfm_sst_defs.h"
+#include "psa_protected_storage.h"
#ifdef __cplusplus
extern "C" {
@@ -27,13 +27,13 @@
* data position to store the data to be reallocated
* \param[in] size Number of bytes to be reallocated
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_dblock_compact_block(uint32_t lblock,
- uint32_t free_size,
- uint32_t src_offset,
- uint32_t dst_offset,
- uint32_t size);
+psa_ps_status_t sst_flash_fs_dblock_compact_block(uint32_t lblock,
+ uint32_t free_size,
+ uint32_t src_offset,
+ uint32_t dst_offset,
+ uint32_t size);
/**
* \brief Copies data from logical block to scratch data block.
@@ -44,11 +44,11 @@
* \param[in] size Number of bytes to be copied from logical block to
* scratch data block
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_dblock_cp_data_to_scratch(uint32_t lblock,
- uint32_t offset,
- uint32_t size);
+psa_ps_status_t sst_flash_fs_dblock_cp_data_to_scratch(uint32_t lblock,
+ uint32_t offset,
+ uint32_t size);
/**
* \brief Reads the file content.
@@ -58,10 +58,9 @@
* \param[in] size Size to be read
* \param[out] buf Buffer pointer to store the data
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_dblock_read_file(
- struct sst_file_meta_t *file_meta,
+psa_ps_status_t sst_flash_fs_dblock_read_file(struct sst_file_meta_t *file_meta,
uint32_t offset,
uint32_t size,
uint8_t *buf);
@@ -77,12 +76,12 @@
* \param[in] data Pointer to data buffer to copy in the scratch data
* block
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_dblock_write_file(uint32_t lblock,
- uint32_t offset,
- uint32_t size,
- const uint8_t *data);
+psa_ps_status_t sst_flash_fs_dblock_write_file(uint32_t lblock,
+ uint32_t offset,
+ uint32_t size,
+ const uint8_t *data);
/**
* \brief Writes logical block data, which is not related with the file
@@ -91,9 +90,9 @@
* \param[in] block_meta Pointer to block meta to process
* \param[in] file_meta Pointer to file's metadata manipulated
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_dblock_cp_remaining_data(
+psa_ps_status_t sst_flash_fs_dblock_cp_remaining_data(
const struct sst_block_meta_t *block_meta,
const struct sst_file_meta_t *file_meta);
#ifdef __cplusplus
diff --git a/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_mblock.c b/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_mblock.c
index 481528e..a845efe 100644
--- a/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_mblock.c
+++ b/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_mblock.c
@@ -274,42 +274,42 @@
*
* \param[in] file_meta Pointer to file meta structure
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
__attribute__((always_inline))
-__STATIC_INLINE enum tfm_sst_err_t sst_mblock_validate_file_meta(
+__STATIC_INLINE psa_ps_status_t sst_mblock_validate_file_meta(
const struct sst_file_meta_t *file_meta)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* Logical block ID can not be bigger or equal than number of
* active blocks.
*/
if (file_meta->lblock >= SST_NUM_ACTIVE_DBLOCKS) {
- return TFM_SST_ERR_DATA_CORRUPT;
+ return PSA_PS_ERROR_DATA_CORRUPT;
}
/* meta->id can be 0 if the file is not in use. If it is in
* use, check the metadata.
*/
- if (sst_utils_validate_fid(file_meta->id) == TFM_SST_ERR_SUCCESS) {
+ if (sst_utils_validate_fid(file_meta->id) == PSA_PS_SUCCESS) {
/* validate files values if file is in use */
if (file_meta->max_size > SST_MAX_OBJECT_SIZE) {
- return TFM_SST_ERR_DATA_CORRUPT;
+ return PSA_PS_ERROR_DATA_CORRUPT;
}
/* The current file data size must be smaller or equal than
* file data max size.
*/
if (file_meta->cur_size > file_meta->max_size) {
- return TFM_SST_ERR_DATA_CORRUPT;
+ return PSA_PS_ERROR_DATA_CORRUPT;
}
if (file_meta->lblock == SST_LOGICAL_DBLOCK0) {
/* In block 0, data index must be located after the metadata */
if (file_meta->data_idx <
sst_mblock_file_meta_offset(SST_MAX_NUM_OBJECTS)) {
- return TFM_SST_ERR_DATA_CORRUPT;
+ return PSA_PS_ERROR_DATA_CORRUPT;
}
}
@@ -317,12 +317,12 @@
err = sst_utils_check_contained_in(SST_BLOCK_SIZE,
file_meta->data_idx,
file_meta->max_size);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_DATA_CORRUPT;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_DATA_CORRUPT;
}
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
/**
@@ -332,18 +332,18 @@
*
* \param[in] block_meta Pointer to block meta structure
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
__attribute__((always_inline))
-__STATIC_INLINE enum tfm_sst_err_t sst_mblock_validate_block_meta(
+__STATIC_INLINE psa_ps_status_t sst_mblock_validate_block_meta(
const struct sst_block_meta_t *block_meta)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* Data block's data start at position 0 */
uint32_t valid_data_start_value = 0;
if (block_meta->phy_id >= SST_TOTAL_NUM_OF_BLOCKS) {
- return TFM_SST_ERR_DATA_CORRUPT;
+ return PSA_PS_ERROR_DATA_CORRUPT;
}
/* Boundary check: block data start + free size can not be bigger
@@ -352,8 +352,8 @@
err = sst_utils_check_contained_in(SST_BLOCK_SIZE,
block_meta->data_start,
block_meta->free_size);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_DATA_CORRUPT;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_DATA_CORRUPT;
}
if (block_meta->phy_id == SST_METADATA_BLOCK0 ||
@@ -367,10 +367,10 @@
}
if (block_meta->data_start != valid_data_start_value) {
- return TFM_SST_ERR_DATA_CORRUPT;
+ return PSA_PS_ERROR_DATA_CORRUPT;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
#endif
@@ -381,20 +381,20 @@
*/
static uint32_t sst_get_free_file_index(void)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t i;
struct sst_file_meta_t tmp_metadata;
for (i = 0; i < SST_MAX_NUM_OBJECTS; i++) {
err = sst_flash_fs_mblock_read_file_meta(i, &tmp_metadata);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return SST_METADATA_INVALID_INDEX;
}
/* Check if this entry is free by checking if ID values is an
* invalid ID.
*/
- if (sst_utils_validate_fid(tmp_metadata.id) != TFM_SST_ERR_SUCCESS) {
+ if (sst_utils_validate_fid(tmp_metadata.id) != PSA_PS_SUCCESS) {
/* Found */
return i;
}
@@ -409,12 +409,12 @@
* \param[in] idx File metadata entry index in the metadata table
* \param[in] file_meta Metadata pointer
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_mblock_update_scratch_file_meta(uint32_t idx,
+static psa_ps_status_t sst_mblock_update_scratch_file_meta(uint32_t idx,
struct sst_file_meta_t *file_meta)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t pos;
uint32_t scratch_block;
@@ -430,9 +430,9 @@
/**
* \brief Erases data and meta scratch blocks.
*/
-static enum tfm_sst_err_t sst_mblock_erase_scratch_blocks(void)
+static psa_ps_status_t sst_mblock_erase_scratch_blocks(void)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t scratch_datablock;
uint32_t scratch_metablock;
@@ -443,7 +443,7 @@
* metadata scratch block is erased before data block.
*/
err = sst_flash_erase_block(scratch_metablock);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -468,12 +468,12 @@
* \param[in] block_meta Pointer to the block metadata data to write in the
* scratch block
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_mblock_update_scratch_block_meta(uint32_t lblock,
+static psa_ps_status_t sst_mblock_update_scratch_block_meta(uint32_t lblock,
struct sst_block_meta_t *block_meta)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t meta_block;
uint32_t pos;
@@ -490,12 +490,12 @@
*
* \param[in] lblock Logical block number to skip
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_mblock_copy_remaining_block_meta(uint32_t lblock)
+static psa_ps_status_t sst_mblock_copy_remaining_block_meta(uint32_t lblock)
{
struct sst_block_meta_t block_meta;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t meta_block;
uint32_t pos;
uint32_t scratch_block;
@@ -515,8 +515,8 @@
*/
err = sst_flash_fs_mblock_read_block_metadata(SST_LOGICAL_DBLOCK0,
&block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Update physical ID for logical block 0 to match with the
@@ -525,8 +525,8 @@
block_meta.phy_id = scratch_block;
err = sst_mblock_update_scratch_block_meta(SST_LOGICAL_DBLOCK0,
&block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Copy the rest of metadata blocks between logical block 0 and
@@ -541,7 +541,7 @@
/* Data before updated content */
err = sst_flash_block_to_block_move(scratch_block, pos, meta_block,
pos, size);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
}
@@ -563,13 +563,13 @@
*
* \param[in] swap_count Swap count to validate
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
__attribute__((always_inline))
-__STATIC_INLINE enum tfm_sst_err_t sst_mblock_validate_swap_count(
+__STATIC_INLINE psa_ps_status_t sst_mblock_validate_swap_count(
uint8_t swap_count)
{
- enum tfm_sst_err_t err = TFM_SST_ERR_SUCCESS;
+ psa_ps_status_t err = PSA_PS_SUCCESS;
/* When a flash block is erased, the default value
* is usually 0xFF (i.e. all 1s). Since the swap count
@@ -584,7 +584,7 @@
* back to previous metablock instead.
*/
if (swap_count == SST_FLASH_DEFAULT_VAL) {
- err = TFM_SST_ERR_OPERATION_FAILED;
+ err = PSA_PS_ERROR_OPERATION_FAILED;
}
return err;
@@ -595,19 +595,19 @@
*
* \param[in] fs_version File system version.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
__attribute__((always_inline))
-__STATIC_INLINE enum tfm_sst_err_t sst_mblock_validate_fs_version(
+__STATIC_INLINE psa_ps_status_t sst_mblock_validate_fs_version(
uint8_t fs_version)
{
- enum tfm_sst_err_t err = TFM_SST_ERR_SUCCESS;
+ psa_ps_status_t err = PSA_PS_SUCCESS;
/* Looks for exact version number.
* FIXME: backward compatibility could be considered in future revisions.
*/
if (fs_version != SST_SUPPORTED_VERSION) {
- err = TFM_SST_ERR_OPERATION_FAILED;
+ err = PSA_PS_ERROR_OPERATION_FAILED;
}
return err;
@@ -620,15 +620,15 @@
*
* \param[in] h_meta Pointer to metadata block header
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_mblock_validate_header_meta(
+static psa_ps_status_t sst_mblock_validate_header_meta(
struct sst_metadata_block_header_t *h_meta)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
err = sst_mblock_validate_fs_version(h_meta->fs_version);
- if (err == TFM_SST_ERR_SUCCESS) {
+ if (err == PSA_PS_SUCCESS) {
err = sst_mblock_validate_swap_count(h_meta->active_swap_count);
}
@@ -638,11 +638,11 @@
/**
* \brief Writes the scratch metadata's header.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_mblock_write_scratch_meta_header(void)
+static psa_ps_status_t sst_mblock_write_scratch_meta_header(void)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t scratch_metablock;
scratch_metablock = sst_cur_meta_scratch_id();
@@ -652,7 +652,7 @@
err = sst_mblock_validate_swap_count(
sst_flash_fs_ctx.meta_block_header.active_swap_count);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
/* Reset the swap count to 0 */
sst_flash_fs_ctx.meta_block_header.active_swap_count = 0;
}
@@ -668,16 +668,16 @@
/**
* \brief Reads the active metadata block header into sst_system_ctx.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_mblock_read_meta_header(void)
+static psa_ps_status_t sst_mblock_read_meta_header(void)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
err = sst_flash_read(sst_flash_fs_ctx.active_metablock,
(uint8_t *)&sst_flash_fs_ctx.meta_block_header, 0,
SST_BLOCK_META_HEADER_SIZE);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -694,19 +694,19 @@
* \param[out] file_meta File metadata entry
* \param[out] block_meta Block metadata entry
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_mblock_reserve_file(uint32_t fid, uint32_t size,
+static psa_ps_status_t sst_mblock_reserve_file(uint32_t fid, uint32_t size,
struct sst_file_meta_t *file_meta,
struct sst_block_meta_t *block_meta)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t i;
for (i = 0; i < SST_NUM_ACTIVE_DBLOCKS; i++) {
err = sst_flash_fs_mblock_read_block_metadata(i, block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
if (block_meta->free_size >= size) {
@@ -719,23 +719,23 @@
/* Update block metadata */
block_meta->free_size -= size;
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
}
/* No block has large enough space to fit the requested file */
- return TFM_SST_ERR_INSUFFICIENT_SPACE;
+ return PSA_PS_ERROR_INSUFFICIENT_SPACE;
}
/**
* \brief Validates and find the valid-active metablock
*
- * \return Returns value as specified in \ref tfm_sst_err_t
+ * \return Returns value as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_init_get_active_metablock(void)
+static psa_ps_status_t sst_init_get_active_metablock(void)
{
uint32_t cur_meta_block;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
struct sst_metadata_block_header_t h_meta0;
struct sst_metadata_block_header_t h_meta1;
uint8_t num_valid_meta_blocks = 0;
@@ -745,13 +745,13 @@
/* Read the header of both the metdata blocks */
err = sst_flash_read(SST_METADATA_BLOCK0, (uint8_t *)&h_meta0,
0, SST_BLOCK_META_HEADER_SIZE);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
err = sst_flash_read(SST_METADATA_BLOCK1, (uint8_t *)&h_meta1,
0, SST_BLOCK_META_HEADER_SIZE);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -760,12 +760,12 @@
* update operation to complete. Need to find out the valid
* metadata block now.
*/
- if (sst_mblock_validate_header_meta(&h_meta0) == TFM_SST_ERR_SUCCESS) {
+ if (sst_mblock_validate_header_meta(&h_meta0) == PSA_PS_SUCCESS) {
num_valid_meta_blocks++;
cur_meta_block = SST_METADATA_BLOCK0;
}
- if (sst_mblock_validate_header_meta(&h_meta1) == TFM_SST_ERR_SUCCESS) {
+ if (sst_mblock_validate_header_meta(&h_meta1) == PSA_PS_SUCCESS) {
num_valid_meta_blocks++;
cur_meta_block = SST_METADATA_BLOCK1;
}
@@ -777,18 +777,18 @@
if (num_valid_meta_blocks > 1) {
cur_meta_block = sst_mblock_latest_meta_block(&h_meta0, &h_meta1);
} else if (num_valid_meta_blocks == 0) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
sst_flash_fs_ctx.active_metablock = cur_meta_block;
sst_flash_fs_ctx.scratch_metablock = SST_OTHER_META_BLOCK(cur_meta_block);
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_flash_fs_mblock_cp_remaining_file_meta(uint32_t idx)
+psa_ps_status_t sst_flash_fs_mblock_cp_remaining_file_meta(uint32_t idx)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t end;
uint32_t meta_block;
uint32_t pos;
@@ -802,7 +802,7 @@
/* Data before updated content */
err = sst_flash_block_to_block_move(scratch_block, pos, meta_block, pos,
(idx * SST_FILE_METADATA_SIZE));
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -831,47 +831,47 @@
return sst_flash_fs_ctx.meta_block_header.scratch_dblock;
}
-enum tfm_sst_err_t sst_flash_fs_mblock_get_file_idx(uint32_t fid, uint32_t *idx)
+psa_ps_status_t sst_flash_fs_mblock_get_file_idx(uint32_t fid, uint32_t *idx)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t i;
struct sst_file_meta_t tmp_metadata;
for (i = 0; i < SST_MAX_NUM_OBJECTS; i++) {
err = sst_flash_fs_mblock_read_file_meta(i, &tmp_metadata);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* ID with value 0x00 means end of file meta section */
if (tmp_metadata.id == fid) {
/* Found */
*idx = i;
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
}
- return TFM_SST_ERR_UID_NOT_FOUND;
+ return PSA_PS_ERROR_UID_NOT_FOUND;
}
-enum tfm_sst_err_t sst_flash_fs_mblock_init(void)
+psa_ps_status_t sst_flash_fs_mblock_init(void)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* Initialize Flash Interface */
err = sst_flash_init();
- if(err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
err = sst_init_get_active_metablock();
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
err = sst_mblock_read_meta_header();
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Erase the other scratch metadata block */
@@ -880,13 +880,13 @@
return err;
}
-enum tfm_sst_err_t sst_flash_fs_mblock_meta_update_finalize(void)
+psa_ps_status_t sst_flash_fs_mblock_meta_update_finalize(void)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* Write the metadata block header to flash */
err = sst_mblock_write_scratch_meta_header();
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -899,12 +899,12 @@
return err;
}
-enum tfm_sst_err_t sst_flash_fs_mblock_migrate_lb0_data_to_scratch(void)
+psa_ps_status_t sst_flash_fs_mblock_migrate_lb0_data_to_scratch(void)
{
struct sst_block_meta_t block_meta;
uint32_t current_metablock;
uint32_t data_size;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t scratch_metablock;
scratch_metablock = sst_cur_meta_scratch_id();
@@ -912,7 +912,7 @@
err = sst_flash_fs_mblock_read_block_metadata(SST_LOGICAL_DBLOCK0,
&block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -927,10 +927,10 @@
return err;
}
-enum tfm_sst_err_t sst_flash_fs_mblock_read_file_meta(uint32_t idx,
+psa_ps_status_t sst_flash_fs_mblock_read_file_meta(uint32_t idx,
struct sst_file_meta_t *file_meta)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t offset;
offset = sst_mblock_file_meta_offset(idx);
@@ -939,7 +939,7 @@
SST_FILE_METADATA_SIZE);
#ifdef SST_VALIDATE_METADATA_FROM_FLASH
- if (err == TFM_SST_ERR_SUCCESS) {
+ if (err == PSA_PS_SUCCESS) {
err = sst_mblock_validate_file_meta(file_meta);
}
#endif
@@ -947,10 +947,10 @@
return err;
}
-enum tfm_sst_err_t sst_flash_fs_mblock_read_block_metadata(uint32_t lblock,
+psa_ps_status_t sst_flash_fs_mblock_read_block_metadata(uint32_t lblock,
struct sst_block_meta_t *block_meta)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t metablock;
uint32_t pos;
@@ -960,7 +960,7 @@
pos, SST_BLOCK_METADATA_SIZE);
#ifdef SST_VALIDATE_METADATA_FROM_FLASH
- if (err == TFM_SST_ERR_SUCCESS) {
+ if (err == PSA_PS_SUCCESS) {
err = sst_mblock_validate_block_meta(block_meta);
}
#endif
@@ -968,28 +968,28 @@
return err;
}
-enum tfm_sst_err_t sst_flash_fs_mblock_reserve_file(uint32_t fid, uint32_t size,
+psa_ps_status_t sst_flash_fs_mblock_reserve_file(uint32_t fid, uint32_t size,
uint32_t *idx,
struct sst_file_meta_t *file_meta,
struct sst_block_meta_t *block_meta)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
err = sst_mblock_reserve_file(fid, size, file_meta, block_meta);
*idx = sst_get_free_file_index();
- if ((err != TFM_SST_ERR_SUCCESS) ||
+ if ((err != PSA_PS_SUCCESS) ||
(*idx == SST_METADATA_INVALID_INDEX)) {
- return TFM_SST_ERR_INSUFFICIENT_SPACE;
+ return PSA_PS_ERROR_INSUFFICIENT_SPACE;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_flash_fs_mblock_reset_metablock(void)
+psa_ps_status_t sst_flash_fs_mblock_reset_metablock(void)
{
struct sst_block_meta_t block_meta;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t i;
uint32_t metablock_to_erase_first = SST_METADATA_BLOCK0;
struct sst_file_meta_t file_metadata;
@@ -998,17 +998,17 @@
* ensure that the active metadata block is erased last to prevent rollback
* in the case of a power failure between the two erases.
*/
- if (sst_init_get_active_metablock() == TFM_SST_ERR_SUCCESS) {
+ if (sst_init_get_active_metablock() == PSA_PS_SUCCESS) {
metablock_to_erase_first = sst_flash_fs_ctx.scratch_metablock;
}
err = sst_flash_erase_block(metablock_to_erase_first);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
err = sst_flash_erase_block(SST_OTHER_META_BLOCK(metablock_to_erase_first));
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -1044,15 +1044,15 @@
/* If an error is detected while erasing the flash, then return a
* system error to abort core wipe process.
*/
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_STORAGE_FAILURE;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_STORAGE_FAILURE;
}
for (i = 0; i < SST_NUM_DEDICATED_DBLOCKS; i++) {
block_meta.phy_id = i + SST_INIT_DBLOCK_START;
err = sst_mblock_update_scratch_block_meta(i + 1, &block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
}
@@ -1063,20 +1063,20 @@
/* In the beginning phys id is same as logical id */
/* Update file metadata to reflect new attributes */
err = sst_mblock_update_scratch_file_meta(i, &file_metadata);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
}
err = sst_mblock_write_scratch_meta_header();
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Swap active and scratch metablocks */
sst_mblock_swap_metablocks();
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
void sst_flash_fs_mblock_set_data_scratch(uint32_t phy_id, uint32_t lblock)
@@ -1086,11 +1086,11 @@
}
}
-enum tfm_sst_err_t sst_flash_fs_mblock_update_scratch_block_meta(
+psa_ps_status_t sst_flash_fs_mblock_update_scratch_block_meta(
uint32_t lblock,
struct sst_block_meta_t *block_meta)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* If the file is the logical block 0, then update the physical ID to the
* current scratch metadata block so that it is correct after the metadata
@@ -1101,8 +1101,8 @@
}
err = sst_mblock_update_scratch_block_meta(lblock, block_meta);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
err = sst_mblock_copy_remaining_block_meta(lblock);
@@ -1110,7 +1110,7 @@
return err;
}
-enum tfm_sst_err_t sst_flash_fs_mblock_update_scratch_file_meta(uint32_t idx,
+psa_ps_status_t sst_flash_fs_mblock_update_scratch_file_meta(uint32_t idx,
struct sst_file_meta_t *file_meta)
{
return sst_mblock_update_scratch_file_meta(idx, file_meta);
diff --git a/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_mblock.h b/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_mblock.h
index ce7795a..617e8ac 100644
--- a/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_mblock.h
+++ b/secure_fw/services/secure_storage/flash_fs/sst_flash_fs_mblock.h
@@ -12,7 +12,7 @@
#include "secure_fw/services/secure_storage/flash/sst_flash.h"
#include "secure_fw/services/secure_storage/sst_object_defs.h"
-#include "tfm_sst_defs.h"
+#include "psa_protected_storage.h"
/*!
* \def SST_SUPPORTED_VERSION
@@ -75,9 +75,9 @@
/**
* \brief Initializes metadata block with the valid/active metablock.
*
- * \return Returns value as specified in \ref tfm_sst_err_t
+ * \return Returns value as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_mblock_init(void);
+psa_ps_status_t sst_flash_fs_mblock_init(void);
/**
* \brief Copies rest of the file metadata, except for the one pointed by
@@ -85,9 +85,9 @@
*
* \param[in] idx File metadata entry index to skip
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_mblock_cp_remaining_file_meta(uint32_t idx);
+psa_ps_status_t sst_flash_fs_mblock_cp_remaining_file_meta(uint32_t idx);
/**
* \brief Gets current scratch datablock physical ID.
@@ -104,10 +104,9 @@
* \param[in] fid ID of the file
* \param[out] idx Index of the file metadata in the file system
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_mblock_get_file_idx(uint32_t fid,
- uint32_t *idx);
+psa_ps_status_t sst_flash_fs_mblock_get_file_idx(uint32_t fid, uint32_t *idx);
/**
* \brief Finalizes an update operation.
@@ -115,7 +114,7 @@
*
* \return Returns offset value in metadata block
*/
-enum tfm_sst_err_t sst_flash_fs_mblock_meta_update_finalize(void);
+psa_ps_status_t sst_flash_fs_mblock_meta_update_finalize(void);
/**
* \brief Writes the files data area of logical block 0 into the scratch
@@ -127,9 +126,9 @@
* medadata block needs to be copied in the scratch block, unless
* the data of the file processed is located in the logical block 0.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_mblock_migrate_lb0_data_to_scratch(void);
+psa_ps_status_t sst_flash_fs_mblock_migrate_lb0_data_to_scratch(void);
/**
* \brief Reads specified file metadata.
@@ -137,9 +136,9 @@
* \param[in] idx File metadata entry index
* \param[out] file_meta Pointer to file meta structure
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_mblock_read_file_meta(uint32_t idx,
+psa_ps_status_t sst_flash_fs_mblock_read_file_meta(uint32_t idx,
struct sst_file_meta_t *file_meta);
/**
@@ -148,9 +147,9 @@
* \param[in] lblock Logical block number
* \param[out] block_meta Pointer to block meta structure
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_mblock_read_block_metadata(uint32_t lblock,
+psa_ps_status_t sst_flash_fs_mblock_read_block_metadata(uint32_t lblock,
struct sst_block_meta_t *block_meta);
/**
@@ -162,9 +161,9 @@
* \param[out] file_meta File metadata entry
* \param[out] block_meta Block metadata entry
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_mblock_reserve_file(uint32_t file_id,
+psa_ps_status_t sst_flash_fs_mblock_reserve_file(uint32_t file_id,
uint32_t size,
uint32_t *file_meta_idx,
struct sst_file_meta_t *file_meta,
@@ -173,9 +172,9 @@
/**
* \brief Resets metablock by cleaning and initializing the metadatablock.
*
- * \return Returns value as specified in \ref tfm_sst_err_t
+ * \return Returns value as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_mblock_reset_metablock(void);
+psa_ps_status_t sst_flash_fs_mblock_reset_metablock(void);
/**
* \brief Sets current data scratch block
@@ -191,9 +190,9 @@
* \param[in] lblock Logical block number
* \param[in] block_meta Pointer to block's metadata
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_mblock_update_scratch_block_meta(
+psa_ps_status_t sst_flash_fs_mblock_update_scratch_block_meta(
uint32_t lblock,
struct sst_block_meta_t *block_meta);
@@ -203,9 +202,9 @@
* \param[in] idx File's index in the metadata table
* \param[in] file_meta Metadata pointer
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_flash_fs_mblock_update_scratch_file_meta(uint32_t idx,
+psa_ps_status_t sst_flash_fs_mblock_update_scratch_file_meta(uint32_t idx,
struct sst_file_meta_t *file_meta);
#ifdef __cplusplus
diff --git a/secure_fw/services/secure_storage/nv_counters/sst_nv_counters.c b/secure_fw/services/secure_storage/nv_counters/sst_nv_counters.c
index efd43a8..df97c03 100644
--- a/secure_fw/services/secure_storage/nv_counters/sst_nv_counters.c
+++ b/secure_fw/services/secure_storage/nv_counters/sst_nv_counters.c
@@ -7,19 +7,19 @@
#include "sst_nv_counters.h"
-enum tfm_sst_err_t sst_init_nv_counter(void)
+psa_ps_status_t sst_init_nv_counter(void)
{
enum tfm_plat_err_t err;
err = tfm_plat_init_nv_counter();
if (err != TFM_PLAT_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
+psa_ps_status_t sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
uint32_t *val)
{
enum tfm_plat_err_t err;
@@ -27,13 +27,13 @@
err = tfm_plat_read_nv_counter(counter_id, SST_NV_COUNTER_SIZE,
(uint8_t *)val);
if (err != TFM_PLAT_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_increment_nv_counter(enum tfm_nv_counter_t counter_id)
+psa_ps_status_t sst_increment_nv_counter(enum tfm_nv_counter_t counter_id)
{
enum tfm_plat_err_t err;
@@ -45,8 +45,8 @@
*/
err = tfm_plat_increment_nv_counter(counter_id);
if (err != TFM_PLAT_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
diff --git a/secure_fw/services/secure_storage/nv_counters/sst_nv_counters.h b/secure_fw/services/secure_storage/nv_counters/sst_nv_counters.h
index d4cd685..d7bd31a 100644
--- a/secure_fw/services/secure_storage/nv_counters/sst_nv_counters.h
+++ b/secure_fw/services/secure_storage/nv_counters/sst_nv_counters.h
@@ -17,7 +17,7 @@
*/
#include <stdint.h>
-#include "tfm_sst_defs.h"
+#include "psa_protected_storage.h"
#include "platform/include/tfm_plat_nv_counters.h"
#define SST_NV_COUNTER_SIZE 4 /* In bytes */
@@ -29,10 +29,10 @@
/**
* \brief Initializes all non-volatile (NV) counters.
*
- * \return TFM_SST_ERR_SUCCESS if the initialization succeeds, otherwise
- * TFM_SST_ERR_OPERATION_FAILED
+ * \return PSA_PS_SUCCESS if the initialization succeeds, otherwise
+ * PSA_PS_ERROR_OPERATION_FAILED
*/
-enum tfm_sst_err_t sst_init_nv_counter(void);
+psa_ps_status_t sst_init_nv_counter(void);
/**
* \brief Reads the given non-volatile (NV) counter.
@@ -40,11 +40,11 @@
* \param[in] counter_id NV counter ID.
* \param[out] val Pointer to store the current NV counter value.
*
- * \return TFM_SST_ERR_SUCCESS if the value is read correctly, otherwise
- * TFM_SST_ERR_OPERATION_FAILED
+ * \return PSA_PS_SUCCESS if the value is read correctly, otherwise
+ * PSA_PS_ERROR_OPERATION_FAILED
*/
-enum tfm_sst_err_t sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
- uint32_t *val);
+psa_ps_status_t sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
+ uint32_t *val);
/**
* \brief Increments the given non-volatile (NV) counter.
@@ -52,9 +52,9 @@
* \param[in] counter_id NV counter ID.
*
* \return If the counter is incremented correctly, it returns
- * TFM_SST_ERR_SUCCESS. Otherwise, TFM_SST_ERR_OPERATION_FAILED.
+ * PSA_PS_SUCCESS. Otherwise, PSA_PS_ERROR_OPERATION_FAILED.
*/
-enum tfm_sst_err_t sst_increment_nv_counter(enum tfm_nv_counter_t counter_id);
+psa_ps_status_t sst_increment_nv_counter(enum tfm_nv_counter_t counter_id);
#ifdef __cplusplus
}
diff --git a/secure_fw/services/secure_storage/sst_encrypted_object.c b/secure_fw/services/secure_storage/sst_encrypted_object.c
index 1c0eec1..d2467ff 100644
--- a/secure_fw/services/secure_storage/sst_encrypted_object.c
+++ b/secure_fw/services/secure_storage/sst_encrypted_object.c
@@ -31,18 +31,18 @@
* \brief Gets the encryption key and sets it as the key to be used for
* cryptographic operations.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_object_set_encryption_key(void)
+static psa_ps_status_t sst_object_set_encryption_key(void)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* Key used for authenticated encryption and decryption */
static uint8_t sst_encryption_key[SST_KEY_LEN_BYTES];
/* Get the encryption key */
err = sst_crypto_getkey(sst_encryption_key, SST_KEY_LEN_BYTES);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -63,17 +63,17 @@
* is the one stored in the object table for the given
* File ID.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_object_auth_decrypt(uint32_t fid,
- uint32_t cur_size,
- struct sst_object_t *obj)
+static psa_ps_status_t sst_object_auth_decrypt(uint32_t fid,
+ uint32_t cur_size,
+ struct sst_object_t *obj)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint8_t *p_obj_data = (uint8_t *)&obj->header.info;
err = sst_object_set_encryption_key();
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -88,7 +88,7 @@
p_obj_data,
sst_crypto_buf,
cur_size);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -98,7 +98,7 @@
sst_utils_memset(sst_crypto_buf, SST_CRYPTO_CLEAR_BUF_VALUE,
sizeof(sst_crypto_buf));
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
/**
@@ -110,17 +110,17 @@
* \param[out] obj Pointer to the object structure to authenticate and
* fill in with the encrypted data.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_object_auth_encrypt(uint32_t fid,
- uint32_t cur_size,
- struct sst_object_t *obj)
+static psa_ps_status_t sst_object_auth_encrypt(uint32_t fid,
+ uint32_t cur_size,
+ struct sst_object_t *obj)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint8_t *p_obj_data = (uint8_t *)&obj->header.info;
err = sst_object_set_encryption_key();
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -139,25 +139,25 @@
p_obj_data,
sst_crypto_buf,
cur_size);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
sst_utils_memcpy(p_obj_data, sst_crypto_buf, cur_size);
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_encrypted_object_read(uint32_t fid,
- struct sst_object_t *obj)
+psa_ps_status_t sst_encrypted_object_read(uint32_t fid,
+ struct sst_object_t *obj)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
struct sst_file_info_t file_info;
uint32_t decrypt_size;
/* Get the current size of the encrypted object */
err = sst_flash_fs_file_get_info(fid, &file_info);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -165,7 +165,7 @@
err = sst_flash_fs_file_read(fid, file_info.size_current,
SST_OBJECT_START_POSITION,
obj->header.crypto.ref.iv);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -175,17 +175,17 @@
/* Decrypt the object data */
err = sst_object_auth_decrypt(fid, decrypt_size, obj);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_encrypted_object_write(uint32_t fid,
- struct sst_object_t *obj)
+psa_ps_status_t sst_encrypted_object_write(uint32_t fid,
+ struct sst_object_t *obj)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t wrt_size;
wrt_size = SST_ENCRYPT_SIZE(obj->header.info.max_size) +
@@ -195,7 +195,7 @@
/* Create an object in the object system */
err = sst_flash_fs_file_create(fid, wrt_size, SST_EMPTY_OBJECT_SIZE, NULL);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -204,7 +204,7 @@
/* Authenticate and encrypt the object */
err = sst_object_auth_encrypt(fid, wrt_size, obj);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
diff --git a/secure_fw/services/secure_storage/sst_encrypted_object.h b/secure_fw/services/secure_storage/sst_encrypted_object.h
index c3292d5..cd757e1 100644
--- a/secure_fw/services/secure_storage/sst_encrypted_object.h
+++ b/secure_fw/services/secure_storage/sst_encrypted_object.h
@@ -10,7 +10,7 @@
#include <stdint.h>
#include "sst_object_defs.h"
-#include "tfm_sst_defs.h"
+#include "psa_protected_storage.h"
#ifdef __cplusplus
extern "C" {
@@ -22,10 +22,10 @@
* \param[in] fid File ID
* \param[out] obj Pointer to the object structure to fill in
*
- * \return Returns error code specified in \ref tfm_sst_err_t
+ * \return Returns error code specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_encrypted_object_read(uint32_t fid,
- struct sst_object_t *obj);
+psa_ps_status_t sst_encrypted_object_read(uint32_t fid,
+ struct sst_object_t *obj);
/**
* \brief Creates and writes a new encrypted object based on the given
@@ -39,10 +39,10 @@
* internal copies. So, this object will contain the encrypted object
* stored in the flash.
*
- * \return Returns error code specified in \ref tfm_sst_err_t
+ * \return Returns error code specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_encrypted_object_write(uint32_t fid,
- struct sst_object_t *obj);
+psa_ps_status_t sst_encrypted_object_write(uint32_t fid,
+ struct sst_object_t *obj);
#ifdef __cplusplus
}
diff --git a/secure_fw/services/secure_storage/sst_object_system.c b/secure_fw/services/secure_storage/sst_object_system.c
index 30de9a1..99e2713 100644
--- a/secure_fw/services/secure_storage/sst_object_system.c
+++ b/secure_fw/services/secure_storage/sst_object_system.c
@@ -39,7 +39,6 @@
* \param[in] size Object size
* \param[out] obj Object to initialize
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
*/
__attribute__ ((always_inline))
__STATIC_INLINE void sst_init_empty_object(psa_ps_create_flags_t create_flags,
@@ -64,15 +63,15 @@
*
* \param[in] old_fid Old file ID to remove.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_remove_old_data(uint32_t old_fid)
+static psa_ps_status_t sst_remove_old_data(uint32_t old_fid)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* Delete old object table from the persistent area */
err = sst_object_table_delete_old_table();
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -94,17 +93,17 @@
*
* \param[in] type Read type as specified in \ref read_type_t
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_read_object(enum read_type_t type)
+static psa_ps_status_t sst_read_object(enum read_type_t type)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* Read object header */
err = sst_flash_fs_file_read(g_obj_tbl_info.fid, SST_OBJECT_HEADER_SIZE,
SST_OBJECT_START_POSITION,
(uint8_t *)&g_sst_object.header);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -113,7 +112,7 @@
*/
if (g_sst_object.header.fid != g_obj_tbl_info.fid ||
g_sst_object.header.version != g_obj_tbl_info.version) {
- err = TFM_SST_ERR_DATA_CORRUPT;
+ err = PSA_PS_ERROR_DATA_CORRUPT;
}
if (type == READ_ALL_OBJECT) {
@@ -123,7 +122,7 @@
g_sst_object.header.info.current_size,
SST_OBJECT_HEADER_SIZE,
g_sst_object.data);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
}
@@ -138,11 +137,11 @@
*
* \param[in] wrt_size Number of bytes to write
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_write_object(uint32_t wrt_size)
+static psa_ps_status_t sst_write_object(uint32_t wrt_size)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t max_size = SST_OBJECT_SIZE(g_sst_object.header.info.max_size);
/* Add object identification and increase object version */
@@ -161,14 +160,14 @@
#endif /* !SST_ENCRYPTION */
-enum tfm_sst_err_t sst_system_prepare(void)
+psa_ps_status_t sst_system_prepare(void)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
sst_global_lock();
err = sst_flash_fs_prepare();
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -178,7 +177,7 @@
* be used for the first time in the object system.
*/
err = sst_object_table_init(g_sst_object.data);
- if (err == TFM_SST_ERR_SUCCESS) {
+ if (err == PSA_PS_SUCCESS) {
sst_system_ready = SST_SYSTEM_READY;
}
@@ -192,11 +191,10 @@
return err;
}
-enum tfm_sst_err_t sst_object_read(psa_ps_uid_t uid, int32_t client_id,
- uint32_t offset, uint32_t size,
- uint8_t *data)
+psa_ps_status_t sst_object_read(psa_ps_uid_t uid, int32_t client_id,
+ uint32_t offset, uint32_t size, uint8_t *data)
{
- enum tfm_sst_err_t err = TFM_SST_ERR_OPERATION_FAILED;
+ psa_ps_status_t err = PSA_PS_ERROR_OPERATION_FAILED;
if (sst_system_ready == SST_SYSTEM_READY) {
sst_global_lock();
@@ -206,7 +204,7 @@
*/
err = sst_object_table_get_obj_tbl_info(uid, client_id,
&g_obj_tbl_info);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -217,7 +215,7 @@
/* Read object header */
err = sst_read_object(READ_ALL_OBJECT);
#endif
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -225,7 +223,7 @@
err = sst_utils_check_contained_in(
g_sst_object.header.info.current_size,
offset, size);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -243,11 +241,11 @@
return err;
}
-enum tfm_sst_err_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
- psa_ps_create_flags_t create_flags,
- uint32_t size, const uint8_t *data)
+psa_ps_status_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
+ psa_ps_create_flags_t create_flags,
+ uint32_t size, const uint8_t *data)
{
- enum tfm_sst_err_t err = TFM_SST_ERR_OPERATION_FAILED;
+ psa_ps_status_t err = PSA_PS_ERROR_OPERATION_FAILED;
uint32_t old_fid = SST_INVALID_FID;
#ifndef SST_ENCRYPTION
@@ -259,7 +257,7 @@
/* Boundary check the incoming request */
if (size > SST_MAX_ASSET_SIZE) {
- err = TFM_SST_ERR_INVALID_ARGUMENT;
+ err = PSA_PS_ERROR_INVALID_ARGUMENT;
goto release_sst_lock_and_return;
}
@@ -268,7 +266,7 @@
*/
err = sst_object_table_get_obj_tbl_info(uid, client_id,
&g_obj_tbl_info);
- if (err == TFM_SST_ERR_SUCCESS) {
+ if (err == PSA_PS_SUCCESS) {
#ifdef SST_ENCRYPTION
/* Read the object */
err = sst_encrypted_object_read(g_obj_tbl_info.fid, &g_sst_object);
@@ -276,7 +274,7 @@
/* Read the object header */
err = sst_read_object(READ_HEADER_ONLY);
#endif
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -285,7 +283,7 @@
*/
if (g_sst_object.header.info.create_flags
& PSA_PS_FLAG_WRITE_ONCE) {
- err = TFM_SST_ERR_WRITE_ONCE;
+ err = PSA_PS_ERROR_WRITE_ONCE;
goto release_sst_lock_and_return;
}
@@ -295,7 +293,7 @@
/* Save old file ID */
old_fid = g_obj_tbl_info.fid;
- } else if (err == TFM_SST_ERR_UID_NOT_FOUND) {
+ } else if (err == PSA_PS_ERROR_UID_NOT_FOUND) {
/* If the object does not exist, then initialize it based on the
* input arguments and empty content.
*/
@@ -312,7 +310,7 @@
/* Get new file ID */
err = sst_object_table_get_free_fid(&g_obj_tbl_info.fid);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -324,7 +322,7 @@
/* Write g_sst_object */
err = sst_write_object(wrt_size);
#endif
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -333,7 +331,7 @@
*/
err = sst_object_table_set_obj_tbl_info(uid, client_id,
&g_obj_tbl_info);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
/* Remove new object as object table is not persistent
* and propagate object table manipulation error.
*/
@@ -361,11 +359,11 @@
return err;
}
-enum tfm_sst_err_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
- uint32_t offset, uint32_t size,
- const uint8_t *data)
+psa_ps_status_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
+ uint32_t offset, uint32_t size,
+ const uint8_t *data)
{
- enum tfm_sst_err_t err = TFM_SST_ERR_OPERATION_FAILED;
+ psa_ps_status_t err = PSA_PS_ERROR_OPERATION_FAILED;
uint32_t old_fid;
#ifndef SST_ENCRYPTION
@@ -380,7 +378,7 @@
*/
err = sst_object_table_get_obj_tbl_info(uid, client_id,
&g_obj_tbl_info);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -390,7 +388,7 @@
#else
err = sst_read_object(READ_ALL_OBJECT);
#endif
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -398,7 +396,7 @@
* modified.
*/
if (g_sst_object.header.info.create_flags & PSA_PS_FLAG_WRITE_ONCE) {
- err = TFM_SST_ERR_WRITE_ONCE;
+ err = PSA_PS_ERROR_WRITE_ONCE;
goto release_sst_lock_and_return;
}
@@ -406,14 +404,14 @@
* prevent gaps being created in the object data.
*/
if (offset > g_sst_object.header.info.current_size) {
- err = TFM_SST_ERR_OFFSET_INVALID;
+ err = PSA_PS_ERROR_OFFSET_INVALID;
goto release_sst_lock_and_return;
}
/* Boundary check the incoming request */
err = sst_utils_check_contained_in(g_sst_object.header.info.max_size,
offset, size);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -430,7 +428,7 @@
/* Get new file ID */
err = sst_object_table_get_free_fid(&g_obj_tbl_info.fid);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -442,7 +440,7 @@
/* Write g_sst_object */
err = sst_write_object(wrt_size);
#endif
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -451,7 +449,7 @@
*/
err = sst_object_table_set_obj_tbl_info(uid, client_id,
&g_obj_tbl_info);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
/* Remove new object as object table is not persistent
* and propagate object table manipulation error.
*/
@@ -474,10 +472,10 @@
return err;
}
-enum tfm_sst_err_t sst_object_get_info(psa_ps_uid_t uid, int32_t client_id,
- struct psa_ps_info_t *info)
+psa_ps_status_t sst_object_get_info(psa_ps_uid_t uid, int32_t client_id,
+ struct psa_ps_info_t *info)
{
- enum tfm_sst_err_t err = TFM_SST_ERR_OPERATION_FAILED;
+ psa_ps_status_t err = PSA_PS_ERROR_OPERATION_FAILED;
if (sst_system_ready == SST_SYSTEM_READY) {
sst_global_lock();
@@ -487,7 +485,7 @@
*/
err = sst_object_table_get_obj_tbl_info(uid, client_id,
&g_obj_tbl_info);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -496,7 +494,7 @@
#else
err = sst_read_object(READ_HEADER_ONLY);
#endif
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -515,9 +513,9 @@
return err;
}
-enum tfm_sst_err_t sst_object_delete(psa_ps_uid_t uid, int32_t client_id)
+psa_ps_status_t sst_object_delete(psa_ps_uid_t uid, int32_t client_id)
{
- enum tfm_sst_err_t err = TFM_SST_ERR_OPERATION_FAILED;
+ psa_ps_status_t err = PSA_PS_ERROR_OPERATION_FAILED;
if (sst_system_ready == SST_SYSTEM_READY) {
sst_global_lock();
@@ -527,7 +525,7 @@
*/
err = sst_object_table_get_obj_tbl_info(uid, client_id,
&g_obj_tbl_info);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -536,13 +534,13 @@
#else
err = sst_read_object(READ_HEADER_ONLY);
#endif
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
/* Check that the write once flag is not set */
if (g_sst_object.header.info.create_flags & PSA_PS_FLAG_WRITE_ONCE) {
- err = TFM_SST_ERR_WRITE_ONCE;
+ err = PSA_PS_ERROR_WRITE_ONCE;
goto release_sst_lock_and_return;
}
@@ -550,7 +548,7 @@
* area.
*/
err = sst_object_table_delete_object(uid, client_id);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
goto release_sst_lock_and_return;
}
@@ -568,9 +566,9 @@
return err;
}
-enum tfm_sst_err_t sst_system_wipe_all(void)
+psa_ps_status_t sst_system_wipe_all(void)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* This function may get called as a corrective action
* if a system level security violation is detected.
@@ -580,12 +578,12 @@
* moves to erasing the flash instead.
*/
err = sst_flash_fs_wipe_all();
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
err = sst_flash_fs_prepare();
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
diff --git a/secure_fw/services/secure_storage/sst_object_system.h b/secure_fw/services/secure_storage/sst_object_system.h
index ce16147..46bcfca 100644
--- a/secure_fw/services/secure_storage/sst_object_system.h
+++ b/secure_fw/services/secure_storage/sst_object_system.h
@@ -11,7 +11,6 @@
#include <stdint.h>
#include "psa_protected_storage.h"
-#include "tfm_sst_defs.h"
#ifdef __cplusplus
extern "C" {
@@ -22,9 +21,9 @@
* structures.
* It identifies and validates the system metadata.
*
- * \return Returns error code specified in \ref tfm_sst_err_t
+ * \return Returns error code specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_system_prepare(void);
+psa_ps_status_t sst_system_prepare(void);
/**
* \brief Creates a new object with the provided UID and client ID.
@@ -35,11 +34,11 @@
* \param[in] size Size of the contents of `data` in bytes
* \param[in] data Buffer containing the data to write
*
- * \return Returns error code specified in \ref tfm_sst_err_t
+ * \return Returns error code specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
- psa_ps_create_flags_t create_flags,
- uint32_t size, const uint8_t *data);
+psa_ps_status_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
+ psa_ps_create_flags_t create_flags,
+ uint32_t size, const uint8_t *data);
/**
* \brief Gets the data of the object with the provided UID and client ID.
@@ -51,11 +50,11 @@
* \param[out] data Buffer where the data will be placed upon successful
* completion
*
- * \return Returns error code specified in \ref tfm_sst_err_t
+ * \return Returns error code specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_object_read(psa_ps_uid_t uid, int32_t client_id,
- uint32_t offset, uint32_t size,
- uint8_t *data);
+psa_ps_status_t sst_object_read(psa_ps_uid_t uid, int32_t client_id,
+ uint32_t offset, uint32_t size,
+ uint8_t *data);
/**
* \brief Writes data into the object with the provided UID and client ID.
@@ -66,11 +65,11 @@
* \param[in] size Size of the contents of `data` in bytes
* \param[in] data Buffer containing the data to write
*
- * \return Returns error code specified in \ref tfm_sst_err_t
+ * \return Returns error code specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
- uint32_t offset, uint32_t size,
- const uint8_t *data);
+psa_ps_status_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
+ uint32_t offset, uint32_t size,
+ const uint8_t *data);
/**
* \brief Deletes the object with the provided UID and client ID.
@@ -78,9 +77,9 @@
* \param[in] uid Unique identifier for the data
* \param[in] client_id Identifier of the asset's owner (client)
*
- * \return Returns error code specified in \ref tfm_sst_err_t
+ * \return Returns error code specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_object_delete(psa_ps_uid_t uid, int32_t client_id);
+psa_ps_status_t sst_object_delete(psa_ps_uid_t uid, int32_t client_id);
/**
* \brief Gets the asset information for the object with the provided UID and
@@ -91,17 +90,17 @@
* \param[out] info Pointer to the `psa_ps_info_t` struct that will be
* populated with the metadata
*
- * \return Returns error code specified in \ref tfm_sst_err_t
+ * \return Returns error code specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_object_get_info(psa_ps_uid_t uid, int32_t client_id,
- struct psa_ps_info_t *info);
+psa_ps_status_t sst_object_get_info(psa_ps_uid_t uid, int32_t client_id,
+ struct psa_ps_info_t *info);
/**
* \brief Wipes the secure storage system and all object data.
*
- * \return Returns error code specified in \ref tfm_sst_err_t
+ * \return Returns error code specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_system_wipe_all(void);
+psa_ps_status_t sst_system_wipe_all(void);
#ifdef __cplusplus
}
diff --git a/secure_fw/services/secure_storage/sst_object_table.c b/secure_fw/services/secure_storage/sst_object_table.c
index 9f5b5c4..57e1628 100644
--- a/secure_fw/services/secure_storage/sst_object_table.c
+++ b/secure_fw/services/secure_storage/sst_object_table.c
@@ -13,6 +13,7 @@
#include "flash_fs/sst_flash_fs.h"
#include "nv_counters/sst_nv_counters.h"
#include "sst_utils.h"
+#include "tfm_sst_defs.h"
/*!
* \def SST_OBJECT_SYSTEM_VERSION
@@ -223,7 +224,7 @@
__STATIC_INLINE void sst_object_table_fs_read_table(
struct sst_obj_table_init_ctx_t *init_ctx)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* FIXME: Read table from a persistent memory (flash location or FS) */
/* Read file with the table 0 data */
@@ -231,7 +232,7 @@
SST_OBJ_TABLE_SIZE,
SST_OBJECT_TABLE_OBJECT_OFFSET,
(uint8_t *)init_ctx->p_table[SST_OBJ_TABLE_IDX_0]);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
init_ctx->table_state[SST_OBJ_TABLE_IDX_0] = SST_OBJ_TABLE_INVALID;
}
@@ -240,7 +241,7 @@
SST_OBJ_TABLE_SIZE,
SST_OBJECT_TABLE_OBJECT_OFFSET,
(uint8_t *)init_ctx->p_table[SST_OBJ_TABLE_IDX_1]);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
init_ctx->table_state[SST_OBJ_TABLE_IDX_1] = SST_OBJ_TABLE_INVALID;
}
}
@@ -251,13 +252,13 @@
* \param[in,out] obj_table Pointer to the object table to generate
* authentication
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
__attribute__ ((always_inline))
-__STATIC_INLINE enum tfm_sst_err_t sst_object_table_fs_write_table(
+__STATIC_INLINE psa_ps_status_t sst_object_table_fs_write_table(
struct sst_obj_table_t *obj_table)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t obj_table_id = SST_TABLE_FS_ID(sst_obj_table_ctx.scratch_table);
uint8_t swap_table_idxs = sst_obj_table_ctx.scratch_table;
@@ -267,7 +268,7 @@
SST_OBJ_TABLE_SIZE,
SST_OBJ_TABLE_SIZE,
(const uint8_t *)obj_table);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -275,27 +276,27 @@
sst_obj_table_ctx.scratch_table = sst_obj_table_ctx.active_table;
sst_obj_table_ctx.active_table = swap_table_idxs;
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
#ifdef SST_ENCRYPTION
/**
* \brief Sets crypto key for object table.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_object_table_set_crypto_key(void)
+static psa_ps_status_t sst_object_table_set_crypto_key(void)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint8_t sst_key[SST_KEY_LEN_BYTES]; /*!< Secure storage system key */
err = sst_crypto_getkey(sst_key, SST_KEY_LEN_BYTES);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
err = sst_crypto_setkey(sst_key, SST_KEY_LEN_BYTES);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -308,40 +309,40 @@
*
* \param[in] nvc_1 Value of SST non-volatile counter 1
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_object_table_align_nv_counters(uint32_t nvc_1)
+static psa_ps_status_t sst_object_table_align_nv_counters(uint32_t nvc_1)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t nvc_x_val = 0;
/* Align SST NVC 2 with NVC 1 */
err = sst_read_nv_counter(TFM_SST_NV_COUNTER_2, &nvc_x_val);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
for (; nvc_x_val < nvc_1; nvc_x_val++) {
err = sst_increment_nv_counter(TFM_SST_NV_COUNTER_2);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
}
/* Align SST NVC 3 with NVC 1 */
err = sst_read_nv_counter(TFM_SST_NV_COUNTER_3, &nvc_x_val);
- if (err != TFM_SST_ERR_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err != PSA_PS_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
for (; nvc_x_val < nvc_1; nvc_x_val++) {
err = sst_increment_nv_counter(TFM_SST_NV_COUNTER_3);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
/**
@@ -351,10 +352,10 @@
* \param[in,out] obj_table Pointer to the object table to generate
* authentication
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
__attribute__ ((always_inline))
-__STATIC_INLINE enum tfm_sst_err_t sst_object_table_nvc_generate_auth_tag(
+__STATIC_INLINE psa_ps_status_t sst_object_table_nvc_generate_auth_tag(
uint32_t nvc_1,
struct sst_obj_table_t *obj_table)
{
@@ -385,7 +386,7 @@
{
struct sst_crypto_assoc_data_t assoc_data;
union sst_crypto_t *crypto = &init_ctx->p_table[table_idx]->crypto;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* Init associated data with NVC 1 */
assoc_data.nv_counter = init_ctx->nvc_1;
@@ -395,7 +396,7 @@
err = sst_crypto_authenticate(crypto, (const uint8_t *)&assoc_data,
SST_CRYPTO_ASSOCIATED_DATA_LEN);
- if (err == TFM_SST_ERR_SUCCESS) {
+ if (err == PSA_PS_SUCCESS) {
init_ctx->table_state[table_idx] = SST_OBJ_TABLE_NVC_1_VALID;
return;
}
@@ -410,7 +411,7 @@
err = sst_crypto_authenticate(crypto, (const uint8_t *)&assoc_data,
SST_CRYPTO_ASSOCIATED_DATA_LEN);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
init_ctx->table_state[table_idx] = SST_OBJ_TABLE_INVALID;
} else {
init_ctx->table_state[table_idx] = SST_OBJ_TABLE_NVC_3_VALID;
@@ -422,27 +423,27 @@
*
* \param[in,out] init_ctx Pointer to the object table to authenticate
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
__attribute__ ((always_inline))
-__STATIC_INLINE enum tfm_sst_err_t sst_object_table_nvc_authenticate(
+__STATIC_INLINE psa_ps_status_t sst_object_table_nvc_authenticate(
struct sst_obj_table_init_ctx_t *init_ctx)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t nvc_2;
err = sst_read_nv_counter(TFM_SST_NV_COUNTER_1, &init_ctx->nvc_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
err = sst_read_nv_counter(TFM_SST_NV_COUNTER_2, &nvc_2);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
err = sst_read_nv_counter(TFM_SST_NV_COUNTER_3, &init_ctx->nvc_3);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -467,7 +468,7 @@
sst_object_table_authenticate(SST_OBJ_TABLE_IDX_1, init_ctx);
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
#else /* SST_ROLLBACK_PROTECTION */
@@ -477,10 +478,10 @@
* \param[in,out] obj_table Pointer to the object table to generate
* authentication
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
__attribute__ ((always_inline))
-__STATIC_INLINE enum tfm_sst_err_t sst_object_table_generate_auth_tag(
+__STATIC_INLINE psa_ps_status_t sst_object_table_generate_auth_tag(
struct sst_obj_table_t *obj_table)
{
union sst_crypto_t *crypto = &obj_table->crypto;
@@ -503,7 +504,7 @@
__STATIC_INLINE void sst_object_table_authenticate_ctx_tables(
struct sst_obj_table_init_ctx_t *init_ctx)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
union sst_crypto_t *crypto =
&init_ctx->p_table[SST_OBJ_TABLE_IDX_0]->crypto;
@@ -512,7 +513,7 @@
err = sst_crypto_authenticate(crypto,
SST_CRYPTO_ASSOCIATED_DATA(crypto),
SST_CRYPTO_ASSOCIATED_DATA_LEN);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
init_ctx->table_state[SST_OBJ_TABLE_IDX_0] = SST_OBJ_TABLE_INVALID;
}
}
@@ -524,7 +525,7 @@
err = sst_crypto_authenticate(crypto,
SST_CRYPTO_ASSOCIATED_DATA(crypto),
SST_CRYPTO_ASSOCIATED_DATA_LEN);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
init_ctx->table_state[SST_OBJ_TABLE_IDX_1] = SST_OBJ_TABLE_INVALID;
}
}
@@ -537,23 +538,23 @@
*
* \param[in,out] obj_table Pointer to the object table to save
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_object_table_save_table(
+static psa_ps_status_t sst_object_table_save_table(
struct sst_obj_table_t *obj_table)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
#ifdef SST_ROLLBACK_PROTECTION
uint32_t nvc_1 = 0;
err = sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
err = sst_read_nv_counter(TFM_SST_NV_COUNTER_1, &nvc_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
#else
@@ -573,7 +574,7 @@
#ifdef SST_ENCRYPTION
/* Set object table key */
err = sst_object_table_set_crypto_key();
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -587,7 +588,7 @@
err = sst_object_table_generate_auth_tag(obj_table);
#endif /* SST_ROLLBACK_PROTECTION */
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
#endif /* SST_ENCRYPTION */
@@ -595,7 +596,7 @@
err = sst_object_table_fs_write_table(obj_table);
#ifdef SST_ROLLBACK_PROTECTION
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -636,8 +637,9 @@
*
* \param[in] init_ctx Pointer to the init object table context
*
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-static enum tfm_sst_err_t sst_set_active_object_table(
+static psa_ps_status_t sst_set_active_object_table(
const struct sst_obj_table_init_ctx_t *init_ctx)
{
#ifndef SST_ROLLBACK_PROTECTION
@@ -652,7 +654,7 @@
&& (init_ctx->table_state[SST_OBJ_TABLE_IDX_1] ==
SST_OBJ_TABLE_INVALID)) {
/* Both tables are invalid */
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
} else if (init_ctx->table_state[SST_OBJ_TABLE_IDX_0] ==
SST_OBJ_TABLE_INVALID) {
/* Table 0 is invalid, the active one is table 1 */
@@ -666,7 +668,7 @@
init_ctx->p_table[SST_OBJ_TABLE_IDX_1],
SST_OBJ_TABLE_SIZE);
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
} else if (init_ctx->table_state[SST_OBJ_TABLE_IDX_1] ==
SST_OBJ_TABLE_INVALID) {
/* Table 1 is invalid, the active one is table 0 */
@@ -677,7 +679,7 @@
* needed to copy the table in the context.
*/
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
#ifdef SST_ROLLBACK_PROTECTION
@@ -739,7 +741,7 @@
SST_OBJ_TABLE_SIZE);
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
/**
@@ -749,12 +751,12 @@
* \param[in] client_id Client UID
* \param[out] idx Pointer to store the entry's index
*
- * \return Returns TFM_SST_ERR_SUCCESS and index of the table, if object exists
- * in the table. Otherwise, it returns TFM_SST_ERR_UID_NOT_FOUND.
+ * \return Returns PSA_PS_SUCCESS and index of the table, if object exists
+ * in the table. Otherwise, it returns PSA_PS_ERROR_UID_NOT_FOUND.
*/
-static enum tfm_sst_err_t sst_get_object_entry_idx(psa_ps_uid_t uid,
- int32_t client_id,
- uint32_t *idx)
+static psa_ps_status_t sst_get_object_entry_idx(psa_ps_uid_t uid,
+ int32_t client_id,
+ uint32_t *idx)
{
uint32_t i;
struct sst_obj_table_t *p_table = &sst_obj_table_ctx.obj_table;
@@ -763,11 +765,11 @@
if (p_table->obj_db[i].uid == uid
&& p_table->obj_db[i].client_id == client_id) {
*idx = i;
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
}
- return TFM_SST_ERR_UID_NOT_FOUND;
+ return PSA_PS_ERROR_UID_NOT_FOUND;
}
/**
@@ -777,11 +779,11 @@
*
* \note The table is dimensioned to fit SST_NUM_ASSETS + 1
*
- * \return Returns TFM_SST_ERR_SUCCESS and a table index if a free index is
- * available. Otherwise, it returns TFM_SST_ERR_INSUFFICIENT_SPACE.
+ * \return Returns PSA_PS_SUCCESS and a table index if a free index is
+ * available. Otherwise, it returns PSA_PS_ERROR_INSUFFICIENT_SPACE.
*/
__attribute__ ((always_inline))
-__STATIC_INLINE enum tfm_sst_err_t sst_table_free_idx(uint32_t *idx)
+__STATIC_INLINE psa_ps_status_t sst_table_free_idx(uint32_t *idx)
{
uint32_t i;
struct sst_obj_table_t *p_table = &sst_obj_table_ctx.obj_table;
@@ -789,11 +791,11 @@
for (i = 0; i < SST_OBJ_TABLE_ENTRIES; i++) {
if (p_table->obj_db[i].uid == TFM_SST_INVALID_UID) {
*idx = i;
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
}
- return TFM_SST_ERR_INSUFFICIENT_SPACE;
+ return PSA_PS_ERROR_INSUFFICIENT_SPACE;
}
/**
@@ -817,16 +819,16 @@
#endif
}
-enum tfm_sst_err_t sst_object_table_create(void)
+psa_ps_status_t sst_object_table_create(void)
{
struct sst_obj_table_t *p_table = &sst_obj_table_ctx.obj_table;
#ifdef SST_ROLLBACK_PROTECTION
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* Initialize SST NV counters */
err = sst_init_nv_counter();
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
#endif
@@ -847,9 +849,9 @@
return sst_object_table_save_table(p_table);
}
-enum tfm_sst_err_t sst_object_table_init(uint8_t *obj_data)
+psa_ps_status_t sst_object_table_init(uint8_t *obj_data)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
struct sst_obj_table_init_ctx_t init_ctx = {
.p_table = {&sst_obj_table_ctx.obj_table, 0},
.table_state = {0, 0}
@@ -863,20 +865,20 @@
#ifdef SST_ENCRYPTION
/* Set object table key */
err = sst_object_table_set_crypto_key();
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
#ifdef SST_ROLLBACK_PROTECTION
/* Initialize SST NV counters */
err = sst_init_nv_counter();
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
/* Authenticate table */
err = sst_object_table_nvc_authenticate(&init_ctx);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
#else
@@ -890,21 +892,21 @@
/* Set active tables */
err = sst_set_active_object_table(&init_ctx);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
/* Remove the old object table file */
err = sst_flash_fs_file_delete(SST_TABLE_FS_ID(
sst_obj_table_ctx.scratch_table));
- if (err != TFM_SST_ERR_SUCCESS && err != TFM_SST_ERR_UID_NOT_FOUND) {
+ if (err != PSA_PS_SUCCESS && err != PSA_PS_ERROR_UID_NOT_FOUND) {
return err;
}
#ifdef SST_ROLLBACK_PROTECTION
/* Align SST NV counters */
err = sst_object_table_align_nv_counters(init_ctx.nvc_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
#endif /* SST_ROLLBACK_PROTECTION */
@@ -917,25 +919,24 @@
sst_crypto_set_iv(&sst_obj_table_ctx.obj_table.crypto);
#endif
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_object_table_obj_exist(psa_ps_uid_t uid,
- int32_t client_id)
+psa_ps_status_t sst_object_table_obj_exist(psa_ps_uid_t uid, int32_t client_id)
{
uint32_t idx = 0;
return sst_get_object_entry_idx(uid, client_id, &idx);
}
-enum tfm_sst_err_t sst_object_table_get_free_fid(uint32_t *p_fid)
+psa_ps_status_t sst_object_table_get_free_fid(uint32_t *p_fid)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t fid;
uint32_t idx;
err = sst_table_free_idx(&idx);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -948,33 +949,33 @@
* can happened when the system is rebooted (e.g. power cut, ...) in the
* middle of a create, write or delete operation.
*/
- if (sst_flash_fs_file_exist(fid) == TFM_SST_ERR_SUCCESS) {
+ if (sst_flash_fs_file_exist(fid) == PSA_PS_SUCCESS) {
/* Remove old file from the persistent area, to keep it consistent
* with the table content.
*/
err = sst_flash_fs_file_delete(fid);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
}
*p_fid = fid;
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_object_table_set_obj_tbl_info(psa_ps_uid_t uid,
- int32_t client_id,
+psa_ps_status_t sst_object_table_set_obj_tbl_info(psa_ps_uid_t uid,
+ int32_t client_id,
const struct sst_obj_table_info_t *obj_tbl_info)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t idx = 0;
uint32_t backup_idx = 0;
struct sst_obj_table_entry_t backup_entry;
struct sst_obj_table_t *p_table = &sst_obj_table_ctx.obj_table;
err = sst_get_object_entry_idx(uid, client_id, &backup_idx);
- if (err == TFM_SST_ERR_SUCCESS) {
+ if (err == PSA_PS_SUCCESS) {
/* If an entry exists for this UID, it creates a backup copy in case
* an error happens while updating the new table in the filesystem.
*/
@@ -999,7 +1000,7 @@
#endif
err = sst_object_table_save_table(p_table);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
/* Rollback the change in the table */
sst_utils_memcpy((uint8_t *)&p_table->obj_db[backup_idx],
(const uint8_t *)&backup_entry,
@@ -1011,16 +1012,16 @@
return err;
}
-enum tfm_sst_err_t sst_object_table_get_obj_tbl_info(psa_ps_uid_t uid,
- int32_t client_id,
+psa_ps_status_t sst_object_table_get_obj_tbl_info(psa_ps_uid_t uid,
+ int32_t client_id,
struct sst_obj_table_info_t *obj_tbl_info)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
uint32_t idx;
struct sst_obj_table_t *p_table = &sst_obj_table_ctx.obj_table;
err = sst_get_object_entry_idx(uid, client_id, &idx);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -1033,22 +1034,22 @@
obj_tbl_info->version = p_table->obj_db[idx].version;
#endif
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_object_table_delete_object(psa_ps_uid_t uid,
- int32_t client_id)
+psa_ps_status_t sst_object_table_delete_object(psa_ps_uid_t uid,
+ int32_t client_id)
{
uint32_t backup_idx = 0;
struct sst_obj_table_entry_t backup_entry;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
struct sst_obj_table_t *p_table = &sst_obj_table_ctx.obj_table;
/* Create a backup copy in case an error happens while updating the new
* table in the filesystem.
*/
err = sst_get_object_entry_idx(uid, client_id, &backup_idx);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
/* If the object is not present in the table, it returns an error
* to not generate a new file where the table content is the same.
* Otherwise, that could be used by an attacker to get the encryption
@@ -1064,7 +1065,7 @@
sst_table_delete_entry(backup_idx);
err = sst_object_table_save_table(p_table);
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
/* Rollback the change in the table */
sst_utils_memcpy((uint8_t *)&p_table->obj_db[backup_idx],
(const uint8_t *)&backup_entry,
@@ -1074,7 +1075,7 @@
return err;
}
-enum tfm_sst_err_t sst_object_table_delete_old_table(void)
+psa_ps_status_t sst_object_table_delete_old_table(void)
{
uint32_t table_id = SST_TABLE_FS_ID(sst_obj_table_ctx.scratch_table);
diff --git a/secure_fw/services/secure_storage/sst_object_table.h b/secure_fw/services/secure_storage/sst_object_table.h
index 1d686b8..68f6ec5 100644
--- a/secure_fw/services/secure_storage/sst_object_table.h
+++ b/secure_fw/services/secure_storage/sst_object_table.h
@@ -11,7 +11,6 @@
#include <stdint.h>
#include "psa_protected_storage.h"
-#include "tfm_sst_defs.h"
#ifdef __cplusplus
extern "C" {
@@ -34,9 +33,9 @@
/**
* \brief Creates object table.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_object_table_create(void);
+psa_ps_status_t sst_object_table_create(void);
/**
* \brief Initializes object table.
@@ -45,9 +44,9 @@
* in other to reuse that memory to allocated a
* temporary object table.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_object_table_init(uint8_t *obj_data);
+psa_ps_status_t sst_object_table_init(uint8_t *obj_data);
/**
* \brief Checks if there is an entry in the table for the provided UID and
@@ -56,23 +55,23 @@
* \param[in] uid Identifier for the data
* \param[in] client_id Identifier of the asset’s owner (client)
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*
- * \retval TFM_SST_ERR_SUCCESS If there is a table entry for the object
- * \retval TFM_SST_ERR_UID_NOT_FOUND If no table entry exists for the object
+ * \retval PSA_PS_SUCCESS If there is a table entry for the object
+ * \retval PSA_PS_ERROR_UID_NOT_FOUND If no table entry exists for the object
*/
-enum tfm_sst_err_t sst_object_table_obj_exist(psa_ps_uid_t uid,
- int32_t client_id);
+psa_ps_status_t sst_object_table_obj_exist(psa_ps_uid_t uid,
+ int32_t client_id);
/**
* \brief Gets a not in use file ID.
*
* \param[out] p_fid Pointer to the location to store the file ID
*
- * \return Returns TFM_SST_ERR_SUCCESS if the fid is valid. Otherwise, it
- * returns an error code as specified in \ref tfm_sst_err_t
+ * \return Returns PSA_PS_SUCCESS if the fid is valid. Otherwise, it
+ * returns an error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_object_table_get_free_fid(uint32_t *p_fid);
+psa_ps_status_t sst_object_table_get_free_fid(uint32_t *p_fid);
/**
* \brief Sets object table information in the object table and stores it
@@ -86,10 +85,10 @@
* \note A call to this function results in writing the table to the
* file system.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_object_table_set_obj_tbl_info(psa_ps_uid_t uid,
- int32_t client_id,
+psa_ps_status_t sst_object_table_set_obj_tbl_info(psa_ps_uid_t uid,
+ int32_t client_id,
const struct sst_obj_table_info_t *obj_tbl_info);
/**
@@ -101,11 +100,11 @@
* \param[out] obj_tbl_info Pointer to the location to store object table
* information
*
- * \return Returns TFM_SST_ERR_SUCCESS if the object exists. Otherwise, it
- * returns TFM_SST_ERR_UID_NOT_FOUND.
+ * \return Returns PSA_PS_SUCCESS if the object exists. Otherwise, it
+ * returns PSA_PS_ERROR_UID_NOT_FOUND.
*/
-enum tfm_sst_err_t sst_object_table_get_obj_tbl_info(psa_ps_uid_t uid,
- int32_t client_id,
+psa_ps_status_t sst_object_table_get_obj_tbl_info(psa_ps_uid_t uid,
+ int32_t client_id,
struct sst_obj_table_info_t *obj_tbl_info);
/**
@@ -114,17 +113,17 @@
* \param[in] uid Identifier for the data.
* \param[in] client_id Identifier of the asset’s owner (client)
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_object_table_delete_object(psa_ps_uid_t uid,
- int32_t client_id);
+psa_ps_status_t sst_object_table_delete_object(psa_ps_uid_t uid,
+ int32_t client_id);
/**
* \brief Deletes old object table from the persistent area.
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_object_table_delete_old_table(void);
+psa_ps_status_t sst_object_table_delete_old_table(void);
#ifdef __cplusplus
}
diff --git a/secure_fw/services/secure_storage/sst_utils.c b/secure_fw/services/secure_storage/sst_utils.c
index 15818a1..2e774b9 100644
--- a/secure_fw/services/secure_storage/sst_utils.c
+++ b/secure_fw/services/secure_storage/sst_utils.c
@@ -24,13 +24,13 @@
return;
}
-enum tfm_sst_err_t sst_utils_check_contained_in(uint32_t superset_size,
- uint32_t subset_offset,
- uint32_t subset_size)
+psa_ps_status_t sst_utils_check_contained_in(uint32_t superset_size,
+ uint32_t subset_offset,
+ uint32_t subset_size)
{
/* Check that subset_offset is valid */
if (subset_offset > superset_size) {
- return TFM_SST_ERR_OFFSET_INVALID;
+ return PSA_PS_ERROR_OFFSET_INVALID;
}
/* Check that subset_offset + subset_size fits in superset_size.
@@ -38,10 +38,10 @@
* and so the right hand side of the inequality cannot underflow.
*/
if (subset_size > (superset_size - subset_offset)) {
- return TFM_SST_ERR_INCORRECT_SIZE;
+ return PSA_PS_ERROR_INCORRECT_SIZE;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
uint32_t sst_utils_validate_secure_caller(void)
@@ -49,13 +49,13 @@
return tfm_core_validate_secure_caller();
}
-enum tfm_sst_err_t sst_utils_validate_fid(uint32_t fid)
+psa_ps_status_t sst_utils_validate_fid(uint32_t fid)
{
if (fid == SST_INVALID_FID) {
- return TFM_SST_ERR_UID_NOT_FOUND;
+ return PSA_PS_ERROR_UID_NOT_FOUND;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
/* FIXME: following functions are not optimized and will eventually to be
diff --git a/secure_fw/services/secure_storage/sst_utils.h b/secure_fw/services/secure_storage/sst_utils.h
index d62e8bf..be92465 100644
--- a/secure_fw/services/secure_storage/sst_utils.h
+++ b/secure_fw/services/secure_storage/sst_utils.h
@@ -11,7 +11,7 @@
#include <stdint.h>
#include "flash_layout.h"
-#include "tfm_sst_defs.h"
+#include "psa_protected_storage.h"
#ifdef __cplusplus
extern "C" {
@@ -70,19 +70,19 @@
* superset region
* \param[in] subset_size Size of subset region
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*
- * \retval TFM_SST_ERR_SUCCESS The subset is contained within the
- * superset
- * \retval TFM_SST_ERR_OFFSET_INVALID The subset offset is greater than the
- * size of the superset
- * \retval TFM_SST_ERR_INCORRECT_SIZE The subset offset is valid, but the
- * subset offset + size is greater than the
- * size of the superset
+ * \retval PSA_PS_SUCCESS The subset is contained within the
+ * superset
+ * \retval PSA_PS_ERROR_OFFSET_INVALID The subset offset is greater than the
+ * size of the superset
+ * \retval PSA_PS_ERROR_INCORRECT_SIZE The subset offset is valid, but the
+ * subset offset + size is greater than the
+ * size of the superset
*/
-enum tfm_sst_err_t sst_utils_check_contained_in(uint32_t superset_size,
- uint32_t subset_offset,
- uint32_t subset_size);
+psa_ps_status_t sst_utils_check_contained_in(uint32_t superset_size,
+ uint32_t subset_offset,
+ uint32_t subset_size);
/* FIXME: following functions(memcpy and memset) will be provided
* by core. This is only an interim abstraction. In the current
@@ -121,9 +121,9 @@
*
* \param[in] fid File ID
*
- * \return Returns error code as specified in \ref tfm_sst_err_t
+ * \return Returns error code as specified in \ref psa_ps_status_t
*/
-enum tfm_sst_err_t sst_utils_validate_fid(uint32_t fid);
+psa_ps_status_t sst_utils_validate_fid(uint32_t fid);
#ifdef __cplusplus
}
diff --git a/secure_fw/services/secure_storage/tfm_protected_storage.c b/secure_fw/services/secure_storage/tfm_protected_storage.c
index e40ef67..89434cc 100644
--- a/secure_fw/services/secure_storage/tfm_protected_storage.c
+++ b/secure_fw/services/secure_storage/tfm_protected_storage.c
@@ -7,10 +7,11 @@
#include "tfm_protected_storage.h"
#include "sst_object_system.h"
+#include "tfm_sst_defs.h"
-enum tfm_sst_err_t tfm_sst_init(void)
+psa_ps_status_t tfm_sst_init(void)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
err = sst_system_prepare();
#ifdef SST_CREATE_FLASH_LAYOUT
@@ -25,11 +26,11 @@
* when it is the first time in the device life that the SST service is
* executed.
*/
- if (err != TFM_SST_ERR_SUCCESS) {
+ if (err != PSA_PS_SUCCESS) {
/* Remove all data in the SST memory area and create a valid SST flash
* layout in that area.
*/
- sst_system_wipe_all();
+ err = sst_system_wipe_all();
/* Attempt to initialise again */
err = sst_system_prepare();
@@ -39,68 +40,68 @@
return err;
}
-enum tfm_sst_err_t tfm_sst_set(int32_t client_id,
- psa_ps_uid_t uid,
- uint32_t data_length,
- const void *p_data,
- psa_ps_create_flags_t create_flags)
+psa_ps_status_t tfm_sst_set(int32_t client_id,
+ psa_ps_uid_t uid,
+ uint32_t data_length,
+ const void *p_data,
+ psa_ps_create_flags_t create_flags)
{
/* Check that the UID is valid */
if (uid == TFM_SST_INVALID_UID) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
+ return PSA_PS_ERROR_INVALID_ARGUMENT;
}
if (p_data == NULL) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
+ return PSA_PS_ERROR_INVALID_ARGUMENT;
}
/* Check that the create_flags does not contain any unsupported flags */
if (create_flags & ~PSA_PS_FLAG_WRITE_ONCE) {
- return TFM_SST_ERR_FLAGS_NOT_SUPPORTED;
+ return PSA_PS_ERROR_FLAGS_NOT_SUPPORTED;
}
/* Create the object in the object system */
return sst_object_create(uid, client_id, create_flags, data_length, p_data);
}
-enum tfm_sst_err_t tfm_sst_get(int32_t client_id,
- psa_ps_uid_t uid,
- uint32_t data_offset,
- uint32_t data_length,
- void *p_data)
+psa_ps_status_t tfm_sst_get(int32_t client_id,
+ psa_ps_uid_t uid,
+ uint32_t data_offset,
+ uint32_t data_length,
+ void *p_data)
{
/* Check that the UID is valid */
if (uid == TFM_SST_INVALID_UID) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
+ return PSA_PS_ERROR_INVALID_ARGUMENT;
}
if (p_data == NULL) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
+ return PSA_PS_ERROR_INVALID_ARGUMENT;
}
/* Read the object data from the object system */
return sst_object_read(uid, client_id, data_offset, data_length, p_data);
}
-enum tfm_sst_err_t tfm_sst_get_info(int32_t client_id, psa_ps_uid_t uid,
- struct psa_ps_info_t *p_info)
+psa_ps_status_t tfm_sst_get_info(int32_t client_id, psa_ps_uid_t uid,
+ struct psa_ps_info_t *p_info)
{
/* Check that the UID is valid */
if (uid == TFM_SST_INVALID_UID) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
+ return PSA_PS_ERROR_INVALID_ARGUMENT;
}
/* Get the info struct data from the object system */
return sst_object_get_info(uid, client_id, p_info);
}
-enum tfm_sst_err_t tfm_sst_remove(int32_t client_id, psa_ps_uid_t uid)
+psa_ps_status_t tfm_sst_remove(int32_t client_id, psa_ps_uid_t uid)
{
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
/* Check that the UID is valid */
if (uid == TFM_SST_INVALID_UID) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
+ return PSA_PS_ERROR_INVALID_ARGUMENT;
}
/* Delete the object from the object system */
@@ -110,8 +111,8 @@
* specification. So, this function returns TFM_SST_ERR_OPERATION_FAILED
* instead.
*/
- if (err == TFM_SST_ERR_AUTH_FAILED) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (err == PSA_PS_ERROR_AUTH_FAILED) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
return err;
diff --git a/secure_fw/services/secure_storage/tfm_protected_storage.h b/secure_fw/services/secure_storage/tfm_protected_storage.h
index 969bf05..e7fdd27 100644
--- a/secure_fw/services/secure_storage/tfm_protected_storage.h
+++ b/secure_fw/services/secure_storage/tfm_protected_storage.h
@@ -11,7 +11,6 @@
#include <stdint.h>
#include "psa_protected_storage.h"
-#include "tfm_sst_defs.h"
#ifdef __cplusplus
extern "C" {
@@ -21,16 +20,16 @@
* \brief Initializes the secure storage system.
*
* \return A status indicating the success/failure of the operation as specified
- * in \ref tfm_sst_err_t
+ * in \ref psa_ps_status_t
*
- * \retval TFM_SST_ERR_SUCCESS The operation completed successfully
- * \retval TFM_SST_ERROR_STORAGE_FAILURE The operation failed because the
- * storage system initialization has
- * failed (fatal error)
- * \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
- * unspecified internal failure
+ * \retval PSA_PS_SUCCESS The operation completed successfully
+ * \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the
+ * storage system initialization has
+ * failed (fatal error)
+ * \retval PSA_PS_ERROR_OPERATION_FAILED The operation failed because of an
+ * unspecified internal failure
*/
-enum tfm_sst_err_t tfm_sst_init(void);
+psa_ps_status_t tfm_sst_init(void);
/**
* \brief Creates a new or modifies an existing asset.
@@ -42,34 +41,33 @@
* \param[in] create_flags The flags indicating the properties of the data
*
* \return A status indicating the success/failure of the operation as specified
- * in \ref tfm_sst_err_t
+ * in \ref psa_ps_status_t
*
- * \retval TFM_SST_ERR_SUCCESS The operation completed successfully
- * \retval TFM_SST_ERR_WRITE_ONCE The operation failed because the
+ * \retval PSA_PS_SUCCESS The operation completed successfully
+ * \retval PSA_PS_ERROR_WRITE_ONCE The operation failed because the
* provided uid value was already
* created with PSA_PS_FLAG_WRITE_ONCE
- * \retval TFM_SST_ERR_INVALID_ARGUMENT The operation failed because one or
+ * \retval PSA_PS_ERROR_INVALID_ARGUMENT The operation failed because one or
* more of the given arguments were
* invalid (null pointer, etc.)
- * \retval TFM_SST_ERR_FLAGS_NOT_SUPPORTED The operation failed because one or
+ * \retval PSA_PS_ERROR_FLAGS_NOT_SUPPORTED The operation failed because one or
* more of the flags provided in
* `create_flags` is not supported or
* is not valid
- * \retval TFM_SST_ERR_INSUFFICIENT_SPACE The operation failed because there
+ * \retval PSA_PS_ERROR_INSUFFICIENT_SPACE The operation failed because there
* was insufficient space on the
* storage medium
- * \retval TFM_SST_ERR_STORAGE_FAILURE The operation failed because the
+ * \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the
* physical storage has failed (fatal
* error)
- * \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
- * unspecified internal failure
+ * \retval PSA_PS_ERROR_OPERATION_FAILED The operation failed because of an
+ * unspecified internal failure.
*/
-enum tfm_sst_err_t tfm_sst_set(int32_t client_id,
- psa_ps_uid_t uid,
- uint32_t data_length,
- const void *p_data,
- psa_ps_create_flags_t create_flags);
-
+psa_ps_status_t tfm_sst_set(int32_t client_id,
+ psa_ps_uid_t uid,
+ uint32_t data_length,
+ const void *p_data,
+ psa_ps_create_flags_t create_flags);
/**
* \brief Gets the asset data for the provided uid.
*
@@ -83,34 +81,34 @@
* successful completion
*
* \return A status indicating the success/failure of the operation as specified
- * in \ref tfm_sst_err_t
+ * in \ref psa_ps_status_t
*
- * \retval TFM_SST_ERR_SUCCESS The operation completed successfully
- * \retval TFM_SST_ERR_INVALID_ARGUMENT The operation failed because one or
- * more of the given arguments were
- * invalid (null pointer, etc.)
- * \retval TFM_SST_ERR_UID_NOT_FOUND The operation failed because the
- * provided uid value was not found in the
- * storage
- * \retval TFM_SST_ERR_INCORRECT_SIZE The operation failed because the data
- * associated with provided uid is not the
- * same size as `data_size`
- * \retval TFM_SST_ERR_STORAGE_FAILURE The operation failed because the
- * physical storage has failed (fatal
- * error)
- * \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
- * unspecified internal failure
- * \retval TFM_SST_ERR_DATA_CORRUPT The operation failed because the data
- * associated with the UID was corrupt
- * \retval TFM_SST_ERR_AUTH_FAILED The operation failed because the data
- * associated with the UID failed
- * authentication
+ * \retval PSA_PS_SUCCESS The operation completed successfully
+ * \retval PSA_PS_ERROR_INVALID_ARGUMENT The operation failed because one or
+ * more of the given arguments were
+ * invalid (null pointer, etc.)
+ * \retval PSA_PS_ERROR_UID_NOT_FOUND The operation failed because the
+ * provided uid value was not found in
+ * the storage
+ * \retval PSA_PS_ERROR_INCORRECT_SIZE The operation failed because the data
+ * associated with provided uid is not
+ * the same size as `data_size`
+ * \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the
+ * physical storage has failed (fatal
+ * error)
+ * \retval PSA_PS_ERROR_OPERATION_FAILED The operation failed because of an
+ * unspecified internal failure
+ * \retval PSA_PS_ERROR_DATA_CORRUPT The operation failed because the data
+ * associated with the UID was corrupt
+ * \retval PSA_PS_ERROR_AUTH_FAILED The operation failed because the data
+ * associated with the UID failed
+ * authentication
*/
-enum tfm_sst_err_t tfm_sst_get(int32_t client_id,
- psa_ps_uid_t uid,
- uint32_t data_offset,
- uint32_t data_length,
- void *p_data);
+psa_ps_status_t tfm_sst_get(int32_t client_id,
+ psa_ps_uid_t uid,
+ uint32_t data_offset,
+ uint32_t data_length,
+ void *p_data);
/**
* \brief Gets the metadata for the provided uid.
@@ -121,28 +119,28 @@
* populated with the metadata
*
* \return A status indicating the success/failure of the operation as specified
- * in \ref tfm_sst_err_t
+ * in \ref psa_ps_status_t
*
- * \retval TFM_SST_ERR_SUCCESS The operation completed successfully
- * \retval TFM_SST_ERR_INVALID_ARGUMENT The operation failed because one or
- * more of the given arguments were
- * invalid (null pointer, etc.)
- * \retval TFM_SST_ERR_UID_NOT_FOUND The operation failed because the
- * provided uid value was not found in the
- * storage
- * \retval TFM_SST_ERR_STORAGE_FAILURE The operation failed because the
- * physical storage has failed (fatal
- * error)
- * \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
- * unspecified internal failure
- * \retval TFM_SST_ERR_DATA_CORRUPT The operation failed because the data
- * associated with the UID was corrupt
- * \retval TFM_SST_ERR_AUTH_FAILED The operation failed because the data
- * associated with the UID failed
- * authentication
+ * \retval PSA_PS_SUCCESS The operation completed successfully
+ * \retval PSA_PS_ERROR_INVALID_ARGUMENT The operation failed because one or
+ * more of the given arguments were
+ * invalid (null pointer, etc.)
+ * \retval PSA_PS_ERROR_UID_NOT_FOUND The operation failed because the
+ * provided uid value was not found in
+ * the storage
+ * \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the
+ * physical storage has failed (fatal
+ * error)
+ * \retval PSA_PS_ERROR_OPERATION_FAILED The operation failed because of an
+ * unspecified internal failure
+ * \retval PSA_PS_ERROR_DATA_CORRUPT The operation failed because the data
+ * associated with the UID was corrupt
+ * \retval PSA_PS_ERROR_AUTH_FAILED The operation failed because the data
+ * associated with the UID failed
+ * authentication
*/
-enum tfm_sst_err_t tfm_sst_get_info(int32_t client_id, psa_ps_uid_t uid,
- struct psa_ps_info_t *p_info);
+psa_ps_status_t tfm_sst_get_info(int32_t client_id, psa_ps_uid_t uid,
+ struct psa_ps_info_t *p_info);
/**
* \brief Removes the provided uid and its associated data from storage.
@@ -151,25 +149,25 @@
* \param[in] uid Unique identifier for the data to be removed
*
* \return A status indicating the success/failure of the operation as specified
- * in \ref tfm_sst_err_t
+ * in \ref psa_ps_status_t
*
- * \retval TFM_SST_ERR_SUCCESS The operation completed successfully
- * \retval TFM_SST_ERR_INVALID_ARGUMENT The operation failed because one or
- * more of the given arguments were
- * invalid (null pointer, etc.)
- * \retval TFM_SST_ERR_UID_NOT_FOUND The operation failed because the
- * provided uid value was not found in the
- * storage
- * \retval TFM_SST_ERR_WRITE_ONCE The operation failed because the
- * provided uid value was created with
- * PSA_PS_WRITE_ONCE_FLAG
- * \retval TFM_SST_ERR_STORAGE_FAILURE The operation failed because the
- * physical storage has failed (fatal
- * error)
- * \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
- * unspecified internal failure
+ * \retval PSA_PS_SUCCESS The operation completed successfully
+ * \retval PSA_PS_ERROR_INVALID_ARGUMENT The operation failed because one or
+ * more of the given arguments were
+ * invalid (null pointer, etc.)
+ * \retval PSA_PS_ERROR_UID_NOT_FOUND The operation failed because the
+ * provided uid value was not found in
+ * the storage
+ * \retval PSA_PS_ERROR_WRITE_ONCE The operation failed because the
+ * provided uid value was created with
+ * PSA_PS_WRITE_ONCE_FLAG
+ * \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the
+ * physical storage has failed (fatal
+ * error)
+ * \retval PSA_PS_ERROR_OPERATION_FAILED The operation failed because of an
+ * unspecified internal failure
*/
-enum tfm_sst_err_t tfm_sst_remove(int32_t client_id, psa_ps_uid_t uid);
+psa_ps_status_t tfm_sst_remove(int32_t client_id, psa_ps_uid_t uid);
/**
* \brief Gets a bitmask with flags set for all of the optional features
diff --git a/secure_fw/services/secure_storage/tfm_sst_secure_api.c b/secure_fw/services/secure_storage/tfm_sst_secure_api.c
index 5491ff6..17a63d6 100644
--- a/secure_fw/services/secure_storage/tfm_sst_secure_api.c
+++ b/secure_fw/services/secure_storage/tfm_sst_secure_api.c
@@ -6,7 +6,6 @@
*/
#include "psa_protected_storage.h"
-#include "tfm_sst_defs.h"
#include "tfm_veneers.h"
#define IOVEC_LEN(x) (sizeof(x)/sizeof(x[0]))
@@ -18,7 +17,7 @@
psa_ps_create_flags_t create_flags)
{
psa_status_t status;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) },
@@ -36,7 +35,7 @@
return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_PSA_RETURN(err);
+ return err;
}
__attribute__((section("SFN")))
@@ -46,7 +45,7 @@
void *p_data)
{
psa_status_t status;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) },
@@ -64,14 +63,14 @@
return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_PSA_RETURN(err);
+ return err;
}
__attribute__((section("SFN")))
psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
{
psa_status_t status;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) }
@@ -89,14 +88,14 @@
return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_PSA_RETURN(err);
+ return err;
}
__attribute__((section("SFN")))
psa_ps_status_t psa_ps_remove(psa_ps_uid_t uid)
{
psa_status_t status;
- enum tfm_sst_err_t err;
+ psa_ps_status_t err;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) }
@@ -113,7 +112,7 @@
return PSA_PS_ERROR_OPERATION_FAILED;
}
- return TFM_SST_PSA_RETURN(err);
+ return err;
}
__attribute__((section("SFN")))
diff --git a/test/suites/sst/secure/nv_counters/test_sst_nv_counters.c b/test/suites/sst/secure/nv_counters/test_sst_nv_counters.c
index 238e8db..db5a2d2 100644
--- a/test/suites/sst/secure/nv_counters/test_sst_nv_counters.c
+++ b/test/suites/sst/secure/nv_counters/test_sst_nv_counters.c
@@ -35,7 +35,7 @@
}
/* Implementation of SST NV counter interfaces defined by sst_nv_counters.h */
-enum tfm_sst_err_t sst_init_nv_counter(void)
+psa_ps_status_t sst_init_nv_counter(void)
{
static uint8_t is_init = 0;
@@ -46,46 +46,46 @@
is_init = 1;
}
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
- uint32_t *val)
+psa_ps_status_t sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
+ uint32_t *val)
{
uint32_t nv_pos;
nv_pos = get_nv_counter_position(counter_id);
if (nv_pos >= TOTAL_SST_NV_COUNTERS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Reads counter value */
*val = test_nv_counters[nv_pos];
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t sst_increment_nv_counter(enum tfm_nv_counter_t counter_id)
+psa_ps_status_t sst_increment_nv_counter(enum tfm_nv_counter_t counter_id)
{
uint32_t nv_pos;
if (nv_increment_status == DISABLE_INCREMENT) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
nv_pos = get_nv_counter_position(counter_id);
if (nv_pos >= TOTAL_SST_NV_COUNTERS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
if (test_nv_counters[nv_pos] == UINT32_MAX) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Increments counter value */
test_nv_counters[nv_pos]++;
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
/* Implementation of SST NV counter interfaces defined by
@@ -101,50 +101,48 @@
nv_increment_status = ENABLE_INCREMENT;
}
-enum tfm_sst_err_t test_sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
- uint32_t *val)
+psa_ps_status_t test_sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
+ uint32_t *val)
{
return sst_read_nv_counter(counter_id, val);
}
-enum tfm_sst_err_t test_sst_increment_nv_counter(
- enum tfm_nv_counter_t counter_id)
+psa_ps_status_t test_sst_increment_nv_counter(enum tfm_nv_counter_t counter_id)
{
return sst_increment_nv_counter(counter_id);
}
-enum tfm_sst_err_t test_sst_decrement_nv_counter(
- enum tfm_nv_counter_t counter_id)
+psa_ps_status_t test_sst_decrement_nv_counter(enum tfm_nv_counter_t counter_id)
{
uint32_t nv_pos;
nv_pos = get_nv_counter_position(counter_id);
if (nv_pos >= TOTAL_SST_NV_COUNTERS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
if (test_nv_counters[nv_pos] == 0) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Decrements counter value */
test_nv_counters[nv_pos]--;
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
-enum tfm_sst_err_t test_sst_set_nv_counter(enum tfm_nv_counter_t counter_id,
- uint32_t value)
+psa_ps_status_t test_sst_set_nv_counter(enum tfm_nv_counter_t counter_id,
+ uint32_t value)
{
uint32_t nv_pos;
nv_pos = get_nv_counter_position(counter_id);
if (nv_pos >= TOTAL_SST_NV_COUNTERS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ return PSA_PS_ERROR_OPERATION_FAILED;
}
/* Sets counter value */
test_nv_counters[nv_pos] = value;
- return TFM_SST_ERR_SUCCESS;
+ return PSA_PS_SUCCESS;
}
diff --git a/test/suites/sst/secure/nv_counters/test_sst_nv_counters.h b/test/suites/sst/secure/nv_counters/test_sst_nv_counters.h
index 1b2f5aa..a4175ca 100644
--- a/test/suites/sst/secure/nv_counters/test_sst_nv_counters.h
+++ b/test/suites/sst/secure/nv_counters/test_sst_nv_counters.h
@@ -9,7 +9,7 @@
#define __TEST_SST_NV_COUNTERS_H__
#include <stdint.h>
-#include "tfm_sst_defs.h"
+#include "psa_protected_storage.h"
#include "platform/include/tfm_plat_nv_counters.h"
#ifdef __cplusplus
@@ -22,11 +22,11 @@
* \param[in] counter_id NV counter ID.
* \param[out] val Pointer to store the current NV counter value.
*
- * \return TFM_SST_ERR_SUCCESS if the value is read correctly, otherwise
- * TFM_SST_ERR_OPERATION_FAILED
+ * \return PSA_PS_SUCCESS if the value is read correctly, otherwise
+ * PSA_PS_ERROR_OPERATION_FAILED
*/
-enum tfm_sst_err_t test_sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
- uint32_t *val);
+psa_ps_status_t test_sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
+ uint32_t *val);
/**
* \brief Increments the given non-volatile (NV) counter.
@@ -34,11 +34,10 @@
* \param[in] counter_id NV counter ID.
*
* \return When the NV counter reaches its maximum value, the
- * TFM_SST_ERR_OPERATION_FAILED error is returned to indicate the value
- * cannot be incremented. Otherwise, TFM_SST_ERR_SUCCESS.
+ * PSA_PS_ERROR_OPERATION_FAILED error is returned to indicate the
+ * value cannot be incremented. Otherwise, PSA_PS_SUCCESS.
*/
-enum tfm_sst_err_t test_sst_increment_nv_counter(
- enum tfm_nv_counter_t counter_id);
+psa_ps_status_t test_sst_increment_nv_counter(enum tfm_nv_counter_t counter_id);
/**
* \brief Decrements the given non-volatile (NV) counter.
@@ -46,15 +45,14 @@
* \param[in] counter_id NV counter ID.
*
* \return When the NV counter reaches its minimum value, the
- * TFM_SST_ERR_OPERATION_FAILED error is returned to indicate the value
- * cannot be decremented. Otherwise, TFM_SST_ERR_SUCCESS.
+ * PSA_PS_ERROR_OPERATION_FAILED error is returned to indicate the
+ * value cannot be decremented. Otherwise, PSA_PS_SUCCESS.
*/
-enum tfm_sst_err_t test_sst_decrement_nv_counter(
- enum tfm_nv_counter_t counter_id);
+psa_ps_status_t test_sst_decrement_nv_counter(enum tfm_nv_counter_t counter_id);
/**
* \brief Disables SST increment nv counter function to force
- * TFM_SST_ERR_OPERATION_FAILED return value as an indication that NV
+ * PSA_PS_ERROR_OPERATION_FAILED return value as an indication that NV
* counter reaches its maximum value.
*/
void test_sst_disable_increment_nv_counter(void);
@@ -71,11 +69,11 @@
* \param[in] value New NV counter value.
*
* \return When the NV counter reaches its maximum value, the
- * TFM_SST_ERR_OPERATION_FAILED error is returned to indicate the value
- * cannot be set. Otherwise, TFM_SST_ERR_SUCCESS.
+ * PSA_PS_ERROR_OPERATION_FAILED error is returned to indicate the
+ * value cannot be set. Otherwise, PSA_PS_SUCCESS.
*/
-enum tfm_sst_err_t test_sst_set_nv_counter(enum tfm_nv_counter_t counter_id,
- uint32_t value);
+psa_ps_status_t test_sst_set_nv_counter(enum tfm_nv_counter_t counter_id,
+ uint32_t value);
#ifdef __cplusplus
}
diff --git a/test/suites/sst/secure/sst_rollback_protection_testsuite.c b/test/suites/sst/secure/sst_rollback_protection_testsuite.c
index 81fa35f..cd26feb 100644
--- a/test/suites/sst/secure/sst_rollback_protection_testsuite.c
+++ b/test/suites/sst/secure/sst_rollback_protection_testsuite.c
@@ -105,7 +105,6 @@
*/
static void tfm_sst_test_4001(struct test_result_t *ret)
{
- enum tfm_sst_err_t err;
psa_ps_status_t status;
const psa_ps_uid_t uid = TEST_UID;
const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
@@ -123,8 +122,8 @@
}
/* Reads NV counter 1 to get the saved value to compare it later */
- err = test_sst_read_nv_counter(TFM_SST_NV_COUNTER_1, &old_nvc_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_read_nv_counter(TFM_SST_NV_COUNTER_1, &old_nvc_1);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Read should not fail");
return;
}
@@ -141,8 +140,8 @@
*/
/* Reads NV counter 1 to get the current value */
- err = test_sst_read_nv_counter(TFM_SST_NV_COUNTER_1, &nvc_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_read_nv_counter(TFM_SST_NV_COUNTER_1, &nvc_1);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Read should not fail");
return;
}
@@ -156,8 +155,8 @@
}
/* Reads NV counter 2 to get the current value */
- err = test_sst_read_nv_counter(TFM_SST_NV_COUNTER_2, &nvc_2);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_read_nv_counter(TFM_SST_NV_COUNTER_2, &nvc_2);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Read should not fail");
return;
}
@@ -168,8 +167,8 @@
}
/* Reads NV counter 3 to get the current value */
- err = test_sst_read_nv_counter(TFM_SST_NV_COUNTER_3, &nvc_3);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_read_nv_counter(TFM_SST_NV_COUNTER_3, &nvc_3);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Read should not fail");
return;
}
@@ -185,8 +184,8 @@
* Prepare should not fail as the NV counters has the same values and
* the SST area authentication is aligned with those values.
*/
- err = sst_system_prepare();
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = sst_system_prepare();
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("AM prepare should not fail");
return;
}
@@ -221,7 +220,6 @@
*/
static void tfm_sst_test_4002(struct test_result_t *ret)
{
- enum tfm_sst_err_t err;
psa_ps_status_t status;
const psa_ps_uid_t uid = TEST_UID;
const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
@@ -236,20 +234,20 @@
}
/* Increments all counters to make that SST area version old/invalid */
- err = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
- err = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_2);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_2);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
- err = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_3);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_3);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
@@ -260,8 +258,8 @@
* Prepare should fail as the SST area version does not match the
* NV counters values.
*/
- err = sst_system_prepare();
- if (err != TFM_SST_ERR_OPERATION_FAILED) {
+ status = sst_system_prepare();
+ if (status != PSA_PS_ERROR_OPERATION_FAILED) {
TEST_FAIL("SST system prepare should fail as version is old");
return;
}
@@ -277,27 +275,27 @@
*/
/* Aligns NV counters with the SST area version */
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_1);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_2);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_2);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
/* Calls sst_system_prepare to mark the SST area as a valid image */
- err = sst_system_prepare();
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = sst_system_prepare();
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
@@ -320,7 +318,6 @@
*/
static void tfm_sst_test_4003(struct test_result_t *ret)
{
- enum tfm_sst_err_t err;
psa_ps_status_t status;
const psa_ps_uid_t uid = TEST_UID;
const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
@@ -339,8 +336,8 @@
/* Decrements NV counters 3 to make it different from the other two counters
* and make the current SST area version match NV counter 1 and 2 values.
*/
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
@@ -351,8 +348,8 @@
* Prepare should not fail as the SST area version match NV counters 1 and
* 2 values.
*/
- err = sst_system_prepare();
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = sst_system_prepare();
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
@@ -390,7 +387,6 @@
*/
static void tfm_sst_test_4004(struct test_result_t *ret)
{
- enum tfm_sst_err_t err;
psa_ps_status_t status;
const psa_ps_uid_t uid = TEST_UID;
const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
@@ -409,8 +405,8 @@
/* Increments NV counters 1 to make it different from the other two counters
* and make the current SST area version match NV counter 2 and 3 values.
*/
- err = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
@@ -421,8 +417,8 @@
* Prepare should not fail as the SST area version match the NV counter 2
* and 3 values.
*/
- err = sst_system_prepare();
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = sst_system_prepare();
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
@@ -460,7 +456,6 @@
*/
static void tfm_sst_test_4005(struct test_result_t *ret)
{
- enum tfm_sst_err_t err;
psa_ps_status_t status;
const psa_ps_uid_t uid = TEST_UID;
const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
@@ -479,14 +474,14 @@
/* Decrements NV counter 2 and 3 to make the SST area version match NV
* counter 1 only.
*/
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_2);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_2);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
@@ -496,8 +491,8 @@
*
* Prepare should not fail as the SST area version match the NV counter 1.
*/
- err = sst_system_prepare();
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = sst_system_prepare();
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
@@ -532,7 +527,6 @@
*/
static void tfm_sst_test_4006(struct test_result_t *ret)
{
- enum tfm_sst_err_t err;
psa_ps_status_t status;
const psa_ps_uid_t uid = TEST_UID;
const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
@@ -551,20 +545,20 @@
/* Decrements NV counter 2 (1 time) and 3 (2 times) to make the SST area
* version match NV counter 1 only.
*/
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_2);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_2);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
@@ -574,8 +568,8 @@
*
* Prepare should not fail as the SST area version match the NV counter 1.
*/
- err = sst_system_prepare();
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = sst_system_prepare();
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
@@ -610,7 +604,6 @@
*/
static void tfm_sst_test_4007(struct test_result_t *ret)
{
- enum tfm_sst_err_t err;
psa_ps_status_t status;
const psa_ps_uid_t uid = TEST_UID;
const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
@@ -627,14 +620,14 @@
/* Increments NV counter 1 and decrements 3 to make the SST area
* version match NV counter 2 only.
*/
- err = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
@@ -645,8 +638,8 @@
* Prepare should fail as the SST area version match the NV counter 2 and
* the other counters are different.
*/
- err = sst_system_prepare();
- if (err != TFM_SST_ERR_OPERATION_FAILED) {
+ status = sst_system_prepare();
+ if (status != PSA_PS_ERROR_OPERATION_FAILED) {
TEST_FAIL("SST system prepare should fail");
return;
}
@@ -662,21 +655,21 @@
*/
/* Aligns NV counters with the SST area version */
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_1);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
- err = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_3);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_3);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
/* Calls sst_system_prepare to mark the SST area as a valid image */
- err = sst_system_prepare();
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = sst_system_prepare();
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
@@ -697,7 +690,6 @@
*/
static void tfm_sst_test_4008(struct test_result_t *ret)
{
- enum tfm_sst_err_t err;
psa_ps_status_t status;
const psa_ps_uid_t uid = TEST_UID;
const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
@@ -714,20 +706,20 @@
/* Increments NV counter 1 (2 times) and 2 (1 time) to make the SST area
* version match NV counter 3 only.
*/
- err = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
- err = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
- err = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_2);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_2);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
@@ -738,8 +730,8 @@
* Prepare should fail as the SST area version match the NV counter 2 and
* the other counters are different.
*/
- err = sst_system_prepare();
- if (err != TFM_SST_ERR_OPERATION_FAILED) {
+ status = sst_system_prepare();
+ if (status != PSA_PS_ERROR_OPERATION_FAILED) {
TEST_FAIL("AM prepare should fail");
return;
}
@@ -755,27 +747,27 @@
*/
/* Align NV counters with the SST area version */
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_1);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_1);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_1);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
- err = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_2);
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_2);
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
/* Calls sst_system_prepare to mark the SST area as a valid image */
- err = sst_system_prepare();
- if (err != TFM_SST_ERR_SUCCESS) {
+ status = sst_system_prepare();
+ if (status != PSA_PS_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}