Commit | Line | Data |
---|---|---|
700d8687 OM |
1 | /** |
2 | * \file check_config.h | |
3 | * | |
4 | * \brief Consistency checks for configuration options | |
5 | */ | |
6 | /* | |
7 | * Copyright (C) 2006-2018, ARM Limited, All Rights Reserved | |
8 | * SPDX-License-Identifier: GPL-2.0 | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; either version 2 of the License, or | |
13 | * (at your option) any later version. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | * GNU General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License along | |
21 | * with this program; if not, write to the Free Software Foundation, Inc., | |
22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
23 | * | |
24 | * This file is part of mbed TLS (https://tls.mbed.org) | |
25 | */ | |
26 | ||
27 | /* | |
28 | * It is recommended to include this file from your config.h | |
29 | * in order to catch dependency issues early. | |
30 | */ | |
31 | ||
32 | #ifndef MBEDTLS_CHECK_CONFIG_H | |
33 | #define MBEDTLS_CHECK_CONFIG_H | |
34 | ||
35 | /* | |
36 | * We assume CHAR_BIT is 8 in many places. In practice, this is true on our | |
37 | * target platforms, so not an issue, but let's just be extra sure. | |
38 | */ | |
39 | #include <limits.h> | |
40 | #if CHAR_BIT != 8 | |
41 | #error "mbed TLS requires a platform with 8-bit chars" | |
42 | #endif | |
43 | ||
44 | #if defined(_WIN32) | |
45 | #if !defined(MBEDTLS_PLATFORM_C) | |
46 | #error "MBEDTLS_PLATFORM_C is required on Windows" | |
47 | #endif | |
48 | ||
49 | /* Fix the config here. Not convenient to put an #ifdef _WIN32 in config.h as | |
50 | * it would confuse config.pl. */ | |
51 | #if !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && \ | |
52 | !defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) | |
53 | #define MBEDTLS_PLATFORM_SNPRINTF_ALT | |
54 | #endif | |
55 | #endif /* _WIN32 */ | |
56 | ||
57 | #if defined(TARGET_LIKE_MBED) && \ | |
58 | ( defined(MBEDTLS_NET_C) || defined(MBEDTLS_TIMING_C) ) | |
59 | #error "The NET and TIMING modules are not available for mbed OS - please use the network and timing functions provided by mbed OS" | |
60 | #endif | |
61 | ||
62 | #if defined(MBEDTLS_DEPRECATED_WARNING) && \ | |
63 | !defined(__GNUC__) && !defined(__clang__) | |
64 | #error "MBEDTLS_DEPRECATED_WARNING only works with GCC and Clang" | |
65 | #endif | |
66 | ||
67 | #if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_HAVE_TIME) | |
68 | #error "MBEDTLS_HAVE_TIME_DATE without MBEDTLS_HAVE_TIME does not make sense" | |
69 | #endif | |
70 | ||
71 | #if defined(MBEDTLS_AESNI_C) && !defined(MBEDTLS_HAVE_ASM) | |
72 | #error "MBEDTLS_AESNI_C defined, but not all prerequisites" | |
73 | #endif | |
74 | ||
75 | #if defined(MBEDTLS_CTR_DRBG_C) && !defined(MBEDTLS_AES_C) | |
76 | #error "MBEDTLS_CTR_DRBG_C defined, but not all prerequisites" | |
77 | #endif | |
78 | ||
79 | #if defined(MBEDTLS_DHM_C) && !defined(MBEDTLS_BIGNUM_C) | |
80 | #error "MBEDTLS_DHM_C defined, but not all prerequisites" | |
81 | #endif | |
82 | ||
83 | #if defined(MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT) && !defined(MBEDTLS_SSL_TRUNCATED_HMAC) | |
84 | #error "MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT defined, but not all prerequisites" | |
85 | #endif | |
86 | ||
87 | #if defined(MBEDTLS_CMAC_C) && \ | |
88 | !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_DES_C) | |
89 | #error "MBEDTLS_CMAC_C defined, but not all prerequisites" | |
90 | #endif | |
91 | ||
92 | #if defined(MBEDTLS_NIST_KW_C) && \ | |
93 | ( !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_CIPHER_C) ) | |
94 | #error "MBEDTLS_NIST_KW_C defined, but not all prerequisites" | |
95 | #endif | |
96 | ||
97 | #if defined(MBEDTLS_ECDH_C) && !defined(MBEDTLS_ECP_C) | |
98 | #error "MBEDTLS_ECDH_C defined, but not all prerequisites" | |
99 | #endif | |
100 | ||
101 | #if defined(MBEDTLS_ECDSA_C) && \ | |
102 | ( !defined(MBEDTLS_ECP_C) || \ | |
103 | !defined(MBEDTLS_ASN1_PARSE_C) || \ | |
104 | !defined(MBEDTLS_ASN1_WRITE_C) ) | |
105 | #error "MBEDTLS_ECDSA_C defined, but not all prerequisites" | |
106 | #endif | |
107 | ||
108 | #if defined(MBEDTLS_ECJPAKE_C) && \ | |
109 | ( !defined(MBEDTLS_ECP_C) || !defined(MBEDTLS_MD_C) ) | |
110 | #error "MBEDTLS_ECJPAKE_C defined, but not all prerequisites" | |
111 | #endif | |
112 | ||
113 | #if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C) | |
114 | #error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites" | |
115 | #endif | |
116 | ||
117 | #if defined(MBEDTLS_ECP_C) && ( !defined(MBEDTLS_BIGNUM_C) || ( \ | |
3a5ffba7 | 118 | !defined(MBEDTLS_ECP_DP_SECP128R1_ENABLED) && \ |
700d8687 OM |
119 | !defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) && \ |
120 | !defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) && \ | |
121 | !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && \ | |
122 | !defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) && \ | |
123 | !defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) && \ | |
124 | !defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) && \ | |
125 | !defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) && \ | |
126 | !defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) && \ | |
127 | !defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) && \ | |
128 | !defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) && \ | |
129 | !defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) ) ) | |
130 | #error "MBEDTLS_ECP_C defined, but not all prerequisites" | |
131 | #endif | |
132 | ||
133 | #if defined(MBEDTLS_ENTROPY_C) && (!defined(MBEDTLS_SHA512_C) && \ | |
134 | !defined(MBEDTLS_SHA256_C)) | |
135 | #error "MBEDTLS_ENTROPY_C defined, but not all prerequisites" | |
136 | #endif | |
137 | #if defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_SHA512_C) && \ | |
138 | defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 64) | |
139 | #error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high" | |
140 | #endif | |
141 | #if defined(MBEDTLS_ENTROPY_C) && \ | |
142 | ( !defined(MBEDTLS_SHA512_C) || defined(MBEDTLS_ENTROPY_FORCE_SHA256) ) \ | |
143 | && defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 32) | |
144 | #error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high" | |
145 | #endif | |
146 | #if defined(MBEDTLS_ENTROPY_C) && \ | |
147 | defined(MBEDTLS_ENTROPY_FORCE_SHA256) && !defined(MBEDTLS_SHA256_C) | |
148 | #error "MBEDTLS_ENTROPY_FORCE_SHA256 defined, but not all prerequisites" | |
149 | #endif | |
150 | ||
151 | #if defined(MBEDTLS_TEST_NULL_ENTROPY) && \ | |
152 | ( !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) ) | |
153 | #error "MBEDTLS_TEST_NULL_ENTROPY defined, but not all prerequisites" | |
154 | #endif | |
155 | #if defined(MBEDTLS_TEST_NULL_ENTROPY) && \ | |
156 | ( defined(MBEDTLS_ENTROPY_NV_SEED) || defined(MBEDTLS_ENTROPY_HARDWARE_ALT) || \ | |
157 | defined(MBEDTLS_HAVEGE_C) ) | |
158 | #error "MBEDTLS_TEST_NULL_ENTROPY defined, but entropy sources too" | |
159 | #endif | |
160 | ||
161 | #if defined(MBEDTLS_GCM_C) && ( \ | |
162 | !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_CAMELLIA_C) ) | |
163 | #error "MBEDTLS_GCM_C defined, but not all prerequisites" | |
164 | #endif | |
165 | ||
166 | #if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
167 | #error "MBEDTLS_ECP_RANDOMIZE_JAC_ALT defined, but not all prerequisites" | |
168 | #endif | |
169 | ||
170 | #if defined(MBEDTLS_ECP_ADD_MIXED_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
171 | #error "MBEDTLS_ECP_ADD_MIXED_ALT defined, but not all prerequisites" | |
172 | #endif | |
173 | ||
174 | #if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
175 | #error "MBEDTLS_ECP_DOUBLE_JAC_ALT defined, but not all prerequisites" | |
176 | #endif | |
177 | ||
178 | #if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
179 | #error "MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT defined, but not all prerequisites" | |
180 | #endif | |
181 | ||
182 | #if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
183 | #error "MBEDTLS_ECP_NORMALIZE_JAC_ALT defined, but not all prerequisites" | |
184 | #endif | |
185 | ||
186 | #if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
187 | #error "MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT defined, but not all prerequisites" | |
188 | #endif | |
189 | ||
190 | #if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
191 | #error "MBEDTLS_ECP_RANDOMIZE_MXZ_ALT defined, but not all prerequisites" | |
192 | #endif | |
193 | ||
194 | #if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
195 | #error "MBEDTLS_ECP_NORMALIZE_MXZ_ALT defined, but not all prerequisites" | |
196 | #endif | |
197 | ||
198 | #if defined(MBEDTLS_HAVEGE_C) && !defined(MBEDTLS_TIMING_C) | |
199 | #error "MBEDTLS_HAVEGE_C defined, but not all prerequisites" | |
200 | #endif | |
201 | ||
202 | #if defined(MBEDTLS_HKDF_C) && !defined(MBEDTLS_MD_C) | |
203 | #error "MBEDTLS_HKDF_C defined, but not all prerequisites" | |
204 | #endif | |
205 | ||
206 | #if defined(MBEDTLS_HMAC_DRBG_C) && !defined(MBEDTLS_MD_C) | |
207 | #error "MBEDTLS_HMAC_DRBG_C defined, but not all prerequisites" | |
208 | #endif | |
209 | ||
210 | #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) && \ | |
211 | ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) ) | |
212 | #error "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED defined, but not all prerequisites" | |
213 | #endif | |
214 | ||
215 | #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ | |
216 | ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) ) | |
217 | #error "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED defined, but not all prerequisites" | |
218 | #endif | |
219 | ||
220 | #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) && !defined(MBEDTLS_DHM_C) | |
221 | #error "MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED defined, but not all prerequisites" | |
222 | #endif | |
223 | ||
224 | #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) && \ | |
225 | !defined(MBEDTLS_ECDH_C) | |
226 | #error "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED defined, but not all prerequisites" | |
227 | #endif | |
228 | ||
229 | #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ | |
230 | ( !defined(MBEDTLS_DHM_C) || !defined(MBEDTLS_RSA_C) || \ | |
231 | !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) ) | |
232 | #error "MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED defined, but not all prerequisites" | |
233 | #endif | |
234 | ||
235 | #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ | |
236 | ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_RSA_C) || \ | |
237 | !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) ) | |
238 | #error "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED defined, but not all prerequisites" | |
239 | #endif | |
240 | ||
241 | #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \ | |
242 | ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_ECDSA_C) || \ | |
243 | !defined(MBEDTLS_X509_CRT_PARSE_C) ) | |
244 | #error "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED defined, but not all prerequisites" | |
245 | #endif | |
246 | ||
247 | #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) && \ | |
248 | ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \ | |
249 | !defined(MBEDTLS_PKCS1_V15) ) | |
250 | #error "MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED defined, but not all prerequisites" | |
251 | #endif | |
252 | ||
253 | #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \ | |
254 | ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \ | |
255 | !defined(MBEDTLS_PKCS1_V15) ) | |
256 | #error "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED defined, but not all prerequisites" | |
257 | #endif | |
258 | ||
259 | #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \ | |
260 | ( !defined(MBEDTLS_ECJPAKE_C) || !defined(MBEDTLS_SHA256_C) || \ | |
261 | !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) ) | |
262 | #error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites" | |
263 | #endif | |
264 | ||
265 | #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ | |
266 | ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) | |
267 | #error "MBEDTLS_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites" | |
268 | #endif | |
269 | ||
270 | #if defined(MBEDTLS_PADLOCK_C) && !defined(MBEDTLS_HAVE_ASM) | |
271 | #error "MBEDTLS_PADLOCK_C defined, but not all prerequisites" | |
272 | #endif | |
273 | ||
274 | #if defined(MBEDTLS_PEM_PARSE_C) && !defined(MBEDTLS_BASE64_C) | |
275 | #error "MBEDTLS_PEM_PARSE_C defined, but not all prerequisites" | |
276 | #endif | |
277 | ||
278 | #if defined(MBEDTLS_PEM_WRITE_C) && !defined(MBEDTLS_BASE64_C) | |
279 | #error "MBEDTLS_PEM_WRITE_C defined, but not all prerequisites" | |
280 | #endif | |
281 | ||
282 | #if defined(MBEDTLS_PK_C) && \ | |
283 | ( !defined(MBEDTLS_RSA_C) && !defined(MBEDTLS_ECP_C) ) | |
284 | #error "MBEDTLS_PK_C defined, but not all prerequisites" | |
285 | #endif | |
286 | ||
287 | #if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_PK_C) | |
288 | #error "MBEDTLS_PK_PARSE_C defined, but not all prerequisites" | |
289 | #endif | |
290 | ||
291 | #if defined(MBEDTLS_PK_WRITE_C) && !defined(MBEDTLS_PK_C) | |
292 | #error "MBEDTLS_PK_WRITE_C defined, but not all prerequisites" | |
293 | #endif | |
294 | ||
295 | #if defined(MBEDTLS_PKCS11_C) && !defined(MBEDTLS_PK_C) | |
296 | #error "MBEDTLS_PKCS11_C defined, but not all prerequisites" | |
297 | #endif | |
298 | ||
299 | #if defined(MBEDTLS_PLATFORM_EXIT_ALT) && !defined(MBEDTLS_PLATFORM_C) | |
300 | #error "MBEDTLS_PLATFORM_EXIT_ALT defined, but not all prerequisites" | |
301 | #endif | |
302 | ||
303 | #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) && !defined(MBEDTLS_PLATFORM_C) | |
304 | #error "MBEDTLS_PLATFORM_EXIT_MACRO defined, but not all prerequisites" | |
305 | #endif | |
306 | ||
307 | #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) &&\ | |
308 | ( defined(MBEDTLS_PLATFORM_STD_EXIT) ||\ | |
309 | defined(MBEDTLS_PLATFORM_EXIT_ALT) ) | |
310 | #error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously" | |
311 | #endif | |
312 | ||
313 | #if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\ | |
314 | ( !defined(MBEDTLS_PLATFORM_C) ||\ | |
315 | !defined(MBEDTLS_HAVE_TIME) ) | |
316 | #error "MBEDTLS_PLATFORM_TIME_ALT defined, but not all prerequisites" | |
317 | #endif | |
318 | ||
319 | #if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\ | |
320 | ( !defined(MBEDTLS_PLATFORM_C) ||\ | |
321 | !defined(MBEDTLS_HAVE_TIME) ) | |
322 | #error "MBEDTLS_PLATFORM_TIME_MACRO defined, but not all prerequisites" | |
323 | #endif | |
324 | ||
325 | #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\ | |
326 | ( !defined(MBEDTLS_PLATFORM_C) ||\ | |
327 | !defined(MBEDTLS_HAVE_TIME) ) | |
328 | #error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO defined, but not all prerequisites" | |
329 | #endif | |
330 | ||
331 | #if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\ | |
332 | ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\ | |
333 | defined(MBEDTLS_PLATFORM_TIME_ALT) ) | |
334 | #error "MBEDTLS_PLATFORM_TIME_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously" | |
335 | #endif | |
336 | ||
337 | #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\ | |
338 | ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\ | |
339 | defined(MBEDTLS_PLATFORM_TIME_ALT) ) | |
340 | #error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously" | |
341 | #endif | |
342 | ||
343 | #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) | |
344 | #error "MBEDTLS_PLATFORM_FPRINTF_ALT defined, but not all prerequisites" | |
345 | #endif | |
346 | ||
347 | #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) | |
348 | #error "MBEDTLS_PLATFORM_FPRINTF_MACRO defined, but not all prerequisites" | |
349 | #endif | |
350 | ||
351 | #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) &&\ | |
352 | ( defined(MBEDTLS_PLATFORM_STD_FPRINTF) ||\ | |
353 | defined(MBEDTLS_PLATFORM_FPRINTF_ALT) ) | |
354 | #error "MBEDTLS_PLATFORM_FPRINTF_MACRO and MBEDTLS_PLATFORM_STD_FPRINTF/MBEDTLS_PLATFORM_FPRINTF_ALT cannot be defined simultaneously" | |
355 | #endif | |
356 | ||
357 | #if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\ | |
358 | ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) | |
359 | #error "MBEDTLS_PLATFORM_FREE_MACRO defined, but not all prerequisites" | |
360 | #endif | |
361 | ||
362 | #if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\ | |
363 | defined(MBEDTLS_PLATFORM_STD_FREE) | |
364 | #error "MBEDTLS_PLATFORM_FREE_MACRO and MBEDTLS_PLATFORM_STD_FREE cannot be defined simultaneously" | |
365 | #endif | |
366 | ||
367 | #if defined(MBEDTLS_PLATFORM_FREE_MACRO) && !defined(MBEDTLS_PLATFORM_CALLOC_MACRO) | |
368 | #error "MBEDTLS_PLATFORM_CALLOC_MACRO must be defined if MBEDTLS_PLATFORM_FREE_MACRO is" | |
369 | #endif | |
370 | ||
371 | #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\ | |
372 | ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) | |
373 | #error "MBEDTLS_PLATFORM_CALLOC_MACRO defined, but not all prerequisites" | |
374 | #endif | |
375 | ||
376 | #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\ | |
377 | defined(MBEDTLS_PLATFORM_STD_CALLOC) | |
378 | #error "MBEDTLS_PLATFORM_CALLOC_MACRO and MBEDTLS_PLATFORM_STD_CALLOC cannot be defined simultaneously" | |
379 | #endif | |
380 | ||
381 | #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) && !defined(MBEDTLS_PLATFORM_FREE_MACRO) | |
382 | #error "MBEDTLS_PLATFORM_FREE_MACRO must be defined if MBEDTLS_PLATFORM_CALLOC_MACRO is" | |
383 | #endif | |
384 | ||
385 | #if defined(MBEDTLS_PLATFORM_MEMORY) && !defined(MBEDTLS_PLATFORM_C) | |
386 | #error "MBEDTLS_PLATFORM_MEMORY defined, but not all prerequisites" | |
387 | #endif | |
388 | ||
389 | #if defined(MBEDTLS_PLATFORM_PRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) | |
390 | #error "MBEDTLS_PLATFORM_PRINTF_ALT defined, but not all prerequisites" | |
391 | #endif | |
392 | ||
393 | #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) | |
394 | #error "MBEDTLS_PLATFORM_PRINTF_MACRO defined, but not all prerequisites" | |
395 | #endif | |
396 | ||
397 | #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) &&\ | |
398 | ( defined(MBEDTLS_PLATFORM_STD_PRINTF) ||\ | |
399 | defined(MBEDTLS_PLATFORM_PRINTF_ALT) ) | |
400 | #error "MBEDTLS_PLATFORM_PRINTF_MACRO and MBEDTLS_PLATFORM_STD_PRINTF/MBEDTLS_PLATFORM_PRINTF_ALT cannot be defined simultaneously" | |
401 | #endif | |
402 | ||
403 | #if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) | |
404 | #error "MBEDTLS_PLATFORM_SNPRINTF_ALT defined, but not all prerequisites" | |
405 | #endif | |
406 | ||
407 | #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) | |
408 | #error "MBEDTLS_PLATFORM_SNPRINTF_MACRO defined, but not all prerequisites" | |
409 | #endif | |
410 | ||
411 | #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) &&\ | |
412 | ( defined(MBEDTLS_PLATFORM_STD_SNPRINTF) ||\ | |
413 | defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) ) | |
414 | #error "MBEDTLS_PLATFORM_SNPRINTF_MACRO and MBEDTLS_PLATFORM_STD_SNPRINTF/MBEDTLS_PLATFORM_SNPRINTF_ALT cannot be defined simultaneously" | |
415 | #endif | |
416 | ||
417 | #if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) &&\ | |
418 | !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) | |
419 | #error "MBEDTLS_PLATFORM_STD_MEM_HDR defined, but not all prerequisites" | |
420 | #endif | |
421 | ||
422 | #if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY) | |
423 | #error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites" | |
424 | #endif | |
425 | ||
426 | #if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY) | |
427 | #error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites" | |
428 | #endif | |
429 | ||
430 | #if defined(MBEDTLS_PLATFORM_STD_FREE) && !defined(MBEDTLS_PLATFORM_MEMORY) | |
431 | #error "MBEDTLS_PLATFORM_STD_FREE defined, but not all prerequisites" | |
432 | #endif | |
433 | ||
434 | #if defined(MBEDTLS_PLATFORM_STD_EXIT) &&\ | |
435 | !defined(MBEDTLS_PLATFORM_EXIT_ALT) | |
436 | #error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites" | |
437 | #endif | |
438 | ||
439 | #if defined(MBEDTLS_PLATFORM_STD_TIME) &&\ | |
440 | ( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\ | |
441 | !defined(MBEDTLS_HAVE_TIME) ) | |
442 | #error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites" | |
443 | #endif | |
444 | ||
445 | #if defined(MBEDTLS_PLATFORM_STD_FPRINTF) &&\ | |
446 | !defined(MBEDTLS_PLATFORM_FPRINTF_ALT) | |
447 | #error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites" | |
448 | #endif | |
449 | ||
450 | #if defined(MBEDTLS_PLATFORM_STD_PRINTF) &&\ | |
451 | !defined(MBEDTLS_PLATFORM_PRINTF_ALT) | |
452 | #error "MBEDTLS_PLATFORM_STD_PRINTF defined, but not all prerequisites" | |
453 | #endif | |
454 | ||
455 | #if defined(MBEDTLS_PLATFORM_STD_SNPRINTF) &&\ | |
456 | !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) | |
457 | #error "MBEDTLS_PLATFORM_STD_SNPRINTF defined, but not all prerequisites" | |
458 | #endif | |
459 | ||
460 | #if defined(MBEDTLS_ENTROPY_NV_SEED) &&\ | |
461 | ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_ENTROPY_C) ) | |
462 | #error "MBEDTLS_ENTROPY_NV_SEED defined, but not all prerequisites" | |
463 | #endif | |
464 | ||
465 | #if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) &&\ | |
466 | !defined(MBEDTLS_ENTROPY_NV_SEED) | |
467 | #error "MBEDTLS_PLATFORM_NV_SEED_ALT defined, but not all prerequisites" | |
468 | #endif | |
469 | ||
470 | #if defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) &&\ | |
471 | !defined(MBEDTLS_PLATFORM_NV_SEED_ALT) | |
472 | #error "MBEDTLS_PLATFORM_STD_NV_SEED_READ defined, but not all prerequisites" | |
473 | #endif | |
474 | ||
475 | #if defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) &&\ | |
476 | !defined(MBEDTLS_PLATFORM_NV_SEED_ALT) | |
477 | #error "MBEDTLS_PLATFORM_STD_NV_SEED_WRITE defined, but not all prerequisites" | |
478 | #endif | |
479 | ||
480 | #if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) &&\ | |
481 | ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) ||\ | |
482 | defined(MBEDTLS_PLATFORM_NV_SEED_ALT) ) | |
483 | #error "MBEDTLS_PLATFORM_NV_SEED_READ_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_READ cannot be defined simultaneously" | |
484 | #endif | |
485 | ||
486 | #if defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) &&\ | |
487 | ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) ||\ | |
488 | defined(MBEDTLS_PLATFORM_NV_SEED_ALT) ) | |
489 | #error "MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_WRITE cannot be defined simultaneously" | |
490 | #endif | |
491 | ||
492 | #if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ | |
493 | !defined(MBEDTLS_OID_C) ) | |
494 | #error "MBEDTLS_RSA_C defined, but not all prerequisites" | |
495 | #endif | |
496 | ||
497 | #if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_PKCS1_V21) && \ | |
498 | !defined(MBEDTLS_PKCS1_V15) ) | |
499 | #error "MBEDTLS_RSA_C defined, but none of the PKCS1 versions enabled" | |
500 | #endif | |
501 | ||
502 | #if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) && \ | |
503 | ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_PKCS1_V21) ) | |
504 | #error "MBEDTLS_X509_RSASSA_PSS_SUPPORT defined, but not all prerequisites" | |
505 | #endif | |
506 | ||
507 | #if defined(MBEDTLS_SSL_PROTO_SSL3) && ( !defined(MBEDTLS_MD5_C) || \ | |
508 | !defined(MBEDTLS_SHA1_C) ) | |
509 | #error "MBEDTLS_SSL_PROTO_SSL3 defined, but not all prerequisites" | |
510 | #endif | |
511 | ||
512 | #if defined(MBEDTLS_SSL_PROTO_TLS1) && ( !defined(MBEDTLS_MD5_C) || \ | |
513 | !defined(MBEDTLS_SHA1_C) ) | |
514 | #error "MBEDTLS_SSL_PROTO_TLS1 defined, but not all prerequisites" | |
515 | #endif | |
516 | ||
517 | #if defined(MBEDTLS_SSL_PROTO_TLS1_1) && ( !defined(MBEDTLS_MD5_C) || \ | |
518 | !defined(MBEDTLS_SHA1_C) ) | |
519 | #error "MBEDTLS_SSL_PROTO_TLS1_1 defined, but not all prerequisites" | |
520 | #endif | |
521 | ||
522 | #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && ( !defined(MBEDTLS_SHA1_C) && \ | |
523 | !defined(MBEDTLS_SHA256_C) && !defined(MBEDTLS_SHA512_C) ) | |
524 | #error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites" | |
525 | #endif | |
526 | ||
527 | #if defined(MBEDTLS_SSL_PROTO_DTLS) && \ | |
528 | !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ | |
529 | !defined(MBEDTLS_SSL_PROTO_TLS1_2) | |
530 | #error "MBEDTLS_SSL_PROTO_DTLS defined, but not all prerequisites" | |
531 | #endif | |
532 | ||
533 | #if defined(MBEDTLS_SSL_CLI_C) && !defined(MBEDTLS_SSL_TLS_C) | |
534 | #error "MBEDTLS_SSL_CLI_C defined, but not all prerequisites" | |
535 | #endif | |
536 | ||
537 | #if defined(MBEDTLS_SSL_TLS_C) && ( !defined(MBEDTLS_CIPHER_C) || \ | |
538 | !defined(MBEDTLS_MD_C) ) | |
539 | #error "MBEDTLS_SSL_TLS_C defined, but not all prerequisites" | |
540 | #endif | |
541 | ||
542 | #if defined(MBEDTLS_SSL_SRV_C) && !defined(MBEDTLS_SSL_TLS_C) | |
543 | #error "MBEDTLS_SSL_SRV_C defined, but not all prerequisites" | |
544 | #endif | |
545 | ||
546 | #if defined(MBEDTLS_SSL_TLS_C) && (!defined(MBEDTLS_SSL_PROTO_SSL3) && \ | |
547 | !defined(MBEDTLS_SSL_PROTO_TLS1) && !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ | |
548 | !defined(MBEDTLS_SSL_PROTO_TLS1_2)) | |
549 | #error "MBEDTLS_SSL_TLS_C defined, but no protocols are active" | |
550 | #endif | |
551 | ||
552 | #if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_SSL3) && \ | |
553 | defined(MBEDTLS_SSL_PROTO_TLS1_1) && !defined(MBEDTLS_SSL_PROTO_TLS1)) | |
554 | #error "Illegal protocol selection" | |
555 | #endif | |
556 | ||
557 | #if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_TLS1) && \ | |
558 | defined(MBEDTLS_SSL_PROTO_TLS1_2) && !defined(MBEDTLS_SSL_PROTO_TLS1_1)) | |
559 | #error "Illegal protocol selection" | |
560 | #endif | |
561 | ||
562 | #if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_SSL3) && \ | |
563 | defined(MBEDTLS_SSL_PROTO_TLS1_2) && (!defined(MBEDTLS_SSL_PROTO_TLS1) || \ | |
564 | !defined(MBEDTLS_SSL_PROTO_TLS1_1))) | |
565 | #error "Illegal protocol selection" | |
566 | #endif | |
567 | ||
568 | #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && !defined(MBEDTLS_SSL_PROTO_DTLS) | |
569 | #error "MBEDTLS_SSL_DTLS_HELLO_VERIFY defined, but not all prerequisites" | |
570 | #endif | |
571 | ||
572 | #if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && \ | |
573 | !defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) | |
574 | #error "MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE defined, but not all prerequisites" | |
575 | #endif | |
576 | ||
577 | #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) && \ | |
578 | ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) ) | |
579 | #error "MBEDTLS_SSL_DTLS_ANTI_REPLAY defined, but not all prerequisites" | |
580 | #endif | |
581 | ||
582 | #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) && \ | |
583 | ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) ) | |
584 | #error "MBEDTLS_SSL_DTLS_BADMAC_LIMIT defined, but not all prerequisites" | |
585 | #endif | |
586 | ||
587 | #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) && \ | |
588 | !defined(MBEDTLS_SSL_PROTO_TLS1) && \ | |
589 | !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ | |
590 | !defined(MBEDTLS_SSL_PROTO_TLS1_2) | |
591 | #error "MBEDTLS_SSL_ENCRYPT_THEN_MAC defined, but not all prerequsites" | |
592 | #endif | |
593 | ||
594 | #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) && \ | |
595 | !defined(MBEDTLS_SSL_PROTO_TLS1) && \ | |
596 | !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ | |
597 | !defined(MBEDTLS_SSL_PROTO_TLS1_2) | |
598 | #error "MBEDTLS_SSL_EXTENDED_MASTER_SECRET defined, but not all prerequsites" | |
599 | #endif | |
600 | ||
601 | #if defined(MBEDTLS_SSL_TICKET_C) && !defined(MBEDTLS_CIPHER_C) | |
602 | #error "MBEDTLS_SSL_TICKET_C defined, but not all prerequisites" | |
603 | #endif | |
604 | ||
605 | #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) && \ | |
606 | !defined(MBEDTLS_SSL_PROTO_SSL3) && !defined(MBEDTLS_SSL_PROTO_TLS1) | |
607 | #error "MBEDTLS_SSL_CBC_RECORD_SPLITTING defined, but not all prerequisites" | |
608 | #endif | |
609 | ||
610 | #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) && \ | |
611 | !defined(MBEDTLS_X509_CRT_PARSE_C) | |
612 | #error "MBEDTLS_SSL_SERVER_NAME_INDICATION defined, but not all prerequisites" | |
613 | #endif | |
614 | ||
615 | #if defined(MBEDTLS_THREADING_PTHREAD) | |
616 | #if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL) | |
617 | #error "MBEDTLS_THREADING_PTHREAD defined, but not all prerequisites" | |
618 | #endif | |
619 | #define MBEDTLS_THREADING_IMPL | |
620 | #endif | |
621 | ||
622 | #if defined(MBEDTLS_THREADING_ALT) | |
623 | #if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL) | |
624 | #error "MBEDTLS_THREADING_ALT defined, but not all prerequisites" | |
625 | #endif | |
626 | #define MBEDTLS_THREADING_IMPL | |
627 | #endif | |
628 | ||
629 | #if defined(MBEDTLS_THREADING_C) && !defined(MBEDTLS_THREADING_IMPL) | |
630 | #error "MBEDTLS_THREADING_C defined, single threading implementation required" | |
631 | #endif | |
632 | #undef MBEDTLS_THREADING_IMPL | |
633 | ||
634 | #if defined(MBEDTLS_VERSION_FEATURES) && !defined(MBEDTLS_VERSION_C) | |
635 | #error "MBEDTLS_VERSION_FEATURES defined, but not all prerequisites" | |
636 | #endif | |
637 | ||
638 | #if defined(MBEDTLS_X509_USE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ | |
639 | !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_PARSE_C) || \ | |
640 | !defined(MBEDTLS_PK_PARSE_C) ) | |
641 | #error "MBEDTLS_X509_USE_C defined, but not all prerequisites" | |
642 | #endif | |
643 | ||
644 | #if defined(MBEDTLS_X509_CREATE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ | |
645 | !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_WRITE_C) || \ | |
646 | !defined(MBEDTLS_PK_WRITE_C) ) | |
647 | #error "MBEDTLS_X509_CREATE_C defined, but not all prerequisites" | |
648 | #endif | |
649 | ||
650 | #if defined(MBEDTLS_X509_CRT_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) | |
651 | #error "MBEDTLS_X509_CRT_PARSE_C defined, but not all prerequisites" | |
652 | #endif | |
653 | ||
654 | #if defined(MBEDTLS_X509_CRL_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) | |
655 | #error "MBEDTLS_X509_CRL_PARSE_C defined, but not all prerequisites" | |
656 | #endif | |
657 | ||
658 | #if defined(MBEDTLS_X509_CSR_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) | |
659 | #error "MBEDTLS_X509_CSR_PARSE_C defined, but not all prerequisites" | |
660 | #endif | |
661 | ||
662 | #if defined(MBEDTLS_X509_CRT_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) ) | |
663 | #error "MBEDTLS_X509_CRT_WRITE_C defined, but not all prerequisites" | |
664 | #endif | |
665 | ||
666 | #if defined(MBEDTLS_X509_CSR_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) ) | |
667 | #error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites" | |
668 | #endif | |
669 | ||
670 | #if defined(MBEDTLS_HAVE_INT32) && defined(MBEDTLS_HAVE_INT64) | |
671 | #error "MBEDTLS_HAVE_INT32 and MBEDTLS_HAVE_INT64 cannot be defined simultaneously" | |
672 | #endif /* MBEDTLS_HAVE_INT32 && MBEDTLS_HAVE_INT64 */ | |
673 | ||
674 | #if ( defined(MBEDTLS_HAVE_INT32) || defined(MBEDTLS_HAVE_INT64) ) && \ | |
675 | defined(MBEDTLS_HAVE_ASM) | |
676 | #error "MBEDTLS_HAVE_INT32/MBEDTLS_HAVE_INT64 and MBEDTLS_HAVE_ASM cannot be defined simultaneously" | |
677 | #endif /* (MBEDTLS_HAVE_INT32 || MBEDTLS_HAVE_INT64) && MBEDTLS_HAVE_ASM */ | |
678 | ||
679 | /* | |
680 | * Avoid warning from -pedantic. This is a convenient place for this | |
681 | * workaround since this is included by every single file before the | |
682 | * #if defined(MBEDTLS_xxx_C) that results in emtpy translation units. | |
683 | */ | |
684 | typedef int mbedtls_iso_c_forbids_empty_translation_units; | |
685 | ||
686 | #endif /* MBEDTLS_CHECK_CONFIG_H */ |