blob: cf5e981da061d1818e078a1de26c3d9ea14e4013 [file] [log] [blame]
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +02001/**
Ronald Crone11ae172024-11-12 15:57:42 +01002 * \file mbedtls/check_config.h
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +02003 *
4 * \brief Consistency checks for configuration options
Gilles Peskine975e74c2024-04-26 14:18:10 +02005 *
6 * This is an internal header. Do not include it directly.
7 *
8 * This header is included automatically by all public Mbed TLS headers
9 * (via mbedtls/build_info.h). Do not include it directly in a configuration
10 * file such as mbedtls/mbedtls_config.h or #MBEDTLS_USER_CONFIG_FILE!
11 * It would run at the wrong time due to missing derived symbols.
Darryl Greena40a1012018-01-05 15:33:17 +000012 */
13/*
Bence Szépkúti1e148272020-08-07 13:07:28 +020014 * Copyright The Mbed TLS Contributors
Dave Rodgman16799db2023-11-02 19:47:20 +000015 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020016 */
17
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020018#ifndef MBEDTLS_CHECK_CONFIG_H
19#define MBEDTLS_CHECK_CONFIG_H
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020020
David Horstmann1b847812022-11-14 15:40:46 +000021/* *INDENT-OFF* */
Gilles Peskine690fb5e2024-05-16 14:54:04 +020022
23#if !defined(MBEDTLS_CONFIG_IS_FINALIZED)
24#warning "Do not include mbedtls/check_config.h manually! " \
25 "This may cause spurious errors. " \
26 "It is included automatically at the right point since Mbed TLS 3.0."
27#endif /* !MBEDTLS_CONFIG_IS_FINALIZED */
28
Jaeden Amero197496a2021-06-08 18:31:27 +010029#if defined(TARGET_LIKE_MBED) && defined(MBEDTLS_NET_C)
30#error "The NET module is not available for mbed OS - please use the network functions provided by Mbed OS"
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020031#endif
32
Manuel Pégourié-Gonnard60c793b2015-06-18 20:52:58 +020033#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_HAVE_TIME)
34#error "MBEDTLS_HAVE_TIME_DATE without MBEDTLS_HAVE_TIME does not make sense"
35#endif
36
Manuel Pégourié-Gonnard7f22f342023-09-28 09:46:22 +020037/* Limitations on ECC curves acceleration: partial curve acceleration is only
38 * supported with crypto excluding PK, X.509 or TLS.
39 * Note: no need to check X.509 as it depends on PK. */
40#if defined(MBEDTLS_PSA_ACCEL_ECC_BRAINPOOL_P_R1_256) || \
41 defined(MBEDTLS_PSA_ACCEL_ECC_BRAINPOOL_P_R1_384) || \
42 defined(MBEDTLS_PSA_ACCEL_ECC_BRAINPOOL_P_R1_512) || \
43 defined(MBEDTLS_PSA_ACCEL_ECC_MONTGOMERY_255) || \
44 defined(MBEDTLS_PSA_ACCEL_ECC_MONTGOMERY_448) || \
45 defined(MBEDTLS_PSA_ACCEL_ECC_SECP_K1_192) || \
Manuel Pégourié-Gonnard7f22f342023-09-28 09:46:22 +020046 defined(MBEDTLS_PSA_ACCEL_ECC_SECP_K1_256) || \
47 defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_192) || \
Manuel Pégourié-Gonnard7f22f342023-09-28 09:46:22 +020048 defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_256) || \
49 defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_384) || \
50 defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_521)
51#if defined(MBEDTLS_PSA_ECC_ACCEL_INCOMPLETE_CURVES)
Ronald Crone11ae172024-11-12 15:57:42 +010052#if defined(MBEDTLS_SSL_TLS_C)
Manuel Pégourié-Gonnard7f22f342023-09-28 09:46:22 +020053#error "Unsupported partial support for ECC curves acceleration, see docs/driver-only-builds.md"
54#endif /* modules beyond what's supported */
55#endif /* not all curves accelerated */
56#endif /* some curve accelerated */
57
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020058#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) && \
Valerio Settiaa7cbd62023-07-07 17:22:17 +020059 ( !defined(MBEDTLS_CAN_ECDH) || \
Elena Uziunaite9c647642024-09-06 10:49:05 +010060 !defined(PSA_HAVE_ALG_ECDSA_SIGN) || \
Gilles Peskine7ab66a62018-09-14 17:47:41 +020061 !defined(MBEDTLS_X509_CRT_PARSE_C) )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020062#error "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020063#endif
64
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020065#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \
Ronald Crona5f36482025-06-30 10:36:25 +020066 ( !defined(MBEDTLS_CAN_ECDH) || !defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC) || \
Gilles Peskine7ab66a62018-09-14 17:47:41 +020067 !defined(MBEDTLS_X509_CRT_PARSE_C) )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020068#error "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020069#endif
70
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020071#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) && \
Valerio Settiaa7cbd62023-07-07 17:22:17 +020072 !defined(MBEDTLS_CAN_ECDH)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020073#error "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020074#endif
75
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020076#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
Ronald Crona5f36482025-06-30 10:36:25 +020077 ( !defined(MBEDTLS_CAN_ECDH) || !defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC) || \
78 !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(PSA_WANT_ALG_RSA_PKCS1V15_CRYPT) || !defined(PSA_WANT_ALG_RSA_PKCS1V15_SIGN) )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020079#error "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020080#endif
81
Manuel Pégourié-Gonnard45bcb6a2023-03-10 11:40:48 +010082#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \
Valerio Settiaa7cbd62023-07-07 17:22:17 +020083 ( !defined(MBEDTLS_CAN_ECDH) || \
Elena Uziunaite9c647642024-09-06 10:49:05 +010084 !defined(PSA_HAVE_ALG_ECDSA_SIGN) || \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020085 !defined(MBEDTLS_X509_CRT_PARSE_C) )
86#error "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020087#endif
88
Manuel Pégourié-Gonnarde1f3faf2024-02-08 12:17:20 +010089#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \
90 ( !defined(PSA_WANT_ALG_JPAKE) || \
91 !defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC) || \
92 !defined(PSA_WANT_ECC_SECP_R1_256) )
Manuel Pégourié-Gonnard557535d2015-09-15 17:53:32 +020093#error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites"
94#endif
95
Manuel Pégourié-Gonnard41bc8b62023-03-14 23:59:24 +010096/* Use of EC J-PAKE in TLS requires SHA-256. */
Manuel Pégourié-Gonnard3c16abe2022-09-19 10:44:42 +020097#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \
Elena Uziunaitec0d69432024-08-20 14:53:19 +010098 !defined(PSA_WANT_ALG_SHA_256)
Manuel Pégourié-Gonnard3c16abe2022-09-19 10:44:42 +020099#error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites"
100#endif
101
Gilles Peskineeccd8882020-03-10 12:19:08 +0100102#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) && \
Manuel Pégourié-Gonnard49f64b42024-02-08 12:00:28 +0100103 !defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) && \
Elena Uziunaitec0d69432024-08-20 14:53:19 +0100104 !defined(PSA_WANT_ALG_SHA_256) && \
Elena Uziunaite05fe6e42024-09-03 16:52:28 +0100105 !defined(PSA_WANT_ALG_SHA_512) && \
Elena Uziunaite9fc5be02024-09-04 18:12:59 +0100106 !defined(PSA_WANT_ALG_SHA_1)
Manuel Pégourié-Gonnard49f64b42024-02-08 12:00:28 +0100107#error "!MBEDTLS_SSL_KEEP_PEER_CERTIFICATE requires SHA-512, SHA-256 or SHA-1".
Hanno Beckerfe4ef0c2019-02-26 11:43:09 +0000108#endif
109
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200110#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) && \
Ronald Crona5f36482025-06-30 10:36:25 +0200111 ( !defined(PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC) || !defined(PSA_WANT_ALG_RSA_OAEP) )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200112#error "MBEDTLS_X509_RSASSA_PSS_SUPPORT defined, but not all prerequisites"
Manuel Pégourié-Gonnard9df5c962014-01-24 14:37:29 +0100113#endif
114
Manuel Pégourié-Gonnarda31ddb92023-03-22 00:13:50 +0100115/* TLS 1.3 requires separate HKDF parts from PSA,
116 * and at least one ciphersuite, so at least SHA-256 or SHA-384
117 * from PSA to use with HKDF.
118 *
119 * Note: for dependencies common with TLS 1.2 (running handshake hash),
120 * see MBEDTLS_SSL_TLS_C. */
Ronald Cron6f135e12021-12-08 16:57:54 +0100121#if defined(MBEDTLS_SSL_PROTO_TLS1_3) && \
Antonio de Angelis7889fe72024-02-07 13:01:33 +0000122 !(defined(MBEDTLS_PSA_CRYPTO_CLIENT) && \
Manuel Pégourié-Gonnarda31ddb92023-03-22 00:13:50 +0100123 defined(PSA_WANT_ALG_HKDF_EXTRACT) && \
124 defined(PSA_WANT_ALG_HKDF_EXPAND) && \
125 (defined(PSA_WANT_ALG_SHA_256) || defined(PSA_WANT_ALG_SHA_384)))
Ronald Cron6f135e12021-12-08 16:57:54 +0100126#error "MBEDTLS_SSL_PROTO_TLS1_3 defined, but not all prerequisites"
Hanno Becker6055a172020-06-02 06:20:23 +0100127#endif
128
Ronald Crond8d2ea52022-10-04 15:48:06 +0200129#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED)
Valerio Settia15078b2023-07-06 14:52:45 +0200130#if !( (defined(PSA_WANT_ALG_ECDH) || defined(PSA_WANT_ALG_FFDH)) && \
131 defined(MBEDTLS_X509_CRT_PARSE_C) && \
Ronald Crona5f36482025-06-30 10:36:25 +0200132 ( defined(PSA_HAVE_ALG_ECDSA_SIGN) || defined(PSA_WANT_ALG_RSA_OAEP) ) )
Ronald Crond8d2ea52022-10-04 15:48:06 +0200133#error "MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED defined, but not all prerequisites"
134#endif
135#endif
136
137#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED)
Przemek Stekielce05f542023-06-15 16:44:08 +0200138#if !( defined(PSA_WANT_ALG_ECDH) || defined(PSA_WANT_ALG_FFDH) )
Ronald Crond8d2ea52022-10-04 15:48:06 +0200139#error "MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED defined, but not all prerequisites"
140#endif
141#endif
142
Tom Cosgroveafb2fe12022-06-29 16:36:12 +0100143/*
144 * The current implementation of TLS 1.3 requires MBEDTLS_SSL_KEEP_PEER_CERTIFICATE.
145 */
146#if defined(MBEDTLS_SSL_PROTO_TLS1_3) && !defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
147#error "MBEDTLS_SSL_PROTO_TLS1_3 defined without MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
148#endif
149
TRodziewicz0f82ec62021-05-12 17:49:18 +0200150#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
Gabor Mezeie1e27302025-02-26 18:06:05 +0100151 !(defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
Simon Butcher432e7022019-04-11 18:56:18 +0100152 defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
153 defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
154 defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \
155 defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \
Simon Butcher432e7022019-04-11 18:56:18 +0100156 defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \
157 defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) )
158#error "One or more versions of the TLS protocol are enabled " \
159 "but no key exchange methods defined with MBEDTLS_KEY_EXCHANGE_xxxx"
160#endif
161
Harry Ramsey2547ae92025-01-20 10:04:53 +0000162#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
163 !(defined(PSA_WANT_ALG_SHA_1) || defined(PSA_WANT_ALG_SHA_256) || defined(PSA_WANT_ALG_SHA_512))
164#error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites"
165#endif
166
Xiaokang Qian95a07302022-10-25 02:56:00 +0000167#if defined(MBEDTLS_SSL_EARLY_DATA) && \
Xiaokang Qian402bb1e2022-11-10 10:38:17 +0000168 ( !defined(MBEDTLS_SSL_SESSION_TICKETS) || \
169 ( !defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED) && \
170 !defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED) ) )
Xiaokang Qian95a07302022-10-25 02:56:00 +0000171#error "MBEDTLS_SSL_EARLY_DATA defined, but not all prerequisites"
172#endif
173
Jerry Yu16f68532022-11-05 10:50:06 +0800174#if defined(MBEDTLS_SSL_EARLY_DATA) && defined(MBEDTLS_SSL_SRV_C) && \
Tom Cosgrove3b4471e2023-09-14 12:59:50 +0100175 defined(MBEDTLS_SSL_MAX_EARLY_DATA_SIZE) && \
176 ((MBEDTLS_SSL_MAX_EARLY_DATA_SIZE < 0) || \
177 (MBEDTLS_SSL_MAX_EARLY_DATA_SIZE > UINT32_MAX))
178#error "MBEDTLS_SSL_MAX_EARLY_DATA_SIZE must be in the range(0..UINT32_MAX)"
Jerry Yu16f68532022-11-05 10:50:06 +0800179#endif
180
Manuel Pégourié-Gonnard5a8d56d2015-05-13 10:10:00 +0200181#if defined(MBEDTLS_SSL_PROTO_DTLS) && \
Manuel Pégourié-Gonnard5a8d56d2015-05-13 10:10:00 +0200182 !defined(MBEDTLS_SSL_PROTO_TLS1_2)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200183#error "MBEDTLS_SSL_PROTO_DTLS defined, but not all prerequisites"
Manuel Pégourié-Gonnard0b1ff292014-02-06 13:04:16 +0100184#endif
185
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200186#if defined(MBEDTLS_SSL_CLI_C) && !defined(MBEDTLS_SSL_TLS_C)
187#error "MBEDTLS_SSL_CLI_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200188#endif
189
Valerio Settia4bb0fa2023-01-03 15:36:25 +0100190#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) && !defined(MBEDTLS_X509_CRT_PARSE_C)
191#error "MBEDTLS_SSL_ASYNC_PRIVATE defined, but not all prerequisites"
192#endif
193
Manuel Pégourié-Gonnarda31ddb92023-03-22 00:13:50 +0100194/* TLS 1.2 and 1.3 require SHA-256 or SHA-384 (running handshake hash) */
Elena Uziunaitefeb105c2024-09-05 13:08:59 +0100195#if defined(MBEDTLS_SSL_TLS_C) && \
Elena Uziunaitec0d69432024-08-20 14:53:19 +0100196 !(defined(PSA_WANT_ALG_SHA_256) || defined(PSA_WANT_ALG_SHA_384))
Manuel Pégourié-Gonnard70a1b6d2023-03-24 10:30:40 +0100197#error "MBEDTLS_SSL_TLS_C defined, but not all prerequisites"
Manuel Pégourié-Gonnarda31ddb92023-03-22 00:13:50 +0100198#endif
Manuel Pégourié-Gonnarda31ddb92023-03-22 00:13:50 +0100199
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200200#if defined(MBEDTLS_SSL_SRV_C) && !defined(MBEDTLS_SSL_TLS_C)
201#error "MBEDTLS_SSL_SRV_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200202#endif
203
Jerry Yue0a64122021-12-23 11:06:26 +0800204#if defined(MBEDTLS_SSL_TLS_C) && \
205 !( defined(MBEDTLS_SSL_PROTO_TLS1_2) || defined(MBEDTLS_SSL_PROTO_TLS1_3) )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200206#error "MBEDTLS_SSL_TLS_C defined, but no protocols are active"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200207#endif
208
Manuel Pégourié-Gonnarde057d3b2015-05-20 10:59:43 +0200209#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && !defined(MBEDTLS_SSL_PROTO_DTLS)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200210#error "MBEDTLS_SSL_DTLS_HELLO_VERIFY defined, but not all prerequisites"
Manuel Pégourié-Gonnard82202f02014-07-23 00:28:58 +0200211#endif
212
Manuel Pégourié-Gonnard62c74bb2015-09-08 17:50:29 +0200213#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && \
Manuel Pégourié-Gonnardddfe5d22015-09-09 12:46:16 +0200214 !defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY)
Manuel Pégourié-Gonnard62c74bb2015-09-08 17:50:29 +0200215#error "MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE defined, but not all prerequisites"
216#endif
217
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200218#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) && \
219 ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) )
220#error "MBEDTLS_SSL_DTLS_ANTI_REPLAY defined, but not all prerequisites"
Manuel Pégourié-Gonnard8464a462014-09-24 14:05:32 +0200221#endif
222
Gilles Peskined3d02902020-03-04 21:35:27 +0100223#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) && \
224 ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) )
225#error "MBEDTLS_SSL_DTLS_CONNECTION_ID defined, but not all prerequisites"
226#endif
227
228#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) && \
229 defined(MBEDTLS_SSL_CID_IN_LEN_MAX) && \
230 MBEDTLS_SSL_CID_IN_LEN_MAX > 255
231#error "MBEDTLS_SSL_CID_IN_LEN_MAX too large (max 255)"
232#endif
233
234#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) && \
235 defined(MBEDTLS_SSL_CID_OUT_LEN_MAX) && \
236 MBEDTLS_SSL_CID_OUT_LEN_MAX > 255
237#error "MBEDTLS_SSL_CID_OUT_LEN_MAX too large (max 255)"
238#endif
239
Hannes Tschofenig88e55662022-11-23 10:14:54 +0100240#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT) && \
241 !defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
Tom Cosgrove1797b052022-12-04 17:19:59 +0000242#error "MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT defined, but not all prerequisites"
Hannes Tschofenigfd6cca42021-10-12 09:22:33 +0200243#endif
244
Hannes Tschofenigb2e66152022-11-23 10:53:44 +0100245#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT) && MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT != 0
246#if defined(MBEDTLS_DEPRECATED_REMOVED)
247#error "MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT is deprecated and will be removed in a future version of Mbed TLS"
248#elif defined(MBEDTLS_DEPRECATED_WARNING)
249#warning "MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT is deprecated and will be removed in a future version of Mbed TLS"
250#endif
251#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT && MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT != 0 */
Hannes Tschofenigfd6cca42021-10-12 09:22:33 +0200252
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200253#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) && \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200254 !defined(MBEDTLS_SSL_PROTO_TLS1_2)
Shaun Case8b0ecbc2021-12-20 21:14:10 -0800255#error "MBEDTLS_SSL_ENCRYPT_THEN_MAC defined, but not all prerequisites"
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100256#endif
257
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200258#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) && \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200259 !defined(MBEDTLS_SSL_PROTO_TLS1_2)
Shaun Case8b0ecbc2021-12-20 21:14:10 -0800260#error "MBEDTLS_SSL_EXTENDED_MASTER_SECRET defined, but not all prerequisites"
Manuel Pégourié-Gonnard769c6b62014-10-28 14:13:55 +0100261#endif
262
Gilles Peskine7d3186d2022-08-12 22:43:18 +0200263#if defined(MBEDTLS_SSL_RENEGOTIATION) && \
264 !defined(MBEDTLS_SSL_PROTO_TLS1_2)
265#error "MBEDTLS_SSL_RENEGOTIATION defined, but not all prerequisites"
266#endif
267
Przemek Stekiel52a428b2022-10-10 08:47:13 +0200268#if defined(MBEDTLS_SSL_TICKET_C) && \
Elena Uziunaitec0d69432024-08-20 14:53:19 +0100269 !( defined(PSA_WANT_ALG_CCM) || defined(PSA_WANT_ALG_GCM) || \
270 defined(PSA_WANT_ALG_CHACHA20_POLY1305) )
Przemek Stekield61a4d32022-10-11 09:40:40 +0200271#error "MBEDTLS_SSL_TICKET_C defined, but not all prerequisites"
Przemek Stekiel52a428b2022-10-10 08:47:13 +0200272#endif
273
Jerry Yu9750f812022-07-20 11:04:50 +0800274#if defined(MBEDTLS_SSL_TLS1_3_TICKET_NONCE_LENGTH) && \
275 MBEDTLS_SSL_TLS1_3_TICKET_NONCE_LENGTH >= 256
276#error "MBEDTLS_SSL_TLS1_3_TICKET_NONCE_LENGTH must be less than 256"
Jerry Yu08aed4d2022-07-20 10:36:12 +0800277#endif
278
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200279#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) && \
280 !defined(MBEDTLS_X509_CRT_PARSE_C)
281#error "MBEDTLS_SSL_SERVER_NAME_INDICATION defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200282#endif
283
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200284#if defined(MBEDTLS_VERSION_FEATURES) && !defined(MBEDTLS_VERSION_C)
285#error "MBEDTLS_VERSION_FEATURES defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200286#endif
287
Valerio Settic6aeb0d2023-07-27 10:10:28 +0200288#if defined(MBEDTLS_X509_USE_C) && \
Gilles Peskine02ec5852025-05-12 20:52:07 +0200289 (!defined(MBEDTLS_ASN1_PARSE_C) || !defined(MBEDTLS_PK_PARSE_C))
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200290#error "MBEDTLS_X509_USE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200291#endif
292
Valerio Settic6aeb0d2023-07-27 10:10:28 +0200293#if defined(MBEDTLS_X509_CREATE_C) && \
Gilles Peskine02ec5852025-05-12 20:52:07 +0200294 (!defined(MBEDTLS_ASN1_WRITE_C) || !defined(MBEDTLS_PK_PARSE_C))
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200295#error "MBEDTLS_X509_CREATE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200296#endif
297
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200298#if defined(MBEDTLS_X509_CRT_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
299#error "MBEDTLS_X509_CRT_PARSE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200300#endif
301
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200302#if defined(MBEDTLS_X509_CRL_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
303#error "MBEDTLS_X509_CRL_PARSE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200304#endif
305
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200306#if defined(MBEDTLS_X509_CSR_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
307#error "MBEDTLS_X509_CSR_PARSE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200308#endif
309
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200310#if defined(MBEDTLS_X509_CRT_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) )
311#error "MBEDTLS_X509_CRT_WRITE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200312#endif
313
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200314#if defined(MBEDTLS_X509_CSR_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) )
315#error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200316#endif
317
Valerio Settia4bb0fa2023-01-03 15:36:25 +0100318#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK) && \
Valerio Setti8e45cdd2023-01-05 09:32:29 +0100319 ( !defined(MBEDTLS_X509_CRT_PARSE_C) )
Valerio Settia4bb0fa2023-01-03 15:36:25 +0100320#error "MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK defined, but not all prerequisites"
321#endif
322
Ron Eldor3adb9922017-12-21 10:15:08 +0200323#if defined(MBEDTLS_SSL_DTLS_SRTP) && ( !defined(MBEDTLS_SSL_PROTO_DTLS) )
324#error "MBEDTLS_SSL_DTLS_SRTP defined, but not all prerequisites"
325#endif
326
Andrzej Kurek557289b2020-10-21 15:12:39 +0200327#if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH) && ( !defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) )
328#error "MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH defined, but not all prerequisites"
329#endif
330
Jan Bruckner151f6422023-02-10 12:45:19 +0100331#if defined(MBEDTLS_SSL_RECORD_SIZE_LIMIT) && ( !defined(MBEDTLS_SSL_PROTO_TLS1_3) )
332#error "MBEDTLS_SSL_RECORD_SIZE_LIMIT defined, but not all prerequisites"
333#endif
334
Valerio Settie7bac172023-10-02 16:03:42 +0200335#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION) && \
Elena Uziunaitec0d69432024-08-20 14:53:19 +0100336 !( defined(PSA_WANT_ALG_CCM) || defined(PSA_WANT_ALG_GCM) || \
337 defined(PSA_WANT_ALG_CHACHA20_POLY1305) )
Przemek Stekield582a012022-09-28 07:59:01 +0200338#error "MBEDTLS_SSL_CONTEXT_SERIALIZATION defined, but not all prerequisites"
339#endif
Gilles Peskinefa4e4b82021-04-21 18:45:41 +0200340
341/* Reject attempts to enable options that have been removed and that could
342 * cause a build to succeed but with features removed. */
343
344#if defined(MBEDTLS_HAVEGE_C) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100345#error "MBEDTLS_HAVEGE_C was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/2599"
Gilles Peskinefa4e4b82021-04-21 18:45:41 +0200346#endif
347
348#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100349#error "MBEDTLS_SSL_HW_RECORD_ACCEL was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4031"
Gilles Peskinefa4e4b82021-04-21 18:45:41 +0200350#endif
351
352#if defined(MBEDTLS_SSL_PROTO_SSL3) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100353#error "MBEDTLS_SSL_PROTO_SSL3 (SSL v3.0 support) was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4031"
Gilles Peskinefa4e4b82021-04-21 18:45:41 +0200354#endif
355
356#if defined(MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100357#error "MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO (SSL v2 ClientHello support) was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4031"
Gilles Peskinefa4e4b82021-04-21 18:45:41 +0200358#endif
359
360#if defined(MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100361#error "MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT (compatibility with the buggy implementation of truncated HMAC in Mbed TLS up to 2.7) was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4031"
Gilles Peskinefa4e4b82021-04-21 18:45:41 +0200362#endif
363
364#if defined(MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES) //no-check-names
Gilles Peskinecc26e3b2021-04-21 19:01:59 +0200365#error "MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES was removed in Mbed TLS 3.0. See the ChangeLog entry if you really need SHA-1-signed certificates."
Gilles Peskinefa4e4b82021-04-21 18:45:41 +0200366#endif
367
368#if defined(MBEDTLS_ZLIB_SUPPORT) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100369#error "MBEDTLS_ZLIB_SUPPORT was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4031"
Gilles Peskinefa4e4b82021-04-21 18:45:41 +0200370#endif
371
TRodziewiczcc707412021-05-14 15:08:04 +0200372#if defined(MBEDTLS_CHECK_PARAMS) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100373#error "MBEDTLS_CHECK_PARAMS was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4313"
TRodziewiczcc707412021-05-14 15:08:04 +0200374#endif
375
TRodziewicz4e57f4c2021-05-31 12:58:25 +0200376#if defined(MBEDTLS_SSL_CID_PADDING_GRANULARITY) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100377#error "MBEDTLS_SSL_CID_PADDING_GRANULARITY was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4335"
TRodziewicz4e57f4c2021-05-31 12:58:25 +0200378#endif
379
380#if defined(MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100381#error "MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4335"
TRodziewicz4e57f4c2021-05-31 12:58:25 +0200382#endif
383
Thomas Daubney4a7010d2021-06-15 12:54:14 +0100384#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100385#error "MBEDTLS_SSL_TRUNCATED_HMAC was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4341"
Thomas Daubney4a7010d2021-06-15 12:54:14 +0100386#endif
387
Nayna Jainc9deb182020-11-16 19:03:12 +0000388#if defined(MBEDTLS_PKCS7_C) && ( ( !defined(MBEDTLS_ASN1_PARSE_C) ) || \
Gilles Peskine02ec5852025-05-12 20:52:07 +0200389 ( !defined(MBEDTLS_PK_PARSE_C) ) || \
Valerio Settic6aeb0d2023-07-27 10:10:28 +0200390 ( !defined(MBEDTLS_X509_CRT_PARSE_C) ) || \
391 ( !defined(MBEDTLS_X509_CRL_PARSE_C) ) || \
Nick Child89e82e12022-11-09 10:36:10 -0600392 ( !defined(MBEDTLS_MD_C) ) )
Nayna Jainc9deb182020-11-16 19:03:12 +0000393#error "MBEDTLS_PKCS7_C is defined, but not all prerequisites"
394#endif
395
David Horstmann1b847812022-11-14 15:40:46 +0000396/* *INDENT-ON* */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200397#endif /* MBEDTLS_CHECK_CONFIG_H */