SST: Implement PSA Protected Storage 1.0
Refactors SST to implement PSA Protected Storage version 1.0.
Change-Id: I967375e98799a465069525f203881f5331d6d84a
Signed-off-by: Galanakis, Minos <minos.galanakis@arm.com>
diff --git a/interface/src/tfm_sst_func_api.c b/interface/src/tfm_sst_func_api.c
index 6d94d67..77a466e 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_INVALID_ARGUMENT;
+ }
+
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 @@
(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));
+ (uint32_t)NULL, 0);
- 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 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 9ef95ff..8d0dc43 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 @@
{ .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_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_INVALID_ARGUMENT;
+ }
+
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_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_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_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 c2d8325..d3480c3 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 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 @@
/* 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 @@
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_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)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 @@
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 @@
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 @@
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 @@
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 2d8f89e..7b10b55 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 @@
/**
* \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 @@
* \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 @@
* \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 @@
* \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 @@
* \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/nv_counters/sst_nv_counters.c b/secure_fw/services/secure_storage/nv_counters/sst_nv_counters.c
index df97c03..6d49efa 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 @@
*/
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 2c3bfc1..3448413 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 @@
/**
* \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 @@
* \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 @@
* \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 aad2752..0be7d3b 100644
--- a/secure_fw/services/secure_storage/sst_encrypted_object.c
+++ b/secure_fw/services/secure_storage/sst_encrypted_object.c
@@ -43,18 +43,18 @@
* 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;
}
@@ -73,9 +73,9 @@
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();
@@ -90,18 +90,18 @@
* \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;
}
@@ -122,9 +122,9 @@
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);
@@ -132,20 +132,18 @@
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;
uint32_t decrypt_size;
size_t data_length;
/* Read the encrypted object from the the persistent area */
- err = psa_status_to_psa_ps_status(
- psa_its_get(fid, SST_OBJECT_START_POSITION,
- SST_MAX_OBJECT_SIZE,
- (void *)obj->header.crypto.ref.iv,
- &data_length));
- if (err != PSA_PS_SUCCESS) {
+ err = psa_its_get(fid, SST_OBJECT_START_POSITION,
+ SST_MAX_OBJECT_SIZE,
+ (void *)obj->header.crypto.ref.iv,
+ &data_length);
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -154,24 +152,23 @@
/* 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.current_size);
/* 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;
}
@@ -180,8 +177,6 @@
/* Write the encrypted object to the persistent area. The tag values is not
* copied as it is stored in the object table.
*/
- return psa_status_to_psa_ps_status(
- psa_its_set(fid, wrt_size,
- (const void *)obj->header.crypto.ref.iv,
- PSA_STORAGE_FLAG_NONE));
+ return psa_its_set(fid, wrt_size, (const void *)obj->header.crypto.ref.iv,
+ PSA_STORAGE_FLAG_NONE);
}
diff --git a/secure_fw/services/secure_storage/sst_encrypted_object.h b/secure_fw/services/secure_storage/sst_encrypted_object.h
index ce72f16..eed82af 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 @@
* \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 @@
* 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 a5e264b..2ac7fd4 100644
--- a/secure_fw/services/secure_storage/sst_object_defs.h
+++ b/secure_fw/services/secure_storage/sst_object_defs.h
@@ -25,7 +25,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 33f4743..5dec285 100644
--- a/secure_fw/services/secure_storage/sst_object_system.c
+++ b/secure_fw/services/secure_storage/sst_object_system.c
@@ -39,9 +39,10 @@
*
*/
__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,20 +62,20 @@
*
* \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;
}
/* Delete old file from the persistent area */
- return psa_status_to_psa_ps_status(psa_its_remove(old_fid));
+ return psa_its_remove(old_fid);
}
#ifndef SST_ENCRYPTION
@@ -89,19 +90,19 @@
*
* \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;
size_t data_length;
/* Read object header */
- err = psa_status_to_psa_ps_status(psa_its_get(g_obj_tbl_info.fid,
- SST_OBJECT_START_POSITION,
- SST_OBJECT_HEADER_SIZE,
- (void *)&g_sst_object.header,
- &data_length));
+ err = psa_its_get(g_obj_tbl_info.fid,
+ SST_OBJECT_START_POSITION,
+ SST_OBJECT_HEADER_SIZE,
+ (void *)&g_sst_object.header,
+ &data_length);
if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -116,12 +117,11 @@
/* Read object data if any */
if (type == READ_ALL_OBJECT && g_sst_object.header.info.current_size > 0) {
- err = psa_status_to_psa_ps_status(
- psa_its_get(g_obj_tbl_info.fid,
- SST_OBJECT_HEADER_SIZE,
- g_sst_object.header.info.current_size,
- (void *)g_sst_object.data,
- &data_length));
+ err = psa_its_get(g_obj_tbl_info.fid,
+ SST_OBJECT_HEADER_SIZE,
+ g_sst_object.header.info.current_size,
+ (void *)g_sst_object.data,
+ &data_length);
if (err != PSA_PS_SUCCESS) {
return err;
}
@@ -136,9 +136,9 @@
*
* \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)
{
/* Add object identification and increase object version */
g_sst_object.header.fid = g_obj_tbl_info.fid;
@@ -147,16 +147,16 @@
/* Save object version to be stored in the object table */
g_obj_tbl_info.version = g_sst_object.header.version;
- return psa_status_to_psa_ps_status(psa_its_set(g_obj_tbl_info.fid, wrt_size,
- (const void *)&g_sst_object,
- PSA_STORAGE_FLAG_NONE));
+ return psa_its_set(g_obj_tbl_info.fid, wrt_size,
+ (const void *)&g_sst_object,
+ PSA_STORAGE_FLAG_NONE);
}
#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;
/* Reuse the allocated g_sst_object.data to store a temporary object table
* data to be validate inside the function.
@@ -172,16 +172,17 @@
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;
}
@@ -192,20 +193,24 @@
/* 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,
@@ -214,11 +219,11 @@
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;
@@ -228,14 +233,14 @@
/* 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);
@@ -243,7 +248,7 @@
/* 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;
}
@@ -251,8 +256,8 @@
* 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;
}
@@ -262,7 +267,7 @@
/* 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.
*/
@@ -274,7 +279,7 @@
/* 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;
}
@@ -284,7 +289,7 @@
/* 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;
}
@@ -296,7 +301,7 @@
/* 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;
}
@@ -304,7 +309,7 @@
* 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.
*/
@@ -329,10 +334,10 @@
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
@@ -343,7 +348,7 @@
* 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;
}
@@ -353,13 +358,13 @@
#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;
}
@@ -367,20 +372,20 @@
* 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;
}
@@ -394,7 +399,7 @@
/* 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;
}
@@ -406,7 +411,7 @@
/* 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;
}
@@ -414,7 +419,7 @@
* 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.
*/
@@ -434,16 +439,16 @@
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;
}
@@ -452,7 +457,7 @@
#else
err = sst_read_object(READ_HEADER_ONLY);
#endif
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
@@ -468,15 +473,15 @@
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;
}
@@ -485,13 +490,13 @@
#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;
}
@@ -499,7 +504,7 @@
* area.
*/
err = sst_object_table_delete_object(uid, client_id);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
goto clear_data_and_return;
}
@@ -514,7 +519,7 @@
return err;
}
-psa_ps_status_t sst_system_wipe_all(void)
+psa_status_t sst_system_wipe_all(void)
{
/* This function may get called as a corrective action
* if a system level security violation is detected.
diff --git a/secure_fw/services/secure_storage/sst_object_system.h b/secure_fw/services/secure_storage/sst_object_system.h
index b6e677c..75702c3 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 @@
* 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,24 +33,27 @@
* \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.
*
- * \param[in] uid Unique identifier for the data
- * \param[in] client_id Identifier of the asset's owner (client)
- * \param[in] offset Offset in the object at which to begin the read
- * \param[in] size Size of the contents of `data` in bytes
+ * \param[in] uid Unique identifier for the data
+ * \param[in] client_id Identifier of the asset's owner (client)
+ * \param[in] offset Offset in the object at which to begin the read
+ * \param[in] size Size of the contents of `data` in bytes
+ * \param[out] p_data_length On success, this will contain size of the data
+ * written to asset
*
- * \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 +63,10 @@
* \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 +74,9 @@
* \param[in] uid Unique identifier for the data
* \param[in] client_id Identifier of the asset's owner (client)
*
- * \return Returns error code specified in \ref 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 +84,20 @@
*
* \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 2c5fff3..96a8906 100644
--- a/secure_fw/services/secure_storage/sst_object_table.c
+++ b/secure_fw/services/secure_storage/sst_object_table.c
@@ -39,7 +39,7 @@
#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 */
};
@@ -218,28 +218,27 @@
__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;
size_t data_length;
/* Read file with the table 0 data */
- err = psa_status_to_psa_ps_status(
- psa_its_get(SST_TABLE_FS_ID(SST_OBJ_TABLE_IDX_0),
- SST_OBJECT_TABLE_OBJECT_OFFSET,
- SST_OBJ_TABLE_SIZE,
- (void *)init_ctx->p_table[SST_OBJ_TABLE_IDX_0],
- &data_length));
- if (err != PSA_PS_SUCCESS) {
+
+ err = psa_its_get(SST_TABLE_FS_ID(SST_OBJ_TABLE_IDX_0),
+ SST_OBJECT_TABLE_OBJECT_OFFSET,
+ SST_OBJ_TABLE_SIZE,
+ (void *)init_ctx->p_table[SST_OBJ_TABLE_IDX_0],
+ &data_length);
+ if (err != PSA_SUCCESS) {
init_ctx->table_state[SST_OBJ_TABLE_IDX_0] = SST_OBJ_TABLE_INVALID;
}
/* Read file with the table 1 data */
- err = psa_status_to_psa_ps_status(
- psa_its_get(SST_TABLE_FS_ID(SST_OBJ_TABLE_IDX_1),
- SST_OBJECT_TABLE_OBJECT_OFFSET,
- SST_OBJ_TABLE_SIZE,
- (void *)init_ctx->p_table[SST_OBJ_TABLE_IDX_1],
- &data_length));
- if (err != PSA_PS_SUCCESS) {
+ err = psa_its_get(SST_TABLE_FS_ID(SST_OBJ_TABLE_IDX_1),
+ SST_OBJECT_TABLE_OBJECT_OFFSET,
+ SST_OBJ_TABLE_SIZE,
+ (void *)init_ctx->p_table[SST_OBJ_TABLE_IDX_1],
+ &data_length);
+ if (err != PSA_SUCCESS) {
init_ctx->table_state[SST_OBJ_TABLE_IDX_1] = SST_OBJ_TABLE_INVALID;
}
}
@@ -250,23 +249,23 @@
* \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;
/* Create file to store object table in the FS */
- err = psa_status_to_psa_ps_status(psa_its_set(obj_table_id,
- SST_OBJ_TABLE_SIZE,
- (const void *)obj_table,
- PSA_STORAGE_FLAG_NONE));
+ err = psa_its_set(obj_table_id,
+ SST_OBJ_TABLE_SIZE,
+ (const void *)obj_table,
+ PSA_STORAGE_FLAG_NONE);
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -274,7 +273,7 @@
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
@@ -284,40 +283,40 @@
*
* \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;
}
/**
@@ -327,10 +326,10 @@
* \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)
{
@@ -361,7 +360,7 @@
{
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;
@@ -371,7 +370,7 @@
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;
}
@@ -386,7 +385,7 @@
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;
@@ -398,27 +397,27 @@
*
* \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;
}
@@ -443,7 +442,7 @@
sst_object_table_authenticate(SST_OBJ_TABLE_IDX_1, init_ctx);
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
#else /* SST_ROLLBACK_PROTECTION */
@@ -453,10 +452,10 @@
* \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;
@@ -479,7 +478,7 @@
__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;
@@ -488,7 +487,7 @@
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;
}
}
@@ -500,7 +499,7 @@
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;
}
}
@@ -513,23 +512,23 @@
*
* \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
@@ -549,7 +548,7 @@
#ifdef SST_ENCRYPTION
/* Set object table key */
err = sst_crypto_setkey();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -563,13 +562,13 @@
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 */
@@ -577,7 +576,7 @@
err = sst_object_table_fs_write_table(obj_table);
#ifdef SST_ROLLBACK_PROTECTION
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
@@ -618,9 +617,9 @@
*
* \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
@@ -635,7 +634,7 @@
&& (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 */
@@ -649,7 +648,7 @@
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 */
@@ -660,7 +659,7 @@
* needed to copy the table in the context.
*/
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
#ifdef SST_ROLLBACK_PROTECTION
@@ -722,7 +721,7 @@
SST_OBJ_TABLE_SIZE);
}
- return PSA_PS_SUCCESS;
+ return PSA_SUCCESS;
}
/**
@@ -732,12 +731,12 @@
* \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;
@@ -746,11 +745,11 @@
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;
}
/**
@@ -764,19 +763,19 @@
*
* \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++) {
@@ -787,10 +786,10 @@
}
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;
}
}
@@ -807,16 +806,16 @@
SST_DEFAULT_EMPTY_BUFF_VAL, SST_OBJECTS_TABLE_ENTRY_SIZE);
}
-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
@@ -837,9 +836,9 @@
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},
@@ -857,21 +856,21 @@
#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;
}
@@ -880,7 +879,7 @@
#endif /* SST_ROLLBACK_PROTECTION */
err = sst_crypto_destroykey();
- if (err != PSA_PS_SUCCESS) {
+ if (err != PSA_SUCCESS) {
return err;
}
#endif /* SST_ENCRYPTION */
@@ -890,21 +889,20 @@
/* 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 = psa_status_to_psa_ps_status(
- psa_its_remove(SST_TABLE_FS_ID(sst_obj_table_ctx.scratch_table)));
- if (err != PSA_PS_SUCCESS && err != PSA_PS_ERROR_UID_NOT_FOUND) {
+ err = psa_its_remove(SST_TABLE_FS_ID(sst_obj_table_ctx.scratch_table));
+ 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 */
@@ -913,25 +911,26 @@
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;
}
@@ -944,21 +943,21 @@
* That can happen when the system is rebooted (e.g. power cut, ...) in the
* middle of a create, write or delete operation.
*/
- err = psa_status_to_psa_ps_status(psa_its_remove(fid));
- if (err != PSA_PS_SUCCESS && err != PSA_PS_ERROR_UID_NOT_FOUND) {
+ err = psa_its_remove(fid);
+ if (err != PSA_SUCCESS && err != PSA_ERROR_DOES_NOT_EXIST) {
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 = {
@@ -973,7 +972,7 @@
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.
*/
@@ -997,7 +996,7 @@
#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,
@@ -1010,16 +1009,16 @@
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;
}
@@ -1032,22 +1031,22 @@
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
@@ -1062,7 +1061,7 @@
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);
@@ -1071,9 +1070,9 @@
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);
- return psa_status_to_psa_ps_status(psa_its_remove(table_id));
+ return psa_its_remove(table_id);
}
diff --git a/secure_fw/services/secure_storage/sst_object_table.h b/secure_fw/services/secure_storage/sst_object_table.h
index 5167c42..7d5a8cf 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 @@
/**
* \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 @@
* 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 @@
* \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 @@
* 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 @@
* \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 @@
* \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 @@
* \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 e4099b3..6bae88d 100644
--- a/secure_fw/services/secure_storage/sst_utils.c
+++ b/secure_fw/services/secure_storage/sst_utils.c
@@ -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,30 +21,8 @@
* 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;
-}
-
-psa_ps_status_t psa_status_to_psa_ps_status(psa_status_t status)
-{
- switch (status) {
- case PSA_SUCCESS:
- return PSA_PS_SUCCESS;
- case PSA_ERROR_NOT_PERMITTED:
- return PSA_PS_ERROR_WRITE_ONCE;
- case PSA_ERROR_NOT_SUPPORTED:
- return PSA_PS_ERROR_FLAGS_NOT_SUPPORTED;
- case PSA_ERROR_INSUFFICIENT_STORAGE:
- return PSA_PS_ERROR_INSUFFICIENT_SPACE;
- case PSA_ERROR_STORAGE_FAILURE:
- return PSA_PS_ERROR_STORAGE_FAILURE;
- case PSA_ERROR_DOES_NOT_EXIST:
- return PSA_PS_ERROR_UID_NOT_FOUND;
- case PSA_ERROR_INVALID_ARGUMENT:
- return PSA_PS_ERROR_INVALID_ARGUMENT;
- default:
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
+ return PSA_SUCCESS;
}
diff --git a/secure_fw/services/secure_storage/sst_utils.h b/secure_fw/services/secure_storage/sst_utils.h
index 2a2f292..de17a75 100644
--- a/secure_fw/services/secure_storage/sst_utils.h
+++ b/secure_fw/services/secure_storage/sst_utils.h
@@ -36,6 +36,11 @@
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 Checks if a subset region is fully contained within a superset region.
*
* \param[in] superset_size Size of superset region
@@ -43,24 +48,19 @@
* 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);
-
-/**
- * \brief Converts from psa_status_t to psa_ps_status_t
- */
-psa_ps_status_t psa_status_to_psa_ps_status(psa_status_t status);
+psa_status_t sst_utils_check_contained_in(uint32_t superset_size,
+ uint32_t subset_offset,
+ uint32_t subset_size);
#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 0655505..674d81a 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 @@
* 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 @@
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 93f08d3..4cd44a5 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 @@
* \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 @@
* \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 @@
* 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 @@
* \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 15141d8..ec9635d 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 @@
* 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 @@
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_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;
+ return PSA_ERROR_GENERIC_ERROR;
}
- if ((in_len != 1) || (out_len != 1)) {
- /* The number of arguments are 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;
}
- if (in_vec[0].len != sizeof(psa_ps_uid_t)) {
- /* The input argument size is incorrect */
- return PSA_ERROR_CONNECTION_REFUSED;
- }
-
- 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 @@
(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_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 @@
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 @@
}
#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 @@
* 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 c3b76fa..e1ce2e0 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 @@
* 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 781e84b..d403b08 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 @@
{ .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,16 @@
};
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_INVALID_ARGUMENT;
+ }
#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,
@@ -93,25 +92,30 @@
psa_close(handle);
- if (status != PSA_SUCCESS) {
- return PSA_PS_ERROR_OPERATION_FAILED;
- }
#else
status = tfm_tfm_sst_get_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;
+ /* 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;
+ }
+
+ *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 +125,13 @@
};
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 +139,21 @@
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 +162,50 @@
{ .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 5158c53..5341058 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,40 +9,6 @@
#include <stdio.h>
-const char *psa_ps_status_to_str(psa_ps_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";
- default:
- return "Unknown error";
- }
-}
-
const char *asset_perms_to_str(uint8_t permissions)
{
switch (permissions) {
diff --git a/test/framework/test_framework_helpers.h b/test/framework/test_framework_helpers.h
index 8d42fe7..6a99067 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,15 +28,6 @@
};
/**
- * \brief Translates psa_ps_status_t into a string.
- *
- * \param[in] status psa_ps_status_t status value.
- *
- * \return psa_ps_status_t as string.
- */
-const char *psa_ps_status_to_str(psa_ps_status_t status);
-
-/**
* \brief Translates asset permissions into a string.
*
* \param[in] permissions Asset permissions value.
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 f2370c0..b0cb5fc 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 @@
*/
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(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(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(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(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 @@
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 @@
/* 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(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 @@
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 @@
/* 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(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 @@
/* 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(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 @@
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 @@
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 @@
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(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(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 @@
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(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 @@
/* 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(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 @@
/* 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(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(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(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 @@
*/
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_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_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_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_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_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_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_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_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_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_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 @@
}
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 @@
}
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 @@
/* 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_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 @@
}
/* 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 @@
/* 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_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_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_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_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_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_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 @@
/* 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_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 @@
*/
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 @@
* 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 @@
* 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 @@
/* 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(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 @@
/* 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 @@
/* 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(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 @@
/* 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(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 @@
/* 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 @@
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 @@
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 @@
/* 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 db5a2d2..5a2b4d1 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 @@
}
/* 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 @@
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 @@
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 b1b85ab..8e08653 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,11 +22,11 @@
* \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,
- uint32_t *val);
+psa_status_t test_sst_read_nv_counter(enum tfm_nv_counter_t counter_id,
+ uint32_t *val);
/**
* \brief Increments the given non-volatile (NV) counter.
@@ -34,10 +34,10 @@
* \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 @@
* \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 @@
* \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 102e7a5..beaa1fd 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 @@
*/
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_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_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_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 @@
* 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_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_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 @@
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 @@
/* 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_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 @@
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 @@
/* 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_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 @@
/* 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_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 @@
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 @@
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 @@
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 @@
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 @@
/* 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,30 @@
*/
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;
+ 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 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_len);
+ 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 +689,13 @@
*/
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 +706,7 @@
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 +720,22 @@
*/
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 +753,7 @@
/* 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 +768,13 @@
*/
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 +792,7 @@
/* 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 +817,14 @@
*/
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 +832,13 @@
/* 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 +846,7 @@
/* 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 +860,46 @@
*/
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 +913,12 @@
*/
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 +932,12 @@
*/
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 +954,27 @@
*/
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 +983,7 @@
* 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 +992,8 @@
* 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 +1005,7 @@
/* 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 +1018,19 @@
*/
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 +1038,9 @@
/* 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 +1055,7 @@
/* 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 +1068,40 @@
*/
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 +1114,7 @@
/* 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 +1147,8 @@
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 +1160,8 @@
/* 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 +1169,15 @@
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 +1188,15 @@
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 +1209,7 @@
/* 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 417a02f..4fbcabd 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 @@
*/
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 @@
/* 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_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 @@
/* 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 de96fdb..c26cda2 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 @@
*/
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 @@
/* 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 @@
/* 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 @@
/* 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,15 @@
* 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) {
+ 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;
}
@@ -206,7 +207,7 @@
/* 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 +221,34 @@
*/
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 +260,7 @@
* 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 +277,33 @@
/* 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 +319,18 @@
*/
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 +339,7 @@
* 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 +351,15 @@
* 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) {
+ 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;
}
@@ -370,7 +372,7 @@
/* 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 +389,18 @@
*/
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 +409,7 @@
* 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 +421,15 @@
* 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) {
+ 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;
}
@@ -439,7 +442,7 @@
/* 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 +459,18 @@
*/
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 +479,13 @@
* 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 +496,15 @@
* 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) {
+ 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;
}
@@ -513,7 +517,7 @@
/* 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 +531,18 @@
*/
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 +551,19 @@
* 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 +574,15 @@
* 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) {
+ 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;
}
@@ -590,7 +595,7 @@
/* 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 +609,15 @@
*/
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 +626,13 @@
* 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 +644,7 @@
* 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 +661,27 @@
/* 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 +695,15 @@
*/
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 +712,19 @@
* 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 +736,7 @@
* 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 +753,33 @@
/* 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 +793,9 @@
*/
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 +806,7 @@
/* 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;