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