blob: ca36395c0dda7c139fc7362c203512d4332dd7c3 [file] [log] [blame]
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +02001/**
2 * \file check_config.h
3 *
4 * \brief Consistency checks for configuration options
Darryl Greena40a1012018-01-05 15:33:17 +00005 */
6/*
Thomas Fossati656864b2016-07-17 08:51:22 +01007 * Copyright (C) 2006-2018, ARM Limited, All Rights Reserved
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02008 * SPDX-License-Identifier: Apache-2.0
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
11 * not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020021 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000022 * This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020023 */
24
25/*
26 * It is recommended to include this file from your config.h
27 * in order to catch dependency issues early.
28 */
29
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020030#ifndef MBEDTLS_CHECK_CONFIG_H
31#define MBEDTLS_CHECK_CONFIG_H
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020032
Manuel Pégourié-Gonnardd14acbc2015-05-29 11:26:37 +020033/*
34 * We assume CHAR_BIT is 8 in many places. In practice, this is true on our
35 * target platforms, so not an issue, but let's just be extra sure.
36 */
37#include <limits.h>
38#if CHAR_BIT != 8
39#error "mbed TLS requires a platform with 8-bit chars"
40#endif
41
Manuel Pégourié-Gonnard9db28872015-06-26 10:52:01 +020042#if defined(_WIN32)
43#if !defined(MBEDTLS_PLATFORM_C)
Manuel Pégourié-Gonnard6c0c8e02015-06-22 10:23:34 +020044#error "MBEDTLS_PLATFORM_C is required on Windows"
45#endif
46
Manuel Pégourié-Gonnard9db28872015-06-26 10:52:01 +020047/* Fix the config here. Not convenient to put an #ifdef _WIN32 in config.h as
Gilles Peskine3bdd4122019-07-27 23:52:53 +020048 * it would confuse config.py. */
Manuel Pégourié-Gonnard9db28872015-06-26 10:52:01 +020049#if !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && \
50 !defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO)
51#define MBEDTLS_PLATFORM_SNPRINTF_ALT
52#endif
k-stachowiak6b5ef482019-01-07 16:53:29 +010053
54#if !defined(MBEDTLS_PLATFORM_VSNPRINTF_ALT) && \
55 !defined(MBEDTLS_PLATFORM_VSNPRINTF_MACRO)
56#define MBEDTLS_PLATFORM_VSNPRINTF_ALT
57#endif
Manuel Pégourié-Gonnard9db28872015-06-26 10:52:01 +020058#endif /* _WIN32 */
59
Gilles Peskine4e117492020-02-26 18:56:08 +010060#if defined(TARGET_LIKE_MBED) && \
61 ( defined(MBEDTLS_NET_C) || defined(MBEDTLS_TIMING_C) )
62#error "The NET and TIMING modules are not available for mbed OS - please use the network and timing functions provided by mbed OS"
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020063#endif
64
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020065#if defined(MBEDTLS_DEPRECATED_WARNING) && \
Manuel Pégourié-Gonnard757ca002015-03-23 15:24:07 +010066 !defined(__GNUC__) && !defined(__clang__)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020067#error "MBEDTLS_DEPRECATED_WARNING only works with GCC and Clang"
Manuel Pégourié-Gonnardc70581c2015-03-23 13:58:27 +010068#endif
69
Manuel Pégourié-Gonnard60c793b2015-06-18 20:52:58 +020070#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_HAVE_TIME)
71#error "MBEDTLS_HAVE_TIME_DATE without MBEDTLS_HAVE_TIME does not make sense"
72#endif
73
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020074#if defined(MBEDTLS_AESNI_C) && !defined(MBEDTLS_HAVE_ASM)
75#error "MBEDTLS_AESNI_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020076#endif
77
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020078#if defined(MBEDTLS_CTR_DRBG_C) && !defined(MBEDTLS_AES_C)
79#error "MBEDTLS_CTR_DRBG_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020080#endif
81
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020082#if defined(MBEDTLS_DHM_C) && !defined(MBEDTLS_BIGNUM_C)
83#error "MBEDTLS_DHM_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020084#endif
85
Gilles Peskine4e117492020-02-26 18:56:08 +010086#if defined(MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT) && !defined(MBEDTLS_SSL_TRUNCATED_HMAC)
87#error "MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT defined, but not all prerequisites"
88#endif
89
Brian Murray53e23b62016-09-13 14:00:15 -070090#if defined(MBEDTLS_CMAC_C) && \
Simon Butcher69283e52016-10-06 12:49:58 +010091 !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_DES_C)
Brian Murray53e23b62016-09-13 14:00:15 -070092#error "MBEDTLS_CMAC_C defined, but not all prerequisites"
93#endif
94
Ron Eldor466a57f2018-05-03 16:54:28 +030095#if defined(MBEDTLS_NIST_KW_C) && \
96 ( !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_CIPHER_C) )
97#error "MBEDTLS_NIST_KW_C defined, but not all prerequisites"
98#endif
99
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200100#if defined(MBEDTLS_ECDH_C) && !defined(MBEDTLS_ECP_C)
101#error "MBEDTLS_ECDH_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200102#endif
103
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200104#if defined(MBEDTLS_ECDSA_C) && \
105 ( !defined(MBEDTLS_ECP_C) || \
106 !defined(MBEDTLS_ASN1_PARSE_C) || \
107 !defined(MBEDTLS_ASN1_WRITE_C) )
108#error "MBEDTLS_ECDSA_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200109#endif
110
Manuel Pégourié-Gonnard4d8685b2015-08-05 15:44:42 +0200111#if defined(MBEDTLS_ECJPAKE_C) && \
112 ( !defined(MBEDTLS_ECP_C) || !defined(MBEDTLS_MD_C) )
113#error "MBEDTLS_ECJPAKE_C defined, but not all prerequisites"
114#endif
115
Ron Eldor5ed8c1e2018-11-05 14:04:26 +0200116#if defined(MBEDTLS_ECP_RESTARTABLE) && \
Hanno Becker85fd9132019-02-22 12:50:35 +0000117 ( defined(MBEDTLS_USE_PSA_CRYPTO) || \
Hanno Becker1ce51e42019-02-22 10:25:47 +0000118 defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT) || \
Ron Eldor5ed8c1e2018-11-05 14:04:26 +0200119 defined(MBEDTLS_ECDH_GEN_PUBLIC_ALT) || \
120 defined(MBEDTLS_ECDSA_SIGN_ALT) || \
121 defined(MBEDTLS_ECDSA_VERIFY_ALT) || \
122 defined(MBEDTLS_ECDSA_GENKEY_ALT) || \
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500123 defined(MBEDTLS_ECP_INTERNAL_ALT) || \
Ron Eldor5ed8c1e2018-11-05 14:04:26 +0200124 defined(MBEDTLS_ECP_ALT) )
Hanno Becker1ce51e42019-02-22 10:25:47 +0000125#error "MBEDTLS_ECP_RESTARTABLE defined, but it cannot coexist with an alternative or PSA-based ECP implementation"
Ron Eldor5ed8c1e2018-11-05 14:04:26 +0200126#endif
127
Gilles Peskine43f564f2019-02-22 12:14:02 +0100128#if defined(MBEDTLS_ECP_RESTARTABLE) && \
129 ! defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
130#error "MBEDTLS_ECP_RESTARTABLE defined, but not MBEDTLS_ECDH_LEGACY_CONTEXT"
131#endif
132
Christoph M. Wintersteiger19d5c802019-04-15 11:09:33 +0100133#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED) && \
134 defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
135#error "MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED defined, but MBEDTLS_ECDH_LEGACY_CONTEXT not disabled"
136#endif
137
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200138#if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C)
139#error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200140#endif
141
k-stachowiakff25af22019-05-31 20:13:58 +0200142#if defined(MBEDTLS_ECP_C) && ( !defined(MBEDTLS_BIGNUM_C) || ( \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200143 !defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) && \
144 !defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) && \
145 !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && \
146 !defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) && \
147 !defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) && \
148 !defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) && \
149 !defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) && \
150 !defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) && \
151 !defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) && \
152 !defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) && \
k-stachowiakff25af22019-05-31 20:13:58 +0200153 !defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) && \
154 !defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) && \
155 !defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) ) )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200156#error "MBEDTLS_ECP_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200157#endif
158
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500159#if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_ASN1_PARSE_C)
160#error "MBEDTLS_PK_PARSE_C defined, but not all prerequesites"
161#endif
162
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200163#if defined(MBEDTLS_ENTROPY_C) && (!defined(MBEDTLS_SHA512_C) && \
164 !defined(MBEDTLS_SHA256_C))
165#error "MBEDTLS_ENTROPY_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200166#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200167#if defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_SHA512_C) && \
168 defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 64)
169#error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200170#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200171#if defined(MBEDTLS_ENTROPY_C) && \
172 ( !defined(MBEDTLS_SHA512_C) || defined(MBEDTLS_ENTROPY_FORCE_SHA256) ) \
173 && defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 32)
174#error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200175#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200176#if defined(MBEDTLS_ENTROPY_C) && \
177 defined(MBEDTLS_ENTROPY_FORCE_SHA256) && !defined(MBEDTLS_SHA256_C)
178#error "MBEDTLS_ENTROPY_FORCE_SHA256 defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200179#endif
180
Simon Butcherab5df402016-06-11 02:31:21 +0100181#if defined(MBEDTLS_TEST_NULL_ENTROPY) && \
182 ( !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) )
183#error "MBEDTLS_TEST_NULL_ENTROPY defined, but not all prerequisites"
Janos Follath53de7842016-06-08 15:29:18 +0100184#endif
Simon Butcherab5df402016-06-11 02:31:21 +0100185#if defined(MBEDTLS_TEST_NULL_ENTROPY) && \
186 ( defined(MBEDTLS_ENTROPY_NV_SEED) || defined(MBEDTLS_ENTROPY_HARDWARE_ALT) || \
187 defined(MBEDTLS_HAVEGE_C) )
188#error "MBEDTLS_TEST_NULL_ENTROPY defined, but entropy sources too"
Janos Follath53de7842016-06-08 15:29:18 +0100189#endif
190
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200191#if defined(MBEDTLS_GCM_C) && ( \
Jaeden Amero651ae682019-04-10 18:19:16 +0100192 !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_CAMELLIA_C) && !defined(MBEDTLS_ARIA_C) )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200193#error "MBEDTLS_GCM_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200194#endif
195
Janos Follathc44ab972016-11-18 16:38:23 +0000196#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
Janos Follathb0697532016-08-18 12:38:46 +0100197#error "MBEDTLS_ECP_RANDOMIZE_JAC_ALT defined, but not all prerequisites"
198#endif
199
Janos Follathc44ab972016-11-18 16:38:23 +0000200#if defined(MBEDTLS_ECP_ADD_MIXED_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
Janos Follathb0697532016-08-18 12:38:46 +0100201#error "MBEDTLS_ECP_ADD_MIXED_ALT defined, but not all prerequisites"
202#endif
203
Janos Follathc44ab972016-11-18 16:38:23 +0000204#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
Janos Follathb0697532016-08-18 12:38:46 +0100205#error "MBEDTLS_ECP_DOUBLE_JAC_ALT defined, but not all prerequisites"
206#endif
207
Janos Follathc44ab972016-11-18 16:38:23 +0000208#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
Janos Follathb0697532016-08-18 12:38:46 +0100209#error "MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT defined, but not all prerequisites"
210#endif
211
Janos Follathc44ab972016-11-18 16:38:23 +0000212#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
Janos Follathb0697532016-08-18 12:38:46 +0100213#error "MBEDTLS_ECP_NORMALIZE_JAC_ALT defined, but not all prerequisites"
214#endif
215
Janos Follathc44ab972016-11-18 16:38:23 +0000216#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
Janos Follathb0697532016-08-18 12:38:46 +0100217#error "MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT defined, but not all prerequisites"
218#endif
219
Janos Follathc44ab972016-11-18 16:38:23 +0000220#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
Janos Follathb0697532016-08-18 12:38:46 +0100221#error "MBEDTLS_ECP_RANDOMIZE_MXZ_ALT defined, but not all prerequisites"
222#endif
223
Janos Follathc44ab972016-11-18 16:38:23 +0000224#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
Janos Follathb0697532016-08-18 12:38:46 +0100225#error "MBEDTLS_ECP_NORMALIZE_MXZ_ALT defined, but not all prerequisites"
226#endif
227
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200228#if defined(MBEDTLS_HAVEGE_C) && !defined(MBEDTLS_TIMING_C)
229#error "MBEDTLS_HAVEGE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200230#endif
231
Thomas Fossati656864b2016-07-17 08:51:22 +0100232#if defined(MBEDTLS_HKDF_C) && !defined(MBEDTLS_MD_C)
233#error "MBEDTLS_HKDF_C defined, but not all prerequisites"
234#endif
235
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200236#if defined(MBEDTLS_HMAC_DRBG_C) && !defined(MBEDTLS_MD_C)
237#error "MBEDTLS_HMAC_DRBG_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200238#endif
239
Gilles Peskine4e117492020-02-26 18:56:08 +0100240#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) && \
241 ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) )
242#error "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED defined, but not all prerequisites"
243#endif
244
245#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \
246 ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) )
247#error "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED defined, but not all prerequisites"
248#endif
249
250#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) && !defined(MBEDTLS_DHM_C)
251#error "MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED defined, but not all prerequisites"
252#endif
253
254#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) && \
255 !defined(MBEDTLS_ECDH_C)
256#error "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED defined, but not all prerequisites"
257#endif
258
259#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \
260 ( !defined(MBEDTLS_DHM_C) || !defined(MBEDTLS_RSA_C) || \
261 !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) )
262#error "MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED defined, but not all prerequisites"
263#endif
264
265#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
266 ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_RSA_C) || \
267 !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) )
268#error "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED defined, but not all prerequisites"
269#endif
270
271#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \
272 ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_ECDSA_C) || \
273 !defined(MBEDTLS_X509_CRT_PARSE_C) )
274#error "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED defined, but not all prerequisites"
275#endif
276
277#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) && \
278 ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \
279 !defined(MBEDTLS_PKCS1_V15) )
280#error "MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED defined, but not all prerequisites"
281#endif
282
283#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \
284 ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \
285 !defined(MBEDTLS_PKCS1_V15) )
286#error "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED defined, but not all prerequisites"
287#endif
288
289#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \
290 ( !defined(MBEDTLS_ECJPAKE_C) || !defined(MBEDTLS_SHA256_C) || \
291 !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) )
292#error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites"
293#endif
294
295#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) && \
296 !defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) && \
297 ( !defined(MBEDTLS_SHA256_C) && \
298 !defined(MBEDTLS_SHA512_C) && \
299 !defined(MBEDTLS_SHA1_C) )
300#error "!MBEDTLS_SSL_KEEP_PEER_CERTIFICATE requires MBEDTLS_SHA512_C, MBEDTLS_SHA256_C or MBEDTLS_SHA1_C"
301#endif
302
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200303#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \
304 ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) )
305#error "MBEDTLS_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200306#endif
307
Hanno Beckeraf46c5f2019-02-26 13:50:21 +0000308#if defined(MBEDTLS_MEMORY_BACKTRACE) && !defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
309#error "MBEDTLS_MEMORY_BACKTRACE defined, but not all prerequesites"
310#endif
311
Hanno Beckerbfaa7182019-06-03 16:31:32 +0100312#if defined(MBEDTLS_MEMORY_DEBUG) && !defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
313#error "MBEDTLS_MEMORY_DEBUG defined, but not all prerequesites"
314#endif
315
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200316#if defined(MBEDTLS_PADLOCK_C) && !defined(MBEDTLS_HAVE_ASM)
317#error "MBEDTLS_PADLOCK_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200318#endif
319
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200320#if defined(MBEDTLS_PEM_PARSE_C) && !defined(MBEDTLS_BASE64_C)
321#error "MBEDTLS_PEM_PARSE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200322#endif
323
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200324#if defined(MBEDTLS_PEM_WRITE_C) && !defined(MBEDTLS_BASE64_C)
325#error "MBEDTLS_PEM_WRITE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200326#endif
327
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200328#if defined(MBEDTLS_PK_C) && \
329 ( !defined(MBEDTLS_RSA_C) && !defined(MBEDTLS_ECP_C) )
330#error "MBEDTLS_PK_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard94de3312015-01-28 16:32:36 +0000331#endif
332
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200333#if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_PK_C)
334#error "MBEDTLS_PK_PARSE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200335#endif
336
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200337#if defined(MBEDTLS_PK_WRITE_C) && !defined(MBEDTLS_PK_C)
338#error "MBEDTLS_PK_WRITE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200339#endif
340
Gilles Peskine252e3912020-02-26 18:33:58 +0100341#if defined(MBEDTLS_PKCS11_C) && !defined(MBEDTLS_PK_C)
342#error "MBEDTLS_PKCS11_C defined, but not all prerequisites"
343#endif
344
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200345#if defined(MBEDTLS_PLATFORM_EXIT_ALT) && !defined(MBEDTLS_PLATFORM_C)
346#error "MBEDTLS_PLATFORM_EXIT_ALT defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000347#endif
348
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200349#if defined(MBEDTLS_PLATFORM_EXIT_MACRO) && !defined(MBEDTLS_PLATFORM_C)
350#error "MBEDTLS_PLATFORM_EXIT_MACRO defined, but not all prerequisites"
Rich Evans4cc8a222015-02-03 11:26:31 +0000351#endif
352
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200353#if defined(MBEDTLS_PLATFORM_EXIT_MACRO) &&\
354 ( defined(MBEDTLS_PLATFORM_STD_EXIT) ||\
355 defined(MBEDTLS_PLATFORM_EXIT_ALT) )
356#error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously"
Rich Evans4cc8a222015-02-03 11:26:31 +0000357#endif
358
Andres Amaya Garcia1e4ec662016-07-20 10:16:25 +0100359#if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\
360 ( !defined(MBEDTLS_PLATFORM_C) ||\
361 !defined(MBEDTLS_HAVE_TIME) )
362#error "MBEDTLS_PLATFORM_TIME_ALT defined, but not all prerequisites"
363#endif
364
365#if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\
366 ( !defined(MBEDTLS_PLATFORM_C) ||\
367 !defined(MBEDTLS_HAVE_TIME) )
368#error "MBEDTLS_PLATFORM_TIME_MACRO defined, but not all prerequisites"
369#endif
370
371#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\
372 ( !defined(MBEDTLS_PLATFORM_C) ||\
373 !defined(MBEDTLS_HAVE_TIME) )
374#error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO defined, but not all prerequisites"
375#endif
376
377#if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\
378 ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\
379 defined(MBEDTLS_PLATFORM_TIME_ALT) )
380#error "MBEDTLS_PLATFORM_TIME_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously"
381#endif
382
383#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\
384 ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\
385 defined(MBEDTLS_PLATFORM_TIME_ALT) )
386#error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously"
387#endif
388
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200389#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C)
390#error "MBEDTLS_PLATFORM_FPRINTF_ALT defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000391#endif
392
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200393#if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C)
394#error "MBEDTLS_PLATFORM_FPRINTF_MACRO defined, but not all prerequisites"
Rich Evans4cc8a222015-02-03 11:26:31 +0000395#endif
396
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200397#if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) &&\
398 ( defined(MBEDTLS_PLATFORM_STD_FPRINTF) ||\
399 defined(MBEDTLS_PLATFORM_FPRINTF_ALT) )
400#error "MBEDTLS_PLATFORM_FPRINTF_MACRO and MBEDTLS_PLATFORM_STD_FPRINTF/MBEDTLS_PLATFORM_FPRINTF_ALT cannot be defined simultaneously"
Rich Evans4cc8a222015-02-03 11:26:31 +0000401#endif
402
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200403#if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\
404 ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) )
405#error "MBEDTLS_PLATFORM_FREE_MACRO defined, but not all prerequisites"
Rich Evans4cc8a222015-02-03 11:26:31 +0000406#endif
407
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200408#if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\
409 defined(MBEDTLS_PLATFORM_STD_FREE)
410#error "MBEDTLS_PLATFORM_FREE_MACRO and MBEDTLS_PLATFORM_STD_FREE cannot be defined simultaneously"
Rich Evans4cc8a222015-02-03 11:26:31 +0000411#endif
412
Manuel Pégourié-Gonnarda7f80332015-05-27 20:26:40 +0200413#if defined(MBEDTLS_PLATFORM_FREE_MACRO) && !defined(MBEDTLS_PLATFORM_CALLOC_MACRO)
414#error "MBEDTLS_PLATFORM_CALLOC_MACRO must be defined if MBEDTLS_PLATFORM_FREE_MACRO is"
Rich Evans16f8cd82015-02-06 16:14:34 +0000415#endif
416
Manuel Pégourié-Gonnarda7f80332015-05-27 20:26:40 +0200417#if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200418 ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) )
Manuel Pégourié-Gonnarda7f80332015-05-27 20:26:40 +0200419#error "MBEDTLS_PLATFORM_CALLOC_MACRO defined, but not all prerequisites"
Rich Evans4cc8a222015-02-03 11:26:31 +0000420#endif
421
Manuel Pégourié-Gonnarda7f80332015-05-27 20:26:40 +0200422#if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\
423 defined(MBEDTLS_PLATFORM_STD_CALLOC)
424#error "MBEDTLS_PLATFORM_CALLOC_MACRO and MBEDTLS_PLATFORM_STD_CALLOC cannot be defined simultaneously"
Rich Evans4cc8a222015-02-03 11:26:31 +0000425#endif
426
Manuel Pégourié-Gonnarda7f80332015-05-27 20:26:40 +0200427#if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) && !defined(MBEDTLS_PLATFORM_FREE_MACRO)
428#error "MBEDTLS_PLATFORM_FREE_MACRO must be defined if MBEDTLS_PLATFORM_CALLOC_MACRO is"
Rich Evans16f8cd82015-02-06 16:14:34 +0000429#endif
430
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200431#if defined(MBEDTLS_PLATFORM_MEMORY) && !defined(MBEDTLS_PLATFORM_C)
432#error "MBEDTLS_PLATFORM_MEMORY defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000433#endif
434
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200435#if defined(MBEDTLS_PLATFORM_PRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C)
436#error "MBEDTLS_PLATFORM_PRINTF_ALT defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000437#endif
438
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200439#if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C)
440#error "MBEDTLS_PLATFORM_PRINTF_MACRO defined, but not all prerequisites"
Rich Evans4cc8a222015-02-03 11:26:31 +0000441#endif
442
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200443#if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) &&\
444 ( defined(MBEDTLS_PLATFORM_STD_PRINTF) ||\
445 defined(MBEDTLS_PLATFORM_PRINTF_ALT) )
446#error "MBEDTLS_PLATFORM_PRINTF_MACRO and MBEDTLS_PLATFORM_STD_PRINTF/MBEDTLS_PLATFORM_PRINTF_ALT cannot be defined simultaneously"
Rich Evans4cc8a222015-02-03 11:26:31 +0000447#endif
448
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200449#if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C)
450#error "MBEDTLS_PLATFORM_SNPRINTF_ALT defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000451#endif
452
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200453#if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C)
454#error "MBEDTLS_PLATFORM_SNPRINTF_MACRO defined, but not all prerequisites"
Rich Evans4cc8a222015-02-03 11:26:31 +0000455#endif
456
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200457#if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) &&\
458 ( defined(MBEDTLS_PLATFORM_STD_SNPRINTF) ||\
459 defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) )
460#error "MBEDTLS_PLATFORM_SNPRINTF_MACRO and MBEDTLS_PLATFORM_STD_SNPRINTF/MBEDTLS_PLATFORM_SNPRINTF_ALT cannot be defined simultaneously"
Rich Evans4cc8a222015-02-03 11:26:31 +0000461#endif
462
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200463#if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) &&\
464 !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS)
465#error "MBEDTLS_PLATFORM_STD_MEM_HDR defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000466#endif
467
Manuel Pégourié-Gonnarda7f80332015-05-27 20:26:40 +0200468#if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY)
469#error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000470#endif
471
Manuel Pégourié-Gonnarda7f80332015-05-27 20:26:40 +0200472#if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY)
473#error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000474#endif
475
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200476#if defined(MBEDTLS_PLATFORM_STD_FREE) && !defined(MBEDTLS_PLATFORM_MEMORY)
477#error "MBEDTLS_PLATFORM_STD_FREE defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000478#endif
479
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200480#if defined(MBEDTLS_PLATFORM_STD_EXIT) &&\
481 !defined(MBEDTLS_PLATFORM_EXIT_ALT)
482#error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000483#endif
484
Andres Amaya Garcia1e4ec662016-07-20 10:16:25 +0100485#if defined(MBEDTLS_PLATFORM_STD_TIME) &&\
486 ( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\
487 !defined(MBEDTLS_HAVE_TIME) )
488#error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites"
489#endif
490
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200491#if defined(MBEDTLS_PLATFORM_STD_FPRINTF) &&\
492 !defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
493#error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000494#endif
495
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200496#if defined(MBEDTLS_PLATFORM_STD_PRINTF) &&\
497 !defined(MBEDTLS_PLATFORM_PRINTF_ALT)
498#error "MBEDTLS_PLATFORM_STD_PRINTF defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000499#endif
500
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200501#if defined(MBEDTLS_PLATFORM_STD_SNPRINTF) &&\
502 !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT)
503#error "MBEDTLS_PLATFORM_STD_SNPRINTF defined, but not all prerequisites"
Rich Evansc0b6da32015-02-03 10:58:06 +0000504#endif
505
Paul Bakkercf0a9f92016-06-01 11:25:44 +0100506#if defined(MBEDTLS_ENTROPY_NV_SEED) &&\
507 ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_ENTROPY_C) )
508#error "MBEDTLS_ENTROPY_NV_SEED defined, but not all prerequisites"
509#endif
510
511#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) &&\
512 !defined(MBEDTLS_ENTROPY_NV_SEED)
513#error "MBEDTLS_PLATFORM_NV_SEED_ALT defined, but not all prerequisites"
514#endif
515
516#if defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) &&\
517 !defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
518#error "MBEDTLS_PLATFORM_STD_NV_SEED_READ defined, but not all prerequisites"
519#endif
520
521#if defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) &&\
522 !defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
523#error "MBEDTLS_PLATFORM_STD_NV_SEED_WRITE defined, but not all prerequisites"
524#endif
525
526#if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) &&\
527 ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) ||\
528 defined(MBEDTLS_PLATFORM_NV_SEED_ALT) )
529#error "MBEDTLS_PLATFORM_NV_SEED_READ_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_READ cannot be defined simultaneously"
530#endif
531
532#if defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) &&\
533 ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) ||\
534 defined(MBEDTLS_PLATFORM_NV_SEED_ALT) )
535#error "MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_WRITE cannot be defined simultaneously"
536#endif
537
Jaeden Amero484ee332018-10-25 17:38:05 +0100538#if defined(MBEDTLS_PSA_CRYPTO_C) && \
539 !( defined(MBEDTLS_CTR_DRBG_C) && \
540 defined(MBEDTLS_ENTROPY_C) )
541#error "MBEDTLS_PSA_CRYPTO_C defined, but not all prerequisites"
542#endif
543
Andrzej Kurekc6905232019-02-05 05:23:41 -0500544#if defined(MBEDTLS_PSA_CRYPTO_SPM) && !defined(MBEDTLS_PSA_CRYPTO_C)
545#error "MBEDTLS_PSA_CRYPTO_SPM defined, but not all prerequisites"
546#endif
547
Gilles Peskinea8ade162019-06-26 11:24:49 +0200548#if defined(MBEDTLS_PSA_CRYPTO_SE_C) && \
549 ! ( defined(MBEDTLS_PSA_CRYPTO_C) && \
550 defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) )
551#error "MBEDTLS_PSA_CRYPTO_SE_C defined, but not all prerequisites"
552#endif
553
Andrzej Kurekc6905232019-02-05 05:23:41 -0500554#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) && \
Jaeden Amero57f4d9e2019-03-15 16:14:19 +0000555 ! defined(MBEDTLS_PSA_CRYPTO_C)
Andrzej Kurekc6905232019-02-05 05:23:41 -0500556#error "MBEDTLS_PSA_CRYPTO_STORAGE_C defined, but not all prerequisites"
557#endif
558
Jaeden Amero57f4d9e2019-03-15 16:14:19 +0000559#if defined(MBEDTLS_PSA_INJECT_ENTROPY) && \
560 !( defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) && \
561 defined(MBEDTLS_ENTROPY_NV_SEED) )
562#error "MBEDTLS_PSA_INJECT_ENTROPY defined, but not all prerequisites"
Andrzej Kurekc6905232019-02-05 05:23:41 -0500563#endif
564
Jaeden Amero57f4d9e2019-03-15 16:14:19 +0000565#if defined(MBEDTLS_PSA_INJECT_ENTROPY) && \
566 !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES)
567#error "MBEDTLS_PSA_INJECT_ENTROPY is not compatible with actual entropy sources"
568#endif
569
570#if defined(MBEDTLS_PSA_ITS_FILE_C) && \
571 !defined(MBEDTLS_FS_IO)
572#error "MBEDTLS_PSA_ITS_FILE_C defined, but not all prerequisites"
Andrzej Kurekc6905232019-02-05 05:23:41 -0500573#endif
574
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200575#if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_BIGNUM_C) || \
576 !defined(MBEDTLS_OID_C) )
577#error "MBEDTLS_RSA_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200578#endif
579
Paul Bakker4fde40f2016-05-09 15:13:04 +0100580#if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_PKCS1_V21) && \
Paul Bakker37068a72016-05-09 14:36:33 +0100581 !defined(MBEDTLS_PKCS1_V15) )
582#error "MBEDTLS_RSA_C defined, but none of the PKCS1 versions enabled"
583#endif
584
Gilles Peskine252e3912020-02-26 18:33:58 +0100585#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) && \
586 ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_PKCS1_V21) )
587#error "MBEDTLS_X509_RSASSA_PSS_SUPPORT defined, but not all prerequisites"
588#endif
589
Manuel Pégourié-Gonnard1e6fb012020-01-07 11:00:34 +0100590#if defined(MBEDTLS_SHA512_NO_SHA384) && !defined(MBEDTLS_SHA512_C)
591#error "MBEDTLS_SHA512_NO_SHA384 defined without MBEDTLS_SHA512_C"
592#endif
593
Gilles Peskine4e117492020-02-26 18:56:08 +0100594#if defined(MBEDTLS_SSL_PROTO_SSL3) && ( !defined(MBEDTLS_MD5_C) || \
595 !defined(MBEDTLS_SHA1_C) )
596#error "MBEDTLS_SSL_PROTO_SSL3 defined, but not all prerequisites"
597#endif
598
599#if defined(MBEDTLS_SSL_PROTO_TLS1) && ( !defined(MBEDTLS_MD5_C) || \
600 !defined(MBEDTLS_SHA1_C) )
601#error "MBEDTLS_SSL_PROTO_TLS1 defined, but not all prerequisites"
602#endif
603
604#if defined(MBEDTLS_SSL_PROTO_TLS1_1) && ( !defined(MBEDTLS_MD5_C) || \
605 !defined(MBEDTLS_SHA1_C) )
606#error "MBEDTLS_SSL_PROTO_TLS1_1 defined, but not all prerequisites"
607#endif
608
609#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && ( !defined(MBEDTLS_SHA1_C) && \
610 !defined(MBEDTLS_SHA256_C) && !defined(MBEDTLS_SHA512_C) )
611#error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites"
612#endif
613
614#if defined(MBEDTLS_SSL_PROTO_DTLS) && \
615 !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \
616 !defined(MBEDTLS_SSL_PROTO_TLS1_2)
617#error "MBEDTLS_SSL_PROTO_DTLS defined, but not all prerequisites"
618#endif
619
620#if defined(MBEDTLS_SSL_CLI_C) && !defined(MBEDTLS_SSL_TLS_C)
621#error "MBEDTLS_SSL_CLI_C defined, but not all prerequisites"
622#endif
623
624#if defined(MBEDTLS_SSL_TLS_C) && ( !defined(MBEDTLS_CIPHER_C) || \
625 !defined(MBEDTLS_MD_C) )
626#error "MBEDTLS_SSL_TLS_C defined, but not all prerequisites"
627#endif
628
629#if defined(MBEDTLS_SSL_SRV_C) && !defined(MBEDTLS_SSL_TLS_C)
630#error "MBEDTLS_SSL_SRV_C defined, but not all prerequisites"
631#endif
632
633#if defined(MBEDTLS_SSL_TLS_C) && (!defined(MBEDTLS_SSL_PROTO_SSL3) && \
634 !defined(MBEDTLS_SSL_PROTO_TLS1) && !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \
635 !defined(MBEDTLS_SSL_PROTO_TLS1_2))
636#error "MBEDTLS_SSL_TLS_C defined, but no protocols are active"
637#endif
638
639#if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_SSL3) && \
640 defined(MBEDTLS_SSL_PROTO_TLS1_1) && !defined(MBEDTLS_SSL_PROTO_TLS1))
641#error "Illegal protocol selection"
642#endif
643
644#if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_TLS1) && \
645 defined(MBEDTLS_SSL_PROTO_TLS1_2) && !defined(MBEDTLS_SSL_PROTO_TLS1_1))
646#error "Illegal protocol selection"
647#endif
648
649#if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_SSL3) && \
650 defined(MBEDTLS_SSL_PROTO_TLS1_2) && (!defined(MBEDTLS_SSL_PROTO_TLS1) || \
651 !defined(MBEDTLS_SSL_PROTO_TLS1_1)))
652#error "Illegal protocol selection"
653#endif
654
655#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && !defined(MBEDTLS_SSL_PROTO_DTLS)
656#error "MBEDTLS_SSL_DTLS_HELLO_VERIFY defined, but not all prerequisites"
657#endif
658
659#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && \
660 !defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY)
661#error "MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE defined, but not all prerequisites"
662#endif
663
664#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) && \
665 ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) )
666#error "MBEDTLS_SSL_DTLS_ANTI_REPLAY defined, but not all prerequisites"
667#endif
668
669#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) && \
670 ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) )
671#error "MBEDTLS_SSL_DTLS_BADMAC_LIMIT defined, but not all prerequisites"
672#endif
673
674#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) && \
675 !defined(MBEDTLS_SSL_PROTO_TLS1) && \
676 !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \
677 !defined(MBEDTLS_SSL_PROTO_TLS1_2)
678#error "MBEDTLS_SSL_ENCRYPT_THEN_MAC defined, but not all prerequsites"
679#endif
680
681#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) && \
682 !defined(MBEDTLS_SSL_PROTO_TLS1) && \
683 !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \
684 !defined(MBEDTLS_SSL_PROTO_TLS1_2)
685#error "MBEDTLS_SSL_EXTENDED_MASTER_SECRET defined, but not all prerequsites"
686#endif
687
688#if defined(MBEDTLS_SSL_TICKET_C) && !defined(MBEDTLS_CIPHER_C)
689#error "MBEDTLS_SSL_TICKET_C defined, but not all prerequisites"
690#endif
691
692#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) && \
693 !defined(MBEDTLS_SSL_PROTO_SSL3) && !defined(MBEDTLS_SSL_PROTO_TLS1)
694#error "MBEDTLS_SSL_CBC_RECORD_SPLITTING defined, but not all prerequisites"
695#endif
696
697#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) && \
698 !defined(MBEDTLS_X509_CRT_PARSE_C)
699#error "MBEDTLS_SSL_SERVER_NAME_INDICATION defined, but not all prerequisites"
700#endif
701
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200702#if defined(MBEDTLS_THREADING_PTHREAD)
703#if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL)
704#error "MBEDTLS_THREADING_PTHREAD defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200705#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200706#define MBEDTLS_THREADING_IMPL
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200707#endif
708
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200709#if defined(MBEDTLS_THREADING_ALT)
710#if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL)
711#error "MBEDTLS_THREADING_ALT defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200712#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200713#define MBEDTLS_THREADING_IMPL
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200714#endif
715
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200716#if defined(MBEDTLS_THREADING_C) && !defined(MBEDTLS_THREADING_IMPL)
717#error "MBEDTLS_THREADING_C defined, single threading implementation required"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200718#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200719#undef MBEDTLS_THREADING_IMPL
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200720
Manuel Pégourié-Gonnardaeefa492018-10-22 12:14:52 +0200721#if defined(MBEDTLS_USE_PSA_CRYPTO) && !defined(MBEDTLS_PSA_CRYPTO_C)
722#error "MBEDTLS_USE_PSA_CRYPTO defined, but not all prerequisites"
723#endif
724
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200725#if defined(MBEDTLS_VERSION_FEATURES) && !defined(MBEDTLS_VERSION_C)
726#error "MBEDTLS_VERSION_FEATURES defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200727#endif
728
Gilles Peskine252e3912020-02-26 18:33:58 +0100729#if defined(MBEDTLS_X509_USE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \
730 !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_PARSE_C) || \
731 !defined(MBEDTLS_PK_PARSE_C) )
732#error "MBEDTLS_X509_USE_C defined, but not all prerequisites"
733#endif
734
735#if defined(MBEDTLS_X509_CREATE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \
736 !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_WRITE_C) || \
737 !defined(MBEDTLS_PK_WRITE_C) )
738#error "MBEDTLS_X509_CREATE_C defined, but not all prerequisites"
739#endif
740
741#if defined(MBEDTLS_X509_CRT_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
742#error "MBEDTLS_X509_CRT_PARSE_C defined, but not all prerequisites"
743#endif
744
745#if defined(MBEDTLS_X509_CRL_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
746#error "MBEDTLS_X509_CRL_PARSE_C defined, but not all prerequisites"
747#endif
748
749#if defined(MBEDTLS_X509_CSR_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
750#error "MBEDTLS_X509_CSR_PARSE_C defined, but not all prerequisites"
751#endif
752
753#if defined(MBEDTLS_X509_CRT_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) )
754#error "MBEDTLS_X509_CRT_WRITE_C defined, but not all prerequisites"
755#endif
756
757#if defined(MBEDTLS_X509_CSR_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) )
758#error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites"
759#endif
760
Andres Amaya Garciad7fce002017-07-20 11:49:32 +0100761#if defined(MBEDTLS_HAVE_INT32) && defined(MBEDTLS_HAVE_INT64)
762#error "MBEDTLS_HAVE_INT32 and MBEDTLS_HAVE_INT64 cannot be defined simultaneously"
763#endif /* MBEDTLS_HAVE_INT32 && MBEDTLS_HAVE_INT64 */
764
Andres Amaya Garcia93db11a2017-07-20 12:11:19 +0100765#if ( defined(MBEDTLS_HAVE_INT32) || defined(MBEDTLS_HAVE_INT64) ) && \
766 defined(MBEDTLS_HAVE_ASM)
Andres Amaya Garciab39467d2017-07-20 13:21:15 +0100767#error "MBEDTLS_HAVE_INT32/MBEDTLS_HAVE_INT64 and MBEDTLS_HAVE_ASM cannot be defined simultaneously"
Andres Amaya Garciad7fce002017-07-20 11:49:32 +0100768#endif /* (MBEDTLS_HAVE_INT32 || MBEDTLS_HAVE_INT64) && MBEDTLS_HAVE_ASM */
769
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200770/*
771 * Avoid warning from -pedantic. This is a convenient place for this
772 * workaround since this is included by every single file before the
Antonin Décimo36e89b52019-01-23 15:24:37 +0100773 * #if defined(MBEDTLS_xxx_C) that results in empty translation units.
Manuel Pégourié-Gonnardf78e4de2015-05-29 10:52:14 +0200774 */
775typedef int mbedtls_iso_c_forbids_empty_translation_units;
776
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200777#endif /* MBEDTLS_CHECK_CONFIG_H */