NetBurner 3.5.8
PDF Version
MON_RT11xx/user_settings.h
1
2#ifndef USER_SETTINGS_H
3#define USER_SETTINGS_H
4
5#include <predef.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11//#define DEBUG_WOLFSSL
12#include <endian.h>
13#define XHTONS(a) __htons(a)
14
15//#define WOLFSSL_CALLBACKS
16
17/* ------------------------------------------------------------------------- */
18/* Platform */
19/* ------------------------------------------------------------------------- */
20#undef WOLFSSL_GENERAL_ALIGNMENT
21#define WOLFSSL_GENERAL_ALIGNMENT 4
22
23/* Enable SSH KDF / extKeyUsage SSH bits used by the NetBurner SSH library */
24#define WOLFSSL_WOLFSSH
25
26/* Keep PQ off by default until size/perf measured */
27#define NO_MLKEM
28
29#undef SINGLE_THREADED
30//#define SINGLE_THREADED
31
32#undef WOLFSSL_SMALL_STACK
33#define WOLFSSL_SMALL_STACK
34
35#undef WOLFSSL_USER_IO
36#define WOLFSSL_USER_IO
37
38/* ------------------------------------------------------------------------- */
39/* Math Configuration */
40/* ------------------------------------------------------------------------- */
41#undef SIZEOF_LONG_LONG
42#define SIZEOF_LONG_LONG 8
43
44#undef USE_FAST_MATH
45#if 1
46 #define USE_FAST_MATH
47
48 #undef TFM_TIMING_RESISTANT
49 #define TFM_TIMING_RESISTANT
50
51 /* Optimizations */
52 //#define TFM_ARM
53#endif
54
55/* Wolf Single Precision Math */
56#undef WOLFSSL_SP
57#if 0
58 #define WOLFSSL_SP
59 #define WOLFSSL_SP_SMALL /* use smaller version of code */
60 #define WOLFSSL_HAVE_SP_RSA
61 #define WOLFSSL_HAVE_SP_DH
62 #define WOLFSSL_HAVE_SP_ECC
63 #define WOLFSSL_SP_CACHE_RESISTANT
64 //#define WOLFSSL_SP_MATH /* only SP math - eliminates fast math code */
65
66 /* 64 or 32 bit version */
67 //#define WOLFSSL_SP_ASM /* required if using the ASM versions */
68 //#define WOLFSSL_SP_ARM32_ASM
69 //#define WOLFSSL_SP_ARM64_ASM
70#endif
71
72/* ------------------------------------------------------------------------- */
73/* FIPS - Requires eval or license from wolfSSL */
74/* ------------------------------------------------------------------------- */
75#undef HAVE_FIPS
76#if 0
77 #define HAVE_FIPS
78
79 #undef HAVE_FIPS_VERSION
80 #define HAVE_FIPS_VERSION 2
81
82 #ifdef SINGLE_THREADED
83 #undef NO_THREAD_LS
84 #define NO_THREAD_LS
85 #endif
86#endif
87
88
89/* ------------------------------------------------------------------------- */
90/* Crypto */
91/* ------------------------------------------------------------------------- */
92/* RSA */
93#undef NO_RSA
94#if 1
95 #ifdef USE_FAST_MATH
96 /* Maximum math bits (Max RSA key bits * 2) */
97 #undef FP_MAX_BITS
98 #define FP_MAX_BITS 8192
99 #endif
100
101 /* half as much memory but twice as slow */
102 #undef RSA_LOW_MEM
103 //#define RSA_LOW_MEM
104
105 /* Enables blinding mode, to prevent timing attacks */
106 #if 1
107 #undef WC_RSA_BLINDING
108 #define WC_RSA_BLINDING
109 #else
110 #undef WC_NO_HARDEN
111 #define WC_NO_HARDEN
112 #endif
113
114 /* RSA PSS Support */
115 #if 1
116 #define WC_RSA_PSS
117 #endif
118
119 #if 1
120 #define WC_RSA_NO_PADDING
121 #endif
122#else
123 #define NO_RSA
124#endif
125
126/* ECC */
127#undef HAVE_ECC
128#if 1
129 #define HAVE_ECC
130
131 // Manually add support for curves.
132 #undef ECC_USER_CURVES
133 #define ECC_USER_CURVES
134
135 #ifdef ECC_USER_CURVES
136 /* Manual Curve Selection */
137 #define HAVE_ECC192 // For WolfSSL
138 #define HAVE_ECC224 // For WolfSSL
139 #undef NO_ECC256
140
141 // Added for specific curve support for WolfSSH
142 // To enable other curves, look at ecc_sets in wolfcrypt/src/ecc.c and add required defines.
143 // You will also need to make adjustments to wolfSSH_ProcessBuffer() where the curveId is checked.
144 #define ECC192
145 #define ECC224
146 #undef NO_ECC_SECP
147 #define HAVE_ECC_SECPR2
148 #define HAVE_ECC_SECPR3
149
150 #ifdef ENABLE_ECC384 // predef.h
151 #define HAVE_ECC384 // - Disabled until we can get better performance
152 #else
153 /* wolfSSL 5.9.1 preferredGroup[] in tls.c gates SECP384R1 on
154 * !NO_ECC384 (not on HAVE_ECC384), but TLSX_KeyShare_GenEccKey gates
155 * its switch arm on HAVE_ECC384. Without explicit NO_ECC384, TLS 1.3
156 * client advertises SECP384R1 then key gen returns BAD_FUNC_ARG. */
157 #define NO_ECC384
158 #endif
159
160 #ifdef ENABLE_ECC521 // predef.h
161 #define HAVE_ECC521 // - Disabled until we can get better performance
162 #else
163 /* Same preferredGroup vs. TLSX_KeyShare_GenEccKey asymmetry as
164 * NO_ECC384 above, but for SECP521R1. */
165 #define NO_ECC521
166 #endif
167
168 #ifdef ENABLE_ED25519 // predef.h
169 #define HAVE_ED25519 /* ED25519 Requires SHA512 */
170 #define HAVE_CURVE25519
171
172 /* Optionally use small math (less flash usage, but much slower) */
173 //#define CURVED25519_SMALL
174 #endif
175 #endif
176
177 /* Fixed point cache (speeds repeated operations against same private key) */
178 #undef FP_ECC
179 #define FP_ECC
180 #ifdef FP_ECC
181 /* Bits / Entries */
182 #undef FP_ENTRIES
183 #define FP_ENTRIES 15
184 #undef FP_LUT
185 #define FP_LUT 4
186 #endif
187
188 /* Optional ECC calculation method */
189 /* Note: doubles heap usage, but slightly faster */
190 #undef ECC_SHAMIR
191 #define ECC_SHAMIR
192
193 /* Reduces heap usage, but slower */
194 #undef ECC_TIMING_RESISTANT
195 //#define ECC_TIMING_RESISTANT // - Disabled for performance
196
197 /* Enable cofactor support */
198 #ifdef HAVE_FIPS
199 #undef HAVE_ECC_CDH
200 #define HAVE_ECC_CDH
201 #endif
202
203 /* Validate import */
204 #ifdef HAVE_FIPS
205 #undef WOLFSSL_VALIDATE_ECC_IMPORT
206 #define WOLFSSL_VALIDATE_ECC_IMPORT
207 #endif
208
209 /* Compressed Key Support */
210 #undef HAVE_COMP_KEY
211 //#define HAVE_COMP_KEY
212
213 /* Use alternate ECC size for ECC math */
214 #ifdef USE_FAST_MATH
215 #ifdef NO_RSA
216 /* Custom fastmath size if not using RSA */
217 /* MAX = ROUND32(ECC BITS 256) + SIZE_OF_MP_DIGIT(32) */
218 #undef FP_MAX_BITS
219 #define FP_MAX_BITS (256 + 32)
220 #else
221 #undef ALT_ECC_SIZE
222 #define ALT_ECC_SIZE
223 #endif
224
225 /* Speedups specific to curve */
226 #ifndef NO_ECC256
227 #undef TFM_ECC256
228 #define TFM_ECC256
229 #endif
230 #endif
231#endif
232
233/* DH */
234#undef NO_DH
235#if 1
236 /* Use table for DH instead of -lm (math) lib dependency */
237 #if 1
238 #define WOLFSSL_DH_CONST
239 #define HAVE_FFDHE_2048
240 #define HAVE_FFDHE_4096
241 //#define HAVE_FFDHE_6144
242 //#define HAVE_FFDHE_8192
243 #endif
244
245 #ifdef HAVE_FIPS
246 #define WOLFSSL_VALIDATE_FFC_IMPORT
247 #define HAVE_FFDHE_Q
248 #endif
249#else
250 #define NO_DH
251#endif
252
253
254/* AES */
255#undef NO_AES
256#if 1
257 #undef HAVE_AES_CBC
258 #define HAVE_AES_CBC
259
260 #define HAVE_AESGCM
261
262 /* GCM Method: GCM_TABLE_4BIT, GCM_SMALL, GCM_WORD32 or GCM_TABLE */
263 // Listed in order of speed and memory usage
264 // #define GCM_TABLE
265 #define GCM_WORD32
266 // #define GCM_TABLE_4BIT
267 // #define GCM_SMALL
268
269 #undef WOLFSSL_AES_DIRECT
270 //#define WOLFSSL_AES_DIRECT
271
272 #undef HAVE_AES_ECB
273 //#define HAVE_AES_ECB
274
275 #undef WOLFSSL_AES_COUNTER
276 //#define WOLFSSL_AES_COUNTER
277
278 #undef HAVE_AESCCM
279 #define HAVE_AESCCM
280#else
281 #define NO_AES
282#endif
283
284
285/* DES3 */
286#undef NO_DES3
287#if 1
288#else
289 #define NO_DES3
290#endif
291
292/* ChaCha20 / Poly1305 */
293//#undef HAVE_CHACHA
294//#undef HAVE_POLY1305
295//#if 0
296 #define HAVE_CHACHA
297 #define HAVE_POLY1305
298
299 /* Needed for Poly1305 */
300 #undef HAVE_ONE_TIME_AUTH
301 #define HAVE_ONE_TIME_AUTH
302//#endif
303
304/* Ed25519 / Curve25519 */
305//#undef HAVE_CURVE25519
306//#undef HAVE_ED25519
307//#if 0
308 #define HAVE_CURVE25519
309 #define HAVE_ED25519 /* ED25519 Requires SHA512 */
310
311 /* Optionally use small math (less flash usage, but much slower) */
312 #if 1
313 #define CURVED25519_SMALL
314 #endif
315//#endif
316
317
318/* ------------------------------------------------------------------------- */
319/* Hashing */
320/* ------------------------------------------------------------------------- */
321/* Sha */
322//#undef WOLFSSL_STATIC_RSA
323#if 1
324 /* 1k smaller, but 25% slower */
325 //#define USE_SLOW_SHA
326#else
327 #define NO_SHA
328#endif
329
330/* Sha256 */
331#undef NO_SHA256
332#if 1
333 /* not unrolled - ~2k smaller and ~25% slower */
334 //#define USE_SLOW_SHA256
335
336 /* Sha224 */
337 #if 0
338 #define WOLFSSL_SHA224
339 #endif
340#else
341 #define NO_SHA256
342#endif
343
344/* Sha512 */
345//#undef WOLFSSL_SHA512
346//#if 0
347 #define WOLFSSL_SHA512
348
349 /* Sha384 */
350 //#undef WOLFSSL_SHA384
351 //#if 0
352 #define WOLFSSL_SHA384
353 //#endif
354
355 /* over twice as small, but 50% slower */
356 //#define USE_SLOW_SHA512
357//#endif
358
359/* Sha3 */
360#undef WOLFSSL_SHA3
361#if 0
362 #define WOLFSSL_SHA3
363#endif
364
365/* MD5 */
366#undef NO_MD5
367#if 0
368
369#else
370 #define NO_MD5
371#endif
372
373/* HKDF */
374#undef HAVE_HKDF
375#if 1
376 #define HAVE_HKDF
377#endif
378
379/* CMAC */
380#undef WOLFSSL_CMAC
381#if 0
382 #define WOLFSSL_CMAC
383#endif
384
385
386/* ------------------------------------------------------------------------- */
387/* Benchmark / Test */
388/* ------------------------------------------------------------------------- */
389/* Use reduced benchmark / test sizes */
390#undef BENCH_EMBEDDED
391//#define BENCH_EMBEDDED
392
393#undef USE_CERT_BUFFERS_2048
394//#define USE_CERT_BUFFERS_2048
395
396#undef USE_CERT_BUFFERS_1024
397//#define USE_CERT_BUFFERS_1024
398
399#undef USE_CERT_BUFFERS_256
400//#define USE_CERT_BUFFERS_256
401
402
403/* ------------------------------------------------------------------------- */
404/* Debugging */
405/* ------------------------------------------------------------------------- */
406
407#undef DEBUG_WOLFSSL
408#undef NO_ERROR_STRINGS
409#if 0
410 #define DEBUG_WOLFSSL
411#else
412 #if 0
413 #define NO_ERROR_STRINGS
414 #endif
415#endif
416
417// Prints out the TLS secrets to the console, allowing for decryption of the TLS stream
418// #define SHOW_SECRETS
419// #define HAVE_SECRET_CALLBACK
420
421/* ------------------------------------------------------------------------- */
422/* Memory */
423/* ------------------------------------------------------------------------- */
424
425/* TLS SRAM pool size in KB for NBMalloc allocator */
426#define WOLFSSL_TLS_SRAM_KB 32
427
428/* Override Memory API's */
429#if 0
430 #undef XMALLOC_OVERRIDE
431 #define XMALLOC_OVERRIDE
432
433 /* prototypes for user heap override functions */
434 /* Note: Realloc only required for normal math */
435 #include <stddef.h> /* for size_t */
436 extern void *myMalloc(size_t n, void* heap, int type);
437 extern void myFree(void *p, void* heap, int type);
438 extern void *myRealloc(void *p, size_t n, void* heap, int type);
439
440 #define XMALLOC(n, h, t) myMalloc(n, h, t)
441 #define XFREE(p, h, t) myFree(p, h, t)
442 #define XREALLOC(p, n, h, t) myRealloc(p, n, h, t)
443#endif
444
445#if 1
446 /* Static memory requires fast math */
447 #define WOLFSSL_STATIC_MEMORY
448
449 /* Disable fallback malloc/free */
450 #define WOLFSSL_NO_MALLOC
451 #if 0
452 #define WOLFSSL_MALLOC_CHECK /* trap malloc failure */
453 #endif
454#endif
455
456/* Memory callbacks */
457#if 0
458 #undef USE_WOLFSSL_MEMORY
459 #define USE_WOLFSSL_MEMORY
460
461 /* Use this to measure / print heap usage */
462 #if 1
463 #undef WOLFSSL_TRACK_MEMORY
464 #define WOLFSSL_TRACK_MEMORY
465
466 #undef WOLFSSL_DEBUG_MEMORY
467 #define WOLFSSL_DEBUG_MEMORY
468 #endif
469#else
470 #ifndef WOLFSSL_STATIC_MEMORY
471 #define NO_WOLFSSL_MEMORY
472 /* Otherwise we will use stdlib malloc, free and realloc */
473 #endif
474#endif
475
476
477/* ------------------------------------------------------------------------- */
478/* Port */
479/* ------------------------------------------------------------------------- */
480
481/* Override Current Time */
482/* Allows custom "custom_time()" function to be used for benchmark */
483#define WOLFSSL_USER_CURRTIME
484#define WOLFSSL_GMTIME
485#define USER_TICKS
486extern unsigned long my_time(unsigned long* timer);
487#define XTIME my_time
488
489
490/* ------------------------------------------------------------------------- */
491/* RNG */
492/* ------------------------------------------------------------------------- */
493
494/* Seed Source */
495/* Size of returned HW RNG value */
496#define CUSTOM_RAND_TYPE unsigned int
497extern unsigned int my_rng_seed_gen(void);
498#undef CUSTOM_RAND_GENERATE
499#define CUSTOM_RAND_GENERATE my_rng_seed_gen
500
501// NetBurner specific define for enabling hardware random number generation for M7
502#define GATHER_RANDOM_USE_HW
503
504/* Choose RNG method */
505#if 1
506 /* Use built-in P-RNG (SHA256 based) with HW RNG */
507 /* P-RNG + HW RNG (P-RNG is ~8K) */
508 #undef HAVE_HASHDRBG
509 //#define HAVE_HASHDRBG
510#else
511 #undef WC_NO_HASHDRBG
512 #define WC_NO_HASHDRBG
513
514 /* Bypass P-RNG and use only HW RNG */
515 extern int my_rng_gen_block(unsigned char* output, unsigned int sz);
516 #undef CUSTOM_RAND_GENERATE_BLOCK
517 #define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block
518#endif
519
520
521/* ------------------------------------------------------------------------- */
522/* Custom Standard Lib */
523/* ------------------------------------------------------------------------- */
524/* Allows override of all standard library functions */
525#undef STRING_USER
526#if 0
527 #define STRING_USER
528
529 #include <string.h>
530
531 #undef USE_WOLF_STRSEP
532 #define USE_WOLF_STRSEP
533 #define XSTRSEP(s1,d) wc_strsep((s1),(d))
534
535 #undef USE_WOLF_STRTOK
536 #define USE_WOLF_STRTOK
537 #define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr))
538
539 #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
540
541 #define XMEMCPY(d,s,l) memcpy((d),(s),(l))
542 #define XMEMSET(b,c,l) memset((b),(c),(l))
543 #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
544 #define XMEMMOVE(d,s,l) memmove((d),(s),(l))
545
546 #define XSTRLEN(s1) strlen((s1))
547 #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
548 #define XSTRSTR(s1,s2) strstr((s1),(s2))
549
550 #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
551 #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
552 #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
553
554 #define XSNPRINTF snprintf
555#endif
556
557
558
559/* ------------------------------------------------------------------------- */
560/* Enable Features */
561/* ------------------------------------------------------------------------- */
562#ifdef SSL_TLS_1_3_SUPPORT // defined in predef.h
563#define WOLFSSL_TLS13
564#endif
565
566#undef WOLFSSL_KEY_GEN
567#if 1
568 #define WOLFSSL_KEY_GEN
569#endif
570
571#if defined(HAVE_FIPS) && !defined(WOLFSSL_KEY_GEN)
572 #define WOLFSSL_OLD_PRIME_CHECK
573#endif
574
575#undef KEEP_PEER_CERT
576#define KEEP_PEER_CERT
577
578#undef HAVE_COMP_KEY
579//#define HAVE_COMP_KEY
580
581#undef HAVE_TLS_EXTENSIONS
582#define HAVE_TLS_EXTENSIONS
583
584#undef HAVE_SUPPORTED_CURVES
585#define HAVE_SUPPORTED_CURVES
586
587#undef WOLFSSL_BASE64_ENCODE
588#define WOLFSSL_BASE64_ENCODE
589
590#define SMALL_SESSION_CACHE
591 #define NO_SESSION_CACHE_REF
592#define HAVE_SESSION_TICKET
593
594/* ------------------------------------------------------------------------- */
595/* Disable Features */
596/* ------------------------------------------------------------------------- */
597#undef NO_WOLFSSL_SERVER
598//#define NO_WOLFSSL_SERVER
599
600#undef NO_WOLFSSL_CLIENT
601//#define NO_WOLFSSL_CLIENT
602
603#undef NO_CRYPT_TEST
604//#define NO_CRYPT_TEST
605
606#undef NO_CRYPT_BENCHMARK
607//#define NO_CRYPT_BENCHMARK
608
609#undef WOLFCRYPT_ONLY
610//#define WOLFCRYPT_ONLY
611
612// Allows WolfSSL to malloc the tls 1.3 ticket nonce, instead of using a static buffer. This supports large ticket nonces
613#define WOLFSSL_TICKET_NONCE_MALLOC
614
615/* In-lining of misc.c functions */
616/* If defined, must include wolfcrypt/src/misc.c in build */
617/* Slower, but about 1k smaller */
618#undef NO_INLINE
619//#define NO_INLINE
620
621#undef WOLFSSL_NO_SOCK
622#define WOLFSSL_NO_SOCK
623
624#undef NO_WOLFSSL_DIR
625#define NO_WOLFSSL_DIR
626
627#undef NO_FILESYSTEM
628#define NO_FILESYSTEM
629
630#undef NO_WRITEV
631#define NO_WRITEV
632
633#undef NO_MAIN_DRIVER
634#define NO_MAIN_DRIVER
635
636#undef NO_DEV_RANDOM
637#define NO_DEV_RANDOM
638
639#undef NO_DSA
640#define NO_DSA
641
642#undef NO_RC4
643//#define NO_RC4
644
645#undef NO_OLD_TLS
646#define NO_OLD_TLS
647
648#undef NO_HC128
649#define NO_HC128
650
651#undef NO_RABBIT
652#define NO_RABBIT
653
654#undef NO_PSK
655#define NO_PSK
656
657#undef NO_MD4
658#define NO_MD4
659
660#undef NO_PWDBASED
661#define NO_PWDBASED
662
663#undef NO_CODING
664//#define NO_CODING
665
666#undef NO_ASN_TIME
667//#define NO_ASN_TIME
668
669#undef NO_CERTS
670//#define NO_CERTS
671
672#undef NO_SIG_WRAPPER
673//#define NO_SIG_WRAPPER
674
675#undef NO_TLS
676
677// Settings made for compatibility
678#define WOLFSSL_STATIC_RSA // Needed to support TLS_RSA_WITH_AES_128_CBC_SHA
679#define WOLFSSL_AES_128 // Needed to support TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA256
680#define WOLFSSL_AES_256 // Needed to support TLS_RSA_WITH_AES_256_CBC_SHA256
681#define WOLFSSL_STATIC_DH // Needed to support TLS_ECDH_ECDSA_WITH_RC4_128_SHA
682
683#define WOLFSSL_CERT_REQ
684#define WOLFSSL_CERT_GEN
685#define WOLFSSL_ALT_NAMES
686#define WOLFSSL_DER_TO_PEM
687#define WOLFSSL_KEY_GEN
688#define WOLFSSL_EITHER_SIDE
689
690#define ENABLE_ECCKEY_CREATE // Custom define, maybe should move to predef?
691#define ENABLE_RSAKEY_CREATE // Custom define, maybe should move to predef?
692
693// For wolfSSH
694//#undef WOLFSSH_SFTP
695//#define WOLFSSH_SFTP
696
697//#undef WOLFSSH_SCP
698//#define WOLFSSH_SCP
699
700#undef WOLFSSH_USER_IO
701#define WOLFSSH_USER_IO
702
703#ifdef __cplusplus
704}
705#endif
706
707#endif /* WOLFSSL_USER_SETTINGS_H */
708