Mbed OS Reference
Loading...
Searching...
No Matches
psa_prot_internal_storage.h
Go to the documentation of this file.
1/* Copyright (C) 2019, ARM Limited, All Rights Reserved
2 * SPDX-License-Identifier: Apache-2.0
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may
5 * not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16/** @file
17@brief This file describes the PSA Internal Trusted Storage API
18*/
19
20#ifndef __PSA_INTERNAL_TRUSTED_STORAGE_H__
21#define __PSA_INTERNAL_TRUSTED_STORAGE_H__
22
23#include <stddef.h>
24#include <stdint.h>
25
26#include "psa/error.h"
27#include "psa/storage_common.h"
28#include "mbed_toolchain.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33#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 */
34#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 */
35
36// These deprecated types are still used by our PSA compliance test tools
37MBED_DEPRECATED("ITS specific types should not be used")
38typedef psa_status_t psa_its_status_t;
39
40MBED_DEPRECATED("ITS specific types should not be used")
41typedef psa_storage_create_flags_t psa_its_create_flags_t;
42
43MBED_DEPRECATED("ITS specific types should not be used")
44typedef psa_storage_uid_t psa_its_uid_t;
45
46MBED_DEPRECATED("ITS specific types should not be used")
47#define psa_its_info_t psa_storage_info_t
48
49// These defines should also be deprecated
50#define PSA_ITS_SUCCESS PSA_SUCCESS
51#define PSA_ITS_ERROR_UID_NOT_FOUND PSA_ERROR_DOES_NOT_EXIST
52#define PSA_ITS_ERROR_STORAGE_FAILURE PSA_ERROR_STORAGE_FAILURE
53#define PSA_ITS_ERROR_INSUFFICIENT_SPACE PSA_ERROR_INSUFFICIENT_STORAGE
54#define PSA_ITS_ERROR_OFFSET_INVALID PSA_ERROR_INVALID_ARGUMENT
55#define PSA_ITS_ERROR_INCORRECT_SIZE PSA_ERROR_BUFFER_TOO_SMALL
56#define PSA_ITS_ERROR_INVALID_ARGUMENTS PSA_ERROR_INVALID_ARGUMENT
57#define PSA_ITS_ERROR_FLAGS_NOT_SUPPORTED PSA_ERROR_NOT_SUPPORTED
58#define PSA_ITS_ERROR_WRITE_ONCE PSA_ERROR_NOT_PERMITTED
59#define PSA_ITS_FLAG_WRITE_ONCE PSA_STORAGE_FLAG_WRITE_ONCE
60
61MBED_DEPRECATED("PS specific types should not be used")
62typedef psa_status_t psa_ps_status_t;
63MBED_DEPRECATED("PS specific types should not be used")
64typedef psa_storage_uid_t psa_ps_uid_t;
65MBED_DEPRECATED("PS specific types should not be used")
66typedef psa_storage_create_flags_t psa_ps_create_flags_t;
67MBED_DEPRECATED("PS specific types should not be used")
68#define psa_ps_info_t psa_storage_info_t
69
70#define PSA_PS_SUCCESS PSA_SUCCESS
71#define PSA_PS_ERROR_UID_NOT_FOUND PSA_ERROR_DOES_NOT_EXIST
72#define PSA_PS_ERROR_STORAGE_FAILURE PSA_ERROR_STORAGE_FAILURE
73#define PSA_PS_ERROR_INSUFFICIENT_SPACE PSA_ERROR_INSUFFICIENT_STORAGE
74#define PSA_PS_ERROR_OFFSET_INVALID PSA_ERROR_INVALID_ARGUMENT
75#define PSA_PS_ERROR_INCORRECT_SIZE PSA_ERROR_BUFFER_TOO_SMALL
76#define PSA_PS_ERROR_INVALID_ARGUMENT PSA_ERROR_INVALID_ARGUMENT
77#define PSA_PS_ERROR_FLAGS_NOT_SUPPORTED PSA_ERROR_NOT_SUPPORTED
78#define PSA_PS_ERROR_WRITE_ONCE PSA_ERROR_NOT_PERMITTED
79#define PSA_PS_FLAG_WRITE_ONCE PSA_STORAGE_FLAG_WRITE_ONCE
80
81/**
82 * \brief create a new or modify an existing uid/value pair
83 *
84 * \param[in] uid the identifier for the data
85 * \param[in] data_length The size in bytes of the data in `p_data`
86 * \param[in] p_data A buffer containing the data
87 * \param[in] create_flags The flags that the data will be stored with
88 *
89 * \return A status indicating the success/failure of the operation
90
91 * \retval PSA_SUCCESS The operation completed successfully
92 * \retval PSA_ERROR_NOT_PERMITTED The operation failed because the provided `uid` value was already created with PSA_STORAGE_WRITE_ONCE_FLAG
93 * \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
94 * \retval PSA_ERROR_INSUFFICIENT_STORAGE The operation failed because there was insufficient space on the storage medium
95 * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
96 * \retval PSA_ERROR_INVALID_ARGUMENTS The operation failed because one of the provided pointers(`p_data`)
97 * is invalid, for example is `NULL` or references memory the caller cannot access
98 */
100 size_t data_length,
101 const void *p_data,
102 psa_storage_create_flags_t create_flags);
103
104/**
105 * \brief Retrieve the value associated with a provided uid
106 *
107 * \param[in] uid The uid value
108 * \param[in] data_offset The starting offset of the data requested
109 * \param[in] data_length the amount of data requested (and the minimum allocated size of the `p_data` buffer)
110 * \param[out] p_data The buffer where the data will be placed upon successful completion
111 * \param[out] p_data_length The actual amount of data returned
112
113 *
114 * \return A status indicating the success/failure of the operation
115 *
116 * \retval PSA_SUCCESS The operation completed successfully
117 * \retval PSA_ERROR_DOES_NOT_EXIST The operation failed because the provided `uid` value was not found in the storage
118 * \retval PSA_ERROR_BUFFER_TOO_SMALL The operation failed because the data associated with provided `uid` is not the same size as `data_size`
119 * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
120 * \retval PSA_ERROR_INVALID_ARGUMENT The operation failed because one of the provided pointers(`p_data`, `p_data_length`)
121 * is invalid. For example is `NULL` or references memory the caller cannot access
122 */
124 size_t data_offset,
125 size_t data_length,
126 void *p_data,
127 size_t *p_data_length);
128
129/**
130 * \brief Retrieve the metadata about the provided uid
131 *
132 * \param[in] uid The uid value
133 * \param[out] p_info A pointer to the `psa_storage_info_t` struct that will be populated with the metadata
134 *
135 * \return A status indicating the success/failure of the operation
136 *
137 * \retval PSA_SUCCESS The operation completed successfully
138 * \retval PSA_ERROR_DOES_NOT_EXIST The operation failed because the provided uid value was not found in the storage
139 * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
140 * \retval PSA_ERROR_INVALID_ARGUMENT The operation failed because one of the provided pointers(`p_info`)
141 * is invalid, for example is `NULL` or references memory the caller cannot access
142 */
144 struct psa_storage_info_t *p_info);
145
146/**
147 * \brief Remove the provided key and its associated data from the storage
148 *
149 * \param[in] uid The uid value
150 *
151 * \return A status indicating the success/failure of the operation
152 *
153 * \retval PSA_SUCCESS The operation completed successfully
154 * \retval PSA_ERROR_DOES_NOT_EXIST The operation failed because the provided key value was not found in the storage
155 * \retval PSA_ERROR_NOT_PERMITTED The operation failed because the provided key value was created with PSA_STORAGE_WRITE_ONCE_FLAG
156 * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
157 */
159
160#ifdef __cplusplus
161}
162#endif
163
164#endif // __PSA_INTERNAL_TRUSTED_STORAGE_H__
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:55
psa_status_t psa_its_set(psa_storage_uid_t uid, size_t data_length, const void *p_data, psa_storage_create_flags_t create_flags)
create a new or modify an existing uid/value pair
psa_status_t psa_its_get(psa_storage_uid_t uid, size_t data_offset, size_t data_length, void *p_data, size_t *p_data_length)
Retrieve the value associated with a provided uid.
psa_status_t psa_its_remove(psa_storage_uid_t uid)
Remove the provided key and its associated data from the storage.
psa_status_t psa_its_get_info(psa_storage_uid_t uid, struct psa_storage_info_t *p_info)
Retrieve the metadata about the provided uid.
This file includes common definitions for PSA storage.
uint32_t psa_storage_create_flags_t
Flags used when creating a data entry.
uint64_t psa_storage_uid_t
A type for UIDs used for identifying data.
A container for metadata associated with a specific uid.