user_settings.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. /* Example custom user settings for wolfSSL */
  2. #ifndef WOLFSSL_USER_SETTINGS_H
  3. #define WOLFSSL_USER_SETTINGS_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include <stddef.h> /* for size_t */
  8. /* ------------------------------------------------------------------------- */
  9. /* Platform */
  10. /* ------------------------------------------------------------------------- */
  11. #undef WOLFSSL_GENERAL_ALIGNMENT
  12. #define WOLFSSL_GENERAL_ALIGNMENT 4
  13. #undef SINGLE_THREADED
  14. #define SINGLE_THREADED
  15. #undef WOLFSSL_SMALL_STACK
  16. #define WOLFSSL_SMALL_STACK
  17. /* ------------------------------------------------------------------------- */
  18. /* Math Configuration */
  19. /* ------------------------------------------------------------------------- */
  20. #undef USE_FAST_MATH
  21. #define USE_FAST_MATH
  22. #ifdef USE_FAST_MATH
  23. #undef TFM_TIMING_RESISTANT
  24. #define TFM_TIMING_RESISTANT
  25. /* Optimizations (TFM_ARM, TFM_ASM or none) */
  26. #define TFM_ARM
  27. //#define TFM_ASM
  28. #endif
  29. /* Math debugging (adds support for mp_dump) */
  30. #undef WOLFSSL_DEBUG_MATH
  31. //#define WOLFSSL_DEBUG_MATH
  32. /* ------------------------------------------------------------------------- */
  33. /* Crypto */
  34. /* ------------------------------------------------------------------------- */
  35. /* ECC */
  36. #if 1
  37. #undef HAVE_ECC
  38. #define HAVE_ECC
  39. /* Manually define enabled curves */
  40. #undef ECC_USER_CURVES
  41. #define ECC_USER_CURVES
  42. #define HAVE_ECC192
  43. #define HAVE_ECC224
  44. #undef NO_ECC256
  45. #define HAVE_ECC384
  46. #ifndef USE_NXP_LTC /* NXP LTC HW supports up to 512 */
  47. #define HAVE_ECC521
  48. #endif
  49. /* Fixed point cache (speeds repeated operations against same private key) */
  50. #undef FP_ECC
  51. //#define FP_ECC
  52. #ifdef FP_ECC
  53. /* Bits / Entries */
  54. #undef FP_ENTRIES
  55. #define FP_ENTRIES 2
  56. #undef FP_LUT
  57. #define FP_LUT 4
  58. #endif
  59. /* Optional ECC calculation method */
  60. /* Note: doubles heap usage, but slightly faster */
  61. #undef ECC_SHAMIR
  62. #ifndef USE_NXP_LTC /* Don't enable Shamir code for HW ECC */
  63. #define ECC_SHAMIR
  64. #endif
  65. /* Reduces heap usage, but slower */
  66. #undef ECC_TIMING_RESISTANT
  67. #define ECC_TIMING_RESISTANT
  68. #ifdef USE_FAST_MATH
  69. /* use reduced size math buffers for ecc points */
  70. #undef ALT_ECC_SIZE
  71. #define ALT_ECC_SIZE
  72. /* Enable TFM optimizations for ECC */
  73. #if defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)
  74. #define TFM_ECC192
  75. #endif
  76. #if defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)
  77. #define TFM_ECC224
  78. #endif
  79. #if !defined(NO_ECC256) || defined(HAVE_ALL_CURVES)
  80. #define TFM_ECC256
  81. #endif
  82. #if defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)
  83. #define TFM_ECC384
  84. #endif
  85. #if defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)
  86. #define TFM_ECC521
  87. #endif
  88. #endif
  89. #endif
  90. /* RSA */
  91. #undef NO_RSA
  92. #if 1
  93. #ifdef USE_FAST_MATH
  94. /* Maximum math bits (Max RSA key bits * 2) */
  95. #undef FP_MAX_BITS
  96. #define FP_MAX_BITS 4096
  97. #endif
  98. /* half as much memory but twice as slow */
  99. #undef RSA_LOW_MEM
  100. //#define RSA_LOW_MEM
  101. /* Enables blinding mode, to prevent timing attacks */
  102. #undef WC_RSA_BLINDING
  103. #define WC_RSA_BLINDING
  104. #else
  105. #define NO_RSA
  106. #endif
  107. /* AES */
  108. #undef NO_AES
  109. #if 1
  110. #undef HAVE_AESGCM
  111. #define HAVE_AESGCM
  112. /* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */
  113. #undef GCM_SMALL
  114. #define GCM_SMALL
  115. #else
  116. #define NO_AES
  117. #endif
  118. /* ChaCha20 / Poly1305 */
  119. #undef HAVE_CHACHA
  120. #undef HAVE_POLY1305
  121. #if 1
  122. #define HAVE_CHACHA
  123. #define HAVE_POLY1305
  124. /* Needed for Poly1305 */
  125. #undef HAVE_ONE_TIME_AUTH
  126. #define HAVE_ONE_TIME_AUTH
  127. #endif
  128. /* Ed25519 / Curve25519 */
  129. #undef HAVE_CURVE25519
  130. #undef HAVE_ED25519
  131. #if 1
  132. #define HAVE_CURVE25519
  133. #define HAVE_ED25519
  134. /* Optionally use small math (less flash usage, but much slower) */
  135. #if 0
  136. #define CURVED25519_SMALL
  137. #endif
  138. #endif
  139. /* ------------------------------------------------------------------------- */
  140. /* Hashing */
  141. /* ------------------------------------------------------------------------- */
  142. /* Sha */
  143. #undef NO_SHA
  144. #if 1
  145. /* 1k smaller, but 25% slower */
  146. //#define USE_SLOW_SHA
  147. #else
  148. #define NO_SHA
  149. #endif
  150. /* Sha256 */
  151. #undef NO_SHA256
  152. #if 1
  153. #else
  154. #define NO_SHA256
  155. #endif
  156. /* Sha512 */
  157. #undef WOLFSSL_SHA512
  158. #if 1
  159. #define WOLFSSL_SHA512
  160. /* Sha384 */
  161. #undef WOLFSSL_SHA384
  162. #if 1
  163. #define WOLFSSL_SHA384
  164. #endif
  165. /* over twice as small, but 50% slower */
  166. //#define USE_SLOW_SHA2
  167. #endif
  168. /* MD5 */
  169. #undef NO_MD5
  170. #if 1
  171. #define NO_MD5
  172. #endif
  173. /* ------------------------------------------------------------------------- */
  174. /* HW Crypto Acceleration */
  175. /* ------------------------------------------------------------------------- */
  176. #define FSL_HW_CRYPTO_MANUAL_SELECTION
  177. #if 1
  178. /* NXP MMCAU / LTC Support (See README.md for instructions) */
  179. #if defined(USE_NXP_MMCAU) || defined(USE_NXP_LTC)
  180. #ifdef USE_NXP_MMCAU
  181. #define FREESCALE_USE_MMCAU
  182. #endif
  183. #ifdef USE_NXP_LTC
  184. #define FREESCALE_USE_LTC
  185. #define LTC_MAX_ECC_BITS (512)
  186. #define LTC_MAX_INT_BYTES (256)
  187. //#define FREESCALE_LTC_TFM_RSA_4096_ENABLE
  188. #endif
  189. #endif
  190. #endif
  191. /* ------------------------------------------------------------------------- */
  192. /* Benchmark / Test */
  193. /* ------------------------------------------------------------------------- */
  194. /* Use reduced benchmark / test sizes */
  195. #undef BENCH_EMBEDDED
  196. #define BENCH_EMBEDDED
  197. #undef USE_CERT_BUFFERS_2048
  198. #define USE_CERT_BUFFERS_2048
  199. #undef USE_CERT_BUFFERS_256
  200. #define USE_CERT_BUFFERS_256
  201. /* ------------------------------------------------------------------------- */
  202. /* Debugging */
  203. /* ------------------------------------------------------------------------- */
  204. #undef DEBUG_WOLFSSL
  205. //#define DEBUG_WOLFSSL
  206. #ifdef DEBUG_WOLFSSL
  207. #define fprintf(file, format, ...) printf(format, ##__VA_ARGS__)
  208. /* Use this to measure / print heap usage */
  209. #if 0
  210. #undef USE_WOLFSSL_MEMORY
  211. #define USE_WOLFSSL_MEMORY
  212. #undef WOLFSSL_TRACK_MEMORY
  213. #define WOLFSSL_TRACK_MEMORY
  214. #endif
  215. #else
  216. #undef NO_WOLFSSL_MEMORY
  217. #define NO_WOLFSSL_MEMORY
  218. #undef NO_ERROR_STRINGS
  219. //#define NO_ERROR_STRINGS
  220. #endif
  221. /* ------------------------------------------------------------------------- */
  222. /* Port */
  223. /* ------------------------------------------------------------------------- */
  224. /* Override Current Time */
  225. /* Allows custom "custom_time()" function to be used for benchmark */
  226. #define WOLFSSL_USER_CURRTIME
  227. #define USER_TICKS
  228. extern unsigned long ksdk_time(unsigned long* timer);
  229. #define XTIME ksdk_time
  230. /* ------------------------------------------------------------------------- */
  231. /* RNG */
  232. /* ------------------------------------------------------------------------- */
  233. /* Size of returned HW RNG value */
  234. #define CUSTOM_RAND_TYPE unsigned int
  235. /* Seed source */
  236. extern unsigned int custom_rand_generate(void);
  237. #undef CUSTOM_RAND_GENERATE
  238. #define CUSTOM_RAND_GENERATE custom_rand_generate
  239. /* Choose RNG method */
  240. #if 1
  241. /* Use built-in P-RNG (SHA256 based) with HW RNG */
  242. /* P-RNG + HW RNG (P-RNG is ~8K) */
  243. #undef HAVE_HASHDRBG
  244. #define HAVE_HASHDRBG
  245. #else
  246. #undef WC_NO_HASHDRBG
  247. #define WC_NO_HASHDRBG
  248. /* Bypass P-RNG and use only HW RNG */
  249. extern int custom_rand_generate_block(unsigned char* output, unsigned int sz);
  250. #undef CUSTOM_RAND_GENERATE_BLOCK
  251. #define CUSTOM_RAND_GENERATE_BLOCK custom_rand_generate_block
  252. #endif
  253. /* ------------------------------------------------------------------------- */
  254. /* Enable Features */
  255. /* ------------------------------------------------------------------------- */
  256. #undef KEEP_PEER_CERT
  257. //#define KEEP_PEER_CERT
  258. #undef HAVE_COMP_KEY
  259. //#define HAVE_COMP_KEY
  260. #undef HAVE_TLS_EXTENSIONS
  261. //#define HAVE_TLS_EXTENSIONS
  262. #undef HAVE_SUPPORTED_CURVES
  263. //#define HAVE_SUPPORTED_CURVES
  264. #undef WOLFSSL_BASE64_ENCODE
  265. //#define WOLFSSL_BASE64_ENCODE
  266. /* TLS Session Cache */
  267. #if 0
  268. #define SMALL_SESSION_CACHE
  269. #else
  270. #define NO_SESSION_CACHE
  271. #endif
  272. /* ------------------------------------------------------------------------- */
  273. /* Disable Features */
  274. /* ------------------------------------------------------------------------- */
  275. #undef NO_WOLFSSL_SERVER
  276. //#define NO_WOLFSSL_SERVER
  277. #undef NO_WOLFSSL_CLIENT
  278. //#define NO_WOLFSSL_CLIENT
  279. #undef NO_CRYPT_TEST
  280. //#define NO_CRYPT_TEST
  281. #undef NO_CRYPT_BENCHMARK
  282. //#define NO_CRYPT_BENCHMARK
  283. /* In-lining of misc.c functions */
  284. /* If defined, must include wolfcrypt/src/misc.c in build */
  285. /* Slower, but about 1k smaller */
  286. #undef NO_INLINE
  287. //#define NO_INLINE
  288. #undef NO_FILESYSTEM
  289. #define NO_FILESYSTEM
  290. #undef NO_WRITEV
  291. #define NO_WRITEV
  292. #undef NO_MAIN_DRIVER
  293. #define NO_MAIN_DRIVER
  294. #undef NO_DEV_RANDOM
  295. #define NO_DEV_RANDOM
  296. #undef NO_DSA
  297. #define NO_DSA
  298. #undef NO_DH
  299. #define NO_DH
  300. #undef NO_DES3
  301. #define NO_DES3
  302. #undef NO_RC4
  303. #define NO_RC4
  304. #undef NO_OLD_TLS
  305. #define NO_OLD_TLS
  306. #undef NO_HC128
  307. #define NO_HC128
  308. #undef NO_RABBIT
  309. #define NO_RABBIT
  310. #undef NO_PSK
  311. #define NO_PSK
  312. #undef NO_MD4
  313. #define NO_MD4
  314. #undef NO_PWDBASED
  315. #define NO_PWDBASED
  316. #undef NO_CODING
  317. #define NO_CODING
  318. #ifdef __cplusplus
  319. }
  320. #endif
  321. #endif /* WOLFSSL_USER_SETTINGS_H */