forked from wolfSSL/wolfssl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
2413 lines (2022 loc) · 68.7 KB
/
CMakeLists.txt
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
# CMakeList.txt
#
# Copyright (C) 2006-2023 wolfSSL Inc.
#
# This file is part of wolfSSL. (formerly known as CyaSSL)
#
# Usage:
# $ mkdir build
# $ cd build
# $ cmake ..
# $ cmake --build .
#
# To build with debugging use:
# $ cmake .. -DCMAKE_BUILD_TYPE=Debug
#
# See "Building with CMake" in INSTALL for more.
####################################################
# Project
####################################################
cmake_minimum_required(VERSION 3.16)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed.\
Run cmake from a separate directory from where CMakeLists.txt lives.\
NOTE: cmake will now create CMakeCache.txt and CMakeFiles/*.\
You must delete them, or cmake will refuse to work.")
endif()
project(wolfssl VERSION 5.6.3 LANGUAGES C ASM)
# shared library versioning
# increment if interfaces have been added, removed or changed
set(LIBTOOL_CURRENT 40)
# increment if source code has changed set to zero if current is incremented
set(LIBTOOL_REVISION 1)
# increment if interfaces have been added set to zero if interfaces have been
# removed or changed
set(LIBTOOL_AGE 5)
math(EXPR LIBTOOL_SO_VERSION "${LIBTOOL_CURRENT} - ${LIBTOOL_AGE}")
set(LIBTOOL_FULL_VERSION ${LIBTOOL_SO_VERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION})
set(WOLFSSL_DEFINITIONS)
set(WOLFSSL_LINK_LIBS)
set(WOLFSSL_INCLUDE_DIRS)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/functions.cmake)
####################################################
# Compiler
####################################################
# Let CMake choose default compiler
# TODO: See gl_VISIBILITY in visibility.m4. Need to perform
# the same checks.
# TODO: Turn on warnings.
if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
# Silence ranlib warning "has no symbols"
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
endif()
include(CheckIncludeFile)
check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
check_include_file("fcntl.h" HAVE_FCNTL_H)
check_include_file("limits.h" HAVE_LIMITS_H)
check_include_file("netdb.h" HAVE_NETDB_H)
check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
check_include_file("stddef.h" HAVE_STDDEF_H)
check_include_file("time.h" HAVE_TIME_H)
check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
check_include_file("sys/time.h" HAVE_SYS_TIME_H)
check_include_file("errno.h" HAVE_ERRNO_H)
check_include_file("dlfcn.h" HAVE_DLFCN_H)
check_include_file("inttypes.h" HAVE_INTTYPES_H)
check_include_file("memory.h" HAVE_MEMORY_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stdlib.h" HAVE_STDLIB_H)
check_include_file("string.h" HAVE_STRING_H)
check_include_file("strings.h" HAVE_STRINGS_H)
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
include(CheckFunctionExists)
# TODO: Also check if these functions are declared by the
# expected headers. See comments around
# AC_CHECK_FUNCS/AC_CHECK_DECLS in configure.ac.
check_function_exists("gethostbyname" HAVE_GETHOSTBYNAME)
check_function_exists("getaddrinfo" HAVE_GETADDRINFO)
check_function_exists("gettimeofday" HAVE_GETTIMEOFDAY)
check_function_exists("gmtime_r" HAVE_GMTIME_R)
check_function_exists("inet_ntoa" HAVE_INET_NTOA)
check_function_exists("memset" HAVE_MEMSET)
check_function_exists("socket" HAVE_SOCKET)
check_function_exists("strftime" HAVE_STRFTIME)
check_function_exists("__atomic_fetch_add" HAVE_C___ATOMIC)
include(CheckTypeSize)
check_type_size("__uint128_t" __UINT128_T)
check_type_size("long long" SIZEOF_LONG_LONG)
check_type_size("long" SIZEOF_LONG)
check_type_size("time_t" SIZEOF_TIME_T)
# By default, HAVE___UINT128_T gets defined as TRUE,
# but we want it as 1.
if(HAVE___UINT128_T)
set(HAVE___UINT128_T "1" CACHE INTERNAL "Result of TRY_COMPILE" FORCE)
endif()
include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)
# Thread local storage
include(CheckCSourceCompiles)
set(TLS_KEYWORDS "__thread" "__declspec(thread)")
foreach(TLS_KEYWORD IN LISTS TLS_KEYWORDS)
set(TLS_CODE "#include <stdlib.h>
static void foo(void) {
static ${TLS_KEYWORD} int bar\;
exit(1)\;
}
int main() {
return 0\;
}"
)
check_c_source_compiles(${TLS_CODE} THREAD_LS_ON)
if(THREAD_LS_ON)
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_THREAD_LS")
break()
else()
# THREAD_LS_ON is cached after each call to
# check_c_source_compiles, and the function
# won't run subsequent times if the variable
# is in the cache. To make it run again, we
# need to remove the variable from the cache.
unset(THREAD_LS_ON CACHE)
endif()
endforeach()
# TODO: AX_PTHREAD does a lot. Need to implement the
# rest of its logic.
find_package(Threads)
####################################################
# Cross Compile Example
####################################################
#set(CMAKE_SYSTEM_NAME Linux)
#set(CMAKE_SYSTEM_PROCESSOR arm)
#set(CMAKE_C_COMPILER "/opt/arm-linux-musleabihf-cross/bin/arm-linux-musleabihf-gcc")
#set(CMAKE_CXX_COMPILER "/opt/arm-linux-musleabihf-cross/bin/arm-linux-musleabihf-g++")
#set(CMAKE_SYSROOT "/opt/arm-linux-musleabihf-cross/arm-linux-musleabihf/")
# Example for setting CFLAGS
#set(CMAKE_C_FLAGS "-std=gnu89 ${CMAKE_C_FLAGS}")
# Example for map file and custom linker script
#set(CMAKE_EXE_LINKER_FLAGS " -Xlinker -Map=output.map -T\"${CMAKE_CURRENT_SOURCE_DIR}/linker.ld\"")
if(DEFINED WARNING_C_FLAGS)
set(CMAKE_C_FLAGS "${WARNING_C_FLAGS} ${CMAKE_C_FLAGS}")
elseif(WIN32)
# Windows cl.exe does not support the -Wextra, -Wno-unused and -Werror flags.
set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}")
else()
set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused -Werror ${CMAKE_C_FLAGS}")
endif()
####################################################
# Build Options
####################################################
# TODO: - FIPS
# - Distro
# - Linux Kernel Module
# - Single precision math
# - Enable all
# - Enable all crypto
# For reproducible build, gate out from the build anything that might
# introduce semantically frivolous jitter, maximizing chance of
# identical object files.
add_option("WOLFSSL_REPRODUCIBLE_BUILD"
"Enable maximally reproducible build (default: disabled)"
"no" "yes;no")
if(WOLFSSL_REPRODUCIBLE_BUILD)
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_REPRODUCIBLE_BUILD")
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> Dq <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
endif()
# Support for forcing 32-bit mode
# TODO: detect platform from other options
add_option("WOLFSSL_32BIT"
"Enables 32-bit support (default: disabled)"
"no" "yes;no")
# 16-bit compiler support
add_option("WOLFSSL_16BIT"
"Enables 16-bit support (default: disabled)"
"no" "yes;no")
if(WOLFSSL_16BIT)
list(APPEND WOLFSSL_DEFINITIONS "-DWC_16BIT_CPU")
endif()
# Support for disabling all ASM
add_option("WOLFSSL_ASM"
"Enables option for assembly (default: enabled)"
"yes" "yes;no")
if(NOT WOLFSSL_ASM)
list(APPEND WOLFSSL_DEFINITIONS
"-DTFM_NO_ASM"
"-DWOLFSSL_NO_ASM")
endif()
# Enable Debugging
add_option("WOLFSSL_DEBUG"
"Enables option for debug (default: disabled)"
"no" "yes;no")
if(WOLFSSL_DEBUG)
set(CMAKE_C_FLAGS "-g ${CMAKE_C_FLAGS}")
list(APPEND WOLFSSL_DEFINITIONS
"-DDEBUG_WOLFSSL"
"-DDEBUG")
endif()
# Single threaded
add_option("WOLFSSL_SINGLE_THREADED"
"Enable wolfSSL single threaded (default: disabled)"
"no" "yes;no")
# TODO: Logic here isn't complete, yet (see AX_PTHREAD)
if(NOT WOLFSSL_SINGLE_THREADED)
if(CMAKE_USE_PTHREADS_INIT)
list(APPEND WOLFSSL_LINK_LIBS Threads::Threads)
set(HAVE_PTHREAD 1)
list(APPEND WOLFSSL_DEFINITIONS
"-DHAVE_PTHREAD"
"-D_POSIX_THREADS")
endif()
endif()
# DTLS
add_option("WOLFSSL_DTLS"
"Enables wolfSSL DTLS (default: disabled)"
"no" "yes;no")
if(WOLFSSL_DTLS)
list(APPEND WOLFSSL_DEFINITIONS
"-DWOLFSSL_DTLS")
endif()
# TLS v1.3
add_option("WOLFSSL_TLS13"
"Enable wolfSSL TLS v1.3 (default: enabled)"
"yes" "yes;no")
if("${FIPS_VERSION}" STREQUAL "v1")
override_cache(WOLFSSL_TLS13 "no")
endif()
# Post-handshake authentication
add_option("WOLFSSL_POSTAUTH"
"Enable wolfSSL Post-handshake Authentication (default: disabled)"
"no" "yes;no")
if(WOLFSSL_POSTAUTH)
if(NOT WOLFSSL_TLS13)
message(WARNING "TLS 1.3 is disabled - disabling Post-handshake Authentication")
override_cache(WOLFSSL_POSTAUTH "no")
else()
list(APPEND WOLFSSL_DEFINITIONS
"-DWOLFSSL_POST_HANDSHAKE_AUTH")
endif()
endif()
# Hello Retry Request Cookie
add_option("WOLFSSL_HRR_COOKIE"
"Enable the server to send Cookie Extension in HRR with state (default: disabled)"
"undefined" "yes;no;undefined")
if("${WOLFSSL_HRR_COOKIE}" STREQUAL "yes")
if(NOT WOLFSSL_TLS13)
message(WARNING "TLS 1.3 is disabled - disabling HRR Cookie")
override_cache(WOLFSSL_HRR_COOKIE "no")
else()
list(APPEND WOLFSSL_DEFINITIONS
"-DWOLFSSL_SEND_HRR_COOKIE")
endif()
endif()
# DTLS v1.3
add_option("WOLFSSL_DTLS13"
"Enable wolfSSL DTLS v1.3 (default: disabled)"
"no" "yes;no")
if(WOLFSSL_DTLS13)
if (NOT WOLFSSL_DTLS)
message(FATAL_ERROR "DTLS13 requires DTLS")
endif()
if (NOT WOLFSSL_TLS13)
message(FATAL_ERROR "DTLS13 requires TLS13")
endif()
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_DTLS13")
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_W64_WRAPPER")
if ("${WOLFSSL_HRR_COOKIE}" STREQUAL "undefined")
message(WARNING "DTLS1.3 is enabled - enabling HRR Cookie")
override_cache(WOLFSSL_HRR_COOKIE "yes")
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SEND_HRR_COOKIE")
endif()
if (WOLFSSL_AES)
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_AES_DIRECT")
endif()
endif()
# DTLS ConnectionID support
add_option("WOLFSSL_DTLS_CID"
"Enables wolfSSL DTLS CID (default: disabled)"
"no" "yes;no")
if(WOLFSSL_DTLS_CID)
if(NOT WOLFSSL_DTLS13)
message(FATAL_ERROR "CID are supported only for DTLSv1.3")
endif()
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_DTLS_CID")
endif()
# RNG
add_option("WOLFSSL_RNG"
"Enable compiling and using RNG (default: enabled)"
"yes" "yes;no")
if(NOT WOLFSSL_RNG)
list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_RNG")
endif()
# TODO: - DTLS-SCTP
# - DTLS multicast
# - OpenSSH
# - OpenVPN
# - Nginx
# - HAProxy
# - wpa_supplicant
# - Fortress
# - libwebsockets
# - IP alternative name
# - Qt
# - SSL bump
# - sniffer
# - Signal
# - OpenSSL coexist
# - OpenSSL compatibility all
# - OpenSSL compatibility extra
# - Max strength
# Harden, enable Timing Resistance and Blinding by default
add_option("WOLFSSL_HARDEN"
"Enable Hardened build, Enables Timing Resistance and Blinding (default: enabled)"
"yes" "yes;no")
if(WOLFSSL_HARDEN)
list(APPEND WOLFSSL_DEFINITIONS "-DTFM_TIMING_RESISTANT" "-DECC_TIMING_RESISTANT")
if(WOLFSSL_RNG)
list(APPEND WOLFSSL_DEFINITIONS "-DWC_RSA_BLINDING")
endif()
else()
list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_HARDEN")
endif()
add_option(WOLFSSL_OPENSSLEXTRA
"Enable extra OpenSSL API, size+ (default: disabled)"
"no" "yes;no")
add_option(WOLFSSL_OPENSSLALL
"Enable all OpenSSL API, size++ (default: disabled)"
"no" "yes;no")
add_option(WOLFSSL_ASIO
"Enable asio support (default: disabled)"
"no" "yes;no")
if (WOLFSSL_ASIO)
list(APPEND WOLFSSL_DEFINITIONS
"-DWOLFSSL_ASIO" "-DASIO_USE_WOLFSSL"
"-DBOOST_ASIO_USE_WOLFSSL" "-DHAVE_EX_DATA"
"-DSSL_TXT_TLSV1_2" "-DOPENSSL_NO_SSL2" "-DOPENSSL_NO_SSL3"
"-DHAVE_OCSP" "-DWOLFSSL_KEY_GEN")
override_cache(WOLFSSL_OPENSSLALL "yes")
override_cache(WOLFSSL_OPENSSLEXTRA "yes")
endif()
if (WOLFSSL_OPENSSLEXTRA AND NOT WOLFSSL_OPENSSLCOEXIST)
list(APPEND WOLFSSL_DEFINITIONS
"-DOPENSSL_EXTRA"
"-DWOLFSSL_ALWAYS_VERIFY_CB"
"-DWOLFSSL_VERIFY_CB_ALL_CERTS"
"-DWOLFSSL_EXTRA_ALERTS"
"-DHAVE_EXT_CACHE"
"-DWOLFSSL_FORCE_CACHE_ON_TICKET")
endif()
if (WOLFSSL_OPENSSLALL)
list(APPEND WOLFSSL_DEFINITIONS
"-DOPENSSL_ALL" "-DWOLFSSL_EITHER_SIDE" "-DWC_RSA_NO_PADDING"
"-DWC_RSA_PSS" "-DWOLFSSL_PSS_LONG_SALT" "-DWOLFSSL_TICKET_HAVE_ID"
"-DWOLFSSL_ERROR_CODE_OPENSSL" "-DWOLFSSL_CERT_NAME_ALL")
endif()
# TODO: - IPv6 test apps
set(WOLFSSL_SLOW_MATH "yes")
# liboqs
add_option(WOLFSSL_OQS
"Enable integration with the OQS (Open Quantum Safe) liboqs library (default: disabled)"
"no" "yes;no")
if (WOLFSSL_OQS)
find_package(OQS)
if (OQS_FOUND)
list(APPEND WOLFSSL_LINK_LIBS ${OQS_LIBRARY})
list(APPEND WOLFSSL_INCLUDE_DIRS ${OQS_INCLUDE_DIR})
set(HAVE_LIBOQS 1)
list(APPEND WOLFSSL_DEFINITIONS
"-DHAVE_TLS_EXTENSIONS"
"-DHAVE_LIBOQS")
endif()
endif()
# TODO: - Lean PSK
# - Lean TLS
# - Low resource
# - Titan cache
# - Huge cache
# - Big cache
# - Small cache
# - Persistent session cache
# - Persistent cert cache
# - Write duplicate
# - Atomic user record layer
# - Public key callbacks
# - Microchip/Atmel CryptoAuthLib
# AES-CBC
add_option("WOLFSSL_AESCBC"
"Enable wolfSSL AES-CBC support (default: enabled)"
"yes" "yes;no")
if(NOT WOLFSSL_AESCBC)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_AES_CBC")
endif()
# AES-GCM
add_option("WOLFSSL_AESGCM"
"Enable wolfSSL AES-GCM support (default: enabled)"
"yes" "yes;no;table;small;word32;4bit")
# leanpsk and leantls don't need gcm
if(WOLFSSL_LEAN_PSK OR (WOLFSSL_LEAN_TLS AND NOT WOLFSSL_TLS13))
override_cache(WOLFSSL_AESGCM "no")
endif()
if(WOLFSSL_AESGCM AND NOT WORDS_BIGENDIAN)
override_cache(WOLFSSL_AESGCM "4bit")
endif()
if(WOLFSSL_AESGCM)
if("${WOLFSSL_AESGCM}" STREQUAL "word32")
list(APPEND WOLFSSL_DEFINITIONS "-DGCM_WORD32")
override_cache(WOLFSSL_AESGCM "yes")
endif()
if(("${WOLFSSL_AESGCM}" STREQUAL "small") OR WOLFSSL_LOW_RESOURCE)
list(APPEND WOLFSSL_DEFINITIONS "-DGCM_SMALL")
override_cache(WOLFSSL_AESGCM "yes")
endif()
if("${WOLFSSL_AESGCM}" STREQUAL "table")
list(APPEND WOLFSSL_DEFINITIONS "-DGCM_TABLE")
override_cache(WOLFSSL_AESGCM "yes")
endif()
if("${WOLFSSL_AESGCM}" STREQUAL "4bit")
list(APPEND WOLFSSL_DEFINITIONS "-DGCM_TABLE_4BIT")
override_cache(WOLFSSL_AESGCM "yes")
endif()
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_AESGCM")
endif()
# AES-SIV
add_option("WOLFSSL_AESSIV"
"Enable wolfSSL AES-SIV support (default: disabled)"
"no" "yes;no")
if(WOLFSSL_AESSIV)
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_AES_SIV")
endif()
# AES-CTR
add_option("WOLFSSL_AESCTR"
"Enable wolfSSL AES-CTR support (default: disabled)"
"no" "yes;no")
if(WOLFSSL_OPENVPN OR
WOLFSSL_LIBSSH2 OR
WOLFSSL_AESSIV)
override_cache(WOLFSSL_AESCTR "yes")
endif()
if(WOLFSSL_AESCTR AND NOT WOLFSSL_FORTRESS)
list(APPEND WOLFSSL_DEFINITIONS
"-DWOLFSSL_AES_COUNTER"
"-DWOLFSSL_AES_DIRECT")
endif()
# AES-CCM
add_option("WOLFSSL_AESCCM"
"Enable wolfSSL AES-CCM support (default: disabled)"
"no" "yes;no")
# AES-OFB
add_option("WOLFSSL_AESOFB"
"Enable wolfSSL AES-OFB support (default: disabled)"
"no" "yes;no")
# TODO: - AES-GCM stream
# - AES-ARM
# - Xilinx hardened crypto
# - Intel AES-NI
# - Intel ASM
# - Intel RDRAND
# - Linux af_alg
# - Linux dev crpyto calls
# - Camellia
# - MD2
# - NULL cipher
# - RIPEMD
# - BLAKE2
add_option("WOLFSSL_AESCFB"
"Enable wolfSSL AES-CFB support (default: disabled)"
"no" "yes;no")
# Align data
add_option("WOLFSSL_ALIGN_DATA"
"Align data for ciphers (default: enabled)"
"yes" "yes;no")
if(WOLFSSL_ALIGN_DATA)
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_USE_ALIGN")
endif()
# SHA224
set(SHA224_DEFAULT "no")
if(("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64|AMD64|arm64") OR
("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
if(NOT WOLFSSL_AFALG AND NOT WOLFSSL_DEVCRYPTO AND
(NOT WOLFSSL_FIPS OR ("${FIPS_VERSION}" STREQUAL "v2")))
set(SHA224_DEFAULT "yes")
endif()
endif()
add_option("WOLFSSL_SHA224"
"Enable wolfSSL SHA-224 support (default: enabled on x86_64/aarch64)"
${SHA224_DEFAULT} "yes;no")
# SHA3
set(SHA3_DEFAULT "no")
if(("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64|AMD64|arm64") OR
("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
if(NOT WOLFSSL_FIPS OR ("${FIPS_VERSION}" STREQUAL "v2"))
set(SHA3_DEFAULT "yes")
endif()
endif()
add_option("WOLFSSL_SHA3"
"Enable wolfSSL SHA-3 support (default: enabled on x86_64/aarch64)"
${SHA3_DEFAULT} "yes;no;small")
# SHAKE256
add_option("WOLFSSL_SHAKE256"
"Enable wolfSSL SHAKE256 support (default: enabled on x86_64/aarch64)"
"no" "yes;no;small")
# SHAKE128
add_option("WOLFSSL_SHAKE128"
"Enable wolfSSL SHAKE128 support (default: enabled on x86_64/aarch64)"
"no" "yes;no;small")
# SHA512
add_option("WOLFSSL_SHA512"
"Enable wolfSSL SHA-512 support (default: enabled)"
"yes" "yes;no")
# options that don't require sha512
if(WOLFSSL_LEAN_PSK OR
WOLFSSL_LEAN_TLS OR
WOLFSSL_32BIT OR
WOLFSSL_16BIT)
override_cache(WOLFSSL_SHA512 "no")
endif()
# options that require sha512
if(WOLFSSL_OPENSSH OR
WOLFSSL_WPAS OR
WOLFSSL_FORTRESS)
override_cache(WOLFSSL_SHA512 "yes")
endif()
if(WOLFSSL_SHA512)
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA512")
endif()
# SHA384
add_option("WOLFSSL_SHA384"
"Enable wolfSSL SHA-384 support (default: enabled)"
"yes" "yes;no")
# options that don't require sha384
if(WOLFSSL_LEAN_PSK OR
WOLFSSL_LEAN_TLS OR
WOLFSSL_32BIT OR
WOLFSSL_16BIT)
override_cache(WOLFSSL_SHA384 "no")
endif()
# options that require sha384
if(WOLFSSL_OPENSSH OR
WOLFSSL_WPAS OR
WOLFSSL_FORTRESS)
override_cache(WOLFSSL_SHA384 "yes")
endif()
if(WOLFSSL_SHA384)
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA384")
endif()
# TODO: - Session certs
# - SEP
add_option("WOLFSSL_KEYGEN"
"Enable key generation (default: disabled)])"
"no" "yes;no")
add_option("WOLFSSL_CERTGEN"
"Enable cert generation (default: disabled)"
"no" "yes;no")
add_option("WOLFSSL_CERTREQ"
"Enable cert request generation (default: disabled)"
"no" "yes;no")
add_option("WOLFSSL_CERTEXT"
"Enable cert request extensions (default: disabled)"
"no" "yes;no")
add_option("WOLFSSL_CERTGENCACHE"
"Enable decoded cert caching (default: disabled)"
"no" "yes;no")
# HKDF
add_option("WOLFSSL_HKDF"
"Enable HKDF (HMAC-KDF) support (default: disabled)"
"no" "yes;no")
if(WOLFSSL_TLS13)
override_cache(WOLFSSL_HKDF "yes")
endif()
if(WOLFSSL_HKDF)
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_HKDF")
endif()
# DSA
add_option("WOLFSSL_DSA"
"Enable DSA (default: disabled)"
"no" "yes;no")
if(NOT WOLFSSL_DSA AND NOT WOLFSSL_OPENSSH)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_DSA")
endif()
# ECC Shamir
add_option("WOLFSSL_ECCSHAMIR"
"Enable ECC Shamir (default: enabled)"
"yes" "yes;no")
# ECC
add_option("WOLFSSL_ECC"
"Enable ECC (default: enabled)"
"yes" "yes;no;nonblock")
# lean psk doesn't need ecc
if(WOLFSSL_LEAN_PSK)
override_cache(WOLFSSL_ECC "no")
endif()
if(WOLFSSL_OPENSSH OR
WOLFSSL_NGINX OR
WOLFSSL_SIGNAL)
override_cache(WOLFSSL_ECC "yes")
endif()
if(WOLFSSL_ECC)
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ECC" "-DTFM_ECC256")
if(WOLFSSL_ECCSHAMIR AND NOT WOLFSSL_LOW_RESOURCE)
list(APPEND WOLFSSL_DEFINITIONS "-DECC_SHAMIR")
endif()
if("${WOLFSSL_ECC}" STREQUAL "nonblock")
list(APPEND WOLFSSL_DEFINITIONS "-DWC_ECC_NONBLOCK")
endif()
endif()
# TODO: - ECC custom curves
# - Compressed key
# - FP ECC, fixed point cache ECC
# - ECC encrypt
# - PSK
# - Single PSK identity
# CURVE25519
set(WOLFSSL_CURVE25519_SMALL "no")
add_option("WOLFSSL_CURVE25519"
"Enable Curve25519 (default: disabled)"
"no" "yes;no;small;no128bit")
if(WOLFSSL_OPENSSH)
override_cache(WOLFSSL_CURVE25519 "yes")
endif()
if(WOLFSSL_CURVE25519)
if("${WOLFSSL_CURVE25519}" STREQUAL "small" OR WOLFSSL_LOW_RESOURCE)
list(APPEND WOLFSSL_DEFINITIONS "-DCURVE25519_SMALL")
set(WOLFSSL_CURVE25519_SMALL "yes")
endif()
if("${WOLFSSL_CURVE25519}" STREQUAL "no128bit" OR WOLFSSL_32BIT)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_CURVED25519_128BIT")
endif()
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CURVE25519")
set(WOLFSSL_FEMATH "yes")
endif()
# ED25519
set(WOLFSSL_ED25519_SMALL "no")
add_option("WOLFSSL_ED25519"
"Enable ED25519 (default: disabled)"
"no" "yes;no")
if(WOLFSSL_OPENSSH)
override_cache(WOLFSSL_ED25519 "yes")
endif()
if(WOLFSSL_ED25519 AND NOT WOLFSSL_32BIT)
if("${WOLFSSL_ED25519}" STREQUAL "small" OR WOLFSSL_LOW_RESOURCE)
list(APPEND WOLFSSL_DEFINITIONS "-DED25519_SMALL")
set(WOLFSSL_ED25519_SMALL "yes")
set(WOLFSSL_CURVE25519_SMALL "yes")
endif()
if(NOT WOLFSSL_SHA512)
message(FATAL_ERROR "cannot enable ed25519 without enabling sha512.")
endif()
set(WOLFSSL_FEMATH "yes")
set(WOLFSSL_GEMATH "yes")
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ED25519")
endif()
# CURVE448
set(WOLFSSL_CURVE448_SMALL "no")
add_option("WOLFSSL_CURVE448"
"Enable Curve448 (default: disabled)"
"no" "yes;no;small")
if(WOLFSSL_CURVE448)
if("${WOLFSSL_CURVE448}" STREQUAL "small" OR WOLFSSL_LOW_RESOURCE)
list(APPEND WOLFSSL_DEFINITIONS "-DCURVE448_SMALL")
set(WOLFSSL_CURVE448_SMALL "yes")
endif()
if("${WOLFSSL_CURVE448}" STREQUAL "no128bit" OR WOLFSSL_32BIT)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_CURVED448_128BIT")
endif()
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CURVE448")
set(WOLFSSL_FE448 "yes")
endif()
# ED448
set(WOLFSSL_ED448_SMALL "no")
add_option("WOLFSSL_ED448"
"Enable ED448 (default: disabled)"
"no" "yes;no;small")
if(WOLFSSL_ED448 AND NOT WOLFSSL_32BIT)
if("${WOLFSSL_ED448}" STREQUAL "small" OR WOLFSSL_LOW_RESOURCE)
list(APPEND WOLFSSL_DEFINITIONS "-DED448_SMALL")
set(WOLFSSL_ED448_SMALL "yes")
set(WOLFSSL_CURVE448_SMALL "yes")
endif()
if(NOT WOLFSSL_SHA512)
message(FATAL_ERROR "cannot enable ed448 without enabling sha512.")
endif()
set(WOLFSSL_FE448 "yes")
set(WOLFSSL_GE448 "yes")
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ED448")
# EdDSA448 requires SHAKE256 which requires SHA-3
override_cache(WOLFSSL_SHAKE256 "yes")
endif()
# Error strings
add_option("WOLFSSL_ERROR_STRINGS"
"Enable error strings table (default: enabled)"
"yes" "yes;no")
if(NOT WOLFSSL_ERROR_STRINGS)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_ERROR_STRINGS")
else()
# turn off error strings if leanpsk or leantls on
if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_ERROR_STRINGS")
override_cache(WOLFSSL_ERROR_STRINGS "no")
endif()
endif()
# Error queue
add_option("WOLFSSL_ERROR_QUEUE"
"Enables adding nodes to error queue when compiled with OPENSSL_EXTRA (default: enabled)"
"yes" "yes;no")
if(NOT WOLFSSL_ERROR_QUEUE)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_ERROR_QUEUE")
endif()
# Old TLS
add_option("WOLFSSL_OLD_TLS"
"Enable old TLS versions < 1.2 (default: enabled)"
"yes" "yes;no")
if(NOT WOLFSSL_OLD_TLS)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_OLD_TLS")
else()
# turn off old if leanpsk or leantls on
if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_OLD_TLS")
override_cache(WOLFSSL_OLD_TLS "no")
endif()
endif()
# TLSv1.2
add_option("WOLFSSL_TLSV12"
"Enable TLS versions 1.2 (default: enabled)"
"yes" "yes;no")
if(NOT WOLFSSL_TLSV12)
list(APPEND WOLFSSL_DEFINITIONS
"-DWOLFSSL_NO_TLS12"
"-DNO_OLD_TLS")
endif()
# TODO: - TLSv1.0
# - SSLv3
# - Stack size
# - Stack size verbose
# Memory
add_option("WOLFSSL_MEMORY"
"Enable memory callbacks (default: enabled)"
"yes" "yes;no")
if(NOT WOLFSSL_MEMORY)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_WOLFSSL_MEMORY")
else()
# turn off memory cb if leanpsk or leantls on
if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
# but don't turn on NO_WOLFSSL_MEMORY because using own
override_cache(WOLFSSL_MEMORY "no")
endif()
endif()
# TODO: - Track memory
# - Memory log
# - Stack log
# RSA
add_option("WOLFSSL_RSA"
"Enable RSA (default: enabled)"
"yes" "yes;no")
if(NOT WOLFSSL_RSA)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_RSA")
else()
if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_RSA")
override_cache(WOLFSSL_RSA "no")
endif()
endif()
# OAEP
add_option("WOLFSSL_OAEP"
"Enable RSA OAEP (default: enabled)"
"yes" "yes;no")
if(NOT WOLFSSL_OAEP)
list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_RSA_OAEP")
endif()
# TODO: - RSA public only
# - RSA verify inline only
# RSA-PSS
add_option("WOLFSSL_RSA_PSS"
"Enable RSA-PSS (default: disabled)"
"no" "yes;no")
if(NOT WOLFSSL_RSA)
override_cache(WOLFSSL_RSA_PSS "no")
else()
if(WOLFSSL_TLS13)
override_cache(WOLFSSL_RSA_PSS "yes")
endif()
endif()
if(WOLFSSL_RSA_PSS)
list(APPEND WOLFSSL_DEFINITIONS "-DWC_RSA_PSS")
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_PSS_LONG_SALT")
endif()
# DH
add_option("WOLFSSL_DH"
"Enable DH (default: enabled)"
"yes" "yes;no;const")
if(WOLFSSL_OPENSSH)
override_cache(WOLFSSL_DH "yes")
endif()
if(NOT WOLFSSL_DH)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_DH")
else()
if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_DH")
override_cache(WOLFSSL_DH "no")
endif()
endif()
if("${WOLFSSL_DH}" STREQUAL "const")
list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_DH_CONST")
set(WOLFSSL_DH_CONST "yes")
endif()
# TODO: - Anonymous
# ASN
# turn off asn, which means no certs, no rsa, no dsa, no ecc,
# and no big int (unless dh is on)
add_option("WOLFSSL_ASN"
"Enable ASN (default: enabled)"
"yes" "yes;no")
if(NOT WOLFSSL_ASN)
list(APPEND WOLFSSL_DEFINITIONS "-DNO_ASN" "-DNO_CERTS")
if(NOT WOLFSSL_DH AND NOT WOLFSSL_ECC)
# DH and ECC need bigint
list(APPEND WOLFSSL_DEFINITIONS "-DNO_BIG_INT")
endif()
else()
# turn off ASN if leanpsk on
if(WOLFSSL_LEAN_PSK)
list(APPEND WOLFSSL_DEFINITIONS
"-DNO_ASN"