Mbed TLS v2.28.9
Loading...
Searching...
No Matches
crypto_platform.h
Go to the documentation of this file.
1
16/*
17 * Copyright The Mbed TLS Contributors
18 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
19 */
20
21#ifndef PSA_CRYPTO_PLATFORM_H
22#define PSA_CRYPTO_PLATFORM_H
23
24/* Include the Mbed TLS configuration file, the way Mbed TLS does it
25 * in each of its header files. */
26#if !defined(MBEDTLS_CONFIG_FILE)
27#include "mbedtls/config.h"
28#else
29#include MBEDTLS_CONFIG_FILE
30#endif
31
32/* Translate between classic MBEDTLS_xxx feature symbols and PSA_xxx
33 * feature symbols. */
34#include "mbedtls/config_psa.h"
35
36/* PSA requires several types which C99 provides in stdint.h. */
37#include <stdint.h>
38
39#if (defined(__ARMCC_VERSION) || defined(_MSC_VER)) && \
40 !defined(inline) && !defined(__cplusplus)
41#define inline __inline
42#endif
43
44#if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
45
46/* Building for the PSA Crypto service on a PSA platform, a key owner is a PSA
47 * partition identifier.
48 *
49 * The function psa_its_identifier_of_slot() in psa_crypto_storage.c that
50 * translates a key identifier to a key storage file name assumes that
51 * mbedtls_key_owner_id_t is a 32-bit integer. This function thus needs
52 * reworking if mbedtls_key_owner_id_t is not defined as a 32-bit integer
53 * here anymore.
54 */
55typedef int32_t mbedtls_key_owner_id_t;
56
64static inline int mbedtls_key_owner_id_equal(mbedtls_key_owner_id_t id1,
65 mbedtls_key_owner_id_t id2)
66{
67 return id1 == id2;
68}
69
70#endif /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
71
72/*
73 * When MBEDTLS_PSA_CRYPTO_SPM is defined, the code is being built for SPM
74 * (Secure Partition Manager) integration which separates the code into two
75 * parts: NSPE (Non-Secure Processing Environment) and SPE (Secure Processing
76 * Environment). When building for the SPE, an additional header file should be
77 * included.
78 */
79#if defined(MBEDTLS_PSA_CRYPTO_SPM)
80#define PSA_CRYPTO_SECURE 1
81#include "crypto_spe.h"
82#endif // MBEDTLS_PSA_CRYPTO_SPM
83
84#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
94typedef struct {
95 uintptr_t opaque[2];
96} mbedtls_psa_external_random_context_t;
97#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
98
99#endif /* PSA_CRYPTO_PLATFORM_H */
Configuration options (set of defines)
PSA crypto configuration options (set of defines)