user_settings.h 15 KB

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