1 /** 2 * \file check_config.h 3 * 4 * \brief Consistency checks for configuration options 5 */ 6 /* 7 * Copyright The Mbed TLS Contributors 8 * 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. 21 */ 22 23 #ifndef MBEDTLS_CHECK_CONFIG_H 24 #define MBEDTLS_CHECK_CONFIG_H 25 26 /* *INDENT-OFF* */ 27 /* 28 * We assume CHAR_BIT is 8 in many places. In practice, this is true on our 29 * target platforms, so not an issue, but let's just be extra sure. 30 */ 31 #include <limits.h> 32 #if CHAR_BIT != 8 33 #error "mbed TLS requires a platform with 8-bit chars" 34 #endif 35 36 #include <stdint.h> 37 38 #if defined(_WIN32) 39 #if !defined(MBEDTLS_PLATFORM_C) 40 #error "MBEDTLS_PLATFORM_C is required on Windows" 41 #endif 42 43 /* Fix the config here. Not convenient to put an #ifdef _WIN32 in mbedtls_config.h as 44 * it would confuse config.py. */ 45 #if !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && \ 46 !defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) 47 #define MBEDTLS_PLATFORM_SNPRINTF_ALT 48 #endif 49 50 #if !defined(MBEDTLS_PLATFORM_VSNPRINTF_ALT) && \ 51 !defined(MBEDTLS_PLATFORM_VSNPRINTF_MACRO) 52 #define MBEDTLS_PLATFORM_VSNPRINTF_ALT 53 #endif 54 #endif /* _WIN32 */ 55 56 #if defined(TARGET_LIKE_MBED) && defined(MBEDTLS_NET_C) 57 #error "The NET module is not available for mbed OS - please use the network functions provided by Mbed OS" 58 #endif 59 60 #if defined(MBEDTLS_DEPRECATED_WARNING) && \ 61 !defined(__GNUC__) && !defined(__clang__) 62 #error "MBEDTLS_DEPRECATED_WARNING only works with GCC and Clang" 63 #endif 64 65 #if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_HAVE_TIME) 66 #error "MBEDTLS_HAVE_TIME_DATE without MBEDTLS_HAVE_TIME does not make sense" 67 #endif 68 69 #if defined(__aarch64__) && defined(__GNUC__) 70 /* We don't do anything with MBEDTLS_AESCE_C on systems without ^ these two */ 71 #if defined(MBEDTLS_AESCE_C) && !defined(MBEDTLS_HAVE_ASM) 72 #error "MBEDTLS_AESCE_C defined, but not all prerequisites" 73 #endif 74 #endif 75 76 #if defined(MBEDTLS_CTR_DRBG_C) && !defined(MBEDTLS_AES_C) 77 #error "MBEDTLS_CTR_DRBG_C defined, but not all prerequisites" 78 #endif 79 80 #if defined(MBEDTLS_DHM_C) && !defined(MBEDTLS_BIGNUM_C) 81 #error "MBEDTLS_DHM_C defined, but not all prerequisites" 82 #endif 83 84 #if defined(MBEDTLS_CMAC_C) && \ 85 ( !defined(MBEDTLS_CIPHER_C ) || ( !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_DES_C) ) ) 86 #error "MBEDTLS_CMAC_C defined, but not all prerequisites" 87 #endif 88 89 #if defined(MBEDTLS_NIST_KW_C) && \ 90 ( !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_CIPHER_C) ) 91 #error "MBEDTLS_NIST_KW_C defined, but not all prerequisites" 92 #endif 93 94 #if defined(MBEDTLS_ECDH_C) && !defined(MBEDTLS_ECP_C) 95 #error "MBEDTLS_ECDH_C defined, but not all prerequisites" 96 #endif 97 98 #if defined(MBEDTLS_ECDSA_C) && \ 99 ( !defined(MBEDTLS_ECP_C) || \ 100 !( defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) || \ 101 defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || \ 102 defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \ 103 defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) || \ 104 defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) || \ 105 defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || \ 106 defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \ 107 defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) || \ 108 defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) || \ 109 defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) || \ 110 defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) ) || \ 111 !defined(MBEDTLS_ASN1_PARSE_C) || \ 112 !defined(MBEDTLS_ASN1_WRITE_C) ) 113 #error "MBEDTLS_ECDSA_C defined, but not all prerequisites" 114 #endif 115 116 #if defined(MBEDTLS_ECJPAKE_C) && \ 117 ( !defined(MBEDTLS_ECP_C) || \ 118 !( defined(MBEDTLS_MD_C) || defined(MBEDTLS_PSA_CRYPTO_C) ) ) 119 #error "MBEDTLS_ECJPAKE_C defined, but not all prerequisites" 120 #endif 121 122 #if defined(MBEDTLS_ECP_RESTARTABLE) && \ 123 ( defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT) || \ 124 defined(MBEDTLS_ECDH_GEN_PUBLIC_ALT) || \ 125 defined(MBEDTLS_ECDSA_SIGN_ALT) || \ 126 defined(MBEDTLS_ECDSA_VERIFY_ALT) || \ 127 defined(MBEDTLS_ECDSA_GENKEY_ALT) || \ 128 defined(MBEDTLS_ECP_INTERNAL_ALT) || \ 129 defined(MBEDTLS_ECP_ALT) ) 130 #error "MBEDTLS_ECP_RESTARTABLE defined, but it cannot coexist with an alternative ECP implementation" 131 #endif 132 133 #if defined(MBEDTLS_ECP_RESTARTABLE) && \ 134 !defined(MBEDTLS_ECP_C) 135 #error "MBEDTLS_ECP_RESTARTABLE defined, but not all prerequisites" 136 #endif 137 138 #if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C) 139 #error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites" 140 #endif 141 142 #if defined(MBEDTLS_ECP_C) && ( !defined(MBEDTLS_BIGNUM_C) || ( \ 143 !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) && \ 153 !defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) && \ 154 !defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) && \ 155 !defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) ) ) 156 #error "MBEDTLS_ECP_C defined, but not all prerequisites" 157 #endif 158 159 #if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_ASN1_PARSE_C) 160 #error "MBEDTLS_PK_PARSE_C defined, but not all prerequisites" 161 #endif 162 163 #if defined(MBEDTLS_PKCS12_C) && !defined(MBEDTLS_CIPHER_C) 164 #error "MBEDTLS_PKCS12_C defined, but not all prerequisites" 165 #endif 166 167 #if defined(MBEDTLS_PKCS5_C) && \ 168 ( !( defined(MBEDTLS_MD_C) || defined(MBEDTLS_PSA_CRYPTO_C) ) || \ 169 !defined(MBEDTLS_CIPHER_C) ) 170 #error "MBEDTLS_PKCS5_C defined, but not all prerequisites" 171 #endif 172 173 #if defined(MBEDTLS_PKCS12_C) && \ 174 !( defined(MBEDTLS_MD_C) || defined(MBEDTLS_PSA_CRYPTO_C) ) 175 #error "MBEDTLS_PKCS12_C defined, but not all prerequisites" 176 #endif 177 178 #if defined(MBEDTLS_PKCS1_V21) && \ 179 !( defined(MBEDTLS_MD_C) || defined(MBEDTLS_PSA_CRYPTO_C) ) 180 #error "MBEDTLS_PKCS1_V21 defined, but not all prerequisites" 181 #endif 182 183 #if defined(MBEDTLS_ENTROPY_C) && (!defined(MBEDTLS_SHA512_C) && \ 184 !defined(MBEDTLS_SHA256_C)) 185 #error "MBEDTLS_ENTROPY_C defined, but not all prerequisites" 186 #endif 187 #if defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_SHA512_C) && \ 188 defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 64) 189 #error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high" 190 #endif 191 #if defined(MBEDTLS_ENTROPY_C) && \ 192 ( !defined(MBEDTLS_SHA512_C) || defined(MBEDTLS_ENTROPY_FORCE_SHA256) ) \ 193 && defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 32) 194 #error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high" 195 #endif 196 #if defined(MBEDTLS_ENTROPY_C) && \ 197 defined(MBEDTLS_ENTROPY_FORCE_SHA256) && !defined(MBEDTLS_SHA256_C) 198 #error "MBEDTLS_ENTROPY_FORCE_SHA256 defined, but not all prerequisites" 199 #endif 200 201 #if defined(__has_feature) 202 #if __has_feature(memory_sanitizer) 203 #define MBEDTLS_HAS_MEMSAN 204 #endif 205 #endif 206 #if defined(MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN) && !defined(MBEDTLS_HAS_MEMSAN) 207 #error "MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN requires building with MemorySanitizer" 208 #endif 209 #undef MBEDTLS_HAS_MEMSAN 210 211 #if defined(MBEDTLS_CCM_C) && ( \ 212 !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_CAMELLIA_C) && !defined(MBEDTLS_ARIA_C) ) 213 #error "MBEDTLS_CCM_C defined, but not all prerequisites" 214 #endif 215 216 #if defined(MBEDTLS_CCM_C) && !defined(MBEDTLS_CIPHER_C) 217 #error "MBEDTLS_CCM_C defined, but not all prerequisites" 218 #endif 219 220 #if defined(MBEDTLS_GCM_C) && ( \ 221 !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_CAMELLIA_C) && !defined(MBEDTLS_ARIA_C) ) 222 #error "MBEDTLS_GCM_C defined, but not all prerequisites" 223 #endif 224 225 #if defined(MBEDTLS_GCM_C) && !defined(MBEDTLS_CIPHER_C) 226 #error "MBEDTLS_GCM_C defined, but not all prerequisites" 227 #endif 228 229 #if defined(MBEDTLS_CHACHAPOLY_C) && !defined(MBEDTLS_CHACHA20_C) 230 #error "MBEDTLS_CHACHAPOLY_C defined, but not all prerequisites" 231 #endif 232 233 #if defined(MBEDTLS_CHACHAPOLY_C) && !defined(MBEDTLS_POLY1305_C) 234 #error "MBEDTLS_CHACHAPOLY_C defined, but not all prerequisites" 235 #endif 236 237 #if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) 238 #error "MBEDTLS_ECP_RANDOMIZE_JAC_ALT defined, but not all prerequisites" 239 #endif 240 241 #if defined(MBEDTLS_ECP_ADD_MIXED_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) 242 #error "MBEDTLS_ECP_ADD_MIXED_ALT defined, but not all prerequisites" 243 #endif 244 245 #if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) 246 #error "MBEDTLS_ECP_DOUBLE_JAC_ALT defined, but not all prerequisites" 247 #endif 248 249 #if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) 250 #error "MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT defined, but not all prerequisites" 251 #endif 252 253 #if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) 254 #error "MBEDTLS_ECP_NORMALIZE_JAC_ALT defined, but not all prerequisites" 255 #endif 256 257 #if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) 258 #error "MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT defined, but not all prerequisites" 259 #endif 260 261 #if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) 262 #error "MBEDTLS_ECP_RANDOMIZE_MXZ_ALT defined, but not all prerequisites" 263 #endif 264 265 #if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) 266 #error "MBEDTLS_ECP_NORMALIZE_MXZ_ALT defined, but not all prerequisites" 267 #endif 268 269 #if defined(MBEDTLS_ECP_NO_FALLBACK) && !defined(MBEDTLS_ECP_INTERNAL_ALT) 270 #error "MBEDTLS_ECP_NO_FALLBACK defined, but no alternative implementation enabled" 271 #endif 272 273 #if defined(MBEDTLS_HKDF_C) && !defined(MBEDTLS_MD_C) 274 #error "MBEDTLS_HKDF_C defined, but not all prerequisites" 275 #endif 276 277 #if defined(MBEDTLS_HMAC_DRBG_C) && !defined(MBEDTLS_MD_C) 278 #error "MBEDTLS_HMAC_DRBG_C defined, but not all prerequisites" 279 #endif 280 281 /* Helper for ECDSA dependencies, will be undefined at the end of the file */ 282 #if defined(MBEDTLS_USE_PSA_CRYPTO) 283 #if defined(PSA_HAVE_FULL_ECDSA) 284 #define MBEDTLS_PK_HAVE_ECDSA 285 #endif 286 #else /* MBEDTLS_USE_PSA_CRYPTO */ 287 #if defined(MBEDTLS_ECDSA_C) 288 #define MBEDTLS_PK_HAVE_ECDSA 289 #endif 290 #endif /* MBEDTLS_USE_PSA_CRYPTO */ 291 292 /* Helper for JPAKE dependencies, will be undefined at the end of the file */ 293 #if defined(MBEDTLS_USE_PSA_CRYPTO) 294 #if defined(PSA_HAVE_FULL_JPAKE) 295 #define MBEDTLS_PK_HAVE_JPAKE 296 #endif 297 #else /* MBEDTLS_USE_PSA_CRYPTO */ 298 #if defined(MBEDTLS_ECJPAKE_C) 299 #define MBEDTLS_PK_HAVE_JPAKE 300 #endif 301 #endif /* MBEDTLS_USE_PSA_CRYPTO */ 302 303 #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) && \ 304 ( !defined(MBEDTLS_ECDH_C) || \ 305 !defined(MBEDTLS_PK_HAVE_ECDSA) || \ 306 !defined(MBEDTLS_X509_CRT_PARSE_C) ) 307 #error "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED defined, but not all prerequisites" 308 #endif 309 310 #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ 311 ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_RSA_C) || \ 312 !defined(MBEDTLS_X509_CRT_PARSE_C) ) 313 #error "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED defined, but not all prerequisites" 314 #endif 315 316 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) && !defined(MBEDTLS_DHM_C) 317 #error "MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED defined, but not all prerequisites" 318 #endif 319 320 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) && \ 321 !defined(MBEDTLS_ECDH_C) 322 #error "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED defined, but not all prerequisites" 323 #endif 324 325 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ 326 ( !defined(MBEDTLS_DHM_C) || !defined(MBEDTLS_RSA_C) || \ 327 !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) ) 328 #error "MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED defined, but not all prerequisites" 329 #endif 330 331 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ 332 ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_RSA_C) || \ 333 !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) ) 334 #error "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED defined, but not all prerequisites" 335 #endif 336 337 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \ 338 ( !defined(MBEDTLS_ECDH_C) || \ 339 !defined(MBEDTLS_PK_HAVE_ECDSA) || \ 340 !defined(MBEDTLS_X509_CRT_PARSE_C) ) 341 #error "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED defined, but not all prerequisites" 342 #endif 343 344 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) && \ 345 ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \ 346 !defined(MBEDTLS_PKCS1_V15) ) 347 #error "MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED defined, but not all prerequisites" 348 #endif 349 350 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \ 351 ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \ 352 !defined(MBEDTLS_PKCS1_V15) ) 353 #error "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED defined, but not all prerequisites" 354 #endif 355 356 #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \ 357 ( !defined(MBEDTLS_PK_HAVE_JPAKE) || \ 358 !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) ) 359 #error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites" 360 #endif 361 362 /* Use of EC J-PAKE in TLS requires SHA-256. 363 * This will be taken from MD if it is present, or from PSA if MD is absent. 364 * Note: MBEDTLS_ECJPAKE_C depends on MBEDTLS_MD_C || MBEDTLS_PSA_CRYPTO_C. */ 365 #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \ 366 !( defined(MBEDTLS_MD_C) && defined(MBEDTLS_SHA256_C) ) && \ 367 !( !defined(MBEDTLS_MD_C) && defined(PSA_WANT_ALG_SHA_256) ) 368 #error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites" 369 #endif 370 371 #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) && \ 372 !defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) && \ 373 ( !defined(MBEDTLS_SHA256_C) && \ 374 !defined(MBEDTLS_SHA512_C) && \ 375 !defined(MBEDTLS_SHA1_C) ) 376 #error "!MBEDTLS_SSL_KEEP_PEER_CERTIFICATE requires MBEDTLS_SHA512_C, MBEDTLS_SHA256_C or MBEDTLS_SHA1_C" 377 #endif 378 379 #if defined(MBEDTLS_MD_C) && !( \ 380 defined(MBEDTLS_MD5_C) || \ 381 defined(MBEDTLS_RIPEMD160_C) || \ 382 defined(MBEDTLS_SHA1_C) || \ 383 defined(MBEDTLS_SHA224_C) || \ 384 defined(MBEDTLS_SHA256_C) || \ 385 defined(MBEDTLS_SHA384_C) || \ 386 defined(MBEDTLS_SHA512_C) ) 387 #error "MBEDTLS_MD_C defined, but not all prerequisites" 388 #endif 389 390 #if defined(MBEDTLS_LMS_C) && \ 391 ! ( defined(MBEDTLS_PSA_CRYPTO_C) && defined(PSA_WANT_ALG_SHA_256) ) 392 #error "MBEDTLS_LMS_C requires MBEDTLS_PSA_CRYPTO_C and PSA_WANT_ALG_SHA_256" 393 #endif 394 395 #if defined(MBEDTLS_LMS_PRIVATE) && \ 396 ( !defined(MBEDTLS_LMS_C) ) 397 #error "MBEDTLS_LMS_PRIVATE requires MBEDTLS_LMS_C" 398 #endif 399 400 #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ 401 ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) 402 #error "MBEDTLS_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites" 403 #endif 404 405 #if defined(MBEDTLS_MEMORY_BACKTRACE) && !defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) 406 #error "MBEDTLS_MEMORY_BACKTRACE defined, but not all prerequisites" 407 #endif 408 409 #if defined(MBEDTLS_MEMORY_DEBUG) && !defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) 410 #error "MBEDTLS_MEMORY_DEBUG defined, but not all prerequisites" 411 #endif 412 413 #if defined(MBEDTLS_PADLOCK_C) && !defined(MBEDTLS_HAVE_ASM) 414 #error "MBEDTLS_PADLOCK_C defined, but not all prerequisites" 415 #endif 416 417 #if defined(MBEDTLS_PEM_PARSE_C) && !defined(MBEDTLS_BASE64_C) 418 #error "MBEDTLS_PEM_PARSE_C defined, but not all prerequisites" 419 #endif 420 421 #if defined(MBEDTLS_PEM_WRITE_C) && !defined(MBEDTLS_BASE64_C) 422 #error "MBEDTLS_PEM_WRITE_C defined, but not all prerequisites" 423 #endif 424 425 #if defined(MBEDTLS_PK_C) && \ 426 !defined(MBEDTLS_RSA_C) && !defined(MBEDTLS_ECP_C) 427 #error "MBEDTLS_PK_C defined, but not all prerequisites" 428 #endif 429 430 #if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_PK_C) 431 #error "MBEDTLS_PK_PARSE_C defined, but not all prerequisites" 432 #endif 433 434 #if defined(MBEDTLS_PK_WRITE_C) && !defined(MBEDTLS_PK_C) 435 #error "MBEDTLS_PK_WRITE_C defined, but not all prerequisites" 436 #endif 437 438 #if defined(MBEDTLS_PLATFORM_EXIT_ALT) && !defined(MBEDTLS_PLATFORM_C) 439 #error "MBEDTLS_PLATFORM_EXIT_ALT defined, but not all prerequisites" 440 #endif 441 442 #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) && !defined(MBEDTLS_PLATFORM_C) 443 #error "MBEDTLS_PLATFORM_EXIT_MACRO defined, but not all prerequisites" 444 #endif 445 446 #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) &&\ 447 ( defined(MBEDTLS_PLATFORM_STD_EXIT) ||\ 448 defined(MBEDTLS_PLATFORM_EXIT_ALT) ) 449 #error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously" 450 #endif 451 452 #if defined(MBEDTLS_PLATFORM_SETBUF_ALT) && !defined(MBEDTLS_PLATFORM_C) 453 #error "MBEDTLS_PLATFORM_SETBUF_ALT defined, but not all prerequisites" 454 #endif 455 456 #if defined(MBEDTLS_PLATFORM_SETBUF_MACRO) && !defined(MBEDTLS_PLATFORM_C) 457 #error "MBEDTLS_PLATFORM_SETBUF_MACRO defined, but not all prerequisites" 458 #endif 459 460 #if defined(MBEDTLS_PLATFORM_SETBUF_MACRO) &&\ 461 ( defined(MBEDTLS_PLATFORM_STD_SETBUF) ||\ 462 defined(MBEDTLS_PLATFORM_SETBUF_ALT) ) 463 #error "MBEDTLS_PLATFORM_SETBUF_MACRO and MBEDTLS_PLATFORM_STD_SETBUF/MBEDTLS_PLATFORM_SETBUF_ALT cannot be defined simultaneously" 464 #endif 465 466 #if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\ 467 ( !defined(MBEDTLS_PLATFORM_C) ||\ 468 !defined(MBEDTLS_HAVE_TIME) ) 469 #error "MBEDTLS_PLATFORM_TIME_ALT defined, but not all prerequisites" 470 #endif 471 472 #if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\ 473 ( !defined(MBEDTLS_PLATFORM_C) ||\ 474 !defined(MBEDTLS_HAVE_TIME) ) 475 #error "MBEDTLS_PLATFORM_TIME_MACRO defined, but not all prerequisites" 476 #endif 477 478 #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\ 479 ( !defined(MBEDTLS_PLATFORM_C) ||\ 480 !defined(MBEDTLS_HAVE_TIME) ) 481 #error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO defined, but not all prerequisites" 482 #endif 483 484 #if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\ 485 ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\ 486 defined(MBEDTLS_PLATFORM_TIME_ALT) ) 487 #error "MBEDTLS_PLATFORM_TIME_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously" 488 #endif 489 490 #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\ 491 ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\ 492 defined(MBEDTLS_PLATFORM_TIME_ALT) ) 493 #error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously" 494 #endif 495 496 #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) 497 #error "MBEDTLS_PLATFORM_FPRINTF_ALT defined, but not all prerequisites" 498 #endif 499 500 #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) 501 #error "MBEDTLS_PLATFORM_FPRINTF_MACRO defined, but not all prerequisites" 502 #endif 503 504 #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) &&\ 505 ( defined(MBEDTLS_PLATFORM_STD_FPRINTF) ||\ 506 defined(MBEDTLS_PLATFORM_FPRINTF_ALT) ) 507 #error "MBEDTLS_PLATFORM_FPRINTF_MACRO and MBEDTLS_PLATFORM_STD_FPRINTF/MBEDTLS_PLATFORM_FPRINTF_ALT cannot be defined simultaneously" 508 #endif 509 510 #if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\ 511 ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) 512 #error "MBEDTLS_PLATFORM_FREE_MACRO defined, but not all prerequisites" 513 #endif 514 515 #if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\ 516 defined(MBEDTLS_PLATFORM_STD_FREE) 517 #error "MBEDTLS_PLATFORM_FREE_MACRO and MBEDTLS_PLATFORM_STD_FREE cannot be defined simultaneously" 518 #endif 519 520 #if defined(MBEDTLS_PLATFORM_FREE_MACRO) && !defined(MBEDTLS_PLATFORM_CALLOC_MACRO) 521 #error "MBEDTLS_PLATFORM_CALLOC_MACRO must be defined if MBEDTLS_PLATFORM_FREE_MACRO is" 522 #endif 523 524 #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\ 525 ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) 526 #error "MBEDTLS_PLATFORM_CALLOC_MACRO defined, but not all prerequisites" 527 #endif 528 529 #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\ 530 defined(MBEDTLS_PLATFORM_STD_CALLOC) 531 #error "MBEDTLS_PLATFORM_CALLOC_MACRO and MBEDTLS_PLATFORM_STD_CALLOC cannot be defined simultaneously" 532 #endif 533 534 #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) && !defined(MBEDTLS_PLATFORM_FREE_MACRO) 535 #error "MBEDTLS_PLATFORM_FREE_MACRO must be defined if MBEDTLS_PLATFORM_CALLOC_MACRO is" 536 #endif 537 538 #if defined(MBEDTLS_PLATFORM_MEMORY) && !defined(MBEDTLS_PLATFORM_C) 539 #error "MBEDTLS_PLATFORM_MEMORY defined, but not all prerequisites" 540 #endif 541 542 #if defined(MBEDTLS_PLATFORM_PRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) 543 #error "MBEDTLS_PLATFORM_PRINTF_ALT defined, but not all prerequisites" 544 #endif 545 546 #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) 547 #error "MBEDTLS_PLATFORM_PRINTF_MACRO defined, but not all prerequisites" 548 #endif 549 550 #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) &&\ 551 ( defined(MBEDTLS_PLATFORM_STD_PRINTF) ||\ 552 defined(MBEDTLS_PLATFORM_PRINTF_ALT) ) 553 #error "MBEDTLS_PLATFORM_PRINTF_MACRO and MBEDTLS_PLATFORM_STD_PRINTF/MBEDTLS_PLATFORM_PRINTF_ALT cannot be defined simultaneously" 554 #endif 555 556 #if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) 557 #error "MBEDTLS_PLATFORM_SNPRINTF_ALT defined, but not all prerequisites" 558 #endif 559 560 #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) 561 #error "MBEDTLS_PLATFORM_SNPRINTF_MACRO defined, but not all prerequisites" 562 #endif 563 564 #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) &&\ 565 ( defined(MBEDTLS_PLATFORM_STD_SNPRINTF) ||\ 566 defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) ) 567 #error "MBEDTLS_PLATFORM_SNPRINTF_MACRO and MBEDTLS_PLATFORM_STD_SNPRINTF/MBEDTLS_PLATFORM_SNPRINTF_ALT cannot be defined simultaneously" 568 #endif 569 570 #if defined(MBEDTLS_PLATFORM_VSNPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) 571 #error "MBEDTLS_PLATFORM_VSNPRINTF_ALT defined, but not all prerequisites" 572 #endif 573 574 #if defined(MBEDTLS_PLATFORM_VSNPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C) 575 #error "MBEDTLS_PLATFORM_VSNPRINTF_MACRO defined, but not all prerequisites" 576 #endif 577 578 #if defined(MBEDTLS_PLATFORM_VSNPRINTF_MACRO) &&\ 579 ( defined(MBEDTLS_PLATFORM_STD_VSNPRINTF) ||\ 580 defined(MBEDTLS_PLATFORM_VSNPRINTF_ALT) ) 581 #error "MBEDTLS_PLATFORM_VSNPRINTF_MACRO and MBEDTLS_PLATFORM_STD_VSNPRINTF/MBEDTLS_PLATFORM_VSNPRINTF_ALT cannot be defined simultaneously" 582 #endif 583 584 #if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) &&\ 585 !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) 586 #error "MBEDTLS_PLATFORM_STD_MEM_HDR defined, but not all prerequisites" 587 #endif 588 589 #if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY) 590 #error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites" 591 #endif 592 593 #if defined(MBEDTLS_PLATFORM_STD_FREE) && !defined(MBEDTLS_PLATFORM_MEMORY) 594 #error "MBEDTLS_PLATFORM_STD_FREE defined, but not all prerequisites" 595 #endif 596 597 #if defined(MBEDTLS_PLATFORM_STD_EXIT) &&\ 598 !defined(MBEDTLS_PLATFORM_EXIT_ALT) 599 #error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites" 600 #endif 601 602 #if defined(MBEDTLS_PLATFORM_STD_TIME) &&\ 603 ( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\ 604 !defined(MBEDTLS_HAVE_TIME) ) 605 #error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites" 606 #endif 607 608 #if defined(MBEDTLS_PLATFORM_STD_FPRINTF) &&\ 609 !defined(MBEDTLS_PLATFORM_FPRINTF_ALT) 610 #error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites" 611 #endif 612 613 #if defined(MBEDTLS_PLATFORM_STD_PRINTF) &&\ 614 !defined(MBEDTLS_PLATFORM_PRINTF_ALT) 615 #error "MBEDTLS_PLATFORM_STD_PRINTF defined, but not all prerequisites" 616 #endif 617 618 #if defined(MBEDTLS_PLATFORM_STD_SNPRINTF) &&\ 619 !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) 620 #error "MBEDTLS_PLATFORM_STD_SNPRINTF defined, but not all prerequisites" 621 #endif 622 623 #if defined(MBEDTLS_ENTROPY_NV_SEED) &&\ 624 ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_ENTROPY_C) ) 625 #error "MBEDTLS_ENTROPY_NV_SEED defined, but not all prerequisites" 626 #endif 627 628 #if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) &&\ 629 !defined(MBEDTLS_ENTROPY_NV_SEED) 630 #error "MBEDTLS_PLATFORM_NV_SEED_ALT defined, but not all prerequisites" 631 #endif 632 633 #if defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) &&\ 634 !defined(MBEDTLS_PLATFORM_NV_SEED_ALT) 635 #error "MBEDTLS_PLATFORM_STD_NV_SEED_READ defined, but not all prerequisites" 636 #endif 637 638 #if defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) &&\ 639 !defined(MBEDTLS_PLATFORM_NV_SEED_ALT) 640 #error "MBEDTLS_PLATFORM_STD_NV_SEED_WRITE defined, but not all prerequisites" 641 #endif 642 643 #if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) &&\ 644 ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) ||\ 645 defined(MBEDTLS_PLATFORM_NV_SEED_ALT) ) 646 #error "MBEDTLS_PLATFORM_NV_SEED_READ_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_READ cannot be defined simultaneously" 647 #endif 648 649 #if defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) &&\ 650 ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) ||\ 651 defined(MBEDTLS_PLATFORM_NV_SEED_ALT) ) 652 #error "MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_WRITE cannot be defined simultaneously" 653 #endif 654 655 #if defined(MBEDTLS_PSA_CRYPTO_C) && \ 656 !( ( ( defined(MBEDTLS_CTR_DRBG_C) || defined(MBEDTLS_HMAC_DRBG_C) ) && \ 657 defined(MBEDTLS_ENTROPY_C) ) || \ 658 defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) ) 659 #error "MBEDTLS_PSA_CRYPTO_C defined, but not all prerequisites (missing RNG)" 660 #endif 661 662 #if defined(MBEDTLS_PSA_CRYPTO_C) && !defined(MBEDTLS_CIPHER_C ) 663 #error "MBEDTLS_PSA_CRYPTO_C defined, but not all prerequisites" 664 #endif 665 666 #if defined(MBEDTLS_PSA_CRYPTO_SPM) && !defined(MBEDTLS_PSA_CRYPTO_C) 667 #error "MBEDTLS_PSA_CRYPTO_SPM defined, but not all prerequisites" 668 #endif 669 670 #if defined(MBEDTLS_PSA_CRYPTO_SE_C) && \ 671 ! ( defined(MBEDTLS_PSA_CRYPTO_C) && \ 672 defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) ) 673 #error "MBEDTLS_PSA_CRYPTO_SE_C defined, but not all prerequisites" 674 #endif 675 676 #if defined(MBEDTLS_PSA_CRYPTO_SE_C) 677 #if defined(MBEDTLS_DEPRECATED_REMOVED) 678 #error "MBEDTLS_PSA_CRYPTO_SE_C is deprecated and will be removed in a future version of Mbed TLS" 679 #elif defined(MBEDTLS_DEPRECATED_WARNING) 680 #warning "MBEDTLS_PSA_CRYPTO_SE_C is deprecated and will be removed in a future version of Mbed TLS" 681 #endif 682 #endif /* MBEDTLS_PSA_CRYPTO_SE_C */ 683 684 #if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) && \ 685 ! defined(MBEDTLS_PSA_CRYPTO_C) 686 #error "MBEDTLS_PSA_CRYPTO_STORAGE_C defined, but not all prerequisites" 687 #endif 688 689 #if defined(MBEDTLS_PSA_INJECT_ENTROPY) && \ 690 !( defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) && \ 691 defined(MBEDTLS_ENTROPY_NV_SEED) ) 692 #error "MBEDTLS_PSA_INJECT_ENTROPY defined, but not all prerequisites" 693 #endif 694 695 #if defined(MBEDTLS_PSA_INJECT_ENTROPY) && \ 696 !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) 697 #error "MBEDTLS_PSA_INJECT_ENTROPY is not compatible with actual entropy sources" 698 #endif 699 700 #if defined(MBEDTLS_PSA_INJECT_ENTROPY) && \ 701 defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) 702 #error "MBEDTLS_PSA_INJECT_ENTROPY is not compatible with MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG" 703 #endif 704 705 #if defined(MBEDTLS_PSA_ITS_FILE_C) && \ 706 !defined(MBEDTLS_FS_IO) 707 #error "MBEDTLS_PSA_ITS_FILE_C defined, but not all prerequisites" 708 #endif 709 710 #if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ 711 !defined(MBEDTLS_OID_C) ) 712 #error "MBEDTLS_RSA_C defined, but not all prerequisites" 713 #endif 714 715 #if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_PKCS1_V21) && \ 716 !defined(MBEDTLS_PKCS1_V15) ) 717 #error "MBEDTLS_RSA_C defined, but none of the PKCS1 versions enabled" 718 #endif 719 720 #if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) && \ 721 ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_PKCS1_V21) ) 722 #error "MBEDTLS_X509_RSASSA_PSS_SUPPORT defined, but not all prerequisites" 723 #endif 724 725 #if defined(MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT) && \ 726 defined(MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY) 727 #error "Must only define one of MBEDTLS_SHA512_USE_A64_CRYPTO_*" 728 #endif 729 730 #if defined(MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT) || \ 731 defined(MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY) 732 #if !defined(MBEDTLS_SHA512_C) 733 #error "MBEDTLS_SHA512_USE_A64_CRYPTO_* defined without MBEDTLS_SHA512_C" 734 #endif 735 #if defined(MBEDTLS_SHA512_ALT) || defined(MBEDTLS_SHA512_PROCESS_ALT) 736 #error "MBEDTLS_SHA512_*ALT can't be used with MBEDTLS_SHA512_USE_A64_CRYPTO_*" 737 #endif 738 739 #endif /* MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT || MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY */ 740 741 #if defined(MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY) && !defined(__aarch64__) 742 #error "MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY defined on non-Aarch64 system" 743 #endif 744 745 #if defined(MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT) && \ 746 defined(MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY) 747 #error "Must only define one of MBEDTLS_SHA256_USE_A64_CRYPTO_*" 748 #endif 749 750 #if defined(MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT) || \ 751 defined(MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY) 752 #if !defined(MBEDTLS_SHA256_C) 753 #error "MBEDTLS_SHA256_USE_A64_CRYPTO_* defined without MBEDTLS_SHA256_C" 754 #endif 755 #if defined(MBEDTLS_SHA256_ALT) || defined(MBEDTLS_SHA256_PROCESS_ALT) 756 #error "MBEDTLS_SHA256_*ALT can't be used with MBEDTLS_SHA256_USE_A64_CRYPTO_*" 757 #endif 758 759 #endif 760 761 #if defined(MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY) && \ 762 !defined(__aarch64__) && !defined(_M_ARM64) 763 #error "MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY defined on non-Aarch64 system" 764 #endif 765 766 #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && !defined(MBEDTLS_USE_PSA_CRYPTO) && \ 767 !( defined(MBEDTLS_SHA1_C) || defined(MBEDTLS_SHA256_C) || defined(MBEDTLS_SHA512_C) ) 768 #error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites" 769 #endif 770 771 /* TLS 1.3 requires separate HKDF parts from PSA */ 772 #if defined(MBEDTLS_SSL_PROTO_TLS1_3) && \ 773 !( defined(MBEDTLS_PSA_CRYPTO_C) && defined(PSA_WANT_ALG_HKDF_EXTRACT) && defined(PSA_WANT_ALG_HKDF_EXPAND) ) 774 #error "MBEDTLS_SSL_PROTO_TLS1_3 defined, but not all prerequisites" 775 #endif 776 777 /* TLS 1.3 requires at least one ciphersuite, so at least SHA-256 or SHA-384 */ 778 #if defined(MBEDTLS_SSL_PROTO_TLS1_3) 779 /* We always need at least one of the hashes via PSA (for use with HKDF) */ 780 #if !( defined(PSA_WANT_ALG_SHA_256) || defined(PSA_WANT_ALG_SHA_384) ) 781 #error "MBEDTLS_SSL_PROTO_TLS1_3 defined, but not all prerequisites" 782 #endif /* !(PSA_WANT_ALG_SHA_256 || PSA_WANT_ALG_SHA_384) */ 783 #if !defined(MBEDTLS_USE_PSA_CRYPTO) 784 /* When USE_PSA_CRYPTO is not defined, we also need SHA-256 or SHA-384 via the 785 * legacy interface, including via the MD layer, for the parts of the code 786 * that are shared with TLS 1.2 (running handshake hash). */ 787 #if !defined(MBEDTLS_MD_C) || \ 788 !( defined(MBEDTLS_SHA256_C) || defined(MBEDTLS_SHA384_C) ) 789 #error "MBEDTLS_SSL_PROTO_TLS1_3 defined, but not all prerequisites" 790 #endif /* !MBEDTLS_MD_C || !(MBEDTLS_SHA256_C || MBEDTLS_SHA384_C) */ 791 #endif /* !MBEDTLS_USE_PSA_CRYPTO */ 792 #endif /* MBEDTLS_SSL_PROTO_TLS1_3 */ 793 794 #if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED) 795 #if !( defined(MBEDTLS_ECDH_C) && defined(MBEDTLS_X509_CRT_PARSE_C) && \ 796 ( defined(MBEDTLS_PK_HAVE_ECDSA) || defined(MBEDTLS_PKCS1_V21) ) ) 797 #error "MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED defined, but not all prerequisites" 798 #endif 799 #endif 800 801 #if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED) 802 #if !( defined(MBEDTLS_ECDH_C) ) 803 #error "MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED defined, but not all prerequisites" 804 #endif 805 #endif 806 807 /* 808 * The current implementation of TLS 1.3 requires MBEDTLS_SSL_KEEP_PEER_CERTIFICATE. 809 */ 810 #if defined(MBEDTLS_SSL_PROTO_TLS1_3) && !defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) 811 #error "MBEDTLS_SSL_PROTO_TLS1_3 defined without MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" 812 #endif 813 814 #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ 815 !(defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ 816 defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ 817 defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ 818 defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ 819 defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ 820 defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \ 821 defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \ 822 defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \ 823 defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \ 824 defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \ 825 defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) ) 826 #error "One or more versions of the TLS protocol are enabled " \ 827 "but no key exchange methods defined with MBEDTLS_KEY_EXCHANGE_xxxx" 828 #endif 829 830 #if defined(MBEDTLS_SSL_EARLY_DATA) && \ 831 ( !defined(MBEDTLS_SSL_SESSION_TICKETS) || \ 832 ( !defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED) && \ 833 !defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED) ) ) 834 #error "MBEDTLS_SSL_EARLY_DATA defined, but not all prerequisites" 835 #endif 836 837 #if defined(MBEDTLS_SSL_EARLY_DATA) && defined(MBEDTLS_SSL_SRV_C) && \ 838 ( !defined(MBEDTLS_SSL_MAX_EARLY_DATA_SIZE) || \ 839 ( MBEDTLS_SSL_MAX_EARLY_DATA_SIZE < 0 ) || \ 840 ( MBEDTLS_SSL_MAX_EARLY_DATA_SIZE > UINT32_MAX ) ) 841 #error "MBEDTLS_SSL_MAX_EARLY_DATA_SIZE MUST be defined and in range(0..UINT32_MAX)" 842 #endif 843 844 #if defined(MBEDTLS_SSL_PROTO_DTLS) && \ 845 !defined(MBEDTLS_SSL_PROTO_TLS1_2) 846 #error "MBEDTLS_SSL_PROTO_DTLS defined, but not all prerequisites" 847 #endif 848 849 #if defined(MBEDTLS_SSL_CLI_C) && !defined(MBEDTLS_SSL_TLS_C) 850 #error "MBEDTLS_SSL_CLI_C defined, but not all prerequisites" 851 #endif 852 853 #if defined(MBEDTLS_SSL_ASYNC_PRIVATE) && !defined(MBEDTLS_X509_CRT_PARSE_C) 854 #error "MBEDTLS_SSL_ASYNC_PRIVATE defined, but not all prerequisites" 855 #endif 856 857 #if defined(MBEDTLS_SSL_TLS_C) && ( !defined(MBEDTLS_CIPHER_C) || \ 858 ( !defined(MBEDTLS_MD_C) && !defined(MBEDTLS_USE_PSA_CRYPTO) ) ) 859 #error "MBEDTLS_SSL_TLS_C defined, but not all prerequisites" 860 #endif 861 862 #if defined(MBEDTLS_SSL_SRV_C) && !defined(MBEDTLS_SSL_TLS_C) 863 #error "MBEDTLS_SSL_SRV_C defined, but not all prerequisites" 864 #endif 865 866 #if defined(MBEDTLS_SSL_TLS_C) && \ 867 !( defined(MBEDTLS_SSL_PROTO_TLS1_2) || defined(MBEDTLS_SSL_PROTO_TLS1_3) ) 868 #error "MBEDTLS_SSL_TLS_C defined, but no protocols are active" 869 #endif 870 871 #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && !defined(MBEDTLS_SSL_PROTO_DTLS) 872 #error "MBEDTLS_SSL_DTLS_HELLO_VERIFY defined, but not all prerequisites" 873 #endif 874 875 #if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && \ 876 !defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) 877 #error "MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE defined, but not all prerequisites" 878 #endif 879 880 #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) && \ 881 ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) ) 882 #error "MBEDTLS_SSL_DTLS_ANTI_REPLAY defined, but not all prerequisites" 883 #endif 884 885 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) && \ 886 ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) ) 887 #error "MBEDTLS_SSL_DTLS_CONNECTION_ID defined, but not all prerequisites" 888 #endif 889 890 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) && \ 891 defined(MBEDTLS_SSL_CID_IN_LEN_MAX) && \ 892 MBEDTLS_SSL_CID_IN_LEN_MAX > 255 893 #error "MBEDTLS_SSL_CID_IN_LEN_MAX too large (max 255)" 894 #endif 895 896 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) && \ 897 defined(MBEDTLS_SSL_CID_OUT_LEN_MAX) && \ 898 MBEDTLS_SSL_CID_OUT_LEN_MAX > 255 899 #error "MBEDTLS_SSL_CID_OUT_LEN_MAX too large (max 255)" 900 #endif 901 902 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT) && \ 903 !defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) 904 #error "MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT defined, but not all prerequisites" 905 #endif 906 907 #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT) && MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT != 0 908 #if defined(MBEDTLS_DEPRECATED_REMOVED) 909 #error "MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT is deprecated and will be removed in a future version of Mbed TLS" 910 #elif defined(MBEDTLS_DEPRECATED_WARNING) 911 #warning "MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT is deprecated and will be removed in a future version of Mbed TLS" 912 #endif 913 #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT && MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT != 0 */ 914 915 #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) && \ 916 !defined(MBEDTLS_SSL_PROTO_TLS1_2) 917 #error "MBEDTLS_SSL_ENCRYPT_THEN_MAC defined, but not all prerequisites" 918 #endif 919 920 #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) && \ 921 !defined(MBEDTLS_SSL_PROTO_TLS1_2) 922 #error "MBEDTLS_SSL_EXTENDED_MASTER_SECRET defined, but not all prerequisites" 923 #endif 924 925 #if defined(MBEDTLS_SSL_RENEGOTIATION) && \ 926 !defined(MBEDTLS_SSL_PROTO_TLS1_2) 927 #error "MBEDTLS_SSL_RENEGOTIATION defined, but not all prerequisites" 928 #endif 929 930 #if defined(MBEDTLS_SSL_TICKET_C) && ( !defined(MBEDTLS_CIPHER_C) && \ 931 !defined(MBEDTLS_USE_PSA_CRYPTO) ) 932 #error "MBEDTLS_SSL_TICKET_C defined, but not all prerequisites" 933 #endif 934 935 #if defined(MBEDTLS_SSL_TICKET_C) && \ 936 !( defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CCM_C) || defined(MBEDTLS_CHACHAPOLY_C) ) 937 #error "MBEDTLS_SSL_TICKET_C defined, but not all prerequisites" 938 #endif 939 940 #if defined(MBEDTLS_SSL_TLS1_3_TICKET_NONCE_LENGTH) && \ 941 MBEDTLS_SSL_TLS1_3_TICKET_NONCE_LENGTH >= 256 942 #error "MBEDTLS_SSL_TLS1_3_TICKET_NONCE_LENGTH must be less than 256" 943 #endif 944 945 #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) && \ 946 !defined(MBEDTLS_X509_CRT_PARSE_C) 947 #error "MBEDTLS_SSL_SERVER_NAME_INDICATION defined, but not all prerequisites" 948 #endif 949 950 #if defined(MBEDTLS_THREADING_PTHREAD) 951 #if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL) 952 #error "MBEDTLS_THREADING_PTHREAD defined, but not all prerequisites" 953 #endif 954 #define MBEDTLS_THREADING_IMPL 955 #endif 956 957 #if defined(MBEDTLS_THREADING_ALT) 958 #if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL) 959 #error "MBEDTLS_THREADING_ALT defined, but not all prerequisites" 960 #endif 961 #define MBEDTLS_THREADING_IMPL 962 #endif 963 964 #if defined(MBEDTLS_THREADING_C) && !defined(MBEDTLS_THREADING_IMPL) 965 #error "MBEDTLS_THREADING_C defined, single threading implementation required" 966 #endif 967 #undef MBEDTLS_THREADING_IMPL 968 969 // #if defined(MBEDTLS_USE_PSA_CRYPTO) && !defined(MBEDTLS_PSA_CRYPTO_C) 970 // #error "MBEDTLS_USE_PSA_CRYPTO defined, but not all prerequisites" 971 // #endif 972 973 #if defined(MBEDTLS_VERSION_FEATURES) && !defined(MBEDTLS_VERSION_C) 974 #error "MBEDTLS_VERSION_FEATURES defined, but not all prerequisites" 975 #endif 976 977 #if defined(MBEDTLS_X509_USE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ 978 !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_PARSE_C) || \ 979 !defined(MBEDTLS_PK_PARSE_C) || \ 980 ( !defined(MBEDTLS_MD_C) && !defined(MBEDTLS_USE_PSA_CRYPTO) ) ) 981 #error "MBEDTLS_X509_USE_C defined, but not all prerequisites" 982 #endif 983 984 #if defined(MBEDTLS_X509_CREATE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \ 985 !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_WRITE_C) || \ 986 !defined(MBEDTLS_PK_PARSE_C) || \ 987 ( !defined(MBEDTLS_MD_C) && !defined(MBEDTLS_USE_PSA_CRYPTO) ) ) 988 #error "MBEDTLS_X509_CREATE_C defined, but not all prerequisites" 989 #endif 990 991 #if defined(MBEDTLS_X509_CRT_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) 992 #error "MBEDTLS_X509_CRT_PARSE_C defined, but not all prerequisites" 993 #endif 994 995 #if defined(MBEDTLS_X509_CRL_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) 996 #error "MBEDTLS_X509_CRL_PARSE_C defined, but not all prerequisites" 997 #endif 998 999 #if defined(MBEDTLS_X509_CSR_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) ) 1000 #error "MBEDTLS_X509_CSR_PARSE_C defined, but not all prerequisites" 1001 #endif 1002 1003 #if defined(MBEDTLS_X509_CRT_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) ) 1004 #error "MBEDTLS_X509_CRT_WRITE_C defined, but not all prerequisites" 1005 #endif 1006 1007 #if defined(MBEDTLS_X509_CSR_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) ) 1008 #error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites" 1009 #endif 1010 1011 #if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK) && \ 1012 ( !defined(MBEDTLS_X509_CRT_PARSE_C) ) 1013 #error "MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK defined, but not all prerequisites" 1014 #endif 1015 1016 #if defined(MBEDTLS_HAVE_INT32) && defined(MBEDTLS_HAVE_INT64) 1017 #error "MBEDTLS_HAVE_INT32 and MBEDTLS_HAVE_INT64 cannot be defined simultaneously" 1018 #endif /* MBEDTLS_HAVE_INT32 && MBEDTLS_HAVE_INT64 */ 1019 1020 #if ( defined(MBEDTLS_HAVE_INT32) || defined(MBEDTLS_HAVE_INT64) ) && \ 1021 defined(MBEDTLS_HAVE_ASM) 1022 #error "MBEDTLS_HAVE_INT32/MBEDTLS_HAVE_INT64 and MBEDTLS_HAVE_ASM cannot be defined simultaneously" 1023 #endif /* (MBEDTLS_HAVE_INT32 || MBEDTLS_HAVE_INT64) && MBEDTLS_HAVE_ASM */ 1024 1025 #if defined(MBEDTLS_SSL_DTLS_SRTP) && ( !defined(MBEDTLS_SSL_PROTO_DTLS) ) 1026 #error "MBEDTLS_SSL_DTLS_SRTP defined, but not all prerequisites" 1027 #endif 1028 1029 #if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH) && ( !defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) ) 1030 #error "MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH defined, but not all prerequisites" 1031 #endif 1032 1033 #if defined(MBEDTLS_SSL_RECORD_SIZE_LIMIT) && ( !defined(MBEDTLS_SSL_PROTO_TLS1_3) ) 1034 #error "MBEDTLS_SSL_RECORD_SIZE_LIMIT defined, but not all prerequisites" 1035 #endif 1036 1037 #if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION) && !( defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CCM_C) || defined(MBEDTLS_CHACHAPOLY_C) ) 1038 #error "MBEDTLS_SSL_CONTEXT_SERIALIZATION defined, but not all prerequisites" 1039 #endif 1040 1041 /* Reject attempts to enable options that have been removed and that could 1042 * cause a build to succeed but with features removed. */ 1043 1044 #if defined(MBEDTLS_HAVEGE_C) //no-check-names 1045 #error "MBEDTLS_HAVEGE_C was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/2599" 1046 #endif 1047 1048 #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) //no-check-names 1049 #error "MBEDTLS_SSL_HW_RECORD_ACCEL was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4031" 1050 #endif 1051 1052 #if defined(MBEDTLS_SSL_PROTO_SSL3) //no-check-names 1053 #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" 1054 #endif 1055 1056 #if defined(MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO) //no-check-names 1057 #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" 1058 #endif 1059 1060 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT) //no-check-names 1061 #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" 1062 #endif 1063 1064 #if defined(MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES) //no-check-names 1065 #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." 1066 #endif 1067 1068 #if defined(MBEDTLS_ZLIB_SUPPORT) //no-check-names 1069 #error "MBEDTLS_ZLIB_SUPPORT was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4031" 1070 #endif 1071 1072 #if defined(MBEDTLS_CHECK_PARAMS) //no-check-names 1073 #error "MBEDTLS_CHECK_PARAMS was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4313" 1074 #endif 1075 1076 #if defined(MBEDTLS_SSL_CID_PADDING_GRANULARITY) //no-check-names 1077 #error "MBEDTLS_SSL_CID_PADDING_GRANULARITY was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4335" 1078 #endif 1079 1080 #if defined(MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY) //no-check-names 1081 #error "MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4335" 1082 #endif 1083 1084 #if defined(MBEDTLS_SSL_TRUNCATED_HMAC) //no-check-names 1085 #error "MBEDTLS_SSL_TRUNCATED_HMAC was removed in Mbed TLS 3.0. See https://github.com/Mbed-TLS/mbedtls/issues/4341" 1086 #endif 1087 1088 #if defined(MBEDTLS_PKCS7_C) && ( ( !defined(MBEDTLS_ASN1_PARSE_C) ) || \ 1089 ( !defined(MBEDTLS_OID_C) ) || ( !defined(MBEDTLS_PK_PARSE_C) ) || \ 1090 ( !defined(MBEDTLS_X509_CRT_PARSE_C) ) ||\ 1091 ( !defined(MBEDTLS_X509_CRL_PARSE_C) ) || ( !defined(MBEDTLS_BIGNUM_C) ) || \ 1092 ( !defined(MBEDTLS_MD_C) ) ) 1093 #error "MBEDTLS_PKCS7_C is defined, but not all prerequisites" 1094 #endif 1095 1096 /* Undefine helper symbols */ 1097 #undef MBEDTLS_PK_HAVE_ECDSA 1098 #undef MBEDTLS_PK_HAVE_JPAKE 1099 1100 /* 1101 * Avoid warning from -pedantic. This is a convenient place for this 1102 * workaround since this is included by every single file before the 1103 * #if defined(MBEDTLS_xxx_C) that results in empty translation units. 1104 */ 1105 typedef int mbedtls_iso_c_forbids_empty_translation_units; 1106 1107 /* *INDENT-ON* */ 1108 #endif /* MBEDTLS_CHECK_CONFIG_H */ 1109