Mbed TLS v3.5.0
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
19  *
20  * Licensed under the Apache License, Version 2.0 (the "License"); you may
21  * not use this file except in compliance with the License.
22  * You may obtain a copy of the License at
23  *
24  * http://www.apache.org/licenses/LICENSE-2.0
25  *
26  * Unless required by applicable law or agreed to in writing, software
27  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
28  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29  * See the License for the specific language governing permissions and
30  * limitations under the License.
31  */
32 
33 #ifndef PSA_CRYPTO_PLATFORM_H
34 #define PSA_CRYPTO_PLATFORM_H
35 #include "mbedtls/private_access.h"
36 
37 /*
38  * Include the build-time configuration information file. Here, we do not
39  * include `"mbedtls/build_info.h"` directly but `"psa/build_info.h"`, which
40  * is basically just an alias to it. This is to ease the maintenance of the
41  * PSA cryptography repository which has a different build system and
42  * configuration.
43  */
44 #include "psa/build_info.h"
45 
46 /* PSA requires several types which C99 provides in stdint.h. */
47 #include <stdint.h>
48 
49 #if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
50 
51 /* Building for the PSA Crypto service on a PSA platform, a key owner is a PSA
52  * partition identifier.
53  *
54  * The function psa_its_identifier_of_slot() in psa_crypto_storage.c that
55  * translates a key identifier to a key storage file name assumes that
56  * mbedtls_key_owner_id_t is a 32-bit integer. This function thus needs
57  * reworking if mbedtls_key_owner_id_t is not defined as a 32-bit integer
58  * here anymore.
59  */
60 typedef int32_t mbedtls_key_owner_id_t;
61 
69 static inline int mbedtls_key_owner_id_equal(mbedtls_key_owner_id_t id1,
70  mbedtls_key_owner_id_t id2)
71 {
72  return id1 == id2;
73 }
74 
75 #endif /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
76 
77 /*
78  * When MBEDTLS_PSA_CRYPTO_SPM is defined, the code is being built for SPM
79  * (Secure Partition Manager) integration which separates the code into two
80  * parts: NSPE (Non-Secure Processing Environment) and SPE (Secure Processing
81  * Environment). When building for the SPE, an additional header file should be
82  * included.
83  */
84 #if defined(MBEDTLS_PSA_CRYPTO_SPM)
85 #define PSA_CRYPTO_SECURE 1
86 #include "crypto_spe.h"
87 #endif // MBEDTLS_PSA_CRYPTO_SPM
88 
89 #if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
99 typedef struct {
100  uintptr_t MBEDTLS_PRIVATE(opaque)[2];
101 } mbedtls_psa_external_random_context_t;
102 #endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
103 
104 #endif /* PSA_CRYPTO_PLATFORM_H */
Macro wrapper for struct's members.
#define MBEDTLS_PRIVATE(member)
Build-time PSA configuration info.