config-tls-generic.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. /*
  2. * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
  3. * Copyright (c) 2017 Intel Corporation.
  4. * Copyright (c) 2018 Nordic Semiconductor ASA
  5. *
  6. * SPDX-License-Identifier: Apache-2.0
  7. *
  8. * Generic configuration for TLS, manageable by Kconfig.
  9. */
  10. #ifndef MBEDTLS_CONFIG_H
  11. #define MBEDTLS_CONFIG_H
  12. /* System support */
  13. #define MBEDTLS_PLATFORM_C
  14. #define MBEDTLS_PLATFORM_MEMORY
  15. #define MBEDTLS_MEMORY_BUFFER_ALLOC_C
  16. #define MBEDTLS_PLATFORM_EXIT_ALT
  17. #define MBEDTLS_NO_PLATFORM_ENTROPY
  18. #define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
  19. #if defined(CONFIG_MBEDTLS_HAVE_ASM)
  20. #define MBEDTLS_HAVE_ASM
  21. #endif
  22. #if defined(CONFIG_MBEDTLS_HAVE_TIME_DATE)
  23. #define MBEDTLS_HAVE_TIME
  24. #define MBEDTLS_HAVE_TIME_DATE
  25. #endif
  26. #if defined(CONFIG_MBEDTLS_TEST)
  27. #define MBEDTLS_SELF_TEST
  28. #define MBEDTLS_DEBUG_C
  29. #endif
  30. /* mbedTLS feature support */
  31. /* Supported TLS versions */
  32. #if defined(CONFIG_MBEDTLS_TLS_VERSION_1_0)
  33. #define MBEDTLS_SSL_PROTO_TLS1
  34. #endif
  35. #if defined(CONFIG_MBEDTLS_TLS_VERSION_1_1)
  36. #define MBEDTLS_SSL_PROTO_TLS1_1
  37. #endif
  38. #if defined(CONFIG_MBEDTLS_TLS_VERSION_1_2)
  39. #define MBEDTLS_SSL_PROTO_TLS1_2
  40. #endif
  41. #if defined(CONFIG_MBEDTLS_TLS_VERSION_1_0) || \
  42. defined(CONFIG_MBEDTLS_TLS_VERSION_1_1) || \
  43. defined(CONFIG_MBEDTLS_TLS_VERSION_1_2)
  44. /* Modules required for TLS */
  45. #define MBEDTLS_SSL_TLS_C
  46. #define MBEDTLS_SSL_SRV_C
  47. #define MBEDTLS_SSL_CLI_C
  48. #define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
  49. #endif
  50. #if defined(CONFIG_MBEDTLS_DTLS)
  51. #define MBEDTLS_SSL_PROTO_DTLS
  52. #define MBEDTLS_SSL_DTLS_ANTI_REPLAY
  53. #define MBEDTLS_SSL_DTLS_HELLO_VERIFY
  54. #define MBEDTLS_SSL_COOKIE_C
  55. #endif
  56. /* Supported key exchange methods */
  57. #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
  58. #define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
  59. #endif
  60. #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
  61. #define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
  62. #endif
  63. #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
  64. #define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
  65. #endif
  66. #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)
  67. #define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
  68. #endif
  69. #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_ENABLED)
  70. #define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
  71. #endif
  72. #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)
  73. #define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
  74. #endif
  75. #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED)
  76. #define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
  77. #endif
  78. #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
  79. #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
  80. #endif
  81. #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
  82. #define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
  83. #endif
  84. #if defined(CONFIG_MBEDTLS_ECDSA_DETERMINISTIC)
  85. #define MBEDTLS_ECDSA_DETERMINISTIC
  86. #endif
  87. #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED)
  88. #define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
  89. #endif
  90. #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
  91. #define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
  92. #endif
  93. /* Supported cipher modes */
  94. #if defined(CONFIG_MBEDTLS_CIPHER_AES_ENABLED)
  95. #ifndef CONFIG_AEM_WATCH_SUPPORT
  96. #define MBEDTLS_AES_C
  97. #endif
  98. #endif
  99. #if defined(CONFIG_MBEDTLS_AES_ROM_TABLES)
  100. #ifndef CONFIG_AEM_WATCH_SUPPORT
  101. #define MBEDTLS_AES_ROM_TABLES
  102. #endif
  103. #endif
  104. #if defined(CONFIG_MBEDTLS_CIPHER_CAMELLIA_ENABLED)
  105. #define MBEDTLS_CAMELLIA_C
  106. #endif
  107. #if defined(CONFIG_MBEDTLS_CIPHER_DES_ENABLED)
  108. #define MBEDTLS_DES_C
  109. #endif
  110. #if defined(CONFIG_MBEDTLS_CIPHER_ARC4_ENABLED)
  111. #define MBEDTLS_ARC4_C
  112. #endif
  113. #if defined(CONFIG_MBEDTLS_CIPHER_CHACHA20_ENABLED)
  114. #define MBEDTLS_CHACHA20_C
  115. #endif
  116. #if defined(CONFIG_MBEDTLS_CIPHER_BLOWFISH_ENABLED)
  117. #define MBEDTLS_BLOWFISH_C
  118. #endif
  119. #if defined(CONFIG_MBEDTLS_CIPHER_CCM_ENABLED)
  120. #define MBEDTLS_CCM_C
  121. #endif
  122. #if defined(CONFIG_MBEDTLS_CIPHER_GCM_ENABLED)
  123. #define MBEDTLS_GCM_C
  124. #endif
  125. #if defined(CONFIG_MBEDTLS_CIPHER_MODE_XTS_ENABLED)
  126. #define MBEDTLS_CIPHER_MODE_XTS
  127. #endif
  128. #if defined(CONFIG_MBEDTLS_CIPHER_MODE_CBC_ENABLED)
  129. #define MBEDTLS_CIPHER_MODE_CBC
  130. #endif
  131. #if defined(CONFIG_MBEDTLS_CIPHER_MODE_CTR_ENABLED)
  132. #define MBEDTLS_CIPHER_MODE_CTR
  133. #endif
  134. /* Supported elliptic curves */
  135. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED)
  136. #define MBEDTLS_ECP_DP_SECP192R1_ENABLED
  137. #endif
  138. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED)
  139. #define MBEDTLS_ECP_DP_SECP224R1_ENABLED
  140. #endif
  141. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED)
  142. #define MBEDTLS_ECP_DP_SECP256R1_ENABLED
  143. #endif
  144. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED)
  145. #define MBEDTLS_ECP_DP_SECP384R1_ENABLED
  146. #endif
  147. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED)
  148. #define MBEDTLS_ECP_DP_SECP521R1_ENABLED
  149. #endif
  150. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED)
  151. #define MBEDTLS_ECP_DP_SECP192K1_ENABLED
  152. #endif
  153. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED)
  154. #define MBEDTLS_ECP_DP_SECP224K1_ENABLED
  155. #endif
  156. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED)
  157. #define MBEDTLS_ECP_DP_SECP256K1_ENABLED
  158. #endif
  159. #if defined(CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED)
  160. #define MBEDTLS_ECP_DP_BP256R1_ENABLED
  161. #endif
  162. #if defined(CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED)
  163. #define MBEDTLS_ECP_DP_BP384R1_ENABLED
  164. #endif
  165. #if defined(CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED)
  166. #define MBEDTLS_ECP_DP_BP512R1_ENABLED
  167. #endif
  168. #if defined(CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED)
  169. #define MBEDTLS_ECP_DP_CURVE25519_ENABLED
  170. #endif
  171. #if defined(CONFIG_MBEDTLS_ECP_DP_CURVE448_ENABLED)
  172. #define MBEDTLS_ECP_DP_CURVE448_ENABLED
  173. #endif
  174. #if defined(CONFIG_MBEDTLS_ECP_NIST_OPTIM)
  175. #define MBEDTLS_ECP_NIST_OPTIM
  176. #endif
  177. /* Supported message authentication methods */
  178. #if defined(CONFIG_MBEDTLS_MAC_MD4_ENABLED)
  179. #define MBEDTLS_MD4_C
  180. #endif
  181. #if defined(CONFIG_MBEDTLS_MAC_MD5_ENABLED)
  182. #ifndef CONFIG_AEM_WATCH_SUPPORT
  183. #define MBEDTLS_MD5_C
  184. #endif
  185. #endif
  186. #if defined(CONFIG_MBEDTLS_MAC_SHA1_ENABLED)
  187. #define MBEDTLS_SHA1_C
  188. #endif
  189. #if defined(CONFIG_MBEDTLS_MAC_SHA256_ENABLED)
  190. #define MBEDTLS_SHA256_C
  191. #endif
  192. #if defined(CONFIG_MBEDTLS_SHA256_SMALLER)
  193. #define MBEDTLS_SHA256_SMALLER
  194. #endif
  195. #if defined(CONFIG_MBEDTLS_MAC_SHA512_ENABLED)
  196. #define MBEDTLS_SHA512_C
  197. #endif
  198. #if defined(CONFIG_MBEDTLS_MAC_POLY1305_ENABLED)
  199. #define MBEDTLS_POLY1305_C
  200. #endif
  201. #if defined(CONFIG_MBEDTLS_MAC_CMAC_ENABLED)
  202. #define MBEDTLS_CMAC_C
  203. #endif
  204. /* mbedTLS modules */
  205. #if defined(CONFIG_MBEDTLS_CTR_DRBG_ENABLED)
  206. #ifndef CONFIG_AEM_WATCH_SUPPORT
  207. #define MBEDTLS_CTR_DRBG_C
  208. #endif
  209. #endif
  210. #if defined(CONFIG_MBEDTLS_HMAC_DRBG_ENABLED)
  211. #ifndef CONFIG_AEM_WATCH_SUPPORT
  212. #define MBEDTLS_HMAC_DRBG_C
  213. #endif
  214. #endif
  215. #if defined(CONFIG_MBEDTLS_DEBUG)
  216. #define MBEDTLS_ERROR_C
  217. #define MBEDTLS_DEBUG_C
  218. #define MBEDTLS_SSL_DEBUG_ALL
  219. #define MBEDTLS_SSL_ALL_ALERT_MESSAGES
  220. #endif
  221. #if defined(CONFIG_MBEDTLS_MEMORY_DEBUG)
  222. #define MBEDTLS_MEMORY_DEBUG
  223. #endif
  224. #if defined(CONFIG_MBEDTLS_CHACHAPOLY_AEAD_ENABLED)
  225. #define MBEDTLS_CHACHAPOLY_C
  226. #endif
  227. #if defined(CONFIG_MBEDTLS_GENPRIME_ENABLED)
  228. #define MBEDTLS_GENPRIME
  229. #endif
  230. #if defined(CONFIG_MBEDTLS_ENTROPY_ENABLED)
  231. #define MBEDTLS_ENTROPY_C
  232. #endif
  233. #if defined(CONFIG_MBEDTLS_SSL_EXPORT_KEYS)
  234. #define MBEDTLS_SSL_EXPORT_KEYS
  235. #endif
  236. #if defined(CONFIG_MBEDTLS_SSL_ALPN)
  237. #define MBEDTLS_SSL_ALPN
  238. #endif
  239. #if defined(CONFIG_MBEDTLS_CIPHER)
  240. #define MBEDTLS_CIPHER_C
  241. #endif
  242. #if defined(CONFIG_MBEDTLS_MD)
  243. #define MBEDTLS_MD_C
  244. #endif
  245. /* Automatic dependencies */
  246. #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
  247. defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)
  248. #define MBEDTLS_DHM_C
  249. #endif
  250. #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \
  251. defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
  252. defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
  253. defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \
  254. defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED)
  255. #define MBEDTLS_ECDH_C
  256. #endif
  257. #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
  258. defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
  259. defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
  260. defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED)
  261. #define MBEDTLS_RSA_C
  262. #endif
  263. #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
  264. defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
  265. defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
  266. defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED)
  267. #define MBEDTLS_PKCS1_V15
  268. #define MBEDTLS_PKCS1_V21
  269. #endif
  270. #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
  271. defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
  272. defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
  273. defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
  274. defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
  275. defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \
  276. defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED)
  277. #define MBEDTLS_X509_CRT_PARSE_C
  278. #endif
  279. #if defined (CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT) && \
  280. defined(MBEDTLS_X509_CRT_PARSE_C)
  281. #define MBEDTLS_PEM_PARSE_C
  282. #define MBEDTLS_BASE64_C
  283. #endif
  284. #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
  285. #define MBEDTLS_ECDSA_C
  286. #endif
  287. #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
  288. #define MBEDTLS_ECJPAKE_C
  289. #endif
  290. #if defined(MBEDTLS_ECDH_C) || \
  291. defined(MBEDTLS_ECDSA_C) || \
  292. defined(MBEDTLS_ECJPAKE_C)
  293. #define MBEDTLS_ECP_C
  294. #endif
  295. #if defined(MBEDTLS_X509_CRT_PARSE_C)
  296. #define MBEDTLS_X509_USE_C
  297. #endif
  298. #if defined(MBEDTLS_X509_USE_C) || \
  299. defined(MBEDTLS_ECDSA_C)
  300. #define MBEDTLS_ASN1_PARSE_C
  301. #endif
  302. #if defined(MBEDTLS_ECDSA_C)
  303. #define MBEDTLS_ASN1_WRITE_C
  304. #endif
  305. #if defined(MBEDTLS_DHM_C) || \
  306. defined(MBEDTLS_ECP_C) || \
  307. defined(MBEDTLS_RSA_C) || \
  308. defined(MBEDTLS_X509_USE_C) || \
  309. defined(MBEDTLS_GENPRIME)
  310. #define MBEDTLS_BIGNUM_C
  311. #endif
  312. #if defined(MBEDTLS_RSA_C) || \
  313. defined(MBEDTLS_X509_USE_C)
  314. #define MBEDTLS_OID_C
  315. #endif
  316. #if defined(MBEDTLS_X509_USE_C)
  317. #define MBEDTLS_PK_PARSE_C
  318. #endif
  319. #if defined(CONFIG_MBEDTLS_PK_WRITE_C)
  320. #define MBEDTLS_PK_WRITE_C
  321. #endif
  322. #if defined(MBEDTLS_PK_PARSE_C) || defined(MBEDTLS_PK_WRITE_C)
  323. #define MBEDTLS_PK_C
  324. #endif
  325. #define MBEDTLS_SSL_MAX_CONTENT_LEN CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN
  326. /* Enable OpenThread optimizations. */
  327. #if defined(CONFIG_MBEDTLS_OPENTHREAD_OPTIMIZATIONS_ENABLED)
  328. #define MBEDTLS_MPI_WINDOW_SIZE 1 /**< Maximum windows size used. */
  329. #define MBEDTLS_MPI_MAX_SIZE 32 /**< Maximum number of bytes for usable MPIs. */
  330. #define MBEDTLS_ECP_MAX_BITS 256 /**< Maximum bit size of groups */
  331. #define MBEDTLS_ECP_WINDOW_SIZE 2 /**< Maximum window size used */
  332. #define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Enable fixed-point speed-up */
  333. #define MBEDTLS_ENTROPY_MAX_SOURCES 1 /**< Maximum number of sources supported */
  334. #endif
  335. #if defined(CONFIG_MBEDTLS_SERVER_NAME_INDICATION) && \
  336. defined(MBEDTLS_X509_CRT_PARSE_C)
  337. #define MBEDTLS_SSL_SERVER_NAME_INDICATION
  338. #endif
  339. /* User config file */
  340. #if defined(CONFIG_MBEDTLS_USER_CONFIG_FILE)
  341. #include CONFIG_MBEDTLS_USER_CONFIG_FILE
  342. #endif
  343. #include "mbedtls/check_config.h"
  344. #endif /* MBEDTLS_CONFIG_H */