crypto_struct.h
Go to the documentation of this file.
1 
44 /*
45  * Copyright The Mbed TLS Contributors
46  * Copyright 2022-2025, Texas Instruments Incorporated
47  * SPDX-License-Identifier: Apache-2.0
48  *
49  * Licensed under the Apache License, Version 2.0 (the "License"); you may
50  * not use this file except in compliance with the License.
51  * You may obtain a copy of the License at
52  *
53  * http://www.apache.org/licenses/LICENSE-2.0
54  *
55  * Unless required by applicable law or agreed to in writing, software
56  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
57  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
58  * See the License for the specific language governing permissions and
59  * limitations under the License.
60  *
61  * Modified by Texas Instruments to:
62  * - Support SimpleLink device crypto hardware drivers.
63  * - Support key derivation using HSM DDK.
64  * - Change mbedtls_svc_key_id_t input params to psa_key_id_t.
65  * - Remove MBEDTLS_PSA_KA_xxxx defines.
66  * - Remove MBEDTLS_PSA_CRYPTO_SE_C specific code.
67  */
68 
69 #ifndef PSA_CRYPTO_STRUCT_H
70 #define PSA_CRYPTO_STRUCT_H
71 
72 /* clang-format off */
73 #include <stdbool.h>
74 #include <stdint.h>
75 
76 /* Include the Mbed TLS configuration file if defined */
77 #if defined(MBEDTLS_CONFIG_FILE)
78  #include MBEDTLS_CONFIG_FILE
79 #endif
80 
81 /* Include the context definition for the compiled-in drivers for the primitive
82  * algorithms.
83  */
84 #include <ti/drivers/SHA2.h>
85 #include <ti/drivers/AESECB.h>
86 #include <ti/drivers/AESCCM.h>
87 #include <ti/drivers/AESGCM.h>
88 
89 #if (TFM_ENABLED == 1) && !defined(TFM_BUILD)
90  /* Includes for NS library build */
91  #include <third_party/tfm/interface/include/psa/crypto_client_struct.h>
92 #endif
93 
94 #include <ti/devices/DeviceFamily.h>
95 
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))
102  /* No headers needed */
103 #else
104  #error "Device family not supported"
105 #endif
106 
107 #ifdef __cplusplus
108 extern "C" {
109 #endif
110 
112 {
116 };
118 
119 #define PSA_KEY_POLICY_INIT \
120  { \
121  0, 0, 0 \
122  }
123 static inline struct psa_key_policy_s psa_key_policy_init(void)
124 {
125  const struct psa_key_policy_s v = PSA_KEY_POLICY_INIT;
126  return (v);
127 }
128 
129 /* The type used internally for key sizes.
130  * Public interfaces use size_t, but internally we use a smaller type. */
131 typedef uint16_t psa_key_bits_t;
132 
133 /* The maximum value of the type used to represent bit-sizes.
134  * This is used to mark an invalid key size. */
135 #define PSA_KEY_BITS_TOO_LARGE ((psa_key_bits_t)(-1))
136 /* The maximum size of a key in bits.
137  * Currently defined as the maximum that can be represented, rounded down
138  * to a whole number of bytes.
139  * This is an uncast value so that it can be used in preprocessor
140  * conditionals. */
141 #define PSA_MAX_KEY_BITS 0xfff8
142 
150 typedef uint16_t psa_key_attributes_flag_t;
151 
152 /* Default owner ID to match with client ID in TFM-enabled builds */
153 #define PSA_CRYPTO_KEY_ID_DEFAULT_OWNER -1
154 
155 
156 /* NOTE: this must match the attributes struct needed by CryptoKeyKeyStore.h */
157 typedef struct
158 {
160  psa_key_bits_t bits;
164  psa_key_attributes_flag_t flags;
166 
167 #define PSA_CORE_KEY_ATTRIBUTES_INIT \
168  (psa_core_key_attributes_t) \
169  { \
170  0 \
171  }
172 
173 #if (TFM_ENABLED == 0) || defined(TFM_BUILD)
175 {
179 };
180 #endif
181 
182 #define PSA_KEY_ATTRIBUTES_INIT \
183  (psa_key_attributes_t) \
184  { \
185  0 \
186  }
187 
188 #if (TFM_ENABLED == 0) || defined(TFM_BUILD)
189 
190 extern psa_status_t tfm_crypto_get_caller_id(int32_t *id);
191 
192 #ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
193 static inline void mbedtls_set_key_owner_id(psa_key_attributes_t *attributes,
195 {
196  attributes->core.id.owner = owner;
197 }
198 #endif
199 #endif
200 
202 {
204  return v;
205 }
206 
207 #if ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || \
208  (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX))
209 
210 /* The ECDSA driver only supports sign and verify of a hash. When a message
211  * needs to be signed/verified, the hash must be calculated first. The ECDSA
212  * driver always specifies the PSA_KEY_USAGE_SIGN_MESSAGE or
213  * PSA_KEY_USAGE_VERIFY_MESSAGE flag when retrieving a key, thus we must extend
214  * hash usage flags to allow ECDSA to be used for both cases.
215  */
216 static inline void psa_extend_key_usage_flags(psa_key_usage_t *usage_flags)
217 {
218  if (*usage_flags & PSA_KEY_USAGE_SIGN_HASH) {
219  *usage_flags |= PSA_KEY_USAGE_SIGN_MESSAGE;
220  }
221 
222  if (*usage_flags & PSA_KEY_USAGE_VERIFY_HASH) {
223  *usage_flags |= PSA_KEY_USAGE_VERIFY_MESSAGE;
224  }
225 }
226 
227 #if (TFM_ENABLED == 0) || defined(TFM_BUILD)
228 
229 static inline void psa_set_key_id(psa_key_attributes_t *attributes,
230  psa_key_id_t key)
231 {
232  psa_key_lifetime_t lifetime = attributes->core.lifetime;
233 
234  attributes->core.id.key_id = key;
235 #ifdef TFM_BUILD
236  /* tfm_crypto_get_caller_id always returns PSA_SUCCESS */
237  (void)tfm_crypto_get_caller_id(&attributes->core.id.owner);
238 #else
240 #endif
241 
242  if (PSA_KEY_LIFETIME_IS_VOLATILE(lifetime)) {
243  attributes->core.lifetime =
247  }
248 }
249 
251  const psa_key_attributes_t *attributes)
252 {
253  return attributes->core.id.key_id;
254 }
255 
256 static inline void psa_set_key_lifetime(psa_key_attributes_t *attributes,
257  psa_key_lifetime_t lifetime)
258 {
259  attributes->core.lifetime = lifetime;
260  if (PSA_KEY_LIFETIME_IS_VOLATILE(lifetime)) {
261  attributes->core.id.key_id = 0;
262  }
263 }
264 
266  const psa_key_attributes_t *attributes)
267 {
268  return attributes->core.lifetime;
269 }
270 
271 static inline void psa_set_key_usage_flags(psa_key_attributes_t *attributes,
272  psa_key_usage_t usage_flags)
273 {
274  psa_extend_key_usage_flags(&usage_flags);
275  attributes->core.policy.usage = usage_flags;
276 }
277 
279  const psa_key_attributes_t *attributes)
280 {
281  return attributes->core.policy.usage;
282 }
283 
284 static inline void psa_set_key_algorithm(psa_key_attributes_t *attributes,
286 {
287  attributes->core.policy.alg = alg;
288 }
289 
291  const psa_key_attributes_t *attributes)
292 {
293  return attributes->core.policy.alg;
294 }
295 
296 /* This function is declared in crypto_extra.h, which comes after this
297  * header file, but we need the function here, so repeat the declaration. */
299  psa_key_type_t type,
300  const uint8_t *data,
301  size_t data_length);
302 
303 static inline void psa_set_key_type(psa_key_attributes_t *attributes,
304  psa_key_type_t type)
305 {
306  /* Ignore unused key domain parameters */
307  attributes->core.type = type;
308 }
309 
311  const psa_key_attributes_t *attributes)
312 {
313  return attributes->core.type;
314 }
315 
316 static inline void psa_set_key_bits(psa_key_attributes_t *attributes,
317  size_t bits)
318 {
319  if (bits > PSA_MAX_KEY_BITS) {
320  attributes->core.bits = PSA_KEY_BITS_TOO_LARGE;
321  } else {
322  attributes->core.bits = (psa_key_bits_t)bits;
323  }
324 }
325 
326 static inline size_t psa_get_key_bits(
327  const psa_key_attributes_t *attributes)
328 {
329  return attributes->core.bits;
330 }
331 
332 #else
333 
334 /* NS application (for TFM-enabled builds) uses these APIs providing client key
335  * attributes.
336  */
337 
338 static inline void psa_set_key_id(psa_key_attributes_t *attributes,
339  psa_key_id_t key)
340 {
341  psa_key_lifetime_t lifetime = attributes->lifetime;
342 
343  attributes->id = key;
344 
345  if (PSA_KEY_LIFETIME_IS_VOLATILE(lifetime)) {
346  attributes->lifetime =
350  }
351 }
352 
353 static inline psa_key_id_t psa_get_key_id(
354  const psa_key_attributes_t *attributes)
355 {
356  return attributes->id;
357 }
358 
359 static inline void psa_set_key_lifetime(psa_key_attributes_t *attributes,
360  psa_key_lifetime_t lifetime)
361 {
362  attributes->lifetime = lifetime;
363  if (PSA_KEY_LIFETIME_IS_VOLATILE(lifetime)) {
364  attributes->id = 0;
365  }
366 }
367 
369  const psa_key_attributes_t *attributes)
370 {
371  return attributes->lifetime;
372 }
373 
374 static inline void psa_set_key_usage_flags(psa_key_attributes_t *attributes,
375  psa_key_usage_t usage_flags)
376 {
377  psa_extend_key_usage_flags(&usage_flags);
378  attributes->usage = usage_flags;
379 }
380 
382  const psa_key_attributes_t *attributes)
383 {
384  return attributes->usage;
385 }
386 
387 static inline void psa_set_key_algorithm(psa_key_attributes_t *attributes,
389 {
390  attributes->alg = alg;
391 }
392 
394  const psa_key_attributes_t *attributes)
395 {
396  return attributes->alg;
397 }
398 
399 static inline void psa_set_key_type(psa_key_attributes_t *attributes,
400  psa_key_type_t type)
401 {
402  attributes->type = type;
403 }
404 
405 static inline psa_key_type_t psa_get_key_type(
406  const psa_key_attributes_t *attributes)
407 {
408  return attributes->type;
409 }
410 
411 static inline void psa_set_key_bits(psa_key_attributes_t *attributes,
412  size_t bits)
413 {
414  if (bits > PSA_MAX_KEY_BITS) {
415  attributes->bits = PSA_KEY_BITS_TOO_LARGE;
416  } else {
417  attributes->bits = (psa_key_bits_t)bits;
418  }
419 }
420 
421 static inline size_t psa_get_key_bits(
422  const psa_key_attributes_t *attributes)
423 {
424  return attributes->bits;
425 }
426 
427 #endif /* #if (TFM_ENABLED == 0) || defined(TFM_BUILD) */
428 
429 #elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X4_CC26X3_CC26X4)
430 
431 /*
432  * ======== psa_set_key_id ========
433  */
434 static inline void psa_set_key_id(psa_key_attributes_t *attributes, psa_key_id_t key)
435 {
436  KeyStore_PSA_setKeyId(attributes, toKeyStoreKeyID(key));
437 }
438 
439 /*
440  * ======== psa_get_key_id ========
441  */
442 static inline psa_key_id_t psa_get_key_id(const psa_key_attributes_t *attributes)
443 {
444  return toKeyID(KeyStore_PSA_getKeyId((psa_key_attributes_t *)attributes));
445 }
446 
447 /*
448  * ======== psa_set_key_lifetime ========
449  */
450 static inline void psa_set_key_lifetime(psa_key_attributes_t *attributes, psa_key_lifetime_t lifetime)
451 {
452  KeyStore_PSA_setKeyLifetime(attributes, lifetime);
453 }
454 
455 /*
456  * ======== psa_get_key_lifetime ========
457  */
458 static inline psa_key_lifetime_t psa_get_key_lifetime(const psa_key_attributes_t *attributes)
459 {
461 }
462 
463 /*
464  * ======== psa_set_key_usage_flags ========
465  */
466 static inline void psa_set_key_usage_flags(psa_key_attributes_t *attributes, psa_key_usage_t usage_flags)
467 {
468  KeyStore_PSA_setKeyUsageFlags(attributes, usage_flags);
469 }
470 
471 /*
472  * ======== psa_get_key_usage_flags ========
473  */
474 static inline psa_key_usage_t psa_get_key_usage_flags(const psa_key_attributes_t *attributes)
475 {
477 }
478 
479 /*
480  * ======== psa_set_key_algorithm ========
481  */
482 static inline void psa_set_key_algorithm(psa_key_attributes_t *attributes, psa_algorithm_t alg)
483 {
484  KeyStore_PSA_setKeyAlgorithm(attributes, alg);
485 }
486 
487 /*
488  * ======== psa_get_key_algorithm ========
489  */
490 static inline psa_algorithm_t psa_get_key_algorithm(const psa_key_attributes_t *attributes)
491 {
493 }
494 
495 /*
496  * ======== psa_set_key_type ========
497  */
498 static inline void psa_set_key_type(psa_key_attributes_t *attributes, psa_key_type_t type)
499 {
500  KeyStore_PSA_setKeyType(attributes, type);
501 }
502 
503 /*
504  * ======== psa_get_key_type ========
505  */
506 static inline psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes)
507 {
508  return KeyStore_PSA_getKeyType((psa_key_attributes_t *)attributes);
509 }
510 
511 /*
512  * ======== psa_set_key_bits ========
513  */
514 static inline void psa_set_key_bits(psa_key_attributes_t *attributes, size_t bits)
515 {
516  KeyStore_PSA_setKeyBits(attributes, bits);
517 }
518 
519 /*
520  * ======== psa_get_key_bits ========
521  */
522 static inline size_t psa_get_key_bits(const psa_key_attributes_t *attributes)
523 {
524  return KeyStore_PSA_getKeyBits((psa_key_attributes_t *)attributes);
525 }
526 
527 #else
528 
529 #error "Device not supported"
530 
531 #endif /* (DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || (DeviceFamily_PARENT == DeviceFamily_PARENT_CC35XX) */
532 
533 /* ############################################################################### */
534 
536 {
544  unsigned int id;
545  /* alg identifier */
547 };
548 
549 #define PSA_HASH_OPERATION_INIT \
550  (psa_hash_operation_t) \
551  { \
552  0 \
553  }
555 {
557  return (v);
558 }
559 
561 {
568  unsigned int id;
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;
575 
578 
579  /* Buffer for data that has not been processed yet. Word-aligned for max
580  * performance and in case any drivers require aligned input buffer.
581  * Double-buffer is used when PSA crypto is built into the TFM to prevent
582  * corruption before the data can be consumed since the underlying crypto
583  * drivers are used in callback mode. */
584 #ifdef TFM_BUILD
585  uint8_t unprocessed_data[PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE * 2] __attribute__((aligned(4)));
586 #else
587  uint8_t unprocessed_data[PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE] __attribute__((aligned(4)));
588 #endif /* TFM_BUILD */
589 
590  /* Pointer to the current unprocessed data */
592 
594 };
595 
596 #define PSA_CIPHER_OPERATION_INIT \
597  (psa_cipher_operation_t) \
598  { \
599  0 \
600  }
602 {
604  return (v);
605 }
606 
608 {
615  unsigned int id;
616  size_t mac_size;
619 
620  /* Buffer for data that has not been processed yet. Word-aligned for max
621  * performance and in case any drivers require aligned input buffer.
622  * Double-buffer is used when PSA crypto is built into the TFM to prevent
623  * corruption before the data can be consumed since the underlying crypto
624  * drivers are used in callback mode. */
625 #ifdef TFM_BUILD
626  uint8_t unprocessedData[PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE * 2] __attribute__((aligned(4)));
627 #else
628  uint8_t unprocessedData[PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE] __attribute__((aligned(4)));
629 #endif /* TFM_BUILD */
630 
631  /* Pointer to the current unprocessed data */
633 
635  bool is_sign;
636 };
637 
638 #define PSA_MAC_OPERATION_INIT \
639  (psa_mac_operation_t) \
640  { \
641  0 \
642  }
643 static inline struct psa_mac_operation_s psa_mac_operation_init(void)
644 {
646  return (v);
647 }
648 
650 {
657  unsigned int id;
659  unsigned int iv_set:1;
660  unsigned int in_error_state:1;
661  size_t adLength;
665  size_t tagSize;
666 
667  /* Buffer for data that has not been processed yet. Word-aligned for max
668  * performance and in case any drivers require aligned input buffer.
669  * Double-buffer is used when PSA crypto is built into the TFM to prevent
670  * corruption before the data can be consumed since the underlying crypto
671  * drivers are used in callback mode. */
672 #ifdef TFM_BUILD
673  uint8_t unprocessedData[PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE * 2] __attribute__((aligned(4)));
674 #else
675  uint8_t unprocessedData[PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE] __attribute__((aligned(4)));
676 #endif /* TFM_BUILD */
677 
678  /* Pointer to the current unprocessed data */
680 
682 
686 };
687 
688 #define PSA_AEAD_OPERATION_INIT \
689  (psa_aead_operation_t) \
690  { \
691  0 \
692  }
694 {
696  return (v);
697 }
698 
699 #if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF)
700 typedef struct
701 {
702  uint8_t *info;
703  size_t info_length;
704  psa_mac_operation_t hmac;
705  uint8_t prk[PSA_HASH_MAX_SIZE];
706  uint8_t output_block[PSA_HASH_MAX_SIZE];
707  #if PSA_HASH_MAX_SIZE > 0xff
708  #error "PSA_HASH_MAX_SIZE does not fit in uint8_t"
709  #endif
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;
715 #endif /* MBEDTLS_PSA_BUILTIN_ALG_HKDF */
716 
717 #if defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) || defined(MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS)
718 typedef enum
719 {
720  PSA_TLS12_PRF_STATE_INIT, /* no input provided */
721  PSA_TLS12_PRF_STATE_SEED_SET, /* seed has been set */
722  PSA_TLS12_PRF_STATE_KEY_SET, /* key has been set */
723  PSA_TLS12_PRF_STATE_LABEL_SET, /* label has been set */
724  PSA_TLS12_PRF_STATE_OUTPUT /* output has been started */
725 } psa_tls12_prf_key_derivation_state_t;
726 
727 typedef struct psa_tls12_prf_key_derivation_s
728 {
729  #if PSA_HASH_MAX_SIZE > 0xff
730  #error "PSA_HASH_MAX_SIZE does not fit in uint8_t"
731  #endif
732 
733  /* Indicates how many bytes in the current HMAC block have
734  * not yet been read by the user. */
735  uint8_t left_in_block;
736 
737  /* The 1-based number of the block. */
738  uint8_t block_number;
739 
740  psa_tls12_prf_key_derivation_state_t state;
741 
742  uint8_t *secret;
743  size_t secret_length;
744  uint8_t *seed;
745  size_t seed_length;
746  uint8_t *label;
747  size_t label_length;
748 
749  uint8_t Ai[PSA_HASH_MAX_SIZE];
750 
751  /* `HMAC_hash( prk, A(i) + seed )` in the notation of RFC 5246, Sect. 5. */
752  uint8_t output_block[PSA_HASH_MAX_SIZE];
753 } psa_tls12_prf_key_derivation_t;
754 #endif /* MBEDTLS_PSA_BUILTIN_ALG_TLS12_PRF) || \
755  * MBEDTLS_PSA_BUILTIN_ALG_TLS12_PSK_TO_MS */
756 
757 /* Note: The following key derivation define, struct, and function are copied from the HSM DDK */
758 
760 #ifndef PSA_KDF_LABEL_MAX_SIZE
761 #define PSA_KDF_LABEL_MAX_SIZE (224U - 20U)
762 #endif
764 {
767  /* Should be at least 53 bytes of label data. Has to also fit an end marker
768  * between the label and the context, which is 1 byte (0x00). It should also
769  * fit four bytes for the length of the key to derive.
770  */
771  uint8_t fixedInputData[PSA_KDF_LABEL_MAX_SIZE];
772  size_t labelSize;
773  size_t contextSize;
774  uint32_t handle;
775  uint32_t capacity;
776  bool canDerive;
778 };
779 
780 #define PSA_KEY_DERIVATION_OPERATION_INIT {0, MBEDTLS_SVC_KEY_ID_INIT, {0, 0, 0, 0, 0}, false, false}
781 static inline struct psa_key_derivation_s
783 {
785  return (v);
786 }
787 
788 #ifdef __cplusplus
789 }
790 #endif
791 
792 #endif /* PSA_CRYPTO_STRUCT_H */
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
© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale