From 601bd53b80fdd86e42345fdc1394850d2e64540e Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sun, 24 Feb 2019 11:34:28 +0100 Subject: [PATCH] Fix up ITS header files for internal use in crypto Merge storage_common.h and internal_trusted_storage.h into a single file for convenience. Remove #include of which crypto doesn't have yet and include and instead. Drop __cplusplus support which we don't need. Tweak style (whitespace, line breaks, comment formatting) to satisfy check-names.sh and check-files.sh. --- ...nal_trusted_storage.h => psa_crypto_its.h} | 69 +++++++++++++------ library/storage_common.h | 58 ---------------- visualc/VS2010/mbedTLS.vcxproj | 1 + 3 files changed, 48 insertions(+), 80 deletions(-) rename library/{internal_trusted_storage.h => psa_crypto_its.h} (81%) delete mode 100644 library/storage_common.h diff --git a/library/internal_trusted_storage.h b/library/psa_crypto_its.h similarity index 81% rename from library/internal_trusted_storage.h rename to library/psa_crypto_its.h index 4b117e746..44d51982a 100644 --- a/library/internal_trusted_storage.h +++ b/library/psa_crypto_its.h @@ -1,3 +1,6 @@ +/** \file psa_crypto_its.h + * \brief Interface of trusted storage that crypto is built on. + */ /* Copyright (C) 2019, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * @@ -13,22 +16,48 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** @file -@brief This file describes the PSA Internal Trusted Storage API -*/ -#ifndef __PSA_INTERNAL_TRUSTED_STORAGE_H__ -#define __PSA_INTERNAL_TRUSTED_STORAGE_H__ +#ifndef PSA_CRYPTO_ITS_H +#define PSA_CRYPTO_ITS_H #include #include -#include "psa/error.h" -#include "psa/storage_common.h" +#include +#include #ifdef __cplusplus extern "C" { #endif + +/** \brief Flags used when creating a data entry + */ +typedef uint32_t psa_storage_create_flags_t; + +/** \brief A type for UIDs used for identifying data + */ +typedef uint64_t psa_storage_uid_t; + +#define PSA_STORAGE_FLAG_NONE 0 /**< No flags to pass */ +#define PSA_STORAGE_FLAG_WRITE_ONCE (1 << 0) /**< The data associated with the uid will not be able to be modified or deleted. Intended to be used to set bits in `psa_storage_create_flags_t`*/ + +/** + * \brief A container for metadata associated with a specific uid + */ +struct psa_storage_info_t +{ + uint32_t size; /**< The size of the data associated with a uid **/ + psa_storage_create_flags_t flags; /**< The flags set when the uid was created **/ +}; + +/** Flag indicating that \ref psa_storage_create and \ref psa_storage_set_extended are supported */ +#define PSA_STORAGE_SUPPORT_SET_EXTENDED (1 << 0) + +/** \brief PSA storage specific error codes + */ +#define PSA_ERROR_INVALID_SIGNATURE ((psa_status_t)-149) +#define PSA_ERROR_DATA_CORRUPT ((psa_status_t)-152) + #define PSA_ITS_API_VERSION_MAJOR 1 /**< The major version number of the PSA ITS API. It will be incremented on significant updates that may include breaking changes */ #define PSA_ITS_API_VERSION_MINOR 1 /**< The minor version number of the PSA ITS API. It will be incremented in small updates that are unlikely to include breaking changes */ @@ -39,9 +68,9 @@ extern "C" { * \param[in] data_length The size in bytes of the data in `p_data` * \param[in] p_data A buffer containing the data * \param[in] create_flags The flags that the data will be stored with - * + * * \return A status indicating the success/failure of the operation - + * * \retval PSA_SUCCESS The operation completed successfully * \retval PSA_ERROR_NOT_PERMITTED The operation failed because the provided `uid` value was already created with PSA_STORAGE_WRITE_ONCE_FLAG * \retval PSA_ERROR_NOT_SUPPORTED The operation failed because one or more of the flags provided in `create_flags` is not supported or is not valid @@ -62,8 +91,8 @@ psa_status_t psa_its_set(psa_storage_uid_t uid, * \param[in] data_offset The starting offset of the data requested * \param[in] data_length the amount of data requested (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 * * \retval PSA_SUCCESS The operation completed successfully @@ -81,12 +110,12 @@ psa_status_t psa_its_get(psa_storage_uid_t uid, /** * \brief Retrieve the metadata about the provided uid - * + * * \param[in] uid The uid value * \param[out] p_info A pointer to the `psa_storage_info_t` struct that will be populated with the metadata - * + * * \return A status indicating the success/failure of the operation - * + * * \retval PSA_SUCCESS The operation completed successfully * \retval PSA_ERROR_DOES_NOT_EXIST The operation failed because the provided uid value was not found in the storage * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error) @@ -98,11 +127,11 @@ psa_status_t psa_its_get_info(psa_storage_uid_t uid, /** * \brief Remove the provided key and its associated data from the storage - * + * * \param[in] uid The uid value - * + * * \return A status indicating the success/failure of the operation - * + * * \retval PSA_SUCCESS The operation completed successfully * \retval PSA_ERROR_DOES_NOT_EXIST The operation failed because the provided key value was not found in the storage * \retval PSA_ERROR_NOT_PERMITTED The operation failed because the provided key value was created with PSA_STORAGE_WRITE_ONCE_FLAG @@ -110,8 +139,4 @@ psa_status_t psa_its_get_info(psa_storage_uid_t uid, */ psa_status_t psa_its_remove(psa_storage_uid_t uid); -#ifdef __cplusplus -} -#endif - -#endif // __PSA_INTERNAL_TRUSTED_STORAGE_H__ +#endif /* PSA_CRYPTO_ITS_H */ diff --git a/library/storage_common.h b/library/storage_common.h deleted file mode 100644 index 07cb6e9c6..000000000 --- a/library/storage_common.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2019, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** @file -@brief This file includes common definitions for PSA storage -*/ - -#ifndef __PSA_STORAGE_COMMON_H__ -#define __PSA_STORAGE_COMMON_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** \brief Flags used when creating a data entry - */ -typedef uint32_t psa_storage_create_flags_t; - -/** \brief A type for UIDs used for identifying data - */ -typedef uint64_t psa_storage_uid_t; - -#define PSA_STORAGE_FLAG_NONE 0 /**< No flags to pass */ -#define PSA_STORAGE_FLAG_WRITE_ONCE (1 << 0) /**< The data associated with the uid will not be able to be modified or deleted. Intended to be used to set bits in `psa_storage_create_flags_t`*/ - -/** - * \brief A container for metadata associated with a specific uid - */ -struct psa_storage_info_t { - uint32_t size; /**< The size of the data associated with a uid **/ - psa_storage_create_flags_t flags; /**< The flags set when the uid was created **/ -}; - -/** Flag indicating that \ref psa_storage_create and \ref psa_storage_set_extended are supported */ -#define PSA_STORAGE_SUPPORT_SET_EXTENDED (1 << 0) - -/** \brief PSA storage specific error codes - */ -#define PSA_ERROR_INVALID_SIGNATURE ((psa_status_t)-149) -#define PSA_ERROR_DATA_CORRUPT ((psa_status_t)-152) - -#endif // __PSA_STORAGE_COMMON_H__ diff --git a/visualc/VS2010/mbedTLS.vcxproj b/visualc/VS2010/mbedTLS.vcxproj index bb92d8f8c..aa48c1620 100644 --- a/visualc/VS2010/mbedTLS.vcxproj +++ b/visualc/VS2010/mbedTLS.vcxproj @@ -238,6 +238,7 @@ +