]>
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) || ( \ | |
118 | !defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) && \ | |
119 | !defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) && \ | |
120 | !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && \ | |
121 | !defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) && \ | |
122 | !defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) && \ | |
123 | !defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) && \ | |
124 | !defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) && \ | |
125 | !defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) && \ | |
126 | !defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) && \ | |
127 | !defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) && \ | |
128 | !defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) ) ) | |
129 | #error "MBEDTLS_ECP_C defined, but not all prerequisites" | |
130 | #endif | |
131 | ||
132 | #if defined(MBEDTLS_ENTROPY_C) && (!defined(MBEDTLS_SHA512_C) && \ | |
133 | !defined(MBEDTLS_SHA256_C)) | |
134 | #error "MBEDTLS_ENTROPY_C defined, but not all prerequisites" | |
135 | #endif | |
136 | #if defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_SHA512_C) && \ | |
137 | defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 64) | |
138 | #error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high" | |
139 | #endif | |
140 | #if defined(MBEDTLS_ENTROPY_C) && \ | |
141 | ( !defined(MBEDTLS_SHA512_C) || defined(MBEDTLS_ENTROPY_FORCE_SHA256) ) \ | |
142 | && defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 32) | |
143 | #error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high" | |
144 | #endif | |
145 | #if defined(MBEDTLS_ENTROPY_C) && \ | |
146 | defined(MBEDTLS_ENTROPY_FORCE_SHA256) && !defined(MBEDTLS_SHA256_C) | |
147 | #error "MBEDTLS_ENTROPY_FORCE_SHA256 defined, but not all prerequisites" | |
148 | #endif | |
149 | ||
150 | #if defined(MBEDTLS_TEST_NULL_ENTROPY) && \ | |
151 | ( !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) ) | |
152 | #error "MBEDTLS_TEST_NULL_ENTROPY defined, but not all prerequisites" | |
153 | #endif | |
154 | #if defined(MBEDTLS_TEST_NULL_ENTROPY) && \ | |
155 | ( defined(MBEDTLS_ENTROPY_NV_SEED) || defined(MBEDTLS_ENTROPY_HARDWARE_ALT) || \ | |
156 | defined(MBEDTLS_HAVEGE_C) ) | |
157 | #error "MBEDTLS_TEST_NULL_ENTROPY defined, but entropy sources too" | |
158 | #endif | |
159 | ||
160 | #if defined(MBEDTLS_GCM_C) && ( \ | |
161 | !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_CAMELLIA_C) ) | |
162 | #error "MBEDTLS_GCM_C defined, but not all prerequisites" | |
163 | #endif | |
164 | ||
165 | #if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
166 | #error "MBEDTLS_ECP_RANDOMIZE_JAC_ALT defined, but not all prerequisites" | |
167 | #endif | |
168 | ||
169 | #if defined(MBEDTLS_ECP_ADD_MIXED_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
170 | #error "MBEDTLS_ECP_ADD_MIXED_ALT defined, but not all prerequisites" | |
171 | #endif | |
172 | ||
173 | #if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
174 | #error "MBEDTLS_ECP_DOUBLE_JAC_ALT defined, but not all prerequisites" | |
175 | #endif | |
176 | ||
177 | #if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
178 | #error "MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT defined, but not all prerequisites" | |
179 | #endif | |
180 | ||
181 | #if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
182 | #error "MBEDTLS_ECP_NORMALIZE_JAC_ALT defined, but not all prerequisites" | |
183 | #endif | |
184 | ||
185 | #if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
186 | #error "MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT defined, but not all prerequisites" | |
187 | #endif | |
188 | ||
189 | #if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
190 | #error "MBEDTLS_ECP_RANDOMIZE_MXZ_ALT defined, but not all prerequisites" | |
191 | #endif | |
192 | ||
193 | #if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) | |
194 | #error "MBEDTLS_ECP_NORMALIZE_MXZ_ALT defined, but not all prerequisites" | |
195 | #endif | |
196 | ||
197 | #if defined(MBEDTLS_HAVEGE_C) && !defined(MBEDTLS_TIMING_C) | |
198 | #error "MBEDTLS_HAVEGE_C defined, but not all prerequisites" | |
199 | #endif | |
200 | ||
201 | #if defined(MBEDTLS_HKDF_C) && !defined(MBEDTLS_MD_C) | |
202 | #error "MBEDTLS_HKDF_C defined, but not all prerequisites" | |
203 | #endif | |
204 | ||
205 | #if defined(MBEDTLS_HMAC_DRBG_C) && !defined(MBEDTLS_MD_C) | |
206 | #error "MBEDTLS_HMAC_DRBG_C defined, but not all prerequisites" | |
207 | #endif | |
208 | ||
209 | #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) && \ | |
210 | ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) ) | |
211 | #error "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED defined, but not all prerequisites" | |
212 | #endif | |
213 | ||
214 | #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ | |
215 | ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) ) | |
216 | #error "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED defined, but not all prerequisites" | |
217 | #endif | |
218 | ||
219 | #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) && !defined(MBEDTLS_DHM_C) | |
220 | #error "MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED defined, but not all prerequisites" | |
221 | #endif | |
222 | ||
223 | #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) && \ | |
224 | !defined(MBEDTLS_ECDH_C) | |
225 | #error "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED defined, but not all prerequisites" | |
226 | #endif | |
227 | ||
228 | #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ | |
229 | ( !defined(MBEDTLS_DHM_C) || !defined(MBEDTLS_RSA_C) || \ | |
230 | !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) ) | |
231 | #error "MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED defined, but not all prerequisites" | |
232 | #endif | |
233 | ||
234 | #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ | |
235 | ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_RSA_C) || \ | |
236 | !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) ) | |
237 | #error "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED defined, but not all prerequisites" | |
238 | #endif | |
239 | ||
240 | #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \ | |
241 | ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_ECDSA_C) || \ | |
242 | !defined(MBEDTLS_X509_CRT_PARSE_C) ) | |
243 | #error "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED defined, but not all prerequisites" | |
244 | #endif | |
245 | ||
246 | #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) && \ | |
247 | ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \ | |
248 | !defined(MBEDTLS_PKCS1_V15) ) | |
249 | #error "MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED defined, but not all prerequisites" | |
250 | #endif | |
251 | ||
252 | #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \ | |
253 | ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \ | |
254 | !defined(MBEDTLS_PKCS1_V15) ) | |
255 | #error "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED defined, but not all prerequisites" | |
256 | #endif | |
257 | ||
258 | #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \ | |
259 | ( !defined(MBEDTLS_ECJPAKE_C) || !defined(MBEDTLS_SHA256_C) || \ | |
260 | !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) ) | |
261 | #error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites" | |
262 | #endif | |
263 | ||
264 | #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ | |
265 | ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) | |
266 | #error "MBEDTLS_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites" | |
267 | #endif | |
268 | ||
269 | #if defined(MBEDTLS_PADLOCK_C) && !defined(MBEDTLS_HAVE_ASM) | |
270 | #error "MBEDTLS_PADLOCK_C defined, but not all prerequisites" | |
271 | #endif | |
272 | ||
273 | #if defined(MBEDTLS_PEM_PARSE_C) && !defined(MBEDTLS_BASE64_C) | |
274 | #error "MBEDTLS_PEM_PARSE_C defined, but not all prerequisites" | |
275 | #endif | |
276 | ||
277 | #if defined(MBEDTLS_PEM_WRITE_C) && !defined(MBEDTLS_BASE64_C) | |
278 | #error "MBEDTLS_PEM_WRITE_C defined, but not all prerequisites" | |
279 | #endif | |
280 | ||
281 | #if defined(MBEDTLS_PK_C) && \ | |
282 | ( !defined(MBEDTLS_RSA_C) && !defined(MBEDTLS_ECP_C) ) | |
283 | #error "MBEDTLS_PK_C defined, but not all prerequisites" | |
284 | #endif | |
285 | ||
286 | #if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_PK_C) | |
287 | #error "MBEDTLS_PK_PARSE_C defined, but not all prerequisites" | |
288 | #endif | |
289 | ||
290 | #if defined(MBEDTLS_PK_WRITE_C) && !defined(MBEDTLS_PK_C) | |
291 | #error "MBEDTLS_PK_WRITE_C defined, but not all prerequisites" | |
292 | #endif | |
293 | ||
294 | #if defined(MBEDTLS_PKCS11_C) && !defined(MBEDTLS_PK_C) | |
295 | #error "MBEDTLS_PKCS11_C defined, but not all prerequisites" | |
296 | #endif | |
297 | ||
298 | #if defined(MBEDTLS_PLATFORM_EXIT_ALT) && !defined(MBEDTLS_PLATFORM_C) | |
299 | #error "MBEDTLS_PLATFORM_EXIT_ALT defined, but not all prerequisites" | |
300 | #endif | |
301 | ||
302 | #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) && !defined(MBEDTLS_PLATFORM_C) | |
303 | #error "MBEDTLS_PLATFORM_EXIT_MACRO defined, but not all prerequisites" | |
304 | #endif | |
305 | ||
306 | #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) &&\ | |
307 | ( defined(MBEDTLS_PLATFORM_STD_EXIT) ||\ | |
308 | defined(MBEDTLS_PLATFORM_EXIT_ALT) ) | |
309 | #error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously" | |
310 | #endif | |
311 | ||
312 | #if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\ | |
313 | ( !defined(MBEDTLS_PLATFORM_C) ||\ | |
314 | !defined(MBEDTLS_HAVE_TIME) ) | |
315 | #error "MBEDTLS_PLATFORM_TIME_ALT defined, but not all prerequisites" | |
316 | #endif | |
317 | ||
318 | #if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\ | |
319 | ( !defined(MBEDTLS_PLATFORM_C) ||\ | |
320 | !defined(MBEDTLS_HAVE_TIME) ) | |
321 | #error "MBEDTLS_PLATFORM_TIME_MACRO defined, but not all prerequisites" | |
322 | #endif | |
323 | ||
324 | #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\ | |
325 | ( !defined(MBEDTLS_PLATFORM_C) ||\ | |
326 | !defined(MBEDTLS_HAVE_TIME) ) | |
327 | #error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO defined, but not all prerequisites" | |
328 | #endif | |
329 | ||
330 | #if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\ | |
331 | ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\ | |
332 | defined(MBEDTLS_PLATFORM_TIME_ALT) ) | |
333 | #error "MBEDTLS_PLATFORM_TIME_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously" | |
334 | #endif | |
335 | ||
336 | #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\ | |
337 | ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\ | |
338 | defined(MBEDTLS_PLATFORM_TIME_ALT) ) | |
339 | #error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously" | |
340 | #endif | |
341 | ||
342 | #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) | |
343 | #error "MBEDTLS_PLATFORM_FPRINTF_ALT defined, but not all prerequisites" | |
344 | #endif | |
345 | ||
346 | #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) | |
347 | #error "MBEDTLS_PLATFORM_FPRINTF_MACRO defined, but not all prerequisites" | |
348 | #endif | |
349 | ||
350 | #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) &&\ | |
351 | ( defined(MBEDTLS_PLATFORM_STD_FPRINTF) ||\ | |
352 | defined(MBEDTLS_PLATFORM_FPRINTF_ALT) ) | |
353 | #error "MBEDTLS_PLATFORM_FPRINTF_MACRO and MBEDTLS_PLATFORM_STD_FPRINTF/MBEDTLS_PLATFORM_FPRINTF_ALT cannot be defined simultaneously" | |
354 | #endif | |
355 | ||
356 | #if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\ | |
357 | ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) | |
358 | #error "MBEDTLS_PLATFORM_FREE_MACRO defined, but not all prerequisites" | |
359 | #endif | |
360 | ||
361 | #if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\ | |
362 | defined(MBEDTLS_PLATFORM_STD_FREE) | |
363 | #error "MBEDTLS_PLATFORM_FREE_MACRO and MBEDTLS_PLATFORM_STD_FREE cannot be defined simultaneously" | |
364 | #endif | |
365 | ||
366 | #if defined(MBEDTLS_PLATFORM_FREE_MACRO) && !defined(MBEDTLS_PLATFORM_CALLOC_MACRO) | |
367 | #error "MBEDTLS_PLATFORM_CALLOC_MACRO must be defined if MBEDTLS_PLATFORM_FREE_MACRO is" | |
368 | #endif | |
369 | ||
370 | #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\ | |
371 | ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) | |
372 | #error "MBEDTLS_PLATFORM_CALLOC_MACRO defined, but not all prerequisites" | |
373 | #endif | |
374 | ||
375 | #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\ | |
376 | defined(MBEDTLS_PLATFORM_STD_CALLOC) | |
377 | #error "MBEDTLS_PLATFORM_CALLOC_MACRO and MBEDTLS_PLATFORM_STD_CALLOC cannot be defined simultaneously" | |
378 | #endif | |
379 | ||
380 | #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) && !defined(MBEDTLS_PLATFORM_FREE_MACRO) | |
381 | #error "MBEDTLS_PLATFORM_FREE_MACRO must be defined if MBEDTLS_PLATFORM_CALLOC_MACRO is" | |
382 | #endif | |
383 | ||
384 | #if defined(MBEDTLS_PLATFORM_MEMORY) && !defined(MBEDTLS_PLATFORM_C) | |
385 | #error "MBEDTLS_PLATFORM_MEMORY defined, but not all prerequisites" | |
386 | #endif | |
387 | ||
388 | #if defined(MBEDTLS_PLATFORM_PRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) | |
389 | #error "MBEDTLS_PLATFORM_PRINTF_ALT defined, but not all prerequisites" | |
390 | #endif | |
391 | ||
392 | #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) | |
393 | #error "MBEDTLS_PLATFORM_PRINTF_MACRO defined, but not all prerequisites" | |
394 | #endif | |
395 | ||
396 | #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) &&\ | |
397 | ( defined(MBEDTLS_PLATFORM_STD_PRINTF) ||\ | |
398 | defined(MBEDTLS_PLATFORM_PRINTF_ALT) ) | |
399 | #error "MBEDTLS_PLATFORM_PRINTF_MACRO and MBEDTLS_PLATFORM_STD_PRINTF/MBEDTLS_PLATFORM_PRINTF_ALT cannot be defined simultaneously" | |
400 | #endif | |
401 | ||
402 | #if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) | |
403 | #error "MBEDTLS_PLATFORM_SNPRINTF_ALT defined, but not all prerequisites" | |
404 | #endif | |
405 | ||
406 | #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) | |
407 | #error "MBEDTLS_PLATFORM_SNPRINTF_MACRO defined, but not all prerequisites" | |
408 | #endif | |
409 | ||
410 | #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) &&\ | |
411 | ( defined(MBEDTLS_PLATFORM_STD_SNPRINTF) ||\ | |
412 | defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) ) | |
413 | #error "MBEDTLS_PLATFORM_SNPRINTF_MACRO and MBEDTLS_PLATFORM_STD_SNPRINTF/MBEDTLS_PLATFORM_SNPRINTF_ALT cannot be defined simultaneously" | |
414 | #endif | |
415 | ||
416 | #if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) &&\ | |
417 | !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) | |
418 | #error "MBEDTLS_PLATFORM_STD_MEM_HDR defined, but not all prerequisites" | |
419 | #endif | |
420 | ||
421 | #if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY) | |
422 | #error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites" | |
423 | #endif | |
424 | ||
425 | #if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY) | |
426 | #error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites" | |
427 | #endif | |
428 | ||
429 | #if defined(MBEDTLS_PLATFORM_STD_FREE) && !defined(MBEDTLS_PLATFORM_MEMORY) | |
430 | #error "MBEDTLS_PLATFORM_STD_FREE defined, but not all prerequisites" | |
431 | #endif | |
432 | ||
433 | #if defined(MBEDTLS_PLATFORM_STD_EXIT) &&\ | |
434 | !defined(MBEDTLS_PLATFORM_EXIT_ALT) | |
435 | #error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites" | |
436 | #endif | |
437 | ||
438 | #if defined(MBEDTLS_PLATFORM_STD_TIME) &&\ | |
439 | ( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\ | |
440 | !defined(MBEDTLS_HAVE_TIME) ) | |
441 | #error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites" | |
442 | #endif | |
443 | ||
444 | #if defined(MBEDTLS_PLATFORM_STD_FPRINTF) &&\ | |
445 | !defined(MBEDTLS_PLATFORM_FPRINTF_ALT) | |
446 | #error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites" | |
447 | #endif | |
448 | ||
449 | #if defined(MBEDTLS_PLATFORM_STD_PRINTF) &&\ | |
450 | !defined(MBEDTLS_PLATFORM_PRINTF_ALT) | |
451 | #error "MBEDTLS_PLATFORM_STD_PRINTF defined, but not all prerequisites" | |
452 | #endif | |
453 | ||
454 | #if defined(MBEDTLS_PLATFORM_STD_SNPRINTF) &&\ | |
455 | !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) | |
456 | #error "MBEDTLS_PLATFORM_STD_SNPRINTF defined, but not all prerequisites" | |
457 | #endif | |
458 | ||
459 | #if defined(MBEDTLS_ENTROPY_NV_SEED) &&\ | |
460 | ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_ENTROPY_C) ) | |
461 | #error "MBEDTLS_ENTROPY_NV_SEED defined, but not all prerequisites" | |
462 | #endif | |
463 | ||
464 | #if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) &&\ | |
465 | !defined(MBEDTLS_ENTROPY_NV_SEED) | |
466 | #error "MBEDTLS_PLATFORM_NV_SEED_ALT defined, but not all prerequisites" | |
467 | #endif | |
468 | ||
469 | #if defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) &&\ | |
470 | !defined(MBEDTLS_PLATFORM_NV_SEED_ALT) | |
471 | #error "MBEDTLS_PLATFORM_STD_NV_SEED_READ defined, but not all prerequisites" | |
472 | #endif | |
473 | ||
474 | #if defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) &&\ | |
475 | !defined(MBEDTLS_PLATFORM_NV_SEED_ALT) | |
476 | #error "MBEDTLS_PLATFORM_STD_NV_SEED_WRITE defined, but not all prerequisites" | |
477 | #endif | |
478 | ||
479 | #if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) &&\ | |
480 | ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) ||\ | |
481 | defined(MBEDTLS_PLATFORM_NV_SEED_ALT) ) | |
482 | #error "MBEDTLS_PLATFORM_NV_SEED_READ_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_READ cannot be defined simultaneously" | |
483 | #endif | |
484 | ||
485 | #if defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) &&\ | |
486 | ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) ||\ | |
487 | defined(MBEDTLS_PLATFORM_NV_SEED_ALT) ) | |
488 | #error "MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_WRITE cannot be defined simultaneously" | |
489 | #endif | |
490 | ||
491 | #if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ | |
492 | !defined(MBEDTLS_OID_C) ) | |
493 | #error "MBEDTLS_RSA_C defined, but not all prerequisites" | |
494 | #endif | |
495 | ||
496 | #if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_PKCS1_V21) && \ | |
497 | !defined(MBEDTLS_PKCS1_V15) ) | |
498 | #error "MBEDTLS_RSA_C defined, but none of the PKCS1 versions enabled" | |
499 | #endif | |
500 | ||
501 | #if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) && \ | |
502 | ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_PKCS1_V21) ) | |
503 | #error "MBEDTLS_X509_RSASSA_PSS_SUPPORT defined, but not all prerequisites" | |
504 | #endif | |
505 | ||
506 | #if defined(MBEDTLS_SSL_PROTO_SSL3) && ( !defined(MBEDTLS_MD5_C) || \ | |
507 | !defined(MBEDTLS_SHA1_C) ) | |
508 | #error "MBEDTLS_SSL_PROTO_SSL3 defined, but not all prerequisites" | |
509 | #endif | |
510 | ||
511 | #if defined(MBEDTLS_SSL_PROTO_TLS1) && ( !defined(MBEDTLS_MD5_C) || \ | |
512 | !defined(MBEDTLS_SHA1_C) ) | |
513 | #error "MBEDTLS_SSL_PROTO_TLS1 defined, but not all prerequisites" | |
514 | #endif | |
515 | ||
516 | #if defined(MBEDTLS_SSL_PROTO_TLS1_1) && ( !defined(MBEDTLS_MD5_C) || \ | |
517 | !defined(MBEDTLS_SHA1_C) ) | |
518 | #error "MBEDTLS_SSL_PROTO_TLS1_1 defined, but not all prerequisites" | |
519 | #endif | |
520 | ||
521 | #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && ( !defined(MBEDTLS_SHA1_C) && \ | |
522 | !defined(MBEDTLS_SHA256_C) && !defined(MBEDTLS_SHA512_C) ) | |
523 | #error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites" | |
524 | #endif | |
525 | ||
526 | #if defined(MBEDTLS_SSL_PROTO_DTLS) && \ | |
527 | !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ | |
528 | !defined(MBEDTLS_SSL_PROTO_TLS1_2) | |
529 | #error "MBEDTLS_SSL_PROTO_DTLS defined, but not all prerequisites" | |
530 | #endif | |
531 | ||
532 | #if defined(MBEDTLS_SSL_CLI_C) && !defined(MBEDTLS_SSL_TLS_C) | |
533 | #error "MBEDTLS_SSL_CLI_C defined, but not all prerequisites" | |
534 | #endif | |
535 | ||
536 | #if defined(MBEDTLS_SSL_TLS_C) && ( !defined(MBEDTLS_CIPHER_C) || \ | |
537 | !defined(MBEDTLS_MD_C) ) | |
538 | #error "MBEDTLS_SSL_TLS_C defined, but not all prerequisites" | |
539 | #endif | |
540 | ||
541 | #if defined(MBEDTLS_SSL_SRV_C) && !defined(MBEDTLS_SSL_TLS_C) | |
542 | #error "MBEDTLS_SSL_SRV_C defined, but not all prerequisites" | |
543 | #endif | |
544 | ||
545 | #if defined(MBEDTLS_SSL_TLS_C) && (!defined(MBEDTLS_SSL_PROTO_SSL3) && \ | |
546 | !defined(MBEDTLS_SSL_PROTO_TLS1) && !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ | |
547 | !defined(MBEDTLS_SSL_PROTO_TLS1_2)) | |
548 | #error "MBEDTLS_SSL_TLS_C defined, but no protocols are active" | |
549 | #endif | |
550 | ||
551 | #if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_SSL3) && \ | |
552 | defined(MBEDTLS_SSL_PROTO_TLS1_1) && !defined(MBEDTLS_SSL_PROTO_TLS1)) | |
553 | #error "Illegal protocol selection" | |
554 | #endif | |
555 | ||
556 | #if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_TLS1) && \ | |
557 | defined(MBEDTLS_SSL_PROTO_TLS1_2) && !defined(MBEDTLS_SSL_PROTO_TLS1_1)) | |
558 | #error "Illegal protocol selection" | |
559 | #endif | |
560 | ||
561 | #if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_SSL3) && \ | |
562 | defined(MBEDTLS_SSL_PROTO_TLS1_2) && (!defined(MBEDTLS_SSL_PROTO_TLS1) || \ | |
563 | !defined(MBEDTLS_SSL_PROTO_TLS1_1))) | |
564 | #error "Illegal protocol selection" | |
565 | #endif | |
566 | ||
567 | #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && !defined(MBEDTLS_SSL_PROTO_DTLS) | |
568 | #error "MBEDTLS_SSL_DTLS_HELLO_VERIFY defined, but not all prerequisites" | |
569 | #endif | |
570 | ||
571 | #if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && \ | |
572 | !defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) | |
573 | #error "MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE defined, but not all prerequisites" | |
574 | #endif | |
575 | ||
576 | #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) && \ | |
577 | ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) ) | |
578 | #error "MBEDTLS_SSL_DTLS_ANTI_REPLAY defined, but not all prerequisites" | |
579 | #endif | |
580 | ||
581 | #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) && \ | |
582 | ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) ) | |
583 | #error "MBEDTLS_SSL_DTLS_BADMAC_LIMIT defined, but not all prerequisites" | |
584 | #endif | |
585 | ||
586 | #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) && \ | |
587 | !defined(MBEDTLS_SSL_PROTO_TLS1) && \ | |
588 | !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ | |
589 | !defined(MBEDTLS_SSL_PROTO_TLS1_2) | |
590 | #error "MBEDTLS_SSL_ENCRYPT_THEN_MAC defined, but not all prerequsites" | |
591 | #endif | |
592 | ||
593 | #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) && \ | |
594 | !defined(MBEDTLS_SSL_PROTO_TLS1) && \ | |
595 | !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \ | |
596 | !defined(MBEDTLS_SSL_PROTO_TLS1_2) | |
597 | #error "MBEDTLS_SSL_EXTENDED_MASTER_SECRET defined, but not all prerequsites" | |
598 | #endif | |
599 | ||
600 | #if defined(MBEDTLS_SSL_TICKET_C) && !defined(MBEDTLS_CIPHER_C) | |
601 | #error "MBEDTLS_SSL_TICKET_C defined, but not all prerequisites" | |
602 | #endif | |
603 | ||
604 | #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) && \ | |
605 | !defined(MBEDTLS_SSL_PROTO_SSL3) && !defined(MBEDTLS_SSL_PROTO_TLS1) | |
606 | #error "MBEDTLS_SSL_CBC_RECORD_SPLITTING defined, but not all prerequisites" | |
607 | #endif | |
608 | ||
609 | #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) && \ | |
610 | !defined(MBEDTLS_X509_CRT_PARSE_C) | |
611 | #error "MBEDTLS_SSL_SERVER_NAME_INDICATION defined, but not all prerequisites" | |
612 | #endif | |
613 | ||
614 | #if defined(MBEDTLS_THREADING_PTHREAD) | |
615 | #if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL) | |
616 | #error "MBEDTLS_THREADING_PTHREAD defined, but not all prerequisites" | |
617 | #endif | |
618 | #define MBEDTLS_THREADING_IMPL | |
619 | #endif | |
620 | ||
621 | #if defined(MBEDTLS_THREADING_ALT) | |
622 | #if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL) | |
623 | #error "MBEDTLS_THREADING_ALT defined, but not all prerequisites" | |
624 | #endif | |
625 | #define MBEDTLS_THREADING_IMPL | |
626 | #endif | |
627 | ||
628 | #if defined(MBEDTLS_THREADING_C) && !defined(MBEDTLS_THREADING_IMPL) | |
629 | #error "MBEDTLS_THREADING_C defined, single threading implementation required" | |
630 | #endif | |
631 | #undef MBEDTLS_THREADING_IMPL | |
632 | ||
633 | #if defined(MBEDTLS_VERSION_FEATURES) && !defined(MBEDTLS_VERSION_C) | |
634 | #error "MBEDTLS_VERSION_FEATURES defined, but not all prerequisites" | |
635 | #endif | |
636 | ||
637 | #if defined(MBEDTLS_X509_USE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ | |
638 | !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_PARSE_C) || \ | |
639 | !defined(MBEDTLS_PK_PARSE_C) ) | |
640 | #error "MBEDTLS_X509_USE_C defined, but not all prerequisites" | |
641 | #endif | |
642 | ||
643 | #if defined(MBEDTLS_X509_CREATE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ | |
644 | !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_WRITE_C) || \ | |
645 | !defined(MBEDTLS_PK_WRITE_C) ) | |
646 | #error "MBEDTLS_X509_CREATE_C defined, but not all prerequisites" | |
647 | #endif | |
648 | ||
649 | #if defined(MBEDTLS_X509_CRT_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) | |
650 | #error "MBEDTLS_X509_CRT_PARSE_C defined, but not all prerequisites" | |
651 | #endif | |
652 | ||
653 | #if defined(MBEDTLS_X509_CRL_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) | |
654 | #error "MBEDTLS_X509_CRL_PARSE_C defined, but not all prerequisites" | |
655 | #endif | |
656 | ||
657 | #if defined(MBEDTLS_X509_CSR_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) | |
658 | #error "MBEDTLS_X509_CSR_PARSE_C defined, but not all prerequisites" | |
659 | #endif | |
660 | ||
661 | #if defined(MBEDTLS_X509_CRT_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) ) | |
662 | #error "MBEDTLS_X509_CRT_WRITE_C defined, but not all prerequisites" | |
663 | #endif | |
664 | ||
665 | #if defined(MBEDTLS_X509_CSR_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) ) | |
666 | #error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites" | |
667 | #endif | |
668 | ||
669 | #if defined(MBEDTLS_HAVE_INT32) && defined(MBEDTLS_HAVE_INT64) | |
670 | #error "MBEDTLS_HAVE_INT32 and MBEDTLS_HAVE_INT64 cannot be defined simultaneously" | |
671 | #endif /* MBEDTLS_HAVE_INT32 && MBEDTLS_HAVE_INT64 */ | |
672 | ||
673 | #if ( defined(MBEDTLS_HAVE_INT32) || defined(MBEDTLS_HAVE_INT64) ) && \ | |
674 | defined(MBEDTLS_HAVE_ASM) | |
675 | #error "MBEDTLS_HAVE_INT32/MBEDTLS_HAVE_INT64 and MBEDTLS_HAVE_ASM cannot be defined simultaneously" | |
676 | #endif /* (MBEDTLS_HAVE_INT32 || MBEDTLS_HAVE_INT64) && MBEDTLS_HAVE_ASM */ | |
677 | ||
678 | /* | |
679 | * Avoid warning from -pedantic. This is a convenient place for this | |
680 | * workaround since this is included by every single file before the | |
681 | * #if defined(MBEDTLS_xxx_C) that results in emtpy translation units. | |
682 | */ | |
683 | typedef int mbedtls_iso_c_forbids_empty_translation_units; | |
684 | ||
685 | #endif /* MBEDTLS_CHECK_CONFIG_H */ |