forked from boschresearch/pq-wolfSSL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.h
2571 lines (2232 loc) · 73.8 KB
/
settings.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* settings.h
*
* Copyright (C) 2006-2020 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
/*
* Modified by: Yulia Kuzovkova (CR/APA3), Robert Bosch GmbH, 2021
* This file was modified due to the integration of post-quantum cryptography
* into wolfSSL library.
* This work has been partially founded by the German Federal Ministry of Education
* and Research (BMBF) under the project FLOQI (ID 16KIS1074).
*/
/* Place OS specific preprocessor flags, defines, includes here, will be
included into every file because types.h includes it */
#ifndef WOLF_CRYPT_SETTINGS_H
#define WOLF_CRYPT_SETTINGS_H
#ifdef __cplusplus
extern "C" {
#endif
/* This flag allows wolfSSL to include options.h instead of having client
* projects do it themselves. This should *NEVER* be defined when building
* wolfSSL as it can cause hard to debug problems. */
#ifdef EXTERNAL_OPTS_OPENVPN
#include <wolfssl/options.h>
#endif
/* PQ-wolfSSL settings */
#ifdef HAVE_KYBER
#define KYBER_MODE 1 /* available modes 1, 3 */
#endif
#ifdef HAVE_DILITHIUM
#define DILITHIUM_MODE 2 /* available modes 2, 3 */
//#define DILITHIUM_MODE 3
#endif
#ifdef HAVE_FALCON
#define FALCON_MODE 1
//#define FALCON_MODE 5 /* available modes 1, 5 */
#endif
#ifdef HAVE_SPHINCS
#define SPX_TYPE SHA256_128F_SIMPLE
#define SPX_TYPE SHA256_128S_SIMPLE
//#define SPX_TYPE SHA256_192F_SIMPLE
//#define SPX_TYPE SHA256_192S_SIMPLE
/* available types SHA256_128S_SIMPLE, SHA256_192S_SIMPLE */
#define SPX_MODE 1 /* available modes 1, 3 */
#endif
#ifdef HAVE_XMSS
#define XMSS_MODE 1 /* available modes 1, 5 */
//#define XMSS_MODE 5
#endif
#ifdef HAVE_ECC
#define ECC_MODE 1 /* available modes 1, 3 */
/* Set curves */
#if ECC_MODE == 1
#define ECC_CURVE_SZ 32 /* SECP256R1 curve size in bytes */
#define ECC_CURVE_ID ECC_SECP256R1
#elif ECC_MODE == 3
#define ECC_CURVE_SZ 48 /* SECP384R1 curve size in bytes */
#define ECC_CURVE_ID ECC_SECP384R1
#endif
#endif
#ifndef WOLFSSL_CERT_EXT
#define WOLFSSL_CERT_EXT
#endif
/* Uncomment next line if using IPHONE */
/* #define IPHONE */
/* Uncomment next line if using ThreadX */
/* #define THREADX */
/* Uncomment next line if using Micrium uC/OS-III */
/* #define MICRIUM */
/* Uncomment next line if using Deos RTOS*/
/* #define WOLFSSL_DEOS*/
/* Uncomment next line if using Mbed */
/* #define MBED */
/* Uncomment next line if using Microchip PIC32 ethernet starter kit */
/* #define MICROCHIP_PIC32 */
/* Uncomment next line if using Microchip TCP/IP stack, version 5 */
/* #define MICROCHIP_TCPIP_V5 */
/* Uncomment next line if using Microchip TCP/IP stack, version 6 or later */
/* #define MICROCHIP_TCPIP */
/* Uncomment next line if using above Microchip TCP/IP defines with BSD API */
/* #define MICROCHIP_TCPIP_BSD_API */
/* Uncomment next line if using PIC32MZ Crypto Engine */
/* #define WOLFSSL_MICROCHIP_PIC32MZ */
/* Uncomment next line if using FreeRTOS */
/* #define FREERTOS */
/* Uncomment next line if using FreeRTOS+ TCP */
/* #define FREERTOS_TCP */
/* Uncomment next line if using FreeRTOS Windows Simulator */
/* #define FREERTOS_WINSIM */
/* Uncomment next line if using RTIP */
/* #define EBSNET */
/* Uncomment next line if using lwip */
/* #define WOLFSSL_LWIP */
/* Uncomment next line if building wolfSSL for a game console */
/* #define WOLFSSL_GAME_BUILD */
/* Uncomment next line if building wolfSSL for LSR */
/* #define WOLFSSL_LSR */
/* Uncomment next line if building for Freescale Classic MQX version 5.0 */
/* #define FREESCALE_MQX_5_0 */
/* Uncomment next line if building for Freescale Classic MQX version 4.0 */
/* #define FREESCALE_MQX_4_0 */
/* Uncomment next line if building for Freescale Classic MQX/RTCS/MFS */
/* #define FREESCALE_MQX */
/* Uncomment next line if building for Freescale KSDK MQX/RTCS/MFS */
/* #define FREESCALE_KSDK_MQX */
/* Uncomment next line if building for Freescale KSDK Bare Metal */
/* #define FREESCALE_KSDK_BM */
/* Uncomment next line if building for Freescale KSDK FreeRTOS, */
/* (old name FREESCALE_FREE_RTOS) */
/* #define FREESCALE_KSDK_FREERTOS */
/* Uncomment next line if using STM32F2 */
/* #define WOLFSSL_STM32F2 */
/* Uncomment next line if using STM32F4 */
/* #define WOLFSSL_STM32F4 */
/* Uncomment next line if using STM32FL */
/* #define WOLFSSL_STM32FL */
/* Uncomment next line if using STM32F7 */
/* #define WOLFSSL_STM32F7 */
/* Uncomment next line if using QL SEP settings */
/* #define WOLFSSL_QL */
/* Uncomment next line if building for EROAD */
/* #define WOLFSSL_EROAD */
/* Uncomment next line if building for IAR EWARM */
/* #define WOLFSSL_IAR_ARM */
/* Uncomment next line if building for Rowley CrossWorks ARM */
/* #define WOLFSSL_ROWLEY_ARM */
/* Uncomment next line if using TI-RTOS settings */
/* #define WOLFSSL_TIRTOS */
/* Uncomment next line if building with PicoTCP */
/* #define WOLFSSL_PICOTCP */
/* Uncomment next line if building for PicoTCP demo bundle */
/* #define WOLFSSL_PICOTCP_DEMO */
/* Uncomment next line if building for uITRON4 */
/* #define WOLFSSL_uITRON4 */
/* Uncomment next line if building for uT-Kernel */
/* #define WOLFSSL_uTKERNEL2 */
/* Uncomment next line if using Max Strength build */
/* #define WOLFSSL_MAX_STRENGTH */
/* Uncomment next line if building for VxWorks */
/* #define WOLFSSL_VXWORKS */
/* Uncomment next line if building for Nordic nRF5x platform */
/* #define WOLFSSL_NRF5x */
/* Uncomment next line to enable deprecated less secure static DH suites */
/* #define WOLFSSL_STATIC_DH */
/* Uncomment next line to enable deprecated less secure static RSA suites */
/* #define WOLFSSL_STATIC_RSA */
/* Uncomment next line if building for ARDUINO */
/* Uncomment both lines if building for ARDUINO on INTEL_GALILEO */
/* #define WOLFSSL_ARDUINO */
/* #define INTEL_GALILEO */
/* Uncomment next line to enable asynchronous crypto WC_PENDING_E */
/* #define WOLFSSL_ASYNC_CRYPT */
/* Uncomment next line if building for uTasker */
/* #define WOLFSSL_UTASKER */
/* Uncomment next line if building for embOS */
/* #define WOLFSSL_EMBOS */
/* Uncomment next line if building for RIOT-OS */
/* #define WOLFSSL_RIOT_OS */
/* Uncomment next line if building for using XILINX hardened crypto */
/* #define WOLFSSL_XILINX_CRYPT */
/* Uncomment next line if building for using XILINX */
/* #define WOLFSSL_XILINX */
/* Uncomment next line if building for WICED Studio. */
/* #define WOLFSSL_WICED */
/* Uncomment next line if building for Nucleus 1.2 */
/* #define WOLFSSL_NUCLEUS_1_2 */
/* Uncomment next line if building for using Apache mynewt */
/* #define WOLFSSL_APACHE_MYNEWT */
/* Uncomment next line if building for using ESP-IDF */
/* #define WOLFSSL_ESPIDF */
/* Uncomment next line if using Espressif ESP32-WROOM-32 */
/* #define WOLFSSL_ESPWROOM32 */
/* Uncomment next line if using Espressif ESP32-WROOM-32SE */
/* #define WOLFSSL_ESPWROOM32SE */
/* Uncomment next line if using ARM CRYPTOCELL*/
/* #define WOLFSSL_CRYPTOCELL */
/* Uncomment next line if using RENESAS TSIP */
/* #define WOLFSSL_RENESAS_TSIP */
/* Uncomment next line if using RENESAS RX64N */
/* #define WOLFSSL_RENESAS_RX65N */
/* Uncomment next line if using Solaris OS*/
/* #define WOLFSSL_SOLARIS */
/* Uncomment next line if building for Linux Kernel Module */
/* #define WOLFSSL_LINUXKM */
#include <wolfssl/wolfcrypt/visibility.h>
#ifdef WOLFSSL_USER_SETTINGS
#include "user_settings.h"
#elif defined(USE_HAL_DRIVER) && !defined(HAVE_CONFIG_H)
/* STM Configuration File (generated by CubeMX) */
#include "wolfSSL.I-CUBE-wolfSSL_conf.h"
#endif
/* make sure old RNG name is used with CTaoCrypt FIPS */
#ifdef HAVE_FIPS
#if !defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)
#define WC_RNG RNG
#else
#ifndef WOLFSSL_STM32L4
#define RNG WC_RNG
#endif
#endif
/* blinding adds API not available yet in FIPS mode */
#undef WC_RSA_BLINDING
#endif
#if defined(_WIN32) && !defined(_M_X64) && \
defined(HAVE_AESGCM) && defined(WOLFSSL_AESNI)
/* The _M_X64 macro is what's used in the headers for MSC to tell if it
* has the 64-bit versions of the 128-bit integers available. If one is
* building on 32-bit Windows with AES-NI, turn off the AES-GCMloop
* unrolling. */
#define AES_GCM_AESNI_NO_UNROLL
#endif
#ifdef IPHONE
#define SIZEOF_LONG_LONG 8
#endif
#ifdef THREADX
#define SIZEOF_LONG_LONG 8
#endif
#ifdef HAVE_NETX
#ifdef NEED_THREADX_TYPES
#include <types.h>
#endif
#include <nx_api.h>
#endif
#if defined(WOLFSSL_ESPIDF)
#define FREERTOS
#define WOLFSSL_LWIP
#define NO_WRITEV
#define SIZEOF_LONG_LONG 8
#define NO_WOLFSSL_DIR
#define WOLFSSL_NO_CURRDIR
#define TFM_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT
#define WC_RSA_BLINDING
#if defined(WOLFSSL_ESPWROOM32) || defined(WOLFSSL_ESPWROOM32SE)
#ifndef NO_ESP32WROOM32_CRYPT
#define WOLFSSL_ESP32WROOM32_CRYPT
#if defined(ESP32_USE_RSA_PRIMITIVE) && \
!defined(NO_WOLFSSL_ESP32WROOM32_CRYPT_RSA_PRI)
#define WOLFSSL_ESP32WROOM32_CRYPT_RSA_PRI
#define USE_FAST_MATH
#define WOLFSSL_SMALL_STACK
#endif
#endif
#endif
#endif /* WOLFSSL_ESPIDF */
#if defined(WOLFSSL_RENESAS_TSIP)
#define TSIP_TLS_HMAC_KEY_INDEX_WORDSIZE 64
#define TSIP_TLS_MASTERSECRET_SIZE 80 /* 20 words */
#define TSIP_TLS_ENCPUBKEY_SZ_BY_CERTVRFY 560 /* in byte */
#if !defined(NO_RENESAS_TSIP_CRYPT) && defined(WOLFSSL_RENESAS_RX65N)
#define WOLFSSL_RENESAS_TSIP_CRYPT
#define WOLFSSL_RENESAS_TSIP_TLS
#define WOLFSSL_RENESAS_TSIP_TLS_AES_CRYPT
#endif
#endif
#if defined(WOLFSSL_RENESAS_RA6M3G) || defined(WOLFSSL_RENESAS_RA6M3)
/* settings in user_settings.h */
#endif
#if defined(HAVE_LWIP_NATIVE) /* using LwIP native TCP socket */
#define WOLFSSL_LWIP
#define NO_WRITEV
#define SINGLE_THREADED
#define WOLFSSL_USER_IO
#define NO_FILESYSTEM
#endif
#if defined(WOLFSSL_CONTIKI)
#include <contiki.h>
#define WOLFSSL_UIP
#define NO_WOLFSSL_MEMORY
#define NO_WRITEV
#define SINGLE_THREADED
#define WOLFSSL_USER_IO
#define NO_FILESYSTEM
#define CUSTOM_RAND_TYPE uint16_t
#define CUSTOM_RAND_GENERATE random_rand
static inline word32 LowResTimer(void)
{
return clock_seconds();
}
#endif
#if defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_ROWLEY_ARM)
#define NO_MAIN_DRIVER
#define SINGLE_THREADED
#if !defined(USE_CERT_BUFFERS_2048) && !defined(USE_CERT_BUFFERS_4096)
#define USE_CERT_BUFFERS_1024
#endif
#define BENCH_EMBEDDED
#define NO_FILESYSTEM
#define NO_WRITEV
#define WOLFSSL_USER_IO
#define BENCH_EMBEDDED
#endif
#ifdef MICROCHIP_PIC32
/* #define WOLFSSL_MICROCHIP_PIC32MZ */
#define SIZEOF_LONG_LONG 8
#define SINGLE_THREADED
#ifndef MICROCHIP_TCPIP_BSD_API
#define WOLFSSL_USER_IO
#endif
#define NO_WRITEV
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define NO_BIG_INT
#endif
#ifdef WOLFSSL_MICROCHIP_PIC32MZ
#define WOLFSSL_HAVE_MIN
#define WOLFSSL_HAVE_MAX
#ifndef NO_PIC32MZ_CRYPT
#define WOLFSSL_PIC32MZ_CRYPT
#endif
#ifndef NO_PIC32MZ_RNG
#define WOLFSSL_PIC32MZ_RNG
#endif
#ifndef NO_PIC32MZ_HASH
#define WOLFSSL_PIC32MZ_HASH
#endif
#endif
#ifdef MICROCHIP_TCPIP_V5
/* include timer functions */
#include "TCPIP Stack/TCPIP.h"
#endif
#ifdef MICROCHIP_TCPIP
/* include timer, NTP functions */
#ifdef MICROCHIP_MPLAB_HARMONY
#include "tcpip/tcpip.h"
#else
#include "system/system_services.h"
#include "tcpip/sntp.h"
#endif
#endif
#ifdef WOLFSSL_ATECC508A
/* backwards compatibility */
#ifndef WOLFSSL_ATECC_NO_ECDH_ENC
#define WOLFSSL_ATECC_ECDH_ENC
#endif
#ifdef WOLFSSL_ATECC508A_DEBUG
#define WOLFSSL_ATECC_DEBUG
#endif
#endif
#ifdef MBED
#define WOLFSSL_USER_IO
#define NO_FILESYSTEM
#define NO_CERTS
#if !defined(USE_CERT_BUFFERS_2048) && !defined(USE_CERT_BUFFERS_4096)
#define USE_CERT_BUFFERS_1024
#endif
#define NO_WRITEV
#define NO_DEV_RANDOM
#define NO_SHA512
#define NO_DH
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
/* WOLFSSL_DH_CONST */
#define NO_DSA
#define NO_HC128
#define HAVE_ECC
#define NO_SESSION_CACHE
#define WOLFSSL_CMSIS_RTOS
#endif
#ifdef WOLFSSL_EROAD
#define FREESCALE_MQX
#define FREESCALE_MMCAU
#define SINGLE_THREADED
#define NO_STDIO_FILESYSTEM
#define WOLFSSL_LEANPSK
#define HAVE_NULL_CIPHER
#define NO_OLD_TLS
#define NO_ASN
#define NO_BIG_INT
#define NO_RSA
#define NO_DSA
#define NO_DH
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
/* WOLFSSL_DH_CONST */
#define NO_CERTS
#define NO_PWDBASED
#define NO_DES3
#define NO_MD4
#define NO_RC4
#define NO_MD5
#define NO_SESSION_CACHE
#define NO_MAIN_DRIVER
#endif
#ifdef WOLFSSL_PICOTCP
#ifndef errno
#define errno pico_err
#endif
#include "pico_defines.h"
#include "pico_stack.h"
#include "pico_constants.h"
#include "pico_protocol.h"
#define CUSTOM_RAND_GENERATE pico_rand
#endif
#ifdef WOLFSSL_PICOTCP_DEMO
#define WOLFSSL_STM32
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define XMALLOC(s, h, type) PICO_ZALLOC((s))
#define XFREE(p, h, type) PICO_FREE((p))
#define SINGLE_THREADED
#define NO_WRITEV
#define WOLFSSL_USER_IO
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#endif
#ifdef FREERTOS_WINSIM
#define FREERTOS
#define USE_WINDOWS_API
#endif
#ifdef WOLFSSL_VXWORKS
/* VxWorks simulator incorrectly detects building for i386 */
#ifdef VXWORKS_SIM
#define TFM_NO_ASM
#endif
/* For VxWorks pthreads wrappers for mutexes uncomment the next line. */
/* #define WOLFSSL_PTHREADS */
#define WOLFSSL_HAVE_MIN
#define WOLFSSL_HAVE_MAX
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define NO_MAIN_DRIVER
#define NO_DEV_RANDOM
#define NO_WRITEV
#define HAVE_STRINGS_H
#endif
#ifdef WOLFSSL_ARDUINO
#define NO_WRITEV
#define NO_WOLFSSL_DIR
#define SINGLE_THREADED
#define NO_DEV_RANDOM
#ifndef INTEL_GALILEO /* Galileo has time.h compatibility */
#define TIME_OVERRIDES
#ifndef XTIME
#error "Must define XTIME externally see porting guide"
#error "https://www.wolfssl.com/docs/porting-guide/"
#endif
#ifndef XGMTIME
#error "Must define XGMTIME externally see porting guide"
#error "https://www.wolfssl.com/docs/porting-guide/"
#endif
#endif
#define WOLFSSL_USER_IO
#define HAVE_ECC
#define NO_DH
#define NO_SESSION_CACHE
#endif
#ifdef WOLFSSL_UTASKER
/* uTasker configuration - used for fnRandom() */
#include "config.h"
#define SINGLE_THREADED
#define NO_WOLFSSL_DIR
#define WOLFSSL_HAVE_MIN
#define NO_WRITEV
#define HAVE_ECC
#define ALT_ECC_SIZE
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT
/* used in wolfCrypt test */
#define NO_MAIN_DRIVER
#define USE_CERT_BUFFERS_2048
/* uTasker port uses RAW sockets, use I/O callbacks
* See wolfSSL uTasker example for sample callbacks */
#define WOLFSSL_USER_IO
/* uTasker filesystem not ported */
#define NO_FILESYSTEM
/* uTasker RNG is abstracted, calls HW RNG when available */
#define CUSTOM_RAND_GENERATE fnRandom
#define CUSTOM_RAND_TYPE unsigned short
/* user needs to define XTIME to function that provides
* seconds since Unix epoch */
#ifndef XTIME
#error XTIME must be defined in wolfSSL settings.h
/* #define XTIME fnSecondsSinceEpoch */
#endif
/* use uTasker std library replacements where available */
#define STRING_USER
#define XMEMCPY(d,s,l) uMemcpy((d),(s),(l))
#define XMEMSET(b,c,l) uMemset((b),(c),(l))
#define XMEMCMP(s1,s2,n) uMemcmp((s1),(s2),(n))
#define XMEMMOVE(d,s,l) memmove((d),(s),(l))
#define XSTRLEN(s1) uStrlen((s1))
#define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
#define XSTRSTR(s1,s2) strstr((s1),(s2))
#define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
#define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
#define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
#define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
#if defined(WOLFSSL_CERT_EXT) || defined(OPENSSL_EXTRA) \
|| defined(HAVE_ALPN)
#define XSTRTOK strtok_r
#endif
#endif
#ifdef WOLFSSL_EMBOS
#define NO_FILESYSTEM /* Not ported at this time */
#define USE_CERT_BUFFERS_2048 /* use when NO_FILESYSTEM */
#define NO_MAIN_DRIVER
#define NO_RC4
#define SINGLE_THREADED /* Not ported at this time */
#endif
#ifdef WOLFSSL_RIOT_OS
#define NO_WRITEV
#define TFM_NO_ASM
#define NO_FILESYSTEM
#define USE_CERT_BUFFERS_2048
#if defined(WOLFSSL_GNRC) && !defined(WOLFSSL_DTLS)
#define WOLFSSL_DTLS
#endif
#endif
#ifdef WOLFSSL_CHIBIOS
/* ChibiOS definitions. This file is distributed with chibiOS. */
#include "wolfssl_chibios.h"
#endif
#ifdef WOLFSSL_PB
/* PB is using older 1.2 version of Nucleus */
#undef WOLFSSL_NUCLEUS
#define WOLFSSL_NUCLEUS_1_2
#endif
#ifdef WOLFSSL_NUCLEUS_1_2
#define NO_WRITEV
#define NO_WOLFSSL_DIR
#if !defined(NO_ASN_TIME) && !defined(USER_TIME)
#error User must define XTIME, see manual
#endif
#if !defined(XMALLOC_OVERRIDE) && !defined(XMALLOC_USER)
extern void* nucleus_malloc(unsigned long size, void* heap, int type);
extern void* nucleus_realloc(void* ptr, unsigned long size, void* heap,
int type);
extern void nucleus_free(void* ptr, void* heap, int type);
#define XMALLOC(s, h, type) nucleus_malloc((s), (h), (type))
#define XREALLOC(p, n, h, t) nucleus_realloc((p), (n), (h), (t))
#define XFREE(p, h, type) nucleus_free((p), (h), (type))
#endif
#endif
#ifdef WOLFSSL_NRF5x
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#define NO_MAIN_DRIVER
#define NO_WRITEV
#define SINGLE_THREADED
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define WOLFSSL_NRF51
#define WOLFSSL_USER_IO
#define NO_SESSION_CACHE
#endif
/* Micrium will use Visual Studio for compilation but not the Win32 API */
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \
!defined(FREERTOS_TCP) && !defined(EBSNET) && !defined(WOLFSSL_EROAD) && \
!defined(WOLFSSL_UTASKER) && !defined(INTIME_RTOS)
#define USE_WINDOWS_API
#endif
#if defined(WOLFSSL_uITRON4)
#define XMALLOC_USER
#include <stddef.h>
#define ITRON_POOL_SIZE 1024*20
extern int uITRON4_minit(size_t poolsz) ;
extern void *uITRON4_malloc(size_t sz) ;
extern void *uITRON4_realloc(void *p, size_t sz) ;
extern void uITRON4_free(void *p) ;
#define XMALLOC(sz, heap, type) uITRON4_malloc(sz)
#define XREALLOC(p, sz, heap, type) uITRON4_realloc(p, sz)
#define XFREE(p, heap, type) uITRON4_free(p)
#endif
#if defined(WOLFSSL_uTKERNEL2)
#ifndef NO_TKERNEL_MEM_POOL
#define XMALLOC_OVERRIDE
int uTKernel_init_mpool(unsigned int sz); /* initializing malloc pool */
void* uTKernel_malloc(unsigned int sz);
void* uTKernel_realloc(void *p, unsigned int sz);
void uTKernel_free(void *p);
#define XMALLOC(s, h, type) uTKernel_malloc((s))
#define XREALLOC(p, n, h, t) uTKernel_realloc((p), (n))
#define XFREE(p, h, type) uTKernel_free((p))
#endif
#ifndef NO_STDIO_FGETS_REMAP
#include <stdio.h>
#include "tm/tmonitor.h"
/* static char* gets(char *buff); */
static char* fgets(char *buff, int sz, XFILE fp) {
char * s = buff;
*s = '\0';
while (1) {
*s = tm_getchar(-1);
tm_putchar(*s);
if (*s == '\r') {
tm_putchar('\n');
*s = '\0';
break;
}
s++;
}
return buff;
}
#endif /* !NO_STDIO_FGETS_REMAP */
#endif
#if defined(WOLFSSL_LEANPSK) && !defined(XMALLOC_USER) && \
!defined(NO_WOLFSSL_MEMORY)
#include <stdlib.h>
#define XMALLOC(s, h, type) malloc((s))
#define XFREE(p, h, type) free((p))
#define XREALLOC(p, n, h, t) realloc((p), (n))
#endif
#if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL)
#undef XMALLOC
#define XMALLOC yaXMALLOC
#undef XFREE
#define XFREE yaXFREE
#undef XREALLOC
#define XREALLOC yaXREALLOC
#endif
#ifdef FREERTOS
#include "FreeRTOS.h"
#if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) && \
!defined(WOLFSSL_STATIC_MEMORY)
#define XMALLOC(s, h, type) pvPortMalloc((s))
#define XFREE(p, h, type) vPortFree((p))
/* FreeRTOS pvPortRealloc() implementation can be found here:
https://github.com/wolfSSL/wolfssl-freertos/pull/3/files */
#if !defined(USE_FAST_MATH) || defined(HAVE_ED25519) || \
defined(HAVE_ED448)
#if defined(WOLFSSL_ESPIDF)
/*In IDF, realloc(p, n) is equivalent to
heap_caps_realloc(p, s, MALLOC_CAP_8BIT) */
#define XREALLOC(p, n, h, t) realloc((p), (n))
#else
#define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
#endif
#endif
#endif
#ifndef NO_WRITEV
#define NO_WRITEV
#endif
#ifndef HAVE_SHA512
#ifndef NO_SHA512
#define NO_SHA512
#endif
#endif
#ifndef HAVE_DH
#ifndef NO_DH
#define NO_DH
#endif
#endif
#ifndef NO_DSA
#define NO_DSA
#endif
#ifndef NO_HC128
#define NO_HC128
#endif
#ifndef SINGLE_THREADED
#include "semphr.h"
#endif
#endif
#ifdef FREERTOS_TCP
#if !defined(NO_WOLFSSL_MEMORY) && !defined(XMALLOC_USER) && \
!defined(WOLFSSL_STATIC_MEMORY)
#define XMALLOC(s, h, type) pvPortMalloc((s))
#define XFREE(p, h, type) vPortFree((p))
#endif
#define WOLFSSL_GENSEED_FORTEST
#define NO_WOLFSSL_DIR
#define NO_WRITEV
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define NO_MAIN_DRIVER
#endif
#ifdef WOLFSSL_TIRTOS
#define SIZEOF_LONG_LONG 8
#define NO_WRITEV
#define NO_WOLFSSL_DIR
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT
#define WC_RSA_BLINDING
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#define USE_CERT_BUFFERS_2048
#define NO_ERROR_STRINGS
/* Uncomment this setting if your toolchain does not offer time.h header */
/* #define USER_TIME */
#define HAVE_ECC
#define HAVE_ALPN
#define USE_WOLF_STRTOK /* use with HAVE_ALPN */
#define HAVE_TLS_EXTENSIONS
#define HAVE_AESGCM
#ifdef WOLFSSL_TI_CRYPT
#define NO_GCM_ENCRYPT_EXTRA
#define NO_PUBLIC_GCM_SET_IV
#define NO_PUBLIC_CCM_SET_NONCE
#endif
#define HAVE_SUPPORTED_CURVES
#define ALT_ECC_SIZE
#ifdef __IAR_SYSTEMS_ICC__
#pragma diag_suppress=Pa089
#elif !defined(__GNUC__)
/* Suppress the sslpro warning */
#pragma diag_suppress=11
#endif
#include <ti/sysbios/hal/Seconds.h>
#endif
#ifdef EBSNET
#include "rtip.h"
/* #define DEBUG_WOLFSSL */
#define NO_WOLFSSL_DIR /* tbd */
#if (POLLOS)
#define SINGLE_THREADED
#endif
#if (RTPLATFORM)
#if (!RTP_LITTLE_ENDIAN)
#define BIG_ENDIAN_ORDER
#endif
#else
#if (!KS_LITTLE_ENDIAN)
#define BIG_ENDIAN_ORDER
#endif
#endif
#if (WINMSP3)
#undef SIZEOF_LONG
#define SIZEOF_LONG_LONG 8
#else
#if !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
#error settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
#endif
#endif
#define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
#define XFREE(p, h, type) (rtp_free(p))
#define XREALLOC(p, n, h, t) (rtp_realloc((p), (n)))
#if (WINMSP3)
#define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
#else
#ifndef XSTRNCASECMP
#error settings.h - please implement XSTRNCASECMP - needed for HAVE_ECC
#endif
#endif
#define WOLFSSL_HAVE_MAX
#define WOLFSSL_HAVE_MIN
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define WC_RSA_BLINDING
#define ECC_TIMING_RESISTANT
#define HAVE_ECC
#endif /* EBSNET */
#ifdef WOLFSSL_GAME_BUILD
#define SIZEOF_LONG_LONG 8
#if defined(__PPU) || defined(__XENON)
#define BIG_ENDIAN_ORDER
#endif
#endif
#ifdef WOLFSSL_LSR
#define HAVE_WEBSERVER
#define SIZEOF_LONG_LONG 8
#define WOLFSSL_LOW_MEMORY
#define NO_WRITEV
#define NO_SHA512
#define NO_DH
/* Allows use of DH with fixed points if uncommented and NO_DH is removed */
/* WOLFSSL_DH_CONST */
#define NO_DSA
#define NO_HC128
#define NO_DEV_RANDOM
#define NO_WOLFSSL_DIR
#define NO_RABBIT
#ifndef NO_FILESYSTEM
#define LSR_FS
#include "inc/hw_types.h"
#include "fs.h"
#endif
#define WOLFSSL_LWIP
#include <errno.h> /* for tcp errno */
#define WOLFSSL_SAFERTOS
#if defined(__IAR_SYSTEMS_ICC__)
/* enum uses enum */
#pragma diag_suppress=Pa089
#endif
#endif
#ifdef WOLFSSL_SAFERTOS
#ifndef SINGLE_THREADED
#include "SafeRTOS/semphr.h"
#endif
#ifndef WOLFSSL_NO_MALLOC
#include "SafeRTOS/heap.h"
#endif
#if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) && \
!defined(WOLFSSL_STATIC_MEMORY)
#define XMALLOC(s, h, type) pvPortMalloc((s))
#define XFREE(p, h, type) vPortFree((p))
/* FreeRTOS pvPortRealloc() implementation can be found here:
https://github.com/wolfSSL/wolfssl-freertos/pull/3/files */
#if !defined(USE_FAST_MATH) || defined(HAVE_ED25519) || \
defined(HAVE_ED448)
#define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
#endif
#endif
#endif
#ifdef WOLFSSL_LOW_MEMORY
#undef RSA_LOW_MEM
#define RSA_LOW_MEM
#undef WOLFSSL_SMALL_STACK
#define WOLFSSL_SMALL_STACK
#undef TFM_TIMING_RESISTANT
#define TFM_TIMING_RESISTANT
#endif
/* To support storing some of the large constant tables in flash memory rather than SRAM.
Useful for processors that have limited SRAM, such as the AVR family of microtrollers. */
#ifdef WOLFSSL_USE_FLASHMEM
/* This is supported on the avr-gcc compiler, for more information see:
https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html */
#define FLASH_QUALIFIER __flash
/* Copy data out of flash memory and into SRAM */
#define XMEMCPY_P(pdest, psrc, size) memcpy_P((pdest), (psrc), (size))
#else
#define FLASH_QUALIFIER
#endif
#ifdef FREESCALE_MQX_5_0
/* use normal Freescale MQX port, but with minor changes for 5.0 */
#define FREESCALE_MQX
#endif