![]() |
|
|||
File indexing completed on 2025-08-27 09:43:22
0001 /** 0002 * \file psa/crypto_platform.h 0003 * 0004 * \brief PSA cryptography module: Mbed TLS platform definitions 0005 * 0006 * \note This file may not be included directly. Applications must 0007 * include psa/crypto.h. 0008 * 0009 * This file contains platform-dependent type definitions. 0010 * 0011 * In implementations with isolation between the application and the 0012 * cryptography module, implementers should take care to ensure that 0013 * the definitions that are exposed to applications match what the 0014 * module implements. 0015 */ 0016 /* 0017 * Copyright The Mbed TLS Contributors 0018 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 0019 */ 0020 0021 #ifndef PSA_CRYPTO_PLATFORM_H 0022 #define PSA_CRYPTO_PLATFORM_H 0023 #include "mbedtls/private_access.h" 0024 0025 /* 0026 * Include the build-time configuration information header. Here, we do not 0027 * include `"mbedtls/build_info.h"` directly but `"psa/build_info.h"`, which 0028 * is basically just an alias to it. This is to ease the maintenance of the 0029 * TF-PSA-Crypto repository which has a different build system and 0030 * configuration. 0031 */ 0032 #include "psa/build_info.h" 0033 0034 /* PSA requires several types which C99 provides in stdint.h. */ 0035 #include <stdint.h> 0036 0037 #if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER) 0038 0039 /* Building for the PSA Crypto service on a PSA platform, a key owner is a PSA 0040 * partition identifier. 0041 * 0042 * The function psa_its_identifier_of_slot() in psa_crypto_storage.c that 0043 * translates a key identifier to a key storage file name assumes that 0044 * mbedtls_key_owner_id_t is a 32-bit integer. This function thus needs 0045 * reworking if mbedtls_key_owner_id_t is not defined as a 32-bit integer 0046 * here anymore. 0047 */ 0048 typedef int32_t mbedtls_key_owner_id_t; 0049 0050 /** Compare two key owner identifiers. 0051 * 0052 * \param id1 First key owner identifier. 0053 * \param id2 Second key owner identifier. 0054 * 0055 * \return Non-zero if the two key owner identifiers are equal, zero otherwise. 0056 */ 0057 static inline int mbedtls_key_owner_id_equal(mbedtls_key_owner_id_t id1, 0058 mbedtls_key_owner_id_t id2) 0059 { 0060 return id1 == id2; 0061 } 0062 0063 #endif /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */ 0064 0065 /* 0066 * When MBEDTLS_PSA_CRYPTO_SPM is defined, the code is being built for SPM 0067 * (Secure Partition Manager) integration which separates the code into two 0068 * parts: NSPE (Non-Secure Processing Environment) and SPE (Secure Processing 0069 * Environment). When building for the SPE, an additional header file should be 0070 * included. 0071 */ 0072 #if defined(MBEDTLS_PSA_CRYPTO_SPM) 0073 #define PSA_CRYPTO_SECURE 1 0074 #include "crypto_spe.h" 0075 #endif // MBEDTLS_PSA_CRYPTO_SPM 0076 0077 #if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) 0078 /** The type of the context passed to mbedtls_psa_external_get_random(). 0079 * 0080 * Mbed TLS initializes the context to all-bits-zero before calling 0081 * mbedtls_psa_external_get_random() for the first time. 0082 * 0083 * The definition of this type in the Mbed TLS source code is for 0084 * demonstration purposes. Implementers of mbedtls_psa_external_get_random() 0085 * are expected to replace it with a custom definition. 0086 */ 0087 typedef struct { 0088 uintptr_t MBEDTLS_PRIVATE(opaque)[2]; 0089 } mbedtls_psa_external_random_context_t; 0090 #endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */ 0091 0092 #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) && !defined(MBEDTLS_PSA_CRYPTO_C) 0093 /** The type of the client handle used in context structures 0094 * 0095 * When a client view of the multipart context structures is required, 0096 * this handle is used to keep a mapping with the service side of the 0097 * context which contains the actual data. 0098 */ 0099 typedef uint32_t mbedtls_psa_client_handle_t; 0100 #endif 0101 0102 #endif /* PSA_CRYPTO_PLATFORM_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |