user_settings.h 15 KB

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