user_settings.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. /* Copyright (C) 2006-2018 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. #include <stddef.h> /* for size_t */
  337. extern void *myMalloc(size_t n, void* heap, int type);
  338. extern void myFree(void *p, void* heap, int type);
  339. extern void *myRealloc(void *p, size_t n, void* heap, int type);
  340. #define XMALLOC(n, h, t) myMalloc(n, h, t)
  341. #define XFREE(p, h, t) myFree(p, h, t)
  342. #define XREALLOC(p, n, h, t) myRealloc(p, n, h, t)
  343. #endif
  344. #if 0
  345. /* Static memory requires fast math */
  346. #define WOLFSSL_STATIC_MEMORY
  347. /* Disable fallback malloc/free */
  348. #define WOLFSSL_NO_MALLOC
  349. #if 1
  350. #define WOLFSSL_MALLOC_CHECK /* trap malloc failure */
  351. #endif
  352. #endif
  353. /* Memory callbacks */
  354. #if 0
  355. #undef USE_WOLFSSL_MEMORY
  356. #define USE_WOLFSSL_MEMORY
  357. /* Use this to measure / print heap usage */
  358. #if 1
  359. #undef WOLFSSL_TRACK_MEMORY
  360. #define WOLFSSL_TRACK_MEMORY
  361. #undef WOLFSSL_DEBUG_MEMORY
  362. #define WOLFSSL_DEBUG_MEMORY
  363. #endif
  364. #else
  365. #ifndef WOLFSSL_STATIC_MEMORY
  366. #define NO_WOLFSSL_MEMORY
  367. /* Otherwise we will use stdlib malloc, free and realloc */
  368. #endif
  369. #endif
  370. /* ------------------------------------------------------------------------- */
  371. /* Port */
  372. /* ------------------------------------------------------------------------- */
  373. /* Override Current Time */
  374. /* Allows custom "custom_time()" function to be used for benchmark */
  375. //#define WOLFSSL_USER_CURRTIME
  376. //#define WOLFSSL_GMTIME
  377. //#define USER_TICKS
  378. extern unsigned long my_time(unsigned long* timer);
  379. #if 0
  380. #define XTIME my_time
  381. #endif
  382. /* ------------------------------------------------------------------------- */
  383. /* RNG */
  384. /* ------------------------------------------------------------------------- */
  385. /* Seed Source */
  386. /* Size of returned HW RNG value */
  387. //#define CUSTOM_RAND_TYPE unsigned int
  388. extern unsigned int my_rng_seed_gen(void);
  389. #undef CUSTOM_RAND_GENERATE
  390. //#define CUSTOM_RAND_GENERATE my_rng_seed_gen
  391. /* Choose RNG method */
  392. #if 1
  393. /* Use built-in P-RNG (SHA256 based) with HW RNG */
  394. /* P-RNG + HW RNG (P-RNG is ~8K) */
  395. #undef HAVE_HASHDRBG
  396. #define HAVE_HASHDRBG
  397. #else
  398. #undef WC_NO_HASHDRBG
  399. #define WC_NO_HASHDRBG
  400. /* Bypass P-RNG and use only HW RNG */
  401. extern int my_rng_gen_block(unsigned char* output, unsigned int sz);
  402. #undef CUSTOM_RAND_GENERATE_BLOCK
  403. #define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block
  404. #endif
  405. /* ------------------------------------------------------------------------- */
  406. /* Custom Standard Lib */
  407. /* ------------------------------------------------------------------------- */
  408. /* Allows override of all standard library functions */
  409. #undef STRING_USER
  410. #if 1
  411. #define STRING_USER
  412. #include <string.h>
  413. #undef USE_WOLF_STRSEP
  414. #define USE_WOLF_STRSEP
  415. #define XSTRSEP(s1,d) wc_strsep((s1),(d))
  416. #undef USE_WOLF_STRTOK
  417. #define USE_WOLF_STRTOK
  418. #define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr))
  419. #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
  420. #define XMEMCPY(d,s,l) memcpy((d),(s),(l))
  421. #define XMEMSET(b,c,l) memset((b),(c),(l))
  422. #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
  423. #define XMEMMOVE(d,s,l) memmove((d),(s),(l))
  424. #define XSTRLEN(s1) strlen((s1))
  425. #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
  426. #define XSTRSTR(s1,s2) strstr((s1),(s2))
  427. #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
  428. #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
  429. #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
  430. #define XSNPRINTF snprintf
  431. #endif
  432. /* ------------------------------------------------------------------------- */
  433. /* Enable Features */
  434. /* ------------------------------------------------------------------------- */
  435. #undef WOLFSSL_TLS13
  436. #if 1
  437. #define WOLFSSL_TLS13
  438. #endif
  439. #undef WOLFSSL_KEY_GEN
  440. #if 0
  441. #define WOLFSSL_KEY_GEN
  442. #endif
  443. #if defined(HAVE_FIPS) && !defined(WOLFSSL_KEY_GEN)
  444. #define WOLFSSL_OLD_PRIME_CHECK
  445. #endif
  446. #undef KEEP_PEER_CERT
  447. //#define KEEP_PEER_CERT
  448. #undef HAVE_COMP_KEY
  449. //#define HAVE_COMP_KEY
  450. #undef HAVE_TLS_EXTENSIONS
  451. #define HAVE_TLS_EXTENSIONS
  452. #undef HAVE_SUPPORTED_CURVES
  453. #define HAVE_SUPPORTED_CURVES
  454. #undef WOLFSSL_BASE64_ENCODE
  455. #define WOLFSSL_BASE64_ENCODE
  456. /* TLS Session Cache */
  457. #if 1
  458. #define SMALL_SESSION_CACHE
  459. #else
  460. #define NO_SESSION_CACHE
  461. #endif
  462. #undef HAVE_EXTENDED_MASTER
  463. #define HAVE_EXTENDED_MASTER
  464. #undef HAVE_TRUNCATED_HMAC
  465. #define HAVE_TRUNCATED_HMAC
  466. #undef WOLFSSL_ALLOW_TLSV10
  467. #define WOLFSSL_ALLOW_TLSV10
  468. #undef HAVE_SNI
  469. #if 1
  470. #define HAVE_SNI
  471. #endif
  472. #undef HAVE_MAX_FRAGMENT
  473. #if 1
  474. /* Set maximum fragment size. */
  475. #define HAVE_MAX_FRAGMENT
  476. #endif
  477. #if 1
  478. #define FP_MAX_BITS_ECC (256 + 32)
  479. #endif
  480. /* ------------------------------------------------------------------------- */
  481. /* TCP STACK */
  482. /* ------------------------------------------------------------------------- */
  483. #undef HAVE_NETX
  484. #if 1
  485. #define HAVE_NETX
  486. #endif
  487. #undef WOLFSSL_LWIP
  488. #if 0
  489. #define WOLFSSL_LWIP
  490. #endif
  491. /* ------------------------------------------------------------------------- */
  492. /* RTOS */
  493. /* ------------------------------------------------------------------------- */
  494. #undef THREADX
  495. #if 1
  496. #define THREADX
  497. #undef THREADX_NO_DC_PRINTF
  498. #if 1
  499. #define THREADX_NO_DC_PRINTF
  500. #endif
  501. #endif
  502. /* ------------------------------------------------------------------------- */
  503. /* Disable Features */
  504. /* ------------------------------------------------------------------------- */
  505. #undef NO_WOLFSSL_SERVER
  506. //#define NO_WOLFSSL_SERVER
  507. #undef NO_WOLFSSL_CLIENT
  508. //#define NO_WOLFSSL_CLIENT
  509. #undef NO_CRYPT_TEST
  510. //#define NO_CRYPT_TEST
  511. #undef NO_CRYPT_BENCHMARK
  512. //#define NO_CRYPT_BENCHMARK
  513. #undef WOLFCRYPT_ONLY
  514. //#define WOLFCRYPT_ONLY
  515. /* In-lining of misc.c functions */
  516. /* If defined, must include wolfcrypt/src/misc.c in build */
  517. /* Slower, but about 1k smaller */
  518. #undef NO_INLINE
  519. //#define NO_INLINE
  520. #undef NO_FILESYSTEM
  521. #define NO_FILESYSTEM
  522. #undef NO_WRITEV
  523. #define NO_WRITEV
  524. #undef NO_MAIN_DRIVER
  525. #define NO_MAIN_DRIVER
  526. #undef NO_DEV_RANDOM
  527. #define NO_DEV_RANDOM
  528. #undef NO_DSA
  529. //#define NO_DSA
  530. #undef NO_RC4
  531. //#define NO_RC4
  532. #undef NO_OLD_TLS
  533. //#define NO_OLD_TLS
  534. #undef NO_PSK
  535. //#define NO_PSK
  536. #undef NO_MD4
  537. //#define NO_MD4
  538. #undef NO_PWDBASED
  539. #define NO_PWDBASED
  540. #undef NO_CODING
  541. //#define NO_CODING
  542. #undef NO_ASN_TIME
  543. //#define NO_ASN_TIME
  544. #undef NO_CERTS
  545. //#define NO_CERTS
  546. #undef NO_SIG_WRAPPER
  547. //#define NO_SIG_WRAPPER
  548. #undef NO_OLD_WC_NAMES
  549. //#define NO_OLD_WC_NAMES
  550. #undef NO_WOLFSSL_DIR
  551. //#define NO_WOLFSSL_DIR
  552. /* ------------------------------------------------------------------------- */
  553. /* WICED SDK */
  554. /* ------------------------------------------------------------------------- */
  555. #undef WOLFSSL_WICED
  556. #if 1
  557. #define WOLFSSL_WICED
  558. #undef WICED_MBEDTLS
  559. #endif
  560. #ifdef __cplusplus
  561. }
  562. #endif
  563. #endif /* WOLFSSL_USER_SETTINGS_H */