functions.cmake 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943
  1. function(override_cache VAR VAL)
  2. get_property(VAR_STRINGS CACHE ${VAR} PROPERTY STRINGS)
  3. LIST(FIND VAR_STRINGS ${VAL} CK)
  4. if(-1 EQUAL ${CK})
  5. message(SEND_ERROR
  6. "\"${VAL}\" is not valid override value for \"${VAR}\"."
  7. " Please select value from \"${VAR_STRINGS}\"\n")
  8. endif()
  9. set_property(CACHE ${VAR} PROPERTY VALUE ${VAL})
  10. endfunction()
  11. function(add_option NAME HELP_STRING DEFAULT VALUES)
  12. # Set the default value for the option.
  13. set(${NAME} ${DEFAULT} CACHE STRING ${HELP_STRING})
  14. # Set the list of allowed values for the option.
  15. set_property(CACHE ${NAME} PROPERTY STRINGS ${VALUES})
  16. if(DEFINED ${NAME})
  17. list(FIND VALUES ${${NAME}} IDX)
  18. #
  19. # If the given value isn't in the list of allowed values for the option,
  20. # reduce it to yes/no according to CMake's "if" logic:
  21. # https://cmake.org/cmake/help/latest/command/if.html#basic-expressions
  22. #
  23. # This has no functional impact; it just makes the settings in
  24. # CMakeCache.txt and cmake-gui easier to read.
  25. #
  26. if (${IDX} EQUAL -1)
  27. if(${${NAME}})
  28. override_cache(${NAME} "yes")
  29. else()
  30. override_cache(${NAME} "no")
  31. endif()
  32. endif()
  33. endif()
  34. endfunction()
  35. function(generate_build_flags)
  36. set(BUILD_DISTRO ${WOLFSSL_DISTRO} PARENT_SCOPE)
  37. set(BUILD_ALL ${WOLFSSL_ALL} PARENT_SCOPE)
  38. if(WOLFSSL_TLS13 OR WOLFSSL_USER_SETTINGS)
  39. set(BUILD_TLS13 "yes" PARENT_SCOPE)
  40. endif()
  41. if(WOLFSSL_DTLS13 OR WOLFSSL_USER_SETTINGS)
  42. set(BUILD_DTLS13 "yes" PARENT_SCOPE)
  43. endif()
  44. if(WOLFSSL_QUIC)
  45. set(BUILD_QUIC "yes" PARENT_SCOPE)
  46. endif()
  47. if(WOLFSSL_RNG OR WOLFSSL_USER_SETTINGS)
  48. set(BUILD_RNG "yes" PARENT_SCOPE)
  49. endif()
  50. if(WOLFSSL_SCTP OR WOLFSSL_USER_SETTINGS)
  51. set(BUILD_SCTP "yes" PARENT_SCOPE)
  52. endif()
  53. if(WOLFSSL_DTLS_CID OR WOLFSSL_USER_SETTINGS OR WOLFSSL_DTLS)
  54. set(BUILD_DTLS_COMMON "yes" PARENT_SCOPE)
  55. endif()
  56. set(BUILD_MCAST ${WOLFSSL_MCAST} PARENT_SCOPE)
  57. set(BUILD_IPV6 ${WOLFSSL_IPV6} PARENT_SCOPE)
  58. set(BUILD_LEAN_PSK ${WOLFSSL_LEAN_PSK} PARENT_SCOPE)
  59. set(BUILD_LEAN_TLS ${WOLFSSL_LEAN_TLS} PARENT_SCOPE)
  60. set(BUILD_LOWMEM ${WOLFSSL_LOWRESOURCE} PARENT_SCOPE)
  61. set(BUILD_PKCALLBACKS ${WOLFSSL_PKCALLBACKS} PARENT_SCOPE)
  62. set(BUILD_CRYPTOAUTHLIB ${WOLFSSL_CRYPTOAUTHLIB} PARENT_SCOPE)
  63. if(WOLFSSL_SNIFFER OR WOLFSSL_USER_SETTINGS)
  64. set(BUILD_SNIFFER "yes" PARENT_SCOPE)
  65. endif()
  66. set(BUILD_SNIFFTEST ${WOLFSSL_SNIFFTEST} PARENT_SCOPE)
  67. if(WOLFSSL_AESGCM OR WOLFSSL_USER_SETTINGS)
  68. set(BUILD_AESGCM "yes" PARENT_SCOPE)
  69. endif()
  70. if(WOLFSSL_AESCCM OR WOLFSSL_USER_SETTINGS)
  71. set(BUILD_AESCCM "yes" PARENT_SCOPE)
  72. endif()
  73. set(BUILD_ARM_ASM ${WOLFSSL_ARM_ASM} PARENT_SCOPE)
  74. set(BUILD_XILINX ${WOLFSSL_XILINX} PARENT_SCOPE)
  75. set(BUILD_AESNI ${WOLFSSL_AESNI} PARENT_SCOPE)
  76. set(BUILD_INTEL_ASM ${WOLFSSL_INTEL_ASM} PARENT_SCOPE)
  77. set(BUILD_AFALG ${WOLFSSL_AFALG} PARENT_SCOPE)
  78. set(BUILD_DEVCRYPTO ${WOLFSSL_DEVCRYPTO} PARENT_SCOPE)
  79. if(WOLFSSL_CAMELLIA OR WOLFSSL_USER_SETTINGS)
  80. set(BUILD_CAMELLIA "yes" PARENT_SCOPE)
  81. endif()
  82. if(WOLFSSL_MD2 OR WOLFSSL_USER_SETTINGS)
  83. set(BUILD_MD2 "yes" PARENT_SCOPE)
  84. endif()
  85. if(WOLFSSL_RIPEMD OR WOLFSSL_USER_SETTINGS)
  86. set(BUILD_RIPEMD "yes" PARENT_SCOPE)
  87. endif()
  88. if(WOLFSSL_BLAKE2 OR WOLFSSL_USER_SETTINGS)
  89. set(BUILD_BLAKE2 "yes" PARENT_SCOPE)
  90. endif()
  91. if(WOLFSSL_BLAKE2S OR WOLFSSL_USER_SETTINGS)
  92. set(BUILD_BLAKE2S "yes" PARENT_SCOPE)
  93. endif()
  94. if(WOLFSSL_SHA512 OR WOLFSSL_SHA384 OR WOLFSSL_USER_SETTINGS)
  95. set(BUILD_SHA512 "yes" PARENT_SCOPE)
  96. endif()
  97. if(WOLFSSL_DSA OR WOLFSSL_USER_SETTINGS)
  98. set(BUILD_DSA "yes" PARENT_SCOPE)
  99. endif()
  100. if(WOLFSSL_ECC OR WOLFSSL_USER_SETTINGS)
  101. set(BUILD_ECC "yes" PARENT_SCOPE)
  102. endif()
  103. if(WOLFSSL_ED25519 OR WOLFSSL_USER_SETTINGS)
  104. set(BUILD_ED25519 "yes" PARENT_SCOPE)
  105. endif()
  106. set(BUILD_ED25519_SMALL ${WOLFSSL_ED25519_SMALL} PARENT_SCOPE)
  107. if(WOLFSSL_FEMATH OR WOLFSSL_USER_SETTINGS)
  108. set(BUILD_FEMATH "yes" PARENT_SCOPE)
  109. endif()
  110. if(WOLFSSL_GEMATH OR WOLFSSL_USER_SETTINGS)
  111. set(BUILD_GEMATH "yes" PARENT_SCOPE)
  112. endif()
  113. if(WOLFSSL_CURVE25519 OR WOLFSSL_USER_SETTINGS)
  114. set(BUILD_CURVE25519 "yes" PARENT_SCOPE)
  115. endif()
  116. set(BUILD_CURVE25519_SMALL ${WOLFSSL_CURVE25519_SMALL} PARENT_SCOPE)
  117. if(WOLFSSL_ED448 OR WOLFSSL_USER_SETTINGS)
  118. set(BUILD_ED448 "yes" PARENT_SCOPE)
  119. endif()
  120. set(BUILD_ED448_SMALL ${WOLFSSL_ED448_SMALL} PARENT_SCOPE)
  121. if(WOLFSSL_FE448 OR WOLFSSL_USER_SETTINGS)
  122. set(BUILD_FE448 "yes" PARENT_SCOPE)
  123. endif()
  124. if(WOLFSSL_GE448 OR WOLFSSL_USER_SETTINGS)
  125. set(BUILD_GE448 "yes" PARENT_SCOPE)
  126. endif()
  127. if(WOLFSSL_CURVE448 OR WOLFSSL_USER_SETTINGS)
  128. set(BUILD_CURVE448 "yes" PARENT_SCOPE)
  129. endif()
  130. if(WOLFSSL_CURVE448_SMALL OR WOLFSSL_USER_SETTINGS)
  131. set(BUILD_CURVE448_SMALL "yes" PARENT_SCOPE)
  132. endif()
  133. if(WOLFSSL_MEMORY OR WOLFSSL_USER_SETTINGS)
  134. set(BUILD_MEMORY "yes" PARENT_SCOPE)
  135. endif()
  136. if(WOLFSSL_RSA OR WOLFSSL_USER_SETTINGS)
  137. set(BUILD_RSA "yes" PARENT_SCOPE)
  138. endif()
  139. if(WOLFSSL_DH OR WOLFSSL_USER_SETTINGS)
  140. set(BUILD_DH "yes" PARENT_SCOPE)
  141. endif()
  142. if(WOLFSSL_ASN OR WOLFSSL_USER_SETTINGS)
  143. set(BUILD_ASN "yes" PARENT_SCOPE)
  144. endif()
  145. if(WOLFSSL_AES OR WOLFSSL_USER_SETTINGS)
  146. set(BUILD_AES "yes" PARENT_SCOPE)
  147. endif()
  148. if(WOLFSSL_CODING OR WOLFSSL_USER_SETTINGS)
  149. set(BUILD_CODING "yes" PARENT_SCOPE)
  150. endif()
  151. if(WOLFSSL_ARC4 OR WOLFSSL_USER_SETTINGS)
  152. set(BUILD_RC4 "yes" PARENT_SCOPE)
  153. endif()
  154. if(WOLFSSL_MD5 OR WOLFSSL_USER_SETTINGS)
  155. set(BUILD_MD5 "yes" PARENT_SCOPE)
  156. endif()
  157. if(WOLFSSL_SHA OR WOLFSSL_USER_SETTINGS)
  158. set(BUILD_SHA "yes" PARENT_SCOPE)
  159. endif()
  160. set(BUILD_FIPS ${WOLFSSL_FIPS} PARENT_SCOPE)
  161. if("${FIPS_VERSION}" STREQUAL "v1")
  162. set(BUILD_FIPS_V1 "yes" PARENT_SCOPE)
  163. endif()
  164. if("${FIPS_VERSION}" STREQUAL "v2")
  165. set(BUILD_FIPS_V2 "yes" PARENT_SCOPE)
  166. endif()
  167. if("${FIPS_VERSION}" STREQUAL "rand")
  168. set(BUILD_FIPS_RAND "yes" PARENT_SCOPE)
  169. endif()
  170. if("${FIPS_VERSION}" STREQUAL "v5")
  171. set(BUILD_FIPS_V5 "yes" PARENT_SCOPE)
  172. endif()
  173. set(BUILD_FIPS_READY ${FIPS_READY} PARENT_SCOPE)
  174. if(WOLFSSL_CMAC OR WOLFSSL_USER_SETTINGS)
  175. set(BUILD_CMAC "yes" PARENT_SCOPE)
  176. endif()
  177. set(BUILD_SELFTEST ${WOLFSSL_SELFTEST} PARENT_SCOPE)
  178. if(WOLFSSL_SHA224 OR WOLFSSL_USER_SETTINGS)
  179. set(BUILD_SHA224 "yes" PARENT_SCOPE)
  180. endif()
  181. if(WOLFSSL_SHA3 OR WOLFSSL_USER_SETTINGS)
  182. set(BUILD_SHA3 "yes" PARENT_SCOPE)
  183. endif()
  184. if(WOLFSSL_POLY1305 OR WOLFSSL_USER_SETTINGS)
  185. set(BUILD_POLY1305 "yes" PARENT_SCOPE)
  186. endif()
  187. if(WOLFSSL_CHACHA OR WOLFSSL_USER_SETTINGS)
  188. set(BUILD_CHACHA "yes" PARENT_SCOPE)
  189. endif()
  190. if(WOLFSSL_XCHACHA OR WOLFSSL_USER_SETTINGS)
  191. set(BUILD_XCHACHA "yes" PARENT_SCOPE)
  192. endif()
  193. if(WOLFSSL_OQS OR WOLFSSL_USER_SETTINGS)
  194. set(BUILD_FALCON "yes" PARENT_SCOPE)
  195. set(BUILD_SPHINCS "yes" PARENT_SCOPE)
  196. set(BUILD_DILITHIUM "yes" PARENT_SCOPE)
  197. set(BUILD_EXT_KYBER "yes" PARENT_SCOPE)
  198. set(BUILD_OQS_HELPER "yes" PARENT_SCOPE)
  199. endif()
  200. if(WOLFSSL_ARIA OR WOLFSSL_USER_SETTINGS)
  201. message(STATUS "ARIA functions.cmake found WOLFSSL_ARIA")
  202. # we cannot actually build, as we only have pre-compiled bin
  203. set(BUILD_ARIA "yes" PARENT_SCOPE)
  204. endif()
  205. set(BUILD_INLINE ${WOLFSSL_INLINE} PARENT_SCOPE)
  206. if(WOLFSSL_OCSP OR WOLFSSL_USER_SETTINGS)
  207. set(BUILD_OCSP "yes" PARENT_SCOPE)
  208. endif()
  209. set(BUILD_OCSP_STAPLING ${WOLFSSL_OCSPSTAPLING} PARENT_SCOPE)
  210. set(BUILD_OCSP_STAPLING_V2 ${WOLFSSL_OCSPSTAPLING_V2} PARENT_SCOPE)
  211. if(WOLFSSL_CRL OR WOLFSSL_USER_SETTINGS)
  212. set(BUILD_CRL "yes" PARENT_SCOPE)
  213. endif()
  214. if(WOLFSSL_CRL_MONITOR)
  215. set(BUILD_CRL_MONITOR "yes" PARENT_SCOPE)
  216. endif()
  217. set(BUILD_QUIC ${WOLFSSL_QUIC} PARENT_SCOPE)
  218. set(BUILD_WNR ${WOLFSSL_WNR} PARENT_SCOPE)
  219. if(WOLFSSL_SRP OR WOLFSSL_USER_SETTINGS)
  220. set(BUILD_SRP "yes" PARENT_SCOPE)
  221. endif()
  222. set(USE_VALGRIND ${WOLFSSL_VALGRIND})
  223. if(WOLFSSL_MD4 OR WOLFSSL_USER_SETTINGS)
  224. set(BUILD_MD4 "yes" PARENT_SCOPE)
  225. endif()
  226. if(WOLFSSL_PWDBASED OR WOLFSSL_USER_SETTINGS)
  227. set(BUILD_PWDBASED "yes" PARENT_SCOPE)
  228. endif()
  229. if(WOLFSSL_SCRYPT OR WOLFSSL_USER_SETTINGS)
  230. set(BUILD_SCRYPT "yes" PARENT_SCOPE)
  231. endif()
  232. if(WOLFSSL_CRYPT_ONLY AND NOT WOLFSSL_OPENSSL_EXTRA)
  233. set(BUILD_CRYPTONLY "yes" PARENT_SCOPE)
  234. endif()
  235. if(WOLFSSL_FAST_MATH OR WOLFSSL_USER_SETTINGS)
  236. set(BUILD_FAST_MATH "yes" PARENT_SCOPE)
  237. endif()
  238. if(WOLFSSL_SLOW_MATH OR WOLFSSL_USER_SETTINGS)
  239. set(BUILD_SLOW_MATH "yes" PARENT_SCOPE)
  240. endif()
  241. if(WOLFSSL_EXAMPLES AND NOT WOLFSSL_LEAN_TLS)
  242. set(BUILD_EXAMPLE_SERVERS "yes" PARENT_SCOPE)
  243. endif()
  244. set(BUILD_EXAMPLE_CLIENTS ${WOLFSSL_EXAMPLES} PARENT_SCOPE)
  245. set(BUILD_TESTS ${WOLFSSL_EXAMPLES} PARENT_SCOPE)
  246. if(NOT WOLFSSL_SINGLETHREADED AND WOLFSSL_EXAMPLES AND NOT WOLFSSL_LEAN_TLS)
  247. set(BUILD_THREADED_EXAMPLES "yes" PARENT_SCOPE)
  248. endif()
  249. set(BUILD_WOLFCRYPT_TESTS ${WOLFSSL_CRYPT_TESTS} PARENT_SCOPE)
  250. set(BUILD_LIBZ ${WOLFSSL_LIBZ} PARENT_SCOPE)
  251. if(WOLFSSL_PKCS11 OR WOLFSSL_USER_SETTINGS)
  252. set(BUILD_PKCS11 "yes" PARENT_SCOPE)
  253. endif()
  254. if(WOLFSSL_PKCS12 OR WOLFSSL_USER_SETTINGS)
  255. set(BUILD_PKCS12 "yes" PARENT_SCOPE)
  256. endif()
  257. set(BUILD_CAVIUM ${WOLFSSL_CAVIUM} PARENT_SCOPE)
  258. set(BUILD_CAVIUM_V ${WOLFSSL_CAVIUM_V} PARENT_SCOPE)
  259. set(BUILD_OCTEON_SYNC ${WOLFSSL_OCTEON_SYNC} PARENT_SCOPE)
  260. set(BUILD_INTEL_QA ${WOLFSSL_INTEL_QA} PARENT_SCOPE)
  261. set(BUILD_INTEL_QA_SYNC ${WOLFSSL_INTEL_QA_SYNC} PARENT_SCOPE)
  262. if(WOLFSSL_SP OR WOLFSSL_USER_SETTINGS)
  263. set(BUILD_SP "yes" PARENT_SCOPE)
  264. endif()
  265. if((WOLFSSL_SP AND NOT WOLFSSL_SP_ASM) OR WOLFSSL_USER_SETTINGS)
  266. set(BUILD_SP_C "yes" PARENT_SCOPE)
  267. endif()
  268. if(WOLFSSL_SP_ARM64_ASM OR WOLFSSL_USER_SETTINGS)
  269. set(BUILD_SP_ARM64 "yes" PARENT_SCOPE)
  270. endif()
  271. if(WOLFSSL_SP_ARM32_ASM OR WOLFSSL_USER_SETTINGS)
  272. set(BUILD_SP_ARM32 "yes" PARENT_SCOPE)
  273. endif()
  274. if(WOLFSSL_SP_ARM_THUMB_ASM OR WOLFSSL_USER_SETTINGS)
  275. set(BUILD_SP_ARM_THUMB "yes" PARENT_SCOPE)
  276. endif()
  277. if(WOLFSSL_SP_ARM_CORTEX_ASM OR WOLFSSL_USER_SETTINGS)
  278. set(BUILD_SP_ARM_CORTEX "yes" PARENT_SCOPE)
  279. endif()
  280. if(WOLFSSL_X86_64_BUILD AND (WOLFSSL_SP_X86_64_ASM OR WOLFSSL_USER_SETTINGS))
  281. set(BUILD_SP_X86_64 "yes" PARENT_SCOPE)
  282. endif()
  283. if(WOLFSSL_SP_MATH OR WOLFSSL_SP_MATH_ALL OR WOLFSSL_USER_SETTINGS)
  284. set(BUILD_SP_INT "yes" PARENT_SCOPE)
  285. endif()
  286. set(BUILD_MCAPI ${WOLFSSL_MCAPI} PARENT_SCOPE)
  287. set(BUILD_ASYNCCRYPT ${WOLFSSL_ASYNCCRYPT} PARENT_SCOPE)
  288. set(BUILD_WOLFEVENT ${WOLFSSL_ASYNCCRYPT} PARENT_SCOPE)
  289. if(WOLFSSL_CRYPTOCB OR WOLFSSL_USER_SETTINGS)
  290. set(BUILD_CRYPTOCB "yes" PARENT_SCOPE)
  291. endif()
  292. set(BUILD_PSK ${WOLFSSL_PSK} PARENT_SCOPE)
  293. set(BUILD_TRUST_PEER_CERT ${WOLFSSL_TRUSTED_PEER_CERT} PARENT_SCOPE)
  294. set(BUILD_PKI ${WOLFSSL_PKI} PARENT_SCOPE)
  295. if(WOLFSSL_DES3 OR WOLFSSL_USER_SETTINGS)
  296. set(BUILD_DES3 "yes" PARENT_SCOPE)
  297. endif()
  298. if(WOLFSSL_PKCS7 OR WOLFSSL_USER_SETTINGS)
  299. set(BUILD_PKCS7 "yes" PARENT_SCOPE)
  300. endif()
  301. set(BUILD_HASHFLAGS ${WOLFSSL_HASHFLAGS} PARENT_SCOPE)
  302. set(BUILD_LINUX_KM ${WOLFSSL_LINUX_KM} PARENT_SCOPE)
  303. set(BUILD_NO_LIBRARY ${WOLFSSL_NO_LIBRARY} PARENT_SCOPE)
  304. if(WOLFSSL_DEBUG OR WOLFSSL_STACK_SIZE)
  305. set(BUILD_DEBUG "yes" PARENT_SCOPE)
  306. endif()
  307. set(BUILD_RC2 ${WOLFSSL_RC2} PARENT_SCOPE)
  308. if(WOLFSSL_CAAM)
  309. set(BUILD_CAAM "yes" PARENT_SCOPE)
  310. endif()
  311. if(WOLFSSL_HPKE OR WOLFSSL_USER_SETTINGS)
  312. set(BUILD_HPKE "yes" PARENT_SCOPE)
  313. endif()
  314. set(BUILD_FLAGS_GENERATED "yes" PARENT_SCOPE)
  315. endfunction()
  316. function(generate_lib_src_list LIB_SOURCES)
  317. if(NOT BUILD_FLAGS_GENERATED)
  318. message(FATAL_ERROR "Cannot call generate_lib_src_list without calling generate_build_flags first.")
  319. endif()
  320. # Corresponds to src/include.am
  321. if(BUILD_FIPS)
  322. if(BUILD_FIPS_V2)
  323. # FIPSv2 first file
  324. list(APPEND LIB_SOURCES wolfcrypt/src/wolfcrypt_first.c)
  325. list(APPEND LIB_SOURCES
  326. wolfcrypt/src/hmac.c
  327. wolfcrypt/src/random.c
  328. wolfcrypt/src/sha256.c)
  329. if(BUILD_RSA)
  330. list(APPEND LIB_SOURCES wolfcrypt/src/rsa.c)
  331. endif()
  332. if(BUILD_ECC)
  333. list(APPEND LIB_SOURCES wolfcrypt/src/ecc.c)
  334. endif()
  335. if(BUILD_AES)
  336. list(APPEND LIB_SOURCES wolfcrypt/src/aes.c)
  337. if(BUILD_ARMASM AND BUILD_FIPS_READY)
  338. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-aes.c)
  339. endif()
  340. endif()
  341. if(BUILD_AESNI)
  342. list(APPEND LIB_SOURCES wolfcrypt/src/aes_asm.S)
  343. if(BUILD_INTELASM)
  344. list(APPEND LIB_SOURCES wolfcrypt/src/aes_gcm_asm.S)
  345. endif()
  346. endif()
  347. if(BUILD_DES3)
  348. list(APPEND LIB_SOURCES wolfcrypt/src/des3.c)
  349. endif()
  350. if(BUILD_SHA)
  351. list(APPEND LIB_SOURCES wolfcrypt/src/sha.c)
  352. endif()
  353. if(BUILD_ARMASM AND BUILD_FIPS_READY)
  354. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-sha256.c)
  355. endif()
  356. if(BUILD_INTELASM)
  357. list(APPEND LIB_SOURCES wolfcrypt/src/sha256_asm.S)
  358. endif()
  359. if(BUILD_SHA512)
  360. list(APPEND LIB_SOURCES wolfcrypt/src/sha512.c)
  361. if(BUILD_ARMASM AND BUILD_FIPS_READY)
  362. list(APPEND LIB_SOURCES
  363. wolfcrypt/src/port/arm/armv8-sha512.c
  364. wolfcrypt/src/port/arm/armv8-sha512-asm.S
  365. wolfcrypt/src/port/arm/armv8-32-sha512-asm.S)
  366. endif()
  367. if(BUILD_INTELASM)
  368. list(APPEND LIB_SOURCES wolfcrypt/src/sha512_asm.S)
  369. endif()
  370. endif()
  371. if(BUILD_SHA3)
  372. list(APPEND LIB_SOURCES wolfcrypt/src/sha3.c)
  373. endif()
  374. if(BUILD_DH)
  375. list(APPEND LIB_SOURCES wolfcrypt/src/dh.c)
  376. endif()
  377. if(BUILD_CMAC)
  378. list(APPEND LIB_SOURCES wolfcrypt/src/cmac.c)
  379. endif()
  380. list(APPEND LIB_SOURCES
  381. wolfcrypt/src/fips.c
  382. wolfcrypt/src/fips_test.c)
  383. # fips last file
  384. list(APPEND LIB_SOURCES wolfcrypt/src/wolfcrypt_last.c)
  385. endif()
  386. if(BUILD_FIPS_V5)
  387. list(APPEND LIB_SOURCES wolfcrypt/src/wolfcrypt_first.c)
  388. list(APPEND LIB_SOURCES
  389. wolfcrypt/src/hmac.c
  390. wolfcrypt/src/random.c
  391. wolfcrypt/src/sha256.c)
  392. list(APPEND LIB_SOURCES
  393. wolfcrypt/src/kdf.c)
  394. if(BUILD_RSA)
  395. list(APPEND LIB_SOURCES wolfcrypt/src/rsa.c)
  396. endif()
  397. endif()
  398. if(BUILD_FIPS_RAND)
  399. list(APPEND LIB_SOURCES
  400. wolfcrypt/src/wolfcrypt_first.c
  401. wolfcrypt/src/hmac.c
  402. wolfcrypt/src/random.c
  403. wolfcrypt/src/sha256.c
  404. wolfcrypt/src/sha256_asm.S
  405. wolfcrypt/src/fips.c
  406. wolfcrypt/src/fips_test.c
  407. wolfcrypt/src/wolfcrypt_last.c)
  408. endif()
  409. endif()
  410. # For wolfRand, exclude everything else.
  411. if(NOT BUILD_FIPS_RAND)
  412. # For FIPSV2, exclude the wolfCrypt files included above.
  413. # For wolfRand, exclude just a couple files.
  414. # For old FIPS, keep the wolfCrypt versions of the
  415. # CtaoCrypt files included above.
  416. if(NOT BUILD_FIPS_V2)
  417. list(APPEND LIB_SOURCES wolfcrypt/src/hmac.c)
  418. endif()
  419. # CAVP self test
  420. if(BUILD_SELFTEST)
  421. list(APPEND LIB_SOURCES wolfcrypt/src/selftest.c)
  422. endif()
  423. endif()
  424. list(APPEND LIB_SOURCES
  425. wolfcrypt/src/hash.c
  426. wolfcrypt/src/cpuid.c)
  427. if(NOT BUILD_FIPS_RAND)
  428. if(NOT BUILD_FIPS_V5)
  429. list(APPEND LIB_SOURCES wolfcrypt/src/kdf.c)
  430. endif()
  431. if(NOT BUILD_FIPS_V2 AND BUILD_RNG)
  432. list(APPEND LIB_SOURCES wolfcrypt/src/random.c)
  433. endif()
  434. if(NOT BUILD_FIPS_V2)
  435. if(BUILD_ARMASM)
  436. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-sha256.c)
  437. else()
  438. list(APPEND LIB_SOURCES wolfcrypt/src/sha256.c)
  439. if(BUILD_INTELASM)
  440. list(APPEND LIB_SOURCES wolfcrypt/src/sha256_asm.S)
  441. endif()
  442. endif()
  443. endif()
  444. if(BUILD_AFALG)
  445. list(APPEND LIB_SOURCES wolfcrypt/src/port/af_alg/afalg_hash.c)
  446. endif()
  447. if(BUILD_WOLFEVENT)
  448. list(APPEND LIB_SOURCES wolfcrypt/src/wolfevent.c)
  449. endif()
  450. if(BUILD_ASYNCCRYPT)
  451. list(APPEND LIB_SOURCES wolfcrypt/src/async.c)
  452. endif()
  453. if(BUILD_RSA)
  454. if(NOT BUILD_FIPS_V2)
  455. list(APPEND LIB_SOURCES wolfcrypt/src/rsa.c)
  456. endif()
  457. endif()
  458. if(BUILD_SP)
  459. if(BUILD_SP_C)
  460. list(APPEND LIB_SOURCES
  461. wolfcrypt/src/sp_c32.c
  462. wolfcrypt/src/sp_c64.c)
  463. endif()
  464. if(BUILD_SP_X86_64)
  465. list(APPEND LIB_SOURCES wolfcrypt/src/sp_x86_64.c)
  466. if(WOLFSSL_X86_64_BUILD_ASM)
  467. list(APPEND LIB_SOURCES wolfcrypt/src/sp_x86_64_asm.S)
  468. endif()
  469. endif()
  470. if(NOT BUILD_FIPS_V2 AND BUILD_SP_ARM32)
  471. list(APPEND LIB_SOURCES wolfcrypt/src/sp_arm32.c)
  472. endif()
  473. if(BUILD_SP_ARM_THUMB)
  474. list(APPEND LIB_SOURCES wolfcrypt/src/sp_armthumb.c)
  475. endif()
  476. if(BUILD_SP_ARM64)
  477. list(APPEND LIB_SOURCES wolfcrypt/src/sp_arm64.c)
  478. endif()
  479. if(BUILD_SP_ARM_CORTEX)
  480. list(APPEND LIB_SOURCES wolfcrypt/src/sp_cortexm.c)
  481. endif()
  482. endif()
  483. if(BUILD_SP_INT)
  484. list(APPEND LIB_SOURCES wolfcrypt/src/sp_int.c)
  485. endif()
  486. if(NOT BUILD_FIPS_V2)
  487. if(BUILD_AES)
  488. list(APPEND LIB_SOURCES wolfcrypt/src/aes.c)
  489. if(BUILD_ARMASM)
  490. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-aes.c)
  491. endif()
  492. if(BUILD_AFALG)
  493. list(APPEND LIB_SOURCES wolfcrypt/src/port/af_alg/afalg_aes.c)
  494. endif()
  495. endif()
  496. endif()
  497. if(NOT BUILD_FIPS_V2 AND BUILD_CMAC)
  498. list(APPEND LIB_SOURCES wolfcrypt/src/cmac.c)
  499. endif()
  500. if(NOT BUILD_FIPS_V2 AND BUILD_DES3)
  501. list(APPEND LIB_SOURCES wolfcrypt/src/des3.c)
  502. endif()
  503. if(NOT BUILD_FIPS_V2 AND BUILD_SHA)
  504. list(APPEND LIB_SOURCES wolfcrypt/src/sha.c)
  505. endif()
  506. if(NOT BUILD_FIPS_V2 AND BUILD_SHA512)
  507. if(BUILD_ARMASM)
  508. list(APPEND LIB_SOURCES
  509. wolfcrypt/src/port/arm/armv8-sha512.c
  510. wolfcrypt/src/port/arm/armv8-sha512-asm.S
  511. wolfcrypt/src/port/arm/armv8-32-sha512-asm.S)
  512. else()
  513. list(APPEND LIB_SOURCES wolfcrypt/src/sha512.c)
  514. if(BUILD_INTELASM)
  515. list(APPEND LIB_SOURCES wolfcrypt/src/sha512_asm.S)
  516. endif()
  517. endif()
  518. endif()
  519. if(NOT BUILD_FIPS_V2 AND BUILD_SHA3)
  520. list(APPEND LIB_SOURCES wolfcrypt/src/sha3.c)
  521. endif()
  522. endif()
  523. list(APPEND LIB_SOURCES
  524. wolfcrypt/src/logging.c
  525. wolfcrypt/src/wc_port.c
  526. wolfcrypt/src/error.c)
  527. if(BUILD_OQS_HELPER)
  528. list(APPEND LIB_SOURCES
  529. wolfcrypt/src/port/liboqs/liboqs.c)
  530. endif()
  531. if(BUILD_ARIA)
  532. list(APPEND LIB_SOURCES
  533. wolfcrypt/src/port/aria/aria-crypt.c
  534. wolfcrypt/src/port/aria/aria-cryptocb.c)
  535. endif()
  536. if(NOT BUILD_FIPS_RAND)
  537. list(APPEND LIB_SOURCES
  538. wolfcrypt/src/wc_encrypt.c
  539. wolfcrypt/src/signature.c
  540. wolfcrypt/src/wolfmath.c)
  541. endif()
  542. if(BUILD_MEMORY)
  543. list(APPEND LIB_SOURCES wolfcrypt/src/memory.c)
  544. endif()
  545. if(NOT BUILD_FIPS_RAND)
  546. if(NOT BUILD_FIPS_V2 AND BUILD_DH)
  547. list(APPEND LIB_SOURCES wolfcrypt/src/dh.c)
  548. endif()
  549. if(BUILD_ASN)
  550. list(APPEND LIB_SOURCES wolfcrypt/src/asn.c)
  551. endif()
  552. endif()
  553. if(BUILD_CODING)
  554. list(APPEND LIB_SOURCES wolfcrypt/src/coding.c)
  555. endif()
  556. if(NOT BUILD_FIPS_RAND)
  557. if(BUILD_POLY1305)
  558. if(BUILD_ARMASM)
  559. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-poly1305.c)
  560. endif()
  561. list(APPEND LIB_SOURCES wolfcrypt/src/poly1305.c)
  562. if(BUILD_INTELASM)
  563. list(APPEND LIB_SOURCES wolfcrypt/src/poly1305_asm.S)
  564. endif()
  565. endif()
  566. if(BUILD_RC4)
  567. list(APPEND LIB_SOURCES wolfcrypt/src/arc4.c)
  568. endif()
  569. if(BUILD_MD4)
  570. list(APPEND LIB_SOURCES wolfcrypt/src/md4.c)
  571. endif()
  572. if(BUILD_MD5)
  573. list(APPEND LIB_SOURCES wolfcrypt/src/md5.c)
  574. endif()
  575. if(BUILD_PWDBASED)
  576. list(APPEND LIB_SOURCES
  577. wolfcrypt/src/pwdbased.c
  578. wolfcrypt/src/pkcs12.c)
  579. endif()
  580. if(BUILD_DSA)
  581. list(APPEND LIB_SOURCES wolfcrypt/src/dsa.c)
  582. endif()
  583. if(NOT BUILD_FIPS_V2 AND BUILD_AESNI)
  584. list(APPEND LIB_SOURCES
  585. wolfcrypt/src/aes_asm.S
  586. wolfcrypt/src/aes_gcm_asm.S)
  587. endif()
  588. if(BUILD_CAMELLIA)
  589. list(APPEND LIB_SOURCES wolfcrypt/src/camellia.c)
  590. endif()
  591. if(BUILD_MD2)
  592. list(APPEND LIB_SOURCES wolfcrypt/src/md2.c)
  593. endif()
  594. if(BUILD_RIPEMD)
  595. list(APPEND LIB_SOURCES wolfcrypt/src/ripemd.c)
  596. endif()
  597. if(BUILD_BLAKE2)
  598. list(APPEND LIB_SOURCES wolfcrypt/src/blake2b.c)
  599. endif()
  600. if(BUILD_BLAKE2S)
  601. list(APPEND LIB_SOURCES wolfcrypt/src/blake2s.c)
  602. endif()
  603. if(BUILD_CHACHA)
  604. if(BUILD_ARMASM)
  605. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-chacha.c)
  606. else()
  607. list(APPEND LIB_SOURCES wolfcrypt/src/chacha.c)
  608. if(BUILD_INTELASM)
  609. list(APPEND LIB_SOURCES wolfcrypt/src/chacha_asm.S)
  610. endif()
  611. endif()
  612. if(BUILD_POLY1305)
  613. list(APPEND LIB_SOURCES wolfcrypt/src/chacha20_poly1305.c)
  614. endif()
  615. endif()
  616. if(NOT BUILD_INLINE)
  617. list(APPEND LIB_SOURCES wolfcrypt/src/misc.c)
  618. endif()
  619. if(BUILD_FAST_MATH)
  620. list(APPEND LIB_SOURCES wolfcrypt/src/tfm.c)
  621. endif()
  622. if(BUILD_SLOW_MATH)
  623. list(APPEND LIB_SOURCES wolfcrypt/src/integer.c)
  624. endif()
  625. if(NOT BUILD_FIPS_V2 AND BUILD_ECC)
  626. list(APPEND LIB_SOURCES wolfcrypt/src/ecc.c)
  627. endif()
  628. if(BUILD_CURVE25519)
  629. list(APPEND LIB_SOURCES wolfcrypt/src/curve25519.c)
  630. endif()
  631. if(BUILD_ED25519)
  632. list(APPEND LIB_SOURCES wolfcrypt/src/ed25519.c)
  633. endif()
  634. if(BUILD_FEMATH)
  635. if(BUILD_CURVE25519_SMALL)
  636. list(APPEND LIB_SOURCES wolfcrypt/src/fe_low_mem.c)
  637. else()
  638. if(BUILD_INTELASM)
  639. list(APPEND LIB_SOURCES wolfcrypt/src/fe_x25519_asm.S)
  640. else()
  641. if(BUILD_ARMASM)
  642. list(APPEND LIB_SOURCES
  643. wolfcrypt/src/port/arm/armv8-32-curve25519.S
  644. wolfcrypt/src/port/arm/armv8-curve25519.S)
  645. else()
  646. list(APPEND LIB_SOURCES wolfcrypt/src/fe_operations.c)
  647. endif()
  648. endif()
  649. endif()
  650. endif()
  651. if(BUILD_GEMATH)
  652. if(BUILD_ED25519_SMALL)
  653. list(APPEND LIB_SOURCES wolfcrypt/src/ge_low_mem.c)
  654. else()
  655. list(APPEND LIB_SOURCES wolfcrypt/src/ge_operations.c)
  656. if(NOT BUILD_FEMATH)
  657. if(BUILD_INTELASM)
  658. list(APPEND LIB_SOURCES wolfcrypt/src/fe_x25519_asm.S)
  659. else()
  660. if(BUILD_ARMASM)
  661. list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-curve25519.S)
  662. else()
  663. list(APPEND LIB_SOURCES wolfcrypt/src/fe_operations.c)
  664. endif()
  665. endif()
  666. endif()
  667. endif()
  668. endif()
  669. if(BUILD_CURVE448)
  670. list(APPEND LIB_SOURCES wolfcrypt/src/curve448.c)
  671. endif()
  672. if(BUILD_ED448)
  673. list(APPEND LIB_SOURCES wolfcrypt/src/ed448.c)
  674. endif()
  675. if(BUILD_FE448)
  676. list(APPEND LIB_SOURCES wolfcrypt/src/fe_448.c)
  677. endif()
  678. if(BUILD_GE448)
  679. list(APPEND LIB_SOURCES wolfcrypt/src/ge_448.c)
  680. if(NOT BUILD_FE448)
  681. list(APPEND LIB_SOURCES wolfcrypt/src/fe_448.c)
  682. endif()
  683. endif()
  684. if(BUILD_FALCON)
  685. list(APPEND LIB_SOURCES wolfcrypt/src/falcon.c)
  686. endif()
  687. if(BUILD_SPHINCS)
  688. list(APPEND LIB_SOURCES wolfcrypt/src/sphincs.c)
  689. endif()
  690. if(BUILD_DILITHIUM)
  691. list(APPEND LIB_SOURCES wolfcrypt/src/dilithium.c)
  692. endif()
  693. if(BUILD_EXT_KYBER)
  694. list(APPEND LIB_SOURCES wolfcrypt/src/ext_kyber.c)
  695. endif()
  696. if(BUILD_LIBZ)
  697. list(APPEND LIB_SOURCES wolfcrypt/src/compress.c)
  698. endif()
  699. if(BUILD_PKCS7)
  700. list(APPEND LIB_SOURCES wolfcrypt/src/pkcs7.c)
  701. endif()
  702. if(BUILD_SRP)
  703. list(APPEND LIB_SOURCES wolfcrypt/src/srp.c)
  704. endif()
  705. if(BUILD_AFALG)
  706. list(APPEND LIB_SOURCES wolfcrypt/src/port/af_alg/wc_afalg.c)
  707. endif()
  708. if(NOT BUILD_CRYPTONLY)
  709. # ssl files
  710. list(APPEND LIB_SOURCES
  711. src/internal.c
  712. src/wolfio.c
  713. src/keys.c
  714. src/ssl.c
  715. src/ocsp.c
  716. src/tls.c)
  717. if(BUILD_TLS13)
  718. list(APPEND LIB_SOURCES src/tls13.c)
  719. endif()
  720. if(BUILD_DTLS13)
  721. list(APPEND LIB_SOURCES src/dtls13.c)
  722. endif()
  723. if(BUILD_QUIC)
  724. list(APPEND LIB_SOURCES src/quic.c)
  725. endif()
  726. if(BUILD_OCSP)
  727. list(APPEND LIB_SOURCES src/ocsp.c)
  728. endif()
  729. if(BUILD_CRL)
  730. list(APPEND LIB_SOURCES src/crl.c)
  731. endif()
  732. if(BUILD_SNIFFER)
  733. list(APPEND LIB_SOURCES src/sniffer.c)
  734. endif()
  735. if(BUILD_DTLS_COMMON)
  736. list(APPEND LIB_SOURCES src/dtls.c)
  737. endif()
  738. if(BUILD_QUIC)
  739. list(APPEND LIB_SOURCES src/quic.c)
  740. endif()
  741. endif()
  742. endif()
  743. # Corresponds to wolfcrypt/src/include.am
  744. if(BUILD_CRYPTOCB)
  745. list(APPEND LIB_SOURCES wolfcrypt/src/cryptocb.c)
  746. endif()
  747. if(BUILD_PKCS11)
  748. list(APPEND LIB_SOURCES wolfcrypt/src/wc_pkcs11.c)
  749. endif()
  750. if(BUILD_DEVCRYPTO)
  751. list(APPEND LIB_SOURCES
  752. wolfcrypt/src/port/devcrypto/devcrypto_hash.c
  753. wolfcrypt/src/port/devcrypto/devcrypto_aes.c
  754. wolfcrypt/src/port/devcrypto/wc_devcrypto.c)
  755. endif()
  756. if(BUILD_CAVIUM)
  757. list(APPEND LIB_SOURCES wolfcrypt/src/port/cavium/cavium_nitrox.c)
  758. endif()
  759. if(BUILD_OCTEON_SYNC)
  760. list(APPEND LIB_SOURCES wolfcrypt/src/port/cavium/cavium_octeon_sync.c)
  761. endif()
  762. if(BUILD_INTEL_QA)
  763. list(APPEND LIB_SOURCES
  764. wolfcrypt/src/port/intel/quickassist.c
  765. wolfcrypt/src/port/intel/quickassist_mem.c)
  766. endif()
  767. if(BUILD_INTEL_QA_SYNC)
  768. list(APPEND LIB_SOURCES wolfcrypt/src/port/intel/quickassist_sync.c)
  769. endif()
  770. if(BUILD_CRYPTOAUTHLIB)
  771. list(APPEND LIB_SOURCES wolfcrypt/src/port/atmel/atmel.c)
  772. endif()
  773. if(BUILD_CAAM)
  774. list(APPEND LIB_SOURCES
  775. wolfcrypt/src/port/caam/wolfcaam_init.c
  776. wolfcrypt/src/port/caam/wolfcaam_qnx.c
  777. wolfcrypt/src/port/caam/wolfcaam_seco.c
  778. wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c
  779. wolfcrypt/src/port/caam/wolfcaam_x25519.c
  780. wolfcrypt/src/port/caam/wolfcaam_ecdsa.c
  781. wolfcrypt/src/port/caam/wolfcaam_cmac.c
  782. wolfcrypt/src/port/caam/wolfcaam_aes.c
  783. wolfcrypt/src/port/caam/wolfcaam_hash.c
  784. wolfcrypt/src/port/caam/wolfcaam_rsa.c
  785. wolfcrypt/src/port/caam/wolfcaam_hmac.c)
  786. endif()
  787. if(BUILD_HPKE)
  788. list(APPEND LIB_SOURCES wolfcrypt/src/hpke.c)
  789. endif()
  790. set(LIB_SOURCES ${LIB_SOURCES} PARENT_SCOPE)
  791. endfunction()
  792. function(add_to_options_file DEFINITIONS OPTION_FILE)
  793. list(REMOVE_DUPLICATES DEFINITIONS)
  794. foreach(DEF IN LISTS DEFINITIONS)
  795. if(DEF MATCHES "^-D")
  796. if(DEF MATCHES "^-D(N)?DEBUG(=.+)?")
  797. message("not outputting (N)DEBUG to ${OPTION_FILE}")
  798. endif()
  799. # allow user to ignore system options
  800. if(DEF MATCHES "^-D_.*")
  801. file(APPEND ${OPTION_FILE} "#ifndef WOLFSSL_OPTIONS_IGNORE_SYS\n")
  802. endif()
  803. string(REGEX REPLACE "^-D" "" DEF_NO_PREFIX ${DEF})
  804. string(REGEX REPLACE "=.*$" "" DEF_NO_EQUAL_NO_VAL ${DEF_NO_PREFIX})
  805. string(REPLACE "=" " " DEF_NO_EQUAL ${DEF_NO_PREFIX})
  806. file(APPEND ${OPTION_FILE} "#undef ${DEF_NO_EQUAL_NO_VAL}\n")
  807. file(APPEND ${OPTION_FILE} "#define ${DEF_NO_EQUAL}\n")
  808. if(DEF MATCHES "^-D_.*")
  809. file(APPEND ${OPTION_FILE} "#endif\n")
  810. endif()
  811. file(APPEND ${OPTION_FILE} "\n")
  812. endif()
  813. endforeach()
  814. endfunction()