Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
protected_storage.h
Go to the documentation of this file.
1/* Copyright (c) 2024 Nordic Semiconductor
2 * SPDX-License-Identifier: Apache-2.0
3 */
4#ifndef PSA_PROTECTED_STORAGE_H
5#define PSA_PROTECTED_STORAGE_H
6
13#ifdef CONFIG_SECURE_STORAGE_PS_IMPLEMENTATION_ITS
15#define ITS_UID (secure_storage_its_uid_t){.uid = uid, \
16 .caller_id = SECURE_STORAGE_ITS_CALLER_PSA_PS}
17#else
19#endif
22#include <psa/storage_common.h>
23
24#define PSA_PS_API_VERSION_MAJOR 1
25#define PSA_PS_API_VERSION_MINOR 0
26
47static ALWAYS_INLINE
50 const void *p_data, psa_storage_create_flags_t create_flags)
51{
52#ifdef CONFIG_SECURE_STORAGE_PS_IMPLEMENTATION_ITS
53 return secure_storage_its_set(ITS_UID, data_length, p_data, create_flags);
54#else
55 return secure_storage_ps_set(uid, data_length, p_data, create_flags);
56#endif
57}
58
80static ALWAYS_INLINE
83 size_t data_size, void *p_data, size_t *p_data_length)
84{
85#ifdef CONFIG_SECURE_STORAGE_PS_IMPLEMENTATION_ITS
86 return secure_storage_its_get(ITS_UID, data_offset, data_size, p_data, p_data_length);
87#else
88 return secure_storage_ps_get(uid, data_offset, data_size, p_data, p_data_length);
89#endif
90}
91
108static ALWAYS_INLINE
111{
112#ifdef CONFIG_SECURE_STORAGE_PS_IMPLEMENTATION_ITS
113 return secure_storage_its_get_info(ITS_UID, p_info);
114#else
115 return secure_storage_ps_get_info(uid, p_info);
116#endif
117}
118
136static ALWAYS_INLINE
139{
140#ifdef CONFIG_SECURE_STORAGE_PS_IMPLEMENTATION_ITS
141 return secure_storage_its_remove(ITS_UID);
142#else
143 return secure_storage_ps_remove(uid);
144#endif
145}
146
170static ALWAYS_INLINE
173 psa_storage_create_flags_t create_flags)
174{
175#ifdef CONFIG_SECURE_STORAGE_PS_SUPPORTS_SET_EXTENDED
176 return secure_storage_ps_create(uid, capacity, create_flags);
177#else
179#endif
180}
181
208static ALWAYS_INLINE
211 size_t data_length, const void *p_data)
212{
213#ifdef CONFIG_SECURE_STORAGE_PS_SUPPORTS_SET_EXTENDED
214 return secure_storage_ps_set_extended(uid, data_offset, data_length, p_data);
215#else
217#endif
218}
219
227static ALWAYS_INLINE
230{
231 uint32_t flags = 0;
232
233#ifdef CONFIG_SECURE_STORAGE_PS_SUPPORTS_SET_EXTENDED
235#endif
236 return flags;
237}
238
239#undef ITS_UID
240
241#endif
#define ALWAYS_INLINE
Definition common.h:129
The secure storage ITS implementation.
psa_status_t secure_storage_its_remove(secure_storage_its_uid_t uid)
See psa_its_remove(), to which this function is analogous.
psa_status_t secure_storage_its_set(secure_storage_its_uid_t uid, size_t data_length, const void *p_data, psa_storage_create_flags_t create_flags)
See psa_its_set(), to which this function is analogous.
psa_status_t secure_storage_its_get(secure_storage_its_uid_t uid, size_t data_offset, size_t data_size, void *p_data, size_t *p_data_length)
See psa_its_get(), to which this function is analogous.
psa_status_t secure_storage_its_get_info(secure_storage_its_uid_t uid, struct psa_storage_info_t *p_info)
See psa_its_get_info(), to which this function is analogous.
flags
Definition parser.h:96
psa_status_t psa_ps_remove(psa_storage_uid_t uid)
Removes the provided uid and its associated data.
Definition protected_storage.h:138
psa_status_t psa_ps_set_extended(psa_storage_uid_t uid, size_t data_offset, size_t data_length, const void *p_data)
Writes part of the data associated with the provided uid.
Definition protected_storage.h:210
psa_status_t psa_ps_get(psa_storage_uid_t uid, size_t data_offset, size_t data_size, void *p_data, size_t *p_data_length)
Retrieves data associated with the provided uid.
Definition protected_storage.h:82
uint32_t psa_ps_get_support(void)
Lists optional features.
Definition protected_storage.h:229
psa_status_t psa_ps_create(psa_storage_uid_t uid, size_t capacity, psa_storage_create_flags_t create_flags)
Reserves storage for the provided uid.
Definition protected_storage.h:172
psa_status_t psa_ps_set(psa_storage_uid_t uid, size_t data_length, const void *p_data, psa_storage_create_flags_t create_flags)
Creates a new or modifies an existing entry.
Definition protected_storage.h:49
psa_status_t psa_ps_get_info(psa_storage_uid_t uid, struct psa_storage_info_t *p_info)
Retrieves the metadata of a given entry.
Definition protected_storage.h:110
The secure storage PS implementation.
psa_status_t secure_storage_ps_get(const psa_storage_uid_t uid, size_t data_offset, size_t data_length, void *p_data, size_t *p_data_length)
See psa_ps_get(), to which this function is analogous.
psa_status_t secure_storage_ps_set(const psa_storage_uid_t uid, size_t data_length, const void *p_data, psa_storage_create_flags_t create_flags)
See psa_ps_set(), to which this function is analogous.
psa_status_t secure_storage_ps_set_extended(psa_storage_uid_t uid, size_t data_offset, size_t data_length, const void *p_data)
See psa_ps_set_extended(), to which this function is analogous.
psa_status_t secure_storage_ps_create(psa_storage_uid_t uid, size_t capacity, psa_storage_create_flags_t create_flags)
See psa_ps_create(), to which this function is analogous.
psa_status_t secure_storage_ps_remove(const psa_storage_uid_t uid)
See psa_ps_remove(), to which this function is analogous.
psa_status_t secure_storage_ps_get_info(const psa_storage_uid_t uid, struct psa_storage_info_t *p_info)
See psa_ps_get_info(), to which this function is analogous.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Common definitions of the PSA Secure Storage API.
uint32_t psa_storage_create_flags_t
Flags used when creating an entry.
Definition storage_common.h:26
#define PSA_STORAGE_SUPPORT_SET_EXTENDED
Flag indicating that psa_ps_create() and psa_ps_set_extended() are supported.
Definition storage_common.h:48
uint64_t psa_storage_uid_t
UID type for identifying entries.
Definition storage_common.h:23
Metadata associated with a specific entry.
Definition storage_common.h:38
int32_t psa_status_t
Definition error.h:13
#define PSA_ERROR_NOT_SUPPORTED
Definition error.h:19