crypto_types.h
Go to the documentation of this file.
1 
16 /*
17  * Copyright The Mbed TLS Contributors
18  * Copyright 2023-2024, Texas Instruments Incorporated
19  * SPDX-License-Identifier: Apache-2.0
20  *
21  * Licensed under the Apache License, Version 2.0 (the "License"); you may
22  * not use this file except in compliance with the License.
23  * You may obtain a copy of the License at
24  *
25  * http://www.apache.org/licenses/LICENSE-2.0
26  *
27  * Unless required by applicable law or agreed to in writing, software
28  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
29  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30  * See the License for the specific language governing permissions and
31  * limitations under the License.
32  *
33  * Modified by Texas Instruments to:
34  * - Support 'TFM_ENABLED' builds for SimpleLink devices
35  * - Change header file includes
36  * - Remove MBEDTLS_PRIVATE() usage
37  * - Add MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER define
38  */
39 
40 #ifndef PSA_CRYPTO_TYPES_H
41 #define PSA_CRYPTO_TYPES_H
42 
43 /* clang-format off */
44 
45 /* Enable key identifiers that encode a key owner identifiers */
46 #if (TFM_ENABLED == 0) || defined(TFM_BUILD)
47 #ifndef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
48 #define MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
49 #endif
50 #endif
51 
52 #if 0 /* Texas Instruments modification */
53 /* Make sure the Mbed TLS configuration is visible. */
54 #include "mbedtls/build_info.h"
55 /* Define the MBEDTLS_PRIVATE macro. */
56 #include "mbedtls/private_access.h"
57 
58 #if defined(MBEDTLS_PSA_CRYPTO_PLATFORM_FILE)
59 #include MBEDTLS_PSA_CRYPTO_PLATFORM_FILE
60 #else
61 #include "crypto_platform.h"
62 #endif
63 #endif
64 
65 #include <stdint.h>
66 
77 /* If #PSA_SUCCESS is already defined, it means that #psa_status_t
78  * is also defined in an external header, so prevent its multiple
79  * definition.
80  */
81 #ifndef PSA_SUCCESS
82 typedef int32_t psa_status_t;
83 #endif
84 
101 typedef uint16_t psa_key_type_t;
102 
120 typedef uint8_t psa_ecc_family_t;
121 
139 typedef uint8_t psa_dh_family_t;
140 
157 typedef uint32_t psa_algorithm_t;
158 
206 typedef uint32_t psa_key_lifetime_t;
207 
242 typedef uint8_t psa_key_persistence_t;
243 
283 typedef uint32_t psa_key_location_t;
284 
298 typedef uint32_t psa_key_id_t;
299 
314 #if !defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
315 #if (TFM_ENABLED == 0) || defined(TFM_BUILD)
316 /* For S-only builds or building into TFM, the core key attributes should store
317  * the key ID with the owner encoded.
318  */
319 #error "MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER must be defined for S-only builds or building into TFM"
320 #endif
322 #else /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
323 
324 /* Building for the PSA Crypto service on a PSA platform, a key owner is a PSA
325  * partition identifier.
326  *
327  * The function psa_its_identifier_of_slot() in psa_crypto_storage.c that
328  * translates a key identifier to a key storage file name assumes that
329  * mbedtls_key_owner_id_t is a 32-bit integer. This function thus needs
330  * reworking if mbedtls_key_owner_id_t is not defined as a 32-bit integer
331  * here anymore.
332  */
333 typedef int32_t mbedtls_key_owner_id_t;
334 
344 {
345  return id1 == id2;
346 }
347 
348 /* Implementation-specific: The Mbed TLS library can be built as
349  * part of a multi-client service that exposes the PSA Cryptography API in each
350  * client and encodes the client identity in the key identifier argument of
351  * functions such as psa_open_key().
352  */
353 typedef struct
354 {
358 
359 #endif /* !MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
360 
377 typedef uint32_t psa_key_usage_t;
378 
486 #if (TFM_ENABLED == 0) || defined(TFM_BUILD)
487 /* For S-only builds, always use the full key attributes. If the PSA Crypto API
488  * Wrapper is built into the S side when TFM is enabled, the full internal
489  * version of the key attributes from mbedTLS should be used. The Crypto secure
490  * service will translate the client key attributes into the full internal key
491  * attributes before calling the PSA Crypto API Wrapper.
492  */
494 #else
495 /* When building the NS application for TFM-enabled builds, use client key
496  * attributes.
497  */
498 typedef struct psa_client_key_attributes_s psa_key_attributes_t;
499 #endif /* (TFM_ENABLED == 0) || defined(TFM_BUILD) */
500 
501 #ifndef __DOXYGEN_ONLY__
502 #if defined(MBEDTLS_PSA_CRYPTO_SE_C)
503 /* Mbed TLS defines this type in crypto_types.h because it is also
504  * visible to applications through an implementation-specific extension.
505  * For the PSA Cryptography specification, this type is only visible
506  * via crypto_se_driver.h. */
507 typedef uint64_t psa_key_slot_number_t;
508 #endif /* MBEDTLS_PSA_CRYPTO_SE_C */
509 #endif /* !__DOXYGEN_ONLY__ */
510 
522 typedef uint16_t psa_key_derivation_step_t;
523 
526 #endif /* PSA_CRYPTO_TYPES_H */
Definition: crypto_struct.h:174
psa_key_id_t key_id
Definition: crypto_types.h:355
uint8_t psa_key_persistence_t
Definition: crypto_types.h:242
uint16_t psa_key_derivation_step_t
Encoding of the step of a key derivation.
Definition: crypto_types.h:522
uint32_t psa_key_id_t
Definition: crypto_types.h:298
uint8_t psa_dh_family_t
Definition: crypto_types.h:139
uint32_t psa_key_location_t
Definition: crypto_types.h:283
static int mbedtls_key_owner_id_equal(mbedtls_key_owner_id_t id1, mbedtls_key_owner_id_t id2)
Definition: crypto_types.h:342
Definition: crypto_types.h:353
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:157
uint32_t psa_key_usage_t
Encoding of permitted usage on a key.
Definition: crypto_types.h:377
uint16_t psa_key_type_t
Encoding of a key type.
Definition: crypto_types.h:101
uint32_t psa_key_lifetime_t
Definition: crypto_types.h:206
mbedtls_key_owner_id_t owner
Definition: crypto_types.h:356
uint8_t psa_ecc_family_t
Definition: crypto_types.h:120
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:82
int32_t mbedtls_key_owner_id_t
Definition: crypto_types.h:333
© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale