mbed TLS v3.1.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 /* Include the Mbed TLS configuration file, the way Mbed TLS does it
38  * in each of its header files. */
39 #include "mbedtls/build_info.h"
40 
41 /* Translate between classic MBEDTLS_xxx feature symbols and PSA_xxx
42  * feature symbols. */
43 #include "mbedtls/config_psa.h"
44 
45 /* PSA requires several types which C99 provides in stdint.h. */
46 #include <stdint.h>
47 
48 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
49  !defined(inline) && !defined(__cplusplus)
50 #define inline __inline
51 #endif
52 
53 #if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
54 
55 /* Building for the PSA Crypto service on a PSA platform, a key owner is a PSA
56  * partition identifier.
57  *
58  * The function psa_its_identifier_of_slot() in psa_crypto_storage.c that
59  * translates a key identifier to a key storage file name assumes that
60  * mbedtls_key_owner_id_t is an 32 bits integer. This function thus needs
61  * reworking if mbedtls_key_owner_id_t is not defined as a 32 bits integer
62  * here anymore.
63  */
64 typedef int32_t mbedtls_key_owner_id_t;
65 
75 {
76  return( id1 == id2 );
77 }
78 
79 #endif /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */
80 
81 /*
82  * When MBEDTLS_PSA_CRYPTO_SPM is defined, the code is being built for SPM
83  * (Secure Partition Manager) integration which separates the code into two
84  * parts: NSPE (Non-Secure Processing Environment) and SPE (Secure Processing
85  * Environment). When building for the SPE, an additional header file should be
86  * included.
87  */
88 #if defined(MBEDTLS_PSA_CRYPTO_SPM)
89 #define PSA_CRYPTO_SECURE 1
90 #include "crypto_spe.h"
91 #endif // MBEDTLS_PSA_CRYPTO_SPM
92 
93 #if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
94 
103 typedef struct {
104  uintptr_t MBEDTLS_PRIVATE(opaque)[2];
106 #endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
107 
108 #endif /* PSA_CRYPTO_PLATFORM_H */
#define MBEDTLS_PRIVATE(member)
int32_t mbedtls_key_owner_id_t
Macro wrapper for struct's memebrs.
Build-time configuration info.
static int mbedtls_key_owner_id_equal(mbedtls_key_owner_id_t id1, mbedtls_key_owner_id_t id2)
PSA crypto configuration options (set of defines)