lifetime.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 TU Dresden
3  * Copyright (C) 2021 HAW Hamburg
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
10 #pragma once
11 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include <stdint.h>
29 
66 typedef uint32_t psa_key_lifetime_t;
67 
106 typedef uint8_t psa_key_persistence_t;
107 
142 typedef uint32_t psa_key_location_t;
143 
155 #define PSA_KEY_LIFETIME_VOLATILE ((psa_key_lifetime_t)0x00000000)
156 
170 #define PSA_KEY_LIFETIME_PERSISTENT ((psa_key_lifetime_t)0x00000001)
171 
177 #define PSA_KEY_PERSISTENCE_VOLATILE ((psa_key_persistence_t)0x00)
178 
184 #define PSA_KEY_PERSISTENCE_DEFAULT ((psa_key_persistence_t)0x01)
185 
191 #define PSA_KEY_PERSISTENCE_READ_ONLY ((psa_key_persistence_t)0xff)
192 
201 #define PSA_KEY_LOCATION_LOCAL_STORAGE ((psa_key_location_t)0x000000)
202 
214 #define PSA_KEY_LOCATION_PRIMARY_SECURE_ELEMENT ((psa_key_location_t)0x000001)
215 
219 #define PSA_KEY_LOCATION_VENDOR_FLAG ((psa_key_location_t)0x800000)
220 
224 #define PSA_KEY_LOCATION_SE_MIN (PSA_KEY_LOCATION_VENDOR_FLAG)
225 
229 #define PSA_KEY_LOCATION_SE_MAX ((psa_key_location_t)0x8000ff)
230 
236 #define PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime) \
237  ((psa_key_persistence_t)((lifetime) & 0x000000ff))
238 
244 #define PSA_KEY_LIFETIME_GET_LOCATION(lifetime) \
245  ((psa_key_location_t)((lifetime) >> 8))
246 
262 #define PSA_KEY_LIFETIME_IS_VOLATILE(lifetime) \
263  (PSA_KEY_LIFETIME_GET_PERSISTENCE(lifetime) == PSA_KEY_PERSISTENCE_VOLATILE)
264 
273 #define PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(persistence, location) \
274  ((location) << 8 | (persistence))
275 
276 #ifdef __cplusplus
277 }
278 #endif
279 
uint8_t psa_key_persistence_t
Encoding of key persistence levels.
Definition: lifetime.h:106
uint32_t psa_key_location_t
Encoding of key location indicators.
Definition: lifetime.h:142
uint32_t psa_key_lifetime_t
Encoding of key lifetimes.
Definition: lifetime.h:66