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