69 #ifndef PSA_CRYPTO_STRUCT_H 70 #define PSA_CRYPTO_STRUCT_H 77 #if defined(MBEDTLS_CONFIG_FILE) 78 #include MBEDTLS_CONFIG_FILE 89 #if (TFM_ENABLED == 1) && !defined(TFM_BUILD) 91 #include <third_party/tfm/interface/include/psa/crypto_client_struct.h> 94 #include <ti/devices/DeviceFamily.h> 96 #if ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2) || \ 97 (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X4_CC26X3_CC26X4)) 100 #elif ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || \ 101 (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX)) 104 #error "Device family not supported" 119 #define PSA_KEY_POLICY_INIT \ 135 #define PSA_KEY_BITS_TOO_LARGE ((psa_key_bits_t)(-1)) 141 #define PSA_MAX_KEY_BITS 0xfff8 153 #define PSA_CRYPTO_KEY_ID_DEFAULT_OWNER -1 167 #define PSA_CORE_KEY_ATTRIBUTES_INIT \ 168 (psa_core_key_attributes_t) \ 173 #if (TFM_ENABLED == 0) || defined(TFM_BUILD) 182 #define PSA_KEY_ATTRIBUTES_INIT \ 183 (psa_key_attributes_t) \ 188 #if (TFM_ENABLED == 0) || defined(TFM_BUILD) 192 #ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER 207 #if ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || \ 208 (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX)) 227 #if (TFM_ENABLED == 0) || defined(TFM_BUILD) 343 attributes->id = key;
346 attributes->lifetime =
356 return attributes->id;
362 attributes->lifetime = lifetime;
371 return attributes->lifetime;
378 attributes->usage = usage_flags;
384 return attributes->usage;
390 attributes->alg =
alg;
396 return attributes->alg;
402 attributes->type = type;
408 return attributes->type;
424 return attributes->bits;
429 #elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X4_CC26X3_CC26X4) 529 #error "Device not supported" 549 #define PSA_HASH_OPERATION_INIT \ 550 (psa_hash_operation_t) \ 569 unsigned int iv_required:1;
570 unsigned int iv_set:1;
571 unsigned int is_encrypt:1;
572 unsigned int in_error_state:1;
596 #define PSA_CIPHER_OPERATION_INIT \ 597 (psa_cipher_operation_t) \ 638 #define PSA_MAC_OPERATION_INIT \ 639 (psa_mac_operation_t) \ 659 unsigned int iv_set:1;
660 unsigned int in_error_state:1;
688 #define PSA_AEAD_OPERATION_INIT \ 689 (psa_aead_operation_t) \ 699 #if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF) 707 #if PSA_HASH_MAX_SIZE > 0xff 708 #error "PSA_HASH_MAX_SIZE does not fit in uint8_t" 710 uint8_t offset_in_block;
711 uint8_t block_number;
712 unsigned int state:2;
713 unsigned int info_set:1;
714 } psa_hkdf_key_derivation_t;
717 #if defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) || defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS) 720 PSA_TLS12_PRF_STATE_INIT,
721 PSA_TLS12_PRF_STATE_SEED_SET,
722 PSA_TLS12_PRF_STATE_KEY_SET,
723 PSA_TLS12_PRF_STATE_LABEL_SET,
724 PSA_TLS12_PRF_STATE_OUTPUT
725 } psa_tls12_prf_key_derivation_state_t;
727 typedef struct psa_tls12_prf_key_derivation_s
729 #if PSA_HASH_MAX_SIZE > 0xff 730 #error "PSA_HASH_MAX_SIZE does not fit in uint8_t" 735 uint8_t left_in_block;
738 uint8_t block_number;
740 psa_tls12_prf_key_derivation_state_t state;
743 size_t secret_length;
753 } psa_tls12_prf_key_derivation_t;
760 #ifndef PSA_KDF_LABEL_MAX_SIZE 761 #define PSA_KDF_LABEL_MAX_SIZE (224U - 20U) 780 #define PSA_KEY_DERIVATION_OPERATION_INIT {0, MBEDTLS_SVC_KEY_ID_INIT, {0, 0, 0, 0, 0}, false, false} psa_key_lifetime_t lifetime
Definition: crypto_struct.h:161
Definition: crypto_struct.h:174
mbedtls_svc_key_id_t toKeyStoreKeyID(psa_key_id_t keyID)
Definition: crypto_struct.h:649
size_t labelSize
Definition: crypto_struct.h:772
Definition: crypto_struct.h:607
static void psa_set_key_usage_flags(psa_key_attributes_t *attributes, psa_key_usage_t usage_flags)
Definition: crypto_struct.h:271
mbedtls_svc_key_id_t inputKey
Definition: crypto_struct.h:766
#define PSA_MAX_KEY_BITS
Definition: crypto_struct.h:141
static psa_key_lifetime_t psa_get_key_lifetime(const psa_key_attributes_t *attributes)
Definition: crypto_struct.h:265
uint8_t * curr_unprocessed_data
Definition: crypto_struct.h:632
Definition: crypto_struct.h:111
psa_algorithm_t alg
Definition: crypto_struct.h:617
KeyStore_PSA_KeyUsage KeyStore_PSA_getKeyUsageFlags(KeyStore_PSA_KeyAttributes *attributes)
#define PSA_MAC_OPERATION_INIT
Definition: crypto_struct.h:638
size_t adLength
Definition: crypto_struct.h:661
psa_key_type_t type
Definition: crypto_struct.h:159
uint8_t * curr_unprocessed_data
Definition: crypto_struct.h:679
static struct psa_aead_operation_s psa_aead_operation_init(void)
Definition: crypto_struct.h:693
size_t domain_parameters_size
Definition: crypto_struct.h:178
Definition: crypto_struct.h:560
psa_key_usage_t usage
Definition: crypto_struct.h:113
size_t KeyStore_PSA_getKeyBits(KeyStore_PSA_KeyAttributes *attributes)
psa_key_id_t key_id
Definition: crypto_types.h:355
uint16_t psa_key_bits_t
Definition: crypto_struct.h:131
bool canDerive
Definition: crypto_struct.h:776
static psa_key_attributes_t psa_key_attributes_init(void)
Definition: crypto_struct.h:201
psa_algorithm_t alg2
Definition: crypto_struct.h:115
psa_key_attributes_flag_t flags
Definition: crypto_struct.h:164
psa_algorithm_t alg
Definition: crypto_struct.h:574
#define PSA_CRYPTO_KEY_ID_DEFAULT_OWNER
Definition: crypto_struct.h:153
uint32_t psa_key_id_t
Definition: crypto_types.h:298
void KeyStore_PSA_setKeyId(KeyStore_PSA_KeyAttributes *attributes, KeyStore_PSA_KeyFileId key)
unsigned int id
Definition: crypto_struct.h:657
size_t plaintextLength
Definition: crypto_struct.h:662
void KeyStore_PSA_setKeyType(KeyStore_PSA_KeyAttributes *attributes, KeyStore_PSA_KeyType type)
psa_core_key_attributes_t core
Definition: crypto_struct.h:176
psa_status_t KeyMgmt_psa_set_key_domain_parameters(psa_key_attributes_t *attributes, psa_key_type_t type, const uint8_t *data, size_t data_length)
#define PSA_CIPHER_OPERATION_INIT
Definition: crypto_struct.h:596
void KeyStore_PSA_setKeyUsageFlags(KeyStore_PSA_KeyAttributes *attributes, KeyStore_PSA_KeyUsage usageFlags)
#define PSA_KEY_ATTRIBUTES_INIT
Definition: crypto_struct.h:182
unsigned int id
Definition: crypto_struct.h:615
#define PSA_KEY_LIFETIME_IS_VOLATILE(lifetime)
Definition: crypto_values.h:2465
Definition: crypto_struct.h:763
unsigned int id
Definition: crypto_struct.h:568
static psa_key_id_t psa_get_key_id(const psa_key_attributes_t *attributes)
Definition: crypto_struct.h:250
void KeyStore_PSA_setKeyAlgorithm(KeyStore_PSA_KeyAttributes *attributes, KeyStore_PSA_Algorithm alg)
unsigned int id
Definition: crypto_struct.h:544
#define PSA_KEY_USAGE_VERIFY_MESSAGE
Definition: crypto_values.h:2726
Definition: crypto_struct.h:535
static struct psa_key_derivation_s psa_key_derivation_operation_init(void)
Definition: crypto_struct.h:782
KeyStore_PSA_KeyFileId KeyStore_PSA_getKeyId(KeyStore_PSA_KeyAttributes *attributes)
CryptoKey cryptoKey
Definition: crypto_struct.h:683
static void psa_set_key_id(psa_key_attributes_t *attributes, psa_key_id_t key)
Definition: crypto_struct.h:229
#define PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(persistence, location)
Definition: crypto_values.h:2499
psa_key_id_t toKeyID(mbedtls_svc_key_id_t keystoreKeyID)
#define PSA_KEY_LIFETIME_GET_LOCATION(lifetime)
Definition: crypto_values.h:2446
#define PSA_KEY_USAGE_SIGN_MESSAGE
Definition: crypto_values.h:2716
psa_algorithm_t alg
Definition: crypto_struct.h:658
static void mbedtls_set_key_owner_id(psa_key_attributes_t *attributes, mbedtls_key_owner_id_t owner)
void KeyStore_PSA_setKeyLifetime(KeyStore_PSA_KeyAttributes *attributes, KeyStore_PSA_KeyLifetime lifetime)
psa_algorithm_t alg
Definition: crypto_struct.h:114
uint16_t psa_key_attributes_flag_t
Definition: crypto_struct.h:150
CryptoKey cryptoKey
Definition: crypto_struct.h:634
Definition: crypto_types.h:353
KeyStore_PSA_KeyLifetime KeyStore_PSA_getKeyLifetime(KeyStore_PSA_KeyAttributes *attributes)
size_t mac_size
Definition: crypto_struct.h:616
#define PSA_HASH_MAX_SIZE
Definition: crypto_sizes.h:164
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:157
psa_algorithm_t alg
Definition: crypto_struct.h:765
size_t contextSize
Definition: crypto_struct.h:773
#define PSA_KEY_LIFETIME_PERSISTENT
Definition: crypto_values.h:2413
uint32_t capacity
Definition: crypto_struct.h:775
psa_key_bits_t bits
Definition: crypto_struct.h:160
uint8_t * curr_unprocessed_data
Definition: crypto_struct.h:591
bool length_set
Definition: crypto_struct.h:685
CryptoKey cryptoKey
Definition: crypto_struct.h:593
uint32_t psa_key_usage_t
Encoding of permitted usage on a key.
Definition: crypto_types.h:377
psa_status_t tfm_crypto_get_caller_id(int32_t *id)
size_t unprocessed_len
Definition: crypto_struct.h:577
uint16_t psa_key_type_t
Encoding of a key type.
Definition: crypto_types.h:101
#define PSA_KEY_POLICY_INIT
Definition: crypto_struct.h:119
size_t runningADLength
Definition: crypto_struct.h:663
#define PSA_KEY_DERIVATION_OPERATION_INIT
Definition: crypto_struct.h:780
#define PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE
Definition: crypto_sizes.h:344
static psa_algorithm_t psa_get_key_algorithm(const psa_key_attributes_t *attributes)
Definition: crypto_struct.h:290
#define PSA_AEAD_OPERATION_INIT
Definition: crypto_struct.h:688
#define PSA_KEY_BITS_TOO_LARGE
Definition: crypto_struct.h:135
size_t unprocessed_len
Definition: crypto_struct.h:618
static psa_key_usage_t psa_get_key_usage_flags(const psa_key_attributes_t *attributes)
Definition: crypto_struct.h:278
#define PSA_KDF_LABEL_MAX_SIZE
Definition: crypto_struct.h:761
#define PSA_HASH_OPERATION_INIT
Definition: crypto_struct.h:549
static struct psa_mac_operation_s psa_mac_operation_init(void)
Definition: crypto_struct.h:643
mbedtls_svc_key_id_t id
Definition: crypto_struct.h:162
KeyStore_PSA_Algorithm KeyStore_PSA_getKeyAlgorithm(KeyStore_PSA_KeyAttributes *attributes)
void * domain_parameters
Definition: crypto_struct.h:177
size_t default_iv_length
Definition: crypto_struct.h:573
psa_key_policy_t policy
Definition: crypto_struct.h:163
bool done_updating_ad
Definition: crypto_struct.h:684
static size_t psa_get_key_bits(const psa_key_attributes_t *attributes)
Definition: crypto_struct.h:326
static struct psa_cipher_operation_s psa_cipher_operation_init(void)
Definition: crypto_struct.h:601
Definition: crypto_struct.h:157
static void psa_set_key_bits(psa_key_attributes_t *attributes, size_t bits)
Definition: crypto_struct.h:316
static void psa_set_key_lifetime(psa_key_attributes_t *attributes, psa_key_lifetime_t lifetime)
Definition: crypto_struct.h:256
uint32_t psa_key_lifetime_t
Definition: crypto_types.h:206
mbedtls_key_owner_id_t owner
Definition: crypto_types.h:356
KeyStore_PSA_KeyType KeyStore_PSA_getKeyType(KeyStore_PSA_KeyAttributes *attributes)
size_t unprocessed_len
Definition: crypto_struct.h:681
bool capacitySet
Definition: crypto_struct.h:777
static void psa_extend_key_usage_flags(psa_key_usage_t *usage_flags)
Definition: crypto_struct.h:216
psa_algorithm_t alg
Definition: crypto_struct.h:546
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:82
static void psa_set_key_algorithm(psa_key_attributes_t *attributes, psa_algorithm_t alg)
Definition: crypto_struct.h:284
size_t runningPlaintextLength
Definition: crypto_struct.h:664
static psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes)
Definition: crypto_struct.h:310
static void psa_set_key_type(psa_key_attributes_t *attributes, psa_key_type_t type)
Definition: crypto_struct.h:303
size_t tagSize
Definition: crypto_struct.h:665
#define PSA_KEY_USAGE_VERIFY_HASH
Definition: crypto_values.h:2746
static struct psa_key_policy_s psa_key_policy_init(void)
Definition: crypto_struct.h:123
#define PSA_KEY_USAGE_SIGN_HASH
Definition: crypto_values.h:2736
void KeyStore_PSA_setKeyBits(KeyStore_PSA_KeyAttributes *attributes, size_t bits)
bool is_sign
Definition: crypto_struct.h:635
int32_t mbedtls_key_owner_id_t
Definition: crypto_types.h:333
static struct psa_hash_operation_s psa_hash_operation_init(void)
Definition: crypto_struct.h:554
uint32_t handle
Definition: crypto_struct.h:774