lifetime.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2024 TU Dresden
3  * SPDX-FileCopyrightText: 2021 HAW Hamburg
4  * SPDX-License-Identifier: LGPL-2.1-only
5  */
6 
7 #pragma once
8 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #include <stdint.h>
26 
63 typedef uint32_t psa_key_lifetime_t;
64 
103 typedef uint8_t psa_key_persistence_t;
104 
139 typedef uint32_t psa_key_location_t;
140 
152 #define PSA_KEY_LIFETIME_VOLATILE ((psa_key_lifetime_t)0x00000000)
153 
167 #define PSA_KEY_LIFETIME_PERSISTENT ((psa_key_lifetime_t)0x00000001)
168 
174 #define PSA_KEY_PERSISTENCE_VOLATILE ((psa_key_persistence_t)0x00)
175 
181 #define PSA_KEY_PERSISTENCE_DEFAULT ((psa_key_persistence_t)0x01)
182 
188 #define PSA_KEY_PERSISTENCE_READ_ONLY ((psa_key_persistence_t)0xff)
189 
198 #define PSA_KEY_LOCATION_LOCAL_STORAGE ((psa_key_location_t)0x000000)
199 
211 #define PSA_KEY_LOCATION_PRIMARY_SECURE_ELEMENT ((psa_key_location_t)0x000001)
212 
216 #define PSA_KEY_LOCATION_VENDOR_FLAG ((psa_key_location_t)0x800000)
217 
221 #define PSA_KEY_LOCATION_SE_MIN (PSA_KEY_LOCATION_VENDOR_FLAG)
222 
226 #define PSA_KEY_LOCATION_SE_MAX ((psa_key_location_t)0x8000ff)
227 
233 #define PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime) \
234  ((psa_key_persistence_t)((lifetime) & 0x000000ff))
235 
241 #define PSA_KEY_LIFETIME_GET_LOCATION(lifetime) \
242  ((psa_key_location_t)((lifetime) >> 8))
243 
259 #define PSA_KEY_LIFETIME_IS_VOLATILE(lifetime) \
260  (PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime) == PSA_KEY_PERSISTENCE_VOLATILE)
261 
270 #define PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(persistence, location) \
271  ((location) << 8 | (persistence))
272 
273 #ifdef __cplusplus
274 }
275 #endif
276 
uint8_t psa_key_persistence_t
Encoding of key persistence levels.
Definition: lifetime.h:103
uint32_t psa_key_location_t
Encoding of key location indicators.
Definition: lifetime.h:139
uint32_t psa_key_lifetime_t
Encoding of key lifetimes.
Definition: lifetime.h:63