blob: 22ddaa80fde70fc0257cb5482f37f0e644a04c12 [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) || \
48 defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_224) || \
49 defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_256) || \
50 defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_384) || \
51 defined(MBEDTLS_PSA_ACCEL_ECC_SECP_R1_521)
52#if defined(MBEDTLS_PSA_ECC_ACCEL_INCOMPLETE_CURVES)
Ronald Crone11ae172024-11-12 15:57:42 +010053#if defined(MBEDTLS_SSL_TLS_C)
Manuel Pégourié-Gonnard7f22f342023-09-28 09:46:22 +020054#error "Unsupported partial support for ECC curves acceleration, see docs/driver-only-builds.md"
55#endif /* modules beyond what's supported */
56#endif /* not all curves accelerated */
57#endif /* some curve accelerated */
58
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020059#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) && \
Valerio Settiaa7cbd62023-07-07 17:22:17 +020060 ( !defined(MBEDTLS_CAN_ECDH) || \
Elena Uziunaite9c647642024-09-06 10:49:05 +010061 !defined(PSA_HAVE_ALG_ECDSA_SIGN) || \
Gilles Peskine7ab66a62018-09-14 17:47:41 +020062 !defined(MBEDTLS_X509_CRT_PARSE_C) )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020063#error "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020064#endif
65
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020066#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \
Valerio Settiaa7cbd62023-07-07 17:22:17 +020067 ( !defined(MBEDTLS_CAN_ECDH) || !defined(MBEDTLS_RSA_C) || \
Gilles Peskine7ab66a62018-09-14 17:47:41 +020068 !defined(MBEDTLS_X509_CRT_PARSE_C) )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020069#error "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020070#endif
71
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020072#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) && \
Valerio Settiaa7cbd62023-07-07 17:22:17 +020073 !defined(MBEDTLS_CAN_ECDH)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020074#error "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020075#endif
76
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020077#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
Valerio Settiaa7cbd62023-07-07 17:22:17 +020078 ( !defined(MBEDTLS_CAN_ECDH) || !defined(MBEDTLS_RSA_C) || \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020079 !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) )
80#error "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020081#endif
82
Manuel Pégourié-Gonnard45bcb6a2023-03-10 11:40:48 +010083#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \
Valerio Settiaa7cbd62023-07-07 17:22:17 +020084 ( !defined(MBEDTLS_CAN_ECDH) || \
Elena Uziunaite9c647642024-09-06 10:49:05 +010085 !defined(PSA_HAVE_ALG_ECDSA_SIGN) || \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020086 !defined(MBEDTLS_X509_CRT_PARSE_C) )
87#error "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +020088#endif
89
Manuel Pégourié-Gonnarde1f3faf2024-02-08 12:17:20 +010090#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \
91 ( !defined(PSA_WANT_ALG_JPAKE) || \
92 !defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC) || \
93 !defined(PSA_WANT_ECC_SECP_R1_256) )
Manuel Pégourié-Gonnard557535d2015-09-15 17:53:32 +020094#error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites"
95#endif
96
Manuel Pégourié-Gonnard41bc8b62023-03-14 23:59:24 +010097/* Use of EC J-PAKE in TLS requires SHA-256. */
Manuel Pégourié-Gonnard3c16abe2022-09-19 10:44:42 +020098#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \
Elena Uziunaitec0d69432024-08-20 14:53:19 +010099 !defined(PSA_WANT_ALG_SHA_256)
Manuel Pégourié-Gonnard3c16abe2022-09-19 10:44:42 +0200100#error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites"
101#endif
102
Gilles Peskineeccd8882020-03-10 12:19:08 +0100103#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) && \
Manuel Pégourié-Gonnard49f64b42024-02-08 12:00:28 +0100104 !defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) && \
Elena Uziunaitec0d69432024-08-20 14:53:19 +0100105 !defined(PSA_WANT_ALG_SHA_256) && \
Elena Uziunaite05fe6e42024-09-03 16:52:28 +0100106 !defined(PSA_WANT_ALG_SHA_512) && \
Elena Uziunaite9fc5be02024-09-04 18:12:59 +0100107 !defined(PSA_WANT_ALG_SHA_1)
Manuel Pégourié-Gonnard49f64b42024-02-08 12:00:28 +0100108#error "!MBEDTLS_SSL_KEEP_PEER_CERTIFICATE requires SHA-512, SHA-256 or SHA-1".
Hanno Beckerfe4ef0c2019-02-26 11:43:09 +0000109#endif
110
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200111#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) && \
112 ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_PKCS1_V21) )
113#error "MBEDTLS_X509_RSASSA_PSS_SUPPORT defined, but not all prerequisites"
Manuel Pégourié-Gonnard9df5c962014-01-24 14:37:29 +0100114#endif
115
Manuel Pégourié-Gonnarda31ddb92023-03-22 00:13:50 +0100116/* TLS 1.3 requires separate HKDF parts from PSA,
117 * and at least one ciphersuite, so at least SHA-256 or SHA-384
118 * from PSA to use with HKDF.
119 *
120 * Note: for dependencies common with TLS 1.2 (running handshake hash),
121 * see MBEDTLS_SSL_TLS_C. */
Ronald Cron6f135e12021-12-08 16:57:54 +0100122#if defined(MBEDTLS_SSL_PROTO_TLS1_3) && \
Antonio de Angelis7889fe72024-02-07 13:01:33 +0000123 !(defined(MBEDTLS_PSA_CRYPTO_CLIENT) && \
Manuel Pégourié-Gonnarda31ddb92023-03-22 00:13:50 +0100124 defined(PSA_WANT_ALG_HKDF_EXTRACT) && \
125 defined(PSA_WANT_ALG_HKDF_EXPAND) && \
126 (defined(PSA_WANT_ALG_SHA_256) || defined(PSA_WANT_ALG_SHA_384)))
Ronald Cron6f135e12021-12-08 16:57:54 +0100127#error "MBEDTLS_SSL_PROTO_TLS1_3 defined, but not all prerequisites"
Hanno Becker6055a172020-06-02 06:20:23 +0100128#endif
129
Ronald Crond8d2ea52022-10-04 15:48:06 +0200130#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED)
Valerio Settia15078b2023-07-06 14:52:45 +0200131#if !( (defined(PSA_WANT_ALG_ECDH) || defined(PSA_WANT_ALG_FFDH)) && \
132 defined(MBEDTLS_X509_CRT_PARSE_C) && \
Elena Uziunaite9c647642024-09-06 10:49:05 +0100133 ( defined(PSA_HAVE_ALG_ECDSA_SIGN) || defined(MBEDTLS_PKCS1_V21) ) )
Ronald Crond8d2ea52022-10-04 15:48:06 +0200134#error "MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED defined, but not all prerequisites"
135#endif
136#endif
137
138#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED)
Przemek Stekielce05f542023-06-15 16:44:08 +0200139#if !( defined(PSA_WANT_ALG_ECDH) || defined(PSA_WANT_ALG_FFDH) )
Ronald Crond8d2ea52022-10-04 15:48:06 +0200140#error "MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED defined, but not all prerequisites"
141#endif
142#endif
143
Tom Cosgroveafb2fe12022-06-29 16:36:12 +0100144/*
145 * The current implementation of TLS 1.3 requires MBEDTLS_SSL_KEEP_PEER_CERTIFICATE.
146 */
147#if defined(MBEDTLS_SSL_PROTO_TLS1_3) && !defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
148#error "MBEDTLS_SSL_PROTO_TLS1_3 defined without MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
149#endif
150
TRodziewicz0f82ec62021-05-12 17:49:18 +0200151#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
Gabor Mezeie1e27302025-02-26 18:06:05 +0100152 !(defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
Simon Butcher432e7022019-04-11 18:56:18 +0100153 defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
154 defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
155 defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \
156 defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \
Simon Butcher432e7022019-04-11 18:56:18 +0100157 defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \
158 defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) )
159#error "One or more versions of the TLS protocol are enabled " \
160 "but no key exchange methods defined with MBEDTLS_KEY_EXCHANGE_xxxx"
161#endif
162
Harry Ramsey2547ae92025-01-20 10:04:53 +0000163#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
164 !(defined(PSA_WANT_ALG_SHA_1) || defined(PSA_WANT_ALG_SHA_256) || defined(PSA_WANT_ALG_SHA_512))
165#error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites"
166#endif
167
Xiaokang Qian95a07302022-10-25 02:56:00 +0000168#if defined(MBEDTLS_SSL_EARLY_DATA) && \
Xiaokang Qian402bb1e2022-11-10 10:38:17 +0000169 ( !defined(MBEDTLS_SSL_SESSION_TICKETS) || \
170 ( !defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED) && \
171 !defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED) ) )
Xiaokang Qian95a07302022-10-25 02:56:00 +0000172#error "MBEDTLS_SSL_EARLY_DATA defined, but not all prerequisites"
173#endif
174
Jerry Yu16f68532022-11-05 10:50:06 +0800175#if defined(MBEDTLS_SSL_EARLY_DATA) && defined(MBEDTLS_SSL_SRV_C) && \
Tom Cosgrove3b4471e2023-09-14 12:59:50 +0100176 defined(MBEDTLS_SSL_MAX_EARLY_DATA_SIZE) && \
177 ((MBEDTLS_SSL_MAX_EARLY_DATA_SIZE < 0) || \
178 (MBEDTLS_SSL_MAX_EARLY_DATA_SIZE > UINT32_MAX))
179#error "MBEDTLS_SSL_MAX_EARLY_DATA_SIZE must be in the range(0..UINT32_MAX)"
Jerry Yu16f68532022-11-05 10:50:06 +0800180#endif
181
Manuel Pégourié-Gonnard5a8d56d2015-05-13 10:10:00 +0200182#if defined(MBEDTLS_SSL_PROTO_DTLS) && \
Manuel Pégourié-Gonnard5a8d56d2015-05-13 10:10:00 +0200183 !defined(MBEDTLS_SSL_PROTO_TLS1_2)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200184#error "MBEDTLS_SSL_PROTO_DTLS defined, but not all prerequisites"
Manuel Pégourié-Gonnard0b1ff292014-02-06 13:04:16 +0100185#endif
186
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200187#if defined(MBEDTLS_SSL_CLI_C) && !defined(MBEDTLS_SSL_TLS_C)
188#error "MBEDTLS_SSL_CLI_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200189#endif
190
Valerio Settia4bb0fa2023-01-03 15:36:25 +0100191#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) && !defined(MBEDTLS_X509_CRT_PARSE_C)
192#error "MBEDTLS_SSL_ASYNC_PRIVATE defined, but not all prerequisites"
193#endif
194
Manuel Pégourié-Gonnarda31ddb92023-03-22 00:13:50 +0100195/* TLS 1.2 and 1.3 require SHA-256 or SHA-384 (running handshake hash) */
Elena Uziunaitefeb105c2024-09-05 13:08:59 +0100196#if defined(MBEDTLS_SSL_TLS_C) && \
Elena Uziunaitec0d69432024-08-20 14:53:19 +0100197 !(defined(PSA_WANT_ALG_SHA_256) || defined(PSA_WANT_ALG_SHA_384))
Manuel Pégourié-Gonnard70a1b6d2023-03-24 10:30:40 +0100198#error "MBEDTLS_SSL_TLS_C defined, but not all prerequisites"
Manuel Pégourié-Gonnarda31ddb92023-03-22 00:13:50 +0100199#endif
Manuel Pégourié-Gonnarda31ddb92023-03-22 00:13:50 +0100200
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200201#if defined(MBEDTLS_SSL_SRV_C) && !defined(MBEDTLS_SSL_TLS_C)
202#error "MBEDTLS_SSL_SRV_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200203#endif
204
Jerry Yue0a64122021-12-23 11:06:26 +0800205#if defined(MBEDTLS_SSL_TLS_C) && \
206 !( defined(MBEDTLS_SSL_PROTO_TLS1_2) || defined(MBEDTLS_SSL_PROTO_TLS1_3) )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200207#error "MBEDTLS_SSL_TLS_C defined, but no protocols are active"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200208#endif
209
Manuel Pégourié-Gonnarde057d3b2015-05-20 10:59:43 +0200210#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && !defined(MBEDTLS_SSL_PROTO_DTLS)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200211#error "MBEDTLS_SSL_DTLS_HELLO_VERIFY defined, but not all prerequisites"
Manuel Pégourié-Gonnard82202f02014-07-23 00:28:58 +0200212#endif
213
Manuel Pégourié-Gonnard62c74bb2015-09-08 17:50:29 +0200214#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && \
Manuel Pégourié-Gonnardddfe5d22015-09-09 12:46:16 +0200215 !defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY)
Manuel Pégourié-Gonnard62c74bb2015-09-08 17:50:29 +0200216#error "MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE defined, but not all prerequisites"
217#endif
218
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200219#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) && \
220 ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) )
221#error "MBEDTLS_SSL_DTLS_ANTI_REPLAY defined, but not all prerequisites"
Manuel Pégourié-Gonnard8464a462014-09-24 14:05:32 +0200222#endif
223
Gilles Peskined3d02902020-03-04 21:35:27 +0100224#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) && \
225 ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) )
226#error "MBEDTLS_SSL_DTLS_CONNECTION_ID defined, but not all prerequisites"
227#endif
228
229#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) && \
230 defined(MBEDTLS_SSL_CID_IN_LEN_MAX) && \
231 MBEDTLS_SSL_CID_IN_LEN_MAX > 255
232#error "MBEDTLS_SSL_CID_IN_LEN_MAX too large (max 255)"
233#endif
234
235#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) && \
236 defined(MBEDTLS_SSL_CID_OUT_LEN_MAX) && \
237 MBEDTLS_SSL_CID_OUT_LEN_MAX > 255
238#error "MBEDTLS_SSL_CID_OUT_LEN_MAX too large (max 255)"
239#endif
240
Hannes Tschofenig88e55662022-11-23 10:14:54 +0100241#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT) && \
242 !defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
Tom Cosgrove1797b052022-12-04 17:19:59 +0000243#error "MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT defined, but not all prerequisites"
Hannes Tschofenigfd6cca42021-10-12 09:22:33 +0200244#endif
245
Hannes Tschofenigb2e66152022-11-23 10:53:44 +0100246#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT) && MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT != 0
247#if defined(MBEDTLS_DEPRECATED_REMOVED)
248#error "MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT is deprecated and will be removed in a future version of Mbed TLS"
249#elif defined(MBEDTLS_DEPRECATED_WARNING)
250#warning "MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT is deprecated and will be removed in a future version of Mbed TLS"
251#endif
252#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT && MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT != 0 */
Hannes Tschofenigfd6cca42021-10-12 09:22:33 +0200253
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200254#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) && \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200255 !defined(MBEDTLS_SSL_PROTO_TLS1_2)
Shaun Case8b0ecbc2021-12-20 21:14:10 -0800256#error "MBEDTLS_SSL_ENCRYPT_THEN_MAC defined, but not all prerequisites"
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100257#endif
258
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200259#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) && \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200260 !defined(MBEDTLS_SSL_PROTO_TLS1_2)
Shaun Case8b0ecbc2021-12-20 21:14:10 -0800261#error "MBEDTLS_SSL_EXTENDED_MASTER_SECRET defined, but not all prerequisites"
Manuel Pégourié-Gonnard769c6b62014-10-28 14:13:55 +0100262#endif
263
Gilles Peskine7d3186d2022-08-12 22:43:18 +0200264#if defined(MBEDTLS_SSL_RENEGOTIATION) && \
265 !defined(MBEDTLS_SSL_PROTO_TLS1_2)
266#error "MBEDTLS_SSL_RENEGOTIATION defined, but not all prerequisites"
267#endif
268
Przemek Stekiel52a428b2022-10-10 08:47:13 +0200269#if defined(MBEDTLS_SSL_TICKET_C) && \
Elena Uziunaitec0d69432024-08-20 14:53:19 +0100270 !( defined(PSA_WANT_ALG_CCM) || defined(PSA_WANT_ALG_GCM) || \
271 defined(PSA_WANT_ALG_CHACHA20_POLY1305) )
Przemek Stekield61a4d32022-10-11 09:40:40 +0200272#error "MBEDTLS_SSL_TICKET_C defined, but not all prerequisites"
Przemek Stekiel52a428b2022-10-10 08:47:13 +0200273#endif
274
Jerry Yu9750f812022-07-20 11:04:50 +0800275#if defined(MBEDTLS_SSL_TLS1_3_TICKET_NONCE_LENGTH) && \
276 MBEDTLS_SSL_TLS1_3_TICKET_NONCE_LENGTH >= 256
277#error "MBEDTLS_SSL_TLS1_3_TICKET_NONCE_LENGTH must be less than 256"
Jerry Yu08aed4d2022-07-20 10:36:12 +0800278#endif
279
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200280#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) && \
281 !defined(MBEDTLS_X509_CRT_PARSE_C)
282#error "MBEDTLS_SSL_SERVER_NAME_INDICATION defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200283#endif
284
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200285#if defined(MBEDTLS_VERSION_FEATURES) && !defined(MBEDTLS_VERSION_C)
286#error "MBEDTLS_VERSION_FEATURES defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200287#endif
288
Valerio Settic6aeb0d2023-07-27 10:10:28 +0200289#if defined(MBEDTLS_X509_USE_C) && \
Gilles Peskine02ec5852025-05-12 20:52:07 +0200290 (!defined(MBEDTLS_ASN1_PARSE_C) || !defined(MBEDTLS_PK_PARSE_C))
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200291#error "MBEDTLS_X509_USE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200292#endif
293
Valerio Settic6aeb0d2023-07-27 10:10:28 +0200294#if defined(MBEDTLS_X509_CREATE_C) && \
Gilles Peskine02ec5852025-05-12 20:52:07 +0200295 (!defined(MBEDTLS_ASN1_WRITE_C) || !defined(MBEDTLS_PK_PARSE_C))
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200296#error "MBEDTLS_X509_CREATE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200297#endif
298
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200299#if defined(MBEDTLS_X509_CRT_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
300#error "MBEDTLS_X509_CRT_PARSE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200301#endif
302
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200303#if defined(MBEDTLS_X509_CRL_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
304#error "MBEDTLS_X509_CRL_PARSE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200305#endif
306
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200307#if defined(MBEDTLS_X509_CSR_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
308#error "MBEDTLS_X509_CSR_PARSE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200309#endif
310
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200311#if defined(MBEDTLS_X509_CRT_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) )
312#error "MBEDTLS_X509_CRT_WRITE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200313#endif
314
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200315#if defined(MBEDTLS_X509_CSR_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) )
316#error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites"
Manuel Pégourié-Gonnard14d55952014-04-30 12:35:08 +0200317#endif
318
Valerio Settia4bb0fa2023-01-03 15:36:25 +0100319#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK) && \
Valerio Setti8e45cdd2023-01-05 09:32:29 +0100320 ( !defined(MBEDTLS_X509_CRT_PARSE_C) )
Valerio Settia4bb0fa2023-01-03 15:36:25 +0100321#error "MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK defined, but not all prerequisites"
322#endif
323
Ron Eldor3adb9922017-12-21 10:15:08 +0200324#if defined(MBEDTLS_SSL_DTLS_SRTP) && ( !defined(MBEDTLS_SSL_PROTO_DTLS) )
325#error "MBEDTLS_SSL_DTLS_SRTP defined, but not all prerequisites"
326#endif
327
Andrzej Kurek557289b2020-10-21 15:12:39 +0200328#if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH) && ( !defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) )
329#error "MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH defined, but not all prerequisites"
330#endif
331
Jan Bruckner151f6422023-02-10 12:45:19 +0100332#if defined(MBEDTLS_SSL_RECORD_SIZE_LIMIT) && ( !defined(MBEDTLS_SSL_PROTO_TLS1_3) )
333#error "MBEDTLS_SSL_RECORD_SIZE_LIMIT defined, but not all prerequisites"
334#endif
335
Valerio Settie7bac172023-10-02 16:03:42 +0200336#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION) && \
Elena Uziunaitec0d69432024-08-20 14:53:19 +0100337 !( defined(PSA_WANT_ALG_CCM) || defined(PSA_WANT_ALG_GCM) || \
338 defined(PSA_WANT_ALG_CHACHA20_POLY1305) )
Przemek Stekield582a012022-09-28 07:59:01 +0200339#error "MBEDTLS_SSL_CONTEXT_SERIALIZATION defined, but not all prerequisites"
340#endif
Gilles Peskinefa4e4b82021-04-21 18:45:41 +0200341
342/* Reject attempts to enable options that have been removed and that could
343 * cause a build to succeed but with features removed. */
344
345#if defined(MBEDTLS_HAVEGE_C) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100346#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 +0200347#endif
348
349#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100350#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 +0200351#endif
352
353#if defined(MBEDTLS_SSL_PROTO_SSL3) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100354#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 +0200355#endif
356
357#if defined(MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100358#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 +0200359#endif
360
361#if defined(MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100362#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 +0200363#endif
364
365#if defined(MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES) //no-check-names
Gilles Peskinecc26e3b2021-04-21 19:01:59 +0200366#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 +0200367#endif
368
369#if defined(MBEDTLS_ZLIB_SUPPORT) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100370#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 +0200371#endif
372
TRodziewiczcc707412021-05-14 15:08:04 +0200373#if defined(MBEDTLS_CHECK_PARAMS) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100374#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 +0200375#endif
376
TRodziewicz4e57f4c2021-05-31 12:58:25 +0200377#if defined(MBEDTLS_SSL_CID_PADDING_GRANULARITY) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100378#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 +0200379#endif
380
381#if defined(MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100382#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 +0200383#endif
384
Thomas Daubney4a7010d2021-06-15 12:54:14 +0100385#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) //no-check-names
Dave Rodgman017a1992022-03-31 14:07:01 +0100386#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 +0100387#endif
388
Nayna Jainc9deb182020-11-16 19:03:12 +0000389#if defined(MBEDTLS_PKCS7_C) && ( ( !defined(MBEDTLS_ASN1_PARSE_C) ) || \
Gilles Peskine02ec5852025-05-12 20:52:07 +0200390 ( !defined(MBEDTLS_PK_PARSE_C) ) || \
Valerio Settic6aeb0d2023-07-27 10:10:28 +0200391 ( !defined(MBEDTLS_X509_CRT_PARSE_C) ) || \
392 ( !defined(MBEDTLS_X509_CRL_PARSE_C) ) || \
Nick Child89e82e12022-11-09 10:36:10 -0600393 ( !defined(MBEDTLS_MD_C) ) )
Nayna Jainc9deb182020-11-16 19:03:12 +0000394#error "MBEDTLS_PKCS7_C is defined, but not all prerequisites"
395#endif
396
David Horstmann1b847812022-11-14 15:40:46 +0000397/* *INDENT-ON* */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200398#endif /* MBEDTLS_CHECK_CONFIG_H */