user_settings.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. /* user_settings.h
  2. *
  3. * Copyright (C) 2006-2024 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. /* This user_settings.h is for Espressif ESP-IDF
  22. *
  23. * Standardized wolfSSL Espressif ESP32 + ESP8266 user_settings.h V5.7.0-1
  24. *
  25. * Do not include any wolfssl headers here
  26. *
  27. * When editing this file:
  28. * ensure wolfssl_test and wolfssl_benchmark settings match.
  29. */
  30. /* The Espressif project config file. See also sdkconfig.defaults */
  31. #include "sdkconfig.h"
  32. /* The Espressif sdkconfig will have chipset info.
  33. **
  34. ** Some possible values:
  35. **
  36. ** CONFIG_IDF_TARGET_ESP32
  37. ** CONFIG_IDF_TARGET_ESP32S2
  38. ** CONFIG_IDF_TARGET_ESP32S3
  39. ** CONFIG_IDF_TARGET_ESP32C3
  40. ** CONFIG_IDF_TARGET_ESP32C6
  41. */
  42. #undef WOLFSSL_ESPIDF
  43. #define WOLFSSL_ESPIDF
  44. /* We don't use WiFi, so don't compile in the esp-sdk-lib WiFi helpers: */
  45. #define NO_ESP_SDK_WIFI
  46. /* Experimental Kyber */
  47. #if 0
  48. /* Kyber typically needs a minimum 10K stack */
  49. #define WOLFSSL_EXPERIMENTAL_SETTINGS
  50. #define WOLFSSL_HAVE_KYBER
  51. #define WOLFSSL_WC_KYBER
  52. #define WOLFSSL_SHA3
  53. #endif
  54. /*
  55. * ONE of these Espressif chip families will be detected from sdkconfig:
  56. *
  57. * WOLFSSL_ESP32
  58. * WOLFSSL_ESP8266
  59. */
  60. #undef WOLFSSL_ESPWROOM32SE
  61. #undef WOLFSSL_ESP8266
  62. #undef WOLFSSL_ESP32
  63. /* See below for chipset detection from sdkconfig.h */
  64. /* when you want to use SINGLE THREAD. Note Default ESP-IDF is FreeRTOS */
  65. /* #define SINGLE_THREADED */
  66. /* SMALL_SESSION_CACHE saves a lot of RAM for ClientCache and SessionCache.
  67. * Memory requirement is about 5KB, otherwise 20K is needed when not specified.
  68. * If extra small footprint is needed, try MICRO_SESSION_CACHE (< 1K)
  69. * When really desperate or no TLS used, try NO_SESSION_CACHE. */
  70. #define NO_SESSION_CACHE
  71. /* Small Stack uses more heap. */
  72. #define WOLFSSL_SMALL_STACK
  73. /* Full debugging turned off, but show malloc failure detail */
  74. /* #define DEBUG_WOLFSSL */
  75. #define DEBUG_WOLFSSL_MALLOC
  76. /* See test.c that sets cert buffers; we'll set them here: */
  77. #define USE_CERT_BUFFERS_256
  78. #define USE_CERT_BUFFERS_2048
  79. /* RSA_LOW_MEM: Half as much memory but twice as slow. */
  80. #define RSA_LOW_MEM
  81. /* optionally turn off SHA512/224 SHA512/256 */
  82. /* #define WOLFSSL_NOSHA512_224 */
  83. /* #define WOLFSSL_NOSHA512_256 */
  84. /* when you want to use SINGLE THREAD. Note Default ESP-IDF is FreeRTOS */
  85. /* #define SINGLE_THREADED */
  86. /* When you don't want to use the old SHA */
  87. /* #define NO_SHA */
  88. /* #define NO_OLD_TLS */
  89. #define BENCH_EMBEDDED
  90. /* TLS 1.3 */
  91. #define WOLFSSL_TLS13
  92. #define HAVE_TLS_EXTENSIONS
  93. #define WC_RSA_PSS
  94. #define HAVE_HKDF
  95. #define HAVE_AEAD
  96. #define HAVE_SUPPORTED_CURVES
  97. #define WOLFSSL_BENCHMARK_FIXED_UNITS_KB
  98. #define NO_FILESYSTEM
  99. #define NO_OLD_TLS
  100. #define HAVE_AESGCM
  101. /* Optional RIPEMD: RACE Integrity Primitives Evaluation Message Digest */
  102. /* #define WOLFSSL_RIPEMD */
  103. /* when you want to use SHA224 */
  104. #define WOLFSSL_SHA224
  105. /* when you want to use SHA384 */
  106. #define WOLFSSL_SHA384
  107. /* when you want to use SHA512 */
  108. #define WOLFSSL_SHA512
  109. /* when you want to use SHA3 */
  110. #define WOLFSSL_SHA3
  111. /* ED25519 requires SHA512 */
  112. #define HAVE_ED25519
  113. /* Some features not enabled for ESP8266: */
  114. #if defined(CONFIG_IDF_TARGET_ESP8266) || \
  115. defined(CONFIG_IDF_TARGET_ESP32C2)
  116. /* TODO determine low memory configuration for ECC. */
  117. #else
  118. #define HAVE_ECC
  119. #define HAVE_CURVE25519
  120. #define CURVE25519_SMALL
  121. #endif
  122. #define HAVE_ED25519
  123. /* Optional OPENSSL compatibility */
  124. #define OPENSSL_EXTRA
  125. /* #Optional HAVE_PKCS7 */
  126. /* #define HAVE_PKCS7 */
  127. #if defined(HAVE_PKCS7)
  128. /* HAVE_PKCS7 may enable HAVE_PBKDF2 see settings.h */
  129. #define NO_PBKDF2
  130. #define HAVE_AES_KEYWRAP
  131. #define HAVE_X963_KDF
  132. #define WOLFSSL_AES_DIRECT
  133. #endif
  134. /* when you want to use AES counter mode */
  135. /* #define WOLFSSL_AES_DIRECT */
  136. /* #define WOLFSSL_AES_COUNTER */
  137. /* esp32-wroom-32se specific definition */
  138. #if defined(WOLFSSL_ESPWROOM32SE)
  139. #define WOLFSSL_ATECC508A
  140. #define HAVE_PK_CALLBACKS
  141. /* when you want to use a custom slot allocation for ATECC608A */
  142. /* unless your configuration is unusual, you can use default */
  143. /* implementation. */
  144. /* #define CUSTOM_SLOT_ALLOCATION */
  145. #endif
  146. /* WC_NO_CACHE_RESISTANT: slower but more secure */
  147. /* #define WC_NO_CACHE_RESISTANT */
  148. /* TFM_TIMING_RESISTANT: slower but more secure */
  149. /* #define TFM_TIMING_RESISTANT */
  150. /* #define WOLFSSL_ATECC508A_DEBUG */
  151. /* date/time */
  152. /* if it cannot adjust time in the device, */
  153. /* enable macro below */
  154. /* #define NO_ASN_TIME */
  155. /* #define XTIME time */
  156. /* adjust wait-timeout count if you see timeout in RSA HW acceleration */
  157. #define ESP_RSA_TIMEOUT_CNT 0x349F00
  158. /* hash limit for test.c */
  159. #define HASH_SIZE_LIMIT
  160. /* USE_FAST_MATH is default */
  161. #define USE_FAST_MATH
  162. /***** Use SP_MATH *****/
  163. /* #undef USE_FAST_MATH */
  164. /* #define SP_MATH */
  165. /* #define WOLFSSL_SP_MATH_ALL */
  166. /* #define WOLFSSL_SP_RISCV32 */
  167. /***** Use Integer Heap Math *****/
  168. /* #undef USE_FAST_MATH */
  169. /* #define USE_INTEGER_HEAP_MATH */
  170. #define WOLFSSL_SMALL_STACK
  171. #define HAVE_VERSION_EXTENDED_INFO
  172. /* #define HAVE_WC_INTROSPECTION */
  173. #define HAVE_SESSION_TICKET
  174. /* #define HAVE_HASHDRBG */
  175. #define WOLFSSL_KEY_GEN
  176. #define WOLFSSL_CERT_REQ
  177. #define WOLFSSL_CERT_GEN
  178. #define WOLFSSL_CERT_EXT
  179. #define WOLFSSL_SYS_CA_CERTS
  180. #define WOLFSSL_CERT_TEXT
  181. #define WOLFSSL_ASN_TEMPLATE
  182. /*
  183. #undef WOLFSSL_KEY_GEN
  184. #undef WOLFSSL_CERT_REQ
  185. #undef WOLFSSL_CERT_GEN
  186. #undef WOLFSSL_CERT_EXT
  187. #undef WOLFSSL_SYS_CA_CERTS
  188. */
  189. /* command-line options
  190. --enable-keygen
  191. --enable-certgen
  192. --enable-certreq
  193. --enable-certext
  194. --enable-asn-template
  195. */
  196. /* Chipset detection from sdkconfig.h
  197. * Default is HW enabled unless turned off.
  198. * Uncomment lines to force SW instead of HW acceleration */
  199. #if defined(CONFIG_IDF_TARGET_ESP32)
  200. #define WOLFSSL_ESP32
  201. /* Alternatively, if there's an ECC Secure Element present: */
  202. /* #define WOLFSSL_ESPWROOM32SE */
  203. /* wolfSSL HW Acceleration supported on ESP32. Uncomment to disable: */
  204. /* #define NO_ESP32_CRYPT */
  205. /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */
  206. /* #define NO_WOLFSSL_ESP32_CRYPT_AES */
  207. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */
  208. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */
  209. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */
  210. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */
  211. /* These are defined automatically in esp32-crypt.h, here for clarity: */
  212. #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA224 /* no SHA224 HW on ESP32 */
  213. #undef ESP_RSA_MULM_BITS
  214. #define ESP_RSA_MULM_BITS 16 /* TODO add compile-time warning */
  215. /***** END CONFIG_IDF_TARGET_ESP32 *****/
  216. #elif defined(CONFIG_IDF_TARGET_ESP32S2)
  217. #define WOLFSSL_ESP32
  218. /* wolfSSL HW Acceleration supported on ESP32-S2. Uncomment to disable: */
  219. /* #define NO_ESP32_CRYPT */
  220. /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */
  221. /* Note: There's no AES192 HW on the ESP32-S2; falls back to SW */
  222. /* #define NO_WOLFSSL_ESP32_CRYPT_AES */
  223. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */
  224. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */
  225. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */
  226. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */
  227. /***** END CONFIG_IDF_TARGET_ESP32S2 *****/
  228. #elif defined(CONFIG_IDF_TARGET_ESP32S3)
  229. #define WOLFSSL_ESP32
  230. /* wolfSSL HW Acceleration supported on ESP32-S3. Uncomment to disable: */
  231. /* #define NO_ESP32_CRYPT */
  232. /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */
  233. /* Note: There's no AES192 HW on the ESP32-S3; falls back to SW */
  234. /* #define NO_WOLFSSL_ESP32_CRYPT_AES */
  235. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */
  236. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */
  237. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */
  238. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */
  239. /***** END CONFIG_IDF_TARGET_ESP32S3 *****/
  240. #elif defined(CONFIG_IDF_TARGET_ESP32C2) || \
  241. defined(CONFIG_IDF_TARGET_ESP8684)
  242. #define WOLFSSL_ESP32
  243. /* ESP8684 is essentially ESP32-C2 chip + flash embedded together in a
  244. * single QFN 4x4 mm package. Out of released documentation, Technical
  245. * Reference Manual as well as ESP-IDF Programming Guide is applicable
  246. * to both ESP32-C2 and ESP8684.
  247. *
  248. * See: https://www.esp32.com/viewtopic.php?f=5&t=27926#:~:text=ESP8684%20is%20essentially%20ESP32%2DC2,both%20ESP32%2DC2%20and%20ESP8684. */
  249. /* wolfSSL HW Acceleration supported on ESP32-C2. Uncomment to disable: */
  250. /* #define NO_ESP32_CRYPT */
  251. /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ /* to disable all SHA HW */
  252. /* These are defined automatically in esp32-crypt.h, here for clarity */
  253. #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA384 /* no SHA384 HW on C2 */
  254. #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA512 /* no SHA512 HW on C2 */
  255. /* There's no AES or RSA/Math accelerator on the ESP32-C2
  256. * Auto defined with NO_WOLFSSL_ESP32_CRYPT_RSA_PRI, for clarity: */
  257. #define NO_WOLFSSL_ESP32_CRYPT_AES
  258. #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI
  259. #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL
  260. #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD
  261. #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD
  262. /***** END CONFIG_IDF_TARGET_ESP32C2 *****/
  263. #elif defined(CONFIG_IDF_TARGET_ESP32C3)
  264. #define WOLFSSL_ESP32
  265. /* wolfSSL HW Acceleration supported on ESP32-C3. Uncomment to disable: */
  266. /* #define NO_ESP32_CRYPT */
  267. /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ /* to disable all SHA HW */
  268. /* These are defined automatically in esp32-crypt.h, here for clarity: */
  269. #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA384 /* no SHA384 HW on C6 */
  270. #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA512 /* no SHA512 HW on C6 */
  271. /* #define NO_WOLFSSL_ESP32_CRYPT_AES */
  272. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */
  273. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */
  274. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */
  275. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */
  276. /***** END CONFIG_IDF_TARGET_ESP32C3 *****/
  277. #elif defined(CONFIG_IDF_TARGET_ESP32C6)
  278. #define WOLFSSL_ESP32
  279. /* wolfSSL HW Acceleration supported on ESP32-C6. Uncomment to disable: */
  280. /* #define NO_ESP32_CRYPT */
  281. /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */
  282. /* These are defined automatically in esp32-crypt.h, here for clarity: */
  283. #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA384 /* no SHA384 HW on C6 */
  284. #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA512 /* no SHA512 HW on C6 */
  285. /* #define NO_WOLFSSL_ESP32_CRYPT_AES */
  286. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */
  287. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */
  288. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */
  289. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */
  290. /***** END CONFIG_IDF_TARGET_ESP32C6 *****/
  291. #elif defined(CONFIG_IDF_TARGET_ESP32H2)
  292. #define WOLFSSL_ESP32
  293. /* wolfSSL Hardware Acceleration not yet implemented */
  294. #define NO_ESP32_CRYPT
  295. #define NO_WOLFSSL_ESP32_CRYPT_HASH
  296. #define NO_WOLFSSL_ESP32_CRYPT_AES
  297. #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI
  298. /***** END CONFIG_IDF_TARGET_ESP32H2 *****/
  299. #elif defined(CONFIG_IDF_TARGET_ESP8266)
  300. #define WOLFSSL_ESP8266
  301. /* There's no hardware encryption on the ESP8266 */
  302. /* Consider using the ESP32-C2/C3/C6
  303. * See https://www.espressif.com/en/products/socs/esp32-c2 */
  304. #define NO_ESP32_CRYPT
  305. #define NO_WOLFSSL_ESP32_CRYPT_HASH
  306. #define NO_WOLFSSL_ESP32_CRYPT_AES
  307. #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI
  308. /***** END CONFIG_IDF_TARGET_ESP266 *****/
  309. #elif defined(CONFIG_IDF_TARGET_ESP8684)
  310. /* There's no Hardware Acceleration available on ESP8684 */
  311. #define NO_ESP32_CRYPT
  312. #define NO_WOLFSSL_ESP32_CRYPT_HASH
  313. #define NO_WOLFSSL_ESP32_CRYPT_AES
  314. #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI
  315. /***** END CONFIG_IDF_TARGET_ESP8684 *****/
  316. #else
  317. /* Anything else encountered, disable HW accleration */
  318. #warning "Unexpected CONFIG_IDF_TARGET_NN value"
  319. #define NO_ESP32_CRYPT
  320. #define NO_WOLFSSL_ESP32_CRYPT_HASH
  321. #define NO_WOLFSSL_ESP32_CRYPT_AES
  322. #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI
  323. #endif /* CONFIG_IDF_TARGET Check */
  324. /* RSA primitive specific definition, listed AFTER the Chipset detection */
  325. #if defined(WOLFSSL_ESP32) || defined(WOLFSSL_ESPWROOM32SE)
  326. /* Consider USE_FAST_MATH and SMALL_STACK */
  327. #ifndef NO_RSA
  328. #define ESP32_USE_RSA_PRIMITIVE
  329. #if defined(CONFIG_IDF_TARGET_ESP32)
  330. #ifdef CONFIG_ESP_MAIN_TASK_STACK_SIZE
  331. #if CONFIG_ESP_MAIN_TASK_STACK_SIZE < 10500
  332. #warning "RSA may be difficult with less than 10KB Stack "/
  333. #endif
  334. #endif
  335. /* NOTE HW unreliable for small values! */
  336. /* threshold for performance adjustment for HW primitive use */
  337. /* X bits of G^X mod P greater than */
  338. #undef ESP_RSA_EXPT_XBITS
  339. #define ESP_RSA_EXPT_XBITS 32
  340. /* X and Y of X * Y mod P greater than */
  341. #undef ESP_RSA_MULM_BITS
  342. #define ESP_RSA_MULM_BITS 16
  343. #endif
  344. #endif
  345. #endif
  346. /* Debug options:
  347. See wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h for details on debug options
  348. #define ESP_VERIFY_MEMBLOCK
  349. #define DEBUG_WOLFSSL
  350. #define DEBUG_WOLFSSL_VERBOSE
  351. #define DEBUG_WOLFSSL_SHA_MUTEX
  352. #define WOLFSSL_ESP32_CRYPT_DEBUG
  353. #define WOLFSSL_ESP32_CRYPT_HASH_SHA224_DEBUG
  354. #define NO_RECOVER_SOFTWARE_CALC
  355. #define WOLFSSL_TEST_STRAY 1
  356. #define USE_ESP_DPORT_ACCESS_READ_BUFFER
  357. #define WOLFSSL_ESP32_HW_LOCK_DEBUG
  358. #define WOLFSSL_DEBUG_ESP_RSA_MULM_BITS
  359. #define ESP_DISABLE_HW_TASK_LOCK
  360. See wolfcrypt/benchmark/benchmark.c for debug and other settings:
  361. Turn on benchmark timing debugging (CPU Cycles, RTOS ticks, etc)
  362. #define DEBUG_WOLFSSL_BENCHMARK_TIMING
  363. Turn on timer debugging (used when CPU cycles not available)
  364. #define WOLFSSL_BENCHMARK_TIMER_DEBUG
  365. */
  366. /* Pause in a loop rather than exit. */
  367. #define WOLFSSL_ESPIDF_ERROR_PAUSE
  368. #define WOLFSSL_HW_METRICS
  369. /* for test.c */
  370. /* #define HASH_SIZE_LIMIT */
  371. /* Optionally turn off HW math checks */
  372. /* #define NO_HW_MATH_TEST */
  373. /* Optionally include alternate HW test library: alt_hw_test.h */
  374. /* When enabling, the ./components/wolfssl/CMakeLists.txt file
  375. * will need the name of the library in the idf_component_register
  376. * for the PRIV_REQUIRES list. */
  377. /* #define INCLUDE_ALT_HW_TEST */
  378. /* optionally turn off individual math HW acceleration features */
  379. /* Turn off Large Number ESP32 HW Multiplication:
  380. ** [Z = X * Y] in esp_mp_mul() */
  381. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */
  382. /* Turn off Large Number ESP32 HW Modular Exponentiation:
  383. ** [Z = X^Y mod M] in esp_mp_exptmod() */
  384. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */
  385. /* Turn off Large Number ESP32 HW Modular Multiplication
  386. ** [Z = X * Y mod M] in esp_mp_mulmod() */
  387. /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */
  388. /* used by benchmark: */
  389. #define WOLFSSL_PUBLIC_MP
  390. /* when turning on ECC508 / ECC608 support
  391. #define WOLFSSL_ESPWROOM32SE
  392. #define HAVE_PK_CALLBACKS
  393. #define WOLFSSL_ATECC508A
  394. #define ATCA_WOLFSSL
  395. */
  396. /***************************** Certificate Macros *****************************
  397. *
  398. * The section below defines macros used in typically all of the wolfSSL
  399. * examples such as the client and server for certs stored in header files.
  400. *
  401. * There are various certificate examples in this header file:
  402. * https://github.com/wolfSSL/wolfssl/blob/master/wolfssl/certs_test.h
  403. *
  404. * To use the sets of macros below, define *one* of these:
  405. *
  406. * USE_CERT_BUFFERS_1024 - ECC 1024 bit encoded ASN1
  407. * USE_CERT_BUFFERS_2048 - RSA 2048 bit encoded ASN1
  408. * WOLFSSL_SM[2,3,4] - SM Ciphers
  409. *
  410. * For example: define USE_CERT_BUFFERS_2048 to use CA Certs used in this
  411. * wolfSSL function for the `ca_cert_der_2048` buffer, size and types:
  412. *
  413. * ret = wolfSSL_CTX_load_verify_buffer(ctx,
  414. * CTX_CA_CERT,
  415. * CTX_CA_CERT_SIZE,
  416. * CTX_CA_CERT_TYPE);
  417. *
  418. * See https://www.wolfssl.com/documentation/manuals/wolfssl/group__CertsKeys.html#function-wolfssl_ctx_load_verify_buffer
  419. *
  420. * In this case the CTX_CA_CERT will be defined as `ca_cert_der_2048` as
  421. * defined here: https://github.com/wolfSSL/wolfssl/blob/master/wolfssl/certs_test.h
  422. *
  423. * The CTX_CA_CERT_SIZE and CTX_CA_CERT_TYPE are similarly used to reference
  424. * array size and cert type respectively.
  425. *
  426. * Similarly for loading the private client key:
  427. *
  428. * ret = wolfSSL_CTX_use_PrivateKey_buffer(ctx,
  429. * CTX_CLIENT_KEY,
  430. * CTX_CLIENT_KEY_SIZE,
  431. * CTX_CLIENT_KEY_TYPE);
  432. *
  433. * see https://www.wolfssl.com/documentation/manuals/wolfssl/group__CertsKeys.html#function-wolfssl_ctx_use_privatekey_buffer
  434. *
  435. * Similarly, the other macros are for server certificates and keys:
  436. * `CTX_SERVER_CERT` and `CTX_SERVER_KEY` are available.
  437. *
  438. * The certificate and key names are typically `static const unsigned char`
  439. * arrays. The [NAME]_size are typically `sizeof([array name])`, and the types
  440. * are the known wolfSSL encoding type integers (e.g. WOLFSSL_FILETYPE_PEM).
  441. *
  442. * See `SSL_FILETYPE_[name]` in
  443. * https://github.com/wolfSSL/wolfssl/blob/master/wolfssl/ssl.h
  444. *
  445. * See Abstract Syntax Notation One (ASN.1) in:
  446. * https://github.com/wolfSSL/wolfssl/blob/master/wolfssl/wolfcrypt/asn.h
  447. *
  448. * Optional SM4 Ciphers:
  449. *
  450. * Although the SM ciphers are shown here, the `certs_test_sm.h` may not yet
  451. * be available. See:
  452. * https://github.com/wolfSSL/wolfssl/pull/6825
  453. * https://github.com/wolfSSL/wolfsm
  454. *
  455. * Uncomment these 3 macros to enable the SM Ciphers and use the macros below.
  456. */
  457. /*
  458. #define WOLFSSL_SM2
  459. #define WOLFSSL_SM3
  460. #define WOLFSSL_SM4
  461. */
  462. /* Conditional macros used in wolfSSL TLS client and server examples */
  463. #if defined(WOLFSSL_SM2) || defined(WOLFSSL_SM3) || defined(WOLFSSL_SM4)
  464. #include <wolfssl/certs_test_sm.h>
  465. #define CTX_CA_CERT root_sm2
  466. #define CTX_CA_CERT_SIZE sizeof_root_sm2
  467. #define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_PEM
  468. #define CTX_SERVER_CERT server_sm2
  469. #define CTX_SERVER_CERT_SIZE sizeof_server_sm2
  470. #define CTX_SERVER_CERT_TYPE WOLFSSL_FILETYPE_PEM
  471. #define CTX_SERVER_KEY server_sm2_priv
  472. #define CTX_SERVER_KEY_SIZE sizeof_server_sm2_priv
  473. #define CTX_SERVER_KEY_TYPE WOLFSSL_FILETYPE_PEM
  474. #undef WOLFSSL_BASE16
  475. #define WOLFSSL_BASE16
  476. #else
  477. #if defined(USE_CERT_BUFFERS_2048)
  478. /* Be sure to include in app when using example certs: */
  479. /* #include <wolfssl/certs_test.h> */
  480. #define CTX_CA_CERT ca_cert_der_2048
  481. #define CTX_CA_CERT_SIZE sizeof_ca_cert_der_2048
  482. #define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_ASN1
  483. #define CTX_SERVER_CERT server_cert_der_2048
  484. #define CTX_SERVER_CERT_SIZE sizeof_server_cert_der_2048
  485. #define CTX_SERVER_CERT_TYPE WOLFSSL_FILETYPE_ASN1
  486. #define CTX_SERVER_KEY server_key_der_2048
  487. #define CTX_SERVER_KEY_SIZE sizeof_server_key_der_2048
  488. #define CTX_SERVER_KEY_TYPE WOLFSSL_FILETYPE_ASN1
  489. #define CTX_CLIENT_CERT client_cert_der_2048
  490. #define CTX_CLIENT_CERT_SIZE sizeof_client_cert_der_2048
  491. #define CTX_CLIENT_CERT_TYPE WOLFSSL_FILETYPE_ASN1
  492. #define CTX_CLIENT_KEY client_key_der_2048
  493. #define CTX_CLIENT_KEY_SIZE sizeof_client_key_der_2048
  494. #define CTX_CLIENT_KEY_TYPE WOLFSSL_FILETYPE_ASN1
  495. #elif defined(USE_CERT_BUFFERS_1024)
  496. /* Be sure to include in app when using example certs: */
  497. /* #include <wolfssl/certs_test.h> */
  498. #define CTX_CA_CERT ca_cert_der_1024
  499. #define CTX_CA_CERT_SIZE sizeof_ca_cert_der_1024
  500. #define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_ASN1
  501. #define CTX_CLIENT_CERT client_cert_der_1024
  502. #define CTX_CLIENT_CERT_SIZE sizeof_client_cert_der_1024
  503. #define CTX_CLIENT_CERT_TYPE WOLFSSL_FILETYPE_ASN1
  504. #define CTX_CLIENT_KEY client_key_der_1024
  505. #define CTX_CLIENT_KEY_SIZE sizeof_client_key_der_1024
  506. #define CTX_CLIENT_KEY_TYPE WOLFSSL_FILETYPE_ASN1
  507. #define CTX_SERVER_CERT server_cert_der_1024
  508. #define CTX_SERVER_CERT_SIZE sizeof_server_cert_der_1024
  509. #define CTX_SERVER_CERT_TYPE WOLFSSL_FILETYPE_ASN1
  510. #define CTX_SERVER_KEY server_key_der_1024
  511. #define CTX_SERVER_KEY_SIZE sizeof_server_key_der_1024
  512. #define CTX_SERVER_KEY_TYPE WOLFSSL_FILETYPE_ASN1
  513. #else
  514. /* Optionally define custom cert arrays, sizes, and types here */
  515. #error "Must define USE_CERT_BUFFERS_2048 or USE_CERT_BUFFERS_1024"
  516. #endif
  517. #endif /* Conditional key and cert constant names */