user_settings.h 15 KB

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