aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGalanakis, Minos <minos.galanakis@arm.com>2019-11-20 14:29:44 +0000
committerSoby Mathew <soby.mathew@arm.com>2020-01-13 14:32:18 +0000
commitcd2379022a03fd6d193b14ec1e523f74ae1f3b42 (patch)
tree75ef5f5f83904795f30366e29496ae2fad0484fc
parent49a499bdc5cecefda1330cadce2b44a6fbd57d56 (diff)
downloadtrusted-firmware-m-feature-psa-dev-api-update.tar.gz
SST: Implement PSA Protected Storage 1.0feature-psa-dev-api-update
Refactors SST to implement PSA Protected Storage version 1.0. Change-Id: I967375e98799a465069525f203881f5331d6d84a Signed-off-by: Galanakis, Minos <minos.galanakis@arm.com>
-rw-r--r--interface/include/psa/protected_storage.h198
-rw-r--r--interface/src/tfm_sst_func_api.c93
-rw-r--r--interface/src/tfm_sst_ipc_api.c99
-rw-r--r--secure_fw/services/secure_storage/crypto/sst_crypto_interface.c80
-rw-r--r--secure_fw/services/secure_storage/crypto/sst_crypto_interface.h66
-rw-r--r--secure_fw/services/secure_storage/flash/sst_flash.c84
-rw-r--r--secure_fw/services/secure_storage/flash/sst_flash.h44
-rw-r--r--secure_fw/services/secure_storage/flash_fs/sst_flash_fs.c176
-rw-r--r--secure_fw/services/secure_storage/flash_fs/sst_flash_fs.h60
-rw-r--r--secure_fw/services/secure_storage/flash_fs/sst_flash_fs_dblock.c62
-rw-r--r--secure_fw/services/secure_storage/flash_fs/sst_flash_fs_dblock.h46
-rw-r--r--secure_fw/services/secure_storage/flash_fs/sst_flash_fs_mblock.c260
-rw-r--r--secure_fw/services/secure_storage/flash_fs/sst_flash_fs_mblock.h44
-rw-r--r--secure_fw/services/secure_storage/nv_counters/sst_nv_counters.c22
-rw-r--r--secure_fw/services/secure_storage/nv_counters/sst_nv_counters.h20
-rw-r--r--secure_fw/services/secure_storage/sst_encrypted_object.c56
-rw-r--r--secure_fw/services/secure_storage/sst_encrypted_object.h14
-rw-r--r--secure_fw/services/secure_storage/sst_object_defs.h4
-rw-r--r--secure_fw/services/secure_storage/sst_object_system.c150
-rw-r--r--secure_fw/services/secure_storage/sst_object_system.h45
-rw-r--r--secure_fw/services/secure_storage/sst_object_table.c207
-rw-r--r--secure_fw/services/secure_storage/sst_object_table.h52
-rw-r--r--secure_fw/services/secure_storage/sst_utils.c20
-rw-r--r--secure_fw/services/secure_storage/sst_utils.h27
-rw-r--r--secure_fw/services/secure_storage/tfm_protected_storage.c58
-rw-r--r--secure_fw/services/secure_storage/tfm_protected_storage.h110
-rw-r--r--secure_fw/services/secure_storage/tfm_sst_req_mngr.c317
-rw-r--r--secure_fw/services/secure_storage/tfm_sst_req_mngr.h4
-rw-r--r--secure_fw/services/secure_storage/tfm_sst_secure_api.c131
-rw-r--r--test/framework/test_framework_helpers.c72
-rw-r--r--test/framework/test_framework_helpers.h10
-rw-r--r--test/suites/sst/non_secure/psa_ps_ns_interface_testsuite.c504
-rw-r--r--test/suites/sst/secure/nv_counters/test_sst_nv_counters.c46
-rw-r--r--test/suites/sst/secure/nv_counters/test_sst_nv_counters.h31
-rw-r--r--test/suites/sst/secure/psa_ps_s_interface_testsuite.c359
-rw-r--r--test/suites/sst/secure/psa_ps_s_reliability_testsuite.c34
-rw-r--r--test/suites/sst/secure/sst_rollback_protection_testsuite.c198
37 files changed, 2008 insertions, 1795 deletions
diff --git a/interface/include/psa/protected_storage.h b/interface/include/psa/protected_storage.h
index f27c53f9e..ffac7a496 100644
--- a/interface/include/psa/protected_storage.h
+++ b/interface/include/psa/protected_storage.h
@@ -20,14 +20,46 @@
extern "C" {
#endif
+/**
+ * \brief PSA_PS_API_VERSION version
+ *
+ * Major and minor PSA_PS_API_VERSION numbers
+ */
#define PSA_PS_API_VERSION_MAJOR 1
#define PSA_PS_API_VERSION_MINOR 0
-// This version of the header file is associated with 1.0 final release.
-
/**
- * Create a new or modify an existing key/value pair
+ * \brief Create a new, or modify an existing, uid/value pair
+ *
+ * Stores data in the internal storage.
+ *
+ * \param[in] uid The identifier for the data
+ * \param[in] data_length The size in bytes of the data in `p_data`
+ * \param[in] p_data A buffer containing the data
+ * \param[in] create_flags The flags that the data will be stored with
+ *
+ * \return A status indicating the success/failure of the operation
*
+ * \retval PSA_SUCCESS The operation completed successfully
+ * \retval PSA_ERROR_NOT_PERMITTED The operation failed because the
+ * provided `uid` value was already
+ * created with
+ * PSA_STORAGE_FLAG_WRITE_ONCE
+ * \retval PSA_ERROR_NOT_SUPPORTED The operation failed because one or
+ * more of the flags provided in
+ * `create_flags` is not supported or is
+ * not valid
+ * \retval PSA_ERROR_INSUFFICIENT_STORAGE The operation failed because there
+ * was insufficient space on the
+ * storage medium
+ * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the
+ * physical storage has failed (Fatal
+ * error)
+ * \retval PSA_ERROR_INVALID_ARGUMENT The operation failed because one
+ * of the provided pointers(`p_data`)
+ * is invalid, for example is `NULL` or
+ * references memory the caller cannot
+ * access
*/
psa_status_t psa_ps_set(psa_storage_uid_t uid,
size_t data_length,
@@ -35,7 +67,40 @@ psa_status_t psa_ps_set(psa_storage_uid_t uid,
psa_storage_create_flags_t create_flags);
/**
- * Retrieve data associated with a provided UID
+ * \brief Retrieve data associated with a provided uid
+ *
+ * Retrieves up to `data_size` bytes of the data associated with `uid`, starting
+ * at `data_offset` bytes from the beginning of the data. Upon successful
+ * completion, the data will be placed in the `p_data` buffer, which must be at
+ * least `data_size` bytes in size. The length of the data returned will be in
+ * `p_data_length`. If `data_size` is 0, the contents of `p_data_length` will
+ * be set to zero.
+ *
+ * \param[in] uid The uid value
+ * \param[in] data_offset The starting offset of the data requested
+ * \param[in] data_size The amount of data requested
+ * \param[out] p_data On success, the buffer where the data will
+ * be placed
+ * \param[out] p_data_length On success, this will contain size of the data
+ * placed in `p_data`
+ *
+ * \return A status indicating the success/failure of the operation
+ *
+ * \retval PSA_SUCCESS The operation completed successfully
+ * \retval PSA_ERROR_DOES_NOT_EXIST The operation failed because the
+ * provided `uid` value was not found in
+ * the storage
+ * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the
+ * physical storage has failed (Fatal
+ * error)
+ * \retval PSA_ERROR_INVALID_ARGUMENT The operation failed because one of the
+ * provided arguments (`p_data`,
+ * `p_data_length`) is invalid, for example
+ * is `NULL` or references memory the
+ * caller cannot access. In addition, this
+ * can also happen if `data_offset` is
+ * larger than the size of the data
+ * associated with `uid`
*/
psa_status_t psa_ps_get(psa_storage_uid_t uid,
size_t data_offset,
@@ -44,26 +109,133 @@ psa_status_t psa_ps_get(psa_storage_uid_t uid,
size_t *p_data_length);
/**
- * Retrieve the metadata about the provided uid
+ * \brief Retrieve the metadata about the provided uid
+ *
+ * Retrieves the metadata stored for a given `uid`
+ *
+ * \param[in] uid The `uid` value
+ * \param[out] p_info A pointer to the `psa_storage_info_t` struct that will
+ * be populated with the metadata
+ *
+ * \return A status indicating the success/failure of the operation
+ *
+ * \retval PSA_SUCCESS The operation completed successfully
+ * \retval PSA_ERROR_DOES_NOT_EXIST The operation failed because the provided
+ * uid value was not found in the storage
+ * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the physical
+ * storage has failed (Fatal error)
+ * \retval PSA_ERROR_INVALID_ARGUMENT The operation failed because one of the
+ * provided pointers(`p_info`)
+ * is invalid, for example is `NULL` or
+ * references memory the caller cannot
+ * access
*/
psa_status_t psa_ps_get_info(psa_storage_uid_t uid,
struct psa_storage_info_t *p_info);
/**
- * Remove the provided uid and its associated data from the storage
+ * \brief Remove the provided uid and its associated data from the storage
+ *
+ * Deletes the data from internal storage.
+ *
+ * \param[in] uid The `uid` value
+ *
+ * \return A status indicating the success/failure of the operation
+ *
+ * \retval PSA_SUCCESS The operation completed successfully
+ * \retval PSA_ERROR_INVALID_ARGUMENT The operation failed because one or more
+ * of the given arguments were invalid (null
+ * pointer, wrong flags and so on)
+ * \retval PSA_ERROR_DOES_NOT_EXIST The operation failed because the provided
+ * uid value was not found in the storage
+ * \retval PSA_ERROR_NOT_PERMITTED The operation failed because the provided
+ * uid value was created with
+ * PSA_STORAGE_FLAG_WRITE_ONCE
+ * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the physical
+ * storage has failed (Fatal error)
*/
psa_status_t psa_ps_remove(psa_storage_uid_t uid);
/**
- * Reserves storage for the specified UID.
+ * \brief Reserves storage for the specified uid
+ *
+ * Upon success, the capacity of the storage will be capacity, and the size
+ * will be 0. It is only necessary to call this function for assets that will
+ * be written with the psa_ps_set_extended function. If only the psa_ps_set
+ * function is needed, calls to this function are redundant.
+ *
+ * \param[in] uid The `uid` value
+ * \param[in] capacity The capacity to be allocated in bytes
+ * \param[in] create_flags Flags indicating properties of storage
+ *
+ * \return A status indicating the success/failure of the operation
+ *
+ * \retval PSA_SUCCESS The operation completed successfully
+ * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the
+ * physical storage has failed
+ * (Fatal error)
+ * \retval PSA_ERROR_INSUFFICIENT_STORAGE The operation failed because capacity
+ * is bigger than the current available
+ * space
+ * \retval PSA_ERROR_NOT_SUPPORTED The operation failed function is
+ * not implemented or one or more
+ * create_flags are not supported.
+ * \retval PSA_ERROR_INVALID_ARGUMENT The operation failed uid was 0 or
+ * create_flags specified flags that are
+ * not defined in the API.
+ * pointer, wrong flags and so on)
*/
psa_status_t psa_ps_create(psa_storage_uid_t uid,
size_t capacity,
psa_storage_create_flags_t create_flags);
/**
- * Sets partial data into an asset based on the given identifier, data_offset,
- * data length and p_data.
+ * \brief Sets partial data into an asset
+ *
+ * Before calling this function, the storage must have been reserved with a call
+ * to psa_ps_create. It can also be used to overwrite data in an asset that was
+ * created with a call to psa_ps_set. Calling this function with data_length = 0
+ * is permitted, which will make no change to the stored data.This function can
+ * overwrite existing data and/or extend it up to the capacity for the uid
+ * specified in psa_ps_create, but cannot create gaps.
+ *
+ * That is, it has preconditions:
+ * - data_offset <= size
+ * - data_offset + data_length <= capacity
+ * and postconditions:
+ * - size = max(size, data_offset + data_length)
+ * - capacity unchanged.
+ *
+ * \param[in] uid The `uid` value
+ * \param[in] data_offset Offset within the asset to start the write
+ * \param[in] data_length The size in bytes of the data in p_data to write
+ * \param[in] p_data Pointer to a buffer which contains the data to write
+ *
+ * \return A status indicating the success/failure of the operation
+ *
+ * \retval PSA_SUCCESS The asset exists, the input parameters
+ * are correct and the data is correctly
+ * written in the physical storage.
+ * \retval PSA_ERROR_STORAGE_FAILURE The data was not written correctly in
+ * the physical storage
+ * \retval PSA_ERROR_INVALID_ARGUMENT The operation failed because one or more
+ * of the preconditions listed above
+ * regarding data_offset, size, or
+ * data_length was violated.
+ * \retval PSA_ERROR_DOES_NOT_EXIST The specified uid was not found
+ * \retval PSA_ERROR_NOT_SUPPORTED The implementation of the API does not
+ * support this function
+ * \retval PSA_ERROR_GENERIC_ERROR The operation failed due to an
+ * unspecified error
+ * \retval PSA_ERROR_DATA_CORRUPT The operation failed because the
+ * existing data has been corrupted.
+ * \retval PSA_ERROR_INVALID_SIGNATURE The operation failed because the
+ * existing data failed authentication
+ * (MAC check failed).
+ * \retval PSA_ERROR_NOT_PERMITTED The operation failed because it was
+ * attempted on an asset which was written
+ * with the flag
+ * PSA_STORAGE_FLAG_WRITE_ONCE
*/
psa_status_t psa_ps_set_extended(psa_storage_uid_t uid,
size_t data_offset,
@@ -71,9 +243,13 @@ psa_status_t psa_ps_set_extended(psa_storage_uid_t uid,
const void *p_data);
/**
- * Returns a bitmask with flags set for all of the optional features supported
- * by the implementation.
+ * \brief Lists optional features.
*
+ * \retval uint32_t A bitmask with flags set for all of
+ * the optional features supported by the
+ * implementation.Currently defined flags
+ * are limited to
+ * PSA_STORAGE_SUPPORT_SET_EXTENDED
*/
uint32_t psa_ps_get_support(void);
diff --git a/interface/src/tfm_sst_func_api.c b/interface/src/tfm_sst_func_api.c
index 6d94d6794..74262fbbc 100644
--- a/interface/src/tfm_sst_func_api.c
+++ b/interface/src/tfm_sst_func_api.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -12,73 +12,72 @@
#define IOVEC_LEN(x) (uint32_t)(sizeof(x)/sizeof(x[0]))
-psa_ps_status_t psa_ps_set(psa_ps_uid_t uid,
- uint32_t data_length,
- const void *p_data,
- psa_ps_create_flags_t create_flags)
+psa_status_t psa_ps_set(psa_storage_uid_t uid,
+ size_t data_length,
+ const void *p_data,
+ psa_storage_create_flags_t create_flags)
{
psa_status_t status;
- psa_ps_status_t err;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) },
{ .base = p_data, .len = data_length },
{ .base = &create_flags, .len = sizeof(create_flags) }
};
- psa_outvec out_vec[] = {
- { .base = &err , .len = sizeof(err) }
- };
-
status = tfm_ns_interface_dispatch(
(veneer_fn)tfm_tfm_sst_set_req_veneer,
(uint32_t)in_vec, IOVEC_LEN(in_vec),
- (uint32_t)out_vec, IOVEC_LEN(out_vec));
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
+ (uint32_t)NULL, 0);
- return err;
+ /* A parameter with a buffer pointer pointer that has data length longer
+ * than maximum permitted is treated as a secure violation.
+ * TF-M framework rejects the request with TFM_ERROR_INVALID_PARAMETER.
+ */
+ if (status == (psa_status_t)TFM_ERROR_INVALID_PARAMETER) {
+ return PSA_ERROR_INVALID_ARGUMENT;
+ }
+ return status;
}
-psa_ps_status_t psa_ps_get(psa_ps_uid_t uid,
- uint32_t data_offset,
- uint32_t data_length,
- void *p_data)
+psa_status_t psa_ps_get(psa_storage_uid_t uid,
+ size_t data_offset,
+ size_t data_size,
+ void *p_data,
+ size_t *p_data_length)
{
psa_status_t status;
- psa_ps_status_t err;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) },
{ .base = &data_offset, .len = sizeof(data_offset) }
};
psa_outvec out_vec[] = {
- { .base = &err, .len = sizeof(err) },
- { .base = p_data, .len = data_length }
+ { .base = p_data, .len = data_size }
};
+ if (p_data_length == NULL) {
+ return PSA_ERROR_GENERIC_ERROR;
+ }
+
status = tfm_ns_interface_dispatch(
(veneer_fn)tfm_tfm_sst_get_req_veneer,
(uint32_t)in_vec, IOVEC_LEN(in_vec),
(uint32_t)out_vec, IOVEC_LEN(out_vec));
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
+ *p_data_length = out_vec[0].len;
- return err;
+ return status;
}
-psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
+psa_status_t psa_ps_get_info(psa_storage_uid_t uid,
+ struct psa_storage_info_t *p_info)
{
psa_status_t status;
- psa_ps_status_t err;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) }
};
psa_outvec out_vec[] = {
- { .base = &err, .len = sizeof(err) },
{ .base = p_info, .len = sizeof(*p_info) }
};
@@ -87,56 +86,44 @@ psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
(uint32_t)in_vec, IOVEC_LEN(in_vec),
(uint32_t)out_vec, IOVEC_LEN(out_vec));
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
-
- return err;
+ return status;
}
-psa_ps_status_t psa_ps_remove(psa_ps_uid_t uid)
+psa_status_t psa_ps_remove(psa_storage_uid_t uid)
{
psa_status_t status;
- psa_ps_status_t err;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) }
};
- psa_outvec out_vec[] = {
- { .base = &err, .len = sizeof(err) }
- };
-
status = tfm_ns_interface_dispatch(
(veneer_fn)tfm_tfm_sst_remove_req_veneer,
(uint32_t)in_vec, IOVEC_LEN(in_vec),
- (uint32_t)out_vec, IOVEC_LEN(out_vec));
-
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
+ (uint32_t)NULL, 0);
- return err;
+ return status;
}
-psa_ps_status_t psa_ps_create(psa_ps_uid_t uid, uint32_t size,
- psa_ps_create_flags_t create_flags)
+psa_status_t psa_ps_create(psa_storage_uid_t uid,
+ size_t capacity,
+ psa_storage_create_flags_t create_flags)
{
(void)uid;
- (void)size;
+ (void)capacity;
(void)create_flags;
- return PSA_PS_ERROR_NOT_SUPPORTED;
+ return PSA_ERROR_NOT_SUPPORTED;
}
-psa_ps_status_t psa_ps_set_extended(psa_ps_uid_t uid, uint32_t data_offset,
- uint32_t data_length, const void *p_data)
+psa_status_t psa_ps_set_extended(psa_storage_uid_t uid, size_t data_offset,
+ size_t data_length, const void *p_data)
{
(void)uid;
(void)data_offset;
(void)data_length;
(void)p_data;
- return PSA_PS_ERROR_NOT_SUPPORTED;
+ return PSA_ERROR_NOT_SUPPORTED;
}
uint32_t psa_ps_get_support(void)
diff --git a/interface/src/tfm_sst_ipc_api.c b/interface/src/tfm_sst_ipc_api.c
index 9ef95ff49..4608c90a1 100644
--- a/interface/src/tfm_sst_ipc_api.c
+++ b/interface/src/tfm_sst_ipc_api.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -13,13 +13,12 @@
#define IOVEC_LEN(x) (uint32_t)(sizeof(x)/sizeof(x[0]))
-psa_ps_status_t psa_ps_set(psa_ps_uid_t uid,
- uint32_t data_length,
- const void *p_data,
- psa_ps_create_flags_t create_flags)
+psa_status_t psa_ps_set(psa_storage_uid_t uid,
+ size_t data_length,
+ const void *p_data,
+ psa_storage_create_flags_t create_flags)
{
psa_status_t status;
- psa_ps_status_t err;
psa_handle_t handle;
psa_invec in_vec[] = {
@@ -28,34 +27,34 @@ psa_ps_status_t psa_ps_set(psa_ps_uid_t uid,
{ .base = &create_flags, .len = sizeof(create_flags) }
};
- psa_outvec out_vec[] = {
- { .base = &err , .len = sizeof(err) }
- };
-
handle = psa_connect(TFM_SST_SET_SID, TFM_SST_SET_VERSION);
if (!PSA_HANDLE_IS_VALID(handle)) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), out_vec,
- IOVEC_LEN(out_vec));
+ status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec),
+ NULL, 0);
psa_close(handle);
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ /* A parameter with a buffer pointer pointer that has data length longer
+ * than maximum permitted is treated as a secure violation.
+ * TF-M framework rejects the request with TFM_ERROR_INVALID_PARAMETER.
+ */
+ if (status == (psa_status_t)TFM_ERROR_INVALID_PARAMETER) {
+ return PSA_ERROR_INVALID_ARGUMENT;
}
- return err;
+ return status;
}
-psa_ps_status_t psa_ps_get(psa_ps_uid_t uid,
- uint32_t data_offset,
- uint32_t data_length,
- void *p_data)
+psa_status_t psa_ps_get(psa_storage_uid_t uid,
+ size_t data_offset,
+ size_t data_size,
+ void *p_data,
+ size_t *p_data_length)
{
psa_status_t status;
- psa_ps_status_t err;
psa_handle_t handle;
psa_invec in_vec[] = {
@@ -64,13 +63,16 @@ psa_ps_status_t psa_ps_get(psa_ps_uid_t uid,
};
psa_outvec out_vec[] = {
- { .base = &err, .len = sizeof(err) },
- { .base = p_data, .len = data_length }
+ { .base = p_data, .len = data_size }
};
+ if (p_data_length == NULL) {
+ return PSA_ERROR_GENERIC_ERROR;
+ }
+
handle = psa_connect(TFM_SST_GET_SID, TFM_SST_GET_VERSION);
if (!PSA_HANDLE_IS_VALID(handle)) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), out_vec,
@@ -78,17 +80,15 @@ psa_ps_status_t psa_ps_get(psa_ps_uid_t uid,
psa_close(handle);
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
+ *p_data_length = out_vec[0].len;
- return err;
+ return status;
}
-psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
+psa_status_t psa_ps_get_info(psa_storage_uid_t uid,
+ struct psa_storage_info_t *p_info)
{
psa_status_t status;
- psa_ps_status_t err;
psa_handle_t handle;
psa_invec in_vec[] = {
@@ -96,13 +96,12 @@ psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
};
psa_outvec out_vec[] = {
- { .base = &err, .len = sizeof(err) },
{ .base = p_info, .len = sizeof(*p_info) }
};
handle = psa_connect(TFM_SST_GET_INFO_SID, TFM_SST_GET_INFO_VERSION);
if (!PSA_HANDLE_IS_VALID(handle)) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), out_vec,
@@ -110,63 +109,51 @@ psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
psa_close(handle);
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
-
- return err;
+ return status;
}
-psa_ps_status_t psa_ps_remove(psa_ps_uid_t uid)
+psa_status_t psa_ps_remove(psa_storage_uid_t uid)
{
psa_status_t status;
- psa_ps_status_t err;
psa_handle_t handle;
psa_invec in_vec[] = {
{ .base = &uid, .len = sizeof(uid) }
};
- psa_outvec out_vec[] = {
- { .base = &err, .len = sizeof(err) }
- };
handle = psa_connect(TFM_SST_REMOVE_SID, TFM_SST_REMOVE_VERSION);
if (!PSA_HANDLE_IS_VALID(handle)) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), out_vec,
- IOVEC_LEN(out_vec));
+ status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec),
+ NULL, 0);
psa_close(handle);
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
-
- return err;
+ return status;
}
-psa_ps_status_t psa_ps_create(psa_ps_uid_t uid, uint32_t size,
- psa_ps_create_flags_t create_flags)
+psa_status_t psa_ps_create(psa_storage_uid_t uid, size_t size,
+ psa_storage_create_flags_t create_flags)
{
(void)uid;
(void)size;
(void)create_flags;
- return PSA_PS_ERROR_NOT_SUPPORTED;
+ return PSA_ERROR_NOT_SUPPORTED;
}
-psa_ps_status_t psa_ps_set_extended(psa_ps_uid_t uid, uint32_t data_offset,
- uint32_t data_length, const void *p_data)
+psa_status_t psa_ps_set_extended(psa_storage_uid_t uid, size_t data_offset,
+ size_t data_length, const void *p_data)
{
(void)uid;
(void)data_offset;
(void)data_length;
(void)p_data;
- return PSA_PS_ERROR_NOT_SUPPORTED;
+ return PSA_ERROR_NOT_SUPPORTED;
}
uint32_t psa_ps_get_support(void)
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 c2d83250d..d3480c3dd 100644
--- a/secure_fw/services/secure_storage/crypto/sst_crypto_interface.c
+++ b/secure_fw/services/secure_storage/crypto/sst_crypto_interface.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -25,15 +25,15 @@ static const uint8_t sst_key_label[] = "storage_key";
static psa_key_handle_t sst_key_handle;
static uint8_t sst_crypto_iv_buf[SST_IV_LEN_BYTES];
-psa_ps_status_t sst_crypto_init(void)
+psa_status_t sst_crypto_init(void)
{
/* Currently, no initialisation is required. This may change if key
* handling is changed.
*/
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_crypto_setkey(void)
+psa_status_t sst_crypto_setkey(void)
{
psa_status_t status;
psa_key_handle_t huk_key_handle;
@@ -43,7 +43,7 @@ psa_ps_status_t sst_crypto_setkey(void)
/* Allocate a transient key handle for the storage key */
status = psa_allocate_key(&sst_key_handle);
if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Set the key policy for the storage key */
@@ -92,7 +92,7 @@ psa_ps_status_t sst_crypto_setkey(void)
goto release_sst_key;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
release_generator:
(void)psa_generator_abort(&sst_key_generator);
@@ -103,20 +103,20 @@ release_huk:
release_sst_key:
(void)psa_destroy_key(sst_key_handle);
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
-psa_ps_status_t sst_crypto_destroykey(void)
+psa_status_t sst_crypto_destroykey(void)
{
psa_status_t status;
/* Destroy the transient key */
status = psa_destroy_key(sst_key_handle);
if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
void sst_crypto_set_iv(const union sst_crypto_t *crypto)
@@ -166,14 +166,14 @@ void sst_crypto_get_iv(union sst_crypto_t *crypto)
(void)tfm_memcpy(crypto->ref.iv, sst_crypto_iv_buf, SST_IV_LEN_BYTES);
}
-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,
- size_t in_len,
- uint8_t *out,
- size_t out_size,
- size_t *out_len)
+psa_status_t sst_crypto_encrypt_and_tag(union sst_crypto_t *crypto,
+ const uint8_t *add,
+ size_t add_len,
+ const uint8_t *in,
+ size_t in_len,
+ uint8_t *out,
+ size_t out_size,
+ size_t *out_len)
{
psa_status_t status;
@@ -183,24 +183,24 @@ psa_ps_status_t sst_crypto_encrypt_and_tag(union sst_crypto_t *crypto,
in, in_len,
out, out_size, out_len);
if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Copy the tag out of the output buffer */
*out_len -= SST_TAG_LEN_BYTES;
(void)tfm_memcpy(crypto->ref.tag, (out + *out_len), SST_TAG_LEN_BYTES);
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_crypto_auth_and_decrypt(const union sst_crypto_t *crypto,
- const uint8_t *add,
- size_t add_len,
- uint8_t *in,
- size_t in_len,
- uint8_t *out,
- size_t out_size,
- size_t *out_len)
+psa_status_t sst_crypto_auth_and_decrypt(const union sst_crypto_t *crypto,
+ const uint8_t *add,
+ size_t add_len,
+ uint8_t *in,
+ size_t in_len,
+ uint8_t *out,
+ size_t out_size,
+ size_t *out_len)
{
psa_status_t status;
@@ -214,15 +214,15 @@ psa_ps_status_t sst_crypto_auth_and_decrypt(const union sst_crypto_t *crypto,
in, in_len,
out, out_size, out_len);
if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_AUTH_FAILED;
+ return PSA_ERROR_INVALID_SIGNATURE;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_crypto_generate_auth_tag(union sst_crypto_t *crypto,
- const uint8_t *add,
- uint32_t add_len)
+psa_status_t sst_crypto_generate_auth_tag(union sst_crypto_t *crypto,
+ const uint8_t *add,
+ uint32_t add_len)
{
psa_status_t status;
size_t out_len;
@@ -233,15 +233,15 @@ psa_ps_status_t sst_crypto_generate_auth_tag(union sst_crypto_t *crypto,
0, 0,
crypto->ref.tag, SST_TAG_LEN_BYTES, &out_len);
if (status != PSA_SUCCESS || out_len != SST_TAG_LEN_BYTES) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_crypto_authenticate(const union sst_crypto_t *crypto,
- const uint8_t *add,
- uint32_t add_len)
+psa_status_t sst_crypto_authenticate(const union sst_crypto_t *crypto,
+ const uint8_t *add,
+ uint32_t add_len)
{
psa_status_t status;
size_t out_len;
@@ -252,8 +252,8 @@ psa_ps_status_t sst_crypto_authenticate(const union sst_crypto_t *crypto,
crypto->ref.tag, SST_TAG_LEN_BYTES,
0, 0, &out_len);
if (status != PSA_SUCCESS || out_len != 0) {
- return PSA_PS_ERROR_AUTH_FAILED;
+ return PSA_ERROR_INVALID_SIGNATURE;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
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 2d8f89e26..7b10b55c9 100644
--- a/secure_fw/services/secure_storage/crypto/sst_crypto_interface.h
+++ b/secure_fw/services/secure_storage/crypto/sst_crypto_interface.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -35,23 +35,23 @@ union sst_crypto_t {
/**
* \brief Initializes the crypto engine.
*
- * \return Returns values as described in \ref psa_ps_status_t
+ * \return Returns values as described in \ref psa_status_t
*/
-psa_ps_status_t sst_crypto_init(void);
+psa_status_t sst_crypto_init(void);
/**
* \brief Sets the key to use for crypto operations for the current client.
*
- * \return Returns values as described in \ref psa_ps_status_t
+ * \return Returns values as described in \ref psa_status_t
*/
-psa_ps_status_t sst_crypto_setkey(void);
+psa_status_t sst_crypto_setkey(void);
/**
* \brief Destroys the transient key used for crypto operations.
*
- * \return Returns values as described in \ref psa_ps_status_t
+ * \return Returns values as described in \ref psa_status_t
*/
-psa_ps_status_t sst_crypto_destroykey(void);
+psa_status_t sst_crypto_destroykey(void);
/**
* \brief Encrypts and tags the given plaintext data.
@@ -65,16 +65,16 @@ psa_ps_status_t sst_crypto_destroykey(void);
* \param[in] out_size Size of the output buffer
* \param[out] out_len On success, the length of the output data
*
- * \return Returns values as described in \ref psa_ps_status_t
+ * \return Returns values as described in \ref psa_status_t
*/
-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,
- size_t in_len,
- uint8_t *out,
- size_t out_size,
- size_t *out_len);
+psa_status_t sst_crypto_encrypt_and_tag(union sst_crypto_t *crypto,
+ const uint8_t *add,
+ size_t add_len,
+ const uint8_t *in,
+ size_t in_len,
+ uint8_t *out,
+ size_t out_size,
+ size_t *out_len);
/**
* \brief Decrypts and authenticates the given encrypted data.
@@ -88,16 +88,16 @@ psa_ps_status_t sst_crypto_encrypt_and_tag(union sst_crypto_t *crypto,
* \param[in] out_size Size of the output buffer
* \param[out] out_len On success, the length of the output data
*
- * \return Returns values as described in \ref psa_ps_status_t
+ * \return Returns values as described in \ref psa_status_t
*/
-psa_ps_status_t sst_crypto_auth_and_decrypt(const union sst_crypto_t *crypto,
- const uint8_t *add,
- size_t add_len,
- uint8_t *in,
- size_t in_len,
- uint8_t *out,
- size_t out_size,
- size_t *out_len);
+psa_status_t sst_crypto_auth_and_decrypt(const union sst_crypto_t *crypto,
+ const uint8_t *add,
+ size_t add_len,
+ uint8_t *in,
+ size_t in_len,
+ uint8_t *out,
+ size_t out_size,
+ size_t *out_len);
/**
* \brief Generates authentication tag for given data.
@@ -106,11 +106,11 @@ psa_ps_status_t sst_crypto_auth_and_decrypt(const union sst_crypto_t *crypto,
* \param[in] add Pointer to the data to authenticate
* \param[in] add_len Length of the data to authenticate
*
- * \return Returns values as described in \ref psa_ps_status_t
+ * \return Returns values as described in \ref psa_status_t
*/
-psa_ps_status_t sst_crypto_generate_auth_tag(union sst_crypto_t *crypto,
- const uint8_t *add,
- uint32_t add_len);
+psa_status_t sst_crypto_generate_auth_tag(union sst_crypto_t *crypto,
+ const uint8_t *add,
+ uint32_t add_len);
/**
* \brief Authenticate given data against the tag.
@@ -119,11 +119,11 @@ psa_ps_status_t sst_crypto_generate_auth_tag(union sst_crypto_t *crypto,
* \param[in] add Pointer to the data to authenticate
* \param[in] add_len Length of the data to authenticate
*
- * \return Returns values as described in \ref psa_ps_status_t
+ * \return Returns values as described in \ref psa_status_t
*/
-psa_ps_status_t sst_crypto_authenticate(const union sst_crypto_t *crypto,
- const uint8_t *add,
- uint32_t add_len);
+psa_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 ce8c1f0f1..e2b560025 100644
--- a/secure_fw/services/secure_storage/flash/sst_flash.c
+++ b/secure_fw/services/secure_storage/flash/sst_flash.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -48,100 +48,100 @@ __STATIC_INLINE uint32_t get_phys_address(uint32_t block_id, uint32_t offset)
}
#ifdef SST_RAM_FS
-static psa_ps_status_t flash_init(void)
+static psa_status_t flash_init(void)
{
/* Nothing needs to be done in case of Flash emulated in RAM */
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-static psa_ps_status_t flash_read(uint32_t flash_addr, uint32_t size,
- uint8_t *buff)
+static psa_status_t flash_read(uint32_t flash_addr, uint32_t size,
+ uint8_t *buff)
{
uint32_t idx = flash_addr - SST_FLASH_AREA_ADDR;
(void)tfm_memcpy(buff, &block_data[idx], size);
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-static psa_ps_status_t flash_write(uint32_t flash_addr, uint32_t size,
- const uint8_t *buff)
+static psa_status_t flash_write(uint32_t flash_addr, uint32_t size,
+ const uint8_t *buff)
{
uint32_t idx = flash_addr - SST_FLASH_AREA_ADDR;
(void)tfm_memcpy(&block_data[idx], buff, size);
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-static psa_ps_status_t flash_erase(uint32_t flash_addr)
+static psa_status_t flash_erase(uint32_t flash_addr)
{
uint32_t idx = flash_addr - SST_FLASH_AREA_ADDR;
(void)tfm_memset(&block_data[idx], SST_FLASH_DEFAULT_VAL, SST_SECTOR_SIZE);
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
#else
-static psa_ps_status_t flash_init(void)
+static psa_status_t flash_init(void)
{
int32_t err;
err = SST_FLASH_DEV_NAME.Initialize(NULL);
if (err != ARM_DRIVER_OK) {
- return PSA_PS_ERROR_STORAGE_FAILURE;
+ return PSA_ERROR_STORAGE_FAILURE;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-static psa_ps_status_t flash_read(uint32_t flash_addr, uint32_t size,
- uint8_t *buff)
+static psa_status_t flash_read(uint32_t flash_addr, uint32_t size,
+ uint8_t *buff)
{
int32_t err;
err = SST_FLASH_DEV_NAME.ReadData(flash_addr, buff, size);
if (err != ARM_DRIVER_OK) {
- return PSA_PS_ERROR_STORAGE_FAILURE;
+ return PSA_ERROR_STORAGE_FAILURE;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-static psa_ps_status_t flash_write(uint32_t flash_addr, uint32_t size,
- const uint8_t *buff)
+static psa_status_t flash_write(uint32_t flash_addr, uint32_t size,
+ const uint8_t *buff)
{
int32_t err;
err = SST_FLASH_DEV_NAME.ProgramData(flash_addr, buff, size);
if (err != ARM_DRIVER_OK) {
- return PSA_PS_ERROR_STORAGE_FAILURE;
+ return PSA_ERROR_STORAGE_FAILURE;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-static psa_ps_status_t flash_erase(uint32_t flash_addr)
+static psa_status_t flash_erase(uint32_t flash_addr)
{
int32_t err;
err = SST_FLASH_DEV_NAME.EraseSector(flash_addr);
if (err != ARM_DRIVER_OK) {
- return PSA_PS_ERROR_STORAGE_FAILURE;
+ return PSA_ERROR_STORAGE_FAILURE;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
#endif /* SST_RAM_FS */
-psa_ps_status_t sst_flash_init(void)
+psa_status_t sst_flash_init(void)
{
return flash_init();
}
-psa_ps_status_t sst_flash_read(uint32_t block_id, uint8_t *buff,
- uint32_t offset, uint32_t size)
+psa_status_t sst_flash_read(uint32_t block_id, uint8_t *buff,
+ uint32_t offset, uint32_t size)
{
uint32_t flash_addr;
@@ -153,8 +153,8 @@ psa_ps_status_t sst_flash_read(uint32_t block_id, uint8_t *buff,
return flash_read(flash_addr, size, buff);
}
-psa_ps_status_t sst_flash_write(uint32_t block_id, const uint8_t *buff,
- uint32_t offset, uint32_t size)
+psa_status_t sst_flash_write(uint32_t block_id, const uint8_t *buff,
+ uint32_t offset, uint32_t size)
{
uint32_t flash_addr;
@@ -166,13 +166,13 @@ psa_ps_status_t sst_flash_write(uint32_t block_id, const uint8_t *buff,
return flash_write(flash_addr, size, buff);
}
-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)
+psa_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)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint8_t dst_block_data_copy[MAX_BLOCK_DATA_COPY];
uint32_t dst_flash_addr;
uint32_t src_flash_addr;
@@ -194,13 +194,13 @@ psa_ps_status_t sst_flash_block_to_block_move(uint32_t dst_block,
* destination content.
*/
err = flash_read(src_flash_addr, bytes_to_move, dst_block_data_copy);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_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 != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -212,15 +212,15 @@ psa_ps_status_t sst_flash_block_to_block_move(uint32_t dst_block,
dst_flash_addr += bytes_to_move;
};
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_flash_erase_block(uint32_t block_id)
+psa_status_t sst_flash_erase_block(uint32_t block_id)
{
uint32_t flash_addr;
uint32_t offset = BLOCK_START_OFFSET;
uint32_t sectors_to_erase = SST_SECTORS_PER_BLOCK;
- psa_ps_status_t status;
+ psa_status_t status;
while (sectors_to_erase > 0) {
/* Get the flash address defined by block ID and BLOCK_START_OFFSET
@@ -229,7 +229,7 @@ psa_ps_status_t sst_flash_erase_block(uint32_t block_id)
flash_addr = get_phys_address(block_id, offset);
status = flash_erase(flash_addr);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
break;
}
diff --git a/secure_fw/services/secure_storage/flash/sst_flash.h b/secure_fw/services/secure_storage/flash/sst_flash.h
index bdd3c3650..a8e12efed 100644
--- a/secure_fw/services/secure_storage/flash/sst_flash.h
+++ b/secure_fw/services/secure_storage/flash/sst_flash.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -50,10 +50,10 @@ extern "C" {
/**
* \brief Initialize the Flash Interface.
*
- * \return Returns PSA_PS_SUCCESS if the function is executed correctly.
- * Otherwise, it returns PSA_PS_ERROR_STORAGE_FAILURE.
+ * \return Returns PSA_SUCCESS if the function is executed correctly.
+ * Otherwise, it returns PSA_ERROR_STORAGE_FAILURE.
*/
-psa_ps_status_t sst_flash_init(void);
+psa_status_t sst_flash_init(void);
/**
* \brief Reads block data from the position specified by block ID and offset.
@@ -67,11 +67,11 @@ psa_ps_status_t sst_flash_init(void);
* the range of address, based on blockid + offset + size, are always
* valid in the memory.
*
- * \return Returns PSA_PS_SUCCESS if the function is executed correctly.
- * Otherwise, it returns PSA_PS_ERROR_STORAGE_FAILURE.
+ * \return Returns PSA_SUCCESS if the function is executed correctly.
+ * Otherwise, it returns PSA_ERROR_STORAGE_FAILURE.
*/
-psa_ps_status_t sst_flash_read(uint32_t block_id, uint8_t *buff,
- uint32_t offset, uint32_t size);
+psa_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 @@ psa_ps_status_t sst_flash_read(uint32_t block_id, uint8_t *buff,
* the range of address, based on blockid + offset + size, are always
* valid in the memory.
*
- * \return Returns PSA_PS_SUCCESS if the function is executed correctly.
- * Otherwise, it returns PSA_PS_ERROR_STORAGE_FAILURE.
+ * \return Returns PSA_SUCCESS if the function is executed correctly.
+ * Otherwise, it returns PSA_ERROR_STORAGE_FAILURE.
*/
-psa_ps_status_t sst_flash_write(uint32_t block_id, const uint8_t *buff,
- uint32_t offset, uint32_t size);
+psa_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 @@ psa_ps_status_t sst_flash_write(uint32_t block_id, const uint8_t *buff,
* It also considers that the destination block is already erased and
* ready to be written.
*
- * \return Returns PSA_PS_SUCCESS if the function is executed correctly.
- * Otherwise, it returns PSA_PS_ERROR_STORAGE_FAILURE.
+ * \return Returns PSA_SUCCESS if the function is executed correctly.
+ * Otherwise, it returns PSA_ERROR_STORAGE_FAILURE.
*/
-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);
+psa_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 @@ psa_ps_status_t sst_flash_block_to_block_move(uint32_t dst_block,
*
* \note This function considers all input values valids.
*
- * \return Returns PSA_PS_SUCCESS if the function is executed correctly.
- * Otherwise, it returns PSA_PS_ERROR_STORAGE_FAILURE.
+ * \return Returns PSA_SUCCESS if the function is executed correctly.
+ * Otherwise, it returns PSA_ERROR_STORAGE_FAILURE.
*/
-psa_ps_status_t sst_flash_erase_block(uint32_t block_id);
+psa_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 ce5d337d2..7ce0afebf 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -17,24 +17,24 @@
#define SST_FLASH_FS_INIT_FILE 0
-static psa_ps_status_t sst_flash_fs_file_write_aligned_data(
+static psa_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)
{
- psa_ps_status_t err;
+ psa_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 PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_INVALID_ARGUMENT;
}
/* Check if size is aligned with SST_FLASH_PROGRAM_UNIT */
if (GET_ALIGNED_FLASH_BYTES(size) != size) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_INVALID_ARGUMENT;
}
#endif /* (SST_FLASH_PROGRAM_UNIT != 1) */
@@ -46,65 +46,65 @@ static psa_ps_status_t sst_flash_fs_file_write_aligned_data(
return err;
}
-psa_ps_status_t sst_flash_fs_prepare(void)
+psa_status_t sst_flash_fs_prepare(void)
{
/* Initialize metadata block with the valid/active metablock */
return sst_flash_fs_mblock_init();
}
-psa_ps_status_t sst_flash_fs_wipe_all(void)
+psa_status_t sst_flash_fs_wipe_all(void)
{
/* Clean and initialize the metadata block */
return sst_flash_fs_mblock_reset_metablock();
}
-psa_ps_status_t sst_flash_fs_file_exist(uint32_t fid)
+psa_status_t sst_flash_fs_file_exist(uint32_t fid)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t idx;
err = sst_flash_fs_mblock_get_file_idx(fid, &idx);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_UID_NOT_FOUND;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_DOES_NOT_EXIST;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_flash_fs_file_create(uint32_t fid,
- uint32_t max_size,
- uint32_t data_size,
- const uint8_t *data)
+psa_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;
- psa_ps_status_t err;
+ psa_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 == PSA_PS_SUCCESS) {
+ if (err == PSA_SUCCESS) {
/* If it exits return an error as needs to be removed first */
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_INVALID_ARGUMENT;
}
/* Check if max_size is aligned with SST_FLASH_PROGRAM_UNIT */
if (GET_ALIGNED_FLASH_BYTES(max_size) != max_size) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_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 != PSA_PS_SUCCESS) {
+ if (err != PSA_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 PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_INVALID_ARGUMENT;
}
/* Write the content into scratch data block */
@@ -112,16 +112,16 @@ psa_ps_status_t sst_flash_fs_file_create(uint32_t fid,
SST_FLASH_FS_INIT_FILE,
data_size,
data);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* 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 != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
cur_phys_block = block_meta.phy_id;
@@ -138,20 +138,20 @@ psa_ps_status_t sst_flash_fs_file_create(uint32_t fid,
/* Update metadata block information */
err = sst_flash_fs_mblock_update_scratch_block_meta(file_meta.lblock,
&block_meta);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Add file metadata in the metadata block */
err = sst_flash_fs_mblock_update_scratch_file_meta(idx, &file_meta);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Copy rest of the file metadata entries */
err = sst_flash_fs_mblock_cp_remaining_file_meta(idx);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* The file data in the logical block 0 is stored in same physical block
@@ -164,8 +164,8 @@ psa_ps_status_t sst_flash_fs_file_create(uint32_t fid,
*/
if ((file_meta.lblock != SST_LOGICAL_DBLOCK0) || (data_size == 0)) {
err = sst_flash_fs_mblock_migrate_lb0_data_to_scratch();
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
}
@@ -175,68 +175,68 @@ psa_ps_status_t sst_flash_fs_file_create(uint32_t fid,
return err;
}
-psa_ps_status_t sst_flash_fs_file_get_info(uint32_t fid,
- struct sst_file_info_t *info)
+psa_status_t sst_flash_fs_file_get_info(uint32_t fid,
+ struct sst_file_info_t *info)
{
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_UID_NOT_FOUND;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_DOES_NOT_EXIST;
}
/* Read file metadata */
err = sst_flash_fs_mblock_read_file_meta(idx, &tmp_metadata);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
/* Check if index is still referring to same file */
if (fid != tmp_metadata.id) {
- return PSA_PS_ERROR_UID_NOT_FOUND;
+ return PSA_ERROR_DOES_NOT_EXIST;
}
info->size_max = tmp_metadata.max_size;
info->size_current = tmp_metadata.cur_size;
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_flash_fs_file_write(uint32_t fid, uint32_t size,
- uint32_t offset, const uint8_t *data)
+psa_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;
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_UID_NOT_FOUND;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_DOES_NOT_EXIST;
}
/* Read file metadata */
err = sst_flash_fs_mblock_read_file_meta(idx, &file_meta);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_UID_NOT_FOUND;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_DOES_NOT_EXIST;
}
/* Read block metadata */
err = sst_flash_fs_mblock_read_block_metadata(file_meta.lblock,
&block_meta);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Write the content into scratch data block */
err = sst_flash_fs_file_write_aligned_data(&file_meta, offset, size, data);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
if (size > file_meta.cur_size) {
@@ -245,8 +245,8 @@ psa_ps_status_t sst_flash_fs_file_write(uint32_t fid, uint32_t size,
}
err = sst_flash_fs_dblock_cp_remaining_data(&block_meta, &file_meta);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
cur_phys_block = block_meta.phy_id;
@@ -261,20 +261,20 @@ psa_ps_status_t sst_flash_fs_file_write(uint32_t fid, uint32_t size,
/* Update block metadata in scratch metadata block */
err = sst_flash_fs_mblock_update_scratch_block_meta(file_meta.lblock,
&block_meta);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Update file metadata to reflect new attributes */
err = sst_flash_fs_mblock_update_scratch_file_meta(idx, &file_meta);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Copy rest of the file metadata entries */
err = sst_flash_fs_mblock_cp_remaining_file_meta(idx);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* The file data in the logical block 0 is stored in same physical block
@@ -287,8 +287,8 @@ psa_ps_status_t sst_flash_fs_file_write(uint32_t fid, uint32_t size,
*/
if (file_meta.lblock != SST_LOGICAL_DBLOCK0) {
err = sst_flash_fs_mblock_migrate_lb0_data_to_scratch();
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
}
@@ -300,13 +300,13 @@ psa_ps_status_t sst_flash_fs_file_write(uint32_t fid, uint32_t size,
return err;
}
-psa_ps_status_t sst_flash_fs_file_delete(uint32_t fid)
+psa_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;
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t src_offset = SST_BLOCK_SIZE;
uint32_t nbr_bytes_to_move = 0;
uint32_t idx;
@@ -314,17 +314,17 @@ psa_ps_status_t sst_flash_fs_file_delete(uint32_t fid)
/* Get the file index */
err = sst_flash_fs_mblock_get_file_idx(fid, &del_file_idx);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_UID_NOT_FOUND;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_DOES_NOT_EXIST;
}
err = sst_flash_fs_mblock_read_file_meta(del_file_idx, &file_meta);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
- if (sst_utils_validate_fid(file_meta.id) != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_UID_NOT_FOUND;
+ if (sst_utils_validate_fid(file_meta.id) != PSA_SUCCESS) {
+ return PSA_ERROR_DOES_NOT_EXIST;
}
/* Save logical block, data_index and max_size to be used later on */
@@ -341,7 +341,7 @@ psa_ps_status_t sst_flash_fs_file_delete(uint32_t fid)
/* Update file metadata in to the scratch block */
err = sst_flash_fs_mblock_update_scratch_file_meta(del_file_idx,
&file_meta);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -354,7 +354,7 @@ psa_ps_status_t sst_flash_fs_file_delete(uint32_t fid)
/* Read file meta for the given file index */
err = sst_flash_fs_mblock_read_file_meta(idx, &file_meta);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -385,7 +385,7 @@ psa_ps_status_t sst_flash_fs_file_delete(uint32_t fid)
}
/* Update file metadata in to the scratch block */
err = sst_flash_fs_mblock_update_scratch_file_meta(idx, &file_meta);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
}
@@ -394,7 +394,7 @@ psa_ps_status_t sst_flash_fs_file_delete(uint32_t fid)
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 != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -408,8 +408,8 @@ psa_ps_status_t sst_flash_fs_file_delete(uint32_t fid)
*/
if (del_file_lblock != SST_LOGICAL_DBLOCK0) {
err = sst_flash_fs_mblock_migrate_lb0_data_to_scratch();
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
}
@@ -421,41 +421,41 @@ psa_ps_status_t sst_flash_fs_file_delete(uint32_t fid)
return err;
}
-psa_ps_status_t sst_flash_fs_file_read(uint32_t fid, uint32_t size,
- uint32_t offset, uint8_t *data)
+psa_status_t sst_flash_fs_file_read(uint32_t fid, uint32_t size,
+ uint32_t offset, uint8_t *data)
{
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_UID_NOT_FOUND;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_DOES_NOT_EXIST;
}
/* Read file metadata */
err = sst_flash_fs_mblock_read_file_meta(idx, &tmp_metadata);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Check if index is still referring to same file */
if (fid != tmp_metadata.id) {
- return PSA_PS_ERROR_UID_NOT_FOUND;
+ return PSA_ERROR_DOES_NOT_EXIST;
}
/* Boundary check the incoming request */
err = sst_utils_check_contained_in(tmp_metadata.cur_size, offset, size);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
/* Read the file from flash */
err = sst_flash_fs_dblock_read_file(&tmp_metadata, offset, size, data);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
- return PSA_PS_SUCCESS;
+ return PSA_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 4af3f9953..b997b0547 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -38,27 +38,27 @@ extern "C" {
/**
* \brief Prepares the filesystem to accept operations on the files.
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_prepare(void);
+psa_status_t sst_flash_fs_prepare(void);
/**
* \brief Wipes all files from the filesystem.
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_wipe_all(void);
+psa_status_t sst_flash_fs_wipe_all(void);
/**
* \brief Checks if a file exists in the filesystem.
*
* \param[in] fid File ID
*
- * \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.
+ * \return Returns PSA_SUCCESS if the file exists. If file does not
+ * exist, it returns PSA_ERROR_DOES_NOT_EXIST. Otherwise, it returns
+ * error code as specified in \ref psa_status_t.
*/
-psa_ps_status_t sst_flash_fs_file_exist(uint32_t fid);
+psa_status_t sst_flash_fs_file_exist(uint32_t fid);
/**
* \brief Creates a file in the filesystem.
@@ -71,15 +71,15 @@ psa_ps_status_t sst_flash_fs_file_exist(uint32_t fid);
* This parameter is set to NULL when the file is empty
* after the creation.
*
- * \return Returns PSA_PS_SUCCESS if the file has been created correctly.
+ * \return Returns PSA_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.
+ * \ref psa_status_t.
*/
-psa_ps_status_t sst_flash_fs_file_create(uint32_t fid,
- uint32_t max_size,
- uint32_t data_size,
- const uint8_t *data);
+psa_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.
@@ -88,10 +88,10 @@ psa_ps_status_t sst_flash_fs_file_create(uint32_t fid,
* \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 psa_ps_status_t
+ * \return Returns error code specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_file_get_info(uint32_t fid,
- struct sst_file_info_t *info);
+psa_status_t sst_flash_fs_file_get_info(uint32_t fid,
+ struct sst_file_info_t *info);
/**
* \brief Writes data to an existing file.
@@ -101,12 +101,12 @@ psa_ps_status_t sst_flash_fs_file_get_info(uint32_t fid,
* \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 psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_file_write(uint32_t fid,
- uint32_t size,
- uint32_t offset,
- const uint8_t *data);
+psa_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.
@@ -116,21 +116,21 @@ psa_ps_status_t sst_flash_fs_file_write(uint32_t fid,
* \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 psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_file_read(uint32_t fid,
- uint32_t size,
- uint32_t offset,
- uint8_t *data);
+psa_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 psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_file_delete(uint32_t fid);
+psa_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 fa2e40973..2cc2217e8 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -20,29 +20,29 @@
static uint32_t sst_dblock_lo_to_phy(uint32_t lblock)
{
struct sst_block_meta_t block_meta;
- psa_ps_status_t err;
+ psa_status_t err;
err = sst_flash_fs_mblock_read_block_metadata(lblock, &block_meta);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return SST_BLOCK_INVALID_ID;
}
return block_meta.phy_id;
}
-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)
+psa_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;
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -60,8 +60,8 @@ psa_ps_status_t sst_flash_fs_dblock_compact_block(uint32_t lblock,
err = sst_flash_block_to_block_move(scratch_id, dst_offset,
block_meta.phy_id, src_offset,
size);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
}
@@ -74,8 +74,8 @@ psa_ps_status_t sst_flash_fs_dblock_compact_block(uint32_t lblock,
block_meta.phy_id,
block_meta.data_start,
(dst_offset-block_meta.data_start));
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
}
@@ -90,7 +90,7 @@ psa_ps_status_t sst_flash_fs_dblock_compact_block(uint32_t lblock,
/* Update block metadata in scratch metadata block */
err = sst_flash_fs_mblock_update_scratch_block_meta(lblock, &block_meta);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_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 @@ psa_ps_status_t sst_flash_fs_dblock_compact_block(uint32_t lblock,
return err;
}
-psa_ps_status_t sst_flash_fs_dblock_cp_data_to_scratch(uint32_t lblock,
- uint32_t offset,
- uint32_t size)
+psa_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 @@ psa_ps_status_t sst_flash_fs_dblock_cp_data_to_scratch(uint32_t lblock,
/* 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 PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Get the scratch data block ID to write the data */
@@ -121,17 +121,17 @@ psa_ps_status_t sst_flash_fs_dblock_cp_data_to_scratch(uint32_t lblock,
size);
}
-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)
+psa_status_t sst_flash_fs_dblock_read_file(struct sst_file_meta_t *file_meta,
+ uint32_t offset,
+ uint32_t size,
+ uint8_t *buf)
{
uint32_t phys_block;
uint32_t pos;
phys_block = sst_dblock_lo_to_phy(file_meta->lblock);
if (phys_block == SST_BLOCK_INVALID_ID) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
pos = (file_meta->data_idx + offset);
@@ -139,10 +139,10 @@ psa_ps_status_t sst_flash_fs_dblock_read_file(struct sst_file_meta_t *file_meta,
return sst_flash_read(phys_block, buf, pos, size);
}
-psa_ps_status_t sst_flash_fs_dblock_write_file(uint32_t lblock,
- uint32_t offset,
- uint32_t size,
- const uint8_t *data)
+psa_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;
@@ -151,12 +151,12 @@ psa_ps_status_t sst_flash_fs_dblock_write_file(uint32_t lblock,
return sst_flash_write(scratch_id, data, offset, size);
}
-psa_ps_status_t sst_flash_fs_dblock_cp_remaining_data(
+psa_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;
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t scratch_id;
uint32_t wrt_bytes;
@@ -171,7 +171,7 @@ psa_ps_status_t sst_flash_fs_dblock_cp_remaining_data(
block_meta->phy_id,
block_meta->data_start,
wrt_bytes);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_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 4ba4ea561..a231cae97 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -27,13 +27,13 @@ extern "C" {
* 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 psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-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);
+psa_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 @@ psa_ps_status_t sst_flash_fs_dblock_compact_block(uint32_t lblock,
* \param[in] size Number of bytes to be copied from logical block to
* scratch data block
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_dblock_cp_data_to_scratch(uint32_t lblock,
- uint32_t offset,
- uint32_t size);
+psa_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,12 +58,12 @@ psa_ps_status_t sst_flash_fs_dblock_cp_data_to_scratch(uint32_t lblock,
* \param[in] size Size to be read
* \param[out] buf Buffer pointer to store the data
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-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);
+psa_status_t sst_flash_fs_dblock_read_file(struct sst_file_meta_t *file_meta,
+ uint32_t offset,
+ uint32_t size,
+ uint8_t *buf);
/**
* \brief Writes scratch data block content with requested data
@@ -76,12 +76,12 @@ psa_ps_status_t sst_flash_fs_dblock_read_file(struct sst_file_meta_t *file_meta,
* \param[in] data Pointer to data buffer to copy in the scratch data
* block
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_dblock_write_file(uint32_t lblock,
- uint32_t offset,
- uint32_t size,
- const uint8_t *data);
+psa_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
@@ -90,9 +90,9 @@ psa_ps_status_t sst_flash_fs_dblock_write_file(uint32_t lblock,
* \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 psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_dblock_cp_remaining_data(
+psa_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 8365b2d3f..851bd2e06 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -275,42 +275,42 @@ static uint8_t sst_mblock_latest_meta_block(
*
* \param[in] file_meta Pointer to file meta structure
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
__attribute__((always_inline))
-__STATIC_INLINE psa_ps_status_t sst_mblock_validate_file_meta(
+__STATIC_INLINE psa_status_t sst_mblock_validate_file_meta(
const struct sst_file_meta_t *file_meta)
{
- psa_ps_status_t err;
+ psa_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 PSA_PS_ERROR_DATA_CORRUPT;
+ return PSA_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) == PSA_PS_SUCCESS) {
+ if (sst_utils_validate_fid(file_meta->id) == PSA_SUCCESS) {
/* validate files values if file is in use */
if (file_meta->max_size > SST_MAX_OBJECT_SIZE) {
- return PSA_PS_ERROR_DATA_CORRUPT;
+ return PSA_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 PSA_PS_ERROR_DATA_CORRUPT;
+ return PSA_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 PSA_PS_ERROR_DATA_CORRUPT;
+ return PSA_ERROR_DATA_CORRUPT;
}
}
@@ -318,12 +318,12 @@ __STATIC_INLINE psa_ps_status_t sst_mblock_validate_file_meta(
err = sst_utils_check_contained_in(SST_BLOCK_SIZE,
file_meta->data_idx,
file_meta->max_size);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_DATA_CORRUPT;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_DATA_CORRUPT;
}
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
/**
@@ -333,18 +333,18 @@ __STATIC_INLINE psa_ps_status_t sst_mblock_validate_file_meta(
*
* \param[in] block_meta Pointer to block meta structure
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
__attribute__((always_inline))
-__STATIC_INLINE psa_ps_status_t sst_mblock_validate_block_meta(
+__STATIC_INLINE psa_status_t sst_mblock_validate_block_meta(
const struct sst_block_meta_t *block_meta)
{
- psa_ps_status_t err;
+ psa_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 PSA_PS_ERROR_DATA_CORRUPT;
+ return PSA_ERROR_DATA_CORRUPT;
}
/* Boundary check: block data start + free size can not be bigger
@@ -353,8 +353,8 @@ __STATIC_INLINE psa_ps_status_t sst_mblock_validate_block_meta(
err = sst_utils_check_contained_in(SST_BLOCK_SIZE,
block_meta->data_start,
block_meta->free_size);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_DATA_CORRUPT;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_DATA_CORRUPT;
}
if (block_meta->phy_id == SST_METADATA_BLOCK0 ||
@@ -368,10 +368,10 @@ __STATIC_INLINE psa_ps_status_t sst_mblock_validate_block_meta(
}
if (block_meta->data_start != valid_data_start_value) {
- return PSA_PS_ERROR_DATA_CORRUPT;
+ return PSA_ERROR_DATA_CORRUPT;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
#endif
@@ -382,20 +382,20 @@ __STATIC_INLINE psa_ps_status_t sst_mblock_validate_block_meta(
*/
static uint32_t sst_get_free_file_index(void)
{
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
+ if (err != PSA_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) != PSA_PS_SUCCESS) {
+ if (sst_utils_validate_fid(tmp_metadata.id) != PSA_SUCCESS) {
/* Found */
return i;
}
@@ -410,12 +410,12 @@ static uint32_t sst_get_free_file_index(void)
* \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 psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_mblock_update_scratch_file_meta(uint32_t idx,
+static psa_status_t sst_mblock_update_scratch_file_meta(uint32_t idx,
struct sst_file_meta_t *file_meta)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t pos;
uint32_t scratch_block;
@@ -431,9 +431,9 @@ static psa_ps_status_t sst_mblock_update_scratch_file_meta(uint32_t idx,
/**
* \brief Erases data and meta scratch blocks.
*/
-static psa_ps_status_t sst_mblock_erase_scratch_blocks(void)
+static psa_status_t sst_mblock_erase_scratch_blocks(void)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t scratch_datablock;
uint32_t scratch_metablock;
@@ -444,7 +444,7 @@ static psa_ps_status_t sst_mblock_erase_scratch_blocks(void)
* metadata scratch block is erased before data block.
*/
err = sst_flash_erase_block(scratch_metablock);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -469,12 +469,12 @@ static psa_ps_status_t sst_mblock_erase_scratch_blocks(void)
* \param[in] block_meta Pointer to the block metadata data to write in the
* scratch block
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_mblock_update_scratch_block_meta(uint32_t lblock,
+static psa_status_t sst_mblock_update_scratch_block_meta(uint32_t lblock,
struct sst_block_meta_t *block_meta)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t meta_block;
uint32_t pos;
@@ -491,12 +491,12 @@ static psa_ps_status_t sst_mblock_update_scratch_block_meta(uint32_t lblock,
*
* \param[in] lblock Logical block number to skip
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_mblock_copy_remaining_block_meta(uint32_t lblock)
+static psa_status_t sst_mblock_copy_remaining_block_meta(uint32_t lblock)
{
struct sst_block_meta_t block_meta;
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t meta_block;
uint32_t pos;
uint32_t scratch_block;
@@ -516,8 +516,8 @@ static psa_ps_status_t sst_mblock_copy_remaining_block_meta(uint32_t lblock)
*/
err = sst_flash_fs_mblock_read_block_metadata(SST_LOGICAL_DBLOCK0,
&block_meta);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Update physical ID for logical block 0 to match with the
@@ -526,8 +526,8 @@ static psa_ps_status_t sst_mblock_copy_remaining_block_meta(uint32_t lblock)
block_meta.phy_id = scratch_block;
err = sst_mblock_update_scratch_block_meta(SST_LOGICAL_DBLOCK0,
&block_meta);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Copy the rest of metadata blocks between logical block 0 and
@@ -542,7 +542,7 @@ static psa_ps_status_t sst_mblock_copy_remaining_block_meta(uint32_t lblock)
/* Data before updated content */
err = sst_flash_block_to_block_move(scratch_block, pos, meta_block,
pos, size);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
}
@@ -564,13 +564,12 @@ static psa_ps_status_t sst_mblock_copy_remaining_block_meta(uint32_t lblock)
*
* \param[in] swap_count Swap count to validate
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
__attribute__((always_inline))
-__STATIC_INLINE psa_ps_status_t sst_mblock_validate_swap_count(
- uint8_t swap_count)
+__STATIC_INLINE psa_status_t sst_mblock_validate_swap_count(uint8_t swap_count)
{
- psa_ps_status_t err = PSA_PS_SUCCESS;
+ psa_status_t err = PSA_SUCCESS;
/* When a flash block is erased, the default value
* is usually 0xFF (i.e. all 1s). Since the swap count
@@ -585,7 +584,7 @@ __STATIC_INLINE psa_ps_status_t sst_mblock_validate_swap_count(
* back to previous metablock instead.
*/
if (swap_count == SST_FLASH_DEFAULT_VAL) {
- err = PSA_PS_ERROR_OPERATION_FAILED;
+ err = PSA_ERROR_GENERIC_ERROR;
}
return err;
@@ -596,19 +595,18 @@ __STATIC_INLINE psa_ps_status_t sst_mblock_validate_swap_count(
*
* \param[in] fs_version File system version.
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
__attribute__((always_inline))
-__STATIC_INLINE psa_ps_status_t sst_mblock_validate_fs_version(
- uint8_t fs_version)
+__STATIC_INLINE psa_status_t sst_mblock_validate_fs_version(uint8_t fs_version)
{
- psa_ps_status_t err = PSA_PS_SUCCESS;
+ psa_status_t err = PSA_SUCCESS;
/* Looks for exact version number.
* FIXME: backward compatibility could be considered in future revisions.
*/
if (fs_version != SST_SUPPORTED_VERSION) {
- err = PSA_PS_ERROR_OPERATION_FAILED;
+ err = PSA_ERROR_GENERIC_ERROR;
}
return err;
@@ -621,15 +619,15 @@ __STATIC_INLINE psa_ps_status_t sst_mblock_validate_fs_version(
*
* \param[in] h_meta Pointer to metadata block header
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_mblock_validate_header_meta(
+static psa_status_t sst_mblock_validate_header_meta(
struct sst_metadata_block_header_t *h_meta)
{
- psa_ps_status_t err;
+ psa_status_t err;
err = sst_mblock_validate_fs_version(h_meta->fs_version);
- if (err == PSA_PS_SUCCESS) {
+ if (err == PSA_SUCCESS) {
err = sst_mblock_validate_swap_count(h_meta->active_swap_count);
}
@@ -639,11 +637,11 @@ static psa_ps_status_t sst_mblock_validate_header_meta(
/**
* \brief Writes the scratch metadata's header.
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_mblock_write_scratch_meta_header(void)
+static psa_status_t sst_mblock_write_scratch_meta_header(void)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t scratch_metablock;
scratch_metablock = sst_cur_meta_scratch_id();
@@ -653,7 +651,7 @@ static psa_ps_status_t sst_mblock_write_scratch_meta_header(void)
err = sst_mblock_validate_swap_count(
sst_flash_fs_ctx.meta_block_header.active_swap_count);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
/* Reset the swap count to 0 */
sst_flash_fs_ctx.meta_block_header.active_swap_count = 0;
}
@@ -669,16 +667,16 @@ static psa_ps_status_t sst_mblock_write_scratch_meta_header(void)
/**
* \brief Reads the active metadata block header into sst_system_ctx.
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_mblock_read_meta_header(void)
+static psa_status_t sst_mblock_read_meta_header(void)
{
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -695,19 +693,19 @@ static psa_ps_status_t sst_mblock_read_meta_header(void)
* \param[out] file_meta File metadata entry
* \param[out] block_meta Block metadata entry
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_mblock_reserve_file(uint32_t fid, uint32_t size,
+static psa_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)
{
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
if (block_meta->free_size >= size) {
@@ -720,23 +718,23 @@ static psa_ps_status_t sst_mblock_reserve_file(uint32_t fid, uint32_t size,
/* Update block metadata */
block_meta->free_size -= size;
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
}
/* No block has large enough space to fit the requested file */
- return PSA_PS_ERROR_INSUFFICIENT_SPACE;
+ return PSA_ERROR_INSUFFICIENT_STORAGE;
}
/**
* \brief Validates and find the valid-active metablock
*
- * \return Returns value as specified in \ref psa_ps_status_t
+ * \return Returns value as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_init_get_active_metablock(void)
+static psa_status_t sst_init_get_active_metablock(void)
{
uint32_t cur_meta_block = SST_BLOCK_INVALID_ID;
- psa_ps_status_t err;
+ psa_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;
@@ -746,13 +744,13 @@ static psa_ps_status_t sst_init_get_active_metablock(void)
/* 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 != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
err = sst_flash_read(SST_METADATA_BLOCK1, (uint8_t *)&h_meta1,
0, SST_BLOCK_META_HEADER_SIZE);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -761,12 +759,12 @@ static psa_ps_status_t sst_init_get_active_metablock(void)
* update operation to complete. Need to find out the valid
* metadata block now.
*/
- if (sst_mblock_validate_header_meta(&h_meta0) == PSA_PS_SUCCESS) {
+ if (sst_mblock_validate_header_meta(&h_meta0) == PSA_SUCCESS) {
num_valid_meta_blocks++;
cur_meta_block = SST_METADATA_BLOCK0;
}
- if (sst_mblock_validate_header_meta(&h_meta1) == PSA_PS_SUCCESS) {
+ if (sst_mblock_validate_header_meta(&h_meta1) == PSA_SUCCESS) {
num_valid_meta_blocks++;
cur_meta_block = SST_METADATA_BLOCK1;
}
@@ -778,18 +776,18 @@ static psa_ps_status_t sst_init_get_active_metablock(void)
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 PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
sst_flash_fs_ctx.active_metablock = cur_meta_block;
sst_flash_fs_ctx.scratch_metablock = SST_OTHER_META_BLOCK(cur_meta_block);
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_flash_fs_mblock_cp_remaining_file_meta(uint32_t idx)
+psa_status_t sst_flash_fs_mblock_cp_remaining_file_meta(uint32_t idx)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t end;
uint32_t meta_block;
uint32_t pos;
@@ -803,7 +801,7 @@ psa_ps_status_t sst_flash_fs_mblock_cp_remaining_file_meta(uint32_t idx)
/* Data before updated content */
err = sst_flash_block_to_block_move(scratch_block, pos, meta_block, pos,
(idx * SST_FILE_METADATA_SIZE));
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -832,47 +830,47 @@ uint32_t sst_flash_fs_mblock_cur_data_scratch_id(uint32_t lblock)
return sst_flash_fs_ctx.meta_block_header.scratch_dblock;
}
-psa_ps_status_t sst_flash_fs_mblock_get_file_idx(uint32_t fid, uint32_t *idx)
+psa_status_t sst_flash_fs_mblock_get_file_idx(uint32_t fid, uint32_t *idx)
{
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* ID with value 0x00 means end of file meta section */
if (tmp_metadata.id == fid) {
/* Found */
*idx = i;
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
}
- return PSA_PS_ERROR_UID_NOT_FOUND;
+ return PSA_ERROR_DOES_NOT_EXIST;
}
-psa_ps_status_t sst_flash_fs_mblock_init(void)
+psa_status_t sst_flash_fs_mblock_init(void)
{
- psa_ps_status_t err;
+ psa_status_t err;
/* Initialize Flash Interface */
err = sst_flash_init();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
err = sst_init_get_active_metablock();
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
err = sst_mblock_read_meta_header();
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Erase the other scratch metadata block */
@@ -881,13 +879,13 @@ psa_ps_status_t sst_flash_fs_mblock_init(void)
return err;
}
-psa_ps_status_t sst_flash_fs_mblock_meta_update_finalize(void)
+psa_status_t sst_flash_fs_mblock_meta_update_finalize(void)
{
- psa_ps_status_t err;
+ psa_status_t err;
/* Write the metadata block header to flash */
err = sst_mblock_write_scratch_meta_header();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -900,12 +898,12 @@ psa_ps_status_t sst_flash_fs_mblock_meta_update_finalize(void)
return err;
}
-psa_ps_status_t sst_flash_fs_mblock_migrate_lb0_data_to_scratch(void)
+psa_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;
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t scratch_metablock;
scratch_metablock = sst_cur_meta_scratch_id();
@@ -913,7 +911,7 @@ psa_ps_status_t sst_flash_fs_mblock_migrate_lb0_data_to_scratch(void)
err = sst_flash_fs_mblock_read_block_metadata(SST_LOGICAL_DBLOCK0,
&block_meta);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -929,10 +927,10 @@ psa_ps_status_t sst_flash_fs_mblock_migrate_lb0_data_to_scratch(void)
return err;
}
-psa_ps_status_t sst_flash_fs_mblock_read_file_meta(uint32_t idx,
+psa_status_t sst_flash_fs_mblock_read_file_meta(uint32_t idx,
struct sst_file_meta_t *file_meta)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t offset;
offset = sst_mblock_file_meta_offset(idx);
@@ -941,7 +939,7 @@ psa_ps_status_t sst_flash_fs_mblock_read_file_meta(uint32_t idx,
SST_FILE_METADATA_SIZE);
#ifdef SST_VALIDATE_METADATA_FROM_FLASH
- if (err == PSA_PS_SUCCESS) {
+ if (err == PSA_SUCCESS) {
err = sst_mblock_validate_file_meta(file_meta);
}
#endif
@@ -949,10 +947,10 @@ psa_ps_status_t sst_flash_fs_mblock_read_file_meta(uint32_t idx,
return err;
}
-psa_ps_status_t sst_flash_fs_mblock_read_block_metadata(uint32_t lblock,
+psa_status_t sst_flash_fs_mblock_read_block_metadata(uint32_t lblock,
struct sst_block_meta_t *block_meta)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t metablock;
uint32_t pos;
@@ -962,7 +960,7 @@ psa_ps_status_t sst_flash_fs_mblock_read_block_metadata(uint32_t lblock,
pos, SST_BLOCK_METADATA_SIZE);
#ifdef SST_VALIDATE_METADATA_FROM_FLASH
- if (err == PSA_PS_SUCCESS) {
+ if (err == PSA_SUCCESS) {
err = sst_mblock_validate_block_meta(block_meta);
}
#endif
@@ -970,28 +968,28 @@ psa_ps_status_t sst_flash_fs_mblock_read_block_metadata(uint32_t lblock,
return err;
}
-psa_ps_status_t sst_flash_fs_mblock_reserve_file(uint32_t fid, uint32_t size,
+psa_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)
{
- psa_ps_status_t err;
+ psa_status_t err;
err = sst_mblock_reserve_file(fid, size, file_meta, block_meta);
*idx = sst_get_free_file_index();
- if ((err != PSA_PS_SUCCESS) ||
+ if ((err != PSA_SUCCESS) ||
(*idx == SST_METADATA_INVALID_INDEX)) {
- return PSA_PS_ERROR_INSUFFICIENT_SPACE;
+ return PSA_ERROR_INSUFFICIENT_STORAGE;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_flash_fs_mblock_reset_metablock(void)
+psa_status_t sst_flash_fs_mblock_reset_metablock(void)
{
struct sst_block_meta_t block_meta;
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t i;
uint32_t metablock_to_erase_first = SST_METADATA_BLOCK0;
struct sst_file_meta_t file_metadata;
@@ -1000,17 +998,17 @@ psa_ps_status_t sst_flash_fs_mblock_reset_metablock(void)
* 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() == PSA_PS_SUCCESS) {
+ if (sst_init_get_active_metablock() == PSA_SUCCESS) {
metablock_to_erase_first = sst_flash_fs_ctx.scratch_metablock;
}
err = sst_flash_erase_block(metablock_to_erase_first);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
err = sst_flash_erase_block(SST_OTHER_META_BLOCK(metablock_to_erase_first));
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -1029,7 +1027,7 @@ psa_ps_status_t sst_flash_fs_mblock_reset_metablock(void)
block_meta.phy_id = SST_METADATA_BLOCK0;
err = sst_mblock_update_scratch_block_meta(SST_LOGICAL_DBLOCK0,
&block_meta);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -1050,15 +1048,15 @@ psa_ps_status_t sst_flash_fs_mblock_reset_metablock(void)
/* If an error is detected while erasing the flash, then return a
* system error to abort core wipe process.
*/
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_STORAGE_FAILURE;
+ if (err != PSA_SUCCESS) {
+ return PSA_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 != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
}
@@ -1069,20 +1067,20 @@ psa_ps_status_t sst_flash_fs_mblock_reset_metablock(void)
/* 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 != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
}
err = sst_mblock_write_scratch_meta_header();
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Swap active and scratch metablocks */
sst_mblock_swap_metablocks();
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
void sst_flash_fs_mblock_set_data_scratch(uint32_t phy_id, uint32_t lblock)
@@ -1092,11 +1090,11 @@ void sst_flash_fs_mblock_set_data_scratch(uint32_t phy_id, uint32_t lblock)
}
}
-psa_ps_status_t sst_flash_fs_mblock_update_scratch_block_meta(
+psa_status_t sst_flash_fs_mblock_update_scratch_block_meta(
uint32_t lblock,
struct sst_block_meta_t *block_meta)
{
- psa_ps_status_t err;
+ psa_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
@@ -1107,8 +1105,8 @@ psa_ps_status_t sst_flash_fs_mblock_update_scratch_block_meta(
}
err = sst_mblock_update_scratch_block_meta(lblock, block_meta);
- if (err != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
err = sst_mblock_copy_remaining_block_meta(lblock);
@@ -1116,7 +1114,7 @@ psa_ps_status_t sst_flash_fs_mblock_update_scratch_block_meta(
return err;
}
-psa_ps_status_t sst_flash_fs_mblock_update_scratch_file_meta(uint32_t idx,
+psa_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 bee15f9dd..c634081cb 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -75,9 +75,9 @@ extern "C" {
/**
* \brief Initializes metadata block with the valid/active metablock.
*
- * \return Returns value as specified in \ref psa_ps_status_t
+ * \return Returns value as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_mblock_init(void);
+psa_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 @@ psa_ps_status_t sst_flash_fs_mblock_init(void);
*
* \param[in] idx File metadata entry index to skip
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_mblock_cp_remaining_file_meta(uint32_t idx);
+psa_status_t sst_flash_fs_mblock_cp_remaining_file_meta(uint32_t idx);
/**
* \brief Gets current scratch datablock physical ID.
@@ -104,9 +104,9 @@ uint32_t sst_flash_fs_mblock_cur_data_scratch_id(uint32_t lblock);
* \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 psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_mblock_get_file_idx(uint32_t fid, uint32_t *idx);
+psa_status_t sst_flash_fs_mblock_get_file_idx(uint32_t fid, uint32_t *idx);
/**
* \brief Finalizes an update operation.
@@ -114,7 +114,7 @@ psa_ps_status_t sst_flash_fs_mblock_get_file_idx(uint32_t fid, uint32_t *idx);
*
* \return Returns offset value in metadata block
*/
-psa_ps_status_t sst_flash_fs_mblock_meta_update_finalize(void);
+psa_status_t sst_flash_fs_mblock_meta_update_finalize(void);
/**
* \brief Writes the files data area of logical block 0 into the scratch
@@ -126,9 +126,9 @@ psa_ps_status_t sst_flash_fs_mblock_meta_update_finalize(void);
* 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 psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_mblock_migrate_lb0_data_to_scratch(void);
+psa_status_t sst_flash_fs_mblock_migrate_lb0_data_to_scratch(void);
/**
* \brief Reads specified file metadata.
@@ -136,9 +136,9 @@ psa_ps_status_t sst_flash_fs_mblock_migrate_lb0_data_to_scratch(void);
* \param[in] idx File metadata entry index
* \param[out] file_meta Pointer to file meta structure
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_mblock_read_file_meta(uint32_t idx,
+psa_status_t sst_flash_fs_mblock_read_file_meta(uint32_t idx,
struct sst_file_meta_t *file_meta);
/**
@@ -147,9 +147,9 @@ psa_ps_status_t sst_flash_fs_mblock_read_file_meta(uint32_t idx,
* \param[in] lblock Logical block number
* \param[out] block_meta Pointer to block meta structure
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_mblock_read_block_metadata(uint32_t lblock,
+psa_status_t sst_flash_fs_mblock_read_block_metadata(uint32_t lblock,
struct sst_block_meta_t *block_meta);
/**
@@ -161,9 +161,9 @@ psa_ps_status_t sst_flash_fs_mblock_read_block_metadata(uint32_t lblock,
* \param[out] file_meta File metadata entry
* \param[out] block_meta Block metadata entry
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_mblock_reserve_file(uint32_t file_id,
+psa_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,
@@ -172,9 +172,9 @@ psa_ps_status_t sst_flash_fs_mblock_reserve_file(uint32_t file_id,
/**
* \brief Resets metablock by cleaning and initializing the metadatablock.
*
- * \return Returns value as specified in \ref psa_ps_status_t
+ * \return Returns value as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_mblock_reset_metablock(void);
+psa_status_t sst_flash_fs_mblock_reset_metablock(void);
/**
* \brief Sets current data scratch block
@@ -190,9 +190,9 @@ void sst_flash_fs_mblock_set_data_scratch(uint32_t phy_id, uint32_t lblock);
* \param[in] lblock Logical block number
* \param[in] block_meta Pointer to block's metadata
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_mblock_update_scratch_block_meta(
+psa_status_t sst_flash_fs_mblock_update_scratch_block_meta(
uint32_t lblock,
struct sst_block_meta_t *block_meta);
@@ -202,9 +202,9 @@ psa_ps_status_t sst_flash_fs_mblock_update_scratch_block_meta(
* \param[in] idx File's index in the metadata table
* \param[in] file_meta Metadata pointer
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_flash_fs_mblock_update_scratch_file_meta(uint32_t idx,
+psa_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 df97c03d4..6d49efa86 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -7,33 +7,33 @@
#include "sst_nv_counters.h"
-psa_ps_status_t sst_init_nv_counter(void)
+psa_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 PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
- uint32_t *val)
+psa_status_t sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
+ uint32_t *val)
{
enum tfm_plat_err_t err;
err = tfm_plat_read_nv_counter(counter_id, SST_NV_COUNTER_SIZE,
(uint8_t *)val);
if (err != TFM_PLAT_ERR_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_increment_nv_counter(enum tfm_nv_counter_t counter_id)
+psa_status_t sst_increment_nv_counter(enum tfm_nv_counter_t counter_id)
{
enum tfm_plat_err_t err;
@@ -45,8 +45,8 @@ psa_ps_status_t sst_increment_nv_counter(enum tfm_nv_counter_t counter_id)
*/
err = tfm_plat_increment_nv_counter(counter_id);
if (err != TFM_PLAT_ERR_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- return PSA_PS_SUCCESS;
+ return PSA_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 2c3bfc185..344841385 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -33,10 +33,10 @@ extern "C" {
/**
* \brief Initializes all non-volatile (NV) counters.
*
- * \return PSA_PS_SUCCESS if the initialization succeeds, otherwise
- * PSA_PS_ERROR_OPERATION_FAILED
+ * \return PSA_SUCCESS if the initialization succeeds, otherwise
+ * PSA_ERROR_GENERIC_ERROR
*/
-psa_ps_status_t sst_init_nv_counter(void);
+psa_status_t sst_init_nv_counter(void);
/**
* \brief Reads the given non-volatile (NV) counter.
@@ -44,11 +44,11 @@ psa_ps_status_t sst_init_nv_counter(void);
* \param[in] counter_id NV counter ID.
* \param[out] val Pointer to store the current NV counter value.
*
- * \return PSA_PS_SUCCESS if the value is read correctly, otherwise
- * PSA_PS_ERROR_OPERATION_FAILED
+ * \return PSA_SUCCESS if the value is read correctly, otherwise
+ * PSA_ERROR_GENERIC_ERROR
*/
-psa_ps_status_t sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
- uint32_t *val);
+psa_status_t sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
+ uint32_t *val);
/**
* \brief Increments the given non-volatile (NV) counter.
@@ -56,9 +56,9 @@ psa_ps_status_t sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
* \param[in] counter_id NV counter ID.
*
* \return If the counter is incremented correctly, it returns
- * PSA_PS_SUCCESS. Otherwise, PSA_PS_ERROR_OPERATION_FAILED.
+ * PSA_SUCCESS. Otherwise, PSA_ERROR_GENERIC_ERROR.
*/
-psa_ps_status_t sst_increment_nv_counter(enum tfm_nv_counter_t counter_id);
+psa_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 0383ba451..f147ddfa3 100644
--- a/secure_fw/services/secure_storage/sst_encrypted_object.c
+++ b/secure_fw/services/secure_storage/sst_encrypted_object.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -46,18 +46,18 @@ static uint8_t sst_crypto_buf[SST_CRYPTO_BUF_LEN];
* is the one stored in the object table for the given
* File ID.
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_object_auth_decrypt(uint32_t fid,
- uint32_t cur_size,
- struct sst_object_t *obj)
+static psa_status_t sst_object_auth_decrypt(uint32_t fid,
+ uint32_t cur_size,
+ struct sst_object_t *obj)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint8_t *p_obj_data = (uint8_t *)&obj->header.info;
size_t out_len;
err = sst_crypto_setkey();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -76,9 +76,9 @@ static psa_ps_status_t sst_object_auth_decrypt(uint32_t fid,
p_obj_data,
sizeof(*obj) - sizeof(obj->header.crypto),
&out_len);
- if (err != PSA_PS_SUCCESS || out_len != cur_size) {
+ if (err != PSA_SUCCESS || out_len != cur_size) {
(void)sst_crypto_destroykey();
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
return sst_crypto_destroykey();
@@ -93,18 +93,18 @@ static psa_ps_status_t sst_object_auth_decrypt(uint32_t fid,
* \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 psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_object_auth_encrypt(uint32_t fid,
- uint32_t cur_size,
- struct sst_object_t *obj)
+static psa_status_t sst_object_auth_encrypt(uint32_t fid,
+ uint32_t cur_size,
+ struct sst_object_t *obj)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint8_t *p_obj_data = (uint8_t *)&obj->header.info;
size_t out_len;
err = sst_crypto_setkey();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -125,9 +125,9 @@ static psa_ps_status_t sst_object_auth_encrypt(uint32_t fid,
sst_crypto_buf,
sizeof(sst_crypto_buf),
&out_len);
- if (err != PSA_PS_SUCCESS || out_len != cur_size) {
+ if (err != PSA_SUCCESS || out_len != cur_size) {
(void)sst_crypto_destroykey();
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
(void)tfm_memcpy(p_obj_data, sst_crypto_buf, cur_size);
@@ -135,16 +135,15 @@ static psa_ps_status_t sst_object_auth_encrypt(uint32_t fid,
return sst_crypto_destroykey();
}
-psa_ps_status_t sst_encrypted_object_read(uint32_t fid,
- struct sst_object_t *obj)
+psa_status_t sst_encrypted_object_read(uint32_t fid, struct sst_object_t *obj)
{
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -152,7 +151,7 @@ psa_ps_status_t sst_encrypted_object_read(uint32_t fid,
err = sst_flash_fs_file_read(fid, file_info.size_current,
SST_OBJECT_START_POSITION,
obj->header.crypto.ref.iv);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -162,17 +161,16 @@ psa_ps_status_t sst_encrypted_object_read(uint32_t fid,
/* Decrypt the object data */
err = sst_object_auth_decrypt(fid, decrypt_size, obj);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_encrypted_object_write(uint32_t fid,
- struct sst_object_t *obj)
+psa_status_t sst_encrypted_object_write(uint32_t fid, struct sst_object_t *obj)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t wrt_size;
wrt_size = SST_ENCRYPT_SIZE(obj->header.info.max_size) +
@@ -190,7 +188,7 @@ psa_ps_status_t sst_encrypted_object_write(uint32_t fid,
/* Create an object in the object system */
err = sst_flash_fs_file_create(fid, wrt_size, SST_EMPTY_OBJECT_SIZE, NULL);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -199,7 +197,7 @@ psa_ps_status_t sst_encrypted_object_write(uint32_t fid,
/* Authenticate and encrypt the object */
err = sst_object_auth_encrypt(fid, wrt_size, obj);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_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 ce72f1627..eed82aff9 100644
--- a/secure_fw/services/secure_storage/sst_encrypted_object.h
+++ b/secure_fw/services/secure_storage/sst_encrypted_object.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -22,10 +22,10 @@ extern "C" {
* \param[in] fid File ID
* \param[out] obj Pointer to the object structure to fill in
*
- * \return Returns error code specified in \ref psa_ps_status_t
+ * \return Returns error code specified in \ref psa_status_t
*/
-psa_ps_status_t sst_encrypted_object_read(uint32_t fid,
- struct sst_object_t *obj);
+psa_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 @@ psa_ps_status_t sst_encrypted_object_read(uint32_t fid,
* internal copies. So, this object will contain the encrypted object
* stored in the flash.
*
- * \return Returns error code specified in \ref psa_ps_status_t
+ * \return Returns error code specified in \ref psa_status_t
*/
-psa_ps_status_t sst_encrypted_object_write(uint32_t fid,
- struct sst_object_t *obj);
+psa_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_defs.h b/secure_fw/services/secure_storage/sst_object_defs.h
index 56aedf249..0a65bc2e6 100644
--- a/secure_fw/services/secure_storage/sst_object_defs.h
+++ b/secure_fw/services/secure_storage/sst_object_defs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -26,7 +26,7 @@
struct sst_object_info_t {
uint32_t current_size; /*!< Current size of the object content in bytes */
uint32_t max_size; /*!< Maximum size of the object content in bytes */
- psa_ps_create_flags_t create_flags; /*!< Object creation flags */
+ psa_storage_create_flags_t create_flags; /*!< Object creation flags */
};
/*!
diff --git a/secure_fw/services/secure_storage/sst_object_system.c b/secure_fw/services/secure_storage/sst_object_system.c
index 833fee300..c4bc527b4 100644
--- a/secure_fw/services/secure_storage/sst_object_system.c
+++ b/secure_fw/services/secure_storage/sst_object_system.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -39,9 +39,10 @@ static struct sst_obj_table_info_t g_obj_tbl_info;
*
*/
__attribute__ ((always_inline))
-__STATIC_INLINE void sst_init_empty_object(psa_ps_create_flags_t create_flags,
- uint32_t size,
- struct sst_object_t *obj)
+__STATIC_INLINE void sst_init_empty_object(
+ psa_storage_create_flags_t create_flags,
+ uint32_t size,
+ struct sst_object_t *obj)
{
/* Set all object data to 0 */
(void)tfm_memset(obj, SST_DEFAULT_EMPTY_BUFF_VAL, SST_MAX_OBJECT_SIZE);
@@ -61,15 +62,15 @@ __STATIC_INLINE void sst_init_empty_object(psa_ps_create_flags_t create_flags,
*
* \param[in] old_fid Old file ID to remove.
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_remove_old_data(uint32_t old_fid)
+static psa_status_t sst_remove_old_data(uint32_t old_fid)
{
- psa_ps_status_t err;
+ psa_status_t err;
/* Delete old object table from the persistent area */
err = sst_object_table_delete_old_table();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -91,17 +92,17 @@ enum read_type_t {
*
* \param[in] type Read type as specified in \ref read_type_t
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_read_object(enum read_type_t type)
+static psa_status_t sst_read_object(enum read_type_t type)
{
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -110,7 +111,7 @@ static psa_ps_status_t sst_read_object(enum read_type_t type)
*/
if (g_sst_object.header.fid != g_obj_tbl_info.fid ||
g_sst_object.header.version != g_obj_tbl_info.version) {
- err = PSA_PS_ERROR_DATA_CORRUPT;
+ err = PSA_ERROR_DATA_CORRUPT;
}
if (type == READ_ALL_OBJECT) {
@@ -120,7 +121,7 @@ static psa_ps_status_t sst_read_object(enum read_type_t type)
g_sst_object.header.info.current_size,
SST_OBJECT_HEADER_SIZE,
g_sst_object.data);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
}
@@ -135,11 +136,11 @@ static psa_ps_status_t sst_read_object(enum read_type_t type)
*
* \param[in] wrt_size Number of bytes to write
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_write_object(uint32_t wrt_size)
+static psa_status_t sst_write_object(uint32_t wrt_size)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t max_size = SST_OBJECT_SIZE(g_sst_object.header.info.max_size);
/* Add object identification and increase object version */
@@ -158,12 +159,12 @@ static psa_ps_status_t sst_write_object(uint32_t wrt_size)
#endif /* !SST_ENCRYPTION */
-psa_ps_status_t sst_system_prepare(void)
+psa_status_t sst_system_prepare(void)
{
- psa_ps_status_t err;
+ psa_status_t err;
err = sst_flash_fs_prepare();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -181,16 +182,17 @@ psa_ps_status_t sst_system_prepare(void)
return err;
}
-psa_ps_status_t sst_object_read(psa_ps_uid_t uid, int32_t client_id,
- uint32_t offset, uint32_t size)
+psa_status_t sst_object_read(psa_storage_uid_t uid, int32_t client_id,
+ uint32_t offset, uint32_t size,
+ size_t* p_data_length)
{
- psa_ps_status_t err;
+ psa_status_t err;
/* Retrieve the object information from the object table if the object
* exists.
*/
err = sst_object_table_get_obj_tbl_info(uid, client_id, &g_obj_tbl_info);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -201,20 +203,24 @@ psa_ps_status_t sst_object_read(psa_ps_uid_t uid, int32_t client_id,
/* Read object header */
err = sst_read_object(READ_ALL_OBJECT);
#endif
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
/* Boundary check the incoming request */
- err = sst_utils_check_contained_in(g_sst_object.header.info.current_size,
- offset, size);
- if (err != PSA_PS_SUCCESS) {
- goto clear_data_and_return;
+ if (offset > g_sst_object.header.info.current_size) {
+ err = PSA_ERROR_INVALID_ARGUMENT;
+ goto clear_data_and_return;
}
+ size = SST_UTILS_MIN(size,
+ g_sst_object.header.info.current_size - offset);
+
/* Copy the decrypted object data to the output buffer */
sst_req_mngr_write_asset_data(g_sst_object.data + offset, size);
+ *p_data_length = size;
+
clear_data_and_return:
/* Remove data stored in the object before leaving the function */
(void)tfm_memset(&g_sst_object, SST_DEFAULT_EMPTY_BUFF_VAL,
@@ -223,11 +229,11 @@ clear_data_and_return:
return err;
}
-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)
+psa_status_t sst_object_create(psa_storage_uid_t uid, int32_t client_id,
+ psa_storage_create_flags_t create_flags,
+ uint32_t size)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t old_fid = SST_INVALID_FID;
uint32_t fid_am_reserved = 1;
@@ -237,14 +243,14 @@ psa_ps_status_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
/* Boundary check the incoming request */
if (size > SST_MAX_ASSET_SIZE) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_INVALID_ARGUMENT;
}
/* Retrieve the object information from the object table if the object
* exists.
*/
err = sst_object_table_get_obj_tbl_info(uid, client_id, &g_obj_tbl_info);
- if (err == PSA_PS_SUCCESS) {
+ if (err == PSA_SUCCESS) {
#ifdef SST_ENCRYPTION
/* Read the object */
err = sst_encrypted_object_read(g_obj_tbl_info.fid, &g_sst_object);
@@ -252,7 +258,7 @@ psa_ps_status_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
/* Read the object header */
err = sst_read_object(READ_HEADER_ONLY);
#endif
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
@@ -260,8 +266,8 @@ psa_ps_status_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
* be modified.
*/
if (g_sst_object.header.info.create_flags
- & PSA_PS_FLAG_WRITE_ONCE) {
- err = PSA_PS_ERROR_WRITE_ONCE;
+ & PSA_STORAGE_FLAG_WRITE_ONCE) {
+ err = PSA_ERROR_NOT_PERMITTED;
goto clear_data_and_return;
}
@@ -271,7 +277,7 @@ psa_ps_status_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
/* Save old file ID */
old_fid = g_obj_tbl_info.fid;
- } else if (err == PSA_PS_ERROR_UID_NOT_FOUND) {
+ } else if (err == PSA_ERROR_DOES_NOT_EXIST) {
/* If the object does not exist, then initialize it based on the input
* arguments and empty content. Requests 2 FIDs to prevent exhaustion.
*/
@@ -283,7 +289,7 @@ psa_ps_status_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
/* Update the object data */
err = sst_req_mngr_read_asset_data(g_sst_object.data, size);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
@@ -293,7 +299,7 @@ psa_ps_status_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
/* Get new file ID */
err = sst_object_table_get_free_fid(fid_am_reserved,
&g_obj_tbl_info.fid);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
@@ -305,7 +311,7 @@ psa_ps_status_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
/* Write g_sst_object */
err = sst_write_object(wrt_size);
#endif
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
@@ -313,7 +319,7 @@ psa_ps_status_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
* store it in the persistent area.
*/
err = sst_object_table_set_obj_tbl_info(uid, client_id, &g_obj_tbl_info);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
/* Remove new object as object table is not persistent and propagate
* object table manipulation error.
*/
@@ -338,10 +344,10 @@ clear_data_and_return:
return err;
}
-psa_ps_status_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
- uint32_t offset, uint32_t size)
+psa_status_t sst_object_write(psa_storage_uid_t uid, int32_t client_id,
+ uint32_t offset, uint32_t size)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t old_fid;
#ifndef SST_ENCRYPTION
@@ -352,7 +358,7 @@ psa_ps_status_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
* exists.
*/
err = sst_object_table_get_obj_tbl_info(uid, client_id, &g_obj_tbl_info);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -362,13 +368,13 @@ psa_ps_status_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
#else
err = sst_read_object(READ_ALL_OBJECT);
#endif
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
/* If the object has the write once flag set, then it cannot be modified. */
- if (g_sst_object.header.info.create_flags & PSA_PS_FLAG_WRITE_ONCE) {
- err = PSA_PS_ERROR_WRITE_ONCE;
+ if (g_sst_object.header.info.create_flags & PSA_STORAGE_FLAG_WRITE_ONCE) {
+ err = PSA_ERROR_NOT_PERMITTED;
goto clear_data_and_return;
}
@@ -376,20 +382,20 @@ psa_ps_status_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
* being created in the object data.
*/
if (offset > g_sst_object.header.info.current_size) {
- err = PSA_PS_ERROR_OFFSET_INVALID;
+ err = PSA_ERROR_INVALID_ARGUMENT;
goto clear_data_and_return;
}
/* Boundary check the incoming request */
err = sst_utils_check_contained_in(g_sst_object.header.info.max_size,
offset, size);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
/* Update the object data */
err = sst_req_mngr_read_asset_data(g_sst_object.data + offset, size);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
@@ -403,7 +409,7 @@ psa_ps_status_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
/* Get new file ID */
err = sst_object_table_get_free_fid(1, &g_obj_tbl_info.fid);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
@@ -415,7 +421,7 @@ psa_ps_status_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
/* Write g_sst_object */
err = sst_write_object(wrt_size);
#endif
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
@@ -423,7 +429,7 @@ psa_ps_status_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
* store it in the persistent area.
*/
err = sst_object_table_set_obj_tbl_info(uid, client_id, &g_obj_tbl_info);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
/* Remove new object as object table is not persistent and propagate
* object table manipulation error.
*/
@@ -443,16 +449,16 @@ clear_data_and_return:
return err;
}
-psa_ps_status_t sst_object_get_info(psa_ps_uid_t uid, int32_t client_id,
- struct psa_ps_info_t *info)
+psa_status_t sst_object_get_info(psa_storage_uid_t uid, int32_t client_id,
+ struct psa_storage_info_t *info)
{
- psa_ps_status_t err;
+ psa_status_t err;
/* Retrieve the object information from the object table if the object
* exists.
*/
err = sst_object_table_get_obj_tbl_info(uid, client_id, &g_obj_tbl_info);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -461,7 +467,7 @@ psa_ps_status_t sst_object_get_info(psa_ps_uid_t uid, int32_t client_id,
#else
err = sst_read_object(READ_HEADER_ONLY);
#endif
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
@@ -477,15 +483,15 @@ clear_data_and_return:
return err;
}
-psa_ps_status_t sst_object_delete(psa_ps_uid_t uid, int32_t client_id)
+psa_status_t sst_object_delete(psa_storage_uid_t uid, int32_t client_id)
{
- psa_ps_status_t err;
+ psa_status_t err;
/* Retrieve the object information from the object table if the object
* exists.
*/
err = sst_object_table_get_obj_tbl_info(uid, client_id, &g_obj_tbl_info);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -494,13 +500,13 @@ psa_ps_status_t sst_object_delete(psa_ps_uid_t uid, int32_t client_id)
#else
err = sst_read_object(READ_HEADER_ONLY);
#endif
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_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 = PSA_PS_ERROR_WRITE_ONCE;
+ if (g_sst_object.header.info.create_flags & PSA_STORAGE_FLAG_WRITE_ONCE) {
+ err = PSA_ERROR_NOT_PERMITTED;
goto clear_data_and_return;
}
@@ -508,7 +514,7 @@ psa_ps_status_t sst_object_delete(psa_ps_uid_t uid, int32_t client_id)
* area.
*/
err = sst_object_table_delete_object(uid, client_id);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
@@ -523,9 +529,9 @@ clear_data_and_return:
return err;
}
-psa_ps_status_t sst_system_wipe_all(void)
+psa_status_t sst_system_wipe_all(void)
{
- psa_ps_status_t err;
+ psa_status_t err;
/* This function may get called as a corrective action
* if a system level security violation is detected.
@@ -535,12 +541,12 @@ psa_ps_status_t sst_system_wipe_all(void)
* moves to erasing the flash instead.
*/
err = sst_flash_fs_wipe_all();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
err = sst_flash_fs_prepare();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_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 b6e677c6d..80ac10dce 100644
--- a/secure_fw/services/secure_storage/sst_object_system.h
+++ b/secure_fw/services/secure_storage/sst_object_system.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -21,9 +21,9 @@ extern "C" {
* structures.
* It identifies and validates the system metadata.
*
- * \return Returns error code specified in \ref psa_ps_status_t
+ * \return Returns error code specified in \ref psa_status_t
*/
-psa_ps_status_t sst_system_prepare(void);
+psa_status_t sst_system_prepare(void);
/**
* \brief Creates a new object with the provided UID and client ID.
@@ -33,11 +33,11 @@ psa_ps_status_t sst_system_prepare(void);
* \param[in] create_flags Flags indicating the properties of the data
* \param[in] size Size of the contents of `data` in bytes
*
- * \return Returns error code specified in \ref psa_ps_status_t
+ * \return Returns error code specified in \ref psa_status_t
*/
-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);
+psa_status_t sst_object_create(psa_storage_uid_t uid, int32_t client_id,
+ psa_storage_create_flags_t create_flags,
+ uint32_t size);
/**
* \brief Gets the data of the object with the provided UID and client ID.
@@ -47,10 +47,11 @@ psa_ps_status_t sst_object_create(psa_ps_uid_t uid, int32_t client_id,
* \param[in] offset Offset in the object at which to begin the read
* \param[in] size Size of the contents of `data` in bytes
*
- * \return Returns error code specified in \ref psa_ps_status_t
+ * \return Returns error code specified in \ref psa_status_t
*/
-psa_ps_status_t sst_object_read(psa_ps_uid_t uid, int32_t client_id,
- uint32_t offset, uint32_t size);
+psa_status_t sst_object_read(psa_storage_uid_t uid, int32_t client_id,
+ uint32_t offset, uint32_t size,
+ size_t* p_data_length);
/**
* \brief Writes data into the object with the provided UID and client ID.
@@ -60,10 +61,10 @@ psa_ps_status_t sst_object_read(psa_ps_uid_t uid, int32_t client_id,
* \param[in] offset Offset in the object at which to begin the write
* \param[in] size Size of the contents of `data` in bytes
*
- * \return Returns error code specified in \ref psa_ps_status_t
+ * \return Returns error code specified in \ref psa_status_t
*/
-psa_ps_status_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
- uint32_t offset, uint32_t size);
+psa_status_t sst_object_write(psa_storage_uid_t uid, int32_t client_id,
+ uint32_t offset, uint32_t size);
/**
* \brief Deletes the object with the provided UID and client ID.
@@ -71,9 +72,9 @@ psa_ps_status_t sst_object_write(psa_ps_uid_t uid, int32_t client_id,
* \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 psa_ps_status_t
+ * \return Returns error code specified in \ref psa_status_t
*/
-psa_ps_status_t sst_object_delete(psa_ps_uid_t uid, int32_t client_id);
+psa_status_t sst_object_delete(psa_storage_uid_t uid, int32_t client_id);
/**
* \brief Gets the asset information for the object with the provided UID and
@@ -81,20 +82,20 @@ psa_ps_status_t sst_object_delete(psa_ps_uid_t uid, int32_t client_id);
*
* \param[in] uid Unique identifier for the data
* \param[in] client_id Identifier of the asset's owner (client)
- * \param[out] info Pointer to the `psa_ps_info_t` struct that will be
- * populated with the metadata
+ * \param[out] info Pointer to the `psa_storage_info_t` struct that will
+ * be populated with the metadata
*
- * \return Returns error code specified in \ref psa_ps_status_t
+ * \return Returns error code specified in \ref psa_status_t
*/
-psa_ps_status_t sst_object_get_info(psa_ps_uid_t uid, int32_t client_id,
- struct psa_ps_info_t *info);
+psa_status_t sst_object_get_info(psa_storage_uid_t uid, int32_t client_id,
+ struct psa_storage_info_t *info);
/**
* \brief Wipes the secure storage system and all object data.
*
- * \return Returns error code specified in \ref psa_ps_status_t
+ * \return Returns error code specified in \ref psa_status_t
*/
-psa_ps_status_t sst_system_wipe_all(void);
+psa_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 3c13b4451..fe24b3d54 100644
--- a/secure_fw/services/secure_storage/sst_object_table.c
+++ b/secure_fw/services/secure_storage/sst_object_table.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -36,7 +36,7 @@ struct sst_obj_table_entry_t {
#else
uint32_t version; /*!< File version */
#endif
- psa_ps_uid_t uid; /*!< Object UID */
+ psa_storage_uid_t uid; /*!< Object UID */
int32_t client_id; /*!< Client ID */
};
@@ -215,7 +215,7 @@ __attribute__ ((always_inline))
__STATIC_INLINE void sst_object_table_fs_read_table(
struct sst_obj_table_init_ctx_t *init_ctx)
{
- psa_ps_status_t err;
+ psa_status_t err;
/* FIXME: Read table from a persistent memory (flash location or FS) */
/* Read file with the table 0 data */
@@ -223,7 +223,7 @@ __STATIC_INLINE void sst_object_table_fs_read_table(
SST_OBJ_TABLE_SIZE,
SST_OBJECT_TABLE_OBJECT_OFFSET,
(uint8_t *)init_ctx->p_table[SST_OBJ_TABLE_IDX_0]);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
init_ctx->table_state[SST_OBJ_TABLE_IDX_0] = SST_OBJ_TABLE_INVALID;
}
@@ -232,7 +232,7 @@ __STATIC_INLINE void sst_object_table_fs_read_table(
SST_OBJ_TABLE_SIZE,
SST_OBJECT_TABLE_OBJECT_OFFSET,
(uint8_t *)init_ctx->p_table[SST_OBJ_TABLE_IDX_1]);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
init_ctx->table_state[SST_OBJ_TABLE_IDX_1] = SST_OBJ_TABLE_INVALID;
}
}
@@ -243,13 +243,13 @@ __STATIC_INLINE void sst_object_table_fs_read_table(
* \param[in,out] obj_table Pointer to the object table to generate
* authentication
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
__attribute__ ((always_inline))
-__STATIC_INLINE psa_ps_status_t sst_object_table_fs_write_table(
+__STATIC_INLINE psa_status_t sst_object_table_fs_write_table(
struct sst_obj_table_t *obj_table)
{
- psa_ps_status_t err;
+ psa_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;
@@ -259,7 +259,7 @@ __STATIC_INLINE psa_ps_status_t sst_object_table_fs_write_table(
SST_OBJ_TABLE_SIZE,
SST_OBJ_TABLE_SIZE,
(const uint8_t *)obj_table);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -267,7 +267,7 @@ __STATIC_INLINE psa_ps_status_t sst_object_table_fs_write_table(
sst_obj_table_ctx.scratch_table = sst_obj_table_ctx.active_table;
sst_obj_table_ctx.active_table = swap_table_idxs;
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
#ifdef SST_ENCRYPTION
@@ -277,40 +277,40 @@ __STATIC_INLINE psa_ps_status_t sst_object_table_fs_write_table(
*
* \param[in] nvc_1 Value of SST non-volatile counter 1
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_object_table_align_nv_counters(uint32_t nvc_1)
+static psa_status_t sst_object_table_align_nv_counters(uint32_t nvc_1)
{
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
for (; nvc_x_val < nvc_1; nvc_x_val++) {
err = sst_increment_nv_counter(TFM_SST_NV_COUNTER_2);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_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 != PSA_PS_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
for (; nvc_x_val < nvc_1; nvc_x_val++) {
err = sst_increment_nv_counter(TFM_SST_NV_COUNTER_3);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
/**
@@ -320,10 +320,10 @@ static psa_ps_status_t sst_object_table_align_nv_counters(uint32_t nvc_1)
* \param[in,out] obj_table Pointer to the object table to generate
* authentication
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
__attribute__ ((always_inline))
-__STATIC_INLINE psa_ps_status_t sst_object_table_nvc_generate_auth_tag(
+__STATIC_INLINE psa_status_t sst_object_table_nvc_generate_auth_tag(
uint32_t nvc_1,
struct sst_obj_table_t *obj_table)
{
@@ -354,7 +354,7 @@ static void sst_object_table_authenticate(uint8_t table_idx,
{
struct sst_crypto_assoc_data_t assoc_data;
union sst_crypto_t *crypto = &init_ctx->p_table[table_idx]->crypto;
- psa_ps_status_t err;
+ psa_status_t err;
/* Init associated data with NVC 1 */
assoc_data.nv_counter = init_ctx->nvc_1;
@@ -364,7 +364,7 @@ static void sst_object_table_authenticate(uint8_t table_idx,
err = sst_crypto_authenticate(crypto, (const uint8_t *)&assoc_data,
SST_CRYPTO_ASSOCIATED_DATA_LEN);
- if (err == PSA_PS_SUCCESS) {
+ if (err == PSA_SUCCESS) {
init_ctx->table_state[table_idx] = SST_OBJ_TABLE_NVC_1_VALID;
return;
}
@@ -379,7 +379,7 @@ static void sst_object_table_authenticate(uint8_t table_idx,
err = sst_crypto_authenticate(crypto, (const uint8_t *)&assoc_data,
SST_CRYPTO_ASSOCIATED_DATA_LEN);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
init_ctx->table_state[table_idx] = SST_OBJ_TABLE_INVALID;
} else {
init_ctx->table_state[table_idx] = SST_OBJ_TABLE_NVC_3_VALID;
@@ -391,27 +391,27 @@ static void sst_object_table_authenticate(uint8_t table_idx,
*
* \param[in,out] init_ctx Pointer to the object table to authenticate
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
__attribute__ ((always_inline))
-__STATIC_INLINE psa_ps_status_t sst_object_table_nvc_authenticate(
+__STATIC_INLINE psa_status_t sst_object_table_nvc_authenticate(
struct sst_obj_table_init_ctx_t *init_ctx)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t nvc_2;
err = sst_read_nv_counter(TFM_SST_NV_COUNTER_1, &init_ctx->nvc_1);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
err = sst_read_nv_counter(TFM_SST_NV_COUNTER_2, &nvc_2);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
err = sst_read_nv_counter(TFM_SST_NV_COUNTER_3, &init_ctx->nvc_3);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -436,7 +436,7 @@ __STATIC_INLINE psa_ps_status_t sst_object_table_nvc_authenticate(
sst_object_table_authenticate(SST_OBJ_TABLE_IDX_1, init_ctx);
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
#else /* SST_ROLLBACK_PROTECTION */
@@ -446,10 +446,10 @@ __STATIC_INLINE psa_ps_status_t sst_object_table_nvc_authenticate(
* \param[in,out] obj_table Pointer to the object table to generate
* authentication
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
__attribute__ ((always_inline))
-__STATIC_INLINE psa_ps_status_t sst_object_table_generate_auth_tag(
+__STATIC_INLINE psa_status_t sst_object_table_generate_auth_tag(
struct sst_obj_table_t *obj_table)
{
union sst_crypto_t *crypto = &obj_table->crypto;
@@ -472,7 +472,7 @@ __attribute__ ((always_inline))
__STATIC_INLINE void sst_object_table_authenticate_ctx_tables(
struct sst_obj_table_init_ctx_t *init_ctx)
{
- psa_ps_status_t err;
+ psa_status_t err;
union sst_crypto_t *crypto =
&init_ctx->p_table[SST_OBJ_TABLE_IDX_0]->crypto;
@@ -481,7 +481,7 @@ __STATIC_INLINE void sst_object_table_authenticate_ctx_tables(
err = sst_crypto_authenticate(crypto,
SST_CRYPTO_ASSOCIATED_DATA(crypto),
SST_CRYPTO_ASSOCIATED_DATA_LEN);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
init_ctx->table_state[SST_OBJ_TABLE_IDX_0] = SST_OBJ_TABLE_INVALID;
}
}
@@ -493,7 +493,7 @@ __STATIC_INLINE void sst_object_table_authenticate_ctx_tables(
err = sst_crypto_authenticate(crypto,
SST_CRYPTO_ASSOCIATED_DATA(crypto),
SST_CRYPTO_ASSOCIATED_DATA_LEN);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
init_ctx->table_state[SST_OBJ_TABLE_IDX_1] = SST_OBJ_TABLE_INVALID;
}
}
@@ -506,23 +506,23 @@ __STATIC_INLINE void sst_object_table_authenticate_ctx_tables(
*
* \param[in,out] obj_table Pointer to the object table to save
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_object_table_save_table(
+static psa_status_t sst_object_table_save_table(
struct sst_obj_table_t *obj_table)
{
- psa_ps_status_t err;
+ psa_status_t err;
#ifdef SST_ROLLBACK_PROTECTION
uint32_t nvc_1 = 0;
err = sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
err = sst_read_nv_counter(TFM_SST_NV_COUNTER_1, &nvc_1);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
#else
@@ -542,7 +542,7 @@ static psa_ps_status_t sst_object_table_save_table(
#ifdef SST_ENCRYPTION
/* Set object table key */
err = sst_crypto_setkey();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -556,13 +556,13 @@ static psa_ps_status_t sst_object_table_save_table(
err = sst_object_table_generate_auth_tag(obj_table);
#endif /* SST_ROLLBACK_PROTECTION */
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
(void)sst_crypto_destroykey();
return err;
}
err = sst_crypto_destroykey();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
#endif /* SST_ENCRYPTION */
@@ -570,7 +570,7 @@ static psa_ps_status_t sst_object_table_save_table(
err = sst_object_table_fs_write_table(obj_table);
#ifdef SST_ROLLBACK_PROTECTION
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -611,9 +611,9 @@ __STATIC_INLINE void sst_object_table_validate_version(
*
* \param[in] init_ctx Pointer to the init object table context
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-static psa_ps_status_t sst_set_active_object_table(
+static psa_status_t sst_set_active_object_table(
const struct sst_obj_table_init_ctx_t *init_ctx)
{
#ifndef SST_ROLLBACK_PROTECTION
@@ -628,7 +628,7 @@ static psa_ps_status_t sst_set_active_object_table(
&& (init_ctx->table_state[SST_OBJ_TABLE_IDX_1] ==
SST_OBJ_TABLE_INVALID)) {
/* Both tables are invalid */
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
} 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 */
@@ -642,7 +642,7 @@ static psa_ps_status_t sst_set_active_object_table(
init_ctx->p_table[SST_OBJ_TABLE_IDX_1],
SST_OBJ_TABLE_SIZE);
- return PSA_PS_SUCCESS;
+ return PSA_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 */
@@ -653,7 +653,7 @@ static psa_ps_status_t sst_set_active_object_table(
* needed to copy the table in the context.
*/
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
#ifdef SST_ROLLBACK_PROTECTION
@@ -715,7 +715,7 @@ static psa_ps_status_t sst_set_active_object_table(
SST_OBJ_TABLE_SIZE);
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
/**
@@ -725,12 +725,12 @@ static psa_ps_status_t sst_set_active_object_table(
* \param[in] client_id Client UID
* \param[out] idx Pointer to store the entry's index
*
- * \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.
+ * \return Returns PSA_SUCCESS and index of the table, if object exists
+ * in the table. Otherwise, it returns PSA_ERROR_DOES_NOT_EXIST.
*/
-static psa_ps_status_t sst_get_object_entry_idx(psa_ps_uid_t uid,
- int32_t client_id,
- uint32_t *idx)
+static psa_status_t sst_get_object_entry_idx(psa_storage_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;
@@ -739,11 +739,11 @@ static psa_ps_status_t sst_get_object_entry_idx(psa_ps_uid_t uid,
if (p_table->obj_db[i].uid == uid
&& p_table->obj_db[i].client_id == client_id) {
*idx = i;
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
}
- return PSA_PS_ERROR_UID_NOT_FOUND;
+ return PSA_ERROR_DOES_NOT_EXIST;
}
/**
@@ -757,19 +757,19 @@ static psa_ps_status_t sst_get_object_entry_idx(psa_ps_uid_t uid,
*
* \note The table is dimensioned to fit SST_NUM_ASSETS + 1
*
- * \return Returns PSA_PS_SUCCESS and a table index if idx_num free indices are
- * available. Otherwise, it returns PSA_PS_ERROR_INSUFFICIENT_SPACE.
+ * \return Returns PSA_SUCCESS and a table index if idx_num free indices are
+ * available. Otherwise, it returns PSA_ERROR_INSUFFICIENT_STORAGE.
*/
__attribute__ ((always_inline))
-__STATIC_INLINE psa_ps_status_t sst_table_free_idx(uint32_t idx_num,
- uint32_t *idx)
+__STATIC_INLINE psa_status_t sst_table_free_idx(uint32_t idx_num,
+ uint32_t *idx)
{
uint32_t i;
uint32_t last_free = 0;
struct sst_obj_table_t *p_table = &sst_obj_table_ctx.obj_table;
if (idx_num == 0) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_INVALID_ARGUMENT;
}
for (i = 0; i < SST_OBJ_TABLE_ENTRIES && idx_num > 0; i++) {
@@ -780,10 +780,10 @@ __STATIC_INLINE psa_ps_status_t sst_table_free_idx(uint32_t idx_num,
}
if (idx_num != 0) {
- return PSA_PS_ERROR_INSUFFICIENT_SPACE;
+ return PSA_ERROR_INSUFFICIENT_STORAGE;
} else {
*idx = last_free;
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
}
@@ -808,16 +808,16 @@ static void sst_table_delete_entry(uint32_t idx)
#endif
}
-psa_ps_status_t sst_object_table_create(void)
+psa_status_t sst_object_table_create(void)
{
struct sst_obj_table_t *p_table = &sst_obj_table_ctx.obj_table;
#ifdef SST_ROLLBACK_PROTECTION
- psa_ps_status_t err;
+ psa_status_t err;
/* Initialize SST NV counters */
err = sst_init_nv_counter();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
#endif
@@ -838,9 +838,9 @@ psa_ps_status_t sst_object_table_create(void)
return sst_object_table_save_table(p_table);
}
-psa_ps_status_t sst_object_table_init(uint8_t *obj_data)
+psa_status_t sst_object_table_init(uint8_t *obj_data)
{
- psa_ps_status_t err;
+ psa_status_t err;
struct sst_obj_table_init_ctx_t init_ctx = {
.p_table = {&sst_obj_table_ctx.obj_table, NULL},
.table_state = {SST_OBJ_TABLE_VALID, SST_OBJ_TABLE_VALID},
@@ -858,21 +858,21 @@ psa_ps_status_t sst_object_table_init(uint8_t *obj_data)
#ifdef SST_ENCRYPTION
/* Set object table key */
err = sst_crypto_setkey();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
#ifdef SST_ROLLBACK_PROTECTION
/* Initialize SST NV counters */
err = sst_init_nv_counter();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
(void)sst_crypto_destroykey();
return err;
}
/* Authenticate table */
err = sst_object_table_nvc_authenticate(&init_ctx);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
(void)sst_crypto_destroykey();
return err;
}
@@ -881,7 +881,7 @@ psa_ps_status_t sst_object_table_init(uint8_t *obj_data)
#endif /* SST_ROLLBACK_PROTECTION */
err = sst_crypto_destroykey();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
#endif /* SST_ENCRYPTION */
@@ -891,21 +891,21 @@ psa_ps_status_t sst_object_table_init(uint8_t *obj_data)
/* Set active tables */
err = sst_set_active_object_table(&init_ctx);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_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 != PSA_PS_SUCCESS && err != PSA_PS_ERROR_UID_NOT_FOUND) {
+ if (err != PSA_SUCCESS && err != PSA_ERROR_DOES_NOT_EXIST) {
return err;
}
#ifdef SST_ROLLBACK_PROTECTION
/* Align SST NV counters */
err = sst_object_table_align_nv_counters(init_ctx.nvc_1);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
#endif /* SST_ROLLBACK_PROTECTION */
@@ -914,25 +914,26 @@ psa_ps_status_t sst_object_table_init(uint8_t *obj_data)
sst_crypto_set_iv(&sst_obj_table_ctx.obj_table.crypto);
#endif
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_object_table_obj_exist(psa_ps_uid_t uid, int32_t client_id)
+psa_status_t sst_object_table_obj_exist(psa_storage_uid_t uid,
+ int32_t client_id)
{
uint32_t idx = 0;
return sst_get_object_entry_idx(uid, client_id, &idx);
}
-psa_ps_status_t sst_object_table_get_free_fid(uint32_t fid_num,
- uint32_t *p_fid)
+psa_status_t sst_object_table_get_free_fid(uint32_t fid_num,
+ uint32_t *p_fid)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t fid;
uint32_t idx;
err = sst_table_free_idx(fid_num, &idx);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -945,26 +946,26 @@ psa_ps_status_t sst_object_table_get_free_fid(uint32_t fid_num,
* 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) == PSA_PS_SUCCESS) {
+ if (sst_flash_fs_file_exist(fid) == PSA_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 != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
}
*p_fid = fid;
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_object_table_set_obj_tbl_info(psa_ps_uid_t uid,
- int32_t client_id,
+psa_status_t sst_object_table_set_obj_tbl_info(psa_storage_uid_t uid,
+ int32_t client_id,
const struct sst_obj_table_info_t *obj_tbl_info)
{
- psa_ps_status_t err;
+ psa_status_t err;
uint32_t idx = 0;
uint32_t backup_idx = 0;
struct sst_obj_table_entry_t backup_entry = {
@@ -979,7 +980,7 @@ psa_ps_status_t sst_object_table_set_obj_tbl_info(psa_ps_uid_t uid,
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 == PSA_PS_SUCCESS) {
+ if (err == PSA_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.
*/
@@ -1003,7 +1004,7 @@ psa_ps_status_t sst_object_table_set_obj_tbl_info(psa_ps_uid_t uid,
#endif
err = sst_object_table_save_table(p_table);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
if (backup_entry.uid != TFM_SST_INVALID_UID) {
/* Rollback the change in the table */
(void)tfm_memcpy(&p_table->obj_db[backup_idx], &backup_entry,
@@ -1016,16 +1017,16 @@ psa_ps_status_t sst_object_table_set_obj_tbl_info(psa_ps_uid_t uid,
return err;
}
-psa_ps_status_t sst_object_table_get_obj_tbl_info(psa_ps_uid_t uid,
- int32_t client_id,
+psa_status_t sst_object_table_get_obj_tbl_info(psa_storage_uid_t uid,
+ int32_t client_id,
struct sst_obj_table_info_t *obj_tbl_info)
{
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -1038,22 +1039,22 @@ psa_ps_status_t sst_object_table_get_obj_tbl_info(psa_ps_uid_t uid,
obj_tbl_info->version = p_table->obj_db[idx].version;
#endif
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_object_table_delete_object(psa_ps_uid_t uid,
- int32_t client_id)
+psa_status_t sst_object_table_delete_object(psa_storage_uid_t uid,
+ int32_t client_id)
{
uint32_t backup_idx = 0;
struct sst_obj_table_entry_t backup_entry;
- psa_ps_status_t err;
+ psa_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 != PSA_PS_SUCCESS) {
+ if (err != PSA_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
@@ -1068,7 +1069,7 @@ psa_ps_status_t sst_object_table_delete_object(psa_ps_uid_t uid,
sst_table_delete_entry(backup_idx);
err = sst_object_table_save_table(p_table);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
/* Rollback the change in the table */
(void)tfm_memcpy(&p_table->obj_db[backup_idx], &backup_entry,
SST_OBJECTS_TABLE_ENTRY_SIZE);
@@ -1077,7 +1078,7 @@ psa_ps_status_t sst_object_table_delete_object(psa_ps_uid_t uid,
return err;
}
-psa_ps_status_t sst_object_table_delete_old_table(void)
+psa_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 5167c4201..7d5a8cf41 100644
--- a/secure_fw/services/secure_storage/sst_object_table.h
+++ b/secure_fw/services/secure_storage/sst_object_table.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -33,9 +33,9 @@ struct sst_obj_table_info_t {
/**
* \brief Creates object table.
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_object_table_create(void);
+psa_status_t sst_object_table_create(void);
/**
* \brief Initializes object table.
@@ -44,9 +44,9 @@ psa_ps_status_t sst_object_table_create(void);
* in other to reuse that memory to allocated a
* temporary object table.
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_object_table_init(uint8_t *obj_data);
+psa_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
@@ -55,13 +55,13 @@ psa_ps_status_t sst_object_table_init(uint8_t *obj_data);
* \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 psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*
- * \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
+ * \retval PSA_SUCCESS If there is a table entry for the object
+ * \retval PSA_ERROR_DOES_NOT_EXIST If no table entry exists for the object
*/
-psa_ps_status_t sst_object_table_obj_exist(psa_ps_uid_t uid,
- int32_t client_id);
+psa_status_t sst_object_table_obj_exist(psa_storage_uid_t uid,
+ int32_t client_id);
/**
* \brief Gets a not in use file ID.
@@ -72,12 +72,12 @@ psa_ps_status_t sst_object_table_obj_exist(psa_ps_uid_t uid,
* return 1 file ID.
* \param[out] p_fid Pointer to the location to store the file ID
*
- * \return Returns PSA_PS_SUCCESS if the fid is valid and fid_num - 1 entries
+ * \return Returns PSA_SUCCESS if the fid is valid and fid_num - 1 entries
* are still free in the table. Otherwise, it returns an error code as
- * specified in \ref psa_ps_status_t
+ * specified in \ref psa_status_t
*/
-psa_ps_status_t sst_object_table_get_free_fid(uint32_t fid_num,
- uint32_t *p_fid);
+psa_status_t sst_object_table_get_free_fid(uint32_t fid_num,
+ uint32_t *p_fid);
/**
* \brief Sets object table information in the object table and stores it
@@ -91,10 +91,10 @@ psa_ps_status_t sst_object_table_get_free_fid(uint32_t fid_num,
* \note A call to this function results in writing the table to the
* file system.
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_object_table_set_obj_tbl_info(psa_ps_uid_t uid,
- int32_t client_id,
+psa_status_t sst_object_table_set_obj_tbl_info(psa_storage_uid_t uid,
+ int32_t client_id,
const struct sst_obj_table_info_t *obj_tbl_info);
/**
@@ -106,11 +106,11 @@ psa_ps_status_t sst_object_table_set_obj_tbl_info(psa_ps_uid_t uid,
* \param[out] obj_tbl_info Pointer to the location to store object table
* information
*
- * \return Returns PSA_PS_SUCCESS if the object exists. Otherwise, it
- * returns PSA_PS_ERROR_UID_NOT_FOUND.
+ * \return Returns PSA_SUCCESS if the object exists. Otherwise, it
+ * returns PSA_ERROR_DOES_NOT_EXIST.
*/
-psa_ps_status_t sst_object_table_get_obj_tbl_info(psa_ps_uid_t uid,
- int32_t client_id,
+psa_status_t sst_object_table_get_obj_tbl_info(psa_storage_uid_t uid,
+ int32_t client_id,
struct sst_obj_table_info_t *obj_tbl_info);
/**
@@ -119,17 +119,17 @@ psa_ps_status_t sst_object_table_get_obj_tbl_info(psa_ps_uid_t uid,
* \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 psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_object_table_delete_object(psa_ps_uid_t uid,
- int32_t client_id);
+psa_status_t sst_object_table_delete_object(psa_storage_uid_t uid,
+ int32_t client_id);
/**
* \brief Deletes old object table from the persistent area.
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_object_table_delete_old_table(void);
+psa_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 a16ce476d..dd8f7a40d 100644
--- a/secure_fw/services/secure_storage/sst_utils.c
+++ b/secure_fw/services/secure_storage/sst_utils.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -7,13 +7,13 @@
#include "sst_utils.h"
-psa_ps_status_t sst_utils_check_contained_in(uint32_t superset_size,
- uint32_t subset_offset,
- uint32_t subset_size)
+psa_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 PSA_PS_ERROR_OFFSET_INVALID;
+ return PSA_ERROR_INVALID_ARGUMENT;
}
/* Check that subset_offset + subset_size fits in superset_size.
@@ -21,17 +21,17 @@ psa_ps_status_t sst_utils_check_contained_in(uint32_t superset_size,
* and so the right hand side of the inequality cannot underflow.
*/
if (subset_size > (superset_size - subset_offset)) {
- return PSA_PS_ERROR_INCORRECT_SIZE;
+ return PSA_ERROR_INVALID_ARGUMENT;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_utils_validate_fid(uint32_t fid)
+psa_status_t sst_utils_validate_fid(uint32_t fid)
{
if (fid == SST_INVALID_FID) {
- return PSA_PS_ERROR_UID_NOT_FOUND;
+ return PSA_ERROR_DOES_NOT_EXIST;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
diff --git a/secure_fw/services/secure_storage/sst_utils.h b/secure_fw/services/secure_storage/sst_utils.h
index 3133c19d4..f05f356d7 100644
--- a/secure_fw/services/secure_storage/sst_utils.h
+++ b/secure_fw/services/secure_storage/sst_utils.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -42,6 +42,11 @@ extern "C" {
typedef char err_msg[(data_size <= data_buf_size)*2 - 1]
/**
+ * \brief Evaluates to the minimum of the two parameters.
+ */
+#define SST_UTILS_MIN(x, y) (((x) < (y)) ? (x) : (y))
+
+/**
* \brief Macro to get the number of bytes aligned with the
* SST_FLASH_PROGRAM_UNIT.
*
@@ -60,28 +65,28 @@ typedef char err_msg[(data_size <= data_buf_size)*2 - 1]
* superset region
* \param[in] subset_size Size of subset region
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*
- * \retval PSA_PS_SUCCESS The subset is contained within the
+ * \retval PSA_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
+ * \retval PSA_ERROR_INVALID_ARGUMENT The subset offset is greater than the
+ * size of the superset or when
+ * the subset offset is valid, but the
* subset offset + size is greater than the
* size of the superset
*/
-psa_ps_status_t sst_utils_check_contained_in(uint32_t superset_size,
- uint32_t subset_offset,
- uint32_t subset_size);
+psa_status_t sst_utils_check_contained_in(uint32_t superset_size,
+ uint32_t subset_offset,
+ uint32_t subset_size);
/**
* \brief Validates file ID
*
* \param[in] fid File ID
*
- * \return Returns error code as specified in \ref psa_ps_status_t
+ * \return Returns error code as specified in \ref psa_status_t
*/
-psa_ps_status_t sst_utils_validate_fid(uint32_t fid);
+psa_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 0655505bf..674d81a7e 100644
--- a/secure_fw/services/secure_storage/tfm_protected_storage.c
+++ b/secure_fw/services/secure_storage/tfm_protected_storage.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -9,9 +9,9 @@
#include "sst_object_system.h"
#include "tfm_sst_defs.h"
-psa_ps_status_t tfm_sst_init(void)
+psa_status_t tfm_sst_init(void)
{
- psa_ps_status_t err;
+ psa_status_t err;
err = sst_system_prepare();
#ifdef SST_CREATE_FLASH_LAYOUT
@@ -26,12 +26,12 @@ psa_ps_status_t tfm_sst_init(void)
* when it is the first time in the device life that the SST service is
* executed.
*/
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
/* Remove all data in the SST memory area and create a valid SST flash
* layout in that area.
*/
err = sst_system_wipe_all();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -43,69 +43,73 @@ psa_ps_status_t tfm_sst_init(void)
return err;
}
-psa_ps_status_t tfm_sst_set(int32_t client_id,
- psa_ps_uid_t uid,
- uint32_t data_length,
- psa_ps_create_flags_t create_flags)
+psa_status_t tfm_sst_set(int32_t client_id,
+ psa_storage_uid_t uid,
+ uint32_t data_length,
+ psa_storage_create_flags_t create_flags)
{
/* Check that the UID is valid */
if (uid == TFM_SST_INVALID_UID) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_INVALID_ARGUMENT;
}
/* Check that the create_flags does not contain any unsupported flags */
- if (create_flags & ~PSA_PS_FLAG_WRITE_ONCE) {
- return PSA_PS_ERROR_FLAGS_NOT_SUPPORTED;
+ if (create_flags & ~(PSA_STORAGE_FLAG_WRITE_ONCE |
+ PSA_STORAGE_FLAG_NO_CONFIDENTIALITY |
+ PSA_STORAGE_FLAG_NO_REPLAY_PROTECTION)) {
+ return PSA_ERROR_NOT_SUPPORTED;
}
/* Create the object in the object system */
return sst_object_create(uid, client_id, create_flags, data_length);
}
-psa_ps_status_t tfm_sst_get(int32_t client_id,
- psa_ps_uid_t uid,
- uint32_t data_offset,
- uint32_t data_length)
+psa_status_t tfm_sst_get(int32_t client_id,
+ psa_storage_uid_t uid,
+ uint32_t data_offset,
+ uint32_t data_size,
+ size_t *p_data_length)
{
/* Check that the UID is valid */
if (uid == TFM_SST_INVALID_UID) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_INVALID_ARGUMENT;
}
/* Read the object data from the object system */
- return sst_object_read(uid, client_id, data_offset, data_length);
+ return sst_object_read(uid, client_id, data_offset, data_size,
+ p_data_length);
}
-psa_ps_status_t tfm_sst_get_info(int32_t client_id, psa_ps_uid_t uid,
- struct psa_ps_info_t *p_info)
+psa_status_t tfm_sst_get_info(int32_t client_id, psa_storage_uid_t uid,
+ struct psa_storage_info_t *p_info)
{
/* Check that the UID is valid */
if (uid == TFM_SST_INVALID_UID) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_INVALID_ARGUMENT;
}
/* Get the info struct data from the object system */
return sst_object_get_info(uid, client_id, p_info);
}
-psa_ps_status_t tfm_sst_remove(int32_t client_id, psa_ps_uid_t uid)
+psa_status_t tfm_sst_remove(int32_t client_id, psa_storage_uid_t uid)
{
- psa_ps_status_t err;
+ psa_status_t err;
/* Check that the UID is valid */
if (uid == TFM_SST_INVALID_UID) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_INVALID_ARGUMENT;
}
/* Delete the object from the object system */
err = sst_object_delete(uid, client_id);
- /* PSA_PS_ERROR_AUTH_FAILED is not supported by psa_ps_remove
+ /* PSA_ERROR_INVALID_SIGNATURE is not supported by psa_ps_remove
* specification. So, this function returns TFM_SST_ERR_OPERATION_FAILED
* instead.
*/
- if (err == PSA_PS_ERROR_AUTH_FAILED) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ if (err == PSA_ERROR_INVALID_SIGNATURE) {
+ return PSA_ERROR_GENERIC_ERROR;
}
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 93f08d3ef..4cd44a51e 100644
--- a/secure_fw/services/secure_storage/tfm_protected_storage.h
+++ b/secure_fw/services/secure_storage/tfm_protected_storage.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -20,16 +20,16 @@ extern "C" {
* \brief Initializes the secure storage system.
*
* \return A status indicating the success/failure of the operation as specified
- * in \ref psa_ps_status_t
+ * in \ref psa_status_t
*
- * \retval PSA_PS_SUCCESS The operation completed successfully
- * \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the
+ * \retval PSA_SUCCESS The operation completed successfully
+ * \retval PSA_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
+ * \retval PSA_ERROR_GENERIC_ERROR The operation failed because of an
* unspecified internal failure
*/
-psa_ps_status_t tfm_sst_init(void);
+psa_status_t tfm_sst_init(void);
/**
* \brief Creates a new or modifies an existing asset.
@@ -40,32 +40,33 @@ psa_ps_status_t tfm_sst_init(void);
* \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 psa_ps_status_t
+ * in \ref psa_status_t
*
- * \retval PSA_PS_SUCCESS The operation completed successfully
- * \retval PSA_PS_ERROR_WRITE_ONCE The operation failed because the
+ * \retval PSA_SUCCESS The operation completed successfully
+ * \retval PSA_ERROR_NOT_PERMITTED The operation failed because the
* provided uid value was already
- * created with PSA_PS_FLAG_WRITE_ONCE
- * \retval PSA_PS_ERROR_INVALID_ARGUMENT The operation failed because one or
+ * created with
+ * PSA_STORAGE_FLAG_WRITE_ONCE
+ * \retval PSA_ERROR_INVALID_ARGUMENT The operation failed because one or
* more of the given arguments were
* invalid (null pointer, etc.)
- * \retval PSA_PS_ERROR_FLAGS_NOT_SUPPORTED The operation failed because one or
+ * \retval PSA_ERROR_NOT_SUPPORTED The operation failed because one or
* more of the flags provided in
* `create_flags` is not supported or
* is not valid
- * \retval PSA_PS_ERROR_INSUFFICIENT_SPACE The operation failed because there
+ * \retval PSA_ERROR_INSUFFICIENT_STORAGE The operation failed because there
* was insufficient space on the
* storage medium
- * \retval PSA_PS_ERROR_STORAGE_FAILURE The operation failed because the
+ * \retval PSA_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
+ * \retval PSA_ERROR_GENERIC_ERROR The operation failed because of an
* unspecified internal failure.
*/
-psa_ps_status_t tfm_sst_set(int32_t client_id,
- psa_ps_uid_t uid,
- uint32_t data_length,
- psa_ps_create_flags_t create_flags);
+psa_status_t tfm_sst_set(int32_t client_id,
+ psa_storage_uid_t uid,
+ uint32_t data_length,
+ psa_storage_create_flags_t create_flags);
/**
* \brief Gets the asset data for the provided uid.
*
@@ -77,65 +78,62 @@ psa_ps_status_t tfm_sst_set(int32_t client_id,
* allocated size of the `p_data` buffer)
*
* \return A status indicating the success/failure of the operation as specified
- * in \ref psa_ps_status_t
+ * in \ref psa_status_t
*
- * \retval PSA_PS_SUCCESS The operation completed successfully
- * \retval PSA_PS_ERROR_INVALID_ARGUMENT The operation failed because one or
+ * \retval PSA_SUCCESS The operation completed successfully
+ * \retval PSA_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
+ * \retval PSA_ERROR_DOES_NOT_EXIST 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
+ * \retval PSA_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
+ * \retval PSA_ERROR_GENERIC_ERROR The operation failed because of an
* unspecified internal failure
- * \retval PSA_PS_ERROR_DATA_CORRUPT The operation failed because the data
+ * \retval PSA_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
+ * \retval PSA_ERROR_INVALID_SIGNATURE The operation failed because the data
* associated with the UID failed
* authentication
*/
-psa_ps_status_t tfm_sst_get(int32_t client_id,
- psa_ps_uid_t uid,
- uint32_t data_offset,
- uint32_t data_length);
-
+psa_status_t tfm_sst_get(int32_t client_id,
+ psa_storage_uid_t uid,
+ uint32_t data_offset,
+ uint32_t data_size,
+ size_t *p_data_length);
/**
* \brief Gets the metadata for the provided uid.
*
* \param[in] client_id Identifier of the asset's owner (client)
* \param[in] uid Unique identifier for the data
- * \param[out] p_info A pointer to the `psa_ps_info_t` struct that will be
- * populated with the metadata
+ * \param[out] p_info A pointer to the `psa_storage_info_t` struct that will
+ * be populated with the metadata
*
* \return A status indicating the success/failure of the operation as specified
- * in \ref psa_ps_status_t
+ * in \ref psa_status_t
*
- * \retval PSA_PS_SUCCESS The operation completed successfully
- * \retval PSA_PS_ERROR_INVALID_ARGUMENT The operation failed because one or
+ * \retval PSA_SUCCESS The operation completed successfully
+ * \retval PSA_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
+ * \retval PSA_ERROR_DOES_NOT_EXIST 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
+ * \retval PSA_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
+ * \retval PSA_ERROR_GENERIC_ERROR The operation failed because of an
* unspecified internal failure
- * \retval PSA_PS_ERROR_DATA_CORRUPT The operation failed because the data
+ * \retval PSA_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
+ * \retval PSA_ERROR_INVALID_SIGNATURE The operation failed because the data
* associated with the UID failed
* authentication
*/
-psa_ps_status_t tfm_sst_get_info(int32_t client_id, psa_ps_uid_t uid,
- struct psa_ps_info_t *p_info);
+psa_status_t tfm_sst_get_info(int32_t client_id, psa_storage_uid_t uid,
+ struct psa_storage_info_t *p_info);
/**
* \brief Removes the provided uid and its associated data from storage.
@@ -144,25 +142,25 @@ psa_ps_status_t tfm_sst_get_info(int32_t client_id, psa_ps_uid_t uid,
* \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 psa_ps_status_t
+ * in \ref psa_status_t
*
- * \retval PSA_PS_SUCCESS The operation completed successfully
- * \retval PSA_PS_ERROR_INVALID_ARGUMENT The operation failed because one or
+ * \retval PSA_SUCCESS The operation completed successfully
+ * \retval PSA_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
+ * \retval PSA_ERROR_DOES_NOT_EXIST 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
+ * \retval PSA_ERROR_NOT_PERMITTED 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
+ * PSA_STORAGE_FLAG_WRITE_ONCE
+ * \retval PSA_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
+ * \retval PSA_ERROR_GENERIC_ERROR The operation failed because of an
* unspecified internal failure
*/
-psa_ps_status_t tfm_sst_remove(int32_t client_id, psa_ps_uid_t uid);
+psa_status_t tfm_sst_remove(int32_t client_id, psa_storage_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_req_mngr.c b/secure_fw/services/secure_storage/tfm_sst_req_mngr.c
index 15141d894..a005bdb1d 100644
--- a/secure_fw/services/secure_storage/tfm_sst_req_mngr.c
+++ b/secure_fw/services/secure_storage/tfm_sst_req_mngr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -37,14 +37,14 @@ static bool sst_is_init = false;
* function call, as calls to the Crypto service are required for
* initialisation.
*
- * \return PSA_SUCCESS if SST is initialised, PSA_ERROR_CONNECTION_REFUSED
+ * \return PSA_SUCCESS if SST is initialised, PSA_ERROR_GENERIC_ERROR
* otherwise.
*/
static psa_status_t sst_check_init(void)
{
if (!sst_is_init) {
- if (tfm_sst_init() != PSA_PS_SUCCESS) {
- return PSA_ERROR_CONNECTION_REFUSED;
+ if (tfm_sst_init() != PSA_SUCCESS) {
+ return PSA_ERROR_GENERIC_ERROR;
}
sst_is_init = true;
}
@@ -55,109 +55,91 @@ static psa_status_t sst_check_init(void)
psa_status_t tfm_sst_set_req(psa_invec *in_vec, size_t in_len,
psa_outvec *out_vec, size_t out_len)
{
- psa_ps_uid_t uid;
+ psa_storage_uid_t uid;
uint32_t data_length;
int32_t client_id;
int32_t status;
- psa_ps_create_flags_t create_flags;
- psa_ps_status_t *err;
+ psa_storage_create_flags_t create_flags;
if (sst_check_init() != PSA_SUCCESS) {
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- if ((in_len != 3) || (out_len != 1)) {
+ if ((in_len != 3) || (out_len != 0)) {
/* The number of arguments are incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- if (in_vec[0].len != sizeof(psa_ps_uid_t)) {
+ if (in_vec[0].len != sizeof(psa_storage_uid_t)) {
/* The input argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- uid = *((psa_ps_uid_t *)in_vec[0].base);
+ uid = *((psa_storage_uid_t *)in_vec[0].base);
p_data = (void *)in_vec[1].base;
data_length = in_vec[1].len;
- if (in_vec[2].len != sizeof(psa_ps_create_flags_t)) {
+ if (in_vec[2].len != sizeof(psa_storage_create_flags_t)) {
/* The input argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- create_flags = *(psa_ps_create_flags_t *)in_vec[2].base;
-
- if (out_vec[0].len != sizeof(psa_ps_status_t)) {
- /* The output argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
- }
-
- err = (psa_ps_status_t *)out_vec[0].base;
+ create_flags = *(psa_storage_create_flags_t *)in_vec[2].base;
/* Get the caller's client ID */
status = tfm_core_get_caller_client_id(&client_id);
if (status != (int32_t)TFM_SUCCESS) {
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- *err = tfm_sst_set(client_id, uid, data_length, create_flags);
-
- return PSA_SUCCESS;
+ return tfm_sst_set(client_id, uid, data_length, create_flags);
}
psa_status_t tfm_sst_get_req(psa_invec *in_vec, size_t in_len,
psa_outvec *out_vec, size_t out_len)
{
uint32_t data_offset;
- uint32_t data_length;
+ uint32_t data_size;
int32_t client_id;
- psa_ps_uid_t uid;
+ psa_storage_uid_t uid;
int32_t status;
- psa_ps_status_t *err;
+ size_t *p_data_length;
if (sst_check_init() != PSA_SUCCESS) {
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- if ((in_len != 2) || (out_len != 2)) {
+ if ((in_len != 2) || (out_len != 1)) {
/* The number of arguments are incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- if (in_vec[0].len != sizeof(psa_ps_uid_t)) {
+ if (in_vec[0].len != sizeof(psa_storage_uid_t)) {
/* The input argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- uid = *((psa_ps_uid_t *)in_vec[0].base);
+ uid = *((psa_storage_uid_t *)in_vec[0].base);
if (in_vec[1].len != sizeof(data_offset)) {
/* The input argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
data_offset = *(uint32_t *)in_vec[1].base;
- if (out_vec[0].len != sizeof(psa_ps_status_t)) {
- /* The output argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
- }
-
- err = (psa_ps_status_t *)out_vec[0].base;
-
- p_data = (void *)out_vec[1].base;
- data_length = out_vec[1].len;
+ p_data = (void *)out_vec[0].base;
+ data_size = out_vec[0].len;
+ p_data_length = &out_vec[0].len;
/* Get the caller's client ID */
status = tfm_core_get_caller_client_id(&client_id);
if (status != (int32_t)TFM_SUCCESS) {
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- *err = tfm_sst_get(client_id, uid, data_offset, data_length);
-
- return PSA_SUCCESS;
+ return tfm_sst_get(client_id, uid, data_offset, data_size, p_data_length);
}
@@ -165,92 +147,69 @@ psa_status_t tfm_sst_get_info_req(psa_invec *in_vec, size_t in_len,
psa_outvec *out_vec, size_t out_len)
{
int32_t client_id;
- psa_ps_uid_t uid;
- struct psa_ps_info_t *p_info;
- int32_t status;
- psa_ps_status_t *err;
+ psa_storage_uid_t uid;
+ struct psa_storage_info_t *p_info;
+ int32_t tfm_status;
if (sst_check_init() != PSA_SUCCESS) {
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- if ((in_len != 1) || (out_len != 2)) {
+ if ((in_len != 1) || (out_len != 1)) {
/* The number of arguments are incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- if (in_vec[0].len != sizeof(psa_ps_uid_t)) {
+ if (in_vec[0].len != sizeof(psa_storage_uid_t)) {
/* The input argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- uid = *((psa_ps_uid_t *)in_vec[0].base);
+ uid = *((psa_storage_uid_t *)in_vec[0].base);
- if (out_vec[0].len != sizeof(psa_ps_status_t)) {
+ if (out_vec[0].len != sizeof(struct psa_storage_info_t)) {
/* The output argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- err = (psa_ps_status_t *)out_vec[0].base;
-
- if (out_vec[1].len != sizeof(struct psa_ps_info_t)) {
- /* The output argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
- }
-
- p_info = (struct psa_ps_info_t *)out_vec[1].base;
+ p_info = (struct psa_storage_info_t *)out_vec[0].base;
/* Get the caller's client ID */
- status = tfm_core_get_caller_client_id(&client_id);
- if (status != (int32_t)TFM_SUCCESS) {
- return PSA_ERROR_CONNECTION_REFUSED;
+ tfm_status = tfm_core_get_caller_client_id(&client_id);
+ if (tfm_status != (int32_t)TFM_SUCCESS) {
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- *err = tfm_sst_get_info(client_id, uid, p_info);
-
- return PSA_SUCCESS;
+ return tfm_sst_get_info(client_id, uid, p_info);
}
psa_status_t tfm_sst_remove_req(psa_invec *in_vec, size_t in_len,
psa_outvec *out_vec, size_t out_len)
{
int32_t client_id;
- psa_ps_uid_t uid;
- int32_t status;
- psa_ps_status_t *err;
+ psa_storage_uid_t uid;
+ int32_t tfm_status;
if (sst_check_init() != PSA_SUCCESS) {
- return PSA_ERROR_CONNECTION_REFUSED;
- }
-
- if ((in_len != 1) || (out_len != 1)) {
- /* The number of arguments are incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- if (in_vec[0].len != sizeof(psa_ps_uid_t)) {
- /* The input argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ if ((in_len != 1) ||
+ (in_vec[0].len != sizeof(psa_storage_uid_t)) ||
+ (out_len != 0)) {
+ /* The number of arguments/output argument size are incorrect */
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- uid = *((psa_ps_uid_t *)in_vec[0].base);
-
- if (out_vec[0].len != sizeof(psa_ps_status_t)) {
- /* The output argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
- }
-
- err = (psa_ps_status_t *)out_vec[0].base;
+ uid = *((psa_storage_uid_t *)in_vec[0].base);
/* Get the caller's client ID */
- status = tfm_core_get_caller_client_id(&client_id);
- if (status != (int32_t)TFM_SUCCESS) {
- return PSA_ERROR_CONNECTION_REFUSED;
+ tfm_status = tfm_core_get_caller_client_id(&client_id);
+ if (tfm_status != (int32_t)TFM_SUCCESS) {
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- *err = tfm_sst_remove(client_id, uid);
-
- return PSA_SUCCESS;
+ return tfm_sst_remove(client_id, uid);;
}
psa_status_t tfm_sst_get_support_req(psa_invec *in_vec, size_t in_len,
@@ -261,17 +220,17 @@ psa_status_t tfm_sst_get_support_req(psa_invec *in_vec, size_t in_len,
(void)in_vec;
if (sst_check_init() != PSA_SUCCESS) {
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_GENERIC_ERROR;
}
if ((in_len != 0) || (out_len != 1)) {
/* The number of arguments are incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
if (out_vec[0].len != sizeof(*support_flags)) {
/* The output argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
support_flags = (uint32_t *)out_vec[0].base;
@@ -287,130 +246,102 @@ static psa_msg_t msg;
static psa_status_t tfm_sst_set_ipc(void)
{
- psa_ps_uid_t uid;
+ psa_storage_uid_t uid;
int32_t client_id;
- psa_ps_create_flags_t create_flags;
- size_t in_size[3], out_size, num = 0;
- psa_ps_status_t err;
+ psa_storage_create_flags_t create_flags;
+ size_t num = 0;
client_id = msg.client_id;
- in_size[0] = msg.in_size[0];
- in_size[1] = msg.in_size[1];
- in_size[2] = msg.in_size[2];
- out_size = msg.out_size[0];
- if (in_size[0] != sizeof(psa_ps_uid_t) ||
- in_size[2] != sizeof(psa_ps_create_flags_t) ||
- out_size != sizeof(psa_ps_status_t)) {
+
+ if (msg.in_size[0] != sizeof(psa_storage_uid_t) ||
+ msg.in_size[2] != sizeof(psa_storage_create_flags_t)) {
/* The size of one of the arguments is incorrect */
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- num = psa_read(msg.handle, 0, &uid, in_size[0]);
- if (num != in_size[0]) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ num = psa_read(msg.handle, 0, &uid, msg.in_size[0]);
+ if (num != msg.in_size[0]) {
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- num = psa_read(msg.handle, 2, &create_flags, in_size[2]);
- if (num != in_size[2]) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ num = psa_read(msg.handle, 2, &create_flags, msg.in_size[2]);
+ if (num != msg.in_size[2]) {
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- err = tfm_sst_set(client_id, uid, in_size[1], create_flags);
- psa_write(msg.handle, 0, &err, out_size);
- return PSA_SUCCESS;
+ return tfm_sst_set(client_id, uid, msg.in_size[1], create_flags);
}
static psa_status_t tfm_sst_get_ipc(void)
{
- psa_ps_uid_t uid;
- int32_t client_id;
+ psa_storage_uid_t uid;
uint32_t data_offset;
- size_t in_size[2], out_size[2], num = 0;
- psa_ps_status_t err;
+ size_t num = 0;
+ size_t p_data_length;
- client_id = msg.client_id;
- in_size[0] = msg.in_size[0];
- in_size[1] = msg.in_size[1];
- out_size[0] = msg.out_size[0];
- out_size[1] = msg.out_size[1];
- if (in_size[0] != sizeof(psa_ps_uid_t) ||
- in_size[1] != sizeof(uint32_t) ||
- out_size[0] != sizeof(psa_ps_status_t)) {
+ if (msg.in_size[0] != sizeof(psa_storage_uid_t) ||
+ msg.in_size[1] != sizeof(uint32_t)) {
/* The size of one of the arguments is incorrect */
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- num = psa_read(msg.handle, 0, &uid, in_size[0]);
- if (num != in_size[0]) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ num = psa_read(msg.handle, 0, &uid, msg.in_size[0]);
+ if (num != msg.in_size[0]) {
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- num = psa_read(msg.handle, 1, &data_offset, in_size[1]);
- if (num != in_size[1]) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ num = psa_read(msg.handle, 1, &data_offset, msg.in_size[1]);
+ if (num != msg.in_size[1]) {
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- err = tfm_sst_get(client_id, uid, data_offset, out_size[1]);
- psa_write(msg.handle, 0, &err, out_size[0]);
- return PSA_SUCCESS;
+ return tfm_sst_get(msg.client_id, uid, data_offset, msg.out_size[0],
+ &p_data_length);
}
static psa_status_t tfm_sst_get_info_ipc(void)
{
- psa_ps_uid_t uid;
- int32_t client_id;
- struct psa_ps_info_t info;
- size_t in_size, out_size[2], num = 0;
- psa_ps_status_t err;
+ psa_storage_uid_t uid;
- client_id = msg.client_id;
- in_size = msg.in_size[0];
- out_size[0] = msg.out_size[0];
- out_size[1] = msg.out_size[1];
- if (in_size != sizeof(psa_ps_uid_t) ||
- out_size[0] != sizeof(psa_ps_status_t) ||
- out_size[1] != sizeof(struct psa_ps_info_t)) {
+ struct psa_storage_info_t info;
+ size_t num = 0;
+ psa_status_t status;
+
+ if (msg.in_size[0] != sizeof(psa_storage_uid_t) ||
+ msg.out_size[0] != sizeof(struct psa_storage_info_t)) {
/* The size of one of the arguments is incorrect */
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- num = psa_read(msg.handle, 0, &uid, in_size);
- if (num != in_size) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ num = psa_read(msg.handle, 0, &uid, msg.in_size[0]);
+ if (num != msg.in_size[0]) {
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- err = tfm_sst_get_info(client_id, uid, &info);
- psa_write(msg.handle, 0, &err, out_size[0]);
- if (err == PSA_PS_SUCCESS) {
- psa_write(msg.handle, 1, &info, out_size[1]);
+ status = tfm_sst_get_info(msg.client_id, uid, &info);
+
+ if (status == PSA_SUCCESS) {
+ psa_write(msg.handle, 0, &info, msg.out_size[0]);
}
- return PSA_SUCCESS;
+ return status;
}
static psa_status_t tfm_sst_remove_ipc(void)
{
- psa_ps_uid_t uid;
- int32_t client_id;
- size_t in_size, out_size, num = 0;
- psa_ps_status_t err;
+ psa_storage_uid_t uid;
+ size_t num = 0;
- client_id = msg.client_id;
- in_size = msg.in_size[0];
- out_size = msg.out_size[0];
- if (in_size != sizeof(psa_ps_uid_t) ||
- out_size != sizeof(psa_ps_status_t)) {
+ if (msg.in_size[0] != sizeof(psa_storage_uid_t)) {
/* The size of one of the arguments is incorrect */
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- num = psa_read(msg.handle, 0, &uid, in_size);
- if (num != in_size) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ num = psa_read(msg.handle, 0, &uid, msg.in_size[0]);
+ if (num != msg.in_size[0]) {
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
- err = tfm_sst_remove(client_id, uid);
- psa_write(msg.handle, 0, &err, out_size);
- return PSA_SUCCESS;
+ return tfm_sst_remove(msg.client_id, uid);;
}
static psa_status_t tfm_sst_get_support_ipc(void)
@@ -421,7 +352,7 @@ static psa_status_t tfm_sst_get_support_ipc(void)
out_size = msg.out_size[0];
if (out_size != sizeof(support_flags)) {
/* The output argument size is incorrect */
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
support_flags = tfm_sst_get_support();
@@ -461,12 +392,12 @@ static void ps_signal_handle(psa_signal_t signal, sst_func_t pfn)
}
#endif /* !defined(TFM_PSA_API) */
-psa_ps_status_t tfm_sst_req_mngr_init(void)
+psa_status_t tfm_sst_req_mngr_init(void)
{
#ifdef TFM_PSA_API
psa_signal_t signals = 0;
- if (tfm_sst_init() != PSA_PS_SUCCESS) {
+ if (tfm_sst_init() != PSA_SUCCESS) {
tfm_abort();
}
@@ -492,28 +423,28 @@ psa_ps_status_t tfm_sst_req_mngr_init(void)
* function call, as calls to the Crypto service are required for
* initialisation.
*/
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_req_mngr_read_asset_data(uint8_t *out_data, uint32_t size)
+psa_status_t sst_req_mngr_read_asset_data(uint8_t *out_data, uint32_t size)
{
#ifdef TFM_PSA_API
size_t num = 0;
num = psa_read(msg.handle, 1, out_data, size);
if (num != size) {
- return PSA_PS_ERROR_INVALID_ARGUMENT;
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
#else /* TFM_PSA_API */
(void)tfm_memcpy(out_data, p_data, size);
#endif
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
void sst_req_mngr_write_asset_data(const uint8_t *in_data,
uint32_t size)
{
#ifdef TFM_PSA_API
- psa_write(msg.handle, 1, in_data, size);
+ psa_write(msg.handle, 0, in_data, size);
#else /* TFM_PSA_API */
(void)tfm_memcpy(p_data, in_data, size);
#endif
diff --git a/secure_fw/services/secure_storage/tfm_sst_req_mngr.h b/secure_fw/services/secure_storage/tfm_sst_req_mngr.h
index c3b76fa49..e1ce2e046 100644
--- a/secure_fw/services/secure_storage/tfm_sst_req_mngr.h
+++ b/secure_fw/services/secure_storage/tfm_sst_req_mngr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -120,7 +120,7 @@ void sst_req_mngr_write_asset_data(const uint8_t *in_data,
* in \ref psa_status_t
*
*/
-psa_ps_status_t sst_req_mngr_read_asset_data(uint8_t *out_data, uint32_t size);
+psa_status_t sst_req_mngr_read_asset_data(uint8_t *out_data, uint32_t size);
#ifdef __cplusplus
}
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 781e84bc1..4d35c47c8 100644
--- a/secure_fw/services/secure_storage/tfm_sst_secure_api.c
+++ b/secure_fw/services/secure_storage/tfm_sst_secure_api.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -14,13 +14,12 @@
#define IOVEC_LEN(x) (sizeof(x)/sizeof(x[0]))
__attribute__((section("SFN")))
-psa_ps_status_t psa_ps_set(psa_ps_uid_t uid,
- uint32_t data_length,
- const void *p_data,
- psa_ps_create_flags_t create_flags)
+psa_status_t psa_ps_set(psa_storage_uid_t uid,
+ size_t data_length,
+ const void *p_data,
+ psa_storage_create_flags_t create_flags)
{
psa_status_t status;
- psa_ps_status_t err;
#ifdef TFM_PSA_API
psa_handle_t handle;
#endif
@@ -31,43 +30,41 @@ psa_ps_status_t psa_ps_set(psa_ps_uid_t uid,
{ .base = &create_flags, .len = sizeof(create_flags) }
};
- psa_outvec out_vec[] = {
- { .base = &err , .len = sizeof(err) }
- };
-
#ifdef TFM_PSA_API
handle = psa_connect(TFM_SST_SET_SID, TFM_SST_SET_VERSION);
if (!PSA_HANDLE_IS_VALID(handle)) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), out_vec,
- IOVEC_LEN(out_vec));
+ status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec),
+ NULL, 0);
psa_close(handle);
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
#else
status = tfm_tfm_sst_set_req_veneer(in_vec, IOVEC_LEN(in_vec),
- out_vec, IOVEC_LEN(out_vec));
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
+ NULL, 0);
#endif
- return err;
+ /* A parameter with a buffer pointer pointer that has data length longer
+ * than maximum permitted is treated as a secure violation.
+ * TF-M framework rejects the request with TFM_ERROR_INVALID_PARAMETER.
+ */
+ if (status == (psa_status_t)TFM_ERROR_INVALID_PARAMETER) {
+ return PSA_ERROR_INVALID_ARGUMENT;
+ }
+
+ return status;
}
__attribute__((section("SFN")))
-psa_ps_status_t psa_ps_get(psa_ps_uid_t uid,
- uint32_t data_offset,
- uint32_t data_length,
- void *p_data)
+psa_status_t psa_ps_get(psa_storage_uid_t uid,
+ size_t data_offset,
+ size_t data_size,
+ void *p_data,
+ size_t *p_data_length)
{
psa_status_t status;
- psa_ps_status_t err;
#ifdef TFM_PSA_API
psa_handle_t handle;
#endif
@@ -78,14 +75,13 @@ psa_ps_status_t psa_ps_get(psa_ps_uid_t uid,
};
psa_outvec out_vec[] = {
- { .base = &err, .len = sizeof(err) },
- { .base = p_data, .len = data_length }
+ { .base = p_data, .len = data_size }
};
#ifdef TFM_PSA_API
handle = psa_connect(TFM_SST_GET_SID, TFM_SST_GET_VERSION);
if (!PSA_HANDLE_IS_VALID(handle)) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), out_vec,
@@ -94,24 +90,36 @@ psa_ps_status_t psa_ps_get(psa_ps_uid_t uid,
psa_close(handle);
if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return status;
}
#else
status = tfm_tfm_sst_get_req_veneer(in_vec, IOVEC_LEN(in_vec),
out_vec, IOVEC_LEN(out_vec));
+
+#endif
+
+ /* A parameter with a buffer pointer pointer that has data length longer
+ * than maximum permitted is treated as a secure violation.
+ * TF-M framework rejects the request with TFM_ERROR_INVALID_PARAMETER.
+ */
+ if (status == (psa_status_t)TFM_ERROR_INVALID_PARAMETER) {
+ return PSA_ERROR_INVALID_ARGUMENT;
+ }
+
if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return status;
}
-#endif
- return err;
+ *p_data_length = out_vec[0].len;
+
+ return status;
}
__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 psa_ps_get_info(psa_storage_uid_t uid,
+ struct psa_storage_info_t *p_info)
{
psa_status_t status;
- psa_ps_status_t err;
#ifdef TFM_PSA_API
psa_handle_t handle;
#endif
@@ -121,14 +129,13 @@ psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
};
psa_outvec out_vec[] = {
- { .base = &err, .len = sizeof(err) },
{ .base = p_info, .len = sizeof(*p_info) }
};
#ifdef TFM_PSA_API
handle = psa_connect(TFM_SST_GET_INFO_SID, TFM_SST_GET_INFO_VERSION);
if (!PSA_HANDLE_IS_VALID(handle)) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), out_vec,
@@ -136,26 +143,21 @@ psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
psa_close(handle);
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
#else
status = tfm_tfm_sst_get_info_req_veneer(in_vec, IOVEC_LEN(in_vec),
out_vec, IOVEC_LEN(out_vec));
-
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
#endif
- return err;
+ if (status == (psa_status_t)TFM_ERROR_INVALID_PARAMETER) {
+ return PSA_ERROR_INVALID_ARGUMENT;
+ }
+ return status;
}
__attribute__((section("SFN")))
-psa_ps_status_t psa_ps_remove(psa_ps_uid_t uid)
+psa_status_t psa_ps_remove(psa_storage_uid_t uid)
{
psa_status_t status;
- psa_ps_status_t err;
#ifdef TFM_PSA_API
psa_handle_t handle;
#endif
@@ -164,57 +166,50 @@ psa_ps_status_t psa_ps_remove(psa_ps_uid_t uid)
{ .base = &uid, .len = sizeof(uid) }
};
- psa_outvec out_vec[] = {
- { .base = &err, .len = sizeof(err) }
- };
-
#ifdef TFM_PSA_API
handle = psa_connect(TFM_SST_REMOVE_SID, TFM_SST_REMOVE_VERSION);
if (!PSA_HANDLE_IS_VALID(handle)) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
- status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec), out_vec,
- IOVEC_LEN(out_vec));
+ status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec),
+ NULL, 0);
psa_close(handle);
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
#else
status = tfm_tfm_sst_remove_req_veneer(in_vec, IOVEC_LEN(in_vec),
- out_vec, IOVEC_LEN(out_vec));
+ NULL, 0);
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
#endif
- return err;
+ if (status == (psa_status_t)TFM_ERROR_INVALID_PARAMETER) {
+ return PSA_ERROR_INVALID_ARGUMENT;
+ }
+ return status;
}
__attribute__((section("SFN")))
-psa_ps_status_t psa_ps_create(psa_ps_uid_t uid, uint32_t size,
- psa_ps_create_flags_t create_flags)
+psa_status_t psa_ps_create(psa_storage_uid_t uid, size_t size,
+ psa_storage_create_flags_t create_flags)
{
(void)uid;
(void)size;
(void)create_flags;
- return PSA_PS_ERROR_NOT_SUPPORTED;
+ return PSA_ERROR_NOT_SUPPORTED;
}
__attribute__((section("SFN")))
-psa_ps_status_t psa_ps_set_extended(psa_ps_uid_t uid, uint32_t data_offset,
- uint32_t data_length, const void *p_data)
+psa_status_t psa_ps_set_extended(psa_storage_uid_t uid, size_t data_offset,
+ size_t data_length, const void *p_data)
{
(void)uid;
(void)data_offset;
(void)data_length;
(void)p_data;
- return PSA_PS_ERROR_NOT_SUPPORTED;
+ return PSA_ERROR_NOT_SUPPORTED;
}
__attribute__((section("SFN")))
diff --git a/test/framework/test_framework_helpers.c b/test/framework/test_framework_helpers.c
index 5158c536b..8993622b2 100644
--- a/test/framework/test_framework_helpers.c
+++ b/test/framework/test_framework_helpers.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -9,35 +9,51 @@
#include <stdio.h>
-const char *psa_ps_status_to_str(psa_ps_status_t status)
+const char *psa_status_to_str(psa_status_t status)
{
switch (status) {
- case PSA_PS_SUCCESS:
- return "PSA_PS_SUCCESS";
- case PSA_PS_ERROR_WRITE_ONCE:
- return "PSA_PS_ERROR_WRITE_ONCE";
- case PSA_PS_ERROR_FLAGS_NOT_SUPPORTED:
- return "PSA_PS_ERROR_FLAGS_NOT_SUPPORTED";
- case PSA_PS_ERROR_INSUFFICIENT_SPACE:
- return "PSA_PS_ERROR_INSUFFICIENT_SPACE";
- case PSA_PS_ERROR_STORAGE_FAILURE:
- return "PSA_PS_ERROR_STORAGE_FAILURE";
- case PSA_PS_ERROR_UID_NOT_FOUND:
- return "PSA_PS_ERROR_UID_NOT_FOUND";
- case PSA_PS_ERROR_INCORRECT_SIZE:
- return "PSA_PS_ERROR_INCORRECT_SIZE";
- case PSA_PS_ERROR_OFFSET_INVALID:
- return "PSA_PS_ERROR_OFFSET_INVALID";
- case PSA_PS_ERROR_INVALID_ARGUMENT:
- return "PSA_PS_ERROR_INVALID_ARGUMENT";
- case PSA_PS_ERROR_DATA_CORRUPT:
- return "PSA_PS_ERROR_DATA_CORRUPT";
- case PSA_PS_ERROR_AUTH_FAILED:
- return "PSA_PS_ERROR_AUTH_FAILED";
- case PSA_PS_ERROR_OPERATION_FAILED:
- return "PSA_PS_ERROR_OPERATION_FAILED";
- case PSA_PS_ERROR_NOT_SUPPORTED:
- return "PSA_PS_ERROR_NOT_SUPPORTED";
+ case PSA_SUCCESS:
+ return "PSA_SUCCESS";
+ case PSA_ERROR_PROGRAMMER_ERROR:
+ return "PSA_ERROR_PROGRAMMER_ERROR";
+ case PSA_ERROR_CONNECTION_REFUSED:
+ return "PSA_ERROR_CONNECTION_REFUSED";
+ case PSA_ERROR_CONNECTION_BUSY:
+ return "PSA_ERROR_CONNECTION_BUSY";
+ case PSA_ERROR_GENERIC_ERROR:
+ return "PSA_ERROR_GENERIC_ERROR";
+ case PSA_ERROR_NOT_PERMITTED:
+ return "PSA_ERROR_NOT_PERMITTED";
+ case PSA_ERROR_NOT_SUPPORTED:
+ return "PSA_ERROR_NOT_SUPPORTED";
+ case PSA_ERROR_INVALID_ARGUMENT:
+ return "PSA_ERROR_INVALID_ARGUMENT";
+ case PSA_ERROR_INVALID_HANDLE:
+ return "PSA_ERROR_INVALID_HANDLE";
+ case PSA_ERROR_BAD_STATE:
+ return "PSA_ERROR_BAD_STATE";
+ case PSA_ERROR_BUFFER_TOO_SMALL:
+ return "PSA_ERROR_BUFFER_TOO_SMALL";
+ case PSA_ERROR_ALREADY_EXISTS:
+ return "PSA_ERROR_ALREADY_EXISTS";
+ case PSA_ERROR_DOES_NOT_EXIST:
+ return "PSA_ERROR_DOES_NOT_EXIST";
+ case PSA_ERROR_INSUFFICIENT_MEMORY:
+ return "PSA_ERROR_INSUFFICIENT_MEMORY";
+ case PSA_ERROR_INSUFFICIENT_STORAGE:
+ return "PSA_ERROR_INSUFFICIENT_STORAGE";
+ case PSA_ERROR_INSUFFICIENT_DATA:
+ return "PSA_ERROR_INSUFFICIENT_DATA";
+ case PSA_ERROR_SERVICE_FAILURE:
+ return "PSA_ERROR_SERVICE_FAILURE";
+ case PSA_ERROR_COMMUNICATION_FAILURE:
+ return "PSA_ERROR_COMMUNICATION_FAILURE";
+ case PSA_ERROR_STORAGE_FAILURE:
+ return "PSA_ERROR_STORAGE_FAILURE";
+ case PSA_ERROR_HARDWARE_FAILURE:
+ return "PSA_ERROR_HARDWARE_FAILURE";
+ case PSA_ERROR_INVALID_SIGNATURE:
+ return "PSA_ERROR_INVALID_SIGNATURE";
default:
return "Unknown error";
}
diff --git a/test/framework/test_framework_helpers.h b/test/framework/test_framework_helpers.h
index 8d42fe72c..ef6fa5c05 100644
--- a/test/framework/test_framework_helpers.h
+++ b/test/framework/test_framework_helpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -28,13 +28,13 @@ enum serial_color_t {
};
/**
- * \brief Translates psa_ps_status_t into a string.
+ * \brief Translates psa_status_t into a string.
*
- * \param[in] status psa_ps_status_t status value.
+ * \param[in] status psa_status_t status value.
*
- * \return psa_ps_status_t as string.
+ * \return psa_status_t as string.
*/
-const char *psa_ps_status_to_str(psa_ps_status_t status);
+const char *psa_status_to_str(psa_status_t status);
/**
* \brief Translates asset permissions into a string.
diff --git a/test/suites/sst/non_secure/psa_ps_ns_interface_testsuite.c b/test/suites/sst/non_secure/psa_ps_ns_interface_testsuite.c
index f2370c0e0..19af996da 100644
--- a/test/suites/sst/non_secure/psa_ps_ns_interface_testsuite.c
+++ b/test/suites/sst/non_secure/psa_ps_ns_interface_testsuite.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -33,6 +33,8 @@
#define WRITE_ONCE_DATA_SIZE (sizeof(WRITE_ONCE_DATA) - 1)
#define WRITE_ONCE_READ_DATA "############################################"
#define WRITE_ONCE_RESULT_DATA ("####" WRITE_ONCE_DATA "####")
+#define OFFSET_READ_DATA "HEQUICKBROWNFOXJUMPSOVERALAZYDOG"
+#define OFFSET_RESULT_DATA ("____" OFFSET_READ_DATA "_____")
#define WRITE_DATA "THEQUICKBROWNFOXJUMPSOVERALAZYDOG"
#define WRITE_DATA_SIZE (sizeof(WRITE_DATA) - 1)
@@ -43,6 +45,7 @@
static const uint8_t write_asset_data[SST_MAX_ASSET_SIZE] = {0xAF};
static uint8_t read_asset_data[SST_MAX_ASSET_SIZE] = {0};
+static size_t read_asset_data_len = 0;
/* List of tests */
static void tfm_sst_test_1001(struct test_result_t *ret);
@@ -153,36 +156,36 @@ void register_testsuite_ns_psa_ps_interface(struct test_suite_t *p_test_suite)
*/
TFM_SST_NS_TEST(1001, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = 0;
const uint8_t write_data[] = {0};
/* Set with no data and no flags and a valid UID */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
/* Attempt to set a second time */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail the second time with valid UID");
return;
}
/* Set with an invalid UID */
status = psa_ps_set(INVALID_UID, data_len, write_data, flags);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Set should not succeed with an invalid UID");
return;
}
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -198,33 +201,34 @@ TFM_SST_NS_TEST(1001, "Thread_A")
*/
TFM_SST_NS_TEST(1002, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
/* Set with no flags */
status = psa_ps_set(WRITE_ONCE_UID, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with no flags");
return;
}
- /* Set with valid flag: PSA_PS_FLAG_WRITE_ONCE (with previously created UID)
+ /* Set with valid flag: PSA_STORAGE_FLAG_WRITE_ONCE
+ * (with previously created UID)
* Note: Once created, WRITE_ONCE_UID cannot be deleted. It is reused across
* multiple tests.
*/
status = psa_ps_set(WRITE_ONCE_UID, WRITE_ONCE_DATA_SIZE, WRITE_ONCE_DATA,
- PSA_PS_FLAG_WRITE_ONCE);
- if (status != PSA_PS_SUCCESS) {
+ PSA_STORAGE_FLAG_WRITE_ONCE);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid flags (and existing UID)");
return;
}
/* Set with invalid flags */
status = psa_ps_set(uid, data_len, write_data, INVALID_FLAG);
- if (status != PSA_PS_ERROR_FLAGS_NOT_SUPPORTED) {
+ if (status != PSA_ERROR_NOT_SUPPORTED) {
TEST_FAIL("Set should not succeed with invalid flags");
return;
}
@@ -243,14 +247,14 @@ TFM_SST_NS_TEST(1002, "Thread_A")
*/
TFM_SST_NS_TEST(1003, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = 0;
/* Set with NULL data pointer */
status = psa_ps_set(uid, data_len, NULL, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should succeed with NULL data pointer and zero length");
return;
}
@@ -264,25 +268,27 @@ TFM_SST_NS_TEST(1003, "Thread_A")
*/
TFM_SST_NS_TEST(1004, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = WRITE_ONCE_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = WRITE_ONCE_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t write_len = WRITE_DATA_SIZE;
const uint32_t read_len = WRITE_ONCE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = WRITE_ONCE_READ_DATA;
+ size_t read_data_len = 0;
/* Set a write once UID a second time */
status = psa_ps_set(uid, write_len, write_data, flags);
- if (status != PSA_PS_ERROR_WRITE_ONCE) {
+ if (status != PSA_ERROR_NOT_PERMITTED) {
TEST_FAIL("Set should not rewrite a write once UID");
return;
}
/* Get write once data */
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -303,24 +309,27 @@ TFM_SST_NS_TEST(1004, "Thread_A")
*/
TFM_SST_NS_TEST(1005, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
uint32_t data_len = WRITE_DATA_SIZE;
uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
+
const uint8_t *p_read_data = read_data;
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
/* Get the entire data */
- status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -338,8 +347,9 @@ TFM_SST_NS_TEST(1005, "Thread_A")
offset = 2;
data_len -= offset + 2;
- status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -366,7 +376,7 @@ TFM_SST_NS_TEST(1005, "Thread_A")
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -381,24 +391,26 @@ TFM_SST_NS_TEST(1005, "Thread_A")
*/
TFM_SST_NS_TEST(1006, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t write_len = WRITE_DATA_SIZE;
const uint32_t read_len = 0;
uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
status = psa_ps_set(uid, write_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
/* Get zero data from zero offset */
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail with zero data len");
return;
}
@@ -412,8 +424,9 @@ TFM_SST_NS_TEST(1006, "Thread_A")
offset = 5;
/* Get zero data from non-zero offset */
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -426,7 +439,7 @@ TFM_SST_NS_TEST(1006, "Thread_A")
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -441,15 +454,17 @@ TFM_SST_NS_TEST(1006, "Thread_A")
*/
TFM_SST_NS_TEST(1007, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
const uint32_t data_len = 1;
const uint32_t offset = 0;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Get with UID that has not yet been set */
- status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Get succeeded with non-existant UID");
return;
}
@@ -462,8 +477,8 @@ TFM_SST_NS_TEST(1007, "Thread_A")
/* Get with invalid UID */
status = psa_ps_get(INVALID_UID, offset, data_len,
- read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ read_data + HALF_PADDING_SIZE, &read_data_len);
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Get succeeded with invalid UID");
return;
}
@@ -485,17 +500,18 @@ TFM_SST_NS_TEST(1007, "Thread_A")
*/
TFM_SST_NS_TEST(1008, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t write_len = WRITE_DATA_SIZE;
uint32_t read_len;
uint32_t offset;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
status = psa_ps_set(uid, write_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
@@ -504,8 +520,9 @@ TFM_SST_NS_TEST(1008, "Thread_A")
read_len = 1;
offset = write_len + 1;
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_OFFSET_INVALID) {
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Get should not succeed with offset too large");
return;
}
@@ -520,14 +537,21 @@ TFM_SST_NS_TEST(1008, "Thread_A")
read_len = write_len + 1;
offset = 0;
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_INCORRECT_SIZE) {
- TEST_FAIL("Get should not succeed with data length too large");
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
+ TEST_FAIL("Get should succeed with data length larger than UID's "
+ "length");
+ return;
+ }
+
+ if (read_data_len != write_len) {
+ TEST_FAIL("Read data length should be equal to UID's length");
return;
}
/* Check that the read data is unchanged */
- if (memcmp(read_data, READ_DATA, sizeof(read_data)) != 0) {
+ if (memcmp(read_data, RESULT_DATA, sizeof(read_data)) != 0) {
TEST_FAIL("Read data should be equal to original read data");
return;
}
@@ -538,21 +562,32 @@ TFM_SST_NS_TEST(1008, "Thread_A")
read_len = write_len;
offset = 1;
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_INCORRECT_SIZE) {
- TEST_FAIL("Get should not succeed with offset + data length too large");
+ /* Reset read_data to original READ_DATA */
+ memcpy(read_data, READ_DATA, sizeof(read_data));
+
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
+ TEST_FAIL("Get should succeed with offset + data length too large, "
+ "but individually valid");
+ return;
+ }
+
+ if (read_data_len != write_len - offset) {
+ TEST_FAIL("Read data length should be equal to the UID's remaining "
+ "size starting from offset");
return;
}
/* Check that the read data is unchanged */
- if (memcmp(read_data, READ_DATA, sizeof(read_data)) != 0) {
+ if (memcmp(read_data, OFFSET_RESULT_DATA, sizeof(read_data)) != 0) {
TEST_FAIL("Read data should be equal to original read data");
return;
}
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -571,29 +606,30 @@ TFM_SST_NS_TEST(1008, "Thread_A")
*/
TFM_SST_NS_TEST(1009, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
+ size_t read_data_length = 0;
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
/* Get with NULL data pointer */
- status = psa_ps_get(uid, offset, 0, NULL);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, 0, NULL, &read_data_length);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should succeed with NULL data pointer and zero length");
return;
}
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -607,13 +643,13 @@ TFM_SST_NS_TEST(1009, "Thread_A")
*/
TFM_SST_NS_TEST(1010, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = WRITE_ONCE_UID;
- struct psa_ps_info_t info = {0};
+ psa_status_t status;
+ const psa_storage_uid_t uid = WRITE_ONCE_UID;
+ struct psa_storage_info_t info = {0};
/* Get info for write once UID */
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get info should not fail for write once UID");
return;
}
@@ -624,7 +660,7 @@ TFM_SST_NS_TEST(1010, "Thread_A")
return;
}
- if (info.flags != PSA_PS_FLAG_WRITE_ONCE) {
+ if (info.flags != PSA_STORAGE_FLAG_WRITE_ONCE) {
TEST_FAIL("Flags incorrect for write once UID");
return;
}
@@ -638,22 +674,22 @@ TFM_SST_NS_TEST(1010, "Thread_A")
*/
TFM_SST_NS_TEST(1011, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- struct psa_ps_info_t info = {0};
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ struct psa_storage_info_t info = {0};
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
/* Get info for valid UID */
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get info should not fail with valid UID");
return;
}
@@ -671,7 +707,7 @@ TFM_SST_NS_TEST(1011, "Thread_A")
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -686,13 +722,13 @@ TFM_SST_NS_TEST(1011, "Thread_A")
*/
TFM_SST_NS_TEST(1012, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
- struct psa_ps_info_t info = {0};
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
+ struct psa_storage_info_t info = {0};
/* Get info with UID that has not yet been set */
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Get info should not succeed with unset UID");
return;
}
@@ -710,7 +746,7 @@ TFM_SST_NS_TEST(1012, "Thread_A")
/* Get info with invalid UID */
status = psa_ps_get_info(INVALID_UID, &info);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Get info should not succeed with invalid UID");
return;
}
@@ -735,45 +771,46 @@ TFM_SST_NS_TEST(1012, "Thread_A")
*/
TFM_SST_NS_TEST(1013, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- struct psa_ps_info_t info = {0};
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ struct psa_storage_info_t info = {0};
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
/* Call remove with valid ID */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
/* Check that get info fails for removed UID */
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Get info should not succeed with removed UID");
return;
}
/* Check that get fails for removed UID */
- status = psa_ps_get(uid, offset, data_len, read_data);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ status = psa_ps_get(uid, offset, data_len, read_data, &read_data_len);
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Get should not succeed with removed UID");
return;
}
/* Check that remove fails for removed UID */
status = psa_ps_remove(uid);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Remove should not succeed with removed UID");
return;
}
@@ -787,12 +824,12 @@ TFM_SST_NS_TEST(1013, "Thread_A")
*/
TFM_SST_NS_TEST(1014, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = WRITE_ONCE_UID;
+ psa_status_t status;
+ const psa_storage_uid_t uid = WRITE_ONCE_UID;
/* Call remove with write once UID */
status = psa_ps_remove(uid);
- if (status != PSA_PS_ERROR_WRITE_ONCE) {
+ if (status != PSA_ERROR_NOT_PERMITTED) {
TEST_FAIL("Remove should not succeed with write once UID");
return;
}
@@ -806,12 +843,12 @@ TFM_SST_NS_TEST(1014, "Thread_A")
*/
TFM_SST_NS_TEST(1015, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = INVALID_UID;
+ psa_status_t status;
+ const psa_storage_uid_t uid = INVALID_UID;
/* Call remove with an invalid UID */
status = psa_ps_remove(uid);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Remove should not succeed with invalid UID");
return;
}
@@ -825,14 +862,14 @@ TFM_SST_NS_TEST(1015, "Thread_A")
*/
static void tfm_sst_test_1016_task_1(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid thread name");
return;
}
@@ -845,14 +882,15 @@ static void tfm_sst_test_1016_task_1(struct test_result_t *ret)
*/
static void tfm_sst_test_1016_task_2(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
- status = psa_ps_get(uid, offset, data_len, read_data);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ status = psa_ps_get(uid, offset, data_len, read_data, &read_data_len);
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Get should not succeed with invalid thread name");
return;
}
@@ -871,11 +909,11 @@ static void tfm_sst_test_1016_task_2(struct test_result_t *ret)
*/
static void tfm_sst_test_1016_task_3(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid thread name");
return;
}
@@ -906,14 +944,14 @@ static void tfm_sst_test_1016(struct test_result_t *ret)
*/
static void tfm_sst_test_1017_task_1(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid thread name");
return;
}
@@ -926,12 +964,12 @@ static void tfm_sst_test_1017_task_1(struct test_result_t *ret)
*/
static void tfm_sst_test_1017_task_2(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- struct psa_ps_info_t info = {0};
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ struct psa_storage_info_t info = {0};
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Get info should not succeed with invalid thread name");
return;
}
@@ -950,11 +988,11 @@ static void tfm_sst_test_1017_task_2(struct test_result_t *ret)
*/
static void tfm_sst_test_1017_task_3(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid thread name");
return;
}
@@ -985,14 +1023,14 @@ static void tfm_sst_test_1017(struct test_result_t *ret)
*/
static void tfm_sst_test_1018_task_1(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid thread name");
return;
}
@@ -1005,11 +1043,11 @@ static void tfm_sst_test_1018_task_1(struct test_result_t *ret)
*/
static void tfm_sst_test_1018_task_2(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
status = psa_ps_remove(uid);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Remove should not succeed with invalid thread name");
return;
}
@@ -1022,11 +1060,11 @@ static void tfm_sst_test_1018_task_2(struct test_result_t *ret)
*/
static void tfm_sst_test_1018_task_3(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid thread name");
return;
}
@@ -1057,13 +1095,13 @@ static void tfm_sst_test_1018(struct test_result_t *ret)
*/
static void tfm_sst_test_1019_task_1(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint8_t write_data[] = "Thread A data";
status = psa_ps_set(uid, sizeof(write_data), write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
@@ -1076,18 +1114,19 @@ static void tfm_sst_test_1019_task_1(struct test_result_t *ret)
*/
static void tfm_sst_test_1019_task_2(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
- struct psa_ps_info_t info = {0};
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
+ struct psa_storage_info_t info = {0};
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Attempt to access the other thread's UID */
- status = psa_ps_get(uid, offset, data_len, read_data);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ status = psa_ps_get(uid, offset, data_len, read_data, &read_data_len);
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Get should not find another thread's UID");
return;
}
@@ -1099,7 +1138,7 @@ static void tfm_sst_test_1019_task_2(struct test_result_t *ret)
}
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Get info should not find another thread's UID");
return;
}
@@ -1111,20 +1150,21 @@ static void tfm_sst_test_1019_task_2(struct test_result_t *ret)
}
status = psa_ps_remove(uid);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Remove should not find another thread's UID");
return;
}
/* Create the same UID, but belonging to this thread */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
- status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail with valid UID");
return;
}
@@ -1137,7 +1177,7 @@ static void tfm_sst_test_1019_task_2(struct test_result_t *ret)
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -1150,18 +1190,20 @@ static void tfm_sst_test_1019_task_2(struct test_result_t *ret)
*/
static void tfm_sst_test_1019_task_3(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
- struct psa_ps_info_t info = {0};
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
+ struct psa_storage_info_t info = {0};
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t offset = 0;
const uint8_t write_data[] = "Thread A data";
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
+
const uint32_t data_len = sizeof(write_data);
/* Check that first thread can still get info for UID */
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get info should not fail with valid UID");
return;
}
@@ -1173,8 +1215,8 @@ static void tfm_sst_test_1019_task_3(struct test_result_t *ret)
}
/* Check that first thread can still get UID */
- status = psa_ps_get(uid, offset, data_len, read_data);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, data_len, read_data, &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail with valid UID");
return;
}
@@ -1187,7 +1229,7 @@ static void tfm_sst_test_1019_task_3(struct test_result_t *ret)
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -1218,13 +1260,13 @@ static void tfm_sst_test_1019(struct test_result_t *ret)
*/
static void tfm_sst_test_1020_task_1(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint8_t write_data[] = "A";
status = psa_ps_set(uid, sizeof(write_data), write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should succeed for Thread_A");
return;
}
@@ -1237,13 +1279,13 @@ static void tfm_sst_test_1020_task_1(struct test_result_t *ret)
*/
static void tfm_sst_test_1020_task_2(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint8_t write_data[] = "B";
status = psa_ps_set(uid, sizeof(write_data), write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should succeed for Thread_B");
return;
}
@@ -1256,13 +1298,13 @@ static void tfm_sst_test_1020_task_2(struct test_result_t *ret)
*/
static void tfm_sst_test_1020_task_3(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint8_t write_data[] = "HELLO";
status = psa_ps_set(uid, sizeof(write_data), write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Second set should succeed for Thread_A");
return;
}
@@ -1275,13 +1317,13 @@ static void tfm_sst_test_1020_task_3(struct test_result_t *ret)
*/
static void tfm_sst_test_1020_task_4(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint8_t write_data[] = "WORLD_1234";
status = psa_ps_set(uid, sizeof(write_data), write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Second set should succeed for Thread_B");
return;
}
@@ -1294,14 +1336,16 @@ static void tfm_sst_test_1020_task_4(struct test_result_t *ret)
*/
static void tfm_sst_test_1020_task_5(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
const uint32_t offset = 0;
const uint8_t write_data[] = "HELLO";
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
- status = psa_ps_get(uid, offset, sizeof(write_data), read_data);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, sizeof(write_data), read_data,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should succeed for Thread_A");
return;
}
@@ -1320,14 +1364,16 @@ static void tfm_sst_test_1020_task_5(struct test_result_t *ret)
*/
static void tfm_sst_test_1020_task_6(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
const uint32_t offset = 0;
const uint8_t write_data[] = "WORLD_1234";
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
- status = psa_ps_get(uid, offset, sizeof(write_data), read_data);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, sizeof(write_data), read_data,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should succeed for Thread_B");
return;
}
@@ -1340,7 +1386,7 @@ static void tfm_sst_test_1020_task_6(struct test_result_t *ret)
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should work form Thread_B");
return;
}
@@ -1353,12 +1399,12 @@ static void tfm_sst_test_1020_task_6(struct test_result_t *ret)
*/
static void tfm_sst_test_1020_task_7(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should work form Thread_B");
return;
}
@@ -1415,26 +1461,27 @@ static void tfm_sst_test_1020(struct test_result_t *ret)
*/
TFM_SST_NS_TEST(1021, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid_1 = TEST_UID_2;
- const psa_ps_uid_t uid_2 = TEST_UID_3;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid_1 = TEST_UID_2;
+ const psa_storage_uid_t uid_2 = TEST_UID_3;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len_2 = WRITE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data_1[] = "UID 1 DATA";
const uint8_t write_data_2[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Set UID 1 */
status = psa_ps_set(uid_1, sizeof(write_data_1), write_data_1, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail for UID 1");
return;
}
/* Set UID 2 */
status = psa_ps_set(uid_2, data_len_2, write_data_2, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail for UID 2");
return;
}
@@ -1443,7 +1490,7 @@ TFM_SST_NS_TEST(1021, "Thread_A")
* the block.
*/
status = psa_ps_remove(uid_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail for UID 1");
return;
}
@@ -1452,8 +1499,8 @@ TFM_SST_NS_TEST(1021, "Thread_A")
* the data from UID 2 correctly.
*/
status = psa_ps_get(uid_2, offset, data_len_2,
- read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ read_data + HALF_PADDING_SIZE, &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail for UID 2");
return;
}
@@ -1465,7 +1512,7 @@ TFM_SST_NS_TEST(1021, "Thread_A")
/* Remove UID 2 to clean up storage for the next test */
status = psa_ps_remove(uid_2);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail for UID 2");
return;
}
@@ -1478,18 +1525,19 @@ TFM_SST_NS_TEST(1021, "Thread_A")
*/
TFM_SST_NS_TEST(1022, "Thread_A")
{
- psa_ps_status_t status;
+ psa_status_t status;
uint32_t i;
- const psa_ps_uid_t uid = TEST_UID_1;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Set the entire data into UID */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
@@ -1497,8 +1545,9 @@ TFM_SST_NS_TEST(1022, "Thread_A")
/* Get the data from UID one byte at a time */
for (i = 0; i < data_len; ++i) {
status = psa_ps_get(uid, offset, 1,
- (read_data + HALF_PADDING_SIZE + i));
- if (status != PSA_PS_SUCCESS) {
+ (read_data + HALF_PADDING_SIZE + i),
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail for partial read");
return;
}
@@ -1513,7 +1562,7 @@ TFM_SST_NS_TEST(1022, "Thread_A")
/* Remove UID to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail");
return;
}
@@ -1526,38 +1575,40 @@ TFM_SST_NS_TEST(1022, "Thread_A")
*/
TFM_SST_NS_TEST(1023, "Thread_A")
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t offset = 0;
const uint8_t write_data_1[] = "ONE";
const uint8_t write_data_2[] = "TWO";
const uint8_t write_data_3[] = "THREE";
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Set write data 1 into UID */
status = psa_ps_set(uid, sizeof(write_data_1), write_data_1, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("First set should not fail");
return;
}
/* Set write data 2 into UID */
status = psa_ps_set(uid, sizeof(write_data_2), write_data_2, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Second set should not fail");
return;
}
/* Set write data 3 into UID */
status = psa_ps_set(uid, sizeof(write_data_3), write_data_3, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Third set should not fail");
return;
}
- status = psa_ps_get(uid, offset, sizeof(write_data_3), read_data);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, sizeof(write_data_3), read_data,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -1570,7 +1621,7 @@ TFM_SST_NS_TEST(1023, "Thread_A")
/* Remove UID to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail");
return;
}
@@ -1603,8 +1654,8 @@ TFM_SST_NS_TEST(1024, "Thread_A")
TFM_SST_NS_TEST(1025, "Thread_A")
{
uint8_t cycle;
- psa_ps_status_t status;
- const psa_ps_uid_t test_uid[TEST_1025_CYCLES] = {
+ psa_status_t status;
+ const psa_storage_uid_t test_uid[TEST_1025_CYCLES] = {
TEST_UID_1,
TEST_UID_2,
TEST_UID_3};
@@ -1616,8 +1667,8 @@ TFM_SST_NS_TEST(1025, "Thread_A")
/* Loop to test different asset sizes and UID's*/
for (cycle = 0; cycle < TEST_1025_CYCLES; cycle++) {
uint32_t data_size = test_asset_sizes[cycle];
- psa_ps_uid_t uid = test_uid[cycle];
- struct psa_ps_info_t info = {0};
+ psa_storage_uid_t uid = test_uid[cycle];
+ struct psa_storage_info_t info = {0};
memset(read_asset_data, 0x00, sizeof(read_asset_data));
@@ -1625,15 +1676,15 @@ TFM_SST_NS_TEST(1025, "Thread_A")
status = psa_ps_set(uid,
data_size,
write_asset_data,
- PSA_PS_FLAG_NONE);
- if (status != PSA_PS_SUCCESS) {
+ PSA_STORAGE_FLAG_NONE);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
/* Get info for valid UID */
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get info should not fail with valid UID");
return;
}
@@ -1644,14 +1695,15 @@ TFM_SST_NS_TEST(1025, "Thread_A")
return;
}
- if (info.flags != PSA_PS_FLAG_NONE) {
+ if (info.flags != PSA_STORAGE_FLAG_NONE) {
TEST_FAIL("Flags incorrect for valid UID");
return;
}
/* Check that thread can still get UID */
- status = psa_ps_get(uid, 0, data_size, read_asset_data);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, 0, data_size, read_asset_data,
+ &read_asset_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail with valid UID");
return;
}
@@ -1664,7 +1716,7 @@ TFM_SST_NS_TEST(1025, "Thread_A")
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
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 db5a2d222..5a2b4d1f8 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -35,7 +35,7 @@ static uint32_t get_nv_counter_position(enum tfm_nv_counter_t counter_id)
}
/* Implementation of SST NV counter interfaces defined by sst_nv_counters.h */
-psa_ps_status_t sst_init_nv_counter(void)
+psa_status_t sst_init_nv_counter(void)
{
static uint8_t is_init = 0;
@@ -46,46 +46,46 @@ psa_ps_status_t sst_init_nv_counter(void)
is_init = 1;
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
- uint32_t *val)
+psa_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 PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Reads counter value */
*val = test_nv_counters[nv_pos];
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t sst_increment_nv_counter(enum tfm_nv_counter_t counter_id)
+psa_status_t sst_increment_nv_counter(enum tfm_nv_counter_t counter_id)
{
uint32_t nv_pos;
if (nv_increment_status == DISABLE_INCREMENT) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
nv_pos = get_nv_counter_position(counter_id);
if (nv_pos >= TOTAL_SST_NV_COUNTERS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
if (test_nv_counters[nv_pos] == UINT32_MAX) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Increments counter value */
test_nv_counters[nv_pos]++;
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
/* Implementation of SST NV counter interfaces defined by
@@ -101,48 +101,48 @@ void test_sst_enable_increment_nv_counter(void)
nv_increment_status = ENABLE_INCREMENT;
}
-psa_ps_status_t test_sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
- uint32_t *val)
+psa_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);
}
-psa_ps_status_t test_sst_increment_nv_counter(enum tfm_nv_counter_t counter_id)
+psa_status_t test_sst_increment_nv_counter(enum tfm_nv_counter_t counter_id)
{
return sst_increment_nv_counter(counter_id);
}
-psa_ps_status_t test_sst_decrement_nv_counter(enum tfm_nv_counter_t counter_id)
+psa_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 PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
if (test_nv_counters[nv_pos] == 0) {
- return PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Decrements counter value */
test_nv_counters[nv_pos]--;
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
-psa_ps_status_t test_sst_set_nv_counter(enum tfm_nv_counter_t counter_id,
- uint32_t value)
+psa_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 PSA_PS_ERROR_OPERATION_FAILED;
+ return PSA_ERROR_GENERIC_ERROR;
}
/* Sets counter value */
test_nv_counters[nv_pos] = value;
- return PSA_PS_SUCCESS;
+ return PSA_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 b1b85abb3..dafba3d46 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -22,10 +22,10 @@ extern "C" {
* \param[in] counter_id NV counter ID.
* \param[out] val Pointer to store the current NV counter value.
*
- * \return PSA_PS_SUCCESS if the value is read correctly, otherwise
- * PSA_PS_ERROR_OPERATION_FAILED
+ * \return PSA_SUCCESS if the value is read correctly, otherwise
+ * PSA_ERROR_GENERIC_ERROR
*/
-psa_ps_status_t test_sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
+psa_status_t test_sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
uint32_t *val);
/**
@@ -34,10 +34,10 @@ psa_ps_status_t test_sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
* \param[in] counter_id NV counter ID.
*
* \return When the NV counter reaches its maximum value, the
- * PSA_PS_ERROR_OPERATION_FAILED error is returned to indicate the
- * value cannot be incremented. Otherwise, PSA_PS_SUCCESS.
+ * PSA_ERROR_GENERIC_ERROR error is returned to indicate the
+ * value cannot be incremented. Otherwise, PSA_SUCCESS.
*/
-psa_ps_status_t test_sst_increment_nv_counter(enum tfm_nv_counter_t counter_id);
+psa_status_t test_sst_increment_nv_counter(enum tfm_nv_counter_t counter_id);
/**
* \brief Decrements the given non-volatile (NV) counter.
@@ -45,14 +45,14 @@ psa_ps_status_t test_sst_increment_nv_counter(enum tfm_nv_counter_t counter_id);
* \param[in] counter_id NV counter ID.
*
* \return When the NV counter reaches its minimum value, the
- * PSA_PS_ERROR_OPERATION_FAILED error is returned to indicate the
- * value cannot be decremented. Otherwise, PSA_PS_SUCCESS.
+ * PSA_ERROR_GENERIC_ERROR error is returned to indicate the
+ * value cannot be decremented. Otherwise, PSA_SUCCESS.
*/
-psa_ps_status_t test_sst_decrement_nv_counter(enum tfm_nv_counter_t counter_id);
+psa_status_t test_sst_decrement_nv_counter(enum tfm_nv_counter_t counter_id);
/**
* \brief Disables SST increment nv counter function to force
- * PSA_PS_ERROR_OPERATION_FAILED return value as an indication that NV
+ * PSA_ERROR_GENERIC_ERROR return value as an indication that NV
* counter reaches its maximum value.
*/
void test_sst_disable_increment_nv_counter(void);
@@ -69,15 +69,14 @@ void test_sst_enable_increment_nv_counter(void);
* \param[in] value New NV counter value.
*
* \return When the NV counter reaches its maximum value, the
- * PSA_PS_ERROR_OPERATION_FAILED error is returned to indicate the
- * value cannot be set. Otherwise, PSA_PS_SUCCESS.
+ * PSA_ERROR_GENERIC_ERROR error is returned to indicate the
+ * value cannot be set. Otherwise, PSA_SUCCESS.
*/
-psa_ps_status_t test_sst_set_nv_counter(enum tfm_nv_counter_t counter_id,
- uint32_t value);
+psa_status_t test_sst_set_nv_counter(enum tfm_nv_counter_t counter_id,
+ uint32_t value);
#ifdef __cplusplus
}
#endif
#endif /* __TEST_SST_NV_COUNTERS_H__ */
-
diff --git a/test/suites/sst/secure/psa_ps_s_interface_testsuite.c b/test/suites/sst/secure/psa_ps_s_interface_testsuite.c
index 102e7a539..5cc4985cc 100644
--- a/test/suites/sst/secure/psa_ps_s_interface_testsuite.c
+++ b/test/suites/sst/secure/psa_ps_s_interface_testsuite.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -38,11 +38,14 @@
#define WRITE_DATA_SIZE (sizeof(WRITE_DATA) - 1)
#define READ_DATA "_________________________________________"
#define RESULT_DATA ("____" WRITE_DATA "____")
+#define OFFSET_READ_DATA "HEQUICKBROWNFOXJUMPSOVERALAZYDOG"
+#define OFFSET_RESULT_DATA ("____" OFFSET_READ_DATA "_____")
#define TEST_1022_CYCLES 3U
static const uint8_t write_asset_data[SST_MAX_ASSET_SIZE] = {0xBF};
static uint8_t read_asset_data[SST_MAX_ASSET_SIZE] = {0};
+static size_t read_asset_datal_len = 0;
/* List of tests */
static void tfm_sst_test_2001(struct test_result_t *ret);
@@ -139,36 +142,36 @@ void register_testsuite_s_psa_ps_interface(struct test_suite_t *p_test_suite)
*/
static void tfm_sst_test_2001(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = 0;
const uint8_t write_data[] = {0};
/* Set with no data and no flags and a valid UID */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
/* Attempt to set a second time */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail the second time with valid UID");
return;
}
/* Set with an invalid UID */
status = psa_ps_set(INVALID_UID, data_len, write_data, flags);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Set should not succeed with an invalid UID");
return;
}
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -184,33 +187,34 @@ static void tfm_sst_test_2001(struct test_result_t *ret)
*/
static void tfm_sst_test_2002(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
/* Set with no flags */
status = psa_ps_set(WRITE_ONCE_UID, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with no flags");
return;
}
- /* Set with valid flag: PSA_PS_FLAG_WRITE_ONCE (with previously created UID)
+ /* Set with valid flag: PSA_STORAGE_FLAG_WRITE_ONCE
+ * (with previously created UID)
* Note: Once created, WRITE_ONCE_UID cannot be deleted. It is reused across
* multiple tests.
*/
status = psa_ps_set(WRITE_ONCE_UID, WRITE_ONCE_DATA_SIZE, WRITE_ONCE_DATA,
- PSA_PS_FLAG_WRITE_ONCE);
- if (status != PSA_PS_SUCCESS) {
+ PSA_STORAGE_FLAG_WRITE_ONCE);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid flags (and existing UID)");
return;
}
/* Set with invalid flags */
status = psa_ps_set(uid, data_len, write_data, INVALID_FLAG);
- if (status != PSA_PS_ERROR_FLAGS_NOT_SUPPORTED) {
+ if (status != PSA_ERROR_NOT_SUPPORTED) {
TEST_FAIL("Set should not succeed with invalid flags");
return;
}
@@ -229,14 +233,14 @@ static void tfm_sst_test_2002(struct test_result_t *ret)
*/
static void tfm_sst_test_2003(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = 0;
/* Set with NULL data pointer */
status = psa_ps_set(uid, data_len, NULL, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should succeed with NULL data pointer and zero length");
return;
}
@@ -251,9 +255,9 @@ static void tfm_sst_test_2003(struct test_result_t *ret)
static void tfm_sst_test_2004(struct test_result_t *ret)
{
#ifndef TFM_PSA_API
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = INVALID_DATA_LEN;
const uint8_t write_data[] = WRITE_DATA;
@@ -261,12 +265,12 @@ static void tfm_sst_test_2004(struct test_result_t *ret)
* maximum permitted, it is treated as a secure violation.
* TF-M framework rejects the request with a proper error code.
* The SST secure PSA PS implementation returns
- * PSA_PS_ERROR_OPERATION_FAILED in that case.
+ * PSA_ERROR_INVALID_ARGUMENT in that case.
*/
/* Set with data length longer than the maximum supported */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_ERROR_OPERATION_FAILED) {
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Set should not succeed with invalid data length");
return;
}
@@ -281,25 +285,27 @@ static void tfm_sst_test_2004(struct test_result_t *ret)
*/
static void tfm_sst_test_2005(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = WRITE_ONCE_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = WRITE_ONCE_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t write_len = WRITE_DATA_SIZE;
const uint32_t read_len = WRITE_ONCE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = WRITE_ONCE_READ_DATA;
+ size_t read_data_len = 0;
/* Set a write once UID a second time */
status = psa_ps_set(uid, write_len, write_data, flags);
- if (status != PSA_PS_ERROR_WRITE_ONCE) {
+ if (status != PSA_ERROR_NOT_PERMITTED) {
TEST_FAIL("Set should not rewrite a write once UID");
return;
}
/* Get write once data */
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -320,24 +326,26 @@ static void tfm_sst_test_2005(struct test_result_t *ret)
*/
static void tfm_sst_test_2006(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
uint32_t data_len = WRITE_DATA_SIZE;
uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
const uint8_t *p_read_data = read_data;
+ size_t read_data_len = 0;
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
/* Get the entire data */
- status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -355,8 +363,9 @@ static void tfm_sst_test_2006(struct test_result_t *ret)
offset = 2;
data_len -= offset + 2;
- status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -383,7 +392,7 @@ static void tfm_sst_test_2006(struct test_result_t *ret)
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -398,24 +407,26 @@ static void tfm_sst_test_2006(struct test_result_t *ret)
*/
static void tfm_sst_test_2007(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t write_len = WRITE_DATA_SIZE;
const uint32_t read_len = 0;
uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
status = psa_ps_set(uid, write_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
/* Get zero data from zero offset */
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail with zero data len");
return;
}
@@ -429,8 +440,9 @@ static void tfm_sst_test_2007(struct test_result_t *ret)
offset = 5;
/* Get zero data from non-zero offset */
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -443,7 +455,7 @@ static void tfm_sst_test_2007(struct test_result_t *ret)
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -458,15 +470,17 @@ static void tfm_sst_test_2007(struct test_result_t *ret)
*/
static void tfm_sst_test_2008(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
const uint32_t data_len = 1;
const uint32_t offset = 0;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Get with UID that has not yet been set */
- status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ status = psa_ps_get(uid, offset, data_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Get succeeded with non-existant UID");
return;
}
@@ -479,8 +493,8 @@ static void tfm_sst_test_2008(struct test_result_t *ret)
/* Get with invalid UID */
status = psa_ps_get(INVALID_UID, offset, data_len,
- read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ read_data + HALF_PADDING_SIZE, &read_data_len);
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Get succeeded with invalid UID");
return;
}
@@ -503,17 +517,18 @@ static void tfm_sst_test_2008(struct test_result_t *ret)
*/
static void tfm_sst_test_2009(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t write_len = WRITE_DATA_SIZE;
uint32_t read_len;
uint32_t offset;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
status = psa_ps_set(uid, write_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
@@ -522,8 +537,9 @@ static void tfm_sst_test_2009(struct test_result_t *ret)
read_len = 1;
offset = write_len + 1;
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_OFFSET_INVALID) {
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Get should not succeed with offset too large");
return;
}
@@ -538,14 +554,21 @@ static void tfm_sst_test_2009(struct test_result_t *ret)
read_len = write_len + 1;
offset = 0;
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_INCORRECT_SIZE) {
- TEST_FAIL("Get should not succeed with data length too large");
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
+ TEST_FAIL("Get should succeed with data length larger than UID's "
+ "length");
+ return;
+ }
+
+ if (read_data_len != write_len) {
+ TEST_FAIL("Read data length should be equal to UID's length");
return;
}
/* Check that the read data is unchanged */
- if (tfm_memcmp(read_data, READ_DATA, sizeof(read_data)) != 0) {
+ if (tfm_memcmp(read_data, RESULT_DATA, sizeof(read_data)) != 0) {
TEST_FAIL("Read data should be equal to original read data");
return;
}
@@ -556,14 +579,25 @@ static void tfm_sst_test_2009(struct test_result_t *ret)
read_len = write_len;
offset = 1;
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_INCORRECT_SIZE) {
- TEST_FAIL("Get should not succeed with offset + data length too large");
+ /* Reset read_data to original READ_DATA */
+ tfm_memcpy(read_data, READ_DATA, sizeof(read_data));
+
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
+ TEST_FAIL("Get should succeed with offset + data length too large, "
+ "but individually valid");
+ return;
+ }
+
+ if (read_data_len != write_len - offset) {
+ TEST_FAIL("Read data length should be equal to the UID's remaining "
+ "size starting from offset");
return;
}
/* Check that the read data is unchanged */
- if (tfm_memcmp(read_data, READ_DATA, sizeof(read_data)) != 0) {
+ if (tfm_memcmp(read_data, OFFSET_RESULT_DATA, sizeof(read_data)) != 0) {
TEST_FAIL("Read data should be equal to original read data");
return;
}
@@ -573,15 +607,19 @@ static void tfm_sst_test_2009(struct test_result_t *ret)
read_len = INVALID_DATA_LEN;
offset = INVALID_OFFSET;
+ /* Reset read_data to original READ_DATA */
+ tfm_memcpy(read_data, READ_DATA, sizeof(read_data));
+
/* A parameter with a buffer pointer where its data length is longer than
* maximum permitted, it is treated as a secure violation.
* TF-M framework rejects the request with a proper error code.
* The SST secure PSA PS implementation returns
- * PSA_PS_ERROR_OPERATION_FAILED in that case.
+ * PSA_ERROR_INVALID_ARGUMENT in that case.
*/
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_OPERATION_FAILED) {
+ status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE,
+ &read_data_len);
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Get should not succeed with invalid arguments");
return;
}
@@ -595,7 +633,7 @@ static void tfm_sst_test_2009(struct test_result_t *ret)
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -614,29 +652,29 @@ static void tfm_sst_test_2009(struct test_result_t *ret)
*/
static void tfm_sst_test_2010(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
/* Get with NULL data pointer */
- status = psa_ps_get(uid, offset, 0, NULL);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, 0, NULL, NULL);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should succeed with NULL data pointer and zero length");
return;
}
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -650,13 +688,13 @@ static void tfm_sst_test_2010(struct test_result_t *ret)
*/
static void tfm_sst_test_2011(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = WRITE_ONCE_UID;
- struct psa_ps_info_t info = {0};
+ psa_status_t status;
+ const psa_storage_uid_t uid = WRITE_ONCE_UID;
+ struct psa_storage_info_t info = {0};
/* Get info for write once UID */
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get info should not fail for write once UID");
return;
}
@@ -667,7 +705,7 @@ static void tfm_sst_test_2011(struct test_result_t *ret)
return;
}
- if (info.flags != PSA_PS_FLAG_WRITE_ONCE) {
+ if (info.flags != PSA_STORAGE_FLAG_WRITE_ONCE) {
TEST_FAIL("Flags incorrect for write once UID");
return;
}
@@ -681,22 +719,22 @@ static void tfm_sst_test_2011(struct test_result_t *ret)
*/
static void tfm_sst_test_2012(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- struct psa_ps_info_t info = {0};
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ struct psa_storage_info_t info = {0};
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
/* Get info for valid UID */
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get info should not fail with valid UID");
return;
}
@@ -714,7 +752,7 @@ static void tfm_sst_test_2012(struct test_result_t *ret)
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -729,13 +767,13 @@ static void tfm_sst_test_2012(struct test_result_t *ret)
*/
static void tfm_sst_test_2013(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
- struct psa_ps_info_t info = {0};
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
+ struct psa_storage_info_t info = {0};
/* Get info with UID that has not yet been set */
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Get info should not succeed with unset UID");
return;
}
@@ -753,7 +791,7 @@ static void tfm_sst_test_2013(struct test_result_t *ret)
/* Get info with invalid UID */
status = psa_ps_get_info(INVALID_UID, &info);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Get info should not succeed with invalid UID");
return;
}
@@ -778,14 +816,14 @@ static void tfm_sst_test_2013(struct test_result_t *ret)
*/
static void tfm_sst_test_2014(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_3;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_3;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
@@ -793,13 +831,13 @@ static void tfm_sst_test_2014(struct test_result_t *ret)
/* A parameter with a null pointer is treated as a secure violation.
* TF-M framework rejects the request with a proper error code.
* The SST secure PSA PS implementation returns
- * PSA_PS_ERROR_OPERATION_FAILED in that case.
+ * PSA_ERROR_GENERIC_ERROR in that case.
*/
/* Get info with NULL info pointer */
#ifndef TFM_PSA_API
status = psa_ps_get_info(uid, NULL);
- if (status != PSA_PS_ERROR_OPERATION_FAILED) {
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Get info should not succeed with NULL info pointer");
return;
}
@@ -807,7 +845,7 @@ static void tfm_sst_test_2014(struct test_result_t *ret)
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -821,45 +859,46 @@ static void tfm_sst_test_2014(struct test_result_t *ret)
*/
static void tfm_sst_test_2015(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_1;
- struct psa_ps_info_t info = {0};
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ struct psa_storage_info_t info = {0};
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
/* Call remove with valid ID */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
/* Check that get info fails for removed UID */
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Get info should not succeed with removed UID");
return;
}
/* Check that get fails for removed UID */
- status = psa_ps_get(uid, offset, data_len, read_data);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ status = psa_ps_get(uid, offset, data_len, read_data, &read_data_len);
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Get should not succeed with removed UID");
return;
}
/* Check that remove fails for removed UID */
status = psa_ps_remove(uid);
- if (status != PSA_PS_ERROR_UID_NOT_FOUND) {
+ if (status != PSA_ERROR_DOES_NOT_EXIST) {
TEST_FAIL("Remove should not succeed with removed UID");
return;
}
@@ -873,12 +912,12 @@ static void tfm_sst_test_2015(struct test_result_t *ret)
*/
static void tfm_sst_test_2016(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = WRITE_ONCE_UID;
+ psa_status_t status;
+ const psa_storage_uid_t uid = WRITE_ONCE_UID;
/* Call remove with write once UID */
status = psa_ps_remove(uid);
- if (status != PSA_PS_ERROR_WRITE_ONCE) {
+ if (status != PSA_ERROR_NOT_PERMITTED) {
TEST_FAIL("Remove should not succeed with write once UID");
return;
}
@@ -892,12 +931,12 @@ static void tfm_sst_test_2016(struct test_result_t *ret)
*/
static void tfm_sst_test_2017(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = INVALID_UID;
+ psa_status_t status;
+ const psa_storage_uid_t uid = INVALID_UID;
/* Call remove with an invalid UID */
status = psa_ps_remove(uid);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ if (status != PSA_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Remove should not succeed with invalid UID");
return;
}
@@ -914,26 +953,27 @@ static void tfm_sst_test_2017(struct test_result_t *ret)
*/
static void tfm_sst_test_2018(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid_1 = TEST_UID_2;
- const psa_ps_uid_t uid_2 = TEST_UID_3;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid_1 = TEST_UID_2;
+ const psa_storage_uid_t uid_2 = TEST_UID_3;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len_2 = WRITE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data_1[] = "UID 1 DATA";
const uint8_t write_data_2[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Set UID 1 */
status = psa_ps_set(uid_1, sizeof(write_data_1), write_data_1, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail for UID 1");
return;
}
/* Set UID 2 */
status = psa_ps_set(uid_2, data_len_2, write_data_2, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail for UID 2");
return;
}
@@ -942,7 +982,7 @@ static void tfm_sst_test_2018(struct test_result_t *ret)
* the block.
*/
status = psa_ps_remove(uid_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail for UID 1");
return;
}
@@ -951,8 +991,8 @@ static void tfm_sst_test_2018(struct test_result_t *ret)
* the data from UID 2 correctly.
*/
status = psa_ps_get(uid_2, offset, data_len_2,
- read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_SUCCESS) {
+ read_data + HALF_PADDING_SIZE, &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail for UID 2");
return;
}
@@ -964,7 +1004,7 @@ static void tfm_sst_test_2018(struct test_result_t *ret)
/* Remove UID 2 to clean up storage for the next test */
status = psa_ps_remove(uid_2);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail for UID 2");
return;
}
@@ -977,18 +1017,19 @@ static void tfm_sst_test_2018(struct test_result_t *ret)
*/
static void tfm_sst_test_2019(struct test_result_t *ret)
{
- psa_ps_status_t status;
+ psa_status_t status;
uint32_t i;
- const psa_ps_uid_t uid = TEST_UID_1;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ const psa_storage_uid_t uid = TEST_UID_1;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Set the entire data into UID */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail");
return;
}
@@ -996,8 +1037,9 @@ static void tfm_sst_test_2019(struct test_result_t *ret)
/* Get the data from UID one byte at a time */
for (i = 0; i < data_len; ++i) {
status = psa_ps_get(uid, offset, 1,
- (read_data + HALF_PADDING_SIZE + i));
- if (status != PSA_PS_SUCCESS) {
+ (read_data + HALF_PADDING_SIZE + i),
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail for partial read");
return;
}
@@ -1012,7 +1054,7 @@ static void tfm_sst_test_2019(struct test_result_t *ret)
/* Remove UID to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail");
return;
}
@@ -1025,38 +1067,40 @@ static void tfm_sst_test_2019(struct test_result_t *ret)
*/
static void tfm_sst_test_2020(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID_2;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID_2;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t offset = 0;
const uint8_t write_data_1[] = "ONE";
const uint8_t write_data_2[] = "TWO";
const uint8_t write_data_3[] = "THREE";
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Set write data 1 into UID */
status = psa_ps_set(uid, sizeof(write_data_1), write_data_1, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("First set should not fail");
return;
}
/* Set write data 2 into UID */
status = psa_ps_set(uid, sizeof(write_data_2), write_data_2, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Second set should not fail");
return;
}
/* Set write data 3 into UID */
status = psa_ps_set(uid, sizeof(write_data_3), write_data_3, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Third set should not fail");
return;
}
- status = psa_ps_get(uid, offset, sizeof(write_data_3), read_data);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, offset, sizeof(write_data_3), read_data,
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -1069,7 +1113,7 @@ static void tfm_sst_test_2020(struct test_result_t *ret)
/* Remove UID to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail");
return;
}
@@ -1102,8 +1146,8 @@ static void tfm_sst_test_2021(struct test_result_t *ret)
static void tfm_sst_test_2022(struct test_result_t *ret)
{
uint8_t cycle;
- psa_ps_status_t status;
- const psa_ps_uid_t test_uid[TEST_1022_CYCLES] = {
+ psa_status_t status;
+ const psa_storage_uid_t test_uid[TEST_1022_CYCLES] = {
TEST_UID_1,
TEST_UID_2,
TEST_UID_3};
@@ -1115,8 +1159,8 @@ static void tfm_sst_test_2022(struct test_result_t *ret)
/* Loop to test different asset sizes and UID's*/
for (cycle = 0; cycle < TEST_1022_CYCLES; cycle++) {
uint32_t data_size = test_asset_sizes[cycle];
- psa_ps_uid_t uid = test_uid[cycle];
- struct psa_ps_info_t info = {0};
+ psa_storage_uid_t uid = test_uid[cycle];
+ struct psa_storage_info_t info = {0};
tfm_memset(read_asset_data, 0x00, sizeof(read_asset_data));
@@ -1124,15 +1168,15 @@ static void tfm_sst_test_2022(struct test_result_t *ret)
status = psa_ps_set(uid,
data_size,
write_asset_data,
- PSA_PS_FLAG_NONE);
- if (status != PSA_PS_SUCCESS) {
+ PSA_STORAGE_FLAG_NONE);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
/* Get info for valid UID */
status = psa_ps_get_info(uid, &info);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get info should not fail with valid UID");
return;
}
@@ -1143,14 +1187,15 @@ static void tfm_sst_test_2022(struct test_result_t *ret)
return;
}
- if (info.flags != PSA_PS_FLAG_NONE) {
+ if (info.flags != PSA_STORAGE_FLAG_NONE) {
TEST_FAIL("Flags incorrect for valid UID");
return;
}
/* Check that thread can still get UID */
- status = psa_ps_get(uid, 0, data_size, read_asset_data);
- if (status != PSA_PS_SUCCESS) {
+ status = psa_ps_get(uid, 0, data_size, read_asset_data,
+ &read_asset_datal_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail with valid UID");
return;
}
@@ -1163,7 +1208,7 @@ static void tfm_sst_test_2022(struct test_result_t *ret)
/* Call remove to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
diff --git a/test/suites/sst/secure/psa_ps_s_reliability_testsuite.c b/test/suites/sst/secure/psa_ps_s_reliability_testsuite.c
index 417a02fb5..4fbcabd4e 100644
--- a/test/suites/sst/secure/psa_ps_s_reliability_testsuite.c
+++ b/test/suites/sst/secure/psa_ps_s_reliability_testsuite.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -55,29 +55,31 @@ void register_testsuite_s_psa_ps_reliability(struct test_suite_t *p_test_suite)
*/
static void tfm_sst_test_3001(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
uint32_t itr;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
for (itr = 0; itr < LOOP_ITERATIONS_001; itr++) {
TEST_LOG(" > Iteration %d of %d\r", itr + 1, LOOP_ITERATIONS_001);
/* Set a data in the asset */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
/* Get data from the asset */
status = psa_ps_get(uid, offset, data_len, (read_data +
- HALF_PADDING_SIZE));
- if (status != PSA_PS_SUCCESS) {
+ HALF_PADDING_SIZE),
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -96,7 +98,7 @@ static void tfm_sst_test_3001(struct test_result_t *ret)
/* Remove the asset to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -109,29 +111,31 @@ static void tfm_sst_test_3001(struct test_result_t *ret)
*/
static void tfm_sst_test_3002(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
uint32_t itr;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
for (itr = 0; itr < LOOP_ITERATIONS_002; itr++) {
TEST_LOG(" > Iteration %d of %d\r", itr + 1, LOOP_ITERATIONS_002);
/* Set a data in the asset */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
/* Get data from the asset */
status = psa_ps_get(uid, offset, data_len, (read_data +
- HALF_PADDING_SIZE));
- if (status != PSA_PS_SUCCESS) {
+ HALF_PADDING_SIZE),
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -144,7 +148,7 @@ static void tfm_sst_test_3002(struct test_result_t *ret)
/* Remove the asset from the secure storage */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
diff --git a/test/suites/sst/secure/sst_rollback_protection_testsuite.c b/test/suites/sst/secure/sst_rollback_protection_testsuite.c
index de96fdbc0..9c31d1684 100644
--- a/test/suites/sst/secure/sst_rollback_protection_testsuite.c
+++ b/test/suites/sst/secure/sst_rollback_protection_testsuite.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -105,32 +105,33 @@ void register_testsuite_s_rollback_protection(struct test_suite_t *p_test_suite)
*/
static void tfm_sst_test_4001(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
uint32_t old_nvc_1, nvc_1, nvc_2, nvc_3;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Creates an asset in the SST area to generate a new SST area version */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
/* Reads NV counter 1 to get the saved value to compare it later */
status = test_sst_read_nv_counter(TFM_SST_NV_COUNTER_1, &old_nvc_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Read should not fail");
return;
}
/* Sets new data in the asset to generate a new SST area version */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
@@ -141,7 +142,7 @@ static void tfm_sst_test_4001(struct test_result_t *ret)
/* Reads NV counter 1 to get the current value */
status = test_sst_read_nv_counter(TFM_SST_NV_COUNTER_1, &nvc_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Read should not fail");
return;
}
@@ -156,7 +157,7 @@ static void tfm_sst_test_4001(struct test_result_t *ret)
/* Reads NV counter 2 to get the current value */
status = test_sst_read_nv_counter(TFM_SST_NV_COUNTER_2, &nvc_2);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Read should not fail");
return;
}
@@ -168,7 +169,7 @@ static void tfm_sst_test_4001(struct test_result_t *ret)
/* Reads NV counter 3 to get the current value */
status = test_sst_read_nv_counter(TFM_SST_NV_COUNTER_3, &nvc_3);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Read should not fail");
return;
}
@@ -185,15 +186,16 @@ static void tfm_sst_test_4001(struct test_result_t *ret)
* the SST area authentication is aligned with those values.
*/
status = tfm_sst_test_system_prepare();
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("AM prepare should not fail");
return;
}
/* Gets data from the asset */
status = psa_ps_get(uid, offset, data_len, (read_data +
- HALF_PADDING_SIZE));
- if (status != PSA_PS_SUCCESS) {
+ HALF_PADDING_SIZE),
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -206,7 +208,7 @@ static void tfm_sst_test_4001(struct test_result_t *ret)
/* Removes the asset to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -220,34 +222,34 @@ static void tfm_sst_test_4001(struct test_result_t *ret)
*/
static void tfm_sst_test_4002(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
/* Creates an asset in the SST area to generate a new SST area version */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
/* Increments all counters to make that SST area version old/invalid */
status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_2);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_3);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
@@ -259,7 +261,7 @@ static void tfm_sst_test_4002(struct test_result_t *ret)
* NV counters values.
*/
status = tfm_sst_test_system_prepare();
- if (status != PSA_PS_ERROR_OPERATION_FAILED) {
+ if (status != PSA_ERROR_GENERIC_ERROR) {
TEST_FAIL("SST system prepare should fail as version is old");
return;
}
@@ -276,33 +278,33 @@ static void tfm_sst_test_4002(struct test_result_t *ret)
/* Aligns NV counters with the SST area version */
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_2);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
/* Calls sst_system_prepare to mark the SST area as a valid image */
status = tfm_sst_test_system_prepare();
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
/* Removes the asset to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -318,17 +320,18 @@ static void tfm_sst_test_4002(struct test_result_t *ret)
*/
static void tfm_sst_test_4003(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Creates an asset in the SST area to generate a new SST area version */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
@@ -337,7 +340,7 @@ static void tfm_sst_test_4003(struct test_result_t *ret)
* and make the current SST area version match NV counter 1 and 2 values.
*/
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
@@ -349,15 +352,16 @@ static void tfm_sst_test_4003(struct test_result_t *ret)
* 2 values.
*/
status = tfm_sst_test_system_prepare();
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
/* Gets the data from the asset */
status = psa_ps_get(uid, offset, data_len, (read_data +
- HALF_PADDING_SIZE));
- if (status != PSA_PS_SUCCESS) {
+ HALF_PADDING_SIZE),
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -370,7 +374,7 @@ static void tfm_sst_test_4003(struct test_result_t *ret)
/* Removes the asset to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -387,17 +391,18 @@ static void tfm_sst_test_4003(struct test_result_t *ret)
*/
static void tfm_sst_test_4004(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Creates an asset in the SST area to generate a new SST area version */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
@@ -406,7 +411,7 @@ static void tfm_sst_test_4004(struct test_result_t *ret)
* and make the current SST area version match NV counter 2 and 3 values.
*/
status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
@@ -418,15 +423,16 @@ static void tfm_sst_test_4004(struct test_result_t *ret)
* and 3 values.
*/
status = tfm_sst_test_system_prepare();
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
/* Gets the data from the asset */
status = psa_ps_get(uid, offset, data_len, (read_data +
- HALF_PADDING_SIZE));
- if (status != PSA_PS_SUCCESS) {
+ HALF_PADDING_SIZE),
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -439,7 +445,7 @@ static void tfm_sst_test_4004(struct test_result_t *ret)
/* Removes the asset to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -456,17 +462,18 @@ static void tfm_sst_test_4004(struct test_result_t *ret)
*/
static void tfm_sst_test_4005(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Creates an asset in the SST area to generate a new SST area version */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
@@ -475,13 +482,13 @@ static void tfm_sst_test_4005(struct test_result_t *ret)
* counter 1 only.
*/
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_2);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
@@ -492,15 +499,16 @@ static void tfm_sst_test_4005(struct test_result_t *ret)
* Prepare should not fail as the SST area version match the NV counter 1.
*/
status = tfm_sst_test_system_prepare();
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
/* Gets the data from the asset */
status = psa_ps_get(uid, offset, data_len, (read_data +
- HALF_PADDING_SIZE));
- if (status != PSA_PS_SUCCESS) {
+ HALF_PADDING_SIZE),
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -513,7 +521,7 @@ static void tfm_sst_test_4005(struct test_result_t *ret)
/* Removes the asset to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -527,17 +535,18 @@ static void tfm_sst_test_4005(struct test_result_t *ret)
*/
static void tfm_sst_test_4006(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint32_t offset = 0;
const uint8_t write_data[] = WRITE_DATA;
uint8_t read_data[] = READ_DATA;
+ size_t read_data_len = 0;
/* Creates an asset in the SST area to generate a new SST area version */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
@@ -546,19 +555,19 @@ static void tfm_sst_test_4006(struct test_result_t *ret)
* version match NV counter 1 only.
*/
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_2);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
@@ -569,15 +578,16 @@ static void tfm_sst_test_4006(struct test_result_t *ret)
* Prepare should not fail as the SST area version match the NV counter 1.
*/
status = tfm_sst_test_system_prepare();
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
/* Gets data from the asset */
status = psa_ps_get(uid, offset, data_len, (read_data +
- HALF_PADDING_SIZE));
- if (status != PSA_PS_SUCCESS) {
+ HALF_PADDING_SIZE),
+ &read_data_len);
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Get should not fail");
return;
}
@@ -590,7 +600,7 @@ static void tfm_sst_test_4006(struct test_result_t *ret)
/* Removes the asset to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -604,15 +614,15 @@ static void tfm_sst_test_4006(struct test_result_t *ret)
*/
static void tfm_sst_test_4007(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
/* Creates an asset in the SST area to generate a new SST area version */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
@@ -621,13 +631,13 @@ static void tfm_sst_test_4007(struct test_result_t *ret)
* version match NV counter 2 only.
*/
status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_3);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
@@ -639,7 +649,7 @@ static void tfm_sst_test_4007(struct test_result_t *ret)
* the other counters are different.
*/
status = tfm_sst_test_system_prepare();
- if (status != PSA_PS_ERROR_OPERATION_FAILED) {
+ if (status != PSA_ERROR_GENERIC_ERROR) {
TEST_FAIL("SST system prepare should fail");
return;
}
@@ -656,27 +666,27 @@ static void tfm_sst_test_4007(struct test_result_t *ret)
/* Aligns NV counters with the SST area version */
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_3);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
/* Calls sst_system_prepare to mark the SST area as a valid image */
status = tfm_sst_test_system_prepare();
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
/* Removes the asset to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -690,15 +700,15 @@ static void tfm_sst_test_4007(struct test_result_t *ret)
*/
static void tfm_sst_test_4008(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
/* Creates an asset in the SST area to generate a new SST area version */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Set should not fail with valid UID");
return;
}
@@ -707,19 +717,19 @@ static void tfm_sst_test_4008(struct test_result_t *ret)
* version match NV counter 3 only.
*/
status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
status = test_sst_increment_nv_counter(TFM_SST_NV_COUNTER_2);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Increment should not fail");
return;
}
@@ -731,7 +741,7 @@ static void tfm_sst_test_4008(struct test_result_t *ret)
* the other counters are different.
*/
status = tfm_sst_test_system_prepare();
- if (status != PSA_PS_ERROR_OPERATION_FAILED) {
+ if (status != PSA_ERROR_GENERIC_ERROR) {
TEST_FAIL("AM prepare should fail");
return;
}
@@ -748,33 +758,33 @@ static void tfm_sst_test_4008(struct test_result_t *ret)
/* Align NV counters with the SST area version */
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_1);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
status = test_sst_decrement_nv_counter(TFM_SST_NV_COUNTER_2);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Decrement should not fail");
return;
}
/* Calls sst_system_prepare to mark the SST area as a valid image */
status = tfm_sst_test_system_prepare();
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("SST system prepare should not fail");
return;
}
/* Removes the asset to clean up storage for the next test */
status = psa_ps_remove(uid);
- if (status != PSA_PS_SUCCESS) {
+ if (status != PSA_SUCCESS) {
TEST_FAIL("Remove should not fail with valid UID");
return;
}
@@ -788,9 +798,9 @@ static void tfm_sst_test_4008(struct test_result_t *ret)
*/
static void tfm_sst_test_4009(struct test_result_t *ret)
{
- psa_ps_status_t status;
- const psa_ps_uid_t uid = TEST_UID;
- const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
+ psa_status_t status;
+ const psa_storage_uid_t uid = TEST_UID;
+ const psa_storage_create_flags_t flags = PSA_STORAGE_FLAG_NONE;
const uint32_t data_len = WRITE_DATA_SIZE;
const uint8_t write_data[] = WRITE_DATA;
@@ -801,7 +811,7 @@ static void tfm_sst_test_4009(struct test_result_t *ret)
/* Creates an asset in the SST area to generate a new SST area version */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_ERROR_OPERATION_FAILED) {
+ if (status != PSA_ERROR_GENERIC_ERROR) {
TEST_FAIL("Set should fail as the non-volatile counters can not be"
" increased");
return;