Mbed TLS v4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tf-psa-crypto/include/tf-psa-crypto/build_info.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright The Mbed TLS Contributors
11  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
12  */
13 
14 #ifndef TF_PSA_CRYPTO_BUILD_INFO_H
15 #define TF_PSA_CRYPTO_BUILD_INFO_H
16 
17 /*
18  * Version macros are defined in build_info.h rather than in version.h so that
19  * the user config files have access to them. That way, for example, users who
20  * deploy applications to multiple devices with different versions of
21  * TF-PSA-Crypto can write configurations that depend on the version.
22  */
27 #define TF_PSA_CRYPTO_VERSION_MAJOR 1
28 #define TF_PSA_CRYPTO_VERSION_MINOR 0
29 #define TF_PSA_CRYPTO_VERSION_PATCH 0
30 
36 #define TF_PSA_CRYPTO_VERSION_NUMBER 0x01000000
37 #define TF_PSA_CRYPTO_VERSION_STRING "1.0.0"
38 #define TF_PSA_CRYPTO_VERSION_STRING_FULL "TF-PSA-Crypto 1.0.0"
39 
40 /* Macros for build-time platform detection */
41 
42 #if !defined(MBEDTLS_ARCH_IS_ARM64) && \
43  (defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC))
44 #define MBEDTLS_ARCH_IS_ARM64
45 #endif
46 
47 #if !defined(MBEDTLS_ARCH_IS_ARM32) && \
48  (defined(__arm__) || defined(_M_ARM) || \
49  defined(_M_ARMT) || defined(__thumb__) || defined(__thumb2__))
50 #define MBEDTLS_ARCH_IS_ARM32
51 #endif
52 
53 #if !defined(MBEDTLS_ARCH_IS_X64) && \
54  (defined(__amd64__) || defined(__x86_64__) || \
55  ((defined(_M_X64) || defined(_M_AMD64)) && !defined(_M_ARM64EC)))
56 #define MBEDTLS_ARCH_IS_X64
57 #endif
58 
59 #if !defined(MBEDTLS_ARCH_IS_X86) && \
60  (defined(__i386__) || defined(_X86_) || \
61  (defined(_M_IX86) && !defined(_M_I86)))
62 #define MBEDTLS_ARCH_IS_X86
63 #endif
64 
65 #if !defined(MBEDTLS_PLATFORM_IS_WINDOWS_ON_ARM64) && \
66  (defined(_M_ARM64) || defined(_M_ARM64EC))
67 #define MBEDTLS_PLATFORM_IS_WINDOWS_ON_ARM64
68 #endif
69 
70 /* This is defined if the architecture is Armv8-A, or higher */
71 #if !defined(MBEDTLS_ARCH_IS_ARMV8_A)
72 #if defined(__ARM_ARCH) && defined(__ARM_ARCH_PROFILE)
73 #if (__ARM_ARCH >= 8) && (__ARM_ARCH_PROFILE == 'A')
74 /* GCC, clang, armclang and IAR */
75 #define MBEDTLS_ARCH_IS_ARMV8_A
76 #endif
77 #elif defined(__ARM_ARCH_8A)
78 /* Alternative defined by clang */
79 #define MBEDTLS_ARCH_IS_ARMV8_A
80 #elif defined(_M_ARM64) || defined(_M_ARM64EC)
81 /* MSVC ARM64 is at least Armv8.0-A */
82 #define MBEDTLS_ARCH_IS_ARMV8_A
83 #endif
84 #endif
85 
86 #if defined(__GNUC__) && !defined(__ARMCC_VERSION) && !defined(__clang__) \
87  && !defined(__llvm__) && !defined(__INTEL_COMPILER)
88 /* Defined if the compiler really is gcc and not clang, etc */
89 #define MBEDTLS_COMPILER_IS_GCC
90 #define MBEDTLS_GCC_VERSION \
91  (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
92 #endif
93 
94 #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
95 #define _CRT_SECURE_NO_DEPRECATE 1
96 #endif
97 
98 /* Define `inline` on some non-C99-compliant compilers. */
99 #if (defined(__ARMCC_VERSION) || defined(_MSC_VER)) && \
100  !defined(inline) && !defined(__cplusplus)
101 #define inline __inline
102 #endif
103 
104 #if defined(TF_PSA_CRYPTO_CONFIG_FILES_READ)
105 #error \
106  "Something went wrong: TF_PSA_CRYPTO_CONFIG_FILES_READ defined before reading the config files!"
107 #endif
108 #if defined(TF_PSA_CRYPTO_CONFIG_IS_FINALIZED)
109 #error \
110  "Something went wrong: TF_PSA_CRYPTO_CONFIG_IS_FINALIZED defined before reading the config files!"
111 #endif
112 
113 /* PSA crypto configuration */
114 #if defined(TF_PSA_CRYPTO_CONFIG_FILE)
115 #include TF_PSA_CRYPTO_CONFIG_FILE
116 #else
117 #include "psa/crypto_config.h"
118 #endif
119 #if defined(TF_PSA_CRYPTO_USER_CONFIG_FILE)
120 #include TF_PSA_CRYPTO_USER_CONFIG_FILE
121 #endif
122 
123 /* For the sake of consistency checks in tf_psa_crypto_config.c */
124 #if defined(TF_PSA_CRYPTO_INCLUDE_AFTER_RAW_CONFIG)
125 #include TF_PSA_CRYPTO_INCLUDE_AFTER_RAW_CONFIG
126 #endif
127 
128 /* Indicate that all configuration files have been read.
129  * It is now time to adjust the configuration (follow through on dependencies,
130  * make PSA and legacy crypto consistent, etc.).
131  */
132 #define TF_PSA_CRYPTO_CONFIG_FILES_READ
133 
134 #if defined(TF_PSA_CRYPTO_CONFIG_VERSION)
135 #if (TF_PSA_CRYPTO_CONFIG_VERSION < 0x01000000) || \
136  (TF_PSA_CRYPTO_CONFIG_VERSION > TF_PSA_CRYPTO_VERSION_NUMBER)
137 #error "Invalid config version, defined value of TF_PSA_CRYPTO_CONFIG_VERSION is unsupported"
138 #endif
139 #endif
140 
141 /* Auto-enable MBEDTLS_MD_C if needed by a module that didn't require it
142  * in a previous release, to ensure backwards compatibility.
143  */
144 #if defined(MBEDTLS_PKCS5_C)
145 #define MBEDTLS_MD_C
146 #endif
147 
148 /* PSA crypto specific configuration options
149  * - If config_psa.h reads a configuration option in preprocessor directive,
150  * this symbol should be set before its inclusion. (e.g. MBEDTLS_MD_C)
151  * - If config_psa.h writes a configuration option in conditional directive,
152  * this symbol should be consulted after its inclusion.
153  * (e.g. MBEDTLS_MD_LIGHT)
154  */
155 #include "mbedtls/private/config_psa.h"
156 
157 #include "mbedtls/config_adjust_legacy_crypto.h"
158 
159 /* Indicate that all configuration symbols are set,
160  * even the ones that are calculated programmatically.
161  * It is now safe to query the configuration (to check it, to size buffers,
162  * etc.).
163  */
164 #define TF_PSA_CRYPTO_CONFIG_IS_FINALIZED
165 
166 /* Up to Mbed TLS 3.6, build_info.h included check_config.h which included
167  * <limits.h>. Keep including it until it's explicitly included everywhere
168  * that uses definitions from <limits.h>.
169  * https://github.com/Mbed-TLS/mbedtls/issues/10305
170  */
171 #include <limits.h>
172 
173 /*
174  * Avoid warning from -pedantic. This is a convenient place for this
175  * workaround since this is included by every single file before the
176  * #if defined(MBEDTLS_xxx_C) that results in empty translation units.
177  */
179 
180 #endif /* TF_PSA_CRYPTO_BUILD_INFO_H */
PSA crypto configuration options (set of defines)