CMakeLists.txt 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182
  1. # CMakeList.txt
  2. #
  3. # Copyright (C) 2006-2020 wolfSSL Inc.
  4. #
  5. # This file is part of wolfSSL. (formerly known as CyaSSL)
  6. #
  7. # Usage:
  8. # $ mkdir build
  9. # $ cd build
  10. # $ cmake ..
  11. # $ cmake --build .
  12. #
  13. # To build with debugging use:
  14. # $ cmake .. -DCMAKE_BUILD_TYPE=Debug
  15. #
  16. # See "Building with CMake" in INSTALL for more.
  17. ####################################################
  18. # Project
  19. ####################################################
  20. cmake_minimum_required(VERSION 3.16)
  21. if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
  22. message(FATAL_ERROR "In-source builds are not allowed.\
  23. Run cmake from a separate directory from where CMakeLists.txt lives.\
  24. NOTE: cmake will now create CMakeCache.txt and CMakeFiles/*.\
  25. You must delete them, or cmake will refuse to work.")
  26. endif()
  27. project(wolfssl VERSION 5.5.0 LANGUAGES C ASM)
  28. # shared library versioning
  29. # increment if interfaces have been added, removed or changed
  30. set(LIBTOOL_CURRENT 35)
  31. # increment if source code has changed set to zero if current is incremented
  32. set(LIBTOOL_REVISION 0)
  33. # increment if interfaces have been added set to zero if interfaces have been
  34. # removed or changed
  35. set(LIBTOOL_AGE 0)
  36. math(EXPR LIBTOOL_SO_VERSION "${LIBTOOL_CURRENT} - ${LIBTOOL_AGE}")
  37. set(LIBTOOL_FULL_VERSION ${LIBTOOL_SO_VERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION})
  38. set(WOLFSSL_DEFINITIONS)
  39. set(WOLFSSL_LINK_LIBS)
  40. set(WOLFSSL_INCLUDE_DIRS)
  41. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")
  42. include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/functions.cmake)
  43. ####################################################
  44. # Compiler
  45. ####################################################
  46. # Let CMake choose default compiler
  47. # TODO: See gl_VISIBILITY in visibility.m4. Need to perform
  48. # the same checks.
  49. # TODO: Turn on warnings.
  50. if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
  51. # Silence ranlib warning "has no symbols"
  52. set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
  53. set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
  54. set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
  55. set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
  56. endif()
  57. include(CheckIncludeFile)
  58. check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
  59. check_include_file("fcntl.h" HAVE_FCNTL_H)
  60. check_include_file("limits.h" HAVE_LIMITS_H)
  61. check_include_file("netdb.h" HAVE_NETDB_H)
  62. check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
  63. check_include_file("stddef.h" HAVE_STDDEF_H)
  64. check_include_file("time.h" HAVE_TIME_H)
  65. check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
  66. check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
  67. check_include_file("sys/time.h" HAVE_SYS_TIME_H)
  68. check_include_file("errno.h" HAVE_ERRNO_H)
  69. check_include_file("dlfcn.h" HAVE_DLFCN_H)
  70. check_include_file("inttypes.h" HAVE_INTTYPES_H)
  71. check_include_file("memory.h" HAVE_MEMORY_H)
  72. check_include_file("stdint.h" HAVE_STDINT_H)
  73. check_include_file("stdlib.h" HAVE_STDLIB_H)
  74. check_include_file("string.h" HAVE_STRING_H)
  75. check_include_file("strings.h" HAVE_STRINGS_H)
  76. check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
  77. check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
  78. check_include_file("unistd.h" HAVE_UNISTD_H)
  79. include(CheckFunctionExists)
  80. # TODO: Also check if these functions are declared by the
  81. # expected headers. See comments around
  82. # AC_CHECK_FUNCS/AC_CHECK_DECLS in configure.ac.
  83. check_function_exists("gethostbyname" HAVE_GETHOSTBYNAME)
  84. check_function_exists("getaddrinfo" HAVE_GETADDRINFO)
  85. check_function_exists("gettimeofday" HAVE_GETTIMEOFDAY)
  86. check_function_exists("gmtime_r" HAVE_GMTIME_R)
  87. check_function_exists("inet_ntoa" HAVE_INET_NTOA)
  88. check_function_exists("memset" HAVE_MEMSET)
  89. check_function_exists("socket" HAVE_SOCKET)
  90. check_function_exists("strftime" HAVE_STRFTIME)
  91. include(CheckTypeSize)
  92. check_type_size("__uint128_t" __UINT128_T)
  93. check_type_size("long long" SIZEOF_LONG_LONG)
  94. check_type_size("long" SIZEOF_LONG)
  95. check_type_size("time_t" SIZEOF_TIME_T)
  96. # By default, HAVE___UINT128_T gets defined as TRUE,
  97. # but we want it as 1.
  98. if(HAVE___UINT128_T)
  99. set(HAVE___UINT128_T "1" CACHE INTERNAL "Result of TRY_COMPILE" FORCE)
  100. endif()
  101. include(TestBigEndian)
  102. test_big_endian(WORDS_BIGENDIAN)
  103. # Thread local storage
  104. include(CheckCSourceCompiles)
  105. set(TLS_KEYWORDS "__thread" "__declspec(thread)")
  106. foreach(TLS_KEYWORD IN LISTS TLS_KEYWORDS)
  107. set(TLS_CODE "#include <stdlib.h>
  108. static void foo(void) {
  109. static ${TLS_KEYWORD} int bar\;
  110. exit(1)\;
  111. }
  112. int main() {
  113. return 0\;
  114. }"
  115. )
  116. check_c_source_compiles(${TLS_CODE} THREAD_LS_ON)
  117. if(THREAD_LS_ON)
  118. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_THREAD_LS")
  119. break()
  120. else()
  121. # THREAD_LS_ON is cached after each call to
  122. # check_c_source_compiles, and the function
  123. # won't run subsequent times if the variable
  124. # is in the cache. To make it run again, we
  125. # need to remove the variable from the cache.
  126. unset(THREAD_LS_ON CACHE)
  127. endif()
  128. endforeach()
  129. # TODO: AX_PTHREAD does a lot. Need to implement the
  130. # rest of its logic.
  131. find_package(Threads)
  132. ####################################################
  133. # Cross Compile Example
  134. ####################################################
  135. #set(CMAKE_SYSTEM_NAME Linux)
  136. #set(CMAKE_SYSTEM_PROCESSOR arm)
  137. #set(CMAKE_C_COMPILER "/opt/arm-linux-musleabihf-cross/bin/arm-linux-musleabihf-gcc")
  138. #set(CMAKE_CXX_COMPILER "/opt/arm-linux-musleabihf-cross/bin/arm-linux-musleabihf-g++")
  139. #set(CMAKE_SYSROOT "/opt/arm-linux-musleabihf-cross/arm-linux-musleabihf/")
  140. # Example for setting CFLAGS
  141. #set(CMAKE_C_FLAGS "-std=gnu89 ${CMAKE_C_FLAGS}")
  142. # Example for map file and custom linker script
  143. #set(CMAKE_EXE_LINKER_FLAGS " -Xlinker -Map=output.map -T\"${CMAKE_CURRENT_SOURCE_DIR}/linker.ld\"")
  144. if(WIN32)
  145. # Windows cl.exe does not support the -Wextra, -Wno-unused and -Werror flags.
  146. set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}")
  147. else()
  148. set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused -Werror ${CMAKE_C_FLAGS}")
  149. endif()
  150. ####################################################
  151. # Build Options
  152. ####################################################
  153. # TODO: - FIPS
  154. # - Distro
  155. # - Linux Kernel Module
  156. # - Single precision math
  157. # - Enable all
  158. # - Enable all crypto
  159. # For reproducible build, gate out from the build anything that might
  160. # introduce semantically frivolous jitter, maximizing chance of
  161. # identical object files.
  162. add_option("WOLFSSL_REPRODUCIBLE_BUILD"
  163. "Enable maximally reproducible build (default: disabled)"
  164. "no" "yes;no")
  165. if(WOLFSSL_REPRODUCIBLE_BUILD)
  166. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_REPRODUCIBLE_BUILD")
  167. set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>")
  168. set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> Dq <TARGET> <LINK_FLAGS> <OBJECTS>")
  169. set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
  170. endif()
  171. # Support for forcing 32-bit mode
  172. # TODO: detect platform from other options
  173. add_option("WOLFSSL_32BIT"
  174. "Enables 32-bit support (default: disabled)"
  175. "no" "yes;no")
  176. # 16-bit compiler support
  177. add_option("WOLFSSL_16BIT"
  178. "Enables 16-bit support (default: disabled)"
  179. "no" "yes;no")
  180. if(WOLFSSL_16BIT)
  181. list(APPEND WOLFSSL_DEFINITIONS "-DWC_16BIT_CPU")
  182. endif()
  183. # Support for disabling all ASM
  184. add_option("WOLFSSL_ASM"
  185. "Enables option for assembly (default: enabled)"
  186. "yes" "yes;no")
  187. if(NOT WOLFSSL_ASM)
  188. list(APPEND WOLFSSL_DEFINITIONS
  189. "-DTFM_NO_ASM"
  190. "-DWOLFSSL_NO_ASM")
  191. endif()
  192. # Enable Debugging
  193. add_option("WOLFSSL_DEBUG"
  194. "Enables option for debug (default: disabled)"
  195. "no" "yes;no")
  196. if(WOLFSSL_DEBUG)
  197. set(CMAKE_C_FLAGS "-g ${CMAKE_C_FLAGS}")
  198. list(APPEND WOLFSSL_DEFINITIONS
  199. "-DDEBUG_WOLFSSL"
  200. "-DDEBUG")
  201. endif()
  202. # Single threaded
  203. add_option("WOLFSSL_SINGLE_THREADED"
  204. "Enable wolfSSL single threaded (default: disabled)"
  205. "no" "yes;no")
  206. # TODO: Logic here isn't complete, yet (see AX_PTHREAD)
  207. if(NOT WOLFSSL_SINGLE_THREADED)
  208. if(CMAKE_USE_PTHREADS_INIT)
  209. list(APPEND WOLFSSL_LINK_LIBS Threads::Threads)
  210. set(HAVE_PTHREAD 1)
  211. list(APPEND WOLFSSL_DEFINITIONS
  212. "-DHAVE_PTHREAD"
  213. "-D_POSIX_THREADS")
  214. endif()
  215. endif()
  216. # DTLS
  217. add_option("WOLFSSL_DTLS"
  218. "Enables wolfSSL DTLS (default: disabled)"
  219. "no" "yes;no")
  220. if(WOLFSSL_DTLS)
  221. list(APPEND WOLFSSL_DEFINITIONS
  222. "-DWOLFSSL_DTLS")
  223. endif()
  224. # TLS v1.3
  225. add_option("WOLFSSL_TLS13"
  226. "Enable wolfSSL TLS v1.3 (default: enabled)"
  227. "yes" "yes;no")
  228. if("${FIPS_VERSION}" STREQUAL "v1")
  229. override_cache(WOLFSSL_TLS13 "no")
  230. endif()
  231. # Post-handshake authentication
  232. add_option("WOLFSSL_POSTAUTH"
  233. "Enable wolfSSL Post-handshake Authentication (default: disabled)"
  234. "no" "yes;no")
  235. if(WOLFSSL_POSTAUTH)
  236. if(NOT WOLFSSL_TLS13)
  237. message(WARNING "TLS 1.3 is disabled - disabling Post-handshake Authentication")
  238. override_cache(WOLFSSL_POSTAUTH "no")
  239. else()
  240. list(APPEND WOLFSSL_DEFINITIONS
  241. "-DWOLFSSL_POST_HANDSHAKE_AUTH")
  242. endif()
  243. endif()
  244. # Hello Retry Request Cookie
  245. add_option("WOLFSSL_HRR_COOKIE"
  246. "Enable the server to send Cookie Extension in HRR with state (default: disabled)"
  247. "undefined" "yes;no;undefined")
  248. if("${WOLFSSL_HRR_COOKIE}" STREQUAL "yes")
  249. if(NOT WOLFSSL_TLS13)
  250. message(WARNING "TLS 1.3 is disabled - disabling HRR Cookie")
  251. override_cache(WOLFSSL_HRR_COOKIE "no")
  252. else()
  253. list(APPEND WOLFSSL_DEFINITIONS
  254. "-DWOLFSSL_SEND_HRR_COOKIE")
  255. endif()
  256. endif()
  257. # DTLS v1.3
  258. add_option("WOLFSSL_DTLS13"
  259. "Enable wolfSSL DTLS v1.3 (default: disabled)"
  260. "no" "yes;no")
  261. if(WOLFSSL_DTLS13)
  262. if (NOT WOLFSSL_DTLS)
  263. message(FATAL_ERROR "DTLS13 requires DTLS")
  264. endif()
  265. if (NOT WOLFSSL_TLS13)
  266. message(FATAL_ERROR "DTLS13 requires TLS13")
  267. endif()
  268. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_DTLS13")
  269. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_W64_WRAPPER")
  270. if ("${WOLFSSL_HRR_COOKIE}" STREQUAL "undefined")
  271. message(WARNING "DTLS1.3 is enabled - enabling HRR Cookie")
  272. override_cache(WOLFSSL_HRR_COOKIE "yes")
  273. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SEND_HRR_COOKIE")
  274. endif()
  275. if (WOLFSSL_AES)
  276. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_AES_DIRECT")
  277. endif()
  278. endif()
  279. # DTLS ConnectionID support
  280. add_option("WOLFSSL_DTLS_CID"
  281. "Enables wolfSSL DTLS CID (default: disabled)"
  282. "no" "yes;no")
  283. if(WOLFSSL_DTLS_CID)
  284. if(NOT WOLFSSL_DTLS13)
  285. message(FATAL_ERROR "CID are supported only for DTLSv1.3")
  286. endif()
  287. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_DTLS_CID")
  288. endif()
  289. # RNG
  290. add_option("WOLFSSL_RNG"
  291. "Enable compiling and using RNG (default: enabled)"
  292. "yes" "yes;no")
  293. if(NOT WOLFSSL_RNG)
  294. list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_RNG")
  295. endif()
  296. # TODO: - DTLS-SCTP
  297. # - DTLS multicast
  298. # - OpenSSH
  299. # - OpenVPN
  300. # - Nginx
  301. # - HAProxy
  302. # - wpa_supplicant
  303. # - Fortress
  304. # - libwebsockets
  305. # - IP alternative name
  306. # - Qt
  307. # - SSL bump
  308. # - sniffer
  309. # - Signal
  310. # - OpenSSL coexist
  311. # - OpenSSL compatibility all
  312. # - OpenSSL compatibility extra
  313. # - Max strength
  314. # Harden, enable Timing Resistance and Blinding by default
  315. add_option("WOLFSSL_HARDEN"
  316. "Enable Hardened build, Enables Timing Resistance and Blinding (default: enabled)"
  317. "yes" "yes;no")
  318. if(WOLFSSL_HARDEN)
  319. list(APPEND WOLFSSL_DEFINITIONS "-DTFM_TIMING_RESISTANT" "-DECC_TIMING_RESISTANT")
  320. if(WOLFSSL_RNG)
  321. list(APPEND WOLFSSL_DEFINITIONS "-DWC_RSA_BLINDING")
  322. endif()
  323. else()
  324. list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_HARDEN")
  325. endif()
  326. add_option(WOLFSSL_OPENSSLEXTRA
  327. "Enable extra OpenSSL API, size+ (default: disabled)"
  328. "no" "yes;no")
  329. if (WOLFSSL_OPENSSLEXTRA AND NOT WOLFSSL_OPENSSLCOEXIST)
  330. list(APPEND WOLFSSL_DEFINITIONS
  331. "-DOPENSSL_EXTRA"
  332. "-DWOLFSSL_ALWAYS_VERIFY_CB"
  333. "-DWOLFSSL_VERIFY_CB_ALL_CERTS"
  334. "-DWOLFSSL_EXTRA_ALERTS"
  335. "-DHAVE_EXT_CACHE"
  336. "-DWOLFSSL_FORCE_CACHE_ON_TICKET")
  337. endif()
  338. # TODO: - IPv6 test apps
  339. set(WOLFSSL_SLOW_MATH "yes")
  340. # liboqs
  341. add_option(WOLFSSL_OQS
  342. "Enable integration with the OQS (Open Quantum Safe) liboqs library (default: disabled)"
  343. "no" "yes;no")
  344. if (WOLFSSL_OQS)
  345. find_package(OQS)
  346. if (OQS_FOUND)
  347. list(APPEND WOLFSSL_LINK_LIBS ${OQS_LIBRARY})
  348. list(APPEND WOLFSSL_INCLUDE_DIRS ${OQS_INCLUDE_DIR})
  349. set(HAVE_LIBOQS 1)
  350. list(APPEND WOLFSSL_DEFINITIONS
  351. "-DHAVE_TLS_EXTENSIONS"
  352. "-DHAVE_LIBOQS")
  353. endif()
  354. endif()
  355. # TODO: - Lean PSK
  356. # - Lean TLS
  357. # - Low resource
  358. # - Titan cache
  359. # - Huge cache
  360. # - Big cache
  361. # - Small cache
  362. # - Persistent session cache
  363. # - Persistent cert cache
  364. # - Write duplicate
  365. # - Atomic user record layer
  366. # - Public key callbacks
  367. # - Microchip/Atmel CryptoAuthLib
  368. # AES-CBC
  369. add_option("WOLFSSL_AESCBC"
  370. "Enable wolfSSL AES-CBC support (default: enabled)"
  371. "yes" "yes;no")
  372. if(NOT WOLFSSL_AESCBC)
  373. list(APPEND WOLFSSL_DEFINITIONS "-DNO_AES_CBC")
  374. endif()
  375. # AES-GCM
  376. add_option("WOLFSSL_AESGCM"
  377. "Enable wolfSSL AES-GCM support (default: enabled)"
  378. "yes" "yes;no;table;small;word32;4bit")
  379. # leanpsk and leantls don't need gcm
  380. if(WOLFSSL_LEAN_PSK OR (WOLFSSL_LEAN_TLS AND NOT WOLFSSL_TLS13))
  381. override_cache(WOLFSSL_AESGCM "no")
  382. endif()
  383. if(WOLFSSL_AESGCM AND NOT WORDS_BIGENDIAN)
  384. override_cache(WOLFSSL_AESGCM "4bit")
  385. endif()
  386. if(WOLFSSL_AESGCM)
  387. if("${WOLFSSL_AESGCM}" STREQUAL "word32")
  388. list(APPEND WOLFSSL_DEFINITIONS "-DGCM_WORD32")
  389. override_cache(WOLFSSL_AESGCM "yes")
  390. endif()
  391. if(("${WOLFSSL_AESGCM}" STREQUAL "small") OR WOLFSSL_LOW_RESOURCE)
  392. list(APPEND WOLFSSL_DEFINITIONS "-DGCM_SMALL")
  393. override_cache(WOLFSSL_AESGCM "yes")
  394. endif()
  395. if("${WOLFSSL_AESGCM}" STREQUAL "table")
  396. list(APPEND WOLFSSL_DEFINITIONS "-DGCM_TABLE")
  397. override_cache(WOLFSSL_AESGCM "yes")
  398. endif()
  399. if("${WOLFSSL_AESGCM}" STREQUAL "4bit")
  400. list(APPEND WOLFSSL_DEFINITIONS "-DGCM_TABLE_4BIT")
  401. override_cache(WOLFSSL_AESGCM "yes")
  402. endif()
  403. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_AESGCM")
  404. endif()
  405. # AES-SIV
  406. add_option("WOLFSSL_AESSIV"
  407. "Enable wolfSSL AES-SIV support (default: disabled)"
  408. "no" "yes;no")
  409. if(WOLFSSL_AESSIV)
  410. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_AES_SIV")
  411. endif()
  412. # AES-CTR
  413. add_option("WOLFSSL_AESCTR"
  414. "Enable wolfSSL AES-CTR support (default: disabled)"
  415. "no" "yes;no")
  416. if(WOLFSSL_OPENVPN OR
  417. WOLFSSL_LIBSSH2 OR
  418. WOLFSSL_AESSIV)
  419. override_cache(WOLFSSL_AESCTR "yes")
  420. endif()
  421. if(WOLFSSL_AESCTR AND NOT WOLFSSL_FORTRESS)
  422. list(APPEND WOLFSSL_DEFINITIONS
  423. "-DWOLFSSL_AES_COUNTER"
  424. "-DWOLFSSL_AES_DIRECT")
  425. endif()
  426. # AES-CCM
  427. add_option("WOLFSSL_AESCCM"
  428. "Enable wolfSSL AES-CCM support (default: disabled)"
  429. "no" "yes;no")
  430. # AES-OFB
  431. add_option("WOLFSSL_AESOFB"
  432. "Enable wolfSSL AES-OFB support (default: disabled)"
  433. "no" "yes;no")
  434. # TODO: - AES-GCM stream
  435. # - AES-ARM
  436. # - Xilinx hardened crypto
  437. # - Intel AES-NI
  438. # - Intel ASM
  439. # - Intel RDRAND
  440. # - Linux af_alg
  441. # - Linux dev crpyto calls
  442. # - Camellia
  443. # - MD2
  444. # - NULL cipher
  445. # - RIPEMD
  446. # - BLAKE2
  447. add_option("WOLFSSL_AESCFB"
  448. "Enable wolfSSL AES-CFB support (default: disabled)"
  449. "no" "yes;no")
  450. # Align data
  451. add_option("WOLFSSL_ALIGN_DATA"
  452. "Align data for ciphers (default: enabled)"
  453. "yes" "yes;no")
  454. if(WOLFSSL_ALIGN_DATA)
  455. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_USE_ALIGN")
  456. endif()
  457. # SHA224
  458. set(SHA224_DEFAULT "no")
  459. if(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") OR
  460. ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
  461. if(NOT WOLFSSL_AFALG AND NOT WOLFSSL_DEVCRYPTO AND
  462. (NOT WOLFSSL_FIPS OR ("${FIPS_VERSION}" STREQUAL "v2")))
  463. set(SHA224_DEFAULT "yes")
  464. endif()
  465. endif()
  466. add_option("WOLFSSL_SHA224"
  467. "Enable wolfSSL SHA-224 support (default: enabled on x86_64/aarch64)"
  468. ${SHA224_DEFAULT} "yes;no")
  469. # SHA3
  470. set(SHA3_DEFAULT "no")
  471. if(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") OR
  472. ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64"))
  473. if(NOT WOLFSSL_FIPS OR ("${FIPS_VERSION}" STREQUAL "v2"))
  474. set(SHA3_DEFAULT "yes")
  475. endif()
  476. endif()
  477. add_option("WOLFSSL_SHA3"
  478. "Enable wolfSSL SHA-3 support (default: enabled on x86_64/aarch64)"
  479. ${SHA3_DEFAULT} "yes;no;small")
  480. # SHAKE256
  481. add_option("WOLFSSL_SHAKE256"
  482. "Enable wolfSSL SHAKE256 support (default: enabled on x86_64/aarch64)"
  483. "no" "yes;no;small")
  484. # SHA512
  485. add_option("WOLFSSL_SHA512"
  486. "Enable wolfSSL SHA-512 support (default: enabled)"
  487. "yes" "yes;no")
  488. # options that don't require sha512
  489. if(WOLFSSL_LEAN_PSK OR
  490. WOLFSSL_LEAN_TLS OR
  491. WOLFSSL_32BIT OR
  492. WOLFSSL_16BIT)
  493. override_cache(WOLFSSL_SHA512 "no")
  494. endif()
  495. # options that require sha512
  496. if(WOLFSSL_OPENSSH OR
  497. WOLFSSL_WPAS OR
  498. WOLFSSL_FORTRESS)
  499. override_cache(WOLFSSL_SHA512 "yes")
  500. endif()
  501. if(WOLFSSL_SHA512)
  502. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA512")
  503. endif()
  504. # SHA384
  505. add_option("WOLFSSL_SHA384"
  506. "Enable wolfSSL SHA-384 support (default: enabled)"
  507. "yes" "yes;no")
  508. # options that don't require sha384
  509. if(WOLFSSL_LEAN_PSK OR
  510. WOLFSSL_LEAN_TLS OR
  511. WOLFSSL_32BIT OR
  512. WOLFSSL_16BIT)
  513. override_cache(WOLFSSL_SHA384 "no")
  514. endif()
  515. # options that require sha384
  516. if(WOLFSSL_OPENSSH OR
  517. WOLFSSL_WPAS OR
  518. WOLFSSL_FORTRESS)
  519. override_cache(WOLFSSL_SHA384 "yes")
  520. endif()
  521. if(WOLFSSL_SHA384)
  522. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA384")
  523. endif()
  524. # TODO: - Session certs
  525. # - SEP
  526. add_option("WOLFSSL_KEYGEN"
  527. "Enable key generation (default: disabled)])"
  528. "no" "yes;no")
  529. add_option("WOLFSSL_CERTGEN"
  530. "Enable cert generation (default: disabled)"
  531. "no" "yes;no")
  532. add_option("WOLFSSL_CERTREQ"
  533. "Enable cert request generation (default: disabled)"
  534. "no" "yes;no")
  535. add_option("WOLFSSL_CERTEXT"
  536. "Enable cert request extensions (default: disabled)"
  537. "no" "yes;no")
  538. add_option("WOLFSSL_CERTGENCACHE"
  539. "Enable decoded cert caching (default: disabled)"
  540. "no" "yes;no")
  541. # HKDF
  542. add_option("WOLFSSL_HKDF"
  543. "Enable HKDF (HMAC-KDF) support (default: disabled)"
  544. "no" "yes;no")
  545. if(WOLFSSL_TLS13)
  546. override_cache(WOLFSSL_HKDF "yes")
  547. endif()
  548. if(WOLFSSL_HKDF)
  549. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_HKDF")
  550. endif()
  551. # DSA
  552. add_option("WOLFSSL_DSA"
  553. "Enable DSA (default: disabled)"
  554. "no" "yes;no")
  555. if(NOT WOLFSSL_DSA AND NOT WOLFSSL_OPENSSH)
  556. list(APPEND WOLFSSL_DEFINITIONS "-DNO_DSA")
  557. endif()
  558. # ECC Shamir
  559. add_option("WOLFSSL_ECCSHAMIR"
  560. "Enable ECC Shamir (default: enabled)"
  561. "yes" "yes;no")
  562. # ECC
  563. add_option("WOLFSSL_ECC"
  564. "Enable ECC (default: enabled)"
  565. "yes" "yes;no;nonblock")
  566. # lean psk doesn't need ecc
  567. if(WOLFSSL_LEAN_PSK)
  568. override_cache(WOLFSSL_ECC "no")
  569. endif()
  570. if(WOLFSSL_OPENSSH OR
  571. WOLFSSL_NGINX OR
  572. WOLFSSL_SIGNAL)
  573. override_cache(WOLFSSL_ECC "yes")
  574. endif()
  575. if(WOLFSSL_ECC)
  576. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ECC" "-DTFM_ECC256")
  577. if(WOLFSSL_ECCSHAMIR AND NOT WOLFSSL_LOW_RESOURCE)
  578. list(APPEND WOLFSSL_DEFINITIONS "-DECC_SHAMIR")
  579. endif()
  580. if("${WOLFSSL_ECC}" STREQUAL "nonblock")
  581. list(APPEND WOLFSSL_DEFINITIONS "-DWC_ECC_NONBLOCK")
  582. endif()
  583. endif()
  584. # TODO: - ECC custom curves
  585. # - Compressed key
  586. # - FP ECC, fixed point cache ECC
  587. # - ECC encrypt
  588. # - PSK
  589. # - Single PSK identity
  590. # CURVE25519
  591. set(WOLFSSL_CURVE25519_SMALL "no")
  592. add_option("WOLFSSL_CURVE25519"
  593. "Enable Curve25519 (default: disabled)"
  594. "no" "yes;no;small;no128bit")
  595. if(WOLFSSL_OPENSSH)
  596. override_cache(WOLFSSL_CURVE25519 "yes")
  597. endif()
  598. if(WOLFSSL_CURVE25519)
  599. if("${WOLFSSL_CURVE25519}" STREQUAL "small" OR WOLFSSL_LOW_RESOURCE)
  600. list(APPEND WOLFSSL_DEFINITIONS "-DCURVE25519_SMALL")
  601. set(WOLFSSL_CURVE25519_SMALL "yes")
  602. endif()
  603. if("${WOLFSSL_CURVE25519}" STREQUAL "no128bit" OR WOLFSSL_32BIT)
  604. list(APPEND WOLFSSL_DEFINITIONS "-DNO_CURVED25519_128BIT")
  605. endif()
  606. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CURVE25519")
  607. set(WOLFSSL_FEMATH "yes")
  608. endif()
  609. # ED25519
  610. set(WOLFSSL_ED25519_SMALL "no")
  611. add_option("WOLFSSL_ED25519"
  612. "Enable ED25519 (default: disabled)"
  613. "no" "yes;no")
  614. if(WOLFSSL_OPENSSH)
  615. override_cache(WOLFSSL_ED25519 "yes")
  616. endif()
  617. if(WOLFSSL_ED25519 AND NOT WOLFSSL_32BIT)
  618. if("${WOLFSSL_ED25519}" STREQUAL "small" OR WOLFSSL_LOW_RESOURCE)
  619. list(APPEND WOLFSSL_DEFINITIONS "-DED25519_SMALL")
  620. set(WOLFSSL_ED25519_SMALL "yes")
  621. set(WOLFSSL_CURVE25519_SMALL "yes")
  622. endif()
  623. if(NOT WOLFSSL_SHA512)
  624. message(FATAL_ERROR "cannot enable ed25519 without enabling sha512.")
  625. endif()
  626. set(WOLFSSL_FEMATH "yes")
  627. set(WOLFSSL_GEMATH "yes")
  628. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ED25519")
  629. endif()
  630. # CURVE448
  631. set(WOLFSSL_CURVE448_SMALL "no")
  632. add_option("WOLFSSL_CURVE448"
  633. "Enable Curve448 (default: disabled)"
  634. "no" "yes;no;small")
  635. if(WOLFSSL_CURVE448)
  636. if("${WOLFSSL_CURVE448}" STREQUAL "small" OR WOLFSSL_LOW_RESOURCE)
  637. list(APPEND WOLFSSL_DEFINITIONS "-DCURVE448_SMALL")
  638. set(WOLFSSL_CURVE448_SMALL "yes")
  639. endif()
  640. if("${WOLFSSL_CURVE448}" STREQUAL "no128bit" OR WOLFSSL_32BIT)
  641. list(APPEND WOLFSSL_DEFINITIONS "-DNO_CURVED448_128BIT")
  642. endif()
  643. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CURVE448")
  644. set(WOLFSSL_FE448 "yes")
  645. endif()
  646. # ED448
  647. set(WOLFSSL_ED448_SMALL "no")
  648. add_option("WOLFSSL_ED448"
  649. "Enable ED448 (default: disabled)"
  650. "no" "yes;no;small")
  651. if(WOLFSSL_ED448 AND NOT WOLFSSL_32BIT)
  652. if("${WOLFSSL_ED448}" STREQUAL "small" OR WOLFSSL_LOW_RESOURCE)
  653. list(APPEND WOLFSSL_DEFINITIONS "-DED448_SMALL")
  654. set(WOLFSSL_ED448_SMALL "yes")
  655. set(WOLFSSL_CURVE448_SMALL "yes")
  656. endif()
  657. if(NOT WOLFSSL_SHA512)
  658. message(FATAL_ERROR "cannot enable ed448 without enabling sha512.")
  659. endif()
  660. set(WOLFSSL_FE448 "yes")
  661. set(WOLFSSL_GE448 "yes")
  662. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ED448")
  663. # EdDSA448 requires SHAKE256 which requires SHA-3
  664. override_cache(WOLFSSL_SHAKE256 "yes")
  665. endif()
  666. # Error strings
  667. add_option("WOLFSSL_ERROR_STRINGS"
  668. "Enable error strings table (default: enabled)"
  669. "yes" "yes;no")
  670. if(NOT WOLFSSL_ERROR_STRINGS)
  671. list(APPEND WOLFSSL_DEFINITIONS "-DNO_ERROR_STRINGS")
  672. else()
  673. # turn off error strings if leanpsk or leantls on
  674. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  675. list(APPEND WOLFSSL_DEFINITIONS "-DNO_ERROR_STRINGS")
  676. override_cache(WOLFSSL_ERROR_STRINGS "no")
  677. endif()
  678. endif()
  679. # Error queue
  680. add_option("WOLFSSL_ERROR_QUEUE"
  681. "Enables adding nodes to error queue when compiled with OPENSSL_EXTRA (default: enabled)"
  682. "yes" "yes;no")
  683. if(NOT WOLFSSL_ERROR_QUEUE)
  684. list(APPEND WOLFSSL_DEFINITIONS "-DNO_ERROR_QUEUE")
  685. endif()
  686. # Old TLS
  687. add_option("WOLFSSL_OLD_TLS"
  688. "Enable old TLS versions < 1.2 (default: enabled)"
  689. "yes" "yes;no")
  690. if(NOT WOLFSSL_OLD_TLS)
  691. list(APPEND WOLFSSL_DEFINITIONS "-DNO_OLD_TLS")
  692. else()
  693. # turn off old if leanpsk or leantls on
  694. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  695. list(APPEND WOLFSSL_DEFINITIONS "-DNO_OLD_TLS")
  696. override_cache(WOLFSSL_OLD_TLS "no")
  697. endif()
  698. endif()
  699. # TLSv1.2
  700. add_option("WOLFSSL_TLSV12"
  701. "Enable TLS versions 1.2 (default: enabled)"
  702. "yes" "yes;no")
  703. if(NOT WOLFSSL_TLSV12)
  704. list(APPEND WOLFSSL_DEFINITIONS
  705. "-DWOLFSSL_NO_TLS12"
  706. "-DNO_OLD_TLS")
  707. endif()
  708. # TODO: - TLSv1.0
  709. # - SSLv3
  710. # - Stack size
  711. # - Stack size verbose
  712. # Memory
  713. add_option("WOLFSSL_MEMORY"
  714. "Enable memory callbacks (default: enabled)"
  715. "yes" "yes;no")
  716. if(NOT WOLFSSL_MEMORY)
  717. list(APPEND WOLFSSL_DEFINITIONS "-DNO_WOLFSSL_MEMORY")
  718. else()
  719. # turn off memory cb if leanpsk or leantls on
  720. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  721. # but don't turn on NO_WOLFSSL_MEMORY because using own
  722. override_cache(WOLFSSL_MEMORY "no")
  723. endif()
  724. endif()
  725. # TODO: - Track memory
  726. # - Memory log
  727. # - Stack log
  728. # RSA
  729. add_option("WOLFSSL_RSA"
  730. "Enable RSA (default: enabled)"
  731. "yes" "yes;no")
  732. if(NOT WOLFSSL_RSA)
  733. list(APPEND WOLFSSL_DEFINITIONS "-DNO_RSA")
  734. else()
  735. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  736. list(APPEND WOLFSSL_DEFINITIONS "-DNO_RSA")
  737. override_cache(WOLFSSL_RSA "no")
  738. endif()
  739. endif()
  740. # OAEP
  741. add_option("WOLFSSL_OAEP"
  742. "Enable RSA OAEP (default: enabled)"
  743. "yes" "yes;no")
  744. if(NOT WOLFSSL_OAEP)
  745. list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_RSA_OAEP")
  746. endif()
  747. # TODO: - RSA public only
  748. # - RSA verify inline only
  749. # RSA-PSS
  750. add_option("WOLFSSL_RSA_PSS"
  751. "Enable RSA-PSS (default: disabled)"
  752. "no" "yes;no")
  753. if(NOT WOLFSSL_RSA)
  754. override_cache(WOLFSSL_RSA_PSS "no")
  755. else()
  756. if(WOLFSSL_TLS13)
  757. override_cache(WOLFSSL_RSA_PSS "yes")
  758. endif()
  759. endif()
  760. if(WOLFSSL_RSA_PSS)
  761. list(APPEND WOLFSSL_DEFINITIONS "-DWC_RSA_PSS")
  762. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_PSS_LONG_SALT")
  763. endif()
  764. # DH
  765. add_option("WOLFSSL_DH"
  766. "Enable DH (default: enabled)"
  767. "yes" "yes;no")
  768. if(WOLFSSL_OPENSSH)
  769. override_cache(WOLFSSL_DH "yes")
  770. endif()
  771. if(NOT WOLFSSL_DH)
  772. list(APPEND WOLFSSL_DEFINITIONS "-DNO_DH")
  773. else()
  774. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  775. list(APPEND WOLFSSL_DEFINITIONS "-DNO_DH")
  776. override_cache(WOLFSSL_DH "no")
  777. endif()
  778. endif()
  779. # TODO: - Anonymous
  780. # ASN
  781. # turn off asn, which means no certs, no rsa, no dsa, no ecc,
  782. # and no big int (unless dh is on)
  783. add_option("WOLFSSL_ASN"
  784. "Enable ASN (default: enabled)"
  785. "yes" "yes;no")
  786. if(NOT WOLFSSL_ASN)
  787. list(APPEND WOLFSSL_DEFINITIONS "-DNO_ASN" "-DNO_CERTS")
  788. if(NOT WOLFSSL_DH AND NOT WOLFSSL_ECC)
  789. # DH and ECC need bigint
  790. list(APPEND WOLFSSL_DEFINITIONS "-DNO_BIG_INT")
  791. endif()
  792. else()
  793. # turn off ASN if leanpsk on
  794. if(WOLFSSL_LEAN_PSK)
  795. list(APPEND WOLFSSL_DEFINITIONS
  796. "-DNO_ASN"
  797. "-DNO_CERTS"
  798. "-DNO_BIG_INT")
  799. override_cache(WOLFSSL_ASN "no")
  800. else()
  801. if("${WOLFSSL_ASN}" STREQUAL "nocrypt")
  802. list(APPEND WOLFSSL_DEFINITIONS "-DNO_ASN_CRYPT")
  803. # TODO: verify that this is correct
  804. override_cache(WOLFSSL_PWDBASED "no")
  805. endif()
  806. endif()
  807. endif()
  808. if(WOLFSSL_RSA AND NOT WOLFSSL_RSA_VFY AND NOT WOLFSSL_ASN)
  809. message(FATAL_ERROR "please disable rsa if disabling asn.")
  810. endif()
  811. if(WOLFSSL_DSA AND NOT WOLFSSL_ASN)
  812. message(FATAL_ERROR "please disable dsa if disabling asn.")
  813. endif()
  814. # DH and ECC need bigint
  815. if(NOT WOLFSSL_ASN AND
  816. NOT WOLFSSL_DH AND
  817. NOT WOLFSSL_ECC AND
  818. NOT WOLFSSL_RSA)
  819. override_cache(WOLFSSL_FAST_MATH "no")
  820. set(WOLFSSL_SLOWMATH "no")
  821. endif()
  822. # AES
  823. add_option("WOLFSSL_AES"
  824. "Enable AES (default: enabled)"
  825. "yes" "yes;no")
  826. if(NOT WOLFSSL_AES)
  827. list(APPEND WOLFSSL_DEFINITIONS "-DNO_AES")
  828. if(WOLFSSL_FORTRESS)
  829. message(FATAL_ERROR "fortress requires aes")
  830. endif()
  831. if(WOLFSSL_ECC_ENCRYPT)
  832. message(FATAL_ERROR "cannot enable eccencrypt and hkdf without aes.")
  833. endif()
  834. if(WOLFSSL_AESGCM)
  835. message(FATAL_ERROR "AESGCM requires AES.")
  836. endif()
  837. if(WOLFSSL_AESCCM)
  838. message(FATAL_ERROR "AESCCM requires AES.")
  839. endif()
  840. if(WOLFSSL_AESCTR)
  841. message(FATAL_ERROR "AESCTR requires AES.")
  842. endif()
  843. else()
  844. if(WOLFSSL_LEAN_PSK)
  845. list(APPEND WOLFSSL_DEFINITIONS "-DNO_AES")
  846. override_cache(WOLFSSL_AES "no")
  847. endif()
  848. endif()
  849. # Coding
  850. add_option("WOLFSSL_CODING"
  851. "Enable coding base 16/64 (default: enabled)"
  852. "yes" "yes;no")
  853. if(NOT WOLFSSL_CODING)
  854. list(APPEND WOLFSSL_DEFINITIONS "-DNO_CODING")
  855. else()
  856. # turn off CODING if leanpsk on
  857. if(WOLFSSL_LEAN_PSK)
  858. list(APPEND WOLFSSL_DEFINITIONS "-DNO_CODING")
  859. override_cache(WOLFSSL_CODING "no")
  860. endif()
  861. endif()
  862. # Base64
  863. set(BASE64_ENCODE_DEFAULT "no")
  864. if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
  865. set(BASE64_ENCODE_DEFAULT "yes")
  866. endif()
  867. set(WOLFSSL_BASE64_ENCODE_HELP_STRING "Enable Base64 encoding (default: enabled on x86_64)")
  868. add_option("WOLFSSL_BASE64_ENCODE" ${WOLFSSL_BASE64_ENCODE_HELP_STRING} ${BASE64_ENCODE_DEFAULT} "yes;no")
  869. if(WOLFSSL_BASE64_ENCODE)
  870. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_BASE64_ENCODE")
  871. endif()
  872. # TODO: - Base16
  873. # DES3
  874. set(WOLFSSL_DES3_HELP_STRING "Enable DES3 (default: disabled)")
  875. add_option("WOLFSSL_DES3" ${WOLFSSL_DES3_HELP_STRING} "no" "yes;no")
  876. if(WOLFSSL_OPENSSH OR
  877. WOLFSSL_QT OR
  878. WOLFSSL_OPENVPN OR
  879. WOLFSSL_WPAS)
  880. override_cache(WOLFSSL_DES3 "yes")
  881. endif()
  882. # ARC4
  883. set(WOLFSSL_ARC4_HELP_STRING "Enable ARC4 (default: disabled)")
  884. add_option("WOLFSSL_ARC4" ${WOLFSSL_ARC4_HELP_STRING} "no" "yes;no")
  885. if(WOLFSSL_OPENSSH OR WOLFSSL_WPAS)
  886. override_cache(WOLFSSL_ARC4 "yes")
  887. endif()
  888. # MD5
  889. set(WOLFSSL_MD5_HELP_STRING "Enable MD5 (default: enabled)")
  890. add_option("WOLFSSL_MD5" ${WOLFSSL_MD5_HELP_STRING} "yes" "yes;no")
  891. if(NOT WOLFSSL_MD5)
  892. list(APPEND WOLFSSL_DEFINITIONS "-DNO_MD5" "-DNO_OLD_TLS")
  893. else()
  894. # turn off MD5 if leanpsk or leantls on
  895. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  896. list(APPEND WOLFSSL_DEFINITIONS "-DNO_MD5" "-DNO_OLD_TLS")
  897. override_cache(WOLFSSL_MD5 "no")
  898. endif()
  899. endif()
  900. # SHA
  901. add_option("WOLFSSL_SHA"
  902. "Enable SHA (default: enabled)"
  903. "yes" "yes;no")
  904. if(NOT WOLFSSL_SHA)
  905. list(APPEND WOLFSSL_DEFINITIONS "-DNO_SHA" "-DNO_OLD_TLS")
  906. else()
  907. # turn off SHA if leanpsk or leantls on
  908. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  909. list(APPEND WOLFSSL_DEFINITIONS "-DNO_SHA" "-DNO_OLD_TLS")
  910. override_cache(WOLFSSL_SHA "no")
  911. endif()
  912. endif()
  913. # TODO: - AES-XTS
  914. # - Web server
  915. # - Web client
  916. add_option("WOLFSSL_CMAC"
  917. "Enable CMAC (default: disabled)"
  918. "no" "yes;no")
  919. if(WOLFSSL_WPAS OR
  920. WOLFSSL_NTP OR
  921. WOLFSSL_AESSIV)
  922. override_cache(WOLFSSL_CMAC "yes")
  923. endif()
  924. if(WOLFSSL_CMAC)
  925. if (NOT WOLFSSL_AES)
  926. message(FATAL_ERROR "Cannot use CMAC without AES.")
  927. else()
  928. list(APPEND WOLFSSL_DEFINITIONS
  929. "-DWOLFSSL_CMAC"
  930. "-DWOLFSSL_AES_DIRECT")
  931. endif()
  932. endif()
  933. # TODO: - RC2
  934. # - FIPS, again (there's more logic for FIPS in configure.ac)
  935. # - Selftest
  936. # SHA224
  937. if(WOLFSSL_SHA224)
  938. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA224")
  939. endif()
  940. # SHA3
  941. if("${WOLFSSL_SHA3}" STREQUAL "small")
  942. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA3_SMALL")
  943. override_cache(WOLFSSL_SHA3 "yes")
  944. endif()
  945. if(WOLFSSL_SHA3 AND NOT WOLFSSL_32BIT)
  946. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHA3")
  947. endif()
  948. # SHAKE256
  949. if(WOLFSSL_SHAKE256)
  950. if(NOT WOLFSSL_32BIT)
  951. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_SHAKE256")
  952. if(NOT WOLFSSL_SHA3)
  953. message(FATAL_ERROR "Must have SHA-3 enabled: --enable-sha3")
  954. endif()
  955. endif()
  956. endif()
  957. # POLY1305
  958. set(POLY1305_DEFAULT "yes")
  959. if(WOLFSSL_FIPS)
  960. set(POLY1305_DEFAULT "no")
  961. endif()
  962. set(WOLFSSL_POLY1305_HELP_STRING "Enable wolfSSL POLY1305 support (default: enabled)")
  963. add_option("WOLFSSL_POLY1305" ${WOLFSSL_POLY1305_HELP_STRING} ${POLY1305_DEFAULT} "yes;no")
  964. # leanpsk and leantls don't need poly1305
  965. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  966. override_cache(WOLFSSL_POLY1305 "no")
  967. endif()
  968. if(WOLFSSL_POLY1305)
  969. list(APPEND WOLFSSL_DEFINITIONS
  970. "-DHAVE_POLY1305"
  971. "-DHAVE_ONE_TIME_AUTH")
  972. endif()
  973. # CHACHA
  974. set(CHACHA_DEFAULT "yes")
  975. if(WOLFSSL_FIPS)
  976. set(CHACHA_DEFAULT "no")
  977. endif()
  978. add_option("WOLFSSL_CHACHA"
  979. "Enable CHACHA (default: enabled). Use `=noasm` to disable ASM AVX/AVX2 speedups"
  980. ${CHACHA_DEFAULT} "yes;no;noasm")
  981. # leanpsk and leantls don't need chacha
  982. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  983. override_cache(WOLFSSL_CHACHA "no")
  984. endif()
  985. if(("${WOLFSSL_CHACHA}" STREQUAL "noasm") OR NOT WOLFSSL_ASM)
  986. list(APPEND WOLFSSL_DEFINITIONS "-DNO_CHACHA_ASM")
  987. endif()
  988. if(NOT ("${WOLFSSL_CHACHA}" STREQUAL "noasm") AND WOLFSSL_CHACHA)
  989. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CHACHA")
  990. endif()
  991. # TODO: - XCHACHA
  992. # Hash DRBG
  993. add_option("WOLFSSL_HASH_DRBG"
  994. "Enable Hash DRBG support (default: enabled)"
  995. "yes" "yes;no")
  996. if(WOLFSSL_HASH_DRBG)
  997. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_HASHDRBG")
  998. else()
  999. # turn on Hash DRBG if FIPS is on
  1000. if(WOLFSSL_FIPS)
  1001. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_HASHDRBG")
  1002. override_cache(WOLFSSL_HASH_DRBG "yes")
  1003. else()
  1004. list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_HASHDRBG")
  1005. endif()
  1006. endif()
  1007. # Filesystem
  1008. if(WOLFSSL_LINUX_KM)
  1009. set(FILESYSTEM_DEFAULT "no")
  1010. else()
  1011. set(FILESYSTEM_DEFAULT "yes")
  1012. endif()
  1013. add_option("WOLFSSL_FILESYSTEM"
  1014. "Enable Filesystem support (default: enabled)"
  1015. ${FILESYSTEM_DEFAULT} "yes;no")
  1016. if(NOT WOLFSSL_FILESYSTEM)
  1017. list(APPEND WOLFSSL_DEFINITIONS "-DNO_FILESYSTEM")
  1018. else()
  1019. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  1020. list(APPEND WOLFSSL_DEFINITIONS "-DNO_FILESYSTEM")
  1021. override_cache(WOLFSSL_FILESYSTEM "no")
  1022. endif()
  1023. endif()
  1024. # Inline function support
  1025. add_option("WOLFSSL_INLINE"
  1026. "Enable inline functions (default: enabled)"
  1027. "yes" "yes;no")
  1028. if(NOT WOLFSSL_INLINE)
  1029. list(APPEND WOLFSSL_DEFINITIONS "-DNO_INLINE")
  1030. endif()
  1031. # TODO:
  1032. # - CRL monitor
  1033. # - User crypto
  1034. # - Whitewood netRandom client library
  1035. # - SNI
  1036. # - Max fragment length
  1037. # - ALPN
  1038. # - Trusted CA indication
  1039. # - Truncated HMAC
  1040. # - Renegotiation indication
  1041. # - Secure renegotiation
  1042. # - Fallback SCSV
  1043. add_option(WOLFSSL_OCSP "Enable OCSP (default: disabled)" "no" "yes;no")
  1044. add_option(WOLFSSL_OCSPSTAPLING "Enable OCSP Stapling (default: disabled)" "no" "yes;no")
  1045. add_option(WOLFSSL_OCSPSTAPLING_V2 "Enable OCSP Stapling v2 (default: disabled)" "no" "yes;no")
  1046. add_option(WOLFSSL_CRL
  1047. "Enable CRL (Use =io for inline CRL HTTP GET) (default: disabled)"
  1048. "no" "yes;no;io")
  1049. set(WOLFSSL_SNI_HELP_STRING "Enable SNI (default: disabled)")
  1050. add_option(WOLFSSL_SNI ${WOLFSSL_SNI_HELP_STRING} "no" "yes;no")
  1051. set(WOLFSSL_TLSX_HELP_STRING "Enable all TLS Extensions (default: disabled)")
  1052. add_option(WOLFSSL_TLSX ${WOLFSSL_TLSX_HELP_STRING} "no" "yes;no")
  1053. # Supported elliptic curves extensions
  1054. add_option("WOLFSSL_SUPPORTED_CURVES"
  1055. "Enable Supported Elliptic Curves (default: enabled)"
  1056. "yes" "yes;no")
  1057. if(WOLFSSL_SUPPORTED_CURVES)
  1058. if(NOT WOLFSSL_ECC AND NOT WOLFSSL_CURVE25519 AND NOT WOLFSSL_CURVE448)
  1059. override_cache(WOLFSSL_SUPPORTED_CURVES "no")
  1060. else()
  1061. list(APPEND WOLFSSL_DEFINITIONS
  1062. "-DHAVE_TLS_EXTENSIONS"
  1063. "-DHAVE_SUPPORTED_CURVES")
  1064. endif()
  1065. endif()
  1066. # Diffie-Hellman
  1067. if(WOLFSSL_DH)
  1068. if(WOLFSSL_TLS13 OR WOLFSSL_SUPPORTED_CURVES)
  1069. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_FFDHE_2048")
  1070. endif()
  1071. endif()
  1072. # TODO: - FFDHE params only
  1073. # TLS 1.3 Requires either ECC or (RSA/DH), or CURVE25519/ED25519 or CURVE448/ED448
  1074. if (NOT WOLFSSL_ECC AND
  1075. (NOT WOLFSSL_RSA OR NOT WOLFSSL_DH) AND
  1076. (NOT WOLFSSL_CURVE25519 OR NOT WOLFSSL_ED25519) AND
  1077. (NOT WOLFSSL_CURVE448 AND NOT WOLFSSL_ED448))
  1078. override_cache(WOLFSSL_TLS13 "no")
  1079. endif()
  1080. if (WOLFSSL_TLS13)
  1081. list(APPEND WOLFSSL_DEFINITIONS
  1082. "-DHAVE_SUPPORTED_CURVES"
  1083. "-DWOLFSSL_TLS13"
  1084. "-DHAVE_TLS_EXTENSIONS"
  1085. )
  1086. endif()
  1087. # Session Ticket Extension
  1088. add_option("WOLFSSL_SESSION_TICKET"
  1089. "Enable Session Ticket (default: disabled)"
  1090. "no" "yes;no")
  1091. if(WOLFSSL_NGINX OR WOLFSSL_WPAS OR WOLFSSL_HAPROXY OR WOLFSSL_LIGHTY)
  1092. override_cache(WOLFSSL_SESSION_TICKET "yes")
  1093. endif()
  1094. if(WOLFSSL_SESSION_TICKET)
  1095. list(APPEND WOLFSSL_DEFINITIONS
  1096. "-DHAVE_TLS_EXTENSIONS"
  1097. "-DHAVE_SESSION_TICKET")
  1098. endif()
  1099. # Extended master secret extension
  1100. add_option("WOLFSSL_EXTENDED_MASTER"
  1101. "Enable Extended Master Secret (default: enabled)"
  1102. "yes" "yes;no")
  1103. if(WOLFSSL_EXTENDED_MASTER)
  1104. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_EXTENDED_MASTER")
  1105. endif()
  1106. if(NOT WOLFSSL_ARC4)
  1107. list(APPEND WOLFSSL_DEFINITIONS "-DNO_RC4")
  1108. else()
  1109. # turn off ARC4 if leanpsk or leantls on
  1110. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  1111. list(APPEND WOLFSSL_DEFINITIONS "-DNO_RC4")
  1112. override_cache(WOLFSSL_ARC4 "no")
  1113. endif()
  1114. endif()
  1115. # TODO: - TLS extensions
  1116. # - Early data handshake
  1117. # - wolfSSH options
  1118. # - SCEP
  1119. # - Secure remote password
  1120. # - Indefinite length encoded messages
  1121. # - Small stack cache
  1122. # - Small stack
  1123. # - Valgrind
  1124. # - Test certs
  1125. # - I/O pool example
  1126. # - Certificate service
  1127. # - wolfSSL JNI
  1128. # - lighttpd/lighty
  1129. # - Asio
  1130. # - Apache HTTPD
  1131. set(WOLFSSL_PKCS7_HELP_STRING "Enable PKCS7 (default: disabled)")
  1132. add_option(WOLFSSL_PKCS7 ${WOLFSSL_PKCS7_HELP_STRING} "no" "yes;no")
  1133. set(WOLFSSL_TPM_HELP_STRING "Enable wolfTPM options (default: disabled)")
  1134. add_option(WOLFSSL_TPM ${WOLFSSL_TPM_HELP_STRING} "no" "yes;no")
  1135. set(WOLFSSL_AESKEYWRAP_HELP_STRING "Enable AES key wrap support (default: disabled)")
  1136. add_option(WOLFSSL_AESKEYWRAP ${WOLFSSL_AESKEYWRAP_HELP_STRING} "no" "yes;no")
  1137. set(WOLFSSL_X963KDF_HELP_STRING "Enable X9.63 KDF support (default: disabled)")
  1138. add_option(WOLFSSL_X963KDF ${WOLFSSL_X963KDF_HELP_STRING} "no" "yes;no")
  1139. # Encrypt-then-mac
  1140. add_option("WOLFSSL_ENC_THEN_MAC"
  1141. "Enable Encryptr-Then-Mac extension (default: enabled)"
  1142. "yes" "yes;no")
  1143. if(WOLFSSL_APACHE_HTTPD)
  1144. override_cache(WOLFSSL_ENC_THEN_MAC "no")
  1145. endif()
  1146. if(WOLFSSL_TLSX)
  1147. override_cache(WOLFSSL_ENC_THEN_MAC "yes")
  1148. endif()
  1149. if(WOLFSSL_SNIFFER)
  1150. override_cache(WOLFSSL_ENC_THEN_MAC "no")
  1151. endif()
  1152. # stunnel Support
  1153. # TODO: rest of stunnel support
  1154. add_option("WOLFSSL_STUNNEL"
  1155. "Enable stunnel (default: disabled)"
  1156. "no" "yes;no")
  1157. if(WOLFSSL_ENC_THEN_MAC)
  1158. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_ENCRYPT_THEN_MAC")
  1159. endif()
  1160. if(NOT WOLFSSL_PSK AND
  1161. NOT WOLFSSL_LEAN_PSK AND
  1162. NOT WOLFSSL_STUNNEL)
  1163. list(APPEND WOLFSSL_DEFINITIONS "-DNO_PSK")
  1164. endif()
  1165. # MD4
  1166. set(WOLFSSL_MD4_HELP_STRING "Enable MD4 (default: disabled)")
  1167. add_option("WOLFSSL_MD4" ${WOLFSSL_MD4_HELP_STRING} "no" "yes;no")
  1168. if(NOT WOLFSSL_MD4)
  1169. # turn on MD4 if using stunnel
  1170. if(WOLFSSL_STUNNEL OR WOLFSSL_WPAS)
  1171. override_cache(WOLFSSL_MD4 "yes")
  1172. else()
  1173. list(APPEND WOLFSSL_DEFINITIONS "-DNO_MD4")
  1174. endif()
  1175. endif()
  1176. # Encrypted keys
  1177. add_option("WOLFSSL_ENCKEYS"
  1178. "Enable PEM encrypted key support (default: disabled)"
  1179. "no" "yes;no")
  1180. if(NOT WOLFSSL_ENCKEYS)
  1181. if(WOLFSSL_OPENSSLEXTRA OR
  1182. WOLFSSL_WEBSERVER OR
  1183. WOLFSSL_WPAS)
  1184. # opensslextra, webserver, and WPAS needs enckeys
  1185. override_cache(WOLFSSL_ENCKEYS "yes")
  1186. endif()
  1187. endif()
  1188. if(WOLFSSL_ENCKEYS)
  1189. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_ENCRYPTED_KEYS")
  1190. endif()
  1191. # PKCS#12
  1192. set(WOLFSSL_PKCS12_HELP_STRING "Enable pkcs12 (default: enabled)")
  1193. add_option("WOLFSSL_PKCS12" ${WOLFSSL_PKCS12_HELP_STRING} "yes" "yes;no")
  1194. if(NOT WOLFSSL_ASN)
  1195. override_cache(WOLFSSL_PKCS12 "no")
  1196. endif()
  1197. if(NOT WOLFSSL_PKCS12)
  1198. list(APPEND WOLFSSL_DEFINITIONS "-DNO_PKCS12")
  1199. endif()
  1200. # PWDBASED has to come after certservice since we want it on w/o explicit on
  1201. # PWDBASED
  1202. add_option("WOLFSSL_PWDBASED"
  1203. "Enable PWDBASED (default: disabled)"
  1204. "no" "yes;no")
  1205. if(NOT WOLFSSL_PWDBASED)
  1206. if(WOLFSSL_OPENSSLEXTRA OR
  1207. WOLFSSL_OPENSSLALL OR
  1208. WOLFSSL_WEBSERVER OR
  1209. WOLFSSL_ENC_KEYS OR
  1210. WOLFSSL_PKCS12)
  1211. # opensslextra, opensslall, webserver, and enckeys needs pwdbased
  1212. override_cache(WOLFSSL_PWDBASED "yes")
  1213. else()
  1214. list(APPEND WOLFSSL_DEFINITIONS "-DNO_PWDBASED")
  1215. endif()
  1216. endif()
  1217. # TODO: - SCRYPT
  1218. # - wolfCrypt only
  1219. # fastmath
  1220. add_option("WOLFSSL_FAST_MATH"
  1221. "Enable fast math ops (default: disabled)"
  1222. "no" "yes;no")
  1223. if(WOLFSSL_FAST_MATH)
  1224. # turn off fastmath if leanpsk on or asn off (w/o DH and ECC)
  1225. if(WOLFSSL_LEAN_PSK OR NOT WOLFSSL_ASN)
  1226. if(NOT WOLFSSL_DH AND
  1227. NOT WOLFSSL_ECC AND
  1228. NOT WOLFSSL_RSA)
  1229. override_cache(WOLFSSL_FAST_MATH "no")
  1230. else()
  1231. list(APPEND WOLFSSL_DEFINITIONS "-DUSE_FAST_MATH")
  1232. set(WOLFSSL_SLOWMATH "no")
  1233. endif()
  1234. else()
  1235. list(APPEND WOLFSSL_DEFINITIONS "-DUSE_FAST_MATH")
  1236. set(WOLFSSL_SLOWMATH "no")
  1237. endif()
  1238. if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
  1239. # Have settings.h set FP_MAX_BITS higher if user didn't set directly
  1240. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_X86_64_BUILD")
  1241. endif()
  1242. endif()
  1243. # TODO: - Fast huge math
  1244. # SP math all
  1245. add_option("WOLFSSL_SP_MATH_ALL"
  1246. "Enable Single Precision math implementation for full algorithm suite (default: enabled)"
  1247. "yes" "yes;no")
  1248. # Enable examples, used to disable examples
  1249. if(WOLFSSL_LINUX_KM)
  1250. set(EXAMPLES_DEFAULT "no")
  1251. else()
  1252. set(EXAMPLES_DEFAULT "yes")
  1253. endif()
  1254. add_option("WOLFSSL_EXAMPLES"
  1255. "Enable examples (default: enabled)"
  1256. ${EXAMPLES_DEFAULT} "yes;no")
  1257. if(NOT WOLFSSL_FILESYSTEM OR
  1258. NOT WOLFSSL_INLINE OR
  1259. WOLFSSL_CRYPT_ONLY)
  1260. override_cache(WOLFSSL_EXAMPLES "no")
  1261. endif()
  1262. # Enable wolfCrypt test and benchmark
  1263. if(WOLFSSL_LINUX_KM)
  1264. set(CRYPT_TESTS_DEFAULT "no")
  1265. else()
  1266. set(CRYPT_TESTS_DEFAULT "yes")
  1267. endif()
  1268. add_option("WOLFSSL_CRYPT_TESTS"
  1269. "Enable Crypt Bench/Test (default: enabled)"
  1270. ${CRYPT_TESTS_DEFAULT} "yes;no")
  1271. add_option("WOLFSSL_CRYPT_TESTS_LIBS"
  1272. "Build static libraries from the wolfCrypt test and benchmark sources (default: disabled)"
  1273. "no" "yes;no")
  1274. # TODO: - LIBZ
  1275. # - PKCS#11
  1276. # - Cavium
  1277. # - Cavium V
  1278. # - Cavium Octeon
  1279. # - Intel QuickAssist
  1280. # - SP ASM (and other SP logic)
  1281. # - Fast RSA
  1282. # - Static memory use
  1283. # - Microchip API
  1284. # - Asynchronous crypto
  1285. # Asynchronous threading
  1286. add_option("WOLFSSL_ASYNC_THREADS"
  1287. "Enable Asynchronous Threading (default: enabled)"
  1288. "yes" "yes;no")
  1289. if(WOLFSSL_ASYNC_CRYPT AND WOLFSSL_ASYNC_THREADS)
  1290. if(CMAKE_USE_PTHREADS_INIT)
  1291. override_cache(WOLFSSL_ASYNC_THREADS "yes")
  1292. else()
  1293. override_cache(WOLFSSL_ASYNC_THREADS "no")
  1294. endif()
  1295. else()
  1296. override_cache(WOLFSSL_ASYNC_THREADS "no")
  1297. endif()
  1298. if(WOLFSSL_ASYNC_THREADS)
  1299. list(APPEND WOLFSSL_LINK_LIBS Threads::Threads)
  1300. list(APPEND WOLFSSL_DEFINITIONS "-D_GNU_SOURCE")
  1301. else()
  1302. list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_ASYNC_THREADING")
  1303. endif()
  1304. # TODO: - cryptodev
  1305. # - Session export
  1306. add_option("WOLFSSL_CRYPTOCB"
  1307. "Enable crypto callbacks (default: disabled)"
  1308. "no" "yes;no")
  1309. add_option("WOLFSSL_OLD_NAMES"
  1310. "Keep backwards compat with old names (default: enabled)"
  1311. "yes" "yes;no")
  1312. if(NOT WOLFSSL_OLD_NAMES AND NOT WOLFSSL_OPENSSL_COEXIST)
  1313. list(APPEND WOLFSSL_DEFINITIONS
  1314. "-DNO_OLD_RNGNAME"
  1315. "-DNO_OLD_WC_NAMES"
  1316. "-DNO_OLD_SSL_NAMES"
  1317. "-DNO_OLD_SHA_NAMES")
  1318. endif()
  1319. # TODO: - Memory tests
  1320. # - Hash flags
  1321. # Support for enabling setting default DH parameters
  1322. add_option("WOLFSSL_DH_DEFAULT_PARAMS"
  1323. "Enables option for default dh parameters (default: disabled)"
  1324. "no" "yes;no")
  1325. if(WOLFSSL_DH_DEFAULT_PARAMS OR NOT WOLFSSL_QT)
  1326. override_cache(WOLFSSL_DH_DEFAULT_PARAMS "yes")
  1327. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_DH_DEFAULT_PARAMS")
  1328. endif()
  1329. if(NOT WOLFSSL_DES3)
  1330. list(APPEND WOLFSSL_DEFINITIONS "-DNO_DES3")
  1331. else()
  1332. # turn off DES3 if leanpsk or leantls on
  1333. if(WOLFSSL_LEAN_PSK OR WOLFSSL_LEAN_TLS)
  1334. list(APPEND WOLFSSL_DEFINITIONS "-DNO_DES3")
  1335. override_cache(WOLFSSL_DES3 "no")
  1336. endif()
  1337. endif()
  1338. add_option("WOLFSSL_USER_SETTINGS"
  1339. "Use your own user_settings.h and do not add Makefile CFLAGS (default: disabled)"
  1340. "no" "yes;no")
  1341. add_option("WOLFSSL_OPTFLAGS"
  1342. "Enable default optimization CFLAGS for the compiler (default: enabled)"
  1343. "yes" "yes;no")
  1344. # FLAGS operations
  1345. if(WOLFSSL_AESCCM)
  1346. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_AESCCM")
  1347. endif()
  1348. if(WOLFSSL_AESOFB)
  1349. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_AES_OFB" "-DWOLFSSL_AES_DIRECT")
  1350. endif()
  1351. if(WOLFSSL_TPM)
  1352. override_cache(WOLFSSL_KEYGEN "yes")
  1353. override_cache(WOLFSSL_CERTGEN "yes")
  1354. override_cache(WOLFSSL_CRYPTOCB "yes")
  1355. override_cache(WOLFSSL_CERTREQ "yes")
  1356. override_cache(WOLFSSL_CERTEXT "yes")
  1357. override_cache(WOLFSSL_PKCS7 "yes")
  1358. override_cache(WOLFSSL_AESCFB "yes")
  1359. endif()
  1360. if(WOLFSSL_AESCFB)
  1361. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_AES_CFB")
  1362. endif()
  1363. if(WOLFSSL_PKCS7)
  1364. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_PKCS7")
  1365. override_cache(WOLFSSL_AESKEYWRAP "yes")
  1366. # Enable prereqs if not already enabled
  1367. if(WOLFSSL_ECC)
  1368. override_cache(WOLFSSL_X963KDF "yes")
  1369. endif()
  1370. endif()
  1371. if(WOLFSSL_X963KDF)
  1372. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_X963_KDF")
  1373. endif()
  1374. if(WOLFSSL_AESKEYWRAP)
  1375. list(APPEND WOLFSSL_DEFINITIONS
  1376. "-DHAVE_AES_KEYWRAP"
  1377. "-DWOLFSSL_AES_DIRECT"
  1378. )
  1379. endif()
  1380. if(WOLFSSL_KEYGEN)
  1381. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_KEY_GEN")
  1382. endif()
  1383. if(WOLFSSL_CERTGEN)
  1384. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_CERT_GEN")
  1385. endif()
  1386. if(WOLFSSL_CERTREQ)
  1387. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_CERT_REQ")
  1388. endif()
  1389. if(WOLFSSL_CERTEXT)
  1390. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_CERT_EXT")
  1391. endif()
  1392. if(WOLFSSL_CERTGENCACHE)
  1393. list(APPEND WOLFSSL_DEFINITIONS "-DWOLFSSL_CERT_GEN_CACHE")
  1394. endif()
  1395. if(WOLFSSL_CRYPTOCB)
  1396. list(APPEND WOLFSSL_DEFINITIONS "-DWOLF_CRYPTO_CB")
  1397. endif()
  1398. if(WOLFSSL_OCSPSTAPLING)
  1399. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CERTIFICATE_STATUS_REQUEST" "-DHAVE_TLS_EXTENSIONS")
  1400. override_cache(WOLFSSL_OCSP "yes")
  1401. endif()
  1402. if(WOLFSSL_OCSPSTAPLING_V2)
  1403. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CERTIFICATE_STATUS_REQUEST_V2" "-DHAVE_TLS_EXTENSIONS")
  1404. override_cache(WOLFSSL_OCSP "yes")
  1405. endif()
  1406. # must be below OCSP stapling options to allow override
  1407. if (WOLFSSL_OCSP)
  1408. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_OCSP")
  1409. endif()
  1410. if (WOLFSSL_CRL STREQUAL "yes")
  1411. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CRL")
  1412. elseif(WOLFSSL_CRL STREQUAL "io")
  1413. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CRL" "-DHAVE_CRL_IO")
  1414. endif()
  1415. if (WOLFSSL_SNI)
  1416. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_TLS_EXTENSIONS" "-DHAVE_SNI")
  1417. endif()
  1418. if (WOLFSSL_TLSX)
  1419. list(APPEND WOLFSSL_DEFINITIONS
  1420. "-DHAVE_TLS_EXTENSIONS"
  1421. "-DHAVE_SNI"
  1422. "-DHAVE_MAX_FRAGMENT"
  1423. "-DHAVE_TRUNCATED_HMAC"
  1424. "-DHAVE_ALPN"
  1425. "-DHAVE_TRUSTED_CA")
  1426. if (WOLFSSL_ECC OR WOLFSSL_CURVE25519 OR WOLFSSL_CURVE448 OR WOLFSSL_TLS13)
  1427. list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_SUPPORTED_CURVES")
  1428. endif()
  1429. endif()
  1430. # Generates the BUILD_* flags. These control what source files are included in
  1431. # the library. A series of AM_CONDITIONALs handle this in configure.ac.
  1432. generate_build_flags()
  1433. # TODO: - Bit of logic after optimization flags option (above)
  1434. # - Check for build-type conflicts section
  1435. # USER SETTINGS
  1436. if(WOLFSSL_USER_SETTINGS)
  1437. # Replace all options and just use WOLFSSL_USER_SETTINGS
  1438. set(WOLFSSL_DEFINITIONS "-DWOLFSSL_USER_SETTINGS")
  1439. endif()
  1440. # TODO: Applying definitions to everything like this, rather than
  1441. # individual targets, is discouraged in CMake.
  1442. add_definitions(${WOLFSSL_DEFINITIONS})
  1443. add_option("WOLFSSL_CONFIG_H"
  1444. "Enable generation of config.h and define HAVE_CONFIG_H (default: enabled)"
  1445. "yes" "yes;no")
  1446. if(WOLFSSL_CONFIG_H)
  1447. add_definitions("-DHAVE_CONFIG_H")
  1448. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.in"
  1449. "${CMAKE_CURRENT_BINARY_DIR}/config.h" )
  1450. set(abs_top_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
  1451. set(abs_top_builddir ${CMAKE_CURRENT_BINARY_DIR})
  1452. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/wolfcrypt/test/test_paths.h.in"
  1453. "${CMAKE_CURRENT_BINARY_DIR}/wolfcrypt/test/test_paths.h" )
  1454. endif()
  1455. # Suppress some warnings about separate compilation, inlining
  1456. add_definitions("-DWOLFSSL_IGNORE_FILE_WARN")
  1457. # Generate user options header
  1458. message("Generating user options header...")
  1459. if (${CMAKE_DISABLE_SOURCE_CHANGES})
  1460. set(WOLFSSL_BUILD_OUT_OF_TREE_DEFAULT "${CMAKE_DISABLE_SOURCE_CHANGES}")
  1461. else()
  1462. set(WOLFSSL_BUILD_OUT_OF_TREE_DEFAULT "no")
  1463. endif()
  1464. add_option("WOLFSSL_BUILD_OUT_OF_TREE"
  1465. "Don't generate files in the source tree (default: ${WOLFSSL_BUILD_OUT_OF_TREE_DEFAULT})"
  1466. "${WOLFSSL_BUILD_OUT_OF_TREE_DEFAULT}" "yes;no")
  1467. if (${WOLFSSL_BUILD_OUT_OF_TREE})
  1468. set(WOLFSSL_OUTPUT_BASE ${CMAKE_CURRENT_BINARY_DIR})
  1469. else()
  1470. set(WOLFSSL_OUTPUT_BASE ${CMAKE_CURRENT_SOURCE_DIR})
  1471. endif()
  1472. set(OPTION_FILE "${WOLFSSL_OUTPUT_BASE}/wolfssl/options.h")
  1473. set(CYASSL_OPTION_FILE "${WOLFSSL_OUTPUT_BASE}/cyassl/options.h")
  1474. file(REMOVE ${OPTION_FILE})
  1475. file(APPEND ${OPTION_FILE} "/* wolfssl options.h\n")
  1476. file(APPEND ${OPTION_FILE} " * generated from configure options\n")
  1477. file(APPEND ${OPTION_FILE} " *\n")
  1478. file(APPEND ${OPTION_FILE} " * Copyright (C) 2006-2020 wolfSSL Inc.\n")
  1479. file(APPEND ${OPTION_FILE} " *\n")
  1480. file(APPEND ${OPTION_FILE} " * This file is part of wolfSSL. (formerly known as CyaSSL)\n")
  1481. file(APPEND ${OPTION_FILE} " *\n")
  1482. file(APPEND ${OPTION_FILE} " */\n\n")
  1483. file(APPEND ${OPTION_FILE} "#ifndef WOLFSSL_OPTIONS_H\n")
  1484. file(APPEND ${OPTION_FILE} "#define WOLFSSL_OPTIONS_H\n\n\n")
  1485. file(APPEND ${OPTION_FILE} "#ifdef __cplusplus\n")
  1486. file(APPEND ${OPTION_FILE} "extern \"C\" {\n")
  1487. file(APPEND ${OPTION_FILE} "#endif\n\n")
  1488. add_to_options_file("${WOLFSSL_DEFINITIONS}" "${OPTION_FILE}")
  1489. # CMAKE_C_FLAGS is just a string of space-separated flags to pass to the C
  1490. # compiler. We need to replace those spaces with semicolons in order to treat it
  1491. # as a CMake list.
  1492. string(REPLACE " " ";" CMAKE_C_FLAGS_LIST "${CMAKE_C_FLAGS}")
  1493. add_to_options_file("${CMAKE_C_FLAGS_LIST}" "${OPTION_FILE}")
  1494. file(APPEND ${OPTION_FILE} "\n#ifdef __cplusplus\n")
  1495. file(APPEND ${OPTION_FILE} "}\n")
  1496. file(APPEND ${OPTION_FILE} "#endif\n\n\n")
  1497. file(APPEND ${OPTION_FILE} "#endif /* WOLFSSL_OPTIONS_H */\n\n")
  1498. # backwards compatibility for those who have included options or version
  1499. file(REMOVE ${CYASSL_OPTION_FILE})
  1500. file(APPEND ${CYASSL_OPTION_FILE} "/* cyassl options.h\n")
  1501. file(APPEND ${CYASSL_OPTION_FILE} " * generated from wolfssl/options.h\n")
  1502. file(APPEND ${CYASSL_OPTION_FILE} " */\n")
  1503. file(READ ${OPTION_FILE} OPTION_FILE_CONTENTS)
  1504. file(APPEND ${CYASSL_OPTION_FILE} ${OPTION_FILE_CONTENTS})
  1505. ####################################################
  1506. # Library Target
  1507. ####################################################
  1508. # TODO: - Build shared/static libs based on enables. Check CMake
  1509. # global flag BUILD_SHARED_LIBS.
  1510. option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" ON)
  1511. set(LIB_SOURCES "")
  1512. # Generates a list of sources to include in the library.
  1513. # Corresponds to the instances of "src_libwolfssl_la_SOURCES += ..."
  1514. # in the *.am files.
  1515. generate_lib_src_list("${LIB_SOURCES}")
  1516. add_library(wolfssl ${LIB_SOURCES})
  1517. set_target_properties(wolfssl
  1518. PROPERTIES
  1519. SOVERSION ${LIBTOOL_SO_VERSION}
  1520. VERSION ${LIBTOOL_FULL_VERSION}
  1521. )
  1522. target_compile_definitions(wolfssl PRIVATE "BUILDING_WOLFSSL")
  1523. if(${BUILD_SHARED_LIBS})
  1524. target_compile_definitions(wolfssl PUBLIC "WOLFSSL_DLL")
  1525. endif()
  1526. ####################################################
  1527. # Include Directories
  1528. ####################################################
  1529. target_include_directories(wolfssl
  1530. PUBLIC
  1531. $<INSTALL_INTERFACE:include>
  1532. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
  1533. $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
  1534. ${WOLFSSL_INCLUDE_DIRS}
  1535. )
  1536. ####################################################
  1537. # Link Libraries
  1538. ####################################################
  1539. target_link_libraries(wolfssl PUBLIC ${WOLFSSL_LINK_LIBS})
  1540. if(WIN32)
  1541. # For Windows link ws2_32
  1542. target_link_libraries(wolfssl PUBLIC
  1543. $<$<PLATFORM_ID:Windows>:ws2_32>)
  1544. else()
  1545. # DH requires math (m) library
  1546. target_link_libraries(wolfssl
  1547. PUBLIC
  1548. m)
  1549. endif()
  1550. ####################################################
  1551. # Tests and Examples
  1552. ####################################################
  1553. if(WOLFSSL_EXAMPLES)
  1554. # Build wolfSSL client example
  1555. add_executable(client
  1556. ${CMAKE_CURRENT_SOURCE_DIR}/examples/client/client.c)
  1557. target_link_libraries(client wolfssl)
  1558. set_property(TARGET client
  1559. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1560. ${WOLFSSL_OUTPUT_BASE}/examples/client)
  1561. # Build wolfSSL server example
  1562. add_executable(server
  1563. ${CMAKE_CURRENT_SOURCE_DIR}/examples/server/server.c)
  1564. target_link_libraries(server wolfssl)
  1565. set_property(TARGET server
  1566. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1567. ${WOLFSSL_OUTPUT_BASE}/examples/server)
  1568. # Build echo client example
  1569. add_executable(echoclient
  1570. ${CMAKE_CURRENT_SOURCE_DIR}/examples/echoclient/echoclient.c)
  1571. target_include_directories(echoclient PRIVATE
  1572. ${CMAKE_CURRENT_BINARY_DIR})
  1573. target_link_libraries(echoclient wolfssl)
  1574. set_property(TARGET echoclient
  1575. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1576. ${WOLFSSL_OUTPUT_BASE}/examples/echoclient)
  1577. # Build echo server example
  1578. add_executable(echoserver
  1579. ${CMAKE_CURRENT_SOURCE_DIR}/examples/echoserver/echoserver.c)
  1580. target_include_directories(echoserver PRIVATE
  1581. ${CMAKE_CURRENT_BINARY_DIR})
  1582. target_link_libraries(echoserver wolfssl)
  1583. set_property(TARGET echoserver
  1584. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1585. ${WOLFSSL_OUTPUT_BASE}/examples/echoserver)
  1586. if(NOT WIN32)
  1587. # Build TLS benchmark example
  1588. add_executable(tls_bench
  1589. ${CMAKE_CURRENT_SOURCE_DIR}/examples/benchmark/tls_bench.c)
  1590. target_link_libraries(tls_bench wolfssl)
  1591. target_link_libraries(tls_bench Threads::Threads)
  1592. set_property(TARGET tls_bench
  1593. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1594. ${WOLFSSL_OUTPUT_BASE}/examples/benchmark)
  1595. endif()
  1596. # Build unit tests
  1597. add_executable(unit_test
  1598. tests/api.c
  1599. tests/hash.c
  1600. tests/srp.c
  1601. tests/suites.c
  1602. tests/w64wrapper.c
  1603. tests/unit.c
  1604. examples/server/server.c
  1605. examples/client/client.c)
  1606. target_include_directories(unit_test PRIVATE
  1607. ${CMAKE_CURRENT_BINARY_DIR})
  1608. target_compile_options(unit_test PUBLIC "-DNO_MAIN_DRIVER")
  1609. target_link_libraries(unit_test wolfssl)
  1610. target_link_libraries(unit_test Threads::Threads)
  1611. set_property(TARGET unit_test
  1612. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1613. ${WOLFSSL_OUTPUT_BASE}/tests/)
  1614. set_property(TARGET unit_test
  1615. PROPERTY RUNTIME_OUTPUT_NAME
  1616. unit.test)
  1617. endif()
  1618. if(WOLFSSL_CRYPT_TESTS)
  1619. if(WOLFSSL_CRYPT_TESTS_LIBS)
  1620. # Build wolfCrypt test as a library. This will compile test.c and make
  1621. # its functions available as a CMake target that other CMake targets can
  1622. # pull in, in addition to producing the library itself. Note that this
  1623. # feature is not enabled by default, and the API of this library and
  1624. # wofcryptbench_lib should NOT be treated as stable.
  1625. add_library(wolfcrypttest_lib
  1626. ${CMAKE_CURRENT_SOURCE_DIR}/wolfcrypt/test/test.c)
  1627. set_target_properties(wolfcrypttest_lib PROPERTIES OUTPUT_NAME "wolfcrypttest")
  1628. target_link_libraries(wolfcrypttest_lib wolfssl)
  1629. target_compile_options(wolfcrypttest_lib PRIVATE "-DNO_MAIN_DRIVER")
  1630. # Make another library for the wolfCrypt benchmark code.
  1631. add_library(wolfcryptbench_lib
  1632. ${CMAKE_CURRENT_SOURCE_DIR}/wolfcrypt/benchmark/benchmark.c)
  1633. set_target_properties(wolfcryptbench_lib PROPERTIES OUTPUT_NAME "wolfcryptbench")
  1634. target_link_libraries(wolfcryptbench_lib wolfssl)
  1635. target_compile_options(wolfcryptbench_lib PRIVATE "-DNO_MAIN_DRIVER")
  1636. endif()
  1637. # Build wolfCrypt test executable.
  1638. add_executable(wolfcrypttest
  1639. ${CMAKE_CURRENT_SOURCE_DIR}/wolfcrypt/test/test.c)
  1640. target_link_libraries(wolfcrypttest wolfssl)
  1641. set_property(TARGET wolfcrypttest
  1642. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1643. ${WOLFSSL_OUTPUT_BASE}/wolfcrypt/test)
  1644. set_property(TARGET wolfcrypttest
  1645. PROPERTY RUNTIME_OUTPUT_NAME
  1646. testwolfcrypt)
  1647. # Build wolfCrypt benchmark executable.
  1648. add_executable(wolfcryptbench
  1649. ${CMAKE_CURRENT_SOURCE_DIR}/wolfcrypt/benchmark/benchmark.c)
  1650. target_include_directories(wolfcryptbench PRIVATE
  1651. ${CMAKE_CURRENT_BINARY_DIR})
  1652. target_link_libraries(wolfcryptbench wolfssl)
  1653. set_property(TARGET wolfcryptbench
  1654. PROPERTY RUNTIME_OUTPUT_DIRECTORY
  1655. ${WOLFSSL_OUTPUT_BASE}/wolfcrypt/benchmark)
  1656. set_property(TARGET wolfcryptbench
  1657. PROPERTY RUNTIME_OUTPUT_NAME
  1658. benchmark)
  1659. endif()
  1660. ####################################################
  1661. # Installation
  1662. ####################################################
  1663. include(GNUInstallDirs)
  1664. set(HEADER_EXCLUDE
  1665. "internal.h"
  1666. "cyassl/ctaocrypt/port"
  1667. "wolfssl/wolfcrypt/port/nrf51.h"
  1668. "wolfssl/wolfcrypt/port/arm"
  1669. "wolfssl/wolfcrypt/port/cypress"
  1670. "wolfssl/wolfcrypt/port/Espressif"
  1671. "wolfssl/wolfcrypt/port/iotsafe"
  1672. "wolfssl/wolfcrypt/port/nxp"
  1673. "wolfssl/wolfcrypt/port/pic"
  1674. "wolfssl/wolfcrypt/port/Renesas"
  1675. "wolfssl/wolfcrypt/port/silabs"
  1676. "wolfssl/wolfcrypt/port/st"
  1677. "wolfssl/wolfcrypt/port/ti"
  1678. "wolfssl/wolfcrypt/port/xilinx"
  1679. )
  1680. # TODO: add support for the various ports
  1681. # For distro build don't install options.h.
  1682. # It depends on the architecture and conflicts with Multi-Arch.
  1683. if(BUILD_DISTRO)
  1684. list(APPEND HEADER_EXCLUDE
  1685. "options.h")
  1686. endif()
  1687. if(NOT BUILD_CRYPTOAUTHLIB)
  1688. list(APPEND HEADER_EXCLUDE
  1689. "wolfssl/wolfcrypt/port/atmel")
  1690. endif()
  1691. if(NOT BUILD_AFALG)
  1692. list(APPEND HEADER_EXCLUDE
  1693. "wolfssl/wolfcrypt/port/af_alg")
  1694. endif()
  1695. if(NOT BUILD_KCAPI)
  1696. list(APPEND HEADER_EXCLUDE
  1697. "wolfssl/wolfcrypt/port/kcapi"
  1698. )
  1699. endif()
  1700. if(NOT BUILD_DEVCRYPTO)
  1701. list(APPEND HEADER_EXCLUDE
  1702. "wolfssl/wolfcrypt/port/devcrypto")
  1703. endif()
  1704. if(NOT BUILD_ASYNCCRYPT)
  1705. list(APPEND HEADER_EXCLUDE
  1706. "wolfssl/wolfcrypt/async.h")
  1707. endif()
  1708. if(NOT BUILD_PKCS11)
  1709. list(APPEND HEADER_EXCLUDE
  1710. "wolfssl/wolfcrypt/wc_pkcs11.h"
  1711. "wolfssl/wolfcrypt/pkcs11.h"
  1712. )
  1713. endif()
  1714. if(NOT BUILD_CAVIUM AND NOT BUILD_OCTEON_SYNC)
  1715. list(APPEND HEADER_EXCLUDE
  1716. "wolfssl/wolfcrypt/port/cavium")
  1717. else()
  1718. if(NOT BUILD_CAVIUM)
  1719. list(APPEND HEADER_EXCLUDE
  1720. "wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h")
  1721. endif()
  1722. if(NOT BUILD_OCTEON_SYNC)
  1723. list(APPEND HEADER_EXCLUDE
  1724. "wolfssl/wolfcrypt/port/cavium/cavium_octeon_sync.h"
  1725. )
  1726. endif()
  1727. endif()
  1728. if(NOT BUILD_INTEL_QA AND NOT BUILD_INTEL_QA_SYNC)
  1729. list(APPEND HEADER_EXCLUDE
  1730. "wolfssl/wolfcrypt/port/intel")
  1731. else()
  1732. if(NOT BUILD_INTEL_QA)
  1733. list(APPEND HEADER_EXCLUDE
  1734. "wolfssl/wolfcrypt/port/intel/quickassist.h"
  1735. "wolfssl/wolfcrypt/port/intel/quickassist_mem.h"
  1736. )
  1737. endif()
  1738. if(NOT BUILD_INTEL_QA_SYNC)
  1739. list(APPEND HEADER_EXCLUDE
  1740. "wolfssl/wolfcrypt/port/intel/quickassist_sync.h")
  1741. endif()
  1742. endif()
  1743. if(NOT BUILD_SP)
  1744. list(APPEND HEADER_EXCLUDE
  1745. "wolfssl/wolfcrypt/sp.h")
  1746. endif()
  1747. if(NOT BUILD_SP_INT)
  1748. list(APPEND HEADER_EXCLUDE
  1749. "wolfssl/wolfcrypt/sp_int.h")
  1750. endif()
  1751. if(NOT BUILD_SELFTEST)
  1752. list(APPEND HEADER_EXCLUDE
  1753. "wolfssl/wolfcrypt/selftest.h")
  1754. endif()
  1755. if(NOT BUILD_FIPS OR BUILD_FIPS_V1)
  1756. list(APPEND HEADER_EXCLUDE
  1757. "wolfssl/wolfcrypt/fips.h")
  1758. endif()
  1759. if(NOT BUILD_QNXCAAM)
  1760. list(APPEND HEADER_EXCLUDE
  1761. "wolfssl/wolfcrypt/port/caam"
  1762. )
  1763. endif()
  1764. list(JOIN HEADER_EXCLUDE "|" EXCLUDED_HEADERS_REGEX)
  1765. string(PREPEND EXCLUDED_HEADERS_REGEX "(")
  1766. string(APPEND EXCLUDED_HEADERS_REGEX ")")
  1767. set(INSTALLED_EXAMPLES
  1768. ${CMAKE_CURRENT_SOURCE_DIR}/examples/echoserver/echoserver.c
  1769. ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-server.c
  1770. ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-client-dtls.c
  1771. ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-client.c
  1772. ${CMAKE_CURRENT_SOURCE_DIR}/examples/sctp/sctp-server-dtls.c
  1773. ${CMAKE_CURRENT_SOURCE_DIR}/examples/echoclient/echoclient.c
  1774. ${CMAKE_CURRENT_SOURCE_DIR}/examples/server/server.c
  1775. ${CMAKE_CURRENT_SOURCE_DIR}/examples/benchmark/tls_bench.c
  1776. ${CMAKE_CURRENT_SOURCE_DIR}/examples/client/client.c)
  1777. # Install the library
  1778. install(TARGETS wolfssl
  1779. EXPORT wolfssl-targets
  1780. LIBRARY DESTINATION lib
  1781. ARCHIVE DESTINATION lib
  1782. RUNTIME DESTINATION bin
  1783. )
  1784. # Install the headers
  1785. install(DIRECTORY ${WOLFSSL_OUTPUT_BASE}/wolfssl/
  1786. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wolfssl
  1787. FILES_MATCHING PATTERN "*.h"
  1788. REGEX ${EXCLUDED_HEADERS_REGEX} EXCLUDE)
  1789. install(DIRECTORY ${WOLFSSL_OUTPUT_BASE}/cyassl/
  1790. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cyassl
  1791. FILES_MATCHING PATTERN "*.h"
  1792. REGEX ${EXCLUDED_HEADERS_REGEX} EXCLUDE)
  1793. install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/wolfssl/
  1794. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wolfssl
  1795. FILES_MATCHING PATTERN "*.h"
  1796. REGEX ${EXCLUDED_HEADERS_REGEX} EXCLUDE)
  1797. install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cyassl/
  1798. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cyassl
  1799. FILES_MATCHING PATTERN "*.h"
  1800. REGEX ${EXCLUDED_HEADERS_REGEX} EXCLUDE)
  1801. # Install the examples
  1802. install(FILES ${INSTALLED_EXAMPLES}
  1803. DESTINATION ${CMAKE_INSTALL_DOCDIR}/example)
  1804. # Install README.txt and taoCert.txt
  1805. install(FILES
  1806. ${CMAKE_CURRENT_SOURCE_DIR}/doc/README.txt
  1807. ${CMAKE_CURRENT_SOURCE_DIR}/certs/taoCert.txt
  1808. DESTINATION ${CMAKE_INSTALL_DOCDIR})
  1809. # Install the export set
  1810. install(EXPORT wolfssl-targets
  1811. DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wolfssl
  1812. FILE wolfssl-config.cmake)
  1813. # TODO: Distro build + rules for what to include in the distro.
  1814. # See various include.am files.
  1815. set(prefix ${CMAKE_INSTALL_PREFIX})
  1816. set(exec_prefix "\${prefix}")
  1817. set(libdir "\${exec_prefix}/lib")
  1818. set(includedir "\${prefix}/include")
  1819. set(VERSION ${PROJECT_VERSION})
  1820. configure_file(support/wolfssl.pc.in ${CMAKE_CURRENT_BINARY_DIR}/support/wolfssl.pc @ONLY)
  1821. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/support/wolfssl.pc
  1822. DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)