53#ifndef PSA_CRYPTO_STRUCT_H
54#define PSA_CRYPTO_STRUCT_H
62#if !defined(MBEDTLS_CONFIG_FILE)
65#include MBEDTLS_CONFIG_FILE
96#if defined(MBEDTLS_MD2_C)
99#if defined(MBEDTLS_MD4_C)
102#if defined(MBEDTLS_MD5_C)
105#if defined(MBEDTLS_RIPEMD160_C)
108#if defined(MBEDTLS_SHA1_C)
111#if defined(MBEDTLS_SHA256_C)
114#if defined(MBEDTLS_SHA512_C)
120#define PSA_HASH_OPERATION_INIT {0, {0}}
127#if defined(MBEDTLS_MD_C)
133 uint8_t opad[PSA_HMAC_MAX_HASH_BLOCK_SIZE];
134} psa_hmac_internal_data;
140 unsigned int key_set : 1;
141 unsigned int iv_required : 1;
142 unsigned int iv_set : 1;
143 unsigned int has_input : 1;
144 unsigned int is_sign : 1;
149#if defined(MBEDTLS_MD_C)
150 psa_hmac_internal_data hmac;
152#if defined(MBEDTLS_CMAC_C)
158#define PSA_MAC_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, {0}}
168 unsigned int key_set : 1;
169 unsigned int iv_required : 1;
170 unsigned int iv_set : 1;
171 unsigned int mbedtls_in_use : 1;
182#define PSA_CIPHER_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, {0}}
192 unsigned int key_set : 1;
193 unsigned int iv_set : 1;
203#define PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, 0, {0}}
210#if defined(MBEDTLS_MD_C)
215 psa_hmac_internal_data hmac;
218#if PSA_HASH_MAX_SIZE > 0xff
219#error "PSA_HASH_MAX_SIZE does not fit in uint8_t"
221 uint8_t offset_in_block;
222 uint8_t block_number;
223 unsigned int state : 2;
224 unsigned int info_set : 1;
225} psa_hkdf_key_derivation_t;
228#if defined(MBEDTLS_MD_C)
231 TLS12_PRF_STATE_INIT,
232 TLS12_PRF_STATE_SEED_SET,
233 TLS12_PRF_STATE_KEY_SET,
234 TLS12_PRF_STATE_LABEL_SET,
235 TLS12_PRF_STATE_OUTPUT
236} psa_tls12_prf_key_derivation_state_t;
238typedef struct psa_tls12_prf_key_derivation_s
240#if PSA_HASH_MAX_SIZE > 0xff
241#error "PSA_HASH_MAX_SIZE does not fit in uint8_t"
246 uint8_t left_in_block;
249 uint8_t block_number;
251 psa_tls12_prf_key_derivation_state_t state;
257 psa_hmac_internal_data hmac;
262} psa_tls12_prf_key_derivation_t;
268 unsigned int can_output_key : 1;
274#if defined(MBEDTLS_MD_C)
275 psa_hkdf_key_derivation_t hkdf;
276 psa_tls12_prf_key_derivation_t tls12_prf;
282#define PSA_KEY_DERIVATION_OPERATION_INIT {0, 0, 0, {0}}
297#define PSA_KEY_POLICY_INIT {0, 0, 0}
306typedef uint16_t psa_key_bits_t;
309#define PSA_KEY_BITS_TOO_LARGE ( (psa_key_bits_t) ( -1 ) )
315#define PSA_MAX_KEY_BITS 0xfff8
326#define MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER \
327 ( (psa_key_attributes_flag_t) 0x0001 )
331#define MBEDTLS_PSA_KA_MASK_EXTERNAL_ONLY ( \
332 MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER | \
337#define MBEDTLS_PSA_KA_MASK_DUAL_USE ( \
350#define PSA_CORE_KEY_ATTRIBUTES_INIT {PSA_KEY_TYPE_NONE, 0, PSA_KEY_LIFETIME_VOLATILE, MBEDTLS_SVC_KEY_ID_INIT, PSA_KEY_POLICY_INIT, 0}
355#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
358 void *domain_parameters;
359 size_t domain_parameters_size;
362#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
363#define PSA_KEY_ATTRIBUTES_INIT {PSA_CORE_KEY_ATTRIBUTES_INIT, 0, NULL, 0}
365#define PSA_KEY_ATTRIBUTES_INIT {PSA_CORE_KEY_ATTRIBUTES_INIT, NULL, 0}
379 attributes->core.id = key;
383 attributes->core.lifetime =
393 return( attributes->core.id );
396#ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
398 mbedtls_key_owner_id_t owner )
400 attributes->core.id.owner = owner;
407 attributes->core.lifetime = lifetime;
410#ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
411 attributes->core.id.key_id = 0;
413 attributes->core.id = 0;
421 return( attributes->core.lifetime );
427 attributes->core.policy.usage = usage_flags;
433 return( attributes->core.policy.usage );
439 attributes->core.policy.alg = alg;
445 return( attributes->core.policy.alg );
458 if( attributes->domain_parameters == NULL )
461 attributes->core.type = type;
476 return( attributes->core.type );
482 if( bits > PSA_MAX_KEY_BITS )
483 attributes->core.bits = PSA_KEY_BITS_TOO_LARGE;
485 attributes->core.bits = (psa_key_bits_t) bits;
488static inline size_t psa_get_key_bits(
491 return( attributes->core.bits );
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
This file contains CMAC definitions and functions.
Configuration options (set of defines)
#define PSA_HASH_MAX_SIZE
Maximum size of a hash.
uint16_t psa_key_attributes_flag_t
A mask of flags that can be stored in key attributes.
This file contains GCM definitions and functions.
#define PSA_MAC_OPERATION_INIT
This macro returns a suitable initializer for a MAC operation object of type psa_mac_operation_t.
#define PSA_AEAD_OPERATION_INIT
This macro returns a suitable initializer for an AEAD operation object of type psa_aead_operation_t.
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)
Set domain parameters for a key.
#define PSA_KEY_ATTRIBUTES_INIT
This macro returns a suitable initializer for a key attribute structure of type psa_key_attributes_t.
#define PSA_CIPHER_OPERATION_INIT
This macro returns a suitable initializer for a cipher operation object of type psa_cipher_operation_...
uint16_t psa_key_type_t
Encoding of a key type.
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
int32_t psa_status_t
Function return status.
#define PSA_HASH_OPERATION_INIT
This macro returns a suitable initializer for a hash operation object of type psa_hash_operation_t.
#define PSA_KEY_DERIVATION_OPERATION_INIT
This macro returns a suitable initializer for a key derivation operation object of type psa_key_deriv...
#define PSA_KEY_LIFETIME_PERSISTENT
The default lifetime for persistent keys.
#define PSA_KEY_LIFETIME_GET_LOCATION(lifetime)
Get the location (see psa_key_location_t) from a psa_key_lifetime_t.
#define PSA_KEY_LIFETIME_IS_VOLATILE(lifetime)
Whether a key lifetime indicates that the key is volatile.
uint32_t psa_key_lifetime_t
Encoding of key lifetimes.
psa_key_id_t mbedtls_svc_key_id_t
Identifier for persistent keys.
#define PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(persistence, location)
Construct a lifetime from a persistence level and a location.
uint32_t psa_key_usage_t
Encoding of permitted usage on a key.
uint64_t psa_key_slot_number_t
An internal designation of a key slot between the core part of the PSA Crypto implementation and the ...
MD4 message digest algorithm (hash function)
MD5 message digest algorithm (hash function)
This file contains SHA-1 definitions and functions.
MD2 message digest algorithm (hash function)
This file contains the generic message-digest wrapper.
RIPE MD-160 message digest.
This file contains SHA-224 and SHA-256 definitions and functions.
This file contains SHA-384 and SHA-512 definitions and functions.
RIPEMD-160 context structure.
The SHA-1 context structure.
The SHA-256 context structure.
The SHA-512 context structure.
void * ctx
Context structure for the assigned driver, when id is not zero.
unsigned int id
Unique ID indicating which driver got assigned to do the operation.