user_settings.h 15 KB

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