28#ifndef PSA_CRYPTO_EXTRA_H
29#define PSA_CRYPTO_EXTRA_H
40#define PSA_CRYPTO_ITS_RANDOM_SEED_UID 0xFFFFFF52
66static inline void psa_set_key_enrollment_algorithm(
70 attributes->core.policy.alg2 = alg2;
82 return( attributes->core.policy.alg2 );
85#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
136static inline void psa_set_key_slot_number(
140 attributes->core.flags |= MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER;
141 attributes->slot_number = slot_number;
150static inline void psa_clear_key_slot_number(
153 attributes->core.flags &= ~MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER;
333#define PSA_KEY_TYPE_DSA_PUBLIC_KEY ((psa_key_type_t)0x4002)
351#define PSA_KEY_TYPE_DSA_KEY_PAIR ((psa_key_type_t)0x7002)
354#define PSA_KEY_TYPE_IS_DSA(type) \
355 (PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) == PSA_KEY_TYPE_DSA_PUBLIC_KEY)
357#define PSA_ALG_DSA_BASE ((psa_algorithm_t)0x06000400)
372#define PSA_ALG_DSA(hash_alg) \
373 (PSA_ALG_DSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
374#define PSA_ALG_DETERMINISTIC_DSA_BASE ((psa_algorithm_t)0x06000500)
375#define PSA_ALG_DSA_DETERMINISTIC_FLAG PSA_ALG_ECDSA_DETERMINISTIC_FLAG
390#define PSA_ALG_DETERMINISTIC_DSA(hash_alg) \
391 (PSA_ALG_DETERMINISTIC_DSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
392#define PSA_ALG_IS_DSA(alg) \
393 (((alg) & ~PSA_ALG_HASH_MASK & ~PSA_ALG_DSA_DETERMINISTIC_FLAG) == \
395#define PSA_ALG_DSA_IS_DETERMINISTIC(alg) \
396 (((alg) & PSA_ALG_DSA_DETERMINISTIC_FLAG) != 0)
397#define PSA_ALG_IS_DETERMINISTIC_DSA(alg) \
398 (PSA_ALG_IS_DSA(alg) && PSA_ALG_DSA_IS_DETERMINISTIC(alg))
399#define PSA_ALG_IS_RANDOMIZED_DSA(alg) \
400 (PSA_ALG_IS_DSA(alg) && !PSA_ALG_DSA_IS_DETERMINISTIC(alg))
405#undef PSA_ALG_IS_HASH_AND_SIGN
406#define PSA_ALG_IS_HASH_AND_SIGN(alg) \
407 (PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || \
408 PSA_ALG_IS_DSA(alg) || PSA_ALG_IS_ECDSA(alg))
422#define PSA_DH_FAMILY_CUSTOM ((psa_dh_family_t) 0x7e)
523 size_t *data_length);
550#define PSA_KEY_DOMAIN_PARAMETERS_SIZE(key_type, key_bits) \
551 (PSA_KEY_TYPE_IS_RSA(key_type) ? sizeof(int) : \
552 PSA_KEY_TYPE_IS_DH(key_type) ? PSA_DH_KEY_DOMAIN_PARAMETERS_SIZE(key_bits) : \
553 PSA_KEY_TYPE_IS_DSA(key_type) ? PSA_DSA_KEY_DOMAIN_PARAMETERS_SIZE(key_bits) : \
555#define PSA_DH_KEY_DOMAIN_PARAMETERS_SIZE(key_bits) \
556 (4 + (PSA_BITS_TO_BYTES(key_bits) + 5) * 3 )
557#define PSA_DSA_KEY_DOMAIN_PARAMETERS_SIZE(key_bits) \
558 (4 + (PSA_BITS_TO_BYTES(key_bits) + 5) * 2 + 34 )
567#if defined(MBEDTLS_ECP_C)
649 size_t byte_length );
PSA cryptography module: Backward compatibility aliases.
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.
psa_status_t psa_get_key_domain_parameters(const psa_key_attributes_t *attributes, uint8_t *data, size_t data_size, size_t *data_length)
Get domain parameters for a key.
#define PSA_ECC_FAMILY_MONTGOMERY
Curve25519 and Curve448.
#define PSA_ECC_FAMILY_SECP_R1
SEC random curves over prime fields.
#define PSA_ECC_FAMILY_SECP_K1
SEC Koblitz curves over prime fields.
uint16_t psa_key_type_t
Encoding of a key type.
#define PSA_ECC_FAMILY_BRAINPOOL_P_R1
Brainpool P random curves.
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
uint8_t psa_ecc_family_t
The type of PSA elliptic curve family identifiers.
int32_t psa_status_t
Function return status.
uint32_t psa_key_id_t
Encoding of identifiers of persistent keys.
mbedtls_ecp_group_id
Domain-parameter identifiers: curve, subgroup, and generator.
@ MBEDTLS_ECP_DP_SECP192K1
@ MBEDTLS_ECP_DP_SECP384R1
@ MBEDTLS_ECP_DP_CURVE448
@ MBEDTLS_ECP_DP_CURVE25519
@ MBEDTLS_ECP_DP_SECP256K1
@ MBEDTLS_ECP_DP_SECP224R1
@ MBEDTLS_ECP_DP_SECP521R1
@ MBEDTLS_ECP_DP_SECP224K1
@ MBEDTLS_ECP_DP_SECP192R1
@ MBEDTLS_ECP_DP_SECP256R1
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 ...
This file provides an API for Elliptic Curves over GF(P) (ECP).
Statistics about resource consumption related to the PSA keystore.
size_t half_filled_slots
Number of slots which are occupied, but do not contain key material yet.
size_t volatile_slots
Number of slots containing key material for a volatile key.
size_t external_slots
Number of slots containing a reference to a key in a secure element.
size_t locked_slots
Number of slots that are locked.
psa_key_id_t max_open_internal_key_id
Largest key id value among open keys in internal persistent storage.
psa_key_id_t max_open_external_key_id
Largest key id value among open keys in secure elements.
size_t empty_slots
Number of slots that are not used for anything.
size_t persistent_slots
Number of slots containing key material for a key which is in internal persistent storage.
size_t cache_slots
Number of slots that contain cache data.