28 #ifndef PSA_CRYPTO_EXTRA_H 29 #define PSA_CRYPTO_EXTRA_H 31 #include "mbedtls/platform_util.h" 33 #include "crypto_compat.h" 40 #define PSA_CRYPTO_ITS_RANDOM_SEED_UID 0xFFFFFF52 70 attributes->core.policy.alg2 = alg2;
82 return( attributes->core.policy.alg2 );
85 #if defined(MBEDTLS_PSA_CRYPTO_SE_C) 136 static inline void psa_set_key_slot_number(
140 attributes->core.flags |= MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER;
141 attributes->slot_number = slot_number;
150 static inline void psa_clear_key_slot_number(
153 attributes->core.flags &= ~MBEDTLS_PSA_KA_FLAG_HAS_SLOT_NUMBER;
209 void mbedtls_psa_crypto_free(
void );
318 psa_status_t mbedtls_psa_inject_entropy(
const uint8_t *seed,
332 #define PSA_KEY_TYPE_DSA_PUBLIC_KEY ((psa_key_type_t)0x4002) 350 #define PSA_KEY_TYPE_DSA_KEY_PAIR ((psa_key_type_t)0x7002) 353 #define PSA_KEY_TYPE_IS_DSA(type) \ 354 (PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) == PSA_KEY_TYPE_DSA_PUBLIC_KEY) 356 #define PSA_ALG_DSA_BASE ((psa_algorithm_t)0x06000400) 371 #define PSA_ALG_DSA(hash_alg) \ 372 (PSA_ALG_DSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK)) 373 #define PSA_ALG_DETERMINISTIC_DSA_BASE ((psa_algorithm_t)0x06000500) 374 #define PSA_ALG_DSA_DETERMINISTIC_FLAG PSA_ALG_ECDSA_DETERMINISTIC_FLAG 389 #define PSA_ALG_DETERMINISTIC_DSA(hash_alg) \ 390 (PSA_ALG_DETERMINISTIC_DSA_BASE | ((hash_alg) & PSA_ALG_HASH_MASK)) 391 #define PSA_ALG_IS_DSA(alg) \ 392 (((alg) & ~PSA_ALG_HASH_MASK & ~PSA_ALG_DSA_DETERMINISTIC_FLAG) == \ 394 #define PSA_ALG_DSA_IS_DETERMINISTIC(alg) \ 395 (((alg) & PSA_ALG_DSA_DETERMINISTIC_FLAG) != 0) 396 #define PSA_ALG_IS_DETERMINISTIC_DSA(alg) \ 397 (PSA_ALG_IS_DSA(alg) && PSA_ALG_DSA_IS_DETERMINISTIC(alg)) 398 #define PSA_ALG_IS_RANDOMIZED_DSA(alg) \ 399 (PSA_ALG_IS_DSA(alg) && !PSA_ALG_DSA_IS_DETERMINISTIC(alg)) 404 #undef PSA_ALG_IS_HASH_AND_SIGN 405 #define PSA_ALG_IS_HASH_AND_SIGN(alg) \ 406 (PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || \ 407 PSA_ALG_IS_DSA(alg) || PSA_ALG_IS_ECDSA(alg)) 421 #define PSA_DH_FAMILY_CUSTOM ((psa_dh_family_t) 0x7e) 522 size_t *data_length);
549 #define PSA_KEY_DOMAIN_PARAMETERS_SIZE(key_type, key_bits) \ 550 (PSA_KEY_TYPE_IS_RSA(key_type) ? sizeof(int) : \ 551 PSA_KEY_TYPE_IS_DH(key_type) ? PSA_DH_KEY_DOMAIN_PARAMETERS_SIZE(key_bits) : \ 552 PSA_KEY_TYPE_IS_DSA(key_type) ? PSA_DSA_KEY_DOMAIN_PARAMETERS_SIZE(key_bits) : \ 554 #define PSA_DH_KEY_DOMAIN_PARAMETERS_SIZE(key_bits) \ 555 (4 + (PSA_BITS_TO_BYTES(key_bits) + 5) * 3 ) 556 #define PSA_DSA_KEY_DOMAIN_PARAMETERS_SIZE(key_bits) \ 557 (4 + (PSA_BITS_TO_BYTES(key_bits) + 5) * 2 + 34 ) 565 #if defined(MBEDTLS_ECP_C) 566 #include <mbedtls/ecp.h> 581 static inline psa_ecc_family_t mbedtls_ecc_group_to_psa( mbedtls_ecp_group_id grpid,
586 case MBEDTLS_ECP_DP_SECP192R1:
589 case MBEDTLS_ECP_DP_SECP224R1:
592 case MBEDTLS_ECP_DP_SECP256R1:
595 case MBEDTLS_ECP_DP_SECP384R1:
598 case MBEDTLS_ECP_DP_SECP521R1:
601 case MBEDTLS_ECP_DP_BP256R1:
604 case MBEDTLS_ECP_DP_BP384R1:
607 case MBEDTLS_ECP_DP_BP512R1:
610 case MBEDTLS_ECP_DP_CURVE25519:
613 case MBEDTLS_ECP_DP_SECP192K1:
616 case MBEDTLS_ECP_DP_SECP224K1:
619 case MBEDTLS_ECP_DP_SECP256K1:
622 case MBEDTLS_ECP_DP_CURVE448:
647 size_t byte_length );
size_t empty_slots
Number of slots that are not used for anything.
#define PSA_ECC_FAMILY_MONTGOMERY
Curve25519 and Curve448.
static void psa_set_key_enrollment_algorithm(psa_key_attributes_t *attributes, psa_algorithm_t alg2)
Declare the enrollment algorithm for a key.
uint32_t psa_key_id_t
Encoding of identifiers of persistent keys.
size_t cache_slots
Number of slots that contain cache data.
size_t half_filled_slots
Number of slots which are occupied, but do not contain key material yet.
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_ECC_FAMILY_BRAINPOOL_P_R1
Brainpool P random curves.
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 ...
static psa_algorithm_t psa_get_key_enrollment_algorithm(const psa_key_attributes_t *attributes)
Retrieve the enrollment algorithm policy from key attributes.
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
size_t external_slots
Number of slots containing a reference to a key in a secure element.
#define PSA_ECC_FAMILY_SECP_R1
SEC random curves over prime fields.
size_t persistent_slots
Number of slots containing key material for a key which is in internal persistent storage...
uint16_t psa_key_type_t
Encoding of a key type.
size_t locked_slots
Number of slots that are locked.
size_t volatile_slots
Number of slots containing key material for a volatile 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.
psa_key_id_t max_open_external_key_id
Largest key id value among open keys in secure elements.
#define PSA_ECC_FAMILY_SECP_K1
SEC Koblitz curves over prime fields.
psa_key_id_t max_open_internal_key_id
Largest key id value among open keys in internal persistent storage.
uint8_t psa_ecc_family_t
The type of PSA elliptic curve family identifiers.
int32_t psa_status_t
Function return status.
Statistics about resource consumption related to the PSA keystore.