config-tls-generic.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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. #define MBEDTLS_AES_C
  96. #endif
  97. #if defined(CONFIG_MBEDTLS_AES_ROM_TABLES)
  98. #define MBEDTLS_AES_ROM_TABLES
  99. #endif
  100. #if defined(CONFIG_MBEDTLS_CIPHER_CAMELLIA_ENABLED)
  101. #define MBEDTLS_CAMELLIA_C
  102. #endif
  103. #if defined(CONFIG_MBEDTLS_CIPHER_DES_ENABLED)
  104. #define MBEDTLS_DES_C
  105. #endif
  106. #if defined(CONFIG_MBEDTLS_CIPHER_ARC4_ENABLED)
  107. #define MBEDTLS_ARC4_C
  108. #endif
  109. #if defined(CONFIG_MBEDTLS_CIPHER_CHACHA20_ENABLED)
  110. #define MBEDTLS_CHACHA20_C
  111. #endif
  112. #if defined(CONFIG_MBEDTLS_CIPHER_BLOWFISH_ENABLED)
  113. #define MBEDTLS_BLOWFISH_C
  114. #endif
  115. #if defined(CONFIG_MBEDTLS_CIPHER_CCM_ENABLED)
  116. #define MBEDTLS_CCM_C
  117. #endif
  118. #if defined(CONFIG_MBEDTLS_CIPHER_GCM_ENABLED)
  119. #define MBEDTLS_GCM_C
  120. #endif
  121. #if defined(CONFIG_MBEDTLS_CIPHER_MODE_XTS_ENABLED)
  122. #define MBEDTLS_CIPHER_MODE_XTS
  123. #endif
  124. #if defined(CONFIG_MBEDTLS_CIPHER_MODE_CBC_ENABLED)
  125. #define MBEDTLS_CIPHER_MODE_CBC
  126. #endif
  127. #if defined(CONFIG_MBEDTLS_CIPHER_MODE_CTR_ENABLED)
  128. #define MBEDTLS_CIPHER_MODE_CTR
  129. #endif
  130. /* Supported elliptic curves */
  131. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED)
  132. #define MBEDTLS_ECP_DP_SECP192R1_ENABLED
  133. #endif
  134. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED)
  135. #define MBEDTLS_ECP_DP_SECP224R1_ENABLED
  136. #endif
  137. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED)
  138. #define MBEDTLS_ECP_DP_SECP256R1_ENABLED
  139. #endif
  140. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED)
  141. #define MBEDTLS_ECP_DP_SECP384R1_ENABLED
  142. #endif
  143. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED)
  144. #define MBEDTLS_ECP_DP_SECP521R1_ENABLED
  145. #endif
  146. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED)
  147. #define MBEDTLS_ECP_DP_SECP192K1_ENABLED
  148. #endif
  149. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED)
  150. #define MBEDTLS_ECP_DP_SECP224K1_ENABLED
  151. #endif
  152. #if defined(CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED)
  153. #define MBEDTLS_ECP_DP_SECP256K1_ENABLED
  154. #endif
  155. #if defined(CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED)
  156. #define MBEDTLS_ECP_DP_BP256R1_ENABLED
  157. #endif
  158. #if defined(CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED)
  159. #define MBEDTLS_ECP_DP_BP384R1_ENABLED
  160. #endif
  161. #if defined(CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED)
  162. #define MBEDTLS_ECP_DP_BP512R1_ENABLED
  163. #endif
  164. #if defined(CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED)
  165. #define MBEDTLS_ECP_DP_CURVE25519_ENABLED
  166. #endif
  167. #if defined(CONFIG_MBEDTLS_ECP_DP_CURVE448_ENABLED)
  168. #define MBEDTLS_ECP_DP_CURVE448_ENABLED
  169. #endif
  170. #if defined(CONFIG_MBEDTLS_ECP_NIST_OPTIM)
  171. #define MBEDTLS_ECP_NIST_OPTIM
  172. #endif
  173. /* Supported message authentication methods */
  174. #if defined(CONFIG_MBEDTLS_MAC_MD4_ENABLED)
  175. #define MBEDTLS_MD4_C
  176. #endif
  177. #if defined(CONFIG_MBEDTLS_MAC_MD5_ENABLED)
  178. #define MBEDTLS_MD5_C
  179. #endif
  180. #if defined(CONFIG_MBEDTLS_MAC_SHA1_ENABLED)
  181. #define MBEDTLS_SHA1_C
  182. #endif
  183. #if defined(CONFIG_MBEDTLS_MAC_SHA256_ENABLED)
  184. #define MBEDTLS_SHA256_C
  185. #endif
  186. #if defined(CONFIG_MBEDTLS_SHA256_SMALLER)
  187. #define MBEDTLS_SHA256_SMALLER
  188. #endif
  189. #if defined(CONFIG_MBEDTLS_MAC_SHA512_ENABLED)
  190. #define MBEDTLS_SHA512_C
  191. #endif
  192. #if defined(CONFIG_MBEDTLS_MAC_POLY1305_ENABLED)
  193. #define MBEDTLS_POLY1305_C
  194. #endif
  195. #if defined(CONFIG_MBEDTLS_MAC_CMAC_ENABLED)
  196. #define MBEDTLS_CMAC_C
  197. #endif
  198. /* mbedTLS modules */
  199. #if defined(CONFIG_MBEDTLS_CTR_DRBG_ENABLED)
  200. #define MBEDTLS_CTR_DRBG_C
  201. #endif
  202. #if defined(CONFIG_MBEDTLS_HMAC_DRBG_ENABLED)
  203. #define MBEDTLS_HMAC_DRBG_C
  204. #endif
  205. #if defined(CONFIG_MBEDTLS_DEBUG)
  206. #define MBEDTLS_ERROR_C
  207. #define MBEDTLS_DEBUG_C
  208. #define MBEDTLS_SSL_DEBUG_ALL
  209. #define MBEDTLS_SSL_ALL_ALERT_MESSAGES
  210. #endif
  211. #if defined(CONFIG_MBEDTLS_MEMORY_DEBUG)
  212. #define MBEDTLS_MEMORY_DEBUG
  213. #endif
  214. #if defined(CONFIG_MBEDTLS_CHACHAPOLY_AEAD_ENABLED)
  215. #define MBEDTLS_CHACHAPOLY_C
  216. #endif
  217. #if defined(CONFIG_MBEDTLS_GENPRIME_ENABLED)
  218. #define MBEDTLS_GENPRIME
  219. #endif
  220. #if defined(CONFIG_MBEDTLS_ENTROPY_ENABLED)
  221. #define MBEDTLS_ENTROPY_C
  222. #endif
  223. #if defined(CONFIG_MBEDTLS_SSL_EXPORT_KEYS)
  224. #define MBEDTLS_SSL_EXPORT_KEYS
  225. #endif
  226. #if defined(CONFIG_MBEDTLS_SSL_ALPN)
  227. #define MBEDTLS_SSL_ALPN
  228. #endif
  229. #if defined(CONFIG_MBEDTLS_CIPHER)
  230. #define MBEDTLS_CIPHER_C
  231. #endif
  232. #if defined(CONFIG_MBEDTLS_MD)
  233. #define MBEDTLS_MD_C
  234. #endif
  235. /* Automatic dependencies */
  236. #if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
  237. defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)
  238. #define MBEDTLS_DHM_C
  239. #endif
  240. #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \
  241. defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
  242. defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
  243. defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \
  244. defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED)
  245. #define MBEDTLS_ECDH_C
  246. #endif
  247. #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
  248. defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
  249. defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
  250. defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED)
  251. #define MBEDTLS_RSA_C
  252. #endif
  253. #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
  254. defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
  255. defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
  256. defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED)
  257. #define MBEDTLS_PKCS1_V15
  258. #define MBEDTLS_PKCS1_V21
  259. #endif
  260. #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
  261. defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
  262. defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
  263. defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
  264. defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
  265. defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \
  266. defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED)
  267. #define MBEDTLS_X509_CRT_PARSE_C
  268. #endif
  269. #if defined (CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT) && \
  270. defined(MBEDTLS_X509_CRT_PARSE_C)
  271. #define MBEDTLS_PEM_PARSE_C
  272. #define MBEDTLS_BASE64_C
  273. #endif
  274. #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
  275. #define MBEDTLS_ECDSA_C
  276. #endif
  277. #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
  278. #define MBEDTLS_ECJPAKE_C
  279. #endif
  280. #if defined(MBEDTLS_ECDH_C) || \
  281. defined(MBEDTLS_ECDSA_C) || \
  282. defined(MBEDTLS_ECJPAKE_C)
  283. #define MBEDTLS_ECP_C
  284. #endif
  285. #if defined(MBEDTLS_X509_CRT_PARSE_C)
  286. #define MBEDTLS_X509_USE_C
  287. #endif
  288. #if defined(MBEDTLS_X509_USE_C) || \
  289. defined(MBEDTLS_ECDSA_C)
  290. #define MBEDTLS_ASN1_PARSE_C
  291. #endif
  292. #if defined(MBEDTLS_ECDSA_C)
  293. #define MBEDTLS_ASN1_WRITE_C
  294. #endif
  295. #if defined(MBEDTLS_DHM_C) || \
  296. defined(MBEDTLS_ECP_C) || \
  297. defined(MBEDTLS_RSA_C) || \
  298. defined(MBEDTLS_X509_USE_C) || \
  299. defined(MBEDTLS_GENPRIME)
  300. #define MBEDTLS_BIGNUM_C
  301. #endif
  302. #if defined(MBEDTLS_RSA_C) || \
  303. defined(MBEDTLS_X509_USE_C)
  304. #define MBEDTLS_OID_C
  305. #endif
  306. #if defined(MBEDTLS_X509_USE_C)
  307. #define MBEDTLS_PK_PARSE_C
  308. #endif
  309. #if defined(CONFIG_MBEDTLS_PK_WRITE_C)
  310. #define MBEDTLS_PK_WRITE_C
  311. #endif
  312. #if defined(MBEDTLS_PK_PARSE_C) || defined(MBEDTLS_PK_WRITE_C)
  313. #define MBEDTLS_PK_C
  314. #endif
  315. #define MBEDTLS_SSL_MAX_CONTENT_LEN CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN
  316. /* Enable OpenThread optimizations. */
  317. #if defined(CONFIG_MBEDTLS_OPENTHREAD_OPTIMIZATIONS_ENABLED)
  318. #define MBEDTLS_MPI_WINDOW_SIZE 1 /**< Maximum windows size used. */
  319. #define MBEDTLS_MPI_MAX_SIZE 32 /**< Maximum number of bytes for usable MPIs. */
  320. #define MBEDTLS_ECP_MAX_BITS 256 /**< Maximum bit size of groups */
  321. #define MBEDTLS_ECP_WINDOW_SIZE 2 /**< Maximum window size used */
  322. #define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Enable fixed-point speed-up */
  323. #define MBEDTLS_ENTROPY_MAX_SOURCES 1 /**< Maximum number of sources supported */
  324. #endif
  325. #if defined(CONFIG_MBEDTLS_SERVER_NAME_INDICATION) && \
  326. defined(MBEDTLS_X509_CRT_PARSE_C)
  327. #define MBEDTLS_SSL_SERVER_NAME_INDICATION
  328. #endif
  329. /* User config file */
  330. #if defined(CONFIG_MBEDTLS_USER_CONFIG_FILE)
  331. #include CONFIG_MBEDTLS_USER_CONFIG_FILE
  332. #endif
  333. #include "mbedtls/check_config.h"
  334. #endif /* MBEDTLS_CONFIG_H */