23 #ifndef PSA_CRYPTO_STRUCT_H 24 #define PSA_CRYPTO_STRUCT_H 52 #define PSA_HASH_OPERATION_INIT {0} 64 #define PSA_MAC_OPERATION_INIT {0} 76 #define PSA_CIPHER_OPERATION_INIT {0} 88 #define PSA_AEAD_OPERATION_INIT {0} 100 #define PSA_KEY_DERIVATION_OPERATION_INIT {0} 115 #define PSA_KEY_POLICY_INIT {0, 0, 0} 124 typedef uint16_t psa_key_bits_t;
127 #define PSA_KEY_BITS_TOO_LARGE ( (psa_key_bits_t) ( -1 ) ) 133 #define PSA_MAX_KEY_BITS 0xfff8 142 typedef uint16_t psa_key_attributes_flag_t;
144 #define MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER \ 145 ( (psa_key_attributes_flag_t) 0x0001 ) 149 #define MBEDTLS_PSA_KA_MASK_EXTERNAL_ONLY ( \ 150 MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER | \ 155 #define MBEDTLS_PSA_KA_MASK_DUAL_USE ( \ 165 psa_key_attributes_flag_t flags;
168 #define PSA_CORE_KEY_ATTRIBUTES_INIT {0, 0, PSA_KEY_ID_INIT, PSA_KEY_POLICY_INIT, 0, 0} 173 #if defined(MBEDTLS_PSA_CRYPTO_SE_C) 176 void *domain_parameters;
177 size_t domain_parameters_size;
180 #if defined(MBEDTLS_PSA_CRYPTO_SE_C) 181 #define PSA_KEY_ATTRIBUTES_INIT {PSA_CORE_KEY_ATTRIBUTES_INIT, 0, NULL, 0} 183 #define PSA_KEY_ATTRIBUTES_INIT {PSA_CORE_KEY_ATTRIBUTES_INIT, NULL, 0} 195 attributes->core.id = id;
203 return( attributes->core.id );
209 attributes->core.lifetime = lifetime;
212 #ifdef MBEDTLS_PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER 213 attributes->core.id.key_id = 0;
214 attributes->core.id.owner = 0;
216 attributes->core.id = 0;
224 return( attributes->core.lifetime );
230 attributes->core.policy.usage = usage_flags;
236 return( attributes->core.policy.usage );
242 attributes->core.policy.alg = alg;
248 return( attributes->core.policy.alg );
261 if( attributes->domain_parameters == NULL )
264 attributes->core.type = type;
279 return( attributes->core.type );
285 if( bits > PSA_MAX_KEY_BITS )
286 attributes->core.bits = PSA_KEY_BITS_TOO_LARGE;
288 attributes->core.bits = (psa_key_bits_t) bits;
294 return( attributes->core.bits );
static void psa_set_key_id(psa_key_attributes_t *attributes, psa_key_id_t id)
Declare a key as persistent and set its key identifier.
static psa_key_derivation_operation_t psa_key_derivation_operation_init(void)
Return an initial value for a key derivation operation object.
static void psa_set_key_bits(psa_key_attributes_t *attributes, size_t bits)
Declare the size of a key.
#define PSA_KEY_LIFETIME_VOLATILE
The default lifetime for volatile keys.
uint32_t psa_key_id_t
Encoding of identifiers of persistent keys.
static psa_algorithm_t psa_get_key_algorithm(const psa_key_attributes_t *attributes)
Retrieve the algorithm policy from key attributes.
static void psa_set_key_usage_flags(psa_key_attributes_t *attributes, psa_key_usage_t usage_flags)
Declare usage flags for a key.
static void psa_set_key_lifetime(psa_key_attributes_t *attributes, psa_key_lifetime_t lifetime)
Set the location of a persistent key.
static psa_hash_operation_t psa_hash_operation_init(void)
Return an initial value for a hash operation object.
static psa_key_lifetime_t psa_get_key_lifetime(const psa_key_attributes_t *attributes)
Retrieve the lifetime from key attributes.
static void psa_set_key_type(psa_key_attributes_t *attributes, psa_key_type_t type)
Declare the type of a key.
static psa_key_id_t psa_get_key_id(const psa_key_attributes_t *attributes)
Retrieve the key identifier from key attributes.
static size_t psa_get_key_bits(const psa_key_attributes_t *attributes)
Retrieve the key size from key attributes.
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.
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 ...
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
#define PSA_KEY_LIFETIME_PERSISTENT
The default lifetime for persistent keys.
static psa_cipher_operation_t psa_cipher_operation_init(void)
Return an initial value for a cipher operation object.
uint32_t psa_key_usage_t
Encoding of permitted usage on a key.
static void psa_set_key_algorithm(psa_key_attributes_t *attributes, psa_algorithm_t alg)
Declare the permitted algorithm policy for a key.
uint16_t psa_key_type_t
Encoding of a key type.
static psa_aead_operation_t psa_aead_operation_init(void)
Return an initial value for an AEAD operation object.
static psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes)
Retrieve the key type from key attributes.
static psa_key_usage_t psa_get_key_usage_flags(const psa_key_attributes_t *attributes)
Retrieve the usage flags from key attributes.
static psa_key_attributes_t psa_key_attributes_init(void)
Return an initial value for a key attributes structure.
uint32_t psa_key_lifetime_t
Encoding of key lifetimes.
static psa_mac_operation_t psa_mac_operation_init(void)
Return an initial value for a MAC operation object.
int32_t psa_status_t
Function return status.