2
0

user_settings.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. / * Copyright (C) 2006-2024 wolfSSL Inc.
  2. *
  3. * This file is part of wolfSSL.
  4. *
  5. * wolfSSL is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * wolfSSL is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  18. */
  19. /* Custom wolfSSL user settings for Cypress WICED Studio. */
  20. #ifndef WOLFSSL_USER_SETTINGS_H
  21. #define WOLFSSL_USER_SETTINGS_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* ------------------------------------------------------------------------- */
  26. /* Platform */
  27. /* ------------------------------------------------------------------------- */
  28. #undef WOLFSSL_GENERAL_ALIGNMENT
  29. #define WOLFSSL_GENERAL_ALIGNMENT 4
  30. #undef SINGLE_THREADED
  31. #if 0
  32. #define SINGLE_THREADED
  33. #endif
  34. #undef WOLFSSL_SMALL_STACK
  35. #if 1
  36. #define WOLFSSL_SMALL_STACK
  37. #endif
  38. #undef WOLFSSL_USER_IO
  39. #define WOLFSSL_USER_IO
  40. /* ------------------------------------------------------------------------- */
  41. /* Math Configuration */
  42. /* ------------------------------------------------------------------------- */
  43. #undef USE_FAST_MATH
  44. #define USE_FAST_MATH
  45. #undef SIZEOF_LONG_LONG
  46. #define SIZEOF_LONG_LONG 8
  47. #undef USE_FAST_MATH
  48. #if 1
  49. #define USE_FAST_MATH
  50. #undef TFM_TIMING_RESISTANT
  51. #define TFM_TIMING_RESISTANT
  52. /* Optimizations */
  53. //#define TFM_ARM
  54. #endif
  55. /* Wolf Single Precision Math */
  56. #undef WOLFSSL_SP
  57. #if 0
  58. #define WOLFSSL_SP
  59. #define WOLFSSL_SP_SMALL
  60. #define WOLFSSL_HAVE_SP_RSA
  61. #define WOLFSSL_HAVE_SP_DH
  62. #define WOLFSSL_HAVE_SP_ECC
  63. //#define WOLFSSL_SP_MATH
  64. /* 64 or 32 bit version */
  65. //#define WOLFSSL_SP_ARM32_ASM
  66. //#define WOLFSSL_SP_ARM64_ASM
  67. #endif
  68. /* ------------------------------------------------------------------------- */
  69. /* FIPS - Requires eval or license from wolfSSL */
  70. /* ------------------------------------------------------------------------- */
  71. #undef HAVE_FIPS
  72. #if 0
  73. #define HAVE_FIPS
  74. #undef HAVE_FIPS_VERSION
  75. #define HAVE_FIPS_VERSION 2
  76. #ifdef SINGLE_THREADED
  77. #undef NO_THREAD_LS
  78. #define NO_THREAD_LS
  79. #endif
  80. #endif
  81. /* ------------------------------------------------------------------------- */
  82. /* Crypto */
  83. /* ------------------------------------------------------------------------- */
  84. /* RSA */
  85. #undef NO_RSA
  86. #if 1
  87. #ifdef USE_FAST_MATH
  88. /* Maximum math bits (Max RSA key bits * 2) */
  89. #undef FP_MAX_BITS
  90. #define FP_MAX_BITS 4096
  91. #endif
  92. /* half as much memory but twice as slow */
  93. #undef RSA_LOW_MEM
  94. //#define RSA_LOW_MEM
  95. /* Enables blinding mode, to prevent timing attacks */
  96. #if 1
  97. #undef WC_RSA_BLINDING
  98. #define WC_RSA_BLINDING
  99. #else
  100. #undef WC_NO_HARDEN
  101. #define WC_NO_HARDEN
  102. #endif
  103. /* RSA PSS Support */
  104. #if 1
  105. #define WC_RSA_PSS
  106. #endif
  107. #if 0
  108. #define WC_RSA_NO_PADDING
  109. #endif
  110. #else
  111. #define NO_RSA
  112. #endif
  113. /* ECC */
  114. #undef HAVE_ECC
  115. #if 1
  116. #define HAVE_ECC
  117. /* Manually define enabled curves */
  118. #undef ECC_USER_CURVES
  119. #define ECC_USER_CURVES
  120. #ifdef ECC_USER_CURVES
  121. /* Manual Curve Selection */
  122. //#define HAVE_ECC192
  123. //#define HAVE_ECC224
  124. #undef NO_ECC256
  125. //#define HAVE_ECC384
  126. //#define HAVE_ECC521
  127. #endif
  128. /* Fixed point cache (speeds repeated operations against same private key) */
  129. #undef FP_ECC
  130. //#define FP_ECC
  131. #ifdef FP_ECC
  132. /* Bits / Entries */
  133. #undef FP_ENTRIES
  134. #define FP_ENTRIES 2
  135. #undef FP_LUT
  136. #define FP_LUT 4
  137. #endif
  138. /* Optional ECC calculation method */
  139. /* Note: doubles heap usage, but slightly faster */
  140. #undef ECC_SHAMIR
  141. #define ECC_SHAMIR
  142. #undef TFM_ECC256
  143. #define TFM_ECC256
  144. /* Reduces heap usage, but slower */
  145. #undef ECC_TIMING_RESISTANT
  146. #define ECC_TIMING_RESISTANT
  147. /* Enable cofactor support */
  148. #ifdef HAVE_FIPS
  149. #undef HAVE_ECC_CDH
  150. #define HAVE_ECC_CDH
  151. #endif
  152. /* Validate import */
  153. #ifdef HAVE_FIPS
  154. #undef WOLFSSL_VALIDATE_ECC_IMPORT
  155. #define WOLFSSL_VALIDATE_ECC_IMPORT
  156. #endif
  157. /* Compressed Key Support */
  158. #undef HAVE_COMP_KEY
  159. //#define HAVE_COMP_KEY
  160. /* Use alternate ECC size for ECC math */
  161. #ifdef USE_FAST_MATH
  162. #ifdef NO_RSA
  163. /* Custom fastmath size if not using RSA */
  164. /* MAX = ROUND32(ECC BITS 256) + SIZE_OF_MP_DIGIT(32) */
  165. #undef FP_MAX_BITS
  166. #define FP_MAX_BITS (256 + 32)
  167. #else
  168. #undef ALT_ECC_SIZE
  169. #define ALT_ECC_SIZE
  170. #endif
  171. /* Speedups specific to curve */
  172. #ifndef NO_ECC256
  173. #undef TFM_ECC256
  174. #define TFM_ECC256
  175. #endif
  176. #endif
  177. #endif
  178. /* DH */
  179. #undef NO_DH
  180. #if 1
  181. /* Use table for DH instead of -lm (math) lib dependency */
  182. #if 1
  183. #define WOLFSSL_DH_CONST
  184. #define HAVE_FFDHE_2048
  185. #define HAVE_FFDHE_4096
  186. //#define HAVE_FFDHE_6144
  187. //#define HAVE_FFDHE_8192
  188. #endif
  189. #ifdef HAVE_FIPS
  190. #define WOLFSSL_VALIDATE_FFC_IMPORT
  191. #define HAVE_FFDHE_Q
  192. #endif
  193. #else
  194. #define NO_DH
  195. #endif
  196. /* AES */
  197. #undef NO_AES
  198. #if 1
  199. #undef HAVE_AES_CBC
  200. #define HAVE_AES_CBC
  201. #undef HAVE_AESGCM
  202. #define HAVE_AESGCM
  203. /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */
  204. #define GCM_SMALL
  205. #undef WOLFSSL_AES_DIRECT
  206. #define WOLFSSL_AES_DIRECT
  207. #undef HAVE_AES_ECB
  208. //#define HAVE_AES_ECB
  209. #undef WOLFSSL_AES_COUNTER
  210. #define WOLFSSL_AES_COUNTER
  211. #undef HAVE_AESCCM
  212. #define HAVE_AESCCM
  213. #else
  214. #define NO_AES
  215. #endif
  216. /* DES3 */
  217. #undef NO_DES3
  218. #if 1
  219. #else
  220. #define NO_DES3
  221. #endif
  222. /* ChaCha20 / Poly1305 */
  223. #undef HAVE_CHACHA
  224. #undef HAVE_POLY1305
  225. #if 1
  226. #define HAVE_CHACHA
  227. #define HAVE_POLY1305
  228. /* Needed for Poly1305 */
  229. #undef HAVE_ONE_TIME_AUTH
  230. #define HAVE_ONE_TIME_AUTH
  231. #endif
  232. /* Ed25519 / Curve25519 */
  233. #undef HAVE_CURVE25519
  234. #undef HAVE_ED25519
  235. #if 0
  236. #define HAVE_CURVE25519
  237. #define HAVE_ED25519 /* ED25519 Requires SHA512 */
  238. /* Optionally use small math (less flash usage, but much slower) */
  239. #if 1
  240. #define CURVED25519_SMALL
  241. #endif
  242. #endif
  243. /* ------------------------------------------------------------------------- */
  244. /* Hashing */
  245. /* ------------------------------------------------------------------------- */
  246. /* Sha */
  247. #undef NO_SHA
  248. #if 1
  249. /* 1k smaller, but 25% slower */
  250. #define USE_SLOW_SHA
  251. #else
  252. #define NO_SHA
  253. #endif
  254. /* Sha256 */
  255. #undef NO_SHA256
  256. #if 1
  257. /* not unrolled - ~2k smaller and ~25% slower */
  258. //#define USE_SLOW_SHA256
  259. /* Sha224 */
  260. #if 1
  261. #define WOLFSSL_SHA224
  262. #endif
  263. #else
  264. #define NO_SHA256
  265. #endif
  266. /* Sha512 */
  267. #undef WOLFSSL_SHA512
  268. #if 1
  269. #define WOLFSSL_SHA512
  270. /* Sha384 */
  271. #undef WOLFSSL_SHA384
  272. #if 1
  273. #define WOLFSSL_SHA384
  274. #endif
  275. #undef WOLFSSL_SHA224
  276. #if 1
  277. #define WOLFSSL_SHA224
  278. #endif
  279. /* over twice as small, but 50% slower */
  280. //#define USE_SLOW_SHA512
  281. #endif
  282. /* Sha3 */
  283. #undef WOLFSSL_SHA3
  284. #if 0
  285. #define WOLFSSL_SHA3
  286. #endif
  287. /* MD5 */
  288. #undef NO_MD5
  289. #if 1
  290. #else
  291. #define NO_MD5
  292. #endif
  293. /* HKDF */
  294. #undef HAVE_HKDF
  295. #if 1
  296. #define HAVE_HKDF
  297. #endif
  298. /* CMAC */
  299. #undef WOLFSSL_CMAC
  300. #if 0
  301. #define WOLFSSL_CMAC
  302. #endif
  303. /* ------------------------------------------------------------------------- */
  304. /* Benchmark / Test */
  305. /* ------------------------------------------------------------------------- */
  306. /* Use reduced benchmark / test sizes */
  307. #undef BENCH_EMBEDDED
  308. #define BENCH_EMBEDDED
  309. #undef USE_CERT_BUFFERS_2048
  310. #define USE_CERT_BUFFERS_2048
  311. #undef USE_CERT_BUFFERS_1024
  312. #define USE_CERT_BUFFERS_1024
  313. #undef USE_CERT_BUFFERS_256
  314. #define USE_CERT_BUFFERS_256
  315. /* ------------------------------------------------------------------------- */
  316. /* Debugging */
  317. /* ------------------------------------------------------------------------- */
  318. #undef DEBUG_WOLFSSL
  319. #undef NO_ERROR_STRINGS
  320. #if 1
  321. #define DEBUG_WOLFSSL
  322. #else
  323. #if 0
  324. #define NO_ERROR_STRINGS
  325. #endif
  326. #endif
  327. /* ------------------------------------------------------------------------- */
  328. /* Memory */
  329. /* ------------------------------------------------------------------------- */
  330. /* Override Memory API's */
  331. #if 0
  332. #undef XMALLOC_OVERRIDE
  333. #define XMALLOC_OVERRIDE
  334. /* prototypes for user heap override functions */
  335. /* Note: Realloc only required for normal math */
  336. /* Note2: XFREE(NULL) must be properly handled */
  337. #include <stddef.h> /* for size_t */
  338. extern void *myMalloc(size_t n, void* heap, int type);
  339. extern void myFree(void *p, void* heap, int type);
  340. extern void *myRealloc(void *p, size_t n, void* heap, int type);
  341. #define XMALLOC(n, h, t) myMalloc(n, h, t)
  342. #define XFREE(p, h, t) myFree(p, h, t)
  343. #define XREALLOC(p, n, h, t) myRealloc(p, n, h, t)
  344. #endif
  345. #if 0
  346. /* Static memory requires fast math */
  347. #define WOLFSSL_STATIC_MEMORY
  348. /* Disable fallback malloc/free */
  349. #define WOLFSSL_NO_MALLOC
  350. #if 1
  351. #define WOLFSSL_MALLOC_CHECK /* trap malloc failure */
  352. #endif
  353. #endif
  354. /* Memory callbacks */
  355. #if 0
  356. #undef USE_WOLFSSL_MEMORY
  357. #define USE_WOLFSSL_MEMORY
  358. /* Use this to measure / print heap usage */
  359. #if 1
  360. #undef WOLFSSL_TRACK_MEMORY
  361. #define WOLFSSL_TRACK_MEMORY
  362. #undef WOLFSSL_DEBUG_MEMORY
  363. #define WOLFSSL_DEBUG_MEMORY
  364. #endif
  365. #else
  366. #ifndef WOLFSSL_STATIC_MEMORY
  367. #define NO_WOLFSSL_MEMORY
  368. /* Otherwise we will use stdlib malloc, free and realloc */
  369. #endif
  370. #endif
  371. /* ------------------------------------------------------------------------- */
  372. /* Port */
  373. /* ------------------------------------------------------------------------- */
  374. /* Override Current Time */
  375. /* Allows custom "custom_time()" function to be used for benchmark */
  376. //#define WOLFSSL_USER_CURRTIME
  377. //#define WOLFSSL_GMTIME
  378. //#define USER_TICKS
  379. extern unsigned long my_time(unsigned long* timer);
  380. #if 0
  381. #define XTIME my_time
  382. #endif
  383. /* ------------------------------------------------------------------------- */
  384. /* RNG */
  385. /* ------------------------------------------------------------------------- */
  386. /* Seed Source */
  387. /* Size of returned HW RNG value */
  388. //#define CUSTOM_RAND_TYPE unsigned int
  389. extern unsigned int my_rng_seed_gen(void);
  390. #undef CUSTOM_RAND_GENERATE
  391. //#define CUSTOM_RAND_GENERATE my_rng_seed_gen
  392. /* Choose RNG method */
  393. #if 1
  394. /* Use built-in P-RNG (SHA256 based) with HW RNG */
  395. /* P-RNG + HW RNG (P-RNG is ~8K) */
  396. #undef HAVE_HASHDRBG
  397. #define HAVE_HASHDRBG
  398. #else
  399. #undef WC_NO_HASHDRBG
  400. #define WC_NO_HASHDRBG
  401. /* Bypass P-RNG and use only HW RNG */
  402. extern int my_rng_gen_block(unsigned char* output, unsigned int sz);
  403. #undef CUSTOM_RAND_GENERATE_BLOCK
  404. #define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block
  405. #endif
  406. /* ------------------------------------------------------------------------- */
  407. /* Custom Standard Lib */
  408. /* ------------------------------------------------------------------------- */
  409. /* Allows override of all standard library functions */
  410. #undef STRING_USER
  411. #if 1
  412. #define STRING_USER
  413. #include <string.h>
  414. #undef USE_WOLF_STRSEP
  415. #define USE_WOLF_STRSEP
  416. #define XSTRSEP(s1,d) wc_strsep((s1),(d))
  417. #undef USE_WOLF_STRTOK
  418. #define USE_WOLF_STRTOK
  419. #define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr))
  420. #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
  421. #define XMEMCPY(d,s,l) memcpy((d),(s),(l))
  422. #define XMEMSET(b,c,l) memset((b),(c),(l))
  423. #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
  424. #define XMEMMOVE(d,s,l) memmove((d),(s),(l))
  425. #define XSTRLEN(s1) strlen((s1))
  426. #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
  427. #define XSTRSTR(s1,s2) strstr((s1),(s2))
  428. #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
  429. #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
  430. #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
  431. #define XSNPRINTF snprintf
  432. #endif
  433. /* ------------------------------------------------------------------------- */
  434. /* Enable Features */
  435. /* ------------------------------------------------------------------------- */
  436. #undef WOLFSSL_TLS13
  437. #if 1
  438. #define WOLFSSL_TLS13
  439. #endif
  440. #undef WOLFSSL_KEY_GEN
  441. #if 0
  442. #define WOLFSSL_KEY_GEN
  443. #endif
  444. #if defined(HAVE_FIPS) && !defined(WOLFSSL_KEY_GEN)
  445. #define WOLFSSL_OLD_PRIME_CHECK
  446. #endif
  447. #undef KEEP_PEER_CERT
  448. //#define KEEP_PEER_CERT
  449. #undef HAVE_COMP_KEY
  450. //#define HAVE_COMP_KEY
  451. #undef HAVE_TLS_EXTENSIONS
  452. #define HAVE_TLS_EXTENSIONS
  453. #undef HAVE_SUPPORTED_CURVES
  454. #define HAVE_SUPPORTED_CURVES
  455. #undef WOLFSSL_BASE64_ENCODE
  456. #define WOLFSSL_BASE64_ENCODE
  457. /* TLS Session Cache */
  458. #if 1
  459. #define SMALL_SESSION_CACHE
  460. #else
  461. #define NO_SESSION_CACHE
  462. #endif
  463. #undef HAVE_EXTENDED_MASTER
  464. #define HAVE_EXTENDED_MASTER
  465. #undef HAVE_TRUNCATED_HMAC
  466. #define HAVE_TRUNCATED_HMAC
  467. #undef WOLFSSL_ALLOW_TLSV10
  468. #define WOLFSSL_ALLOW_TLSV10
  469. #undef HAVE_SNI
  470. #if 1
  471. #define HAVE_SNI
  472. #endif
  473. #undef HAVE_MAX_FRAGMENT
  474. #if 1
  475. /* Set maximum fragment size. */
  476. #define HAVE_MAX_FRAGMENT
  477. #endif
  478. #if 1
  479. #define FP_MAX_BITS_ECC (256 + 32)
  480. #endif
  481. /* ------------------------------------------------------------------------- */
  482. /* TCP STACK */
  483. /* ------------------------------------------------------------------------- */
  484. #undef HAVE_NETX
  485. #if 1
  486. #define HAVE_NETX
  487. #endif
  488. #undef WOLFSSL_LWIP
  489. #if 0
  490. #define WOLFSSL_LWIP
  491. #endif
  492. /* ------------------------------------------------------------------------- */
  493. /* RTOS */
  494. /* ------------------------------------------------------------------------- */
  495. #undef THREADX
  496. #if 1
  497. #define THREADX
  498. #undef THREADX_NO_DC_PRINTF
  499. #if 1
  500. #define THREADX_NO_DC_PRINTF
  501. #endif
  502. #endif
  503. /* ------------------------------------------------------------------------- */
  504. /* Disable Features */
  505. /* ------------------------------------------------------------------------- */
  506. #undef NO_WOLFSSL_SERVER
  507. //#define NO_WOLFSSL_SERVER
  508. #undef NO_WOLFSSL_CLIENT
  509. //#define NO_WOLFSSL_CLIENT
  510. #undef NO_CRYPT_TEST
  511. //#define NO_CRYPT_TEST
  512. #undef NO_CRYPT_BENCHMARK
  513. //#define NO_CRYPT_BENCHMARK
  514. #undef WOLFCRYPT_ONLY
  515. //#define WOLFCRYPT_ONLY
  516. /* In-lining of misc.c functions */
  517. /* If defined, must include wolfcrypt/src/misc.c in build */
  518. /* Slower, but about 1k smaller */
  519. #undef NO_INLINE
  520. //#define NO_INLINE
  521. #undef NO_FILESYSTEM
  522. #define NO_FILESYSTEM
  523. #undef NO_WRITEV
  524. #define NO_WRITEV
  525. #undef NO_MAIN_DRIVER
  526. #define NO_MAIN_DRIVER
  527. #undef NO_DEV_RANDOM
  528. #define NO_DEV_RANDOM
  529. #undef NO_DSA
  530. //#define NO_DSA
  531. #undef NO_RC4
  532. //#define NO_RC4
  533. #undef NO_OLD_TLS
  534. //#define NO_OLD_TLS
  535. #undef NO_PSK
  536. //#define NO_PSK
  537. #undef NO_MD4
  538. //#define NO_MD4
  539. #undef NO_PWDBASED
  540. #define NO_PWDBASED
  541. #undef NO_CODING
  542. //#define NO_CODING
  543. #undef NO_ASN_TIME
  544. //#define NO_ASN_TIME
  545. #undef NO_CERTS
  546. //#define NO_CERTS
  547. #undef NO_SIG_WRAPPER
  548. //#define NO_SIG_WRAPPER
  549. #undef NO_OLD_WC_NAMES
  550. //#define NO_OLD_WC_NAMES
  551. #undef NO_WOLFSSL_DIR
  552. //#define NO_WOLFSSL_DIR
  553. /* ------------------------------------------------------------------------- */
  554. /* WICED SDK */
  555. /* ------------------------------------------------------------------------- */
  556. #undef WOLFSSL_WICED
  557. #if 1
  558. #define WOLFSSL_WICED
  559. #undef WICED_MBEDTLS
  560. #endif
  561. #ifdef __cplusplus
  562. }
  563. #endif
  564. #endif /* WOLFSSL_USER_SETTINGS_H */