user_settings.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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. /* Template for the Infineon AURIX Development Studio and TC3XX
  22. * Example wolfSSL user settings with #if 0/1 gates to enable/disable algorithms and features.
  23. * This file is included with wolfssl/wolfcrypt/settings.h when WOLFSSL_USER_SETTINGS is defined.
  24. */
  25. #ifndef WOLFSSL_USER_SETTINGS_H
  26. #define WOLFSSL_USER_SETTINGS_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* ------------------------------------------------------------------------- */
  31. /* Platform */
  32. /* ------------------------------------------------------------------------- */
  33. /* Alignment and sizeof 64-bit */
  34. #define WOLFSSL_GENERAL_ALIGNMENT 4
  35. #define SIZEOF_LONG_LONG 8
  36. /* disable threading - mutex locking */
  37. #define SINGLE_THREADED
  38. /* ignore file include warnings */
  39. #define WOLFSSL_IGNORE_FILE_WARN
  40. /* disable the built-in socket support and use the IO callbacks.
  41. * Set with wolfSSL_CTX_SetIORecv/wolfSSL_CTX_SetIOSend
  42. */
  43. #define WOLFSSL_USER_IO
  44. /* Disable file system */
  45. #define NO_FILESYSTEM
  46. /* ------------------------------------------------------------------------- */
  47. /* Port */
  48. /* ------------------------------------------------------------------------- */
  49. /* Override Current Time */
  50. /* Allows custom "custom_time()" function to be used for benchmark */
  51. #define WOLFSSL_USER_CURRTIME
  52. #define WOLFSSL_GMTIME
  53. #define USER_TICKS
  54. extern unsigned long my_time(unsigned long* timer);
  55. #define XTIME my_time
  56. /* Use built-in P-RNG (SHA256 based) with HW RNG */
  57. #undef HAVE_HASHDRBG
  58. #define HAVE_HASHDRBG
  59. /* Custom Seed Source */
  60. #define CUSTOM_RAND_TYPE unsigned int
  61. extern unsigned int my_rng_seed_gen(void);
  62. #undef CUSTOM_RAND_GENERATE
  63. #define CUSTOM_RAND_GENERATE my_rng_seed_gen
  64. /* Standard Lib - C89 */
  65. #define XSTRCASECMP(s1,s2) strcmp((s1),(s2))
  66. /* ------------------------------------------------------------------------- */
  67. /* Math Configuration */
  68. /* ------------------------------------------------------------------------- */
  69. #undef USE_FAST_MATH
  70. #undef WOLFSSL_SP
  71. #if 1
  72. /* Wolf Single Precision Math */
  73. #define WOLFSSL_HAVE_SP_RSA
  74. //#define WOLFSSL_HAVE_SP_DH
  75. #define WOLFSSL_HAVE_SP_ECC
  76. #define WOLFSSL_SP_4096 /* Enable RSA/RH 4096-bit support */
  77. #define WOLFSSL_SP_384 /* Enable ECC 384-bit SECP384R1 support */
  78. #define WOLFSSL_SP_MATH /* only SP math - disables integer.c/tfm.c */
  79. //#define WOLFSSL_SP_MATH_ALL /* use SP math for all key sizes and curves */
  80. #define WOLFSSL_SP_NO_MALLOC
  81. //#define WOLFSSL_SP_DIV_32 /* do not use 64-bit divides */
  82. /* use smaller version of code */
  83. #define WOLFSSL_SP_SMALL
  84. /* SP Assembly Speedups - specific to chip type */
  85. //#define WOLFSSL_SP_ASM
  86. //#define WOLFSSL_SP_ARM32_ASM
  87. //#define WOLFSSL_SP_ARM64_ASM
  88. //#define WOLFSSL_SP_ARM_THUMB_ASM
  89. //#define WOLFSSL_SP_ARM_CORTEX_M_ASM
  90. #endif
  91. #ifndef WOLFSSL_SP_MATH
  92. #if 0
  93. /* fast math (tfmc.) (stack based and timing resistant) */
  94. #define USE_FAST_MATH
  95. #define TFM_TIMING_RESISTANT
  96. #else
  97. /* normal heap based integer.c (not timing resistant) */
  98. #define USE_INTEGER_HEAP_MATH
  99. #endif
  100. #endif
  101. /* ------------------------------------------------------------------------- */
  102. /* Crypto */
  103. /* ------------------------------------------------------------------------- */
  104. /* RSA */
  105. #undef NO_RSA
  106. #if 1
  107. #ifdef USE_FAST_MATH
  108. /* Maximum math bits (Max RSA key bits * 2) */
  109. #define FP_MAX_BITS 4096
  110. #endif
  111. /* half as much memory but twice as slow */
  112. //#define RSA_LOW_MEM
  113. /* Enables blinding mode, to prevent timing attacks */
  114. #define WC_RSA_BLINDING
  115. /* RSA PSS Support */
  116. #define WC_RSA_PSS
  117. #else
  118. #define NO_RSA
  119. #endif
  120. /* DH */
  121. #undef NO_DH
  122. #if 0
  123. /* Use table for DH instead of -lm (math) lib dependency */
  124. #if 1
  125. #define WOLFSSL_DH_CONST
  126. #define HAVE_FFDHE_2048
  127. //#define HAVE_FFDHE_4096
  128. //#define HAVE_FFDHE_6144
  129. //#define HAVE_FFDHE_8192
  130. #endif
  131. #else
  132. #define NO_DH
  133. #endif
  134. /* ECC */
  135. #undef HAVE_ECC
  136. #if 1
  137. #define HAVE_ECC
  138. /* Manually define enabled curves */
  139. #define ECC_USER_CURVES
  140. #ifdef ECC_USER_CURVES
  141. /* Manual Curve Selection */
  142. //#define HAVE_ECC192
  143. //#define HAVE_ECC224
  144. #undef NO_ECC256
  145. #define HAVE_ECC384
  146. //#define HAVE_ECC521
  147. #endif
  148. /* Fixed point cache (speeds repeated operations against same private key) */
  149. //#define FP_ECC
  150. #ifdef FP_ECC
  151. /* Bits / Entries */
  152. #define FP_ENTRIES 2
  153. #define FP_LUT 4
  154. #endif
  155. /* Optional ECC calculation method */
  156. /* Note: doubles heap usage, but slightly faster */
  157. #define ECC_SHAMIR
  158. /* Reduces heap usage, but slower */
  159. #define ECC_TIMING_RESISTANT
  160. /* Compressed ECC Key Support */
  161. //#define HAVE_COMP_KEY
  162. /* Use alternate ECC size for ECC math */
  163. #ifdef USE_FAST_MATH
  164. /* MAX ECC BITS = ROUND8(MAX ECC) * 2 */
  165. #if defined(NO_RSA) && defined(NO_DH)
  166. /* Custom fastmath size if not using RSA/DH */
  167. #define FP_MAX_BITS (256 * 2)
  168. #else
  169. /* use heap allocation for ECC points */
  170. #define ALT_ECC_SIZE
  171. /* wolfSSL will compute the FP_MAX_BITS_ECC, but it can be overridden */
  172. //#define FP_MAX_BITS_ECC (256 * 2)
  173. #endif
  174. /* Speedups specific to curve */
  175. #ifndef NO_ECC256
  176. #define TFM_ECC256
  177. #endif
  178. #endif
  179. #endif
  180. /* AES */
  181. #undef NO_AES
  182. #if 1
  183. #define HAVE_AES_CBC
  184. /* GCM Method: GCM_TABLE_4BIT, GCM_SMALL, GCM_WORD32 or GCM_TABLE */
  185. #define HAVE_AESGCM
  186. #define GCM_SMALL
  187. #define WOLFSSL_AES_DIRECT
  188. #define HAVE_AES_ECB
  189. #else
  190. #define NO_AES
  191. #endif
  192. /* DES3 */
  193. #undef NO_DES3
  194. #if 0
  195. #else
  196. #define NO_DES3
  197. #endif
  198. /* ChaCha20 / Poly1305 */
  199. #undef HAVE_CHACHA
  200. #undef HAVE_POLY1305
  201. #if 1
  202. #define HAVE_CHACHA
  203. #define HAVE_POLY1305
  204. /* Needed for Poly1305 */
  205. #define HAVE_ONE_TIME_AUTH
  206. #endif
  207. /* Ed25519 / Curve25519 */
  208. #undef HAVE_CURVE25519
  209. #undef HAVE_ED25519
  210. #if 0
  211. #define HAVE_CURVE25519
  212. #define HAVE_ED25519 /* ED25519 Requires SHA512 */
  213. /* Optionally use small math (less flash usage, but much slower) */
  214. #if 1
  215. #define CURVED25519_SMALL
  216. #endif
  217. #endif
  218. /* ------------------------------------------------------------------------- */
  219. /* Hashing */
  220. /* ------------------------------------------------------------------------- */
  221. /* Sha */
  222. #undef NO_SHA
  223. #if 1
  224. /* on by default */
  225. /* 1k smaller, but 25% slower */
  226. //#define USE_SLOW_SHA
  227. #else
  228. #define NO_SHA
  229. #endif
  230. /* Sha256 */
  231. #undef NO_SHA256
  232. #if 1
  233. /* not unrolled - ~2k smaller and ~25% slower */
  234. //#define USE_SLOW_SHA256
  235. /* Sha224 */
  236. #if 0
  237. #define WOLFSSL_SHA224
  238. #endif
  239. #else
  240. #define NO_SHA256
  241. #endif
  242. /* Sha512 */
  243. #undef WOLFSSL_SHA512
  244. #if 0
  245. #define WOLFSSL_SHA512
  246. /* Sha384 */
  247. #undef WOLFSSL_SHA384
  248. #if 0
  249. #define WOLFSSL_SHA384
  250. #endif
  251. /* over twice as small, but 50% slower */
  252. //#define USE_SLOW_SHA512
  253. #endif
  254. /* Sha3 */
  255. #undef WOLFSSL_SHA3
  256. #if 0
  257. #define WOLFSSL_SHA3
  258. #endif
  259. /* MD5 */
  260. #undef NO_MD5
  261. #if 0
  262. /* on by default */
  263. #else
  264. #define NO_MD5
  265. #endif
  266. /* HKDF */
  267. #undef HAVE_HKDF
  268. #if 1
  269. #define HAVE_HKDF
  270. #endif
  271. /* CMAC */
  272. #undef WOLFSSL_CMAC
  273. #if 1
  274. #define WOLFSSL_CMAC
  275. /* Note: requires WOLFSSL_AES_DIRECT */
  276. #endif
  277. /* HMAC - on by default */
  278. #undef NO_HMAC
  279. #if 1
  280. /* on by default */
  281. #else
  282. #define NO_HMAC
  283. #endif
  284. /* ------------------------------------------------------------------------- */
  285. /* ASN */
  286. /* ------------------------------------------------------------------------- */
  287. #if 0
  288. /* Use the newer ASN template code */
  289. #define WOLFSSL_ASN_TEMPLATE
  290. //#define WOLFSSL_CUSTOM_OID
  291. //#define HAVE_OID_ENCODING
  292. //#define HAVE_OID_DECODING
  293. #else
  294. /* Use the original custom ASN code */
  295. #endif
  296. /* Optionally disable time checking for ASN */
  297. //#define NO_ASN_TIME
  298. /* ------------------------------------------------------------------------- */
  299. /* Benchmark / Test */
  300. /* ------------------------------------------------------------------------- */
  301. /* Use reduced benchmark / test sizes */
  302. #define BENCH_EMBEDDED
  303. /* Use test buffers from array (not filesystem) */
  304. #ifndef NO_FILESYSTEM
  305. #define USE_CERT_BUFFERS_256
  306. #define USE_CERT_BUFFERS_2048
  307. #endif
  308. /* ------------------------------------------------------------------------- */
  309. /* Debugging */
  310. /* ------------------------------------------------------------------------- */
  311. #undef DEBUG_WOLFSSL
  312. #undef NO_ERROR_STRINGS
  313. #if 0
  314. #define DEBUG_WOLFSSL
  315. #define WOLFSSL_LOG_PRINTF
  316. #else
  317. #if 0
  318. #define NO_ERROR_STRINGS
  319. #endif
  320. #endif
  321. /* ------------------------------------------------------------------------- */
  322. /* Memory */
  323. /* ------------------------------------------------------------------------- */
  324. #if 0
  325. /* Static memory requires fast math or SP math with no malloc */
  326. #define WOLFSSL_STATIC_MEMORY
  327. /* Disable fallback malloc/free */
  328. #define WOLFSSL_NO_MALLOC
  329. #if 1
  330. #define WOLFSSL_MALLOC_CHECK /* trap malloc failure */
  331. #endif
  332. #endif
  333. /* ------------------------------------------------------------------------- */
  334. /* Enable Features */
  335. /* ------------------------------------------------------------------------- */
  336. #define WOLFSSL_TLS13
  337. #define WOLFSSL_OLD_PRIME_CHECK /* Use faster DH prime checking */
  338. #define HAVE_TLS_EXTENSIONS
  339. #define HAVE_SUPPORTED_CURVES
  340. #define WOLFSSL_BASE64_ENCODE
  341. //#define WOLFSSL_KEY_GEN /* For RSA Key gen only */
  342. //#define KEEP_PEER_CERT
  343. //#define HAVE_COMP_KEY
  344. /* TLS Session Cache */
  345. #if 0
  346. #define SMALL_SESSION_CACHE
  347. #else
  348. #define NO_SESSION_CACHE
  349. #endif
  350. /* ------------------------------------------------------------------------- */
  351. /* Disable Features */
  352. /* ------------------------------------------------------------------------- */
  353. //#define NO_WOLFSSL_SERVER
  354. //#define NO_WOLFSSL_CLIENT
  355. //#define NO_CRYPT_TEST
  356. //#define NO_CRYPT_BENCHMARK
  357. //#define WOLFCRYPT_ONLY
  358. /* In-lining of misc.c functions */
  359. /* If defined, must include wolfcrypt/src/misc.c in build */
  360. /* Slower, but about 1k smaller */
  361. //#define NO_INLINE
  362. #define NO_WRITEV
  363. #define NO_MAIN_DRIVER
  364. //#define NO_DEV_RANDOM
  365. #define NO_OLD_TLS
  366. #define NO_PSK
  367. #define NO_DSA
  368. #define NO_RC4
  369. #define NO_MD4
  370. #define NO_PWDBASED
  371. //#define NO_CODING
  372. //#define NO_CERTS
  373. //#define NO_SIG_WRAPPER
  374. #ifdef __cplusplus
  375. }
  376. #endif
  377. #endif /* WOLFSSL_USER_SETTINGS_H */