Mistake on this page?
Report an issue in GitHub or email us
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
31 extern "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
37 MBED_DEPRECATED("ITS specific types should not be used")
38 typedef psa_status_t psa_its_status_t;
39 
40 MBED_DEPRECATED("ITS specific types should not be used")
41 typedef psa_storage_create_flags_t psa_its_create_flags_t;
42 
43 MBED_DEPRECATED("ITS specific types should not be used")
44 typedef psa_storage_uid_t psa_its_uid_t;
45 
46 MBED_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 
61 MBED_DEPRECATED("PS specific types should not be used")
62 typedef psa_status_t psa_ps_status_t;
63 MBED_DEPRECATED("PS specific types should not be used")
64 typedef psa_storage_uid_t psa_ps_uid_t;
65 MBED_DEPRECATED("PS specific types should not be used")
66 typedef psa_storage_create_flags_t psa_ps_create_flags_t;
67 MBED_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  */
99 psa_status_t psa_its_set(psa_storage_uid_t uid,
100  uint32_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 
112  *
113  * \return A status indicating the success/failure of the operation
114  *
115  * \retval PSA_SUCCESS The operation completed successfully
116  * \retval PSA_ERROR_DOES_NOT_EXIST The operation failed because the provided `uid` value was not found in the storage
117  * \retval PSA_ERROR_BUFFER_TOO_SMALL The operation failed because the data associated with provided `uid` is not the same size as `data_size`
118  * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
119  * \retval PSA_ERROR_INVALID_ARGUMENT The operation failed because one of the provided pointers(`p_data`, `p_data_length`)
120  * is invalid. For example is `NULL` or references memory the caller cannot access
121  */
122 psa_status_t psa_its_get(psa_storage_uid_t uid,
123  uint32_t data_offset,
124  uint32_t data_length,
125  void *p_data);
126 
127 /**
128  * \brief Retrieve the metadata about the provided uid
129  *
130  * \param[in] uid The uid value
131  * \param[out] p_info A pointer to the `psa_storage_info_t` struct that will be populated with the metadata
132  *
133  * \return A status indicating the success/failure of the operation
134  *
135  * \retval PSA_SUCCESS The operation completed successfully
136  * \retval PSA_ERROR_DOES_NOT_EXIST The operation failed because the provided uid value was not found in the storage
137  * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
138  * \retval PSA_ERROR_INVALID_ARGUMENT The operation failed because one of the provided pointers(`p_info`)
139  * is invalid, for example is `NULL` or references memory the caller cannot access
140  */
141 psa_status_t psa_its_get_info(psa_storage_uid_t uid,
142  struct psa_storage_info_t *p_info);
143 
144 /**
145  * \brief Remove the provided key and its associated data from the storage
146  *
147  * \param[in] uid The uid value
148  *
149  * \return A status indicating the success/failure of the operation
150  *
151  * \retval PSA_SUCCESS The operation completed successfully
152  * \retval PSA_ERROR_DOES_NOT_EXIST The operation failed because the provided key value was not found in the storage
153  * \retval PSA_ERROR_NOT_PERMITTED The operation failed because the provided key value was created with PSA_STORAGE_WRITE_ONCE_FLAG
154  * \retval PSA_ERROR_STORAGE_FAILURE The operation failed because the physical storage has failed (Fatal error)
155  */
156 psa_status_t psa_its_remove(psa_storage_uid_t uid);
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif // __PSA_INTERNAL_TRUSTED_STORAGE_H__
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.
psa_status_t psa_its_get(psa_storage_uid_t uid, uint32_t data_offset, uint32_t data_length, void *p_data)
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.
uint64_t psa_storage_uid_t
A type for UIDs used for identifying data.
A container for metadata associated with a specific uid.
uint32_t psa_storage_create_flags_t
Flags used when creating a data entry.
psa_status_t psa_its_set(psa_storage_uid_t uid, uint32_t data_length, const void *p_data, psa_storage_create_flags_t create_flags)
create a new or modify an existing uid/value pair
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.