default_conf.ftl 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. [#ftl]
  2. /**
  3. ******************************************************************************
  4. * File Name : ${name}
  5. * Description : This file provides code for the configuration
  6. * of the ${name} instances.
  7. ******************************************************************************
  8. [@common.optinclude name=mxTmpFolder+"/license.tmp"/][#--include License text --]
  9. ******************************************************************************
  10. */
  11. [#assign s = name]
  12. [#assign toto = s?replace(".","_")]
  13. [#assign toto = toto?replace("/","")]
  14. [#assign toto = toto?replace("-","_")]
  15. [#assign inclusion_protection = toto?upper_case]
  16. /* Define to prevent recursive inclusion -------------------------------------*/
  17. #ifndef __${inclusion_protection}__
  18. #define __${inclusion_protection}__
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /* Includes ------------------------------------------------------------------*/
  23. [#if includes??]
  24. [#list includes as include]
  25. #include "${include}"
  26. [/#list]
  27. [/#if]
  28. [#-- SWIPdatas is a list of SWIPconfigModel --]
  29. [#list SWIPdatas as SWIP]
  30. [#-- Global variables --]
  31. [#if SWIP.variables??]
  32. [#list SWIP.variables as variable]
  33. extern ${variable.value} ${variable.name};
  34. [/#list]
  35. [/#if]
  36. [#-- Global variables --]
  37. [#assign instName = SWIP.ipName]
  38. [#assign fileName = SWIP.fileName]
  39. [#assign version = SWIP.version]
  40. /**
  41. MiddleWare name : ${instName}
  42. MiddleWare fileName : ${fileName}
  43. MiddleWare version : ${version}
  44. */
  45. [#if SWIP.defines??]
  46. [#list SWIP.defines as definition]
  47. /*---------- [#if definition.comments??]${definition.comments}[/#if] -----------*/
  48. #define ${definition.name} #t#t ${definition.value}
  49. [#if definition.description??]${definition.description} [/#if]
  50. [/#list]
  51. [/#if]
  52. [/#list]
  53. /* ------------------------------------------------------------------------- */
  54. /* Hardware platform */
  55. /* ------------------------------------------------------------------------- */
  56. #define NO_STM32_HASH
  57. #define NO_STM32_CRYPTO
  58. #if defined(STM32WB55xx)
  59. #define WOLFSSL_STM32WB
  60. #define WOLFSSL_STM32_PKA
  61. #undef NO_STM32_CRYPTO
  62. #define HAL_CONSOLE_UART huart1
  63. #elif defined(STM32F407xx)
  64. #define WOLFSSL_STM32F4
  65. #define HAL_CONSOLE_UART huart2
  66. #elif defined(STM32F437xx)
  67. #define WOLFSSL_STM32F4
  68. #undef NO_STM32_HASH
  69. #undef NO_STM32_CRYPTO
  70. #define STM32_HAL_V2
  71. #define HAL_CONSOLE_UART huart4
  72. #elif defined(STM32F777xx)
  73. #define WOLFSSL_STM32F7
  74. #undef NO_STM32_HASH
  75. #undef NO_STM32_CRYPTO
  76. #define STM32_HAL_V2
  77. #define HAL_CONSOLE_UART huart2
  78. #define STM32_AESGCM_PARTIAL /* allow partial blocks and add auth info (header) */
  79. #elif defined(STM32H753xx)
  80. #define WOLFSSL_STM32H7
  81. #undef NO_STM32_HASH
  82. #undef NO_STM32_CRYPTO
  83. #define HAL_CONSOLE_UART huart3
  84. #elif defined(STM32L4A6xx)
  85. #define WOLFSSL_STM32L4
  86. #undef NO_STM32_HASH
  87. #undef NO_STM32_CRYPTO
  88. #define HAL_CONSOLE_UART hlpuart1
  89. #elif defined(STM32L475xx)
  90. #define WOLFSSL_STM32L4
  91. #define HAL_CONSOLE_UART huart1
  92. #elif defined(STM32L562xx)
  93. #define WOLFSSL_STM32L5
  94. #define WOLFSSL_STM32_PKA
  95. #undef NO_STM32_HASH
  96. #undef NO_STM32_CRYPTO
  97. #define HAL_CONSOLE_UART huart1
  98. #elif defined(STM32L552xx)
  99. #define WOLFSSL_STM32L5
  100. #undef NO_STM32_HASH
  101. #define HAL_CONSOLE_UART hlpuart1
  102. #elif defined(STM32F207xx)
  103. #define WOLFSSL_STM32F2
  104. #define HAL_CONSOLE_UART huart3
  105. #elif defined(STM32F107xC)
  106. #define WOLFSSL_STM32F1
  107. #define HAL_CONSOLE_UART huart4
  108. #define NO_STM32_RNG
  109. #elif defined(STM32F401xE)
  110. #define WOLFSSL_STM32F4
  111. #define HAL_CONSOLE_UART huart2
  112. #define NO_STM32_RNG
  113. #define WOLFSSL_GENSEED_FORTEST
  114. #elif defined(STM32G071xx)
  115. #define WOLFSSL_STM32G0
  116. #define HAL_CONSOLE_UART huart2
  117. #define NO_STM32_RNG
  118. #define WOLFSSL_GENSEED_FORTEST
  119. #else
  120. #warning Please define a hardware platform!
  121. /* This means there is not a pre-defined platform for your board/CPU */
  122. /* You need to define a CPU type, HW crypto and debug UART */
  123. /* CPU Type: WOLFSSL_STM32F1, WOLFSSL_STM32F2, WOLFSSL_STM32F4,
  124. WOLFSSL_STM32F7, WOLFSSL_STM32H7, WOLFSSL_STM32L4 and WOLFSSL_STM32L5 */
  125. #define WOLFSSL_STM32F4
  126. /* Debug UART used for printf */
  127. /* The UART interface number varies for each board/CPU */
  128. /* Typically this is the UART attached to the ST-Link USB CDC UART port */
  129. #define HAL_CONSOLE_UART huart4
  130. /* Hardware Crypto - uncomment as available on hardware */
  131. //#define WOLFSSL_STM32_PKA
  132. //#define NO_STM32_RNG
  133. //#undef NO_STM32_HASH
  134. //#undef NO_STM32_CRYPTO
  135. //#define WOLFSSL_GENSEED_FORTEST
  136. //#define STM32_HAL_V2
  137. #endif
  138. /* ------------------------------------------------------------------------- */
  139. /* Platform */
  140. /* ------------------------------------------------------------------------- */
  141. #define SIZEOF_LONG_LONG 8
  142. #define WOLFSSL_GENERAL_ALIGNMENT 4
  143. #define WOLFSSL_STM32_CUBEMX
  144. #define WOLFSSL_SMALL_STACK
  145. #define WOLFSSL_USER_IO
  146. #define WOLFSSL_NO_SOCK
  147. #define WOLFSSL_IGNORE_FILE_WARN
  148. /* ------------------------------------------------------------------------- */
  149. /* Operating System */
  150. /* ------------------------------------------------------------------------- */
  151. #if defined(WOLF_CONF_RTOS) && WOLF_CONF_RTOS == 2
  152. #define FREERTOS
  153. #else
  154. #define SINGLE_THREADED
  155. #endif
  156. /* ------------------------------------------------------------------------- */
  157. /* Math Configuration */
  158. /* ------------------------------------------------------------------------- */
  159. /* 1=Fast (stack)
  160. * 2=Normal (heap)
  161. * 3=Single Precision C (only common curves/key sizes)
  162. * 4=Single Precision ASM Cortex-M3+
  163. * 5=Single Precision ASM Cortex-M0 (Generic Thumb)
  164. * 6=Single Precision C all small
  165. * 7=Single Precision C all big
  166. */
  167. #if defined(WOLF_CONF_MATH) && WOLF_CONF_MATH != 2
  168. /* fast (stack) math */
  169. #define USE_FAST_MATH
  170. #define TFM_TIMING_RESISTANT
  171. /* Optimizations (TFM_ARM, TFM_ASM or none) */
  172. //#define TFM_NO_ASM
  173. //#define TFM_ASM
  174. #endif
  175. #if defined(WOLF_CONF_MATH) && (WOLF_CONF_MATH >= 3)
  176. /* single precision only */
  177. #define WOLFSSL_SP
  178. #if WOLF_CONF_MATH != 7
  179. #define WOLFSSL_SP_SMALL /* use smaller version of code */
  180. #endif
  181. #if defined(WOLF_CONF_RSA) && WOLF_CONF_RSA == 1
  182. #define WOLFSSL_HAVE_SP_RSA
  183. #endif
  184. #if defined(WOLF_CONF_DH) && WOLF_CONF_DH == 1
  185. #define WOLFSSL_HAVE_SP_DH
  186. #endif
  187. #if defined(WOLF_CONF_ECC) && WOLF_CONF_ECC == 1
  188. #define WOLFSSL_HAVE_SP_ECC
  189. #endif
  190. #if WOLF_CONF_MATH == 6 || WOLF_CONF_MATH == 7
  191. #define WOLFSSL_SP_MATH /* disable non-standard curves / key sizes */
  192. #endif
  193. #define SP_WORD_SIZE 32
  194. /* Enable to put all math on stack (no heap) */
  195. //#define WOLFSSL_SP_NO_MALLOC
  196. /* Enable for SP cache resistance (not usually enabled for embedded micros) */
  197. //#define WOLFSSL_SP_CACHE_RESISTANT
  198. #if WOLF_CONF_MATH == 4 || WOLF_CONF_MATH == 5
  199. #define WOLFSSL_SP_ASM /* required if using the ASM versions */
  200. #if WOLF_CONF_MATH == 4
  201. /* ARM Cortex-M3+ */
  202. #define WOLFSSL_SP_ARM_CORTEX_M_ASM
  203. #endif
  204. #if WOLF_CONF_MATH == 5
  205. /* Generic ARM Thumb (Cortex-M0) Assembly */
  206. #define WOLFSSL_SP_ARM_THUMB_ASM
  207. #endif
  208. #endif
  209. #endif
  210. /* ------------------------------------------------------------------------- */
  211. /* Enable Features */
  212. /* ------------------------------------------------------------------------- */
  213. /* Required for TLS */
  214. #define HAVE_TLS_EXTENSIONS
  215. #define HAVE_SUPPORTED_CURVES
  216. #define HAVE_ENCRYPT_THEN_MAC
  217. #define HAVE_EXTENDED_MASTER
  218. #if defined(WOLF_CONF_TLS13) && WOLF_CONF_TLS13 == 1
  219. #define WOLFSSL_TLS13
  220. #define HAVE_HKDF
  221. #endif
  222. #if defined(WOLF_CONF_DTLS) && WOLF_CONF_DTLS == 1
  223. #define WOLFSSL_DTLS
  224. #endif
  225. #if defined(WOLF_CONF_PSK) && WOLF_CONF_PSK == 0
  226. #define NO_PSK
  227. #endif
  228. #if defined(WOLF_CONF_PWDBASED) && WOLF_CONF_PWDBASED == 0
  229. #define NO_PWDBASED
  230. #endif
  231. #if defined(WOLF_CONF_KEEP_PEER_CERT) && WOLF_CONF_KEEP_PEER_CERT == 1
  232. #define KEEP_PEER_CERT
  233. #endif
  234. #if defined(WOLF_CONF_BASE64_ENCODE) && WOLF_CONF_BASE64_ENCODE == 1
  235. #define WOLFSSL_BASE64_ENCODE
  236. #endif
  237. #if defined(WOLF_CONF_OPENSSL_EXTRA) && WOLF_CONF_OPENSSL_EXTRA == 1
  238. #define OPENSSL_EXTRA
  239. #endif
  240. /* TLS Session Cache */
  241. #if 0
  242. #define SMALL_SESSION_CACHE
  243. #else
  244. #define NO_SESSION_CACHE
  245. #endif
  246. /* ------------------------------------------------------------------------- */
  247. /* Crypto */
  248. /* ------------------------------------------------------------------------- */
  249. /* RSA */
  250. #undef NO_RSA
  251. #if defined(WOLF_CONF_RSA) && WOLF_CONF_RSA == 1
  252. #ifdef USE_FAST_MATH
  253. /* Maximum math bits (Max RSA key bits * 2) */
  254. #undef FP_MAX_BITS
  255. #define FP_MAX_BITS 4096
  256. #endif
  257. /* half as much memory but twice as slow */
  258. #undef RSA_LOW_MEM
  259. //#define RSA_LOW_MEM
  260. /* Enables blinding mode, to prevent timing attacks */
  261. #undef WC_RSA_BLINDING
  262. #define WC_RSA_BLINDING
  263. /* RSA PSS Support (required for TLS v1.3) */
  264. #ifdef WOLFSSL_TLS13
  265. #define WC_RSA_PSS
  266. #endif
  267. #else
  268. #define NO_RSA
  269. #endif
  270. /* ECC */
  271. #undef HAVE_ECC
  272. #if defined(WOLF_CONF_ECC) && WOLF_CONF_ECC == 1
  273. #define HAVE_ECC
  274. /* Manually define enabled curves */
  275. #define ECC_USER_CURVES
  276. //#define HAVE_ECC192
  277. //#define HAVE_ECC224
  278. #undef NO_ECC256
  279. //#define HAVE_ECC384
  280. //#define HAVE_ECC521
  281. /* Fixed point cache (speeds repeated operations against same private key) */
  282. #undef FP_ECC
  283. //#define FP_ECC
  284. #ifdef FP_ECC
  285. /* Bits / Entries */
  286. #undef FP_ENTRIES
  287. #define FP_ENTRIES 2
  288. #undef FP_LUT
  289. #define FP_LUT 4
  290. #endif
  291. /* Optional ECC calculation method */
  292. /* Note: doubles heap usage, but slightly faster */
  293. #undef ECC_SHAMIR
  294. #define ECC_SHAMIR
  295. /* Reduces heap usage, but slower */
  296. #define ECC_TIMING_RESISTANT
  297. /* Compressed ECC key support */
  298. //#define HAVE_COMP_KEY
  299. #ifdef USE_FAST_MATH
  300. #ifdef NO_RSA
  301. /* Custom fastmath size if not using RSA */
  302. /* MAX = ROUND32(ECC BITS) * 2 */
  303. #define FP_MAX_BITS (256 * 2)
  304. #else
  305. #define ALT_ECC_SIZE
  306. #endif
  307. /* Enable TFM optimizations for ECC */
  308. //#define TFM_ECC192
  309. //#define TFM_ECC224
  310. //#define TFM_ECC256
  311. //#define TFM_ECC384
  312. //#define TFM_ECC521
  313. #endif
  314. #endif
  315. /* DH */
  316. #undef NO_DH
  317. #if defined(WOLF_CONF_DH) && WOLF_CONF_DH == 1
  318. #define HAVE_DH /* freeRTOS settings.h requires this */
  319. #define HAVE_FFDHE_2048
  320. #define HAVE_DH_DEFAULT_PARAMS
  321. #else
  322. #define NO_DH
  323. #endif
  324. /* AES */
  325. #if defined(WOLF_CONF_AESGCM) && WOLF_CONF_AESGCM == 1
  326. #define HAVE_AESGCM
  327. /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */
  328. /* GCM_TABLE is about 4K larger and 3x faster */
  329. #define GCM_SMALL
  330. #define HAVE_AES_DECRYPT
  331. #endif
  332. #if defined(WOLF_CONF_AESCBC) && WOLF_CONF_AESCBC == 1
  333. #define HAVE_AES_CBC
  334. #define HAVE_AES_DECRYPT
  335. #endif
  336. /* Other possible AES modes */
  337. //#define WOLFSSL_AES_COUNTER
  338. //#define HAVE_AESCCM
  339. //#define WOLFSSL_AES_XTS
  340. //#define WOLFSSL_AES_DIRECT
  341. //#define HAVE_AES_ECB
  342. //#define HAVE_AES_KEYWRAP
  343. //#define AES_MAX_KEY_SIZE 256
  344. /* ChaCha20 / Poly1305 */
  345. #undef HAVE_CHACHA
  346. #undef HAVE_POLY1305
  347. #if defined(WOLF_CONF_CHAPOLY) && WOLF_CONF_CHAPOLY == 1
  348. #define HAVE_CHACHA
  349. #define HAVE_POLY1305
  350. /* Needed for Poly1305 */
  351. #undef HAVE_ONE_TIME_AUTH
  352. #define HAVE_ONE_TIME_AUTH
  353. #endif
  354. /* Ed25519 / Curve25519 */
  355. #undef HAVE_CURVE25519
  356. #undef HAVE_ED25519
  357. #if defined(WOLF_CONF_EDCURVE25519) && WOLF_CONF_EDCURVE25519 == 1
  358. #define HAVE_CURVE25519
  359. #define HAVE_ED25519
  360. /* Optionally use small math (less flash usage, but much slower) */
  361. #define CURVED25519_SMALL
  362. #endif
  363. /* ------------------------------------------------------------------------- */
  364. /* Hashing */
  365. /* ------------------------------------------------------------------------- */
  366. /* Sha1 */
  367. #undef NO_SHA
  368. #if defined(WOLF_CONF_SHA1) && WOLF_CONF_SHA1 == 1
  369. /* 1k smaller, but 25% slower */
  370. //#define USE_SLOW_SHA
  371. #else
  372. #define NO_SHA
  373. #endif
  374. /* Sha2-256 */
  375. #undef NO_SHA256
  376. #if defined(WOLF_CONF_SHA2_256) && WOLF_CONF_SHA2_256 == 1
  377. /* not unrolled - ~2k smaller and ~25% slower */
  378. //#define USE_SLOW_SHA256
  379. //#define WOLFSSL_SHAKE256
  380. /* Sha2-224 */
  381. #if defined(WOLF_CONF_SHA2_224) && WOLF_CONF_SHA2_224 == 1
  382. #define WOLFSSL_SHA224
  383. #endif
  384. #else
  385. #define NO_SHA256
  386. #endif
  387. /* Sha2-512 */
  388. #undef WOLFSSL_SHA512
  389. #if defined(WOLF_CONF_SHA2_512) && WOLF_CONF_SHA2_512 == 1
  390. /* over twice as small, but 50% slower */
  391. //#define USE_SLOW_SHA512
  392. #define WOLFSSL_SHA512
  393. #define HAVE_SHA512 /* freeRTOS settings.h requires this */
  394. #endif
  395. /* Sha2-384 */
  396. #undef WOLFSSL_SHA384
  397. #if defined(WOLF_CONF_SHA2_384) && WOLF_CONF_SHA2_384 == 1
  398. #define WOLFSSL_SHA384
  399. #endif
  400. /* Sha3 */
  401. #undef WOLFSSL_SHA3
  402. #if defined(WOLF_CONF_SHA3) && WOLF_CONF_SHA3 == 1
  403. #define WOLFSSL_SHA3
  404. #endif
  405. /* MD5 */
  406. #if defined(WOLF_CONF_MD5) && WOLF_CONF_MD5 == 1
  407. /* enabled */
  408. #else
  409. #define NO_MD5
  410. #endif
  411. /* ------------------------------------------------------------------------- */
  412. /* Benchmark / Test */
  413. /* ------------------------------------------------------------------------- */
  414. /* Use reduced benchmark / test sizes */
  415. #define BENCH_EMBEDDED
  416. #define USE_CERT_BUFFERS_2048
  417. #define USE_CERT_BUFFERS_256
  418. /* ------------------------------------------------------------------------- */
  419. /* Debugging */
  420. /* ------------------------------------------------------------------------- */
  421. #if defined(WOLF_CONF_DEBUG) && WOLF_CONF_DEBUG == 1
  422. #define DEBUG_WOLFSSL
  423. /* Use this to measure / print heap usage */
  424. #if 0
  425. #define USE_WOLFSSL_MEMORY
  426. #define WOLFSSL_TRACK_MEMORY
  427. #define WOLFSSL_DEBUG_MEMORY
  428. #define WOLFSSL_DEBUG_MEMORY_PRINT
  429. #endif
  430. #else
  431. //#define NO_WOLFSSL_MEMORY
  432. //#define NO_ERROR_STRINGS
  433. #endif
  434. /* ------------------------------------------------------------------------- */
  435. /* Port */
  436. /* ------------------------------------------------------------------------- */
  437. /* Override Current Time */
  438. /* Allows custom "custom_time()" function to be used for benchmark */
  439. #define WOLFSSL_USER_CURRTIME
  440. /* ------------------------------------------------------------------------- */
  441. /* RNG */
  442. /* ------------------------------------------------------------------------- */
  443. #define NO_OLD_RNGNAME /* conflicts with STM RNG macro */
  444. #if !defined(WOLF_CONF_RNG) || WOLF_CONF_RNG == 1
  445. /* default is enabled */
  446. #define HAVE_HASHDRBG
  447. #else /* WOLF_CONF_RNG == 0 */
  448. #define WC_NO_HASHDRBG
  449. #define WC_NO_RNG
  450. #endif
  451. /* ------------------------------------------------------------------------- */
  452. /* Disable Features */
  453. /* ------------------------------------------------------------------------- */
  454. #if defined(WOLF_CONF_TLS12) && WOLF_CONF_TLS12 == 0
  455. #define WOLFSSL_NO_TLS12
  456. #endif
  457. #if defined(WOLF_CONF_WOLFCRYPT_ONLY) && WOLF_CONF_WOLFCRYPT_ONLY == 1
  458. #define WOLFCRYPT_ONLY
  459. #endif
  460. //#define NO_WOLFSSL_SERVER
  461. //#define NO_WOLFSSL_CLIENT
  462. #if defined(WOLF_CONF_TEST) && WOLF_CONF_TEST == 0
  463. #define NO_CRYPT_TEST
  464. #define NO_CRYPT_BENCHMARK
  465. #endif
  466. #define NO_FILESYSTEM
  467. #define NO_WRITEV
  468. #define NO_MAIN_DRIVER
  469. #define NO_DEV_RANDOM
  470. #define NO_OLD_TLS
  471. #define WOLFSSL_NO_CLIENT_AUTH /* disable client auth for Ed25519/Ed448 */
  472. #define NO_DSA
  473. #define NO_RC4
  474. #define NO_HC128
  475. #define NO_RABBIT
  476. #define NO_MD4
  477. #define NO_DES3
  478. /* In-lining of misc.c functions */
  479. /* If defined, must include wolfcrypt/src/misc.c in build */
  480. /* Slower, but about 1k smaller */
  481. //#define NO_INLINE
  482. /* Base16 / Base64 encoding */
  483. //#define NO_CODING
  484. /* bypass certificate date checking, due to lack of properly configured RTC source */
  485. #ifndef HAL_RTC_MODULE_ENABLED
  486. #define NO_ASN_TIME
  487. #endif
  488. #ifdef __cplusplus
  489. }
  490. #endif
  491. #endif /* ${inclusion_protection}_H */
  492. /**
  493. * @}
  494. */
  495. /*****END OF FILE****/