61 #ifndef PSA_CRYPTO_STRUCT_H
62 #define PSA_CRYPTO_STRUCT_H
94 #define PSA_HASH_OPERATION_INIT { 0, { 0 } }
119 #define PSA_CIPHER_OPERATION_INIT { 0, 0, 0, 0, { 0 } }
144 #define PSA_MAC_OPERATION_INIT { 0, 0, 0, { 0 } }
177 #define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}}
184 #if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF)
189 #if PSA_HASH_MAX_SIZE > 0xff
190 #error "PSA_HASH_MAX_SIZE does not fit in uint8_t"
202 #if defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) || \
203 defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS)
215 #if PSA_HASH_MAX_SIZE > 0xff
216 #error "PSA_HASH_MAX_SIZE does not fit in uint8_t"
252 #if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF)
255 #if defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) || \
256 defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS)
263 #define PSA_KEY_DERIVATION_OPERATION_INIT { 0, 0, 0, { 0 } }
279 #define PSA_KEY_POLICY_INIT { 0, 0, 0 }
291 #define PSA_KEY_BITS_TOO_LARGE ( ( psa_key_bits_t ) -1 )
297 #define PSA_MAX_KEY_BITS 0xfff8
308 #define MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER \
309 ( (psa_key_attributes_flag_t) 0x0001 )
313 #define MBEDTLS_PSA_KA_MASK_EXTERNAL_ONLY ( \
314 MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER | \
319 #define MBEDTLS_PSA_KA_MASK_DUAL_USE ( \
332 #define PSA_CORE_KEY_ATTRIBUTES_INIT { PSA_KEY_TYPE_NONE, 0, \
333 PSA_KEY_LIFETIME_VOLATILE, \
334 MBEDTLS_SVC_KEY_ID_INIT, \
335 PSA_KEY_POLICY_INIT, 0 }
340 #if defined(MBEDTLS_PSA_CRYPTO_SE_C)
347 #if defined(MBEDTLS_PSA_CRYPTO_SE_C)
348 #define PSA_KEY_ATTRIBUTES_INIT { PSA_CORE_KEY_ATTRIBUTES_INIT, 0, NULL, 0 }
350 #define PSA_KEY_ATTRIBUTES_INIT { PSA_CORE_KEY_ATTRIBUTES_INIT, NULL, 0 }
362 psa_key_lifetime_t lifetime = attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(lifetime);
364 attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(
id) = key;
368 attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(lifetime) =
378 return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(
id) );
381 #ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
385 attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(
id).MBEDTLS_PRIVATE(owner) = owner;
392 attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(lifetime) = lifetime;
395 #ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
396 attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(
id).MBEDTLS_PRIVATE(key_id) = 0;
398 attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(
id) = 0;
406 return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(lifetime) );
422 attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(usage) = usage_flags;
428 return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(usage) );
434 attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(alg) = alg;
440 return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(policy).MBEDTLS_PRIVATE(alg) );
448 size_t data_length );
453 if( attributes->MBEDTLS_PRIVATE(domain_parameters) == NULL )
456 attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(type) = type;
471 return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(type) );
480 attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(bits) = (
psa_key_bits_t) bits;
486 return( attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(bits) );
static void psa_set_key_usage_flags(psa_key_attributes_t *attributes, psa_key_usage_t usage_flags)
This file contains the AEAD-ChaCha20-Poly1305 definitions and functions.
static psa_key_lifetime_t psa_get_key_lifetime(const psa_key_attributes_t *attributes)
#define PSA_MAC_OPERATION_INIT
static struct psa_aead_operation_s psa_aead_operation_init(void)
psa_tls12_prf_key_derivation_state_t
static void psa_set_key_id(psa_key_attributes_t *attributes, mbedtls_svc_key_id_t key)
#define MBEDTLS_PRIVATE(member)
#define PSA_CIPHER_OPERATION_INIT
This file contains CMAC definitions and functions.
#define PSA_KEY_ATTRIBUTES_INIT
#define PSA_KEY_LIFETIME_IS_VOLATILE(lifetime)
#define PSA_KEY_USAGE_VERIFY_MESSAGE
static struct psa_key_derivation_s psa_key_derivation_operation_init(void)
#define PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(persistence, location)
#define PSA_KEY_LIFETIME_GET_LOCATION(lifetime)
#define PSA_KEY_USAGE_SIGN_MESSAGE
static void mbedtls_set_key_owner_id(psa_key_attributes_t *attributes, mbedtls_key_owner_id_t owner)
uint16_t psa_key_attributes_flag_t
#define PSA_HASH_MAX_SIZE
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Macro wrapper for struct's memebrs.
#define PSA_KEY_LIFETIME_PERSISTENT
uint32_t psa_key_usage_t
Encoding of permitted usage on a key.
uint16_t psa_key_type_t
Encoding of a key type.
#define PSA_KEY_POLICY_INIT
#define PSA_KEY_DERIVATION_OPERATION_INIT
Build-time configuration info.
static psa_algorithm_t psa_get_key_algorithm(const psa_key_attributes_t *attributes)
#define PSA_AEAD_OPERATION_INIT
#define PSA_KEY_BITS_TOO_LARGE
static mbedtls_svc_key_id_t psa_get_key_id(const psa_key_attributes_t *attributes)
static psa_key_usage_t psa_get_key_usage_flags(const psa_key_attributes_t *attributes)
#define PSA_HASH_OPERATION_INIT
static struct psa_mac_operation_s psa_mac_operation_init(void)
psa_status_t psa_set_key_domain_parameters(psa_key_attributes_t *attributes, psa_key_type_t type, const uint8_t *data, size_t data_length)
This file contains GCM definitions and functions.
static struct psa_key_attributes_s psa_key_attributes_init(void)
struct psa_tls12_prf_key_derivation_s psa_tls12_prf_key_derivation_t
static size_t psa_get_key_bits(const psa_key_attributes_t *attributes)
static struct psa_cipher_operation_s psa_cipher_operation_init(void)
static void psa_set_key_bits(psa_key_attributes_t *attributes, size_t bits)
static void psa_set_key_lifetime(psa_key_attributes_t *attributes, psa_key_lifetime_t lifetime)
uint32_t psa_key_lifetime_t
static void psa_extend_key_usage_flags(psa_key_usage_t *usage_flags)
int32_t psa_status_t
Function return status.
static void psa_set_key_algorithm(psa_key_attributes_t *attributes, psa_algorithm_t alg)
static psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes)
static void psa_set_key_type(psa_key_attributes_t *attributes, psa_key_type_t type)
#define PSA_KEY_USAGE_VERIFY_HASH
static struct psa_key_policy_s psa_key_policy_init(void)
uint64_t psa_key_slot_number_t
#define PSA_KEY_USAGE_SIGN_HASH
This file provides an API for the CCM authenticated encryption mode for block ciphers.
static struct psa_hash_operation_s psa_hash_operation_init(void)