check_config.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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. * It is recommended to include this file from your config.h
  27. * in order to catch dependency issues early.
  28. */
  29. #ifndef MBEDTLS_CHECK_CONFIG_H
  30. #define MBEDTLS_CHECK_CONFIG_H
  31. /*
  32. * We assume CHAR_BIT is 8 in many places. In practice, this is true on our
  33. * target platforms, so not an issue, but let's just be extra sure.
  34. */
  35. #include <limits.h>
  36. #if CHAR_BIT != 8
  37. #error "mbed TLS requires a platform with 8-bit chars"
  38. #endif
  39. #if defined(_WIN32)
  40. #if !defined(MBEDTLS_PLATFORM_C)
  41. #error "MBEDTLS_PLATFORM_C is required on Windows"
  42. #endif
  43. /* Fix the config here. Not convenient to put an #ifdef _WIN32 in config.h as
  44. * it would confuse config.pl. */
  45. #if !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && \
  46. !defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO)
  47. #define MBEDTLS_PLATFORM_SNPRINTF_ALT
  48. #endif
  49. #endif /* _WIN32 */
  50. #if defined(TARGET_LIKE_MBED) && \
  51. ( defined(MBEDTLS_NET_C) || defined(MBEDTLS_TIMING_C) )
  52. #error "The NET and TIMING modules are not available for mbed OS - please use the network and timing functions provided by mbed OS"
  53. #endif
  54. #if defined(MBEDTLS_DEPRECATED_WARNING) && \
  55. !defined(__GNUC__) && !defined(__clang__)
  56. #error "MBEDTLS_DEPRECATED_WARNING only works with GCC and Clang"
  57. #endif
  58. #if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_HAVE_TIME)
  59. #error "MBEDTLS_HAVE_TIME_DATE without MBEDTLS_HAVE_TIME does not make sense"
  60. #endif
  61. #if defined(MBEDTLS_AESNI_C) && !defined(MBEDTLS_HAVE_ASM)
  62. #error "MBEDTLS_AESNI_C defined, but not all prerequisites"
  63. #endif
  64. #if defined(MBEDTLS_CTR_DRBG_C) && !defined(MBEDTLS_AES_C)
  65. #error "MBEDTLS_CTR_DRBG_C defined, but not all prerequisites"
  66. #endif
  67. #if defined(MBEDTLS_DHM_C) && !defined(MBEDTLS_BIGNUM_C)
  68. #error "MBEDTLS_DHM_C defined, but not all prerequisites"
  69. #endif
  70. #if defined(MBEDTLS_CMAC_C) && \
  71. !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_DES_C)
  72. #error "MBEDTLS_CMAC_C defined, but not all prerequisites"
  73. #endif
  74. #if defined(MBEDTLS_ECDH_C) && !defined(MBEDTLS_ECP_C)
  75. #error "MBEDTLS_ECDH_C defined, but not all prerequisites"
  76. #endif
  77. #if defined(MBEDTLS_ECDSA_C) && \
  78. ( !defined(MBEDTLS_ECP_C) || \
  79. !defined(MBEDTLS_ASN1_PARSE_C) || \
  80. !defined(MBEDTLS_ASN1_WRITE_C) )
  81. #error "MBEDTLS_ECDSA_C defined, but not all prerequisites"
  82. #endif
  83. #if defined(MBEDTLS_ECJPAKE_C) && \
  84. ( !defined(MBEDTLS_ECP_C) || !defined(MBEDTLS_MD_C) )
  85. #error "MBEDTLS_ECJPAKE_C defined, but not all prerequisites"
  86. #endif
  87. #if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C)
  88. #error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites"
  89. #endif
  90. #if defined(MBEDTLS_ECP_C) && ( !defined(MBEDTLS_BIGNUM_C) || ( \
  91. !defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) && \
  92. !defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) && \
  93. !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && \
  94. !defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) && \
  95. !defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) && \
  96. !defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) && \
  97. !defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) && \
  98. !defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) && \
  99. !defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) && \
  100. !defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) && \
  101. !defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) ) )
  102. #error "MBEDTLS_ECP_C defined, but not all prerequisites"
  103. #endif
  104. #if defined(MBEDTLS_ENTROPY_C) && (!defined(MBEDTLS_SHA512_C) && \
  105. !defined(MBEDTLS_SHA256_C))
  106. #error "MBEDTLS_ENTROPY_C defined, but not all prerequisites"
  107. #endif
  108. #if defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_SHA512_C) && \
  109. defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 64)
  110. #error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high"
  111. #endif
  112. #if defined(MBEDTLS_ENTROPY_C) && \
  113. ( !defined(MBEDTLS_SHA512_C) || defined(MBEDTLS_ENTROPY_FORCE_SHA256) ) \
  114. && defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) && (MBEDTLS_CTR_DRBG_ENTROPY_LEN > 32)
  115. #error "MBEDTLS_CTR_DRBG_ENTROPY_LEN value too high"
  116. #endif
  117. #if defined(MBEDTLS_ENTROPY_C) && \
  118. defined(MBEDTLS_ENTROPY_FORCE_SHA256) && !defined(MBEDTLS_SHA256_C)
  119. #error "MBEDTLS_ENTROPY_FORCE_SHA256 defined, but not all prerequisites"
  120. #endif
  121. #if defined(MBEDTLS_TEST_NULL_ENTROPY) && \
  122. ( !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) )
  123. #error "MBEDTLS_TEST_NULL_ENTROPY defined, but not all prerequisites"
  124. #endif
  125. #if defined(MBEDTLS_TEST_NULL_ENTROPY) && \
  126. ( defined(MBEDTLS_ENTROPY_NV_SEED) || defined(MBEDTLS_ENTROPY_HARDWARE_ALT) || \
  127. defined(MBEDTLS_HAVEGE_C) )
  128. #error "MBEDTLS_TEST_NULL_ENTROPY defined, but entropy sources too"
  129. #endif
  130. #if defined(MBEDTLS_GCM_C) && ( \
  131. !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_CAMELLIA_C) )
  132. #error "MBEDTLS_GCM_C defined, but not all prerequisites"
  133. #endif
  134. #if defined(MBEDTLS_HAVEGE_C) && !defined(MBEDTLS_TIMING_C)
  135. #error "MBEDTLS_HAVEGE_C defined, but not all prerequisites"
  136. #endif
  137. #if defined(MBEDTLS_HMAC_DRBG_C) && !defined(MBEDTLS_MD_C)
  138. #error "MBEDTLS_HMAC_DRBG_C defined, but not all prerequisites"
  139. #endif
  140. #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) && \
  141. ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) )
  142. #error "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED defined, but not all prerequisites"
  143. #endif
  144. #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \
  145. ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) )
  146. #error "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED defined, but not all prerequisites"
  147. #endif
  148. #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) && !defined(MBEDTLS_DHM_C)
  149. #error "MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED defined, but not all prerequisites"
  150. #endif
  151. #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) && \
  152. !defined(MBEDTLS_ECDH_C)
  153. #error "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED defined, but not all prerequisites"
  154. #endif
  155. #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \
  156. ( !defined(MBEDTLS_DHM_C) || !defined(MBEDTLS_RSA_C) || \
  157. !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) )
  158. #error "MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED defined, but not all prerequisites"
  159. #endif
  160. #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
  161. ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_RSA_C) || \
  162. !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PKCS1_V15) )
  163. #error "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED defined, but not all prerequisites"
  164. #endif
  165. #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \
  166. ( !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_ECDSA_C) || \
  167. !defined(MBEDTLS_X509_CRT_PARSE_C) )
  168. #error "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED defined, but not all prerequisites"
  169. #endif
  170. #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) && \
  171. ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \
  172. !defined(MBEDTLS_PKCS1_V15) )
  173. #error "MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED defined, but not all prerequisites"
  174. #endif
  175. #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \
  176. ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \
  177. !defined(MBEDTLS_PKCS1_V15) )
  178. #error "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED defined, but not all prerequisites"
  179. #endif
  180. #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \
  181. ( !defined(MBEDTLS_ECJPAKE_C) || !defined(MBEDTLS_SHA256_C) || \
  182. !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) )
  183. #error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites"
  184. #endif
  185. #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \
  186. ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) )
  187. #error "MBEDTLS_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites"
  188. #endif
  189. #if defined(MBEDTLS_PADLOCK_C) && !defined(MBEDTLS_HAVE_ASM)
  190. #error "MBEDTLS_PADLOCK_C defined, but not all prerequisites"
  191. #endif
  192. #if defined(MBEDTLS_PEM_PARSE_C) && !defined(MBEDTLS_BASE64_C)
  193. #error "MBEDTLS_PEM_PARSE_C defined, but not all prerequisites"
  194. #endif
  195. #if defined(MBEDTLS_PEM_WRITE_C) && !defined(MBEDTLS_BASE64_C)
  196. #error "MBEDTLS_PEM_WRITE_C defined, but not all prerequisites"
  197. #endif
  198. #if defined(MBEDTLS_PK_C) && \
  199. ( !defined(MBEDTLS_RSA_C) && !defined(MBEDTLS_ECP_C) )
  200. #error "MBEDTLS_PK_C defined, but not all prerequisites"
  201. #endif
  202. #if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_PK_C)
  203. #error "MBEDTLS_PK_PARSE_C defined, but not all prerequisites"
  204. #endif
  205. #if defined(MBEDTLS_PK_WRITE_C) && !defined(MBEDTLS_PK_C)
  206. #error "MBEDTLS_PK_WRITE_C defined, but not all prerequisites"
  207. #endif
  208. #if defined(MBEDTLS_PKCS11_C) && !defined(MBEDTLS_PK_C)
  209. #error "MBEDTLS_PKCS11_C defined, but not all prerequisites"
  210. #endif
  211. #if defined(MBEDTLS_PLATFORM_EXIT_ALT) && !defined(MBEDTLS_PLATFORM_C)
  212. #error "MBEDTLS_PLATFORM_EXIT_ALT defined, but not all prerequisites"
  213. #endif
  214. #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) && !defined(MBEDTLS_PLATFORM_C)
  215. #error "MBEDTLS_PLATFORM_EXIT_MACRO defined, but not all prerequisites"
  216. #endif
  217. #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) &&\
  218. ( defined(MBEDTLS_PLATFORM_STD_EXIT) ||\
  219. defined(MBEDTLS_PLATFORM_EXIT_ALT) )
  220. #error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously"
  221. #endif
  222. #if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\
  223. ( !defined(MBEDTLS_PLATFORM_C) ||\
  224. !defined(MBEDTLS_HAVE_TIME) )
  225. #error "MBEDTLS_PLATFORM_TIME_ALT defined, but not all prerequisites"
  226. #endif
  227. #if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\
  228. ( !defined(MBEDTLS_PLATFORM_C) ||\
  229. !defined(MBEDTLS_HAVE_TIME) )
  230. #error "MBEDTLS_PLATFORM_TIME_MACRO defined, but not all prerequisites"
  231. #endif
  232. #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\
  233. ( !defined(MBEDTLS_PLATFORM_C) ||\
  234. !defined(MBEDTLS_HAVE_TIME) )
  235. #error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO defined, but not all prerequisites"
  236. #endif
  237. #if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\
  238. ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\
  239. defined(MBEDTLS_PLATFORM_TIME_ALT) )
  240. #error "MBEDTLS_PLATFORM_TIME_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously"
  241. #endif
  242. #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\
  243. ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\
  244. defined(MBEDTLS_PLATFORM_TIME_ALT) )
  245. #error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously"
  246. #endif
  247. #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C)
  248. #error "MBEDTLS_PLATFORM_FPRINTF_ALT defined, but not all prerequisites"
  249. #endif
  250. #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C)
  251. #error "MBEDTLS_PLATFORM_FPRINTF_MACRO defined, but not all prerequisites"
  252. #endif
  253. #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) &&\
  254. ( defined(MBEDTLS_PLATFORM_STD_FPRINTF) ||\
  255. defined(MBEDTLS_PLATFORM_FPRINTF_ALT) )
  256. #error "MBEDTLS_PLATFORM_FPRINTF_MACRO and MBEDTLS_PLATFORM_STD_FPRINTF/MBEDTLS_PLATFORM_FPRINTF_ALT cannot be defined simultaneously"
  257. #endif
  258. #if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\
  259. ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) )
  260. #error "MBEDTLS_PLATFORM_FREE_MACRO defined, but not all prerequisites"
  261. #endif
  262. #if defined(MBEDTLS_PLATFORM_FREE_MACRO) &&\
  263. defined(MBEDTLS_PLATFORM_STD_FREE)
  264. #error "MBEDTLS_PLATFORM_FREE_MACRO and MBEDTLS_PLATFORM_STD_FREE cannot be defined simultaneously"
  265. #endif
  266. #if defined(MBEDTLS_PLATFORM_FREE_MACRO) && !defined(MBEDTLS_PLATFORM_CALLOC_MACRO)
  267. #error "MBEDTLS_PLATFORM_CALLOC_MACRO must be defined if MBEDTLS_PLATFORM_FREE_MACRO is"
  268. #endif
  269. #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\
  270. ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) )
  271. #error "MBEDTLS_PLATFORM_CALLOC_MACRO defined, but not all prerequisites"
  272. #endif
  273. #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&\
  274. defined(MBEDTLS_PLATFORM_STD_CALLOC)
  275. #error "MBEDTLS_PLATFORM_CALLOC_MACRO and MBEDTLS_PLATFORM_STD_CALLOC cannot be defined simultaneously"
  276. #endif
  277. #if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) && !defined(MBEDTLS_PLATFORM_FREE_MACRO)
  278. #error "MBEDTLS_PLATFORM_FREE_MACRO must be defined if MBEDTLS_PLATFORM_CALLOC_MACRO is"
  279. #endif
  280. #if defined(MBEDTLS_PLATFORM_MEMORY) && !defined(MBEDTLS_PLATFORM_C)
  281. #error "MBEDTLS_PLATFORM_MEMORY defined, but not all prerequisites"
  282. #endif
  283. #if defined(MBEDTLS_PLATFORM_PRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C)
  284. #error "MBEDTLS_PLATFORM_PRINTF_ALT defined, but not all prerequisites"
  285. #endif
  286. #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C)
  287. #error "MBEDTLS_PLATFORM_PRINTF_MACRO defined, but not all prerequisites"
  288. #endif
  289. #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) &&\
  290. ( defined(MBEDTLS_PLATFORM_STD_PRINTF) ||\
  291. defined(MBEDTLS_PLATFORM_PRINTF_ALT) )
  292. #error "MBEDTLS_PLATFORM_PRINTF_MACRO and MBEDTLS_PLATFORM_STD_PRINTF/MBEDTLS_PLATFORM_PRINTF_ALT cannot be defined simultaneously"
  293. #endif
  294. #if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C)
  295. #error "MBEDTLS_PLATFORM_SNPRINTF_ALT defined, but not all prerequisites"
  296. #endif
  297. #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) && !defined(MBEDTLS_PLATFORM_C)
  298. #error "MBEDTLS_PLATFORM_SNPRINTF_MACRO defined, but not all prerequisites"
  299. #endif
  300. #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) &&\
  301. ( defined(MBEDTLS_PLATFORM_STD_SNPRINTF) ||\
  302. defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) )
  303. #error "MBEDTLS_PLATFORM_SNPRINTF_MACRO and MBEDTLS_PLATFORM_STD_SNPRINTF/MBEDTLS_PLATFORM_SNPRINTF_ALT cannot be defined simultaneously"
  304. #endif
  305. #if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) &&\
  306. !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS)
  307. #error "MBEDTLS_PLATFORM_STD_MEM_HDR defined, but not all prerequisites"
  308. #endif
  309. #if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY)
  310. #error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites"
  311. #endif
  312. #if defined(MBEDTLS_PLATFORM_STD_CALLOC) && !defined(MBEDTLS_PLATFORM_MEMORY)
  313. #error "MBEDTLS_PLATFORM_STD_CALLOC defined, but not all prerequisites"
  314. #endif
  315. #if defined(MBEDTLS_PLATFORM_STD_FREE) && !defined(MBEDTLS_PLATFORM_MEMORY)
  316. #error "MBEDTLS_PLATFORM_STD_FREE defined, but not all prerequisites"
  317. #endif
  318. #if defined(MBEDTLS_PLATFORM_STD_EXIT) &&\
  319. !defined(MBEDTLS_PLATFORM_EXIT_ALT)
  320. #error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites"
  321. #endif
  322. #if defined(MBEDTLS_PLATFORM_STD_TIME) &&\
  323. ( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\
  324. !defined(MBEDTLS_HAVE_TIME) )
  325. #error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites"
  326. #endif
  327. #if defined(MBEDTLS_PLATFORM_STD_FPRINTF) &&\
  328. !defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
  329. #error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites"
  330. #endif
  331. #if defined(MBEDTLS_PLATFORM_STD_PRINTF) &&\
  332. !defined(MBEDTLS_PLATFORM_PRINTF_ALT)
  333. #error "MBEDTLS_PLATFORM_STD_PRINTF defined, but not all prerequisites"
  334. #endif
  335. #if defined(MBEDTLS_PLATFORM_STD_SNPRINTF) &&\
  336. !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT)
  337. #error "MBEDTLS_PLATFORM_STD_SNPRINTF defined, but not all prerequisites"
  338. #endif
  339. #if defined(MBEDTLS_ENTROPY_NV_SEED) &&\
  340. ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_ENTROPY_C) )
  341. #error "MBEDTLS_ENTROPY_NV_SEED defined, but not all prerequisites"
  342. #endif
  343. #if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) &&\
  344. !defined(MBEDTLS_ENTROPY_NV_SEED)
  345. #error "MBEDTLS_PLATFORM_NV_SEED_ALT defined, but not all prerequisites"
  346. #endif
  347. #if defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) &&\
  348. !defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
  349. #error "MBEDTLS_PLATFORM_STD_NV_SEED_READ defined, but not all prerequisites"
  350. #endif
  351. #if defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) &&\
  352. !defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
  353. #error "MBEDTLS_PLATFORM_STD_NV_SEED_WRITE defined, but not all prerequisites"
  354. #endif
  355. #if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) &&\
  356. ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) ||\
  357. defined(MBEDTLS_PLATFORM_NV_SEED_ALT) )
  358. #error "MBEDTLS_PLATFORM_NV_SEED_READ_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_READ cannot be defined simultaneously"
  359. #endif
  360. #if defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) &&\
  361. ( defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) ||\
  362. defined(MBEDTLS_PLATFORM_NV_SEED_ALT) )
  363. #error "MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_WRITE cannot be defined simultaneously"
  364. #endif
  365. #if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_BIGNUM_C) || \
  366. !defined(MBEDTLS_OID_C) )
  367. #error "MBEDTLS_RSA_C defined, but not all prerequisites"
  368. #endif
  369. #if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_PKCS1_V21) && \
  370. !defined(MBEDTLS_PKCS1_V15) )
  371. #error "MBEDTLS_RSA_C defined, but none of the PKCS1 versions enabled"
  372. #endif
  373. #if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) && \
  374. ( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_PKCS1_V21) )
  375. #error "MBEDTLS_X509_RSASSA_PSS_SUPPORT defined, but not all prerequisites"
  376. #endif
  377. #if defined(MBEDTLS_SSL_PROTO_SSL3) && ( !defined(MBEDTLS_MD5_C) || \
  378. !defined(MBEDTLS_SHA1_C) )
  379. #error "MBEDTLS_SSL_PROTO_SSL3 defined, but not all prerequisites"
  380. #endif
  381. #if defined(MBEDTLS_SSL_PROTO_TLS1) && ( !defined(MBEDTLS_MD5_C) || \
  382. !defined(MBEDTLS_SHA1_C) )
  383. #error "MBEDTLS_SSL_PROTO_TLS1 defined, but not all prerequisites"
  384. #endif
  385. #if defined(MBEDTLS_SSL_PROTO_TLS1_1) && ( !defined(MBEDTLS_MD5_C) || \
  386. !defined(MBEDTLS_SHA1_C) )
  387. #error "MBEDTLS_SSL_PROTO_TLS1_1 defined, but not all prerequisites"
  388. #endif
  389. #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && ( !defined(MBEDTLS_SHA1_C) && \
  390. !defined(MBEDTLS_SHA256_C) && !defined(MBEDTLS_SHA512_C) )
  391. #error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites"
  392. #endif
  393. #if defined(MBEDTLS_SSL_PROTO_DTLS) && \
  394. !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \
  395. !defined(MBEDTLS_SSL_PROTO_TLS1_2)
  396. #error "MBEDTLS_SSL_PROTO_DTLS defined, but not all prerequisites"
  397. #endif
  398. #if defined(MBEDTLS_SSL_CLI_C) && !defined(MBEDTLS_SSL_TLS_C)
  399. #error "MBEDTLS_SSL_CLI_C defined, but not all prerequisites"
  400. #endif
  401. #if defined(MBEDTLS_SSL_TLS_C) && ( !defined(MBEDTLS_CIPHER_C) || \
  402. !defined(MBEDTLS_MD_C) )
  403. #error "MBEDTLS_SSL_TLS_C defined, but not all prerequisites"
  404. #endif
  405. #if defined(MBEDTLS_SSL_SRV_C) && !defined(MBEDTLS_SSL_TLS_C)
  406. #error "MBEDTLS_SSL_SRV_C defined, but not all prerequisites"
  407. #endif
  408. #if defined(MBEDTLS_SSL_TLS_C) && (!defined(MBEDTLS_SSL_PROTO_SSL3) && \
  409. !defined(MBEDTLS_SSL_PROTO_TLS1) && !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \
  410. !defined(MBEDTLS_SSL_PROTO_TLS1_2))
  411. #error "MBEDTLS_SSL_TLS_C defined, but no protocols are active"
  412. #endif
  413. #if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_SSL3) && \
  414. defined(MBEDTLS_SSL_PROTO_TLS1_1) && !defined(MBEDTLS_SSL_PROTO_TLS1))
  415. #error "Illegal protocol selection"
  416. #endif
  417. #if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_TLS1) && \
  418. defined(MBEDTLS_SSL_PROTO_TLS1_2) && !defined(MBEDTLS_SSL_PROTO_TLS1_1))
  419. #error "Illegal protocol selection"
  420. #endif
  421. #if defined(MBEDTLS_SSL_TLS_C) && (defined(MBEDTLS_SSL_PROTO_SSL3) && \
  422. defined(MBEDTLS_SSL_PROTO_TLS1_2) && (!defined(MBEDTLS_SSL_PROTO_TLS1) || \
  423. !defined(MBEDTLS_SSL_PROTO_TLS1_1)))
  424. #error "Illegal protocol selection"
  425. #endif
  426. #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && !defined(MBEDTLS_SSL_PROTO_DTLS)
  427. #error "MBEDTLS_SSL_DTLS_HELLO_VERIFY defined, but not all prerequisites"
  428. #endif
  429. #if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && \
  430. !defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY)
  431. #error "MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE defined, but not all prerequisites"
  432. #endif
  433. #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) && \
  434. ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) )
  435. #error "MBEDTLS_SSL_DTLS_ANTI_REPLAY defined, but not all prerequisites"
  436. #endif
  437. #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) && \
  438. ( !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) )
  439. #error "MBEDTLS_SSL_DTLS_BADMAC_LIMIT defined, but not all prerequisites"
  440. #endif
  441. #if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) && \
  442. !defined(MBEDTLS_SSL_PROTO_TLS1) && \
  443. !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \
  444. !defined(MBEDTLS_SSL_PROTO_TLS1_2)
  445. #error "MBEDTLS_SSL_ENCRYPT_THEN_MAC defined, but not all prerequsites"
  446. #endif
  447. #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) && \
  448. !defined(MBEDTLS_SSL_PROTO_TLS1) && \
  449. !defined(MBEDTLS_SSL_PROTO_TLS1_1) && \
  450. !defined(MBEDTLS_SSL_PROTO_TLS1_2)
  451. #error "MBEDTLS_SSL_EXTENDED_MASTER_SECRET defined, but not all prerequsites"
  452. #endif
  453. #if defined(MBEDTLS_SSL_TICKET_C) && !defined(MBEDTLS_CIPHER_C)
  454. #error "MBEDTLS_SSL_TICKET_C defined, but not all prerequisites"
  455. #endif
  456. #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) && \
  457. !defined(MBEDTLS_SSL_PROTO_SSL3) && !defined(MBEDTLS_SSL_PROTO_TLS1)
  458. #error "MBEDTLS_SSL_CBC_RECORD_SPLITTING defined, but not all prerequisites"
  459. #endif
  460. #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) && \
  461. !defined(MBEDTLS_X509_CRT_PARSE_C)
  462. #error "MBEDTLS_SSL_SERVER_NAME_INDICATION defined, but not all prerequisites"
  463. #endif
  464. #if defined(MBEDTLS_THREADING_PTHREAD)
  465. #if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL)
  466. #error "MBEDTLS_THREADING_PTHREAD defined, but not all prerequisites"
  467. #endif
  468. #define MBEDTLS_THREADING_IMPL
  469. #endif
  470. #if defined(MBEDTLS_THREADING_ALT)
  471. #if !defined(MBEDTLS_THREADING_C) || defined(MBEDTLS_THREADING_IMPL)
  472. #error "MBEDTLS_THREADING_ALT defined, but not all prerequisites"
  473. #endif
  474. #define MBEDTLS_THREADING_IMPL
  475. #endif
  476. #if defined(MBEDTLS_THREADING_C) && !defined(MBEDTLS_THREADING_IMPL)
  477. #error "MBEDTLS_THREADING_C defined, single threading implementation required"
  478. #endif
  479. #undef MBEDTLS_THREADING_IMPL
  480. #if defined(MBEDTLS_VERSION_FEATURES) && !defined(MBEDTLS_VERSION_C)
  481. #error "MBEDTLS_VERSION_FEATURES defined, but not all prerequisites"
  482. #endif
  483. #if defined(MBEDTLS_X509_USE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \
  484. !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_PARSE_C) || \
  485. !defined(MBEDTLS_PK_PARSE_C) )
  486. #error "MBEDTLS_X509_USE_C defined, but not all prerequisites"
  487. #endif
  488. #if defined(MBEDTLS_X509_CREATE_C) && ( !defined(MBEDTLS_BIGNUM_C) || \
  489. !defined(MBEDTLS_OID_C) || !defined(MBEDTLS_ASN1_WRITE_C) || \
  490. !defined(MBEDTLS_PK_WRITE_C) )
  491. #error "MBEDTLS_X509_CREATE_C defined, but not all prerequisites"
  492. #endif
  493. #if defined(MBEDTLS_X509_CRT_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
  494. #error "MBEDTLS_X509_CRT_PARSE_C defined, but not all prerequisites"
  495. #endif
  496. #if defined(MBEDTLS_X509_CRL_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
  497. #error "MBEDTLS_X509_CRL_PARSE_C defined, but not all prerequisites"
  498. #endif
  499. #if defined(MBEDTLS_X509_CSR_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
  500. #error "MBEDTLS_X509_CSR_PARSE_C defined, but not all prerequisites"
  501. #endif
  502. #if defined(MBEDTLS_X509_CRT_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) )
  503. #error "MBEDTLS_X509_CRT_WRITE_C defined, but not all prerequisites"
  504. #endif
  505. #if defined(MBEDTLS_X509_CSR_WRITE_C) && ( !defined(MBEDTLS_X509_CREATE_C) )
  506. #error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites"
  507. #endif
  508. /*
  509. * Avoid warning from -pedantic. This is a convenient place for this
  510. * workaround since this is included by every single file before the
  511. * #if defined(MBEDTLS_xxx_C) that results in emtpy translation units.
  512. */
  513. typedef int mbedtls_iso_c_forbids_empty_translation_units;
  514. #endif /* MBEDTLS_CHECK_CONFIG_H */