SST: Add uniform secure functions support
This patch adds the uniform secure functions support in SST.
Change-Id: I52475b43435ed3b6d289651ea777de9483116b7e
Signed-off-by: Marc Moreno <marc.morenoberengue@arm.com>
diff --git a/interface/include/tfm_sst_defs.h b/interface/include/tfm_sst_defs.h
index a008c73..1d54043 100644
--- a/interface/include/tfm_sst_defs.h
+++ b/interface/include/tfm_sst_defs.h
@@ -55,6 +55,9 @@
TFM_SST_ERR_INVALID \
)
+/* Invalid UID */
+#define TFM_SST_INVALID_UID 0
+
#ifdef __cplusplus
}
#endif
diff --git a/interface/include/tfm_sst_veneers.h b/interface/include/tfm_sst_veneers.h
deleted file mode 100644
index 670ffae..0000000
--- a/interface/include/tfm_sst_veneers.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __TFM_SST_VENEERS_H__
-#define __TFM_SST_VENEERS_H__
-
-#include <stdint.h>
-
-#include "psa_protected_storage.h"
-#include "tfm_sst_defs.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Creates a new or modifies an existing asset. (Veneer function)
- *
- * \param[in] uid The unique identifier for the data
- * \param[in] data_length The size in bytes of the data in `p_data`
- * \param[in] p_data A buffer containing the data
- * \param[in] create_flags The flags indicating the properties of the data
- *
- * \return A status indicating the success/failure of the operation as specified
- * in \ref tfm_sst_err_t
- *
- * \retval TFM_SST_ERR_SUCCESS The operation completed successfully
- * \retval TFM_SST_ERR_WRITE_ONCE The operation failed because the
- * provided uid value was already
- * created with PSA_PS_FLAG_WRITE_ONCE
- * \retval TFM_SST_ERR_INVALID_ARGUMENT The operation failed because one or
- * more of the given arguments were
- * invalid (null pointer, etc.)
- * \retval TFM_SST_ERR_FLAGS_NOT_SUPPORTED The operation failed because one or
- * more of the flags provided in
- * `create_flags` is not supported or
- * is not valid
- * \retval TFM_SST_ERR_INSUFFICIENT_SPACE The operation failed because there
- * was insufficient space on the
- * storage medium
- * \retval TFM_SST_ERR_STORAGE_FAILURE The operation failed because the
- * physical storage has failed (fatal
- * error)
- * \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
- * unspecified internal failure.
- */
-enum tfm_sst_err_t tfm_sst_veneer_set(const psa_ps_uid_t *uid,
- uint32_t data_length,
- const void *p_data,
- psa_ps_create_flags_t create_flags);
-
-/**
- * \brief Gets the asset data for the provided uid. (Veneer function)
- *
- * \param[in] uid The unique identifier for the data
- * \param[in] data_offset The offset within the data associated with the `uid`
- * to start retrieving data
- * \param[in] data_length The amount of data to read (and the minimum
- * allocated size of the `p_data` buffer)
- * \param[out] p_data The buffer where the data will be placed upon
- * successful completion
- *
- * \return A status indicating the success/failure of the operation as specified
- * in \ref tfm_sst_err_t
- *
- * \retval TFM_SST_ERR_SUCCESS The operation completed successfully
- * \retval TFM_SST_ERR_INVALID_ARGUMENT The operation failed because one or
- * more of the given arguments were
- * invalid (null pointer, etc.)
- * \retval TFM_SST_ERR_UID_NOT_FOUND The operation failed because the
- * provided uid value was not found in the
- * storage
- * \retval TFM_SST_ERR_INCORRECT_SIZE The operation failed because the data
- * associated with provided uid is not the
- * same size as `data_size`
- * \retval TFM_SST_ERR_STORAGE_FAILURE The operation failed because the
- * physical storage has failed (fatal
- * error)
- * \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
- * unspecified internal failure
- * \retval TFM_SST_ERR_DATA_CORRUPT The operation failed because of an
- * authentication failure when attempting
- * to get the key
- * \retval TFM_SST_ERR_AUTH_FAILED The operation failed because of an
- * unspecified internal failure
- */
-enum tfm_sst_err_t tfm_sst_veneer_get(const psa_ps_uid_t *uid,
- uint32_t data_offset,
- uint32_t data_length,
- void *p_data);
-
-/**
- * \brief Gets the metadata for the provided uid. (Veneer function)
- *
- * \param[in] uid The 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
- *
- * \return A status indicating the success/failure of the operation as specified
- * in \ref tfm_sst_err_t
- *
- * \retval TFM_SST_ERR_SUCCESS The operation completed successfully
- * \retval TFM_SST_ERR_INVALID_ARGUMENT The operation failed because one or
- * more of the given arguments were
- * invalid (null pointer, etc.)
- * \retval TFM_SST_ERR_UID_NOT_FOUND The operation failed because the
- * provided uid value was not found in the
- * storage
- * \retval TFM_SST_ERR_STORAGE_FAILURE The operation failed because the
- * physical storage has failed (fatal
- * error)
- * \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
- * unspecified internal failure
- * \retval TFM_SST_ERR_DATA_CORRUPT The operation failed because of an
- * authentication failure when attempting
- * to get the key
- * \retval TFM_SST_ERR_AUTH_FAILED The operation failed because of an
- * unspecified internal failure
- */
-enum tfm_sst_err_t tfm_sst_veneer_get_info(const psa_ps_uid_t *uid,
- struct psa_ps_info_t *p_info);
-
-/**
- * \brief Removes the provided uid and its associated data from storage. (Veneer
- * function)
- *
- * \param[in] uid The unique identifier for the data to be removed
- *
- * \return A status indicating the success/failure of the operation as specified
- * in \ref tfm_sst_err_t
- *
- * \retval TFM_SST_ERR_SUCCESS The operation completed successfully
- * \retval TFM_SST_ERR_INVALID_ARGUMENT The operation failed because one or
- * more of the given arguments were
- * invalid (null pointer, etc.)
- * \retval TFM_SST_ERR_UID_NOT_FOUND The operation failed because the
- * provided uid value was not found in the
- * storage
- * \retval TFM_SST_ERR_WRITE_ONCE The operation failed because the
- * provided uid value was created with
- * PSA_PS_WRITE_ONCE_FLAG
- * \retval TFM_SST_ERR_STORAGE_FAILURE The operation failed because the
- * physical storage has failed (fatal
- * error)
- * \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
- * unspecified internal failure
- */
-enum tfm_sst_err_t tfm_sst_veneer_remove(const psa_ps_uid_t *uid);
-
-/**
- * \brief Gets a bitmask with flags set for all of the optional features
- * supported by the implementation. (Veneer function)
- *
- * \param[out] support_flags A pointer to a variable that will be populated
- * with a uint32_t bitmask value which contains all
- * the bits set for all the optional features
- * supported by the implementation
- *
- * \return A status indicating the success/failure of the operation as specified
- * in \ref tfm_sst_err_t
- *
- * \retval TFM_SST_ERR_SUCCESS The operation completed successfully
- * \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
- * unspecified internal failure
- */
-enum tfm_sst_err_t tfm_sst_veneer_get_support(uint32_t *support_flags);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TFM_SST_VENEERS_H__ */
diff --git a/interface/include/tfm_veneers.h b/interface/include/tfm_veneers.h
index 966d8c1..3be902d 100644
--- a/interface/include/tfm_veneers.h
+++ b/interface/include/tfm_veneers.h
@@ -17,11 +17,11 @@
#endif
/******** TFM_SP_STORAGE ********/
-psa_status_t tfm_tfm_sst_set_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
-psa_status_t tfm_tfm_sst_get_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
-psa_status_t tfm_tfm_sst_get_info_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
-psa_status_t tfm_tfm_sst_remove_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
-psa_status_t tfm_tfm_sst_get_support_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
+psa_status_t tfm_tfm_sst_set_req_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
+psa_status_t tfm_tfm_sst_get_req_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
+psa_status_t tfm_tfm_sst_get_info_req_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
+psa_status_t tfm_tfm_sst_remove_req_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
+psa_status_t tfm_tfm_sst_get_support_req_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
/******** TFM_SP_AUDIT_LOG ********/
psa_status_t tfm_audit_core_retrieve_record_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
diff --git a/interface/src/tfm_sst_api.c b/interface/src/tfm_sst_api.c
index 2a20e28..5102b2f 100644
--- a/interface/src/tfm_sst_api.c
+++ b/interface/src/tfm_sst_api.c
@@ -9,20 +9,34 @@
#include "tfm_ns_lock.h"
#include "tfm_sst_defs.h"
-#include "tfm_sst_veneers.h"
+#include "tfm_veneers.h"
+
+#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 status;
enum tfm_sst_err_t err;
- err = tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_set,
- (uint32_t)&uid,
- (uint32_t)data_length,
- (uint32_t)p_data,
- (uint32_t)create_flags);
+ 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_lock_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;
+ }
return TFM_SST_PSA_RETURN(err);
}
@@ -32,39 +46,75 @@
uint32_t data_length,
void *p_data)
{
+ psa_status_t status;
enum tfm_sst_err_t err;
- err = tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_get,
- (uint32_t)&uid,
- (uint32_t)data_offset,
- (uint32_t)data_length,
- (uint32_t)p_data);
+ 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 }
+ };
+
+ status = tfm_ns_lock_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;
+ }
return TFM_SST_PSA_RETURN(err);
}
psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
{
+ psa_status_t status;
enum tfm_sst_err_t err;
- err = tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_get_info,
- (uint32_t)&uid,
- (uint32_t)p_info,
- (uint32_t)0,
- (uint32_t)0);
+ 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) }
+ };
+
+ status = tfm_ns_lock_dispatch((veneer_fn)tfm_tfm_sst_get_info_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;
+ }
return TFM_SST_PSA_RETURN(err);
}
psa_ps_status_t psa_ps_remove(psa_ps_uid_t uid)
{
+ psa_status_t status;
enum tfm_sst_err_t err;
- err = tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_remove,
- (uint32_t)&uid,
- (uint32_t)0,
- (uint32_t)0,
- (uint32_t)0);
+ psa_invec in_vec[] = {
+ { .base = &uid, .len = sizeof(uid) }
+ };
+
+ psa_outvec out_vec[] = {
+ { .base = &err, .len = sizeof(err) }
+ };
+
+ status = tfm_ns_lock_dispatch((veneer_fn)tfm_tfm_sst_remove_req_veneer,
+ (uint32_t)in_vec, IOVEC_LEN(in_vec),
+ (uint32_t)out_vec, IOVEC_LEN(out_vec));
+
+ if (status != PSA_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
+ }
return TFM_SST_PSA_RETURN(err);
}
@@ -85,21 +135,21 @@
uint32_t psa_ps_get_support(void)
{
- uint32_t support_flags;
-
/* Initialise support_flags to a sensible default, to avoid returning an
* uninitialised value in case the secure function fails.
*/
- support_flags = 0;
+ uint32_t support_flags = 0;
+
+ psa_outvec out_vec[] = {
+ { .base = &support_flags, .len = sizeof(support_flags) }
+ };
/* The PSA API does not return an error, so any error from TF-M is
* ignored.
*/
- (void)tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_get_support,
- (uint32_t)&support_flags,
- (uint32_t)0,
- (uint32_t)0,
- (uint32_t)0);
+ (void)tfm_ns_lock_dispatch((veneer_fn)tfm_tfm_sst_get_support_req_veneer,
+ (uint32_t)NULL, 0,
+ (uint32_t)out_vec, IOVEC_LEN(out_vec));
return support_flags;
}
diff --git a/secure_fw/ns_callable/CMakeLists.inc b/secure_fw/ns_callable/CMakeLists.inc
index a09ff13..e9e2c18 100644
--- a/secure_fw/ns_callable/CMakeLists.inc
+++ b/secure_fw/ns_callable/CMakeLists.inc
@@ -24,7 +24,6 @@
endif()
set (SS_NS_CALLABLE_C_SRC "${CMAKE_CURRENT_LIST_DIR}/tfm_veneers.c"
- "${CMAKE_CURRENT_LIST_DIR}/tfm_sst_veneers.c"
"${CMAKE_CURRENT_LIST_DIR}/tfm_audit_veneers.c"
"${CMAKE_CURRENT_LIST_DIR}/tfm_crypto_veneers.c"
"${CMAKE_CURRENT_LIST_DIR}/tfm_platform_veneers.c")
diff --git a/secure_fw/ns_callable/tfm_sst_veneers.c b/secure_fw/ns_callable/tfm_sst_veneers.c
deleted file mode 100644
index 5348d5d..0000000
--- a/secure_fw/ns_callable/tfm_sst_veneers.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#include "tfm_sst_veneers.h"
-
-#include "secure_fw/core/tfm_secure_api.h"
-#include "secure_fw/services/secure_storage/tfm_protected_storage.h"
-#include "secure_fw/spm/spm_partition_defs.h"
-
-__tfm_secure_gateway_attributes__
-enum tfm_sst_err_t tfm_sst_veneer_set(const psa_ps_uid_t *uid,
- uint32_t data_length,
- const void *p_data,
- psa_ps_create_flags_t create_flags)
-{
- TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, tfm_sst_set,
- uid, data_length, p_data, create_flags);
-}
-
-__tfm_secure_gateway_attributes__
-enum tfm_sst_err_t tfm_sst_veneer_get(const psa_ps_uid_t *uid,
- uint32_t data_offset,
- uint32_t data_length,
- void *p_data)
-{
- TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, tfm_sst_get,
- uid, data_offset, data_length, p_data);
-}
-
-__tfm_secure_gateway_attributes__
-enum tfm_sst_err_t tfm_sst_veneer_get_info(const psa_ps_uid_t *uid,
- struct psa_ps_info_t *p_info)
-{
- TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, tfm_sst_get_info,
- uid, p_info, 0, 0);
-}
-
-__tfm_secure_gateway_attributes__
-enum tfm_sst_err_t tfm_sst_veneer_remove(const psa_ps_uid_t *uid)
-{
- TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, tfm_sst_remove,
- uid, 0, 0, 0);
-}
-
-__tfm_secure_gateway_attributes__
-enum tfm_sst_err_t tfm_sst_veneer_get_support(uint32_t *support_flags)
-{
- TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, tfm_sst_get_support,
- support_flags, 0, 0, 0);
-}
diff --git a/secure_fw/ns_callable/tfm_veneers.c b/secure_fw/ns_callable/tfm_veneers.c
index 9e9063f..d8c66b6 100644
--- a/secure_fw/ns_callable/tfm_veneers.c
+++ b/secure_fw/ns_callable/tfm_veneers.c
@@ -12,11 +12,11 @@
#include "secure_fw/spm/spm_partition_defs.h"
/******** TFM_SP_STORAGE ********/
-psa_status_t tfm_sst_set(struct psa_invec *, size_t, struct psa_outvec *, size_t);
-psa_status_t tfm_sst_get(struct psa_invec *, size_t, struct psa_outvec *, size_t);
-psa_status_t tfm_sst_get_info(struct psa_invec *, size_t, struct psa_outvec *, size_t);
-psa_status_t tfm_sst_remove(struct psa_invec *, size_t, struct psa_outvec *, size_t);
-psa_status_t tfm_sst_get_support(struct psa_invec *, size_t, struct psa_outvec *, size_t);
+psa_status_t tfm_sst_set_req(struct psa_invec *, size_t, struct psa_outvec *, size_t);
+psa_status_t tfm_sst_get_req(struct psa_invec *, size_t, struct psa_outvec *, size_t);
+psa_status_t tfm_sst_get_info_req(struct psa_invec *, size_t, struct psa_outvec *, size_t);
+psa_status_t tfm_sst_remove_req(struct psa_invec *, size_t, struct psa_outvec *, size_t);
+psa_status_t tfm_sst_get_support_req(struct psa_invec *, size_t, struct psa_outvec *, size_t);
/******** TFM_SP_AUDIT_LOG ********/
psa_status_t audit_core_retrieve_record(struct psa_invec *, size_t, struct psa_outvec *, size_t);
@@ -107,11 +107,11 @@
}
/******** TFM_SP_STORAGE ********/
-TFM_VENEER_FUNCTION(TFM_SP_STORAGE, tfm_sst_set)
-TFM_VENEER_FUNCTION(TFM_SP_STORAGE, tfm_sst_get)
-TFM_VENEER_FUNCTION(TFM_SP_STORAGE, tfm_sst_get_info)
-TFM_VENEER_FUNCTION(TFM_SP_STORAGE, tfm_sst_remove)
-TFM_VENEER_FUNCTION(TFM_SP_STORAGE, tfm_sst_get_support)
+TFM_VENEER_FUNCTION(TFM_SP_STORAGE, tfm_sst_set_req)
+TFM_VENEER_FUNCTION(TFM_SP_STORAGE, tfm_sst_get_req)
+TFM_VENEER_FUNCTION(TFM_SP_STORAGE, tfm_sst_get_info_req)
+TFM_VENEER_FUNCTION(TFM_SP_STORAGE, tfm_sst_remove_req)
+TFM_VENEER_FUNCTION(TFM_SP_STORAGE, tfm_sst_get_support_req)
/******** TFM_SP_AUDIT_LOG ********/
TFM_VENEER_FUNCTION(TFM_SP_AUDIT_LOG, audit_core_retrieve_record)
diff --git a/secure_fw/services/secure_storage/CMakeLists.inc b/secure_fw/services/secure_storage/CMakeLists.inc
index 418d578..6c5d717 100644
--- a/secure_fw/services/secure_storage/CMakeLists.inc
+++ b/secure_fw/services/secure_storage/CMakeLists.inc
@@ -52,6 +52,7 @@
set (SECURE_STORAGE_C_SRC
"${SECURE_STORAGE_DIR}/tfm_sst_secure_api.c"
+ "${SECURE_STORAGE_DIR}/tfm_sst_req_mngr.c"
"${SECURE_STORAGE_DIR}/tfm_protected_storage.c"
"${SECURE_STORAGE_DIR}/sst_object_system.c"
"${SECURE_STORAGE_DIR}/sst_object_table.c"
diff --git a/secure_fw/services/secure_storage/manifest.yaml b/secure_fw/services/secure_storage/manifest.yaml
index 86e2bc7..cc65894 100644
--- a/secure_fw/services/secure_storage/manifest.yaml
+++ b/secure_fw/services/secure_storage/manifest.yaml
@@ -17,7 +17,7 @@
{
"sfid": "TFM_SST_SET_SFID",
"signal": "TFM_SST_SET",
- "tfm_symbol": "tfm_sst_set",
+ "tfm_symbol": "tfm_sst_set_req",
"non_secure_clients": true,
"minor_version": 1,
"minor_policy": "strict"
@@ -25,7 +25,7 @@
{
"sfid": "TFM_SST_GET_SFID",
"signal": "TFM_SST_GET",
- "tfm_symbol": "tfm_sst_get",
+ "tfm_symbol": "tfm_sst_get_req",
"non_secure_clients": true,
"minor_version": 1,
"minor_policy": "strict"
@@ -33,7 +33,7 @@
{
"sfid": "TFM_SST_GET_INFO_SFID",
"signal": "TFM_SST_GET_INFO",
- "tfm_symbol": "tfm_sst_get_info",
+ "tfm_symbol": "tfm_sst_get_info_req",
"non_secure_clients": true,
"minor_version": 1,
"minor_policy": "strict"
@@ -41,7 +41,7 @@
{
"sfid": "TFM_SST_REMOVE_SFID",
"signal": "TFM_SST_REMOVE",
- "tfm_symbol": "tfm_sst_remove",
+ "tfm_symbol": "tfm_sst_remove_req",
"non_secure_clients": true,
"minor_version": 1,
"minor_policy": "strict"
@@ -49,7 +49,7 @@
{
"sfid": "TFM_SST_GET_SUPPORT_SFID",
"signal": "TFM_SST_GET_SUPPORT",
- "tfm_symbol": "tfm_sst_get_support",
+ "tfm_symbol": "tfm_sst_get_support_req",
"non_secure_clients": true,
"minor_version": 1,
"minor_policy": "strict"
@@ -61,6 +61,7 @@
"sst_object_table.c",
"sst_utils.c",
"tfm_protected_storage.c",
+ "tfm_sst_req_mngr.c",
"crypto/sst_crypto_interface.c",
"flash/sst_flash.c",
"flash_fs/sst_flash_fs.c",
diff --git a/secure_fw/services/secure_storage/sst_object_table.c b/secure_fw/services/secure_storage/sst_object_table.c
index f363827..9f5b5c4 100644
--- a/secure_fw/services/secure_storage/sst_object_table.c
+++ b/secure_fw/services/secure_storage/sst_object_table.c
@@ -787,7 +787,7 @@
struct sst_obj_table_t *p_table = &sst_obj_table_ctx.obj_table;
for (i = 0; i < SST_OBJ_TABLE_ENTRIES; i++) {
- if (p_table->obj_db[i].uid == SST_INVALID_UID) {
+ if (p_table->obj_db[i].uid == TFM_SST_INVALID_UID) {
*idx = i;
return TFM_SST_ERR_SUCCESS;
}
@@ -806,7 +806,7 @@
{
struct sst_obj_table_t *p_table = &sst_obj_table_ctx.obj_table;
- p_table->obj_db[idx].uid = SST_INVALID_UID;
+ p_table->obj_db[idx].uid = TFM_SST_INVALID_UID;
p_table->obj_db[idx].client_id = 0;
#ifdef SST_ENCRYPTION
diff --git a/secure_fw/services/secure_storage/sst_utils.h b/secure_fw/services/secure_storage/sst_utils.h
index 939e663..2cab55d 100644
--- a/secure_fw/services/secure_storage/sst_utils.h
+++ b/secure_fw/services/secure_storage/sst_utils.h
@@ -17,7 +17,6 @@
extern "C" {
#endif
-#define SST_INVALID_UID 0
#define SST_INVALID_FID 0
#define SST_DEFAULT_EMPTY_BUFF_VAL 0
diff --git a/secure_fw/services/secure_storage/tfm_protected_storage.c b/secure_fw/services/secure_storage/tfm_protected_storage.c
index 8da2314..e40ef67 100644
--- a/secure_fw/services/secure_storage/tfm_protected_storage.c
+++ b/secure_fw/services/secure_storage/tfm_protected_storage.c
@@ -6,11 +6,7 @@
*/
#include "tfm_protected_storage.h"
-
-#include "secure_fw/core/tfm_secure_api.h"
#include "sst_object_system.h"
-#include "sst_utils.h"
-#include "tfm_api.h"
enum tfm_sst_err_t tfm_sst_init(void)
{
@@ -43,45 +39,19 @@
return err;
}
-enum tfm_sst_err_t tfm_sst_set(const psa_ps_uid_t *uid,
+enum tfm_sst_err_t tfm_sst_set(int32_t client_id,
+ psa_ps_uid_t uid,
uint32_t data_length,
const void *p_data,
psa_ps_create_flags_t create_flags)
{
- enum tfm_status_e status;
- int32_t client_id;
-
- status = tfm_core_memory_permission_check((psa_ps_uid_t *)uid,
- sizeof(psa_ps_uid_t),
- TFM_MEMORY_ACCESS_RO);
- if (status != TFM_SUCCESS) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
- }
-
- /* If the data length is zero, then just check the p_data pointer is not
- * NULL, otherwise perform a memory permission check on the region.
- */
- if (data_length == 0) {
- if (p_data == NULL) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
- }
- } else {
- status = tfm_core_memory_permission_check((void *)p_data, data_length,
- TFM_MEMORY_ACCESS_RO);
- if (status != TFM_SUCCESS) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
- }
- }
-
/* Check that the UID is valid */
- if (*uid == SST_INVALID_UID) {
+ if (uid == TFM_SST_INVALID_UID) {
return TFM_SST_ERR_INVALID_ARGUMENT;
}
- /* Get the caller's client ID */
- status = tfm_core_get_caller_client_id(&client_id);
- if (status != TFM_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (p_data == NULL) {
+ return TFM_SST_ERR_INVALID_ARGUMENT;
}
/* Check that the create_flags does not contain any unsupported flags */
@@ -90,116 +60,51 @@
}
/* Create the object in the object system */
- return sst_object_create(*uid, client_id, create_flags, data_length,
- p_data);
+ return sst_object_create(uid, client_id, create_flags, data_length, p_data);
}
-enum tfm_sst_err_t tfm_sst_get(const psa_ps_uid_t *uid,
+enum tfm_sst_err_t tfm_sst_get(int32_t client_id,
+ psa_ps_uid_t uid,
uint32_t data_offset,
uint32_t data_length,
void *p_data)
{
- enum tfm_status_e status;
- int32_t client_id;
-
- status = tfm_core_memory_permission_check((psa_ps_uid_t *)uid,
- sizeof(psa_ps_uid_t),
- TFM_MEMORY_ACCESS_RO);
- if (status != TFM_SUCCESS) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
- }
-
- /* If the data length is zero, then just check the p_data pointer is not
- * NULL, otherwise perform a memory permission check on the region.
- */
- if (data_length == 0) {
- if (p_data == NULL) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
- }
- } else {
- status = tfm_core_memory_permission_check((void *)p_data, data_length,
- TFM_MEMORY_ACCESS_RW);
- if (status != TFM_SUCCESS) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
- }
- }
-
/* Check that the UID is valid */
- if (*uid == SST_INVALID_UID) {
+ if (uid == TFM_SST_INVALID_UID) {
return TFM_SST_ERR_INVALID_ARGUMENT;
}
- /* Get the caller's client ID */
- status = tfm_core_get_caller_client_id(&client_id);
- if (status != TFM_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
+ if (p_data == NULL) {
+ return TFM_SST_ERR_INVALID_ARGUMENT;
}
/* Read the object data from the object system */
- return sst_object_read(*uid, client_id, data_offset, data_length, p_data);
+ return sst_object_read(uid, client_id, data_offset, data_length, p_data);
}
-enum tfm_sst_err_t tfm_sst_get_info(const psa_ps_uid_t *uid,
+enum tfm_sst_err_t tfm_sst_get_info(int32_t client_id, psa_ps_uid_t uid,
struct psa_ps_info_t *p_info)
{
- enum tfm_status_e status;
- int32_t client_id;
-
- status = tfm_core_memory_permission_check((psa_ps_uid_t *)uid,
- sizeof(psa_ps_uid_t),
- TFM_MEMORY_ACCESS_RO);
- if (status != TFM_SUCCESS) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
- }
-
- status = tfm_core_memory_permission_check(p_info,
- sizeof(struct psa_ps_info_t),
- TFM_MEMORY_ACCESS_RW);
- if (status != TFM_SUCCESS) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
- }
-
/* Check that the UID is valid */
- if (*uid == SST_INVALID_UID) {
+ if (uid == TFM_SST_INVALID_UID) {
return TFM_SST_ERR_INVALID_ARGUMENT;
}
- /* Get the caller's client ID */
- status = tfm_core_get_caller_client_id(&client_id);
- if (status != TFM_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
- }
-
/* Get the info struct data from the object system */
- return sst_object_get_info(*uid, client_id, p_info);
+ return sst_object_get_info(uid, client_id, p_info);
}
-enum tfm_sst_err_t tfm_sst_remove(const psa_ps_uid_t *uid)
+enum tfm_sst_err_t tfm_sst_remove(int32_t client_id, psa_ps_uid_t uid)
{
- enum tfm_status_e status;
enum tfm_sst_err_t err;
- int32_t client_id;
-
- status = tfm_core_memory_permission_check((psa_ps_uid_t *)uid,
- sizeof(psa_ps_uid_t),
- TFM_MEMORY_ACCESS_RO);
- if (status != TFM_SUCCESS) {
- return TFM_SST_ERR_INVALID_ARGUMENT;
- }
/* Check that the UID is valid */
- if (*uid == SST_INVALID_UID) {
+ if (uid == TFM_SST_INVALID_UID) {
return TFM_SST_ERR_INVALID_ARGUMENT;
}
- /* Get the caller's client ID */
- status = tfm_core_get_caller_client_id(&client_id);
- if (status != TFM_SUCCESS) {
- return TFM_SST_ERR_OPERATION_FAILED;
- }
-
/* Delete the object from the object system */
- err = sst_object_delete(*uid, client_id);
+ err = sst_object_delete(uid, client_id);
/* PSA_PS_ERROR_AUTH_FAILED is not supported by psa_ps_remove
* specification. So, this function returns TFM_SST_ERR_OPERATION_FAILED
@@ -212,7 +117,7 @@
return err;
}
-enum tfm_sst_err_t tfm_sst_get_support(uint32_t *support_flags)
+uint32_t tfm_sst_get_support(void)
{
/*
* This function returns a bitmask with flags set for all of the optional
@@ -221,7 +126,5 @@
* SST service does not support the optional extended PSA PS API yet.
*/
- *support_flags = 0;
-
- return TFM_SST_ERR_SUCCESS;
+ return 0;
}
diff --git a/secure_fw/services/secure_storage/tfm_protected_storage.h b/secure_fw/services/secure_storage/tfm_protected_storage.h
index f8e17d9..969bf05 100644
--- a/secure_fw/services/secure_storage/tfm_protected_storage.h
+++ b/secure_fw/services/secure_storage/tfm_protected_storage.h
@@ -35,7 +35,8 @@
/**
* \brief Creates a new or modifies an existing asset.
*
- * \param[in] uid Pointer to the unique identifier for the data
+ * \param[in] client_id Identifier of the asset's owner (client)
+ * \param[in] uid Unique identifier for the data
* \param[in] data_length The size in bytes of the data in `p_data`
* \param[in] p_data A buffer containing the data
* \param[in] create_flags The flags indicating the properties of the data
@@ -63,7 +64,8 @@
* \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
* unspecified internal failure
*/
-enum tfm_sst_err_t tfm_sst_set(const psa_ps_uid_t *uid,
+enum tfm_sst_err_t tfm_sst_set(int32_t client_id,
+ psa_ps_uid_t uid,
uint32_t data_length,
const void *p_data,
psa_ps_create_flags_t create_flags);
@@ -71,7 +73,8 @@
/**
* \brief Gets the asset data for the provided uid.
*
- * \param[in] uid Pointer to the unique identifier for the data
+ * \param[in] client_id Identifier of the asset's owner (client)
+ * \param[in] uid Unique identifier for the data
* \param[in] data_offset The offset within the data associated with the `uid`
* to start retrieving data
* \param[in] data_length The amount of data to read (and the minimum
@@ -103,7 +106,8 @@
* associated with the UID failed
* authentication
*/
-enum tfm_sst_err_t tfm_sst_get(const psa_ps_uid_t *uid,
+enum tfm_sst_err_t tfm_sst_get(int32_t client_id,
+ psa_ps_uid_t uid,
uint32_t data_offset,
uint32_t data_length,
void *p_data);
@@ -111,9 +115,10 @@
/**
* \brief Gets the metadata for the provided uid.
*
- * \param[in] uid Pointer to the 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[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
*
* \return A status indicating the success/failure of the operation as specified
* in \ref tfm_sst_err_t
@@ -136,13 +141,14 @@
* associated with the UID failed
* authentication
*/
-enum tfm_sst_err_t tfm_sst_get_info(const psa_ps_uid_t *uid,
+enum tfm_sst_err_t tfm_sst_get_info(int32_t client_id, psa_ps_uid_t uid,
struct psa_ps_info_t *p_info);
/**
* \brief Removes the provided uid and its associated data from storage.
*
- * \param[in] uid Pointer to the unique identifier for the data to be removed
+ * \param[in] client_id Identifier of the asset's owner (client)
+ * \param[in] uid Unique identifier for the data to be removed
*
* \return A status indicating the success/failure of the operation as specified
* in \ref tfm_sst_err_t
@@ -163,25 +169,16 @@
* \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
* unspecified internal failure
*/
-enum tfm_sst_err_t tfm_sst_remove(const psa_ps_uid_t *uid);
+enum tfm_sst_err_t tfm_sst_remove(int32_t client_id, psa_ps_uid_t uid);
/**
* \brief Gets a bitmask with flags set for all of the optional features
* supported by the implementation.
*
- * \param[out] support_flags A pointer to a variable that will be populated
- * with a uint32_t bitmask value which contains all
- * the bits set for all the optional features
- * supported by the implementation
- *
- * \return A status indicating the success/failure of the operation as specified
- * in \ref tfm_sst_err_t
- *
- * \retval TFM_SST_ERR_SUCCESS The operation completed successfully
- * \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
- * unspecified internal failure
+ * \return Bitmask value which contains all the bits set for all the optional
+ * features supported by the implementation
*/
-enum tfm_sst_err_t tfm_sst_get_support(uint32_t *support_flags);
+uint32_t tfm_sst_get_support(void);
#ifdef __cplusplus
}
diff --git a/secure_fw/services/secure_storage/tfm_sst_req_mngr.c b/secure_fw/services/secure_storage/tfm_sst_req_mngr.c
new file mode 100644
index 0000000..e00ab7c
--- /dev/null
+++ b/secure_fw/services/secure_storage/tfm_sst_req_mngr.c
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "tfm_sst_req_mngr.h"
+
+#include "secure_fw/core/tfm_secure_api.h"
+#include "tfm_api.h"
+#include "tfm_protected_storage.h"
+
+psa_status_t tfm_sst_set_req(struct psa_invec *in_vec, size_t in_len,
+ struct psa_outvec *out_vec, size_t out_len)
+{
+ psa_ps_uid_t uid;
+ uint32_t data_length;
+ int32_t client_id;
+ const void *p_data;
+ enum tfm_status_e status;
+ psa_ps_create_flags_t create_flags;
+ psa_ps_status_t *err;
+
+ if ((in_len != 3) || (out_len != 1)) {
+ /* The number of arguments are incorrect */
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ if (in_vec[0].len != sizeof(psa_ps_uid_t)) {
+ /* The input argument size is incorrect */
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ uid = *((psa_ps_uid_t *)in_vec[0].base);
+
+ p_data = (const void *)in_vec[1].base;
+ data_length = in_vec[1].len;
+
+ if (in_vec[2].len != sizeof(psa_ps_create_flags_t)) {
+ /* The input argument size is incorrect */
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ 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_CONNECTION_REFUSED;
+ }
+
+ err = (psa_ps_status_t *)out_vec[0].base;
+
+ /* Get the caller's client ID */
+ status = tfm_core_get_caller_client_id(&client_id);
+ if (status != TFM_SUCCESS) {
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ *err = tfm_sst_set(client_id, uid, data_length, p_data, create_flags);
+
+ return PSA_SUCCESS;
+}
+
+psa_status_t tfm_sst_get_req(struct psa_invec *in_vec, size_t in_len,
+ struct psa_outvec *out_vec, size_t out_len)
+{
+ uint32_t data_offset;
+ uint32_t data_length;
+ int32_t client_id;
+ psa_ps_uid_t uid;
+ void *p_data;
+ enum tfm_status_e status;
+ psa_ps_status_t *err;
+
+ if ((in_len != 2) || (out_len != 2)) {
+ /* The number of arguments are incorrect */
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ if (in_vec[0].len != sizeof(psa_ps_uid_t)) {
+ /* The input argument size is incorrect */
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ uid = *((psa_ps_uid_t *)in_vec[0].base);
+
+ if (in_vec[1].len != sizeof(data_offset)) {
+ /* The input argument size is incorrect */
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ 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_CONNECTION_REFUSED;
+ }
+
+ err = (psa_ps_status_t *)out_vec[0].base;
+
+ p_data = (void *)out_vec[1].base;
+ data_length = out_vec[1].len;
+
+ /* Get the caller's client ID */
+ status = tfm_core_get_caller_client_id(&client_id);
+ if (status != TFM_SUCCESS) {
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ *err = tfm_sst_get(client_id, uid, data_offset, data_length, p_data);
+
+ return PSA_SUCCESS;
+
+}
+
+psa_status_t tfm_sst_get_info_req(struct psa_invec *in_vec, size_t in_len,
+ struct psa_outvec *out_vec, size_t out_len)
+{
+ int32_t client_id;
+ psa_ps_uid_t uid;
+ struct psa_ps_info_t *p_info;
+ enum tfm_status_e status;
+ psa_ps_status_t *err;
+
+ if ((in_len != 1) || (out_len != 2)) {
+ /* The number of arguments are incorrect */
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ if (in_vec[0].len != sizeof(psa_ps_uid_t)) {
+ /* The input argument size is incorrect */
+ return PSA_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_CONNECTION_REFUSED;
+ }
+
+ 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_CONNECTION_REFUSED;
+ }
+
+ p_info = (struct psa_ps_info_t *)out_vec[1].base;
+
+ /* Get the caller's client ID */
+ status = tfm_core_get_caller_client_id(&client_id);
+ if (status != TFM_SUCCESS) {
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ *err = tfm_sst_get_info(client_id, uid, p_info);
+
+ return PSA_SUCCESS;
+}
+
+psa_status_t tfm_sst_remove_req(struct psa_invec *in_vec, size_t in_len,
+ struct psa_outvec *out_vec, size_t out_len)
+{
+ int32_t client_id;
+ psa_ps_uid_t uid;
+ enum tfm_status_e status;
+ psa_ps_status_t *err;
+
+ if ((in_len != 1) || (out_len != 1)) {
+ /* The number of arguments are incorrect */
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ if (in_vec[0].len != sizeof(psa_ps_uid_t)) {
+ /* The input argument size is incorrect */
+ return PSA_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_CONNECTION_REFUSED;
+ }
+
+ err = (psa_ps_status_t *)out_vec[0].base;
+
+ /* Get the caller's client ID */
+ status = tfm_core_get_caller_client_id(&client_id);
+ if (status != TFM_SUCCESS) {
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ *err = tfm_sst_remove(client_id, uid);
+
+ return PSA_SUCCESS;
+}
+
+psa_status_t tfm_sst_get_support_req(struct psa_invec *in_vec, size_t in_len,
+ struct psa_outvec *out_vec, size_t out_len)
+{
+ uint32_t *support_flags;
+
+ if ((in_len != 0) || (out_len != 1)) {
+ /* The number of arguments are incorrect */
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ if (out_vec[0].len != sizeof(*support_flags)) {
+ /* The output argument size is incorrect */
+ return PSA_CONNECTION_REFUSED;
+ }
+
+ support_flags = (uint32_t *)out_vec[0].base;
+
+ *support_flags = tfm_sst_get_support();
+
+ return PSA_SUCCESS;
+}
diff --git a/secure_fw/services/secure_storage/tfm_sst_req_mngr.h b/secure_fw/services/secure_storage/tfm_sst_req_mngr.h
new file mode 100644
index 0000000..9c22377
--- /dev/null
+++ b/secure_fw/services/secure_storage/tfm_sst_req_mngr.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __TFM_SST_REQ_MNGR_H__
+#define __TFM_SST_REQ_MNGR_H__
+
+#include <stdint.h>
+
+#include "tfm_veneers.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Handles the set request.
+ *
+ * \param[in] in_vec Pointer to the input vector which contains the input
+ * parameters.
+ * \param[in] in_len Number of input parameters in the input vector.
+ * \param[out] out_vec Pointer to the ouput vector which contains the output
+ * parameters.
+ * \param[in] out_len Number of output parameters in the output vector.
+ *
+ * \return A status indicating the success/failure of the operation as specified
+ * in \ref psa_status_t
+ */
+psa_status_t tfm_sst_set_req(struct psa_invec *in_vec, size_t in_len,
+ struct psa_outvec *out_vec, size_t out_len);
+
+/**
+ * \brief Handles the get request.
+ *
+ * \param[in] in_vec Pointer to the input vector which contains the input
+ * parameters.
+ * \param[in] in_len Number of input parameters in the input vector.
+ * \param[out] out_vec Pointer to the ouput vector which contains the output
+ * parameters.
+ * \param[in] out_len Number of output parameters in the output vector.
+ *
+ * \return A status indicating the success/failure of the operation as specified
+ * in \ref psa_status_t
+ */
+psa_status_t tfm_sst_get_req(struct psa_invec *in_vec, size_t in_len,
+ struct psa_outvec *out_vec, size_t out_len);
+
+/**
+ * \brief Handles the get info request.
+ *
+ * \param[in] in_vec Pointer to the input vector which contains the input
+ * parameters.
+ * \param[in] in_len Number of input parameters in the input vector.
+ * \param[out] out_vec Pointer to the ouput vector which contains the output
+ * parameters.
+ * \param[in] out_len Number of output parameters in the output vector.
+ *
+ * \return A status indicating the success/failure of the operation as specified
+ * in \ref psa_status_t
+ */
+psa_status_t tfm_sst_get_info_req(struct psa_invec *in_vec, size_t in_len,
+ struct psa_outvec *out_vec, size_t out_len);
+
+/**
+ * \brief Handles the remove request.
+ *
+ * \param[in] in_vec Pointer to the input vector which contains the input
+ * parameters.
+ * \param[in] in_len Number of input parameters in the input vector.
+ * \param[out] out_vec Pointer to the ouput vector which contains the output
+ * parameters.
+ * \param[in] out_len Number of output parameters in the output vector.
+ *
+ * \return A status indicating the success/failure of the operation as specified
+ * in \ref psa_status_t
+ */
+psa_status_t tfm_sst_remove_req(struct psa_invec *in_vec, size_t in_len,
+ struct psa_outvec *out_vec, size_t out_len);
+
+/**
+ * \brief Handles the get support request.
+ *
+ * \param[in] in_vec Pointer to the input vector which contains the input
+ * parameters.
+ * \param[in] in_len Number of input parameters in the input vector.
+ * \param[out] out_vec Pointer to the ouput vector which contains the output
+ * parameters.
+ * \param[in] out_len Number of output parameters in the output vector.
+ *
+ * \return A status indicating the success/failure of the operation as specified
+ * in \ref psa_status_t
+ *
+ */
+psa_status_t tfm_sst_get_support_req(struct psa_invec *in_vec,
+ size_t in_len,
+ struct psa_outvec *out_vec,
+ size_t out_len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TFM_SST_REQ_MNGR_H__ */
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 c9ff324..5491ff6 100644
--- a/secure_fw/services/secure_storage/tfm_sst_secure_api.c
+++ b/secure_fw/services/secure_storage/tfm_sst_secure_api.c
@@ -6,55 +6,117 @@
*/
#include "psa_protected_storage.h"
-#include "tfm_sst_veneers.h"
+#include "tfm_sst_defs.h"
+#include "tfm_veneers.h"
-__attribute__(( section("SFN")))
+#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 status;
enum tfm_sst_err_t err;
- err = tfm_sst_veneer_set(&uid, data_length, p_data, create_flags);
+ 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_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;
+ }
return TFM_SST_PSA_RETURN(err);
}
-__attribute__(( section("SFN")))
+__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 status;
enum tfm_sst_err_t err;
- err = tfm_sst_veneer_get(&uid, data_offset, data_length, p_data);
+ 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 }
+ };
+
+ 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;
+ }
return TFM_SST_PSA_RETURN(err);
}
-__attribute__(( section("SFN")))
+__attribute__((section("SFN")))
psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
{
+ psa_status_t status;
enum tfm_sst_err_t err;
- err = tfm_sst_veneer_get_info(&uid, p_info);
+ 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) }
+ };
+
+ 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;
+ }
return TFM_SST_PSA_RETURN(err);
}
-__attribute__(( section("SFN")))
+__attribute__((section("SFN")))
psa_ps_status_t psa_ps_remove(psa_ps_uid_t uid)
{
+ psa_status_t status;
enum tfm_sst_err_t err;
- err = tfm_sst_veneer_remove(&uid);
+ psa_invec in_vec[] = {
+ { .base = &uid, .len = sizeof(uid) }
+ };
+
+ psa_outvec out_vec[] = {
+ { .base = &err, .len = sizeof(err) }
+ };
+
+ status = tfm_tfm_sst_remove_req_veneer(in_vec, IOVEC_LEN(in_vec),
+ out_vec, IOVEC_LEN(out_vec));
+
+ if (status != PSA_SUCCESS) {
+ return PSA_PS_ERROR_OPERATION_FAILED;
+ }
return TFM_SST_PSA_RETURN(err);
}
-__attribute__(( section("SFN")))
+__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)
{
@@ -62,7 +124,7 @@
return PSA_PS_ERROR_NOT_SUPPORTED;
}
-__attribute__(( section("SFN")))
+__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)
{
@@ -70,20 +132,23 @@
return PSA_PS_ERROR_NOT_SUPPORTED;
}
-__attribute__(( section("SFN")))
+__attribute__((section("SFN")))
uint32_t psa_ps_get_support(void)
{
- uint32_t support_flags;
-
/* Initialise support_flags to a sensible default, to avoid returning an
* uninitialised value in case the secure function fails.
*/
- support_flags = 0;
+ uint32_t support_flags = 0;
+
+ psa_outvec out_vec[] = {
+ { .base = &support_flags, .len = sizeof(support_flags) }
+ };
/* The PSA API does not return an error, so any error from TF-M is
* ignored.
*/
- (void)tfm_sst_veneer_get_support(&support_flags);
+ (void)tfm_tfm_sst_get_support_req_veneer(NULL, 0,
+ out_vec, IOVEC_LEN(out_vec));
return support_flags;
}
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 da26901..3db2a18 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
@@ -82,7 +82,7 @@
{&tfm_sst_test_1003, "TFM_SST_TEST_1003",
"Set interface with NULL data pointer"},
{&tfm_sst_test_1004, "TFM_SST_TEST_1004",
- "Set interface with invalid data length"},
+ "Set interface with invalid data length (DEPRECATED)"},
{&tfm_sst_test_1005, "TFM_SST_TEST_1005",
"Set interface with write once UID"},
{&tfm_sst_test_1006, "TFM_SST_TEST_1006",
@@ -102,7 +102,7 @@
{&tfm_sst_test_1013, "TFM_SST_TEST_1013",
"Get info interface with invalid UIDs"},
{&tfm_sst_test_1014, "TFM_SST_TEST_1014",
- "Get info interface with NULL info pointer"},
+ "Get info interface with NULL info pointer (DEPRECATED)"},
{&tfm_sst_test_1015, "TFM_SST_TEST_1015",
"Remove interface with valid UID"},
{&tfm_sst_test_1016, "TFM_SST_TEST_1016",
@@ -241,10 +241,16 @@
*/
TFM_SST_NS_TEST(1003, "Thread_A")
{
+ /* A parameter with a null pointer and data length different from 0 is
+ * treated as a secure violation.
+ * TF-M framework will stop this transaction and not return from this
+ * request to NSPE.
+ */
+
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;
- const uint32_t data_len = 1;
+ const uint32_t data_len = 0;
/* Set with NULL data pointer */
status = psa_ps_set(uid, data_len, NULL, flags);
@@ -262,6 +268,14 @@
*/
TFM_SST_NS_TEST(1004, "Thread_A")
{
+ /* 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 will stop this transaction and not return from this
+ * request to NSPE.
+ */
+ TEST_LOG("This test is DEPRECATED and the test execution was SKIPPED\r\n");
+
+#if 0
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;
@@ -274,6 +288,7 @@
TEST_FAIL("Set should not succeed with invalid data length");
return;
}
+#endif
ret->val = TEST_PASSED;
}
@@ -502,7 +517,6 @@
* - Offset greater than UID length
* - Data length greater than UID length
* - Data length + offset greater than UID length
- * - Invalid data len and offset
*/
TFM_SST_NS_TEST(1009, "Thread_A")
{
@@ -571,22 +585,6 @@
return;
}
- /* Get with data length and offset set to invalid values */
- read_len = INVALID_DATA_LEN;
- offset = INVALID_OFFSET;
-
- status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
- TEST_FAIL("Get should not succeed with invalid arguments");
- return;
- }
-
- /* Check that the read data is unchanged */
- if (memcmp(read_data, READ_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) {
@@ -603,6 +601,12 @@
*/
TFM_SST_NS_TEST(1010, "Thread_A")
{
+ /* A parameter with a null pointer and data length different from 0 is
+ * treated as a secure violation.
+ * TF-M framework will stop this transaction and not return from this
+ * request to NSPE.
+ */
+
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;
@@ -617,7 +621,7 @@
}
/* Get with NULL data pointer */
- status = psa_ps_get(uid, offset, data_len, NULL);
+ status = psa_ps_get(uid, offset, 0, NULL);
if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
TEST_FAIL("Get should not succeed with NULL data pointer");
return;
@@ -767,6 +771,13 @@
*/
TFM_SST_NS_TEST(1014, "Thread_A")
{
+ /* A parameter with a null pointer is treated as a secure violation.
+ * TF-M framework will stop this transaction and not return from this
+ * request to NSPE.
+ */
+ TEST_LOG("This test is DEPRECATED and the test execution was SKIPPED\r\n");
+
+#if 0
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;
@@ -792,6 +803,7 @@
TEST_FAIL("Remove should not fail with valid UID");
return;
}
+#endif
ret->val = TEST_PASSED;
}
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 2227cb7..4993604 100644
--- a/test/suites/sst/secure/psa_ps_s_interface_testsuite.c
+++ b/test/suites/sst/secure/psa_ps_s_interface_testsuite.c
@@ -232,9 +232,15 @@
const psa_ps_create_flags_t flags = PSA_PS_FLAG_NONE;
const uint32_t data_len = 1;
+ /* 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.
+ */
+
/* Set with NULL data pointer */
status = psa_ps_set(uid, data_len, NULL, flags);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ if (status != PSA_PS_ERROR_OPERATION_FAILED) {
TEST_FAIL("Set should not succeed with NULL data pointer");
return;
}
@@ -254,9 +260,16 @@
const uint32_t data_len = INVALID_DATA_LEN;
uint8_t write_data[] = WRITE_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.
+ */
+
/* Set with data length longer than the maximum supported */
status = psa_ps_set(uid, data_len, write_data, flags);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ if (status != PSA_PS_ERROR_OPERATION_FAILED) {
TEST_FAIL("Set should not succeed with invalid data length");
return;
}
@@ -561,8 +574,15 @@
read_len = INVALID_DATA_LEN;
offset = INVALID_OFFSET;
+ /* 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.
+ */
+
status = psa_ps_get(uid, offset, read_len, read_data + HALF_PADDING_SIZE);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ if (status != PSA_PS_ERROR_OPERATION_FAILED) {
TEST_FAIL("Get should not succeed with invalid arguments");
return;
}
@@ -602,9 +622,15 @@
return;
}
+ /* 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.
+ */
+
/* Get with NULL data pointer */
status = psa_ps_get(uid, offset, data_len, NULL);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ if (status != PSA_PS_ERROR_OPERATION_FAILED) {
TEST_FAIL("Get should not succeed with NULL data pointer");
return;
}
@@ -765,9 +791,15 @@
return;
}
+ /* 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.
+ */
+
/* Get info with NULL info pointer */
status = psa_ps_get_info(uid, NULL);
- if (status != PSA_PS_ERROR_INVALID_ARGUMENT) {
+ if (status != PSA_PS_ERROR_OPERATION_FAILED) {
TEST_FAIL("Get info should not succeed with NULL info pointer");
return;
}