SST: Replace SST APIs with PSA PS APIs
Refactors the SST non-secure interfaces, secure API, veneers and
manifest to implement the PSA Protected Storage specification. Adds a
stub implementation for the new SST APIs; another patch will add the
final implementation.
Change-Id: Id62eb82c9d33afd2114962ab1994d567cd81e4f7
Signed-off-by: Jamie Fox <jamie.fox@arm.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index 870e896..4b68f26 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -147,7 +147,6 @@
add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES)
set(TEST_FRAMEWORK_S ON)
set(TFM_PARTITION_TEST_SECURE_SERVICES ON)
- set(TFM_PARTITION_TEST_SST ON)
endif()
if (SERVICE_TEST_NS)
@@ -241,6 +240,10 @@
set (SST_RAM_FS OFF)
endif()
endif()
+
+ if (NOT DEFINED PSA_PROTECTED_STORAGE)
+ set (PSA_PROTECTED_STORAGE ON)
+ endif()
endif()
if (NOT DEFINED MBEDTLS_DEBUG)
diff --git a/interface/include/psa_sst_api.h b/interface/include/psa_sst_api.h
deleted file mode 100644
index dee3022..0000000
--- a/interface/include/psa_sst_api.h
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-/**
- * \file psa_sst_api.h
- *
- * \brief Platform security architecture (PSA) API for secure storage partition
- */
-
-#ifndef __PSA_SST_API__
-#define __PSA_SST_API__
-
-#include "psa_sst_asset_defs.h"
-#include "psa_sst_asset_macros.h"
-
-#include "tfm_api.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * PSA SST API version
- */
-#define PSA_SST_API_VERSION_MAJOR 0
-#define PSA_SST_API_VERSION_MINOR 2
-
-/* The return value is shared with the TF-M partition status value.
- * The SST return codes shouldn't overlap with predefined TFM status values.
- */
-#define PSA_SST_ERR_OFFSET (TFM_PARTITION_SPECIFIC_ERROR_MIN)
-
-/*!
- * \enum psa_sst_err_t
- *
- * \brief Secure storage service error types
- *
- */
-enum psa_sst_err_t {
- PSA_SST_ERR_SUCCESS = 0,
- PSA_SST_ERR_ASSET_NOT_PREPARED = PSA_SST_ERR_OFFSET,
- PSA_SST_ERR_ASSET_NOT_FOUND,
- PSA_SST_ERR_PARAM_ERROR,
- PSA_SST_ERR_STORAGE_SYSTEM_FULL,
- PSA_SST_ERR_SYSTEM_ERROR,
- /* Following entry is only to ensure the error code of int size */
- PSA_SST_ERR_FORCE_INT_SIZE = INT_MAX
-};
-
-/**
- * \brief Allocates space for the asset, referenced by asset UUID,
- * without setting any data in the asset.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] token Must be set to NULL, reserved for future use.
- * Pointer to the asset token to be used to generate
- * the asset key to encrypt and decrypt the asset
- * data. This is an optional parameter that has to
- * be NULL in case the token is not provied.
- * \param[in] token_size Must be set to 0, reserved for future use.
- * Token size. In case the token is not provided
- * the token size has to be 0.
- *
- * \return Returns an PSA_SST_ERR_SUCCESS if asset is created correctly.
- * Otherwise, error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t psa_sst_create(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size);
-
-/**
- * \brief Gets asset's information referenced by asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] token Must be set to NULL, reserved for future use.
- * Pointer to the asset token to be used to generate
- * the asset key to encrypt and decrypt the asset
- * data. This is an optional parameter that has to
- * be NULL in case the token is not provied.
- * \param[in] token_size Must be set to 0, reserved for future use.
- * Token size. In case the token is not provided
- * the token size has to be 0.
- * \param[out] info Pointer to store the asset's information
- * \ref psa_sst_asset_info_t
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t psa_sst_get_info(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- struct psa_sst_asset_info_t *info);
-
-/**
- * \brief Gets asset's attributes referenced by asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] token Must be set to NULL, reserved for future use.
- * Pointer to the asset token to be used to generate
- * the asset key to encrypt and decrypt the asset
- * data. This is an optional parameter that has to
- * be NULL in case the token is not provied.
- * \param[in] token_size Must be set to 0, reserved for future use.
- * Token size. In case the token is not provided
- * the token size has to be 0.
- * \param[out] attrs Pointer to store the asset's attributes
- * \ref psa_sst_asset_attrs_t
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t psa_sst_get_attributes(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- struct psa_sst_asset_attrs_t *attrs);
-
-/**
- * \brief Sets asset's attributes referenced by asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] token Must be set to NULL, reserved for future use.
- * Pointer to the asset token to be used to generate
- * the asset key to encrypt and decrypt the asset
- * data. This is an optional parameter that has to
- * be NULL in case the token is not provied.
- * \param[in] token_size Must be set to 0, reserved for future use.
- * Token size. In case the token is not provided
- * the token size has to be 0.
- * \param[in] attrs Pointer to new the asset's attributes
- * \ref psa_sst_asset_attrs_t
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t psa_sst_set_attributes(
- uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- const struct psa_sst_asset_attrs_t *attrs);
-
-/**
- * \brief Reads asset's data from asset referenced by asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] token Must be set to NULL, reserved for future use.
- * Pointer to the asset token to be used to generate
- * the asset key to encrypt and decrypt the asset
- * data. This is an optional parameter that has to
- * be NULL in case the token is not provied.
- * \param[in] token_size Must be set to 0, reserved for future use.
- * Token size. In case the token is not provided
- * the token size has to be 0.
- * \param[in] size Size of the data to read
- * \param[in] offset Offset within asset to start to read
- * \param[out] data Pointer to data vector to store data
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t psa_sst_read(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- uint32_t size,
- uint32_t offset,
- uint8_t *data);
-
-/**
- * \brief Reads asset's data on behalf of the given client ID if the
- * client has reference permissions.
- * This function is only accessible for secure partition with specific
- * permissions. Hence, It must not be accessible from the Non-secure
- * Processing Environment (NSPE).
- *
- * \param[in] client_id Client ID which is referenced in the read
- * \param[in] asset_uuid Asset UUID
- * \param[in] token Must be set to NULL, reserved for future use.
- * Pointer to the asset token to be used to generate
- * the asset key to encrypt and decrypt the asset
- * data. This is an optional parameter that has to
- * be NULL in case the token is not provied.
- * \param[in] token_size Must be set to 0, reserved for future use.
- * Token size. In case the token is not provided
- * the token size has to be 0.
- * \param[in] size Size of the data to read
- * \param[in] offset Offset within asset to start to read
- * \param[out] data Pointer to data vector to store data
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t psa_sst_reference_read(int32_t client_id,
- uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- uint32_t size,
- uint32_t offset,
- uint8_t *data);
-
-/**
- * \brief Writes data into an asset referenced by asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] token Must be set to NULL, reserved for future use.
- * Pointer to the asset token to be used to generate
- * the asset key to encrypt and decrypt the asset
- * data. This is an optional parameter that has to
- * be NULL in case the token is not provied.
- * \param[in] token_size Must be set to 0, reserved for future use.
- * Token size. In case the token is not provided
- * the token size has to be 0.
- * \param[in] size Size of the data to start to write
- * \param[in] offset Offset within asset to write the data
- * \param[in] data Pointer to data vector which contains the data to
- * write
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t psa_sst_write(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- uint32_t size,
- uint32_t offset,
- const uint8_t *data);
-
-/**
- * \brief Deletes the asset referenced by the asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] token Must be set to NULL, reserved for future use.
- * Pointer to the asset token to be used to generate
- * the asset key to encrypt and decrypt the asset
- * data. This is an optional parameter that has to
- * be NULL in case the token is not provied.
- * \param[in] token_size Must be set to 0, reserved for future use.
- * Token size. In case the token is not provided
- * the token size has to be 0.
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t psa_sst_delete(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __PSA_SST_API__ */
diff --git a/interface/include/psa_sst_asset_defs.h b/interface/include/psa_sst_asset_defs.h
deleted file mode 100644
index a810c55..0000000
--- a/interface/include/psa_sst_asset_defs.h
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-/**
- * \file psa_sst_asset_defs.h
- *
- * \brief Platform security architecture (PSA) asset definitions for
- * secure storage partition.
- */
-
-#ifndef __PSA_SST_ASSET_DEFS_H__
-#define __PSA_SST_ASSET_DEFS_H__
-
-#include <inttypes.h>
-#include <limits.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* List of PSA SST asset category types */
-/*!
- * \def PSA_SST_ASSET_CAT_TYPE_NONE
- *
- * \brief Asset category type NONE. This is value used in an asset when the
- * asset category type is not set.
- */
-#define PSA_SST_ASSET_CAT_TYPE_NONE ((uint32_t)0x00000000)
-
-/*!
- * \def PSA_SST_ASSET_CAT_RAW_DATA
- *
- * \brief This category type is used for those assets which contains raw data.
- */
-#define PSA_SST_ASSET_CAT_RAW_DATA ((uint32_t)0x02000000)
-
-/*!
- * \def PSA_SST_ASSET_CAT_KEY_SYMMETRIC
- *
- * \brief This category type is used for those assets which contains a
- * symmetric key.
- */
-#define PSA_SST_ASSET_CAT_KEY_SYMMETRIC ((uint32_t)0x04000000)
-
-/*!
- * \def PSA_SST_ASSET_CAT_KEY_PUBLIC
- *
- * \brief This category type is used for those assets which contains an
- * asymmetric public key.
- */
-#define PSA_SST_ASSET_CAT_KEY_PUBLIC ((uint32_t)0x06000000)
-
-/*!
- * \def PSA_SST_ASSET_CAT_KEY_PRIVATE
- *
- * \brief This category type is used for those assets which contains an
- * asymmetric private key.
- */
-#define PSA_SST_ASSET_CAT_KEY_PRIVATE ((uint32_t)0x07000000)
-
-/*!
- * \def PSA_SST_ASSET_CAT_CERTIFICATE
- *
- * \brief This category type is used for those assets which contains a
- * certificate.
- */
-#define PSA_SST_ASSET_CAT_CERTIFICATE ((uint32_t)0x08000000)
-
-/*!
- * \def PSA_SST_ASSET_CAT_VENDOR_DEFINED
- *
- * \brief This category type is used when assets is vendor defined.
- */
-#define PSA_SST_ASSET_CAT_VENDOR_DEFINED ((uint32_t)0x80000000)
-
-/* PSA SST asset category type masks */
-/*!
- * \def PSA_SST_ASSET_CAT_TYPE_MASK
- *
- * \brief Asset category type mask.
- */
-#define PSA_SST_ASSET_CAT_TYPE_MASK ((uint32_t)0x7f000000)
-
-/*!
- * \def PSA_SST_ASSET_CAT_KEY_MASK
- *
- * \brief Asset key category mask.
- */
-#define PSA_SST_ASSET_CAT_KEY_MASK ((uint32_t)0x04000000)
-
-/*!
- * \def PSA_SST_ASSET_CAT_KEY_ASYMMETRIC_MASK
- *
- * \brief Asset asymmetric key mask.
- */
-#define PSA_SST_ASSET_CAT_KEY_ASYMMETRIC_MASK ((uint32_t)0x06000000)
-
-
-/* Asset types for raw data category */
-/*!
- * \def PSA_SST_ASSET_KEY_HMAC
- *
- * \brief HMAC key.
- */
-#define PSA_SST_ASSET_KEY_HMAC ((PSA_SST_ASSET_CAT_RAW_DATA)| 0x00000001)
-
-/* Asset types for symmetric key category */
-/*!
- * \def PSA_SST_ASSET_KEY_AES
- *
- * \brief AES key to be used in algorithms based on AES cipher
- * (cipher, AEAD or MAC).
- */
-#define PSA_SST_ASSET_KEY_AES ((PSA_SST_ASSET_CAT_KEY_SYMMETRIC)|0x00000001)
-
-/*!
- * \def PSA_SST_ASSET_KEY_DES
- *
- * \brief DES key to be used in algorithms based on DES or 3DES cipher
- * (cipher or MAC).
- */
-#define PSA_SST_ASSET_KEY_DES ((PSA_SST_ASSET_CAT_KEY_SYMMETRIC)|0x00000002)
-
-/*!
- * \def PSA_SST_ASSET_KEY_CAMELLIA
- *
- * \brief Camellia key to be used in algorithms based on Camellia cipher
- * (cipher, AEAD or MAC).
- */
-#define PSA_SST_ASSET_KEY_CAMELLIA \
- ((PSA_SST_ASSET_CAT_KEY_SYMMETRIC)|0x00000003)
-
-/* Asset types for asymmetric key category */
-/*!
- * \def PSA_SST_ASSET_KEY_RSA_PUBLIC
- *
- * \brief RSA public key.
- */
-#define PSA_SST_ASSET_KEY_RSA_PUBLIC ((PSA_SST_ASSET_CAT_KEY_PUBLIC)|0x00010000)
-
-/*!
- * \def PSA_SST_ASSET_KEY_RSA_PRIVATE
- *
- * \brief RSA private key.
- */
-#define PSA_SST_ASSET_KEY_RSA_PRIVATE \
- ((PSA_SST_ASSET_CAT_KEY_PRIVATE)|0x00010000)
-
-/*!
- * \def PSA_SST_ASSET_KEY_DSA_PUBLIC
- *
- * \brief DSA public key.
- */
-#define PSA_SST_ASSET_KEY_DSA_PUBLIC ((PSA_SST_ASSET_CAT_KEY_PUBLIC)|0x00020000)
-
-/*!
- * \def PSA_SST_ASSET_KEY_DSA_PRIVATE
- *
- * \brief DSA private key.
- */
-#define PSA_SST_ASSET_KEY_DSA_PRIVATE \
- ((PSA_SST_ASSET_CAT_KEY_PRIVATE)|0x00020000)
-
-/*!
- * \def PSA_SST_ASSET_KEY_ECC_PUBLIC
- *
- * \brief ECC public key.
- */
-#define PSA_SST_ASSET_KEY_ECC_PUBLIC ((PSA_SST_ASSET_CAT_KEY_PUBLIC)|0x00030000)
-
-/*!
- * \def PSA_SST_ASSET_KEY_ECC_PRIVATE
- *
- * \brief ECC private key.
- */
-#define PSA_SST_ASSET_KEY_ECC_PRIVATE \
- ((PSA_SST_ASSET_CAT_KEY_PRIVATE)|0x00030000)
-
-/*!
- * \def PSA_SST_ASSET_KEY_ECC_CURVE_MASK
- *
- * \brief ECC curve mask. This mask allows to encode the curve identifiers which
- * are aligned with the TLS Supported Groups Registry (formerly known as
- * the TLS EC Named Curve Registry)
- * https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml
- * The values are defined by RFC 4492, RFC 7027 and RFC 7919.
- */
-#define PSA_SST_ASSET_KEY_ECC_CURVE_MASK ((uint32_t)0x0000ffff)
-
-/* Asset types for certificate category */
-/*!
- * \def PSA_SST_ASSET_CERT_X_509
- *
- * \brief X509 certificate.
- */
-#define PSA_SST_ASSET_CERT_X_509 ((PSA_SST_ASSET_CAT_CERTIFICATE)|0x00000001)
-
-/* List of PSA SST asset */
-/*!
- * \def PSA_SST_ASSET_ATTR_EXPIRED
- *
- * \brief Indicates if asset has expired.
- */
-#define PSA_SST_ASSET_ATTR_EXPIRED ((uint32_t)0x00000001)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_GENERATED_LOCALLY
- *
- * \brief Indicates if asset content has been generated locally.
- */
-#define PSA_SST_ASSET_ATTR_GENERATED_LOCALLY ((uint32_t)0x00000002)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_DERIVATION
- *
- * \brief Indicates if asset content can be used in a key derivation (i.e.
- * if other keys can be derived from this one)
- *
- */
-#define PSA_SST_ASSET_ATTR_DERIVATION ((uint32_t)0x00000004)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_TRUSTED
- *
- * \brief Indicates if asset content can be trusted.
- */
-#define PSA_SST_ASSET_ATTR_TRUSTED ((uint32_t)0x00000008)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_WRITE_ONCE
- *
- * \brief Indicates if asset content can be modified once a content has been
- * set.
- */
-#define PSA_SST_ASSET_ATTR_WRITE_ONCE ((uint32_t)0x00000010)
-
-/* The next 3 bits are reserved */
-
-/*!
- * \def PSA_SST_ASSET_ATTR_ENCRYPT
- *
- * \brief Indicates if asset content may be used to encrypt data.
- */
-#define PSA_SST_ASSET_ATTR_ENCRYPT ((uint32_t)0x00000100)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_DECRYPT
- *
- * \brief Indicates if asset content may be used to decrypt data.
- */
-#define PSA_SST_ASSET_ATTR_DECRYPT ((uint32_t)0x00000200)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_SIGN
- *
- * \brief Indicates if asset content may be used to sign data.
- */
-#define PSA_SST_ASSET_ATTR_SIGN ((uint32_t)0x00000400)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_VERIFY
- *
- * \brief Indicates if asset content may be used to verify signed data.
- */
-#define PSA_SST_ASSET_ATTR_VERIFY ((uint32_t)0x00000800)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_VERIFY_RECOVER
- *
- * \brief Indicates if asset content may be used to verify data where
- * data is recovered from the signature.
- */
-#define PSA_SST_ASSET_ATTR_VERIFY_RECOVER ((uint32_t)0x00001000)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_WRAP
- *
- * \brief Indicates if asset content may be used to wrap other data
- * (i.e wrap other keys).
- */
-#define PSA_SST_ASSET_ATTR_WRAP ((uint32_t)0x00002000)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_UNWRAP
- *
- * \brief Indicates if asset content may be used to unwrap other data
- * (i.e unwrap other keys).
- */
-#define PSA_SST_ASSET_ATTR_UNWRAP ((uint32_t)0x00004000)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_SENSITIVE
- *
- * \brief Indicates if asset content is sensitive and cannot be revealed.
- */
-#define PSA_SST_ASSET_ATTR_SENSITIVE ((uint32_t)0x00008000)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_ALWAYS_SENSITIVE
- *
- * \brief Indicates if asset has always had the sensitive attribute. Attribute
- * cannot be changed once set. It becomes a read only attribute.
- */
-#define PSA_SST_ASSET_ATTR_ALWAYS_SENSITIVE ((uint32_t)0x00010000)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_EXTRACTABLE
- *
- * \brief Indicates if asset content is extractable and can be wrapped.
- */
-#define PSA_SST_ASSET_ATTR_EXTRACTABLE ((uint32_t)0x00020000)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_NEVER_EXTRACTABLE
- *
- * \brief Indicates if asset has never had the extactable attribute. Attribute
- * cannot be changed once set. It becomes a read only attribute.
- */
-#define PSA_SST_ASSET_ATTR_NEVER_EXTRACTABLE ((uint32_t)0x00040000)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_ALWAYS_AUTHENTICATE
- *
- * \brief Indicates if user has to be authenticate when the asset content has
- * to be used.
- */
-#define PSA_SST_ASSET_ATTR_ALWAYS_AUTHENTICATE ((uint32_t)0x00080000)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_MASK
- *
- * \brief Asset attributes mask.
- */
-#define PSA_SST_ASSET_ATTR_MASK ((uint32_t)0x7FFFFFFF)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_VENDOR_DEFINED
- *
- * \brief Indicates if the attribute is vendor defined.
- */
-#define PSA_SST_ASSET_ATTR_VENDOR_DEFINED ((uint32_t)0x80000000)
-
-
-/* PSA SST asset structure definitions */
-/*!
- * \struct psa_sst_asset_info_t
- *
- * \brief Asset information.
- */
-struct psa_sst_asset_info_t {
- uint32_t type; /*!< Asset type */
- uint32_t size_current; /*!< The current size of the asset content */
- uint32_t size_max; /*!< The maximum size of the asset content in
- * bytes
- */
-};
-
-/*!
- * \struct psa_sst_asset_validity_t
- *
- * \brief Asset validity structure.
- *
- * \note Start and end values must be set to 0 as they are reserved for future
- * use.
- */
-struct psa_sst_asset_validity_t {
- uint64_t start; /*!< Start date/time on which the asset validity period
- * begins
- */
- uint64_t end; /*!< End date on which the asset validity period ends */
-
-};
-
-/*!
- * \struct psa_sst_asset_attrs_t
- *
- * \brief Asset attributes structure.
- *
- */
-struct psa_sst_asset_attrs_t {
- struct psa_sst_asset_validity_t validity; /*!< Asset validity period */
- uint32_t attrs; /*!< Asset attributes */
- uint8_t reserved[4]; /*!< Reserved for future
- * expansion. Default value is
- * 0 in all bytes
- */
-};
-
-/*!
- * \def PSA_SST_ASSET_INFO_SIZE
- *
- * \brief Indicates the asset information structure size.
- */
-#define PSA_SST_ASSET_INFO_SIZE sizeof(struct psa_sst_asset_info_t)
-
-/*!
- * \def PSA_SST_ASSET_ATTR_SIZE
- *
- * \brief Indicates the asset attributes structure size.
- */
-#define PSA_SST_ASSET_ATTR_SIZE sizeof(struct psa_sst_asset_attrs_t)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __PSA_SST_ASSET_DEFS_H__ */
diff --git a/interface/include/psa_sst_asset_macros.h b/interface/include/psa_sst_asset_macros.h
deleted file mode 100644
index a7fb058..0000000
--- a/interface/include/psa_sst_asset_macros.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-/**
- * \file psa_sst_asset_macros.h
- *
- * \brief Platform security architecture (PSA) asset macros definitions for
- * secure storage partition
- */
-#ifndef __PSA_SST_ASSET_MACROS_H__
-#define __PSA_SST_ASSET_MACROS_H__
-
-#include "psa_sst_asset_defs.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*!
- * \def PSA_SST_ASSET_IS_ASSET_CAT(psa_sst_def_cat_type, type)
- *
- * \brief Macro to check if the asset category type (type) is equal to the
- * PSA SST asset defined category types (psa_sst_def_cat_type).
- *
- * \param[in] psa_sst_def_cat_type PSA SST asset defined category type
- * \param[in] type Asset type
- *
- * \return Returns 1 if the asset type is equal to the PSA SST asset defined
- * type. Otherwise, it returns 0.
- */
-#define PSA_SST_ASSET_IS_ASSET_CAT(psa_sst_def_cat_type, type) \
- (((type & PSA_SST_ASSET_CAT_VENDOR_DEFINED) != 0) && \
- ((type & PSA_SST_ASSET_CAT_TYPE_MASK) == psa_sst_def_cat_type))
-
-/*!
- * \def PSA_SST_ASSET_IS_ASSET_TYPE(psa_sst_def_type, type)
- *
- * \brief Macro to check if the asset type (type) is equal to the
- * PSA SST asset defined type (psa_sst_def_type).
- *
- * \param[in] psa_sst_def_type PSA SST asset defined type
- * \param[in] type Asset type
- *
- * \return Returns 1 if the asset type is equal to the PSA SST asset defined
- * type. Otherwise, it returns 0.
- */
-#define PSA_SST_ASSET_IS_ASSET_TYPE(psa_sst_def_type, type) \
- (((type & PSA_SST_ASSET_CAT_VENDOR_DEFINED) != 0) && \
- (type == psa_sst_def_type))
-
-/*!
- * \def PSA_SST_ASSET_IS_VENDOR_DEFINED(type)
- *
- * \brief Macro to check if the asset type is vendor defined.
- *
- * \param[in] type Asset type
- *
- * \return Returns 1 if the asset type is equal to PSA_SST_ASSET_VENDOR_DEFINED.
- * Otherwise, it returns 0.
- */
-#define PSA_SST_ASSET_IS_VENDOR_DEFINED(type) \
- ((type & PSA_SST_ASSET_VENDOR_DEFINED) != 0)
-
-/*!
- * \def PSA_SST_ASSET_IS_KEY_TYPE(type)
- *
- * \brief Macro to check if the asset type is a key.
- *
- * \param[in] type Asset type
- *
- * \return Returns 1 if it is a key. Otherwise, it returns 0.
- */
-#define PSA_SST_ASSET_IS_KEY_TYPE(type) \
- ((type & PSA_SST_ASSET_KEY_MASK) != 0)
-
-/*!
- * \def PSA_SST_ASSET_IS_ASYMMETRIC_KEY_TYPE(type)
- *
- * \brief Macro to check if the asset type is a symmetric key.
- *
- * \param[in] type Asset type
- *
- * \return Returns 1 if it is an asymmetric key. Otherwise, it returns 0.
- */
-#define PSA_SST_ASSET_IS_ASYMMETRIC_KEY_TYPE(type) \
- ((type & PSA_SST_ASSET_KEY_ASYMMETRIC_MASK) != 0)
-
-/*!
- * \def PSA_SST_ASSET_HAS_ATTR(psa_sst_def_asset_attr, attrs)
- *
- * \brief Macro to check if the asset attributes (attrs) have a specific PSA
- * SST asset defined bit attribute (psa_sst_def_asset_attr).
- *
- * \param[in] psa_sst_def_type PSA SST asset defined bit attribute
- * \param[in] attrs Asset attributes
- *
- * \return Returns 1 if the asset has the PSA SST asset defined
- * attribute. Otherwise, it returns 0.
- */
-#define PSA_SST_ASSET_HAS_ATTR(psa_sst_def_asset_attr, attrs) \
- (((attrs & psa_sst_def_asset_attr) != 0) && \
- ((attrs & PSA_SST_ASSET_ATTR_VENDOR_DEFINED) == 0))
-
-/*!
- * \def PSA_SST_ASSET_HAS_ATTR_VENDOR_DEFINED(attrs)
- *
- * \brief Macro to check if the asset attributes are vendor defined.
- *
- * \param[in] attrs Asset attributes
- *
- * \return Returns 1 if the asset type is equal to PSA_SST_ASSET_VENDOR_DEFINED.
- * Otherwise, it returns 0.
- */
-#define PSA_SST_ASSET_HAS_ATTR_VENDOR_DEFINED(attrs) \
- ((attrs & PSA_SST_ASSET_ATTR_VENDOR_DEFINED) != 0)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __PSA_SST_ASSET_MACROS_H__ */
diff --git a/interface/include/tfm_sst_defs.h b/interface/include/tfm_sst_defs.h
index 09d3b44..a008c73 100644
--- a/interface/include/tfm_sst_defs.h
+++ b/interface/include/tfm_sst_defs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -8,43 +8,52 @@
#ifndef __TFM_SST_DEFS_H__
#define __TFM_SST_DEFS_H__
+#include <limits.h>
+#include "psa_protected_storage.h"
+#include "tfm_api.h"
+
#ifdef __cplusplus
extern "C" {
#endif
-#include <inttypes.h>
-#include <limits.h>
-#include "psa_sst_api.h"
+/* The return value is shared with the TF-M partition status value.
+ * The SST return codes shouldn't overlap with predefined TF-M status values.
+ */
+#define TFM_SST_ERR_OFFSET (TFM_PARTITION_SPECIFIC_ERROR_MIN)
-/*!
- * \struct tfm_sst_token_t
+/**
+ * \enum tfm_sst_err_t
*
- * \brief Structure to store the asset's token.
+ * \brief TF-M Secure Storage service error types
*
*/
-struct tfm_sst_token_t {
- const uint8_t *token; /*!< Pointer to the asset's token to be used to
- * generate the asset key to encrypt and decrypt
- * the asset data. This is an optional parameter
- * that has to be NULL in case the token is not
- * provied.
- */
- uint32_t token_size; /*!< Token size. In case the token is not provided
- * the token size has to be 0.
- */
+enum tfm_sst_err_t {
+ TFM_SST_ERR_SUCCESS = 0,
+ TFM_SST_ERR_WRITE_ONCE = TFM_SST_ERR_OFFSET,
+ TFM_SST_ERR_FLAGS_NOT_SUPPORTED,
+ TFM_SST_ERR_INSUFFICIENT_SPACE,
+ TFM_SST_ERR_STORAGE_FAILURE,
+ TFM_SST_ERR_UID_NOT_FOUND,
+ TFM_SST_ERR_INCORRECT_SIZE,
+ TFM_SST_ERR_OFFSET_INVALID,
+ TFM_SST_ERR_INVALID_ARGUMENT,
+ TFM_SST_ERR_DATA_CORRUPT,
+ TFM_SST_ERR_AUTH_FAILED,
+ TFM_SST_ERR_OPERATION_FAILED,
+ TFM_SST_ERR_NOT_SUPPORTED,
+ /* Add an invalid return code which forces the size of the type as well */
+ TFM_SST_ERR_INVALID = INT_MAX
};
-/*!
- * \struct tfm_sst_buf_t
- *
- * \brief Structure to store data information to read/write from/to asset.
- *
+/**
+ * \brief A macro to translate TF-M API return values including the offset
+ * needed by TF-M, to the corresponding PSA value.
*/
-struct tfm_sst_buf_t {
- uint8_t *data; /*!< Address of input/output data */
- uint32_t size; /*!< Size of input/output data */
- uint32_t offset; /*!< Offset within asset */
-};
+#define TFM_SST_PSA_RETURN(err) ( \
+ (err) == TFM_SST_ERR_SUCCESS ? err : \
+ (err) >= TFM_SST_ERR_WRITE_ONCE ? ((err) - (TFM_SST_ERR_WRITE_ONCE - 1)) : \
+ TFM_SST_ERR_INVALID \
+)
#ifdef __cplusplus
}
diff --git a/interface/include/tfm_sst_veneers.h b/interface/include/tfm_sst_veneers.h
index 6cfd5c1..670ffae 100644
--- a/interface/include/tfm_sst_veneers.h
+++ b/interface/include/tfm_sst_veneers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -8,119 +8,167 @@
#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
-#include "tfm_sst_defs.h"
+/**
+ * \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 Allocates space for the asset, referenced by asset UUID,
- * without setting any data in the asset.
+ * \brief Gets the asset data for the provided uid. (Veneer function)
*
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- * \param[in] asset_uuid Asset UUID \ref tfm_sst_asset_id_t
+ * \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 Returns PSA_SST_ERR_SUCCESS if the asset has been created correctly.
- * If SST area is not prepared, it returns
- * PSA_SST_ERR_ASSET_NOT_PREPARED. If SST area is full, it returns
- * PSA_SST_ERR_STORAGE_SYSTEM_FULL. If application id doesn't have the
- * write rights, it returns PSA_SST_ERR_PERMS_NOT_ALLOWED.
+ * \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 psa_sst_err_t tfm_sst_veneer_create(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token);
+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 asset's information referenced by asset UUID.
+ * \brief Gets the metadata for the provided uid. (Veneer function)
*
- * \param[in] asset_uuid Asset UUID
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- * \param[out] info Pointer to store the asset's information
- * \ref psa_sst_asset_info_t
+ * \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 Returns error code as specified in \ref psa_sst_err_t
+ * \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 psa_sst_err_t tfm_sst_veneer_get_info(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct psa_sst_asset_info_t *info);
+enum tfm_sst_err_t tfm_sst_veneer_get_info(const psa_ps_uid_t *uid,
+ struct psa_ps_info_t *p_info);
/**
- * \brief Gets asset's attributes referenced by asset UUID.
+ * \brief Removes the provided uid and its associated data from storage. (Veneer
+ * function)
*
- * \param[in] asset_uuid Asset UUID
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- * \param[out] attrs Pointer to store the asset's attributes
- * \ref tfm_sst_asset_attrs_t
+ * \param[in] uid The unique identifier for the data to be removed
*
- * \return Returns error code as specified in \ref psa_sst_err_t
+ * \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 psa_sst_err_t tfm_sst_veneer_get_attributes(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct psa_sst_asset_attrs_t *attrs);
+enum tfm_sst_err_t tfm_sst_veneer_remove(const psa_ps_uid_t *uid);
/**
- * \brief Sets asset's attributes referenced by asset UUID.
+ * \brief Gets a bitmask with flags set for all of the optional features
+ * supported by the implementation. (Veneer function)
*
- * \param[in] asset_uuid Asset UUID
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- * \param[in] attrs Pointer to new the asset's attributes
- * \ref psa_sst_asset_attrs_t
+ * \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 Returns error code as specified in \ref psa_sst_err_t
+ * \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 psa_sst_err_t tfm_sst_veneer_set_attributes(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- const struct psa_sst_asset_attrs_t *attrs);
+enum tfm_sst_err_t tfm_sst_veneer_get_support(uint32_t *support_flags);
-/**
- * \brief Reads asset's data from asset referenced by asset UUID.
- *
-
- * \param[in] client_id Client ID which calls the service.
- * In case, the caller is a secure partition, this
- * parameter can be a non-secure or secure client ID
- * if the read is in behalf of that client.
- * \param[in] asset_uuid Asset UUID
- * \param[in] s_token Pointer to the asset's token
- * \ref tfm_sst_token_t
- * \param[in/out] data Pointer to data vector \ref tfm_sst_buf_t to
- * store data, size and offset
- *
- * \return Returns the number of bytes written or a castable \ref psa_sst_err_t
- * value
- */
-enum psa_sst_err_t tfm_sst_veneer_read(int32_t client_id,
- uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct tfm_sst_buf_t *data);
-
-/**
- * \brief Writes data into an asset referenced by asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- * \param[in] data Pointer to data vector \ref tfm_sst_buf_t which
- * contains the data to write
- *
- * \return Returns the number of bytes written or a castable \ref psa_sst_err_t
- * value
- */
-enum psa_sst_err_t tfm_sst_veneer_write(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct tfm_sst_buf_t *data);
-
-/**
- * \brief Deletes the asset referenced by the asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- *
- * \return Returns PSA_SST_ERR_PERMS_NOT_ALLOWED if the asset can't be deleted
- * to by this app ID. Returns PSA_SST_ERR_ASSET_REF_INVALID, if asset
- * no longer exists. Otherwise, PSA_SST_ERR_SUCCESS.
- */
-enum psa_sst_err_t tfm_sst_veneer_delete(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token);
#ifdef __cplusplus
}
#endif
diff --git a/interface/include/tfm_veneers.h b/interface/include/tfm_veneers.h
index 4d4a38d..7fdb9f9 100644
--- a/interface/include/tfm_veneers.h
+++ b/interface/include/tfm_veneers.h
@@ -17,13 +17,11 @@
#endif
/******** TFM_SP_STORAGE ********/
-psa_status_t tfm_sst_am_create_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
-psa_status_t tfm_sst_am_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_sst_am_get_attributes_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
-psa_status_t tfm_sst_am_set_attributes_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
-psa_status_t tfm_sst_am_read_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
-psa_status_t tfm_sst_am_write_veneer(struct psa_invec *in_vec, size_t in_len, struct psa_outvec *out_vec, size_t out_len);
-psa_status_t tfm_sst_am_delete_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_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);
/******** 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 317032c..2a20e28 100644
--- a/interface/src/tfm_sst_api.c
+++ b/interface/src/tfm_sst_api.c
@@ -1,152 +1,105 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
-#include "tfm_sst_veneers.h"
-#include "tfm_sst_defs.h"
+#include "psa_protected_storage.h"
+
#include "tfm_ns_lock.h"
+#include "tfm_sst_defs.h"
+#include "tfm_sst_veneers.h"
-/* This define uses the TF-M invalid client ID to specify a direct client read,
- * as that it can not be used to identify a client.
- */
-#define SST_DIRECT_CLIENT_READ TFM_INVALID_CLIENT_ID
-
-enum psa_sst_err_t psa_sst_create(uint32_t asset_uuid, const uint8_t *token,
- uint32_t token_size)
+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)
{
- struct tfm_sst_token_t s_token;
+ enum tfm_sst_err_t err;
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
+ 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);
- return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_create,
- asset_uuid,
- (uint32_t)&s_token,
- 0, 0);
+ return TFM_SST_PSA_RETURN(err);
}
-enum psa_sst_err_t psa_sst_get_info(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- struct psa_sst_asset_info_t *info)
+psa_ps_status_t psa_ps_get(psa_ps_uid_t uid,
+ uint32_t data_offset,
+ uint32_t data_length,
+ void *p_data)
{
- struct tfm_sst_token_t s_token;
+ enum tfm_sst_err_t err;
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
+ 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);
- return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_get_info,
- asset_uuid,
- (uint32_t)&s_token,
- (uint32_t)info,
- 0);
+ return TFM_SST_PSA_RETURN(err);
}
-enum psa_sst_err_t psa_sst_get_attributes(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- struct psa_sst_asset_attrs_t *attrs)
+psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
{
- struct tfm_sst_token_t s_token;
+ enum tfm_sst_err_t err;
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
+ 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);
- return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_get_attributes,
- asset_uuid,
- (uint32_t)&s_token,
- (uint32_t)attrs,
- 0);
+ return TFM_SST_PSA_RETURN(err);
}
-enum psa_sst_err_t psa_sst_set_attributes(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- const struct psa_sst_asset_attrs_t *attrs)
+psa_ps_status_t psa_ps_remove(psa_ps_uid_t uid)
{
- struct tfm_sst_token_t s_token;
+ enum tfm_sst_err_t err;
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
+ err = tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_remove,
+ (uint32_t)&uid,
+ (uint32_t)0,
+ (uint32_t)0,
+ (uint32_t)0);
- return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_set_attributes,
- asset_uuid,
- (uint32_t)&s_token,
- (uint32_t)attrs,
- 0);
+ return TFM_SST_PSA_RETURN(err);
}
-enum psa_sst_err_t psa_sst_read(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- uint32_t size,
- uint32_t offset,
- uint8_t *data)
+psa_ps_status_t psa_ps_create(psa_ps_uid_t uid, uint32_t size,
+ psa_ps_create_flags_t create_flags)
{
- struct tfm_sst_token_t s_token;
- struct tfm_sst_buf_t s_data;
-
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
-
- /* Pack buffer information in the buffer structure */
- s_data.size = size;
- s_data.offset = offset;
- s_data.data = data;
-
- return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_read,
- SST_DIRECT_CLIENT_READ,
- asset_uuid,
- (uint32_t)&s_token,
- (uint32_t)&s_data);
+ (void)uid, (void)size, (void)create_flags;
+ return PSA_PS_ERROR_NOT_SUPPORTED;
}
-enum psa_sst_err_t psa_sst_write(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- uint32_t size,
- uint32_t offset,
- const uint8_t *data)
+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)
{
- struct tfm_sst_token_t s_token;
- struct tfm_sst_buf_t s_data;
-
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
-
- /* Pack buffer information in the buffer structure */
- s_data.size = size;
- s_data.offset = offset;
- s_data.data = (uint8_t *)data;
-
- return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_write,
- asset_uuid,
- (uint32_t)&s_token,
- (uint32_t)&s_data,
- 0);
+ (void)uid, (void)data_offset, (void)data_length, (void)p_data;
+ return PSA_PS_ERROR_NOT_SUPPORTED;
}
-enum psa_sst_err_t psa_sst_delete(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size)
+uint32_t psa_ps_get_support(void)
{
- struct tfm_sst_token_t s_token;
+ uint32_t support_flags;
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
+ /* Initialise support_flags to a sensible default, to avoid returning an
+ * uninitialised value in case the secure function fails.
+ */
+ support_flags = 0;
- return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_delete,
- asset_uuid,
- (uint32_t)&s_token,
- 0, 0);
+ /* 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);
+
+ return support_flags;
}
diff --git a/secure_fw/CMakeLists.txt b/secure_fw/CMakeLists.txt
index 4698911..16ec640 100644
--- a/secure_fw/CMakeLists.txt
+++ b/secure_fw/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+# Copyright (c) 2017-2019, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -142,16 +142,16 @@
embedded_set_target_compile_defines(TARGET ${PROJECT_OBJ_LIB} LANGUAGE C DEFINES __thumb2__ __ARM_FEATURE_CMSE=3 TFM_LVL=${TFM_LVL} DAUTH_CHIP_DEFAULT APPEND)
if (REGRESSION OR CORE_TEST)
- if (DEFINED TFM_PARTITION_TEST_SST AND TFM_PARTITION_TEST_SST)
+ if (DEFINED TFM_PARTITION_TEST_SECURE_SERVICES AND TFM_PARTITION_TEST_SECURE_SERVICES)
#The test service veneers in the tfm_secure_tests library may not be
#referenced in the secure binary so the veneer objects are explicitly loaded
#from the secure tests library. However by generating the veneer files from
#the manifests, all the iovec interfaced veneers are in a single file in the
#secure_fw directory. The core test partitions use the veneers with the
- #iovec API, so we only need the explicit load in case the SST test partition
- #is present.
- #FIXME Remove the explicit load and the above comment once the SST test
- #partition uses the generated veneers.
+ #iovec API, so we only need the explicit load in case the secure client test
+ #partition is present.
+ #FIXME Remove the explicit load and the above comment once the secure client
+ #test partition uses the generated veneers.
if(${COMPILER} STREQUAL "ARMCLANG")
target_link_libraries(${EXE_NAME} tfm_crypto tfm_storage tfm_audit tfm_platform tfm_attest $<TARGET_LINKER_FILE:tfm_secure_tests>\(*veneers.o\) tfm_secure_tests)
elseif(${COMPILER} STREQUAL "GNUARM")
diff --git a/secure_fw/ns_callable/tfm_sst_veneers.c b/secure_fw/ns_callable/tfm_sst_veneers.c
index 9c63e14..5348d5d 100644
--- a/secure_fw/ns_callable/tfm_sst_veneers.c
+++ b/secure_fw/ns_callable/tfm_sst_veneers.c
@@ -1,74 +1,54 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#include "tfm_sst_veneers.h"
-#include "secure_fw/services/secure_storage/sst_asset_management.h"
-#include "tfm_secure_api.h"
-#include "tfm_api.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 psa_sst_err_t tfm_sst_veneer_create(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token)
+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, sst_am_create,
- asset_uuid, s_token, 0, 0);
+ TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, tfm_sst_set,
+ uid, data_length, p_data, create_flags);
}
__tfm_secure_gateway_attributes__
-enum psa_sst_err_t tfm_sst_veneer_get_info(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct psa_sst_asset_info_t *info)
+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, sst_am_get_info,
- asset_uuid, s_token, info, 0);
+ TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, tfm_sst_get,
+ uid, data_offset, data_length, p_data);
}
__tfm_secure_gateway_attributes__
-enum psa_sst_err_t tfm_sst_veneer_get_attributes(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct psa_sst_asset_attrs_t *attrs)
+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, sst_am_get_attributes,
- asset_uuid, s_token, attrs, 0);
+ TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, tfm_sst_get_info,
+ uid, p_info, 0, 0);
}
__tfm_secure_gateway_attributes__
-enum psa_sst_err_t tfm_sst_veneer_set_attributes(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- const struct psa_sst_asset_attrs_t *attrs)
+enum tfm_sst_err_t tfm_sst_veneer_remove(const psa_ps_uid_t *uid)
{
- TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, sst_am_set_attributes,
- asset_uuid, s_token, attrs, 0);
+ TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, tfm_sst_remove,
+ uid, 0, 0, 0);
}
__tfm_secure_gateway_attributes__
-enum psa_sst_err_t tfm_sst_veneer_read(int32_t client_id,
- uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct tfm_sst_buf_t *data)
+enum tfm_sst_err_t tfm_sst_veneer_get_support(uint32_t *support_flags)
{
- TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, sst_am_read, client_id,
- asset_uuid, s_token, data);
-}
-
-__tfm_secure_gateway_attributes__
-enum psa_sst_err_t tfm_sst_veneer_write(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct tfm_sst_buf_t *data)
-{
- TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, sst_am_write,
- asset_uuid, s_token, data, 0);
-}
-
-__tfm_secure_gateway_attributes__
-enum psa_sst_err_t tfm_sst_veneer_delete(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token)
-{
- TFM_CORE_SFN_REQUEST(TFM_SP_STORAGE_ID, sst_am_delete,
- asset_uuid, s_token, 0, 0);
+ 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 30ef5f1..c3df282 100644
--- a/secure_fw/ns_callable/tfm_veneers.c
+++ b/secure_fw/ns_callable/tfm_veneers.c
@@ -12,13 +12,11 @@
#include "secure_fw/spm/spm_partition_defs.h"
/******** TFM_SP_STORAGE ********/
-psa_status_t sst_am_create(struct psa_invec *, size_t, struct psa_outvec *, size_t);
-psa_status_t sst_am_get_info(struct psa_invec *, size_t, struct psa_outvec *, size_t);
-psa_status_t sst_am_get_attributes(struct psa_invec *, size_t, struct psa_outvec *, size_t);
-psa_status_t sst_am_set_attributes(struct psa_invec *, size_t, struct psa_outvec *, size_t);
-psa_status_t sst_am_read(struct psa_invec *, size_t, struct psa_outvec *, size_t);
-psa_status_t sst_am_write(struct psa_invec *, size_t, struct psa_outvec *, size_t);
-psa_status_t sst_am_delete(struct psa_invec *, size_t, struct psa_outvec *, size_t);
+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);
/******** TFM_SP_AUDIT_LOG ********/
psa_status_t audit_core_retrieve_record(struct psa_invec *, size_t, struct psa_outvec *, size_t);
@@ -92,13 +90,11 @@
}
/******** TFM_SP_STORAGE ********/
-TFM_VENEER_FUNCTION(TFM_SP_STORAGE, sst_am_create)
-TFM_VENEER_FUNCTION(TFM_SP_STORAGE, sst_am_get_info)
-TFM_VENEER_FUNCTION(TFM_SP_STORAGE, sst_am_get_attributes)
-TFM_VENEER_FUNCTION(TFM_SP_STORAGE, sst_am_set_attributes)
-TFM_VENEER_FUNCTION(TFM_SP_STORAGE, sst_am_read)
-TFM_VENEER_FUNCTION(TFM_SP_STORAGE, sst_am_write)
-TFM_VENEER_FUNCTION(TFM_SP_STORAGE, sst_am_delete)
+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_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 a822e08..cc424aa 100644
--- a/secure_fw/services/secure_storage/CMakeLists.inc
+++ b/secure_fw/services/secure_storage/CMakeLists.inc
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+# Copyright (c) 2017-2019, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -61,21 +61,21 @@
set (SECURE_STORAGE_C_SRC
"${SECURE_STORAGE_DIR}/tfm_sst_secure_api.c"
- "${SECURE_STORAGE_DIR}/sst_asset_management.c"
- "${SECURE_STORAGE_DIR}/sst_object_system.c"
- "${SECURE_STORAGE_DIR}/sst_object_table.c"
- "${SECURE_STORAGE_DIR}/sst_utils.c"
- "${SECURE_STORAGE_DIR}/assets/sst_asset_defs.c"
- "${SECURE_STORAGE_DIR}/flash/sst_flash.c"
- "${SECURE_STORAGE_DIR}/flash_fs/sst_flash_fs.c"
- "${SECURE_STORAGE_DIR}/flash_fs/sst_flash_fs_dblock.c"
- "${SECURE_STORAGE_DIR}/flash_fs/sst_flash_fs_mblock.c")
+ "${SECURE_STORAGE_DIR}/tfm_protected_storage.c"
+ # "${SECURE_STORAGE_DIR}/sst_object_system.c"
+ # "${SECURE_STORAGE_DIR}/sst_object_table.c"
+ # "${SECURE_STORAGE_DIR}/sst_utils.c"
+ # "${SECURE_STORAGE_DIR}/flash/sst_flash.c"
+ # "${SECURE_STORAGE_DIR}/flash_fs/sst_flash_fs.c"
+ # "${SECURE_STORAGE_DIR}/flash_fs/sst_flash_fs_dblock.c"
+ # "${SECURE_STORAGE_DIR}/flash_fs/sst_flash_fs_mblock.c"
+ )
if (SST_ENCRYPTION)
- list(APPEND SECURE_STORAGE_C_SRC
- "${SECURE_STORAGE_DIR}/crypto/sst_crypto_interface.c"
- "${SECURE_STORAGE_DIR}/sst_encrypted_object.c"
- )
+ # list(APPEND SECURE_STORAGE_C_SRC
+ # "${SECURE_STORAGE_DIR}/crypto/sst_crypto_interface.c"
+ # "${SECURE_STORAGE_DIR}/sst_encrypted_object.c"
+ # )
set_property(SOURCE ${SECURE_STORAGE_C_SRC} APPEND PROPERTY COMPILE_DEFINITIONS SST_ENCRYPTION)
set_property(DIRECTORY ${TEST_DIR} APPEND PROPERTY COMPILE_DEFINITIONS SST_ENCRYPTION)
@@ -83,8 +83,8 @@
if (NOT REGRESSION OR TFM_LVL GREATER 1)
# In case of regression test executed in TFM level 1, the SST rollback test suite has
# its own implementation of sst_nv_counters intefaces to be able to test different scenarios.
- list (APPEND SECURE_STORAGE_C_SRC
- "${SECURE_STORAGE_DIR}/nv_counters/sst_nv_counters.c")
+ # list (APPEND SECURE_STORAGE_C_SRC
+ # "${SECURE_STORAGE_DIR}/nv_counters/sst_nv_counters.c")
endif()
set_property(SOURCE ${SECURE_STORAGE_C_SRC} APPEND PROPERTY COMPILE_DEFINITIONS SST_ROLLBACK_PROTECTION)
endif()
diff --git a/secure_fw/services/secure_storage/assets/sst_asset_defs.c b/secure_fw/services/secure_storage/assets/sst_asset_defs.c
deleted file mode 100644
index 32e2b3e..0000000
--- a/secure_fw/services/secure_storage/assets/sst_asset_defs.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-/**********************************************/
-/* Automatically-generated file. Do not edit! */
-/**********************************************/
-
-#include "sst_asset_defs.h"
-#include "secure_fw/services/secure_storage/sst_asset_management.h"
-
-const struct sst_asset_policy_t asset_perms[] = {
-{
- .type = PSA_SST_ASSET_KEY_AES,
- .asset_uuid = SST_ASSET_ID_AES_KEY_128,
- .max_size = SST_ASSET_MAX_SIZE_AES_KEY_128,
- .perms_count = 1,
- .perms_modes_start_idx = 0,
-},{
- .type = PSA_SST_ASSET_KEY_AES,
- .asset_uuid = SST_ASSET_ID_AES_KEY_192,
- .max_size = SST_ASSET_MAX_SIZE_AES_KEY_192,
- .perms_count = 3,
- .perms_modes_start_idx = 1,
-},{
- .type = PSA_SST_ASSET_KEY_AES,
- .asset_uuid = SST_ASSET_ID_AES_KEY_256,
- .max_size = SST_ASSET_MAX_SIZE_AES_KEY_256,
- .perms_count = 1,
- .perms_modes_start_idx = 4,
-},{
- .type = PSA_SST_ASSET_KEY_RSA_PUBLIC,
- .asset_uuid = SST_ASSET_ID_RSA_KEY_1024,
- .max_size = SST_ASSET_MAX_SIZE_RSA_KEY_1024,
- .perms_count = 1,
- .perms_modes_start_idx = 5,
-},{
- .type = PSA_SST_ASSET_KEY_RSA_PUBLIC,
- .asset_uuid = SST_ASSET_ID_RSA_KEY_2048,
- .max_size = SST_ASSET_MAX_SIZE_RSA_KEY_2048,
- .perms_count = 1,
- .perms_modes_start_idx = 6,
-},{
- .type = PSA_SST_ASSET_KEY_RSA_PRIVATE,
- .asset_uuid = SST_ASSET_ID_RSA_KEY_4096,
- .max_size = SST_ASSET_MAX_SIZE_RSA_KEY_4096,
- .perms_count = 1,
- .perms_modes_start_idx = 7,
-},{
- .type = PSA_SST_ASSET_CERT_X_509,
- .asset_uuid = SST_ASSET_ID_X509_CERT_SMALL,
- .max_size = SST_ASSET_MAX_SIZE_X509_CERT_SMALL,
- .perms_count = 1,
- .perms_modes_start_idx = 8,
-},{
- .type = PSA_SST_ASSET_CERT_X_509,
- .asset_uuid = SST_ASSET_ID_X509_CERT_LARGE,
- .max_size = SST_ASSET_MAX_SIZE_X509_CERT_LARGE,
- .perms_count = 3,
- .perms_modes_start_idx = 9,
-},{
- .type = PSA_SST_ASSET_KEY_HMAC,
- .asset_uuid = SST_ASSET_ID_SHA224_HASH,
- .max_size = SST_ASSET_MAX_SIZE_SHA224_HASH,
- .perms_count = 1,
- .perms_modes_start_idx = 12,
-},{
- .type = PSA_SST_ASSET_KEY_HMAC,
- .asset_uuid = SST_ASSET_ID_SHA384_HASH,
- .max_size = SST_ASSET_MAX_SIZE_SHA384_HASH,
- .perms_count = 1,
- .perms_modes_start_idx = 13,
-} };
-
-const struct sst_asset_perm_t asset_perms_modes[] = {
-{
- .client_id = SST_CLIENT_ID_3,
- .perm = SST_PERM_REFERENCE,
-},{
- .client_id = SST_CLIENT_ID_2,
- .perm = SST_PERM_REFERENCE,
-},{
- .client_id = SST_CLIENT_ID_1,
- .perm = SST_PERM_REFERENCE | SST_PERM_READ,
-},{
- .client_id = SST_CLIENT_ID_0,
- .perm = SST_PERM_REFERENCE | SST_PERM_READ | SST_PERM_WRITE,
-},{
- .client_id = SST_CLIENT_ID_3,
- .perm = SST_PERM_REFERENCE | SST_PERM_READ | SST_PERM_WRITE,
-},{
- .client_id = SST_CLIENT_ID_3,
- .perm = SST_PERM_REFERENCE | SST_PERM_READ | SST_PERM_WRITE,
-},{
- .client_id = SST_CLIENT_ID_3,
- .perm = SST_PERM_REFERENCE | SST_PERM_READ | SST_PERM_WRITE,
-},{
- .client_id = SST_CLIENT_ID_3,
- .perm = SST_PERM_REFERENCE | SST_PERM_READ | SST_PERM_WRITE,
-},{
- .client_id = SST_CLIENT_ID_3,
- .perm = SST_PERM_REFERENCE | SST_PERM_READ | SST_PERM_WRITE,
-},{
- .client_id = SST_CLIENT_ID_2,
- .perm = SST_PERM_REFERENCE,
-},{
- .client_id = SST_CLIENT_ID_1,
- .perm = SST_PERM_REFERENCE | SST_PERM_READ,
-},{
- .client_id = SST_CLIENT_ID_0,
- .perm = SST_PERM_REFERENCE | SST_PERM_READ | SST_PERM_WRITE,
-},{
- .client_id = SST_CLIENT_ID_1,
- .perm = SST_PERM_REFERENCE | SST_PERM_READ | SST_PERM_WRITE,
-},{
- .client_id = SST_CLIENT_ID_0,
- .perm = SST_PERM_REFERENCE | SST_PERM_WRITE,
-} };
diff --git a/secure_fw/services/secure_storage/assets/sst_asset_defs.h b/secure_fw/services/secure_storage/assets/sst_asset_defs.h
deleted file mode 100644
index 147aa46..0000000
--- a/secure_fw/services/secure_storage/assets/sst_asset_defs.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-/**********************************************/
-/* Automatically-generated file. Do not edit! */
-/**********************************************/
-
-#ifndef __SST_ASSET_DEFS_H__
-#define __SST_ASSET_DEFS_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* SST service reserved IDs */
-#define SST_ASSET_ID_NO_ASSET 0
-/* End SST service reserved IDs */
-
-/* Asset IDs */
-#define SST_ASSET_ID_AES_KEY_128 1
-#define SST_ASSET_ID_AES_KEY_192 2
-#define SST_ASSET_ID_AES_KEY_256 3
-#define SST_ASSET_ID_RSA_KEY_1024 4
-#define SST_ASSET_ID_RSA_KEY_2048 5
-#define SST_ASSET_ID_RSA_KEY_4096 6
-#define SST_ASSET_ID_X509_CERT_SMALL 7
-#define SST_ASSET_ID_X509_CERT_LARGE 8
-#define SST_ASSET_ID_SHA224_HASH 9
-#define SST_ASSET_ID_SHA384_HASH 10
-
-/* Asset sizes */
-#define SST_ASSET_MAX_SIZE_AES_KEY_128 16
-#define SST_ASSET_MAX_SIZE_AES_KEY_192 24
-#define SST_ASSET_MAX_SIZE_AES_KEY_256 32
-#define SST_ASSET_MAX_SIZE_RSA_KEY_1024 128
-#define SST_ASSET_MAX_SIZE_RSA_KEY_2048 256
-#define SST_ASSET_MAX_SIZE_RSA_KEY_4096 512
-#define SST_ASSET_MAX_SIZE_X509_CERT_SMALL 512
-#define SST_ASSET_MAX_SIZE_X509_CERT_LARGE 2048
-#define SST_ASSET_MAX_SIZE_SHA224_HASH 28
-#define SST_ASSET_MAX_SIZE_SHA384_HASH 48
-
-/* Client IDs which have access rights in one or more assets */
-#define SST_CLIENT_ID_0 -1
-#define SST_CLIENT_ID_1 -2
-#define SST_CLIENT_ID_2 -3
-#define SST_CLIENT_ID_3 -4
-
-/* Number of assets that can be stored in SST area */
-#define SST_NUM_ASSETS 10
-
-/* Largest defined asset size */
-#define SST_MAX_ASSET_SIZE 2048
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SST_ASSET_DEFS_H__ */
diff --git a/secure_fw/services/secure_storage/manifest.yaml b/secure_fw/services/secure_storage/manifest.yaml
index 3b1708a..f6f63c1 100644
--- a/secure_fw/services/secure_storage/manifest.yaml
+++ b/secure_fw/services/secure_storage/manifest.yaml
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2018, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -15,71 +15,55 @@
"entry_point": "main",
"stack_size": "0x2000",
"heap_size": "0x0400",
- "tfm_init_symbol": "sst_am_prepare",
+ "tfm_init_symbol": "tfm_sst_init",
"secure_functions": [
{
- "sfid": "SST_AM_CREATE_SFID",
- "signal": "SST_AM_CREATE",
- "tfm_symbol": "sst_am_create",
+ "sfid": "TFM_SST_SET_SFID",
+ "signal": "TFM_SST_SET",
+ "tfm_symbol": "tfm_sst_set",
"non_secure_clients": true,
"minor_version": 1,
"minor_policy": "strict"
},
{
- "sfid": "SST_AM_GET_INFO_SFID",
- "signal": "SST_AM_GET_INFO",
- "tfm_symbol": "sst_am_get_info",
+ "sfid": "TFM_SST_GET_SFID",
+ "signal": "TFM_SST_GET",
+ "tfm_symbol": "tfm_sst_get",
"non_secure_clients": true,
"minor_version": 1,
"minor_policy": "strict"
},
{
- "sfid": "SST_AM_GET_ATTRIBUTES_SFID",
- "signal": "SST_AM_GET_ATTRIBUTES",
- "tfm_symbol": "sst_am_get_attributes",
+ "sfid": "TFM_SST_GET_INFO_SFID",
+ "signal": "TFM_SST_GET_INFO",
+ "tfm_symbol": "tfm_sst_get_info",
"non_secure_clients": true,
"minor_version": 1,
"minor_policy": "strict"
},
{
- "sfid": "SST_AM_SET_ATTRIBUTES_SFID",
- "signal": "SST_AM_SET_ATTRIBUTES",
- "tfm_symbol": "sst_am_set_attributes",
+ "sfid": "TFM_SST_REMOVE_SFID",
+ "signal": "TFM_SST_REMOVE",
+ "tfm_symbol": "tfm_sst_remove",
"non_secure_clients": true,
"minor_version": 1,
"minor_policy": "strict"
},
{
- "sfid": "SST_AM_READ_SFID",
- "signal": "SST_AM_READ",
- "tfm_symbol": "sst_am_read",
- "non_secure_clients": true,
- "minor_version": 1,
- "minor_policy": "strict"
- },
- {
- "sfid": "SST_AM_WRITE_SFID",
- "signal": "SST_AM_WRITE",
- "tfm_symbol": "sst_am_write",
- "non_secure_clients": true,
- "minor_version": 1,
- "minor_policy": "strict"
- },
- {
- "sfid": "SST_AM_DELETE_SFID",
- "signal": "SST_AM_DELETE",
- "tfm_symbol": "sst_am_delete",
+ "sfid": "TFM_SST_GET_SUPPORT_SFID",
+ "signal": "TFM_SST_GET_SUPPORT",
+ "tfm_symbol": "tfm_sst_get_support",
"non_secure_clients": true,
"minor_version": 1,
"minor_policy": "strict"
}
],
"source_files": [
- "sst_utils.c",
"sst_encrypted_object.c",
"sst_object_system.c",
- "sst_asset_management.c",
- "assets/sst_asset_defs.c",
+ "sst_object_table.c",
+ "sst_utils.c",
+ "tfm_protected_storage.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_asset_management.c b/secure_fw/services/secure_storage/sst_asset_management.c
deleted file mode 100644
index e811817..0000000
--- a/secure_fw/services/secure_storage/sst_asset_management.c
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#include "sst_asset_management.h"
-
-#include <stddef.h>
-
-#include "assets/sst_asset_defs.h"
-#include "sst_object_system.h"
-#include "sst_utils.h"
-#include "tfm_secure_api.h"
-#include "tfm_sst_defs.h"
-
-/******************************/
-/* Asset management functions */
-/******************************/
-
-/* Policy database */
-extern struct sst_asset_policy_t asset_perms[];
-extern struct sst_asset_perm_t asset_perms_modes[];
-
-/**
- * \brief Looks up for policy entry for give client and uuid
- *
- * \param[in] db_entry Asset specific entry
- * \param[in] client_id Identify of the client calling the service
- *
- * \return Returns the perms entry on successful lookup
- */
-static struct sst_asset_perm_t *sst_am_lookup_client_perms(
- const struct sst_asset_policy_t *db_entry,
- int32_t client_id)
-{
- struct sst_asset_perm_t *perm_entry;
- uint32_t i;
-
- for (i = 0; i < db_entry->perms_count; i++) {
- perm_entry = &asset_perms_modes[db_entry->perms_modes_start_idx+i];
- if (perm_entry->client_id == client_id) {
- return perm_entry;
- }
- }
-
- return NULL;
-}
-
-/**
- * \brief Gets pointer to policy entry for an asset
- *
- * \param[in] uuid Unique identifier of the object being accessed
- *
- * \return Returns the pointer for entry for specified asset
- */
-static struct sst_asset_policy_t *sst_am_lookup_db_entry(uint32_t uuid)
-{
- uint32_t i;
-
- /* Lookup in db for matching entry */
- for (i = 0; i < SST_NUM_ASSETS; i++) {
- if (asset_perms[i].asset_uuid == uuid) {
- return &asset_perms[i];
- }
- }
-
- return NULL;
-}
-
-/**
- * \brief Checks the compile time policy for secure/non-secure separation
- *
- * \param[in] client_id Client ID
- * \param[in] request_type requested action to perform
- *
- * \return Returns the sanitized request_type
- */
-static uint16_t sst_am_check_s_ns_policy(int32_t client_id,
- uint16_t request_type)
-{
- enum psa_sst_err_t err;
- uint16_t access;
-
- /* FIXME: based on level 1 tfm isolation, any entity on the secure side
- * can have full access if it uses secure client ID to make the call.
- * When the secure caller passes on the client_id of non-secure entity,
- * the code only allows read by reference. I.e. if the client_id
- * has the reference permission, the secure caller will be allowed
- * to read the entry. This needs a revisit when for higher level
- * of isolation.
- *
- * FIXME: current code allows only a referenced read, however there
- * is a case for refereced create/write/delete as well, for example
- * a NS entity may ask another secure service to derive a key and securely
- * store it, and make references for encryption/decryption and later on
- * delete it.
- * For now it is for the other secure service to create/delete/write
- * resources with the secure client ID.
- */
- err = sst_utils_validate_secure_caller();
-
- if (err == PSA_SST_ERR_SUCCESS) {
- if (TFM_CLIENT_ID_IS_S(client_id) == 0) {
- if (request_type & SST_PERM_REFERENCE) {
- access = SST_PERM_REFERENCE;
- } else {
- /* Other permissions can not be delegated */
- access = SST_PERM_FORBIDDEN;
- }
- } else {
- /* a call from secure entity on it's own behalf.
- * In level 1 isolation, any secure entity has
- * full access to storage.
- */
- access = SST_PERM_BYPASS;
- }
- } else if (TFM_CLIENT_ID_IS_S(client_id) == 1) {
- /* non secure caller spoofing as secure caller */
- access = SST_PERM_FORBIDDEN;
- } else {
- access = request_type;
- }
- return access;
-}
-
-/**
- * \brief Gets asset's permissions if the client is allowed
- * based on the request_type
- *
- * \param[in] client_id Client ID
- * \param[in] uuid Asset's unique identifier
- * \param[in] request_type Type of requested access
- *
- * \note If request_type contains multiple permissions, this function
- * returns the entry pointer for specified asset if at least one
- * of those permissions match.
- *
- * \return Returns the entry pointer for specified asset
- */
-static struct sst_asset_policy_t *sst_am_get_db_entry(int32_t client_id,
- uint32_t uuid,
- uint8_t request_type)
-{
- struct sst_asset_perm_t *perm_entry;
- struct sst_asset_policy_t *db_entry;
-
- request_type = sst_am_check_s_ns_policy(client_id, request_type);
-
- /* security access violation */
- if (request_type == SST_PERM_FORBIDDEN) {
- /* FIXME: this is prone to timing attacks. Ideally the time
- * spent in this function should always be constant irrespective
- * of success or failure of checks. Timing attacks will be
- * addressed in later version.
- */
- return NULL;
- }
-
- /* Find policy db entry for the the asset */
- db_entry = sst_am_lookup_db_entry(uuid);
- if (db_entry == NULL) {
- return NULL;
- }
-
- if (request_type == SST_PERM_BYPASS) {
- return db_entry;
- }
-
- /* Find the client ID entry in the database */
- perm_entry = sst_am_lookup_client_perms(db_entry, client_id);
- if (perm_entry == NULL) {
- return NULL;
- }
-
- /* Check if the db permission matches with at least one of the
- * requested permissions types.
- */
- if ((perm_entry->perm & request_type) != 0) {
- return db_entry;
- }
- return NULL;
-}
-
-/**
- * \brief Validates the policy database's integrity
- * Stub function.
- *
- * \return Returns value specified in \ref psa_sst_err_t
- */
-static enum psa_sst_err_t validate_policy_db(void)
-{
- /* Currently the policy database is inbuilt
- * in the code. It's sanity is assumed to be correct.
- * In the later revisions if access policy is
- * stored differently, it may require sanity check
- * as well.
- */
- return PSA_SST_ERR_SUCCESS;
-}
-
-enum psa_sst_err_t sst_am_prepare(void)
-{
- enum psa_sst_err_t err;
- /* FIXME: outcome of this function should determine
- * state machine of asset manager. If this
- * step fails other APIs shouldn't entertain
- * any user calls. Not a major issue for now
- * as policy db check is a dummy function, and
- * sst core maintains it's own state machine.
- */
-
- /* Validate policy database */
- err = validate_policy_db();
-
- /* Initialize underlying storage system */
- if (err != PSA_SST_ERR_SUCCESS) {
- return PSA_SST_ERR_SYSTEM_ERROR;
- }
-
- err = sst_system_prepare();
-#ifdef SST_CREATE_FLASH_LAYOUT
- /* If SST_CREATE_FLASH_LAYOUT is set, it indicates that it is required to
- * create a SST flash layout. SST service will generate an empty and valid
- * SST flash layout to store assets. It will erase all data located in the
- * assigned SST memory area before generating the SST layout.
- * This flag is required to be set if the SST memory area is located in a
- * non-persistent memory.
- * This flag can be set if the SST memory area is located in a persistent
- * memory without a previous valid SST flash layout in it. That is the case
- * when it is the first time in the device life that the SST service is
- * executed.
- */
- if (err != PSA_SST_ERR_SUCCESS) {
- /* Remove all data in the SST memory area and creates a valid SST flash
- * layout in that area.
- */
- sst_system_wipe_all();
-
- /* Attempt to initialise again */
- err = sst_system_prepare();
- }
-#endif /* SST_CREATE_FLASH_LAYOUT */
-
- return err;
-}
-
-/**
- * \brief Validate incoming iovec structure
- *
- * \param[in] src Incoming iovec for the read/write request
- * \param[in] dest Pointer to local copy of the iovec
- * \param[in] client_id Client ID of the caller
- * \param[in] access Access type to be permormed on the given dest->data
- * address
- *
- * \return Returns value specified in \ref psa_sst_err_t
- */
-static enum psa_sst_err_t validate_copy_validate_iovec(
- const struct tfm_sst_buf_t *src,
- struct tfm_sst_buf_t *dest,
- int32_t client_id,
- uint32_t access)
-{
- /* iovec struct needs to be used as veneers do not allow
- * more than four params.
- * First validate the pointer for iovec itself, then copy
- * the iovec, then validate the local copy of iovec.
- */
- enum psa_sst_err_t bound_check;
-
- bound_check = sst_utils_bound_check_and_copy((uint8_t *) src,
- (uint8_t *) dest,
- sizeof(struct tfm_sst_buf_t),
- client_id);
- if (bound_check == PSA_SST_ERR_SUCCESS) {
- bound_check = sst_utils_memory_bound_check(dest->data, dest->size,
- client_id, access);
- }
-
- return bound_check;
-}
-
-enum psa_sst_err_t sst_am_get_info(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct psa_sst_asset_info_t *info)
-{
- enum psa_sst_err_t bound_check;
- struct sst_asset_policy_t *db_entry;
- struct psa_sst_asset_info_t tmp_info;
- enum psa_sst_err_t err;
- uint8_t all_perms = SST_PERM_REFERENCE | SST_PERM_READ | SST_PERM_WRITE;
- int32_t client_id;
-
- if (tfm_core_get_caller_client_id(&client_id) != TFM_SUCCESS) {
- return PSA_SST_ERR_SYSTEM_ERROR;
- }
-
- bound_check = sst_utils_memory_bound_check(info, PSA_SST_ASSET_INFO_SIZE,
- client_id,
- TFM_MEMORY_ACCESS_RW);
- if (bound_check != PSA_SST_ERR_SUCCESS) {
- return PSA_SST_ERR_PARAM_ERROR;
- }
-
- db_entry = sst_am_get_db_entry(client_id, asset_uuid, all_perms);
- if (db_entry == NULL) {
- return PSA_SST_ERR_ASSET_NOT_FOUND;
- }
-
- err = sst_object_get_info(asset_uuid, s_token, &tmp_info);
- if (err == PSA_SST_ERR_SUCCESS) {
- /* Use tmp_info to not leak information in case the previous function
- * returns and error. It avoids to leak information in case of error.
- * So, copy the tmp_info content into the attrs only if that tmp_info
- * data is valid.
- */
- sst_utils_memcpy(info, &tmp_info, PSA_SST_ASSET_INFO_SIZE);
- }
-
- return err;
-}
-
-enum psa_sst_err_t sst_am_get_attributes(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct psa_sst_asset_attrs_t *attrs)
-{
- uint8_t all_perms = SST_PERM_REFERENCE | SST_PERM_READ | SST_PERM_WRITE;
- enum psa_sst_err_t bound_check;
- struct sst_asset_policy_t *db_entry;
- enum psa_sst_err_t err;
- struct psa_sst_asset_attrs_t tmp_attrs;
- int32_t client_id;
-
- if (tfm_core_get_caller_client_id(&client_id) != TFM_SUCCESS) {
- return PSA_SST_ERR_SYSTEM_ERROR;
- }
-
- bound_check = sst_utils_memory_bound_check(attrs, PSA_SST_ASSET_ATTR_SIZE,
- client_id,
- TFM_MEMORY_ACCESS_RW);
- if (bound_check != PSA_SST_ERR_SUCCESS) {
- return PSA_SST_ERR_PARAM_ERROR;
- }
-
- db_entry = sst_am_get_db_entry(client_id, asset_uuid, all_perms);
- if (db_entry == NULL) {
- return PSA_SST_ERR_ASSET_NOT_FOUND;
- }
-
- err = sst_object_get_attributes(asset_uuid, s_token, &tmp_attrs);
- if (err == PSA_SST_ERR_SUCCESS) {
- /* Use tmp_attrs to not leak information incase the previous function
- * returns and error. It avoids to leak information in case of error.
- * So, copy the tmp_attrs content into the attrs only if that tmp_attrs
- * data is valid.
- */
- sst_utils_memcpy(attrs, &tmp_attrs, PSA_SST_ASSET_ATTR_SIZE);
- }
-
- return err;
-}
-
-enum psa_sst_err_t sst_am_set_attributes(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- const struct psa_sst_asset_attrs_t *attrs)
-{
- uint8_t all_perms = SST_PERM_REFERENCE | SST_PERM_READ | SST_PERM_WRITE;
- enum psa_sst_err_t bound_check;
- struct sst_asset_policy_t *db_entry;
- enum psa_sst_err_t err;
- int32_t client_id;
-
- if (tfm_core_get_caller_client_id(&client_id) != TFM_SUCCESS) {
- return PSA_SST_ERR_SYSTEM_ERROR;
- }
-
- bound_check = sst_utils_memory_bound_check((uint8_t *)attrs,
- PSA_SST_ASSET_ATTR_SIZE,
- client_id,
- TFM_MEMORY_ACCESS_RO);
- if (bound_check != PSA_SST_ERR_SUCCESS) {
- return PSA_SST_ERR_PARAM_ERROR;
- }
-
- db_entry = sst_am_get_db_entry(client_id, asset_uuid, all_perms);
- if (db_entry == NULL) {
- return PSA_SST_ERR_ASSET_NOT_FOUND;
- }
-
- /* FIXME: Validity attributes are not supported in the current service
- * implementation. It is mandatory to set start and end subattributes
- * to 0.
- */
- if (attrs->validity.start != 0 || attrs->validity.end != 0) {
- return PSA_SST_ERR_PARAM_ERROR;
- }
-
- /* FIXME: Check which bit attributes have been changed and check if those
- * can be modified or not.
- */
- err = sst_object_set_attributes(asset_uuid, s_token, attrs);
-
- return err;
-}
-
-enum psa_sst_err_t sst_am_create(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token)
-{
- enum psa_sst_err_t err;
- struct sst_asset_policy_t *db_entry;
- int32_t client_id;
-
- if (tfm_core_get_caller_client_id(&client_id) != TFM_SUCCESS) {
- return PSA_SST_ERR_SYSTEM_ERROR;
- }
-
- db_entry = sst_am_get_db_entry(client_id, asset_uuid, SST_PERM_WRITE);
- if (db_entry == NULL) {
- return PSA_SST_ERR_ASSET_NOT_FOUND;
- }
-
- err = sst_object_create(asset_uuid, s_token, db_entry->type,
- db_entry->max_size);
-
- return err;
-}
-
-enum psa_sst_err_t sst_am_read(int32_t client_id, uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct tfm_sst_buf_t *data)
-{
- int32_t caller_id;
- struct sst_asset_policy_t *db_entry;
- enum psa_sst_err_t err;
- struct tfm_sst_buf_t local_data;
-
- /* Check if it is a read by reference request */
- if (client_id != SST_DIRECT_CLIENT_READ) {
- /* Only secure partitions can request it */
- if (sst_utils_validate_secure_caller() == PSA_SST_ERR_SUCCESS) {
- /* Reference read access requested, check if the client has
- * reference permission, otherwise reject the request.
- */
- db_entry = sst_am_get_db_entry(client_id, asset_uuid,
- SST_PERM_REFERENCE);
- if (db_entry == NULL) {
- return PSA_SST_ERR_ASSET_NOT_FOUND;
- }
- } else {
- /* A non-secure caller is not allowed to specify any client ID to
- * request a read by reference.
- */
- return PSA_SST_ERR_ASSET_NOT_FOUND;
- }
- }
-
- if (tfm_core_get_caller_client_id(&caller_id) != TFM_SUCCESS) {
- return PSA_SST_ERR_SYSTEM_ERROR;
- }
-
- /* Check client ID permissions */
- db_entry = sst_am_get_db_entry(caller_id, asset_uuid, SST_PERM_READ);
- if (db_entry == NULL) {
- return PSA_SST_ERR_ASSET_NOT_FOUND;
- }
-
- /* Make a local copy of the iovec data structure */
- err = validate_copy_validate_iovec(data, &local_data,
- caller_id, TFM_MEMORY_ACCESS_RW);
- if (err != PSA_SST_ERR_SUCCESS) {
- return PSA_SST_ERR_ASSET_NOT_FOUND;
- }
-
-#ifndef SST_ENABLE_PARTIAL_ASSET_RW
- if (data->offset != 0) {
- return PSA_SST_ERR_PARAM_ERROR;
- }
-#endif
-
- err = sst_object_read(asset_uuid, s_token, local_data.data,
- local_data.offset, local_data.size);
-
- return err;
-}
-
-enum psa_sst_err_t sst_am_write(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- const struct tfm_sst_buf_t *data)
-{
- struct tfm_sst_buf_t local_data;
- enum psa_sst_err_t err;
- struct sst_asset_policy_t *db_entry;
- int32_t client_id;
-
- if (tfm_core_get_caller_client_id(&client_id) != TFM_SUCCESS) {
- return PSA_SST_ERR_SYSTEM_ERROR;
- }
-
- /* Check client ID permissions */
- db_entry = sst_am_get_db_entry(client_id, asset_uuid, SST_PERM_WRITE);
- if (db_entry == NULL) {
- return PSA_SST_ERR_ASSET_NOT_FOUND;
- }
-
- /* Make a local copy of the iovec data structure */
- err = validate_copy_validate_iovec(data, &local_data,
- client_id, TFM_MEMORY_ACCESS_RO);
- if (err != PSA_SST_ERR_SUCCESS) {
- return PSA_SST_ERR_ASSET_NOT_FOUND;
- }
-
- /* Boundary check the incoming request */
- err = sst_utils_check_contained_in(0, db_entry->max_size,
- local_data.offset, local_data.size);
-
- if (err != PSA_SST_ERR_SUCCESS) {
- return err;
- }
-
-#ifndef SST_ENABLE_PARTIAL_ASSET_RW
- if (data->offset != 0) {
- return PSA_SST_ERR_PARAM_ERROR;
- }
-#endif
-
- err = sst_object_write(asset_uuid, s_token, local_data.data,
- local_data.offset, local_data.size);
-
- return err;
-}
-
-enum psa_sst_err_t sst_am_delete(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token)
-{
- enum psa_sst_err_t err;
- struct sst_asset_policy_t *db_entry;
- int32_t client_id;
-
- if (tfm_core_get_caller_client_id(&client_id) != TFM_SUCCESS) {
- return PSA_SST_ERR_SYSTEM_ERROR;
- }
-
- db_entry = sst_am_get_db_entry(client_id, asset_uuid, SST_PERM_WRITE);
- if (db_entry == NULL) {
- return PSA_SST_ERR_ASSET_NOT_FOUND;
- }
-
- err = sst_object_delete(asset_uuid, s_token);
-
- return err;
-}
diff --git a/secure_fw/services/secure_storage/sst_asset_management.h b/secure_fw/services/secure_storage/sst_asset_management.h
deleted file mode 100644
index 6967c2f..0000000
--- a/secure_fw/services/secure_storage/sst_asset_management.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __SST_ASSET_MANAGEMENT_H__
-#define __SST_ASSET_MANAGEMENT_H__
-
-#include <stdint.h>
-#include "tfm_sst_defs.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* This define uses the TF-M invalid client ID to specify a direct client read,
- * as that it can not be used to identify a client.
- */
-#define SST_DIRECT_CLIENT_READ TFM_INVALID_CLIENT_ID
-
-#define SST_PERM_BYPASS (1<<3) /*!< Permission check bypassed. Used when
- * secure a secure entity calls as itself
- * (and not on behalf of another NS client)
- */
-#define SST_PERM_READ (1<<2) /*!< Client can read this asset */
-#define SST_PERM_WRITE (1<<1) /*!< Client can write to this asset */
-#define SST_PERM_REFERENCE (1) /*!< Client can access this value's meta */
-#define SST_PERM_FORBIDDEN (0) /*!< Used when a security
- * violation detected
- */
-
-struct sst_asset_perm_t {
- int32_t client_id; /*!< Client ID */
- uint8_t perm; /*!< Permissions bitfield */
-};
-
-struct sst_asset_policy_t {
- uint32_t type; /*!< Asset type */
- uint16_t asset_uuid; /*!< Asset's unique ID */
- uint16_t perms_count; /*!< Number of permissions owned by this asset */
- uint16_t max_size; /*!< Policy maximum size fo this asset */
- uint16_t perms_modes_start_idx; /*!< First permission index */
-};
-
-/**
- * \brief Initializes the secure storage system
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t sst_am_prepare(void);
-
-/**
- * \brief Allocates space for the asset, referenced by asset UUID,
- * without setting any data in the asset.
- *
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- * \param[in] asset_uuid Asset UUID
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t sst_am_create(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token);
-
-/**
- * \brief Gets the asset's info referenced by asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- * \param[out] info Pointer to store the asset's information
- * \ref psa_sst_asset_info_t
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t sst_am_get_info(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct psa_sst_asset_info_t *info);
-
-/**
- * \brief Gets the asset's attributes referenced by asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- * \param[out] attrs Pointer to store the asset's attributes
- * \ref psa_sst_asset_attrs_t
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t sst_am_get_attributes(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct psa_sst_asset_attrs_t *attrs);
-
-/**
- * \brief Sets the asset's attributes referenced by asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- * \param[in] attrs Pointer to new the asset's attributes
- * \ref psa_sst_asset_attrs_t
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t sst_am_set_attributes(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- const struct psa_sst_asset_attrs_t *attrs);
-
-/**
- * \brief Reads asset's data referenced by asset UUID.
- *
- * \param[in] client_id In case, the caller is a secure partition, this
- * parameter can be a non-secure or secure client ID if
- * the read is in behalf of that client.
- * Otherwise, it must be 0.
- * \param[in] asset_uuid Asset UUID
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- * \param[out] data Pointer to data vector \ref tfm_sst_buf_t to store
- * data, size and offset
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t sst_am_read(int32_t client_id, uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- struct tfm_sst_buf_t *data);
-
-/**
- * \brief Writes data into an asset referenced by asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- * \param[in] data Pointer to data vector \ref tfm_sst_buf_t which
- * contains the data to write
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t sst_am_write(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token,
- const struct tfm_sst_buf_t *data);
-
-/**
- * \brief Deletes the asset referenced by the asset UUID.
- *
- * \param[in] asset_uuid Asset UUID
- * \param[in] s_token Pointer to the asset's token \ref tfm_sst_token_t
- *
- * \return Returns error code as specified in \ref psa_sst_err_t
- */
-enum psa_sst_err_t sst_am_delete(uint32_t asset_uuid,
- const struct tfm_sst_token_t *s_token);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SST_ASSET_MANAGEMENT_H__ */
diff --git a/secure_fw/services/secure_storage/tfm_protected_storage.c b/secure_fw/services/secure_storage/tfm_protected_storage.c
new file mode 100644
index 0000000..786be7f
--- /dev/null
+++ b/secure_fw/services/secure_storage/tfm_protected_storage.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/* Note: A full implementation will be added in another patch. */
+
+#include "tfm_protected_storage.h"
+
+enum tfm_sst_err_t tfm_sst_init(void)
+{
+ return TFM_SST_ERR_SUCCESS;
+}
+
+enum tfm_sst_err_t tfm_sst_set(const psa_ps_uid_t *uid,
+ uint32_t data_length,
+ const void *p_data,
+ psa_ps_create_flags_t create_flags)
+{
+ (void)uid, (void)data_length, (void)p_data, (void)create_flags;
+ return TFM_SST_ERR_NOT_SUPPORTED;
+}
+
+enum tfm_sst_err_t tfm_sst_get(const psa_ps_uid_t *uid,
+ uint32_t data_offset,
+ uint32_t data_length,
+ void *p_data)
+{
+ (void)uid, (void)data_offset, (void)data_length, (void)p_data;
+ return TFM_SST_ERR_NOT_SUPPORTED;
+}
+
+enum tfm_sst_err_t tfm_sst_get_info(const psa_ps_uid_t *uid,
+ struct psa_ps_info_t *p_info)
+{
+ (void)uid, (void)p_info;
+ return TFM_SST_ERR_NOT_SUPPORTED;
+}
+
+enum tfm_sst_err_t tfm_sst_remove(const psa_ps_uid_t *uid)
+{
+ (void)uid, (void)uid;
+ return TFM_SST_ERR_NOT_SUPPORTED;
+}
+
+enum tfm_sst_err_t tfm_sst_get_support(uint32_t *support_flags)
+{
+ (void)support_flags;
+ return TFM_SST_ERR_NOT_SUPPORTED;
+}
diff --git a/secure_fw/services/secure_storage/tfm_protected_storage.h b/secure_fw/services/secure_storage/tfm_protected_storage.h
new file mode 100644
index 0000000..f8e17d9
--- /dev/null
+++ b/secure_fw/services/secure_storage/tfm_protected_storage.h
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __TFM_PROTECTED_STORAGE_H__
+#define __TFM_PROTECTED_STORAGE_H__
+
+#include <stdint.h>
+
+#include "psa_protected_storage.h"
+#include "tfm_sst_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Initializes the secure storage system.
+ *
+ * \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_ERROR_STORAGE_FAILURE The operation failed because the
+ * storage system initialization has
+ * failed (fatal error)
+ * \retval TFM_SST_ERR_OPERATION_FAILED The operation failed because of an
+ * unspecified internal failure
+ */
+enum tfm_sst_err_t tfm_sst_init(void);
+
+/**
+ * \brief Creates a new or modifies an existing asset.
+ *
+ * \param[in] uid Pointer to 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_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.
+ *
+ * \param[in] uid Pointer to 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 the data
+ * associated with the UID was corrupt
+ * \retval TFM_SST_ERR_AUTH_FAILED The operation failed because the data
+ * associated with the UID failed
+ * authentication
+ */
+enum tfm_sst_err_t tfm_sst_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.
+ *
+ * \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
+ *
+ * \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 the data
+ * associated with the UID was corrupt
+ * \retval TFM_SST_ERR_AUTH_FAILED The operation failed because the data
+ * associated with the UID failed
+ * authentication
+ */
+enum tfm_sst_err_t tfm_sst_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.
+ *
+ * \param[in] uid Pointer to 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_remove(const 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
+ */
+enum tfm_sst_err_t tfm_sst_get_support(uint32_t *support_flags);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TFM_PROTECTED_STORAGE_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 78bb4b3..c9ff324 100644
--- a/secure_fw/services/secure_storage/tfm_sst_secure_api.c
+++ b/secure_fw/services/secure_storage/tfm_sst_secure_api.c
@@ -1,157 +1,89 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
-#include "psa_sst_api.h"
+#include "psa_protected_storage.h"
#include "tfm_sst_veneers.h"
-#include "tfm_secure_api.h"
-#include "secure_fw/services/secure_storage/sst_asset_management.h"
__attribute__(( section("SFN")))
-enum psa_sst_err_t psa_sst_create(uint32_t asset_uuid, const uint8_t *token,
- uint32_t token_size)
+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)
{
- struct tfm_sst_token_t s_token;
+ enum tfm_sst_err_t err;
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
+ err = tfm_sst_veneer_set(&uid, data_length, p_data, create_flags);
- return tfm_sst_veneer_create(asset_uuid, &s_token);
-
+ return TFM_SST_PSA_RETURN(err);
}
__attribute__(( section("SFN")))
-enum psa_sst_err_t psa_sst_get_info(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- struct psa_sst_asset_info_t *info)
+psa_ps_status_t psa_ps_get(psa_ps_uid_t uid,
+ uint32_t data_offset,
+ uint32_t data_length,
+ void *p_data)
{
- struct tfm_sst_token_t s_token;
+ enum tfm_sst_err_t err;
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
+ err = tfm_sst_veneer_get(&uid, data_offset, data_length, p_data);
- return tfm_sst_veneer_get_info(asset_uuid, &s_token, info);
+ return TFM_SST_PSA_RETURN(err);
}
__attribute__(( section("SFN")))
-enum psa_sst_err_t psa_sst_get_attributes(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- struct psa_sst_asset_attrs_t *attrs)
+psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
{
- struct tfm_sst_token_t s_token;
+ enum tfm_sst_err_t err;
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
+ err = tfm_sst_veneer_get_info(&uid, p_info);
- return tfm_sst_veneer_get_attributes(asset_uuid, &s_token, attrs);
+ return TFM_SST_PSA_RETURN(err);
}
__attribute__(( section("SFN")))
-enum psa_sst_err_t psa_sst_set_attributes(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- const struct psa_sst_asset_attrs_t *attrs)
+psa_ps_status_t psa_ps_remove(psa_ps_uid_t uid)
{
- struct tfm_sst_token_t s_token;
+ enum tfm_sst_err_t err;
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
+ err = tfm_sst_veneer_remove(&uid);
- return tfm_sst_veneer_set_attributes(asset_uuid, &s_token, attrs);
+ return TFM_SST_PSA_RETURN(err);
}
__attribute__(( section("SFN")))
-enum psa_sst_err_t psa_sst_read(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- uint32_t size,
- uint32_t offset,
- uint8_t *data)
+psa_ps_status_t psa_ps_create(psa_ps_uid_t uid, uint32_t size,
+ psa_ps_create_flags_t create_flags)
{
- struct tfm_sst_token_t s_token;
- struct tfm_sst_buf_t s_data;
-
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
-
- /* Pack buffer information in the buffer structure */
- s_data.size = size;
- s_data.offset = offset;
- s_data.data = data;
-
- return tfm_sst_veneer_read(SST_DIRECT_CLIENT_READ,
- asset_uuid,
- &s_token,
- &s_data);
+ (void)uid, (void)size, (void)create_flags;
+ return PSA_PS_ERROR_NOT_SUPPORTED;
}
__attribute__(( section("SFN")))
-enum psa_sst_err_t psa_sst_reference_read(int32_t client_id,
- uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- uint32_t size,
- uint32_t offset,
- uint8_t *data)
+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)
{
- struct tfm_sst_token_t s_token;
- struct tfm_sst_buf_t s_data;
-
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
-
- /* Pack buffer information in the buffer structure */
- s_data.size = size;
- s_data.offset = offset;
- s_data.data = data;
-
- return tfm_sst_veneer_read(client_id, asset_uuid, &s_token, &s_data);
+ (void)uid, (void)data_offset, (void)data_length, (void)p_data;
+ return PSA_PS_ERROR_NOT_SUPPORTED;
}
__attribute__(( section("SFN")))
-enum psa_sst_err_t psa_sst_write(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size,
- uint32_t size,
- uint32_t offset,
- const uint8_t *data)
+uint32_t psa_ps_get_support(void)
{
- struct tfm_sst_token_t s_token;
- struct tfm_sst_buf_t s_data;
+ uint32_t support_flags;
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
+ /* Initialise support_flags to a sensible default, to avoid returning an
+ * uninitialised value in case the secure function fails.
+ */
+ support_flags = 0;
- /* Pack buffer information in the buffer structure */
- s_data.size = size;
- s_data.offset = offset;
- s_data.data = (uint8_t *)data;
+ /* The PSA API does not return an error, so any error from TF-M is
+ * ignored.
+ */
+ (void)tfm_sst_veneer_get_support(&support_flags);
- return tfm_sst_veneer_write(asset_uuid, &s_token, &s_data);
-}
-
-__attribute__(( section("SFN")))
-enum psa_sst_err_t psa_sst_delete(uint32_t asset_uuid,
- const uint8_t *token,
- uint32_t token_size)
-{
- struct tfm_sst_token_t s_token;
-
- /* Pack the token information in the token structure */
- s_token.token = token;
- s_token.token_size = token_size;
-
- return tfm_sst_veneer_delete(asset_uuid, &s_token);
+ return support_flags;
}
diff --git a/secure_fw/services/tfm_partition_defs.inc b/secure_fw/services/tfm_partition_defs.inc
index a84c54b..bba652c 100644
--- a/secure_fw/services/tfm_partition_defs.inc
+++ b/secure_fw/services/tfm_partition_defs.inc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
diff --git a/secure_fw/services/tfm_partition_defs.inc.template b/secure_fw/services/tfm_partition_defs.inc.template
index 6c93c77..ad05eeb 100644
--- a/secure_fw/services/tfm_partition_defs.inc.template
+++ b/secure_fw/services/tfm_partition_defs.inc.template
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
diff --git a/secure_fw/services/tfm_partition_list.inc b/secure_fw/services/tfm_partition_list.inc
index 57dd18f..260dbc6 100644
--- a/secure_fw/services/tfm_partition_list.inc
+++ b/secure_fw/services/tfm_partition_list.inc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -12,7 +12,7 @@
/******** TFM_SP_STORAGE ********/
PARTITION_DECLARE(TFM_SP_STORAGE, SPM_PART_FLAG_SECURE | SPM_PART_FLAG_TRUSTED);
-PARTITION_ADD_INIT_FUNC(TFM_SP_STORAGE, sst_am_prepare);
+PARTITION_ADD_INIT_FUNC(TFM_SP_STORAGE, tfm_sst_init);
/******** TFM_SP_AUDIT_LOG ********/
PARTITION_DECLARE(TFM_SP_AUDIT_LOG, SPM_PART_FLAG_SECURE | SPM_PART_FLAG_TRUSTED);
diff --git a/secure_fw/services/tfm_partition_list.inc.template b/secure_fw/services/tfm_partition_list.inc.template
index 7cc1993..3c5812b 100644
--- a/secure_fw/services/tfm_partition_list.inc.template
+++ b/secure_fw/services/tfm_partition_list.inc.template
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
diff --git a/secure_fw/services/tfm_sfid_list.inc b/secure_fw/services/tfm_sfid_list.inc
index 4e56af4..5d08aa6 100644
--- a/secure_fw/services/tfm_sfid_list.inc
+++ b/secure_fw/services/tfm_sfid_list.inc
@@ -11,13 +11,11 @@
#define __TFM_SFID_LIST_INC__
/******** TFM_SP_STORAGE ********/
- {sst_am_create, SST_AM_CREATE_SFID},
- {sst_am_get_info, SST_AM_GET_INFO_SFID},
- {sst_am_get_attributes, SST_AM_GET_ATTRIBUTES_SFID},
- {sst_am_set_attributes, SST_AM_SET_ATTRIBUTES_SFID},
- {sst_am_read, SST_AM_READ_SFID},
- {sst_am_write, SST_AM_WRITE_SFID},
- {sst_am_delete, SST_AM_DELETE_SFID},
+ {tfm_sst_set, TFM_SST_SET_SFID},
+ {tfm_sst_get, TFM_SST_GET_SFID},
+ {tfm_sst_get_info, TFM_SST_GET_INFO_SFID},
+ {tfm_sst_remove, TFM_SST_REMOVE_SFID},
+ {tfm_sst_get_support, TFM_SST_GET_SUPPORT_SFID},
/******** TFM_SP_AUDIT_LOG ********/
{audit_core_retrieve_record, TFM_AUDIT_RETRIEVE_RECORD_SFID},
diff --git a/secure_fw/services/tfm_sfid_list.inc.template b/secure_fw/services/tfm_sfid_list.inc.template
index 08e5918..7f9bb92 100644
--- a/secure_fw/services/tfm_sfid_list.inc.template
+++ b/secure_fw/services/tfm_sfid_list.inc.template
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
diff --git a/test/framework/non_secure_suites.c b/test/framework/non_secure_suites.c
index 496dc4f..35890d9 100644
--- a/test/framework/non_secure_suites.c
+++ b/test/framework/non_secure_suites.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -35,6 +35,8 @@
#ifdef SERVICES_TEST_NS
/* List test cases which compliant with level 1 isolation */
+
+#ifndef PSA_PROTECTED_STORAGE
/* Non-secure SST test cases */
{®ister_testsuite_ns_sst_interface, 0, 0, 0},
@@ -47,6 +49,7 @@
#endif /* TFM_PARTITION_TEST_SST */
#endif /* TFM_NS_CLIENT_IDENTIFICATION */
+#endif /* !PSA_PROTECTED_STORAGE */
/* Non-secure Audit Logging test cases */
{®ister_testsuite_ns_audit_interface, 0, 0, 0},
diff --git a/test/framework/secure_suites.c b/test/framework/secure_suites.c
index 1dde38d..181f1b1 100644
--- a/test/framework/secure_suites.c
+++ b/test/framework/secure_suites.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -16,8 +16,6 @@
#include "test/suites/invert/secure/invert_s_tests.h"
#include "test/suites/crypto/secure/crypto_s_tests.h"
-#include "secure_fw/services/secure_storage/sst_object_system.h"
-
static struct test_suite_t test_suites[] = {
#if TFM_LVL == 3
#ifdef SERVICES_TEST_S
@@ -30,6 +28,8 @@
#ifdef SERVICES_TEST_S
/* List test cases which compliant with level 1 isolation */
+
+#ifndef PSA_PROTECTED_STORAGE
/* Secure SST test cases */
{®ister_testsuite_s_sst_sec_interface, 0, 0, 0},
{®ister_testsuite_s_sst_reliability, 0, 0, 0},
@@ -37,6 +37,7 @@
#if defined(SST_ROLLBACK_PROTECTION) && defined(SST_ENCRYPTION)
{®ister_testsuite_s_rollback_protection, 0, 0, 0},
#endif
+#endif /* !PSA_PROTECTED_STORAGE */
/* Secure Audit Logging test cases */
{®ister_testsuite_s_audit_interface, 0, 0, 0},
@@ -63,14 +64,12 @@
*/
}
-#if TFM_LVL == 1
static void tear_down_integ_test(void)
{
- /* Leave the SST area clean after execute the tests */
- sst_system_wipe_all();
- sst_system_prepare();
+ /* Left empty intentionally, currently implemented
+ * test suites require no tear down
+ */
}
-#endif /* TFM_LVL == 1 */
void start_integ_test(void)
{
@@ -78,7 +77,5 @@
integ_test("Secure",
test_suites,
sizeof(test_suites)/sizeof(test_suites[0]));
-#if TFM_LVL == 1
tear_down_integ_test();
-#endif /* TFM_LVL == 1 */
}
diff --git a/test/framework/test_framework_helpers.c b/test/framework/test_framework_helpers.c
index d9870f4..7423325 100755
--- a/test/framework/test_framework_helpers.c
+++ b/test/framework/test_framework_helpers.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -9,27 +9,37 @@
#include <stdio.h>
-const char *sst_err_to_str(enum psa_sst_err_t err)
+const char *psa_ps_status_to_str(psa_ps_status_t status)
{
- switch (err) {
- case PSA_SST_ERR_SUCCESS:
- return "PSA_SST_ERR_SUCCESS";
- case PSA_SST_ERR_ASSET_NOT_PREPARED:
- return "PSA_SST_ERR_ASSET_NOT_PREPARED";
- case PSA_SST_ERR_ASSET_NOT_FOUND:
- return "PSA_SST_ERR_ASSET_NOT_FOUND";
- case PSA_SST_ERR_PARAM_ERROR:
- return "PSA_SST_ERR_PARAM_ERROR";
- case PSA_SST_ERR_STORAGE_SYSTEM_FULL:
- return "PSA_SST_ERR_STORAGE_SYSTEM_FULL";
- case PSA_SST_ERR_SYSTEM_ERROR:
- return "PSA_SST_ERR_SYSTEM_ERROR";
- case PSA_SST_ERR_FORCE_INT_SIZE:
- return "PSA_SST_ERR_FORCE_INT_SIZE";
- /* default: The default is not defined intentionally to force the
- * compiler to check that all the enumeration values are
- * covered in the switch.
- */
+ 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";
}
}
diff --git a/test/framework/test_framework_helpers.h b/test/framework/test_framework_helpers.h
index c0e7a7a..03eb3dc 100755
--- a/test/framework/test_framework_helpers.h
+++ b/test/framework/test_framework_helpers.h
@@ -1,22 +1,21 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
-#ifndef __HELPERS_H__
-#define __HELPERS_H__
+#ifndef __TEST_FRAMEWORK_HELPERS_H__
+#define __TEST_FRAMEWORK_HELPERS_H__
+
+#include <stdint.h>
+#include "psa_protected_storage.h"
+#include "test_framework.h"
#ifdef __cplusplus
extern "C" {
#endif
-#include <stdint.h>
-#include "tfm_sst_defs.h"
-#include "secure_fw/services/secure_storage/sst_asset_management.h"
-#include "test_framework.h"
-
enum serial_color_t {
BLACK = 0,
RED = 1,
@@ -29,13 +28,13 @@
};
/**
- * \brief Translates psa_sst_err_t into a string.
+ * \brief Translates psa_ps_status_t into a string.
*
- * \param[in] err psa_sst_err_t error value.
+ * \param[in] err psa_ps_status_t status value.
*
- * \return psa_sst_err_t as string.
+ * \return psa_ps_status_t as string.
*/
-const char *sst_err_to_str(enum psa_sst_err_t err);
+const char *psa_ps_status_to_str(psa_ps_status_t status);
/**
* \brief Translates asset permissions into a string.
@@ -59,4 +58,4 @@
}
#endif
-#endif /* __HELPERS_H__ */
+#endif /* __TEST_FRAMEWORK_HELPERS_H__ */
diff --git a/test/suites/sst/CMakeLists.inc b/test/suites/sst/CMakeLists.inc
index c293132..dcd5e32 100644
--- a/test/suites/sst/CMakeLists.inc
+++ b/test/suites/sst/CMakeLists.inc
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+# Copyright (c) 2017-2019, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -27,36 +27,44 @@
if (NOT DEFINED ENABLE_SECURE_STORAGE_SERVICE_TESTS)
message(FATAL_ERROR "Incomplete build configuration: ENABLE_SECURE_STORAGE_SERVICE_TESTS is undefined. ")
elseif (ENABLE_SECURE_STORAGE_SERVICE_TESTS)
- list(APPEND ALL_SRC_C_S "${SECURE_STORAGE_TEST_DIR}/secure/s_test_helpers.c"
- "${SECURE_STORAGE_TEST_DIR}/secure/sst_sec_interface_testsuite.c"
- "${SECURE_STORAGE_TEST_DIR}/secure/sst_reliability_testsuite.c"
+ if (NOT DEFINED PSA_PROTECTED_STORAGE)
+ message(FATAL_ERROR "Incomplete build configuration: PSA_PROTECTED_STORAGE is undefined.")
+
+ elseif (PSA_PROTECTED_STORAGE)
+ set_property(SOURCE ${ALL_SRC_C_S} APPEND PROPERTY COMPILE_DEFINITIONS PSA_PROTECTED_STORAGE)
+ set_property(SOURCE ${ALL_SRC_C_NS} APPEND PROPERTY COMPILE_DEFINITIONS PSA_PROTECTED_STORAGE)
+
+ else()
+ list(APPEND ALL_SRC_C_S "${SECURE_STORAGE_TEST_DIR}/secure/sst_sec_interface_testsuite.c"
+ "${SECURE_STORAGE_TEST_DIR}/secure/sst_reliability_testsuite.c"
+ )
+ if (SST_ROLLBACK_PROTECTION AND SST_ENCRYPTION AND TFM_LVL EQUAL 1)
+ list(APPEND ALL_SRC_C_S "${SECURE_STORAGE_TEST_DIR}/secure/sst_rollback_protection_testsuite.c"
+ "${SECURE_STORAGE_TEST_DIR}/secure/nv_counters/test_sst_nv_counters.c")
+ endif()
+
+ list(APPEND ALL_SRC_C_NS
+ "${SECURE_STORAGE_TEST_DIR}/non_secure/ns_test_helpers.c"
+ "${SECURE_STORAGE_TEST_DIR}/non_secure/sst_ns_interface_testsuite.c"
)
- if (SST_ROLLBACK_PROTECTION AND SST_ENCRYPTION AND TFM_LVL EQUAL 1)
- list(APPEND ALL_SRC_C_S "${SECURE_STORAGE_TEST_DIR}/secure/sst_rollback_protection_testsuite.c"
- "${SECURE_STORAGE_TEST_DIR}/secure/nv_counters/test_sst_nv_counters.c")
- endif()
- list(APPEND ALL_SRC_C_NS
- "${SECURE_STORAGE_TEST_DIR}/non_secure/ns_test_helpers.c"
- "${SECURE_STORAGE_TEST_DIR}/non_secure/sst_ns_interface_testsuite.c"
- )
+ if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION)
+ message(FATAL_ERROR "Incomplete build configuration: TFM_NS_CLIENT_IDENTIFICATION is undefined.")
+ elseif (TFM_NS_CLIENT_IDENTIFICATION)
+ list(APPEND ALL_SRC_C_NS "${SECURE_STORAGE_TEST_DIR}/non_secure/sst_policy_testsuite.c")
+ set_property(SOURCE ${ALL_SRC_C_NS} APPEND PROPERTY COMPILE_DEFINITIONS TFM_NS_CLIENT_IDENTIFICATION)
+ endif()
- if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION)
- message(FATAL_ERROR "Incomplete build configuration: TFM_NS_CLIENT_IDENTIFICATION is undefined.")
- elseif (TFM_NS_CLIENT_IDENTIFICATION)
- list(APPEND ALL_SRC_C_NS "${SECURE_STORAGE_TEST_DIR}/non_secure/sst_policy_testsuite.c")
- set_property(SOURCE ${ALL_SRC_C_NS} APPEND PROPERTY COMPILE_DEFINITIONS TFM_NS_CLIENT_IDENTIFICATION)
- endif()
+ if (NOT DEFINED TFM_PARTITION_TEST_SST)
+ message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_SST is undefined.")
+ elseif (TFM_PARTITION_TEST_SST AND TFM_NS_CLIENT_IDENTIFICATION)
+ list(APPEND ALL_SRC_C_NS "${SECURE_STORAGE_TEST_DIR}/non_secure/sst_ns_ref_access_testsuite.c")
+ endif()
- if (NOT DEFINED TFM_PARTITION_TEST_SST)
- message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_SST is undefined.")
- elseif (TFM_PARTITION_TEST_SST AND TFM_NS_CLIENT_IDENTIFICATION)
- list(APPEND ALL_SRC_C_NS "${SECURE_STORAGE_TEST_DIR}/non_secure/sst_ns_ref_access_testsuite.c")
- endif()
-
- if (SST_ENABLE_PARTIAL_ASSET_RW)
- set_property(SOURCE ${ALL_SRC_C_S} APPEND PROPERTY COMPILE_DEFINITIONS SST_ENABLE_PARTIAL_ASSET_RW)
- set_property(SOURCE ${ALL_SRC_C_NS} APPEND PROPERTY COMPILE_DEFINITIONS SST_ENABLE_PARTIAL_ASSET_RW)
+ if (SST_ENABLE_PARTIAL_ASSET_RW)
+ set_property(SOURCE ${ALL_SRC_C_S} APPEND PROPERTY COMPILE_DEFINITIONS SST_ENABLE_PARTIAL_ASSET_RW)
+ set_property(SOURCE ${ALL_SRC_C_NS} APPEND PROPERTY COMPILE_DEFINITIONS SST_ENABLE_PARTIAL_ASSET_RW)
+ endif()
endif()
if (NOT SST_RAM_FS AND NOT REFERENCE_PLATFORM)
diff --git a/test/suites/sst/non_secure/ns_test_helpers.h b/test/suites/sst/non_secure/ns_test_helpers.h
index fe0798b..e18d812 100644
--- a/test/suites/sst/non_secure/ns_test_helpers.h
+++ b/test/suites/sst/non_secure/ns_test_helpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -17,18 +17,6 @@
#define CONCAT_(x, y) x ## y
#define CONCAT(x, y) CONCAT_(x, y)
-/*!
- * \struct sst_test_buf_t
- *
- * \brief Structure to store test data information to read/write from/to asset.
- *
- */
-struct sst_test_buf_t {
- uint8_t *data; /*!< Address of input/output data */
- uint32_t size; /*!< Size of input/output data */
- uint32_t offset; /*!< Offset within asset */
-};
-
/**
* Several tests use a buffer to read back data from an asset. This buffer is
* larger than the size of the asset data by PADDING_SIZE bytes. This allows
@@ -41,7 +29,7 @@
* Then a correct and successful read would give this result: "XXXXAAAAXXXX"
* (Assuming a PADDING_SIZE of 8)
*/
-#define BUFFER_SIZE SST_ASSET_MAX_SIZE_AES_KEY_192
+#define BUFFER_SIZE 24
#define PADDING_SIZE 8
#define HALF_PADDING_SIZE 4
diff --git a/test/suites/sst/secure/s_test_helpers.c b/test/suites/sst/secure/s_test_helpers.c
deleted file mode 100755
index 4a02d03..0000000
--- a/test/suites/sst/secure/s_test_helpers.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#include "s_test_helpers.h"
-
-#include <stdio.h>
-#include <string.h>
-
-#include "test/framework/test_framework.h"
-#include "secure_fw/services/secure_storage/sst_object_system.h"
-
-uint32_t prepare_test_ctx(struct test_result_t *ret)
-{
- /* Wipes secure storage area */
- sst_system_wipe_all();
-
- /* Prepares secure storage area before write */
- if (sst_system_prepare() != PSA_SST_ERR_SUCCESS) {
- TEST_FAIL("Wiped system should be preparable");
- return 1;
- }
-
- return 0;
-}
diff --git a/test/suites/sst/secure/s_test_helpers.h b/test/suites/sst/secure/s_test_helpers.h
index 5fb913f..1d8d664 100755
--- a/test/suites/sst/secure/s_test_helpers.h
+++ b/test/suites/sst/secure/s_test_helpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -12,20 +12,6 @@
extern "C" {
#endif
-#include "test/framework/test_framework.h"
-
-/*!
- * \struct sst_test_buf_t
- *
- * \brief Structure to store test data information to read/write from/to asset.
- *
- */
-struct sst_test_buf_t {
- uint8_t *data; /*!< Address of input/output data */
- uint32_t size; /*!< Size of input/output data */
- uint32_t offset; /*!< Offset within asset */
-};
-
/**
* Several tests use a buffer to read back data from an asset. This buffer is
* larger than the size of the asset data by PADDING_SIZE bytes. This allows
@@ -38,23 +24,13 @@
* Then a correct and successful read would give this result: "XXXXAAAAXXXX"
* (Assuming a PADDING_SIZE of 8)
*/
-#define BUFFER_SIZE SST_ASSET_MAX_SIZE_AES_KEY_192
+#define BUFFER_SIZE 24
#define PADDING_SIZE 8
#define HALF_PADDING_SIZE 4
#define BUFFER_PLUS_PADDING_SIZE (BUFFER_SIZE + PADDING_SIZE)
#define BUFFER_PLUS_HALF_PADDING_SIZE (BUFFER_SIZE + HALF_PADDING_SIZE)
-/**
- * \brief Prepares secure storage area for the new tests. It executes wipes and
- * prepare.
- *
- * \param[out] ret Pointer to the test result structure.
- *
- * \return 0 if the context is correcly prepared. Otherwise 1.
- */
-uint32_t prepare_test_ctx(struct test_result_t *ret);
-
#ifdef __cplusplus
}
#endif
diff --git a/test/test_services/tfm_secure_client_service/tfm_secure_client_service.c b/test/test_services/tfm_secure_client_service/tfm_secure_client_service.c
index b17f6f3..280e1af 100644
--- a/test/test_services/tfm_secure_client_service/tfm_secure_client_service.c
+++ b/test/test_services/tfm_secure_client_service/tfm_secure_client_service.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -12,11 +12,11 @@
* \brief Service initialisation function. No special initialisation is
* required.
*
- * \return Returns error code as specified in \ref psa_sst_err_t
+ * \return Returns 0 on success
*/
-enum psa_sst_err_t tfm_secure_client_service_init(void)
+int32_t tfm_secure_client_service_init(void)
{
- return PSA_SST_ERR_SUCCESS;
+ return 0;
}
int32_t tfm_secure_client_service_sfn_run_tests(void)
diff --git a/test/test_services/tfm_secure_client_service/tfm_secure_client_service.h b/test/test_services/tfm_secure_client_service/tfm_secure_client_service.h
index d45b92a..baa650a 100644
--- a/test/test_services/tfm_secure_client_service/tfm_secure_client_service.h
+++ b/test/test_services/tfm_secure_client_service/tfm_secure_client_service.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -9,7 +9,6 @@
#define __TFM_SECURE_CLIENT_SERVICE_H__
#include <stdint.h>
-#include "tfm_sst_defs.h"
#ifdef __cplusplus
extern "C" {