1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018 |
- function(override_cache VAR VAL)
- get_property(VAR_STRINGS CACHE ${VAR} PROPERTY STRINGS)
- LIST(FIND VAR_STRINGS ${VAL} CK)
- if(-1 EQUAL ${CK} AND DEFINED VAR_STRINGS)
- message(SEND_ERROR
- "\"${VAL}\" is not valid override value for \"${VAR}\"."
- " Please select value from \"${VAR_STRINGS}\"\n")
- endif()
- set_property(CACHE ${VAR} PROPERTY VALUE ${VAL})
- endfunction()
- function(add_option NAME HELP_STRING DEFAULT VALUES)
- if(VALUES STREQUAL "yes;no")
- # Set the default value for the option.
- set(${NAME} ${DEFAULT} CACHE BOOL ${HELP_STRING})
- else()
- # Set the default value for the option.
- set(${NAME} ${DEFAULT} CACHE STRING ${HELP_STRING})
- # Set the list of allowed values for the option.
- set_property(CACHE ${NAME} PROPERTY STRINGS ${VALUES})
- endif()
- if(DEFINED ${NAME})
- list(FIND VALUES ${${NAME}} IDX)
- #
- # If the given value isn't in the list of allowed values for the option,
- # reduce it to yes/no according to CMake's "if" logic:
- # https://cmake.org/cmake/help/latest/command/if.html#basic-expressions
- #
- # This has no functional impact; it just makes the settings in
- # CMakeCache.txt and cmake-gui easier to read.
- #
- if (${IDX} EQUAL -1)
- if(${${NAME}})
- override_cache(${NAME} "yes")
- else()
- override_cache(${NAME} "no")
- endif()
- endif()
- endif()
- endfunction()
- function(generate_build_flags)
- set(BUILD_DISTRO ${WOLFSSL_DISTRO} PARENT_SCOPE)
- set(BUILD_ALL ${WOLFSSL_ALL} PARENT_SCOPE)
- if(WOLFSSL_TLS13 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_TLS13 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_DTLS13 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_DTLS13 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_QUIC)
- set(BUILD_QUIC "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_RNG OR WOLFSSL_USER_SETTINGS)
- set(BUILD_RNG "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_SCTP OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SCTP "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_DTLS_CID OR WOLFSSL_USER_SETTINGS OR WOLFSSL_DTLS)
- set(BUILD_DTLS_COMMON "yes" PARENT_SCOPE)
- endif()
- set(BUILD_MCAST ${WOLFSSL_MCAST} PARENT_SCOPE)
- set(BUILD_IPV6 ${WOLFSSL_IPV6} PARENT_SCOPE)
- set(BUILD_LEAN_PSK ${WOLFSSL_LEAN_PSK} PARENT_SCOPE)
- set(BUILD_LEAN_TLS ${WOLFSSL_LEAN_TLS} PARENT_SCOPE)
- set(BUILD_LOWMEM ${WOLFSSL_LOWRESOURCE} PARENT_SCOPE)
- set(BUILD_PKCALLBACKS ${WOLFSSL_PKCALLBACKS} PARENT_SCOPE)
- set(BUILD_CRYPTOAUTHLIB ${WOLFSSL_CRYPTOAUTHLIB} PARENT_SCOPE)
- if(WOLFSSL_SNIFFER OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SNIFFER "yes" PARENT_SCOPE)
- endif()
- set(BUILD_SNIFFTEST ${WOLFSSL_SNIFFTEST} PARENT_SCOPE)
- if(WOLFSSL_AESGCM OR WOLFSSL_USER_SETTINGS)
- set(BUILD_AESGCM "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_AESCCM OR WOLFSSL_USER_SETTINGS)
- set(BUILD_AESCCM "yes" PARENT_SCOPE)
- endif()
- set(BUILD_ARM_ASM ${WOLFSSL_ARM_ASM} PARENT_SCOPE)
- set(BUILD_XILINX ${WOLFSSL_XILINX} PARENT_SCOPE)
- set(BUILD_AESNI ${WOLFSSL_AESNI} PARENT_SCOPE)
- set(BUILD_INTEL_ASM ${WOLFSSL_INTEL_ASM} PARENT_SCOPE)
- set(BUILD_AFALG ${WOLFSSL_AFALG} PARENT_SCOPE)
- set(BUILD_DEVCRYPTO ${WOLFSSL_DEVCRYPTO} PARENT_SCOPE)
- if(WOLFSSL_CAMELLIA OR WOLFSSL_USER_SETTINGS)
- set(BUILD_CAMELLIA "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_MD2 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_MD2 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_RIPEMD OR WOLFSSL_USER_SETTINGS)
- set(BUILD_RIPEMD "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_BLAKE2 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_BLAKE2 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_BLAKE2S OR WOLFSSL_USER_SETTINGS)
- set(BUILD_BLAKE2S "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_SHA512 OR WOLFSSL_SHA384 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SHA512 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_DSA OR WOLFSSL_USER_SETTINGS)
- set(BUILD_DSA "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_ECC OR WOLFSSL_USER_SETTINGS)
- set(BUILD_ECC "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_ED25519 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_ED25519 "yes" PARENT_SCOPE)
- endif()
- set(BUILD_ED25519_SMALL ${WOLFSSL_ED25519_SMALL} PARENT_SCOPE)
- if(WOLFSSL_FEMATH OR WOLFSSL_USER_SETTINGS)
- set(BUILD_FEMATH "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_GEMATH OR WOLFSSL_USER_SETTINGS)
- set(BUILD_GEMATH "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_CURVE25519 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_CURVE25519 "yes" PARENT_SCOPE)
- endif()
- set(BUILD_CURVE25519_SMALL ${WOLFSSL_CURVE25519_SMALL} PARENT_SCOPE)
- if(WOLFSSL_ED448 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_ED448 "yes" PARENT_SCOPE)
- endif()
- set(BUILD_ED448_SMALL ${WOLFSSL_ED448_SMALL} PARENT_SCOPE)
- if(WOLFSSL_FE448 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_FE448 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_GE448 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_GE448 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_CURVE448 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_CURVE448 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_CURVE448_SMALL OR WOLFSSL_USER_SETTINGS)
- set(BUILD_CURVE448_SMALL "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_MEMORY OR WOLFSSL_USER_SETTINGS)
- set(BUILD_MEMORY "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_RSA OR WOLFSSL_USER_SETTINGS)
- set(BUILD_RSA "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_DH OR WOLFSSL_USER_SETTINGS)
- set(BUILD_DH "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_ASN OR WOLFSSL_USER_SETTINGS)
- set(BUILD_ASN "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_AES OR WOLFSSL_USER_SETTINGS)
- set(BUILD_AES "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_CODING OR WOLFSSL_USER_SETTINGS)
- set(BUILD_CODING "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_ARC4 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_RC4 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_MD5 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_MD5 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_SHA OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SHA "yes" PARENT_SCOPE)
- endif()
- set(BUILD_FIPS ${WOLFSSL_FIPS} PARENT_SCOPE)
- if("${FIPS_VERSION}" STREQUAL "v1")
- set(BUILD_FIPS_V1 "yes" PARENT_SCOPE)
- endif()
- if("${FIPS_VERSION}" STREQUAL "v2")
- set(BUILD_FIPS_V2 "yes" PARENT_SCOPE)
- endif()
- if("${FIPS_VERSION}" STREQUAL "rand")
- set(BUILD_FIPS_RAND "yes" PARENT_SCOPE)
- endif()
- if("${FIPS_VERSION}" STREQUAL "v5")
- set(BUILD_FIPS_V5 "yes" PARENT_SCOPE)
- endif()
- set(BUILD_FIPS_READY ${FIPS_READY} PARENT_SCOPE)
- if(WOLFSSL_CMAC OR WOLFSSL_USER_SETTINGS)
- set(BUILD_CMAC "yes" PARENT_SCOPE)
- endif()
- set(BUILD_SELFTEST ${WOLFSSL_SELFTEST} PARENT_SCOPE)
- if(WOLFSSL_SHA224 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SHA224 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_SHA3 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SHA3 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_POLY1305 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_POLY1305 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_CHACHA OR WOLFSSL_USER_SETTINGS)
- set(BUILD_CHACHA "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_XCHACHA OR WOLFSSL_USER_SETTINGS)
- set(BUILD_XCHACHA "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_OQS OR WOLFSSL_USER_SETTINGS)
- set(BUILD_FALCON "yes" PARENT_SCOPE)
- set(BUILD_SPHINCS "yes" PARENT_SCOPE)
- set(BUILD_DILITHIUM "yes" PARENT_SCOPE)
- set(BUILD_EXT_KYBER "yes" PARENT_SCOPE)
- set(BUILD_OQS_HELPER "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_ARIA OR WOLFSSL_USER_SETTINGS)
- message(STATUS "ARIA functions.cmake found WOLFSSL_ARIA")
- # we cannot actually build, as we only have pre-compiled bin
- set(BUILD_ARIA "yes" PARENT_SCOPE)
- endif()
- set(BUILD_INLINE ${WOLFSSL_INLINE} PARENT_SCOPE)
- if(WOLFSSL_OCSP OR WOLFSSL_USER_SETTINGS)
- set(BUILD_OCSP "yes" PARENT_SCOPE)
- endif()
- set(BUILD_OCSP_STAPLING ${WOLFSSL_OCSPSTAPLING} PARENT_SCOPE)
- set(BUILD_OCSP_STAPLING_V2 ${WOLFSSL_OCSPSTAPLING_V2} PARENT_SCOPE)
- if(WOLFSSL_CRL OR WOLFSSL_USER_SETTINGS)
- set(BUILD_CRL "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_CRL_MONITOR)
- set(BUILD_CRL_MONITOR "yes" PARENT_SCOPE)
- endif()
- set(BUILD_QUIC ${WOLFSSL_QUIC} PARENT_SCOPE)
- set(BUILD_WNR ${WOLFSSL_WNR} PARENT_SCOPE)
- if(WOLFSSL_SRP OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SRP "yes" PARENT_SCOPE)
- endif()
- set(USE_VALGRIND ${WOLFSSL_VALGRIND})
- if(WOLFSSL_MD4 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_MD4 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_PWDBASED OR WOLFSSL_USER_SETTINGS)
- set(BUILD_PWDBASED "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_SCRYPT OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SCRYPT "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_CRYPT_ONLY AND NOT WOLFSSL_OPENSSL_EXTRA)
- set(BUILD_CRYPTONLY "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_FAST_MATH OR WOLFSSL_USER_SETTINGS)
- set(BUILD_FAST_MATH "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_SLOW_MATH OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SLOW_MATH "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_EXAMPLES AND NOT WOLFSSL_LEAN_TLS)
- set(BUILD_EXAMPLE_SERVERS "yes" PARENT_SCOPE)
- endif()
- set(BUILD_EXAMPLE_CLIENTS ${WOLFSSL_EXAMPLES} PARENT_SCOPE)
- set(BUILD_TESTS ${WOLFSSL_EXAMPLES} PARENT_SCOPE)
- if(NOT WOLFSSL_SINGLETHREADED AND WOLFSSL_EXAMPLES AND NOT WOLFSSL_LEAN_TLS)
- set(BUILD_THREADED_EXAMPLES "yes" PARENT_SCOPE)
- endif()
- set(BUILD_WOLFCRYPT_TESTS ${WOLFSSL_CRYPT_TESTS} PARENT_SCOPE)
- set(BUILD_LIBZ ${WOLFSSL_LIBZ} PARENT_SCOPE)
- if(WOLFSSL_PKCS11 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_PKCS11 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_PKCS12 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_PKCS12 "yes" PARENT_SCOPE)
- endif()
- set(BUILD_CAVIUM ${WOLFSSL_CAVIUM} PARENT_SCOPE)
- set(BUILD_CAVIUM_V ${WOLFSSL_CAVIUM_V} PARENT_SCOPE)
- set(BUILD_OCTEON_SYNC ${WOLFSSL_OCTEON_SYNC} PARENT_SCOPE)
- set(BUILD_INTEL_QA ${WOLFSSL_INTEL_QA} PARENT_SCOPE)
- set(BUILD_INTEL_QA_SYNC ${WOLFSSL_INTEL_QA_SYNC} PARENT_SCOPE)
- if(WOLFSSL_SP OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SP "yes" PARENT_SCOPE)
- endif()
- if((WOLFSSL_SP AND NOT WOLFSSL_SP_ASM) OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SP_C "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_SP_ARM64_ASM OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SP_ARM64 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_SP_ARM32_ASM OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SP_ARM32 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_SP_ARM_THUMB_ASM OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SP_ARM_THUMB "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_SP_ARM_CORTEX_ASM OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SP_ARM_CORTEX "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_X86_64_BUILD AND (WOLFSSL_SP_X86_64_ASM OR WOLFSSL_USER_SETTINGS))
- set(BUILD_SP_X86_64 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_SP_MATH OR WOLFSSL_SP_MATH_ALL OR WOLFSSL_USER_SETTINGS)
- set(BUILD_SP_INT "yes" PARENT_SCOPE)
- endif()
- set(BUILD_MCAPI ${WOLFSSL_MCAPI} PARENT_SCOPE)
- set(BUILD_ASYNCCRYPT ${WOLFSSL_ASYNCCRYPT} PARENT_SCOPE)
- set(BUILD_WOLFEVENT ${WOLFSSL_ASYNCCRYPT} PARENT_SCOPE)
- if(WOLFSSL_CRYPTOCB OR WOLFSSL_USER_SETTINGS)
- set(BUILD_CRYPTOCB "yes" PARENT_SCOPE)
- endif()
- set(BUILD_PSK ${WOLFSSL_PSK} PARENT_SCOPE)
- set(BUILD_TRUST_PEER_CERT ${WOLFSSL_TRUSTED_PEER_CERT} PARENT_SCOPE)
- set(BUILD_PKI ${WOLFSSL_PKI} PARENT_SCOPE)
- if(WOLFSSL_DES3 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_DES3 "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_PKCS7 OR WOLFSSL_USER_SETTINGS)
- set(BUILD_PKCS7 "yes" PARENT_SCOPE)
- endif()
- set(BUILD_HASHFLAGS ${WOLFSSL_HASHFLAGS} PARENT_SCOPE)
- set(BUILD_LINUX_KM ${WOLFSSL_LINUX_KM} PARENT_SCOPE)
- set(BUILD_NO_LIBRARY ${WOLFSSL_NO_LIBRARY} PARENT_SCOPE)
- if(WOLFSSL_DEBUG OR WOLFSSL_STACK_SIZE)
- set(BUILD_DEBUG "yes" PARENT_SCOPE)
- endif()
- set(BUILD_RC2 ${WOLFSSL_RC2} PARENT_SCOPE)
- if(WOLFSSL_CAAM)
- set(BUILD_CAAM "yes" PARENT_SCOPE)
- endif()
- if(WOLFSSL_HPKE OR WOLFSSL_USER_SETTINGS)
- set(BUILD_HPKE "yes" PARENT_SCOPE)
- endif()
- set(BUILD_FLAGS_GENERATED "yes" PARENT_SCOPE)
- endfunction()
- function(generate_lib_src_list LIB_SOURCES)
- if(NOT BUILD_FLAGS_GENERATED)
- message(FATAL_ERROR "Cannot call generate_lib_src_list without calling generate_build_flags first.")
- endif()
- # Corresponds to src/include.am
- if(BUILD_FIPS)
- if(BUILD_FIPS_V2)
- # FIPSv2 first file
- list(APPEND LIB_SOURCES wolfcrypt/src/wolfcrypt_first.c)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/hmac.c
- wolfcrypt/src/random.c
- wolfcrypt/src/sha256.c)
- if(BUILD_RSA)
- list(APPEND LIB_SOURCES wolfcrypt/src/rsa.c)
- endif()
- if(BUILD_ECC)
- list(APPEND LIB_SOURCES wolfcrypt/src/ecc.c)
- endif()
- if(BUILD_AES)
- list(APPEND LIB_SOURCES wolfcrypt/src/aes.c)
- if(BUILD_ARMASM AND BUILD_FIPS_READY)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-aes.c)
- endif()
- endif()
- if(BUILD_AESNI)
- list(APPEND LIB_SOURCES wolfcrypt/src/aes_asm.S)
- if(BUILD_INTELASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/aes_gcm_asm.S)
- endif()
- endif()
- if(BUILD_DES3)
- list(APPEND LIB_SOURCES wolfcrypt/src/des3.c)
- endif()
- if(BUILD_SHA)
- list(APPEND LIB_SOURCES wolfcrypt/src/sha.c)
- endif()
- if(BUILD_ARMASM AND BUILD_FIPS_READY)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-sha256.c)
- endif()
- if(BUILD_INTELASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/sha256_asm.S)
- endif()
- if(BUILD_SHA512)
- list(APPEND LIB_SOURCES wolfcrypt/src/sha512.c)
- if(BUILD_ARMASM AND BUILD_FIPS_READY)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/port/arm/armv8-sha512.c
- wolfcrypt/src/port/arm/armv8-sha512-asm.S
- wolfcrypt/src/port/arm/armv8-32-sha512-asm.S)
- endif()
- if(BUILD_INTELASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/sha512_asm.S)
- endif()
- endif()
- if(BUILD_SHA3)
- list(APPEND LIB_SOURCES wolfcrypt/src/sha3.c)
- endif()
- if(BUILD_DH)
- list(APPEND LIB_SOURCES wolfcrypt/src/dh.c)
- endif()
- if(BUILD_CMAC)
- list(APPEND LIB_SOURCES wolfcrypt/src/cmac.c)
- endif()
- list(APPEND LIB_SOURCES
- wolfcrypt/src/fips.c
- wolfcrypt/src/fips_test.c)
- # fips last file
- list(APPEND LIB_SOURCES wolfcrypt/src/wolfcrypt_last.c)
- endif()
- if(BUILD_FIPS_V5)
- list(APPEND LIB_SOURCES wolfcrypt/src/wolfcrypt_first.c)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/hmac.c
- wolfcrypt/src/random.c
- wolfcrypt/src/sha256.c)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/kdf.c)
- if(BUILD_RSA)
- list(APPEND LIB_SOURCES wolfcrypt/src/rsa.c)
- endif()
- endif()
- if(BUILD_FIPS_RAND)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/wolfcrypt_first.c
- wolfcrypt/src/hmac.c
- wolfcrypt/src/random.c
- wolfcrypt/src/sha256.c
- wolfcrypt/src/sha256_asm.S
- wolfcrypt/src/fips.c
- wolfcrypt/src/fips_test.c
- wolfcrypt/src/wolfcrypt_last.c)
- endif()
- endif()
- # For wolfRand, exclude everything else.
- if(NOT BUILD_FIPS_RAND)
- # For FIPSV2, exclude the wolfCrypt files included above.
- # For wolfRand, exclude just a couple files.
- # For old FIPS, keep the wolfCrypt versions of the
- # CtaoCrypt files included above.
- if(NOT BUILD_FIPS_V2)
- list(APPEND LIB_SOURCES wolfcrypt/src/hmac.c)
- endif()
- # CAVP self test
- if(BUILD_SELFTEST)
- list(APPEND LIB_SOURCES wolfcrypt/src/selftest.c)
- endif()
- endif()
- list(APPEND LIB_SOURCES
- wolfcrypt/src/hash.c
- wolfcrypt/src/cpuid.c)
- if(NOT BUILD_FIPS_RAND)
- if(NOT BUILD_FIPS_V5)
- list(APPEND LIB_SOURCES wolfcrypt/src/kdf.c)
- endif()
- if(NOT BUILD_FIPS_V2 AND BUILD_RNG)
- list(APPEND LIB_SOURCES wolfcrypt/src/random.c)
- endif()
- if(NOT BUILD_FIPS_V2)
- if(BUILD_ARMASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-sha256.c)
- else()
- list(APPEND LIB_SOURCES wolfcrypt/src/sha256.c)
- if(BUILD_INTELASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/sha256_asm.S)
- endif()
- endif()
- endif()
- if(BUILD_AFALG)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/af_alg/afalg_hash.c)
- endif()
- if(BUILD_WOLFEVENT)
- list(APPEND LIB_SOURCES wolfcrypt/src/wolfevent.c)
- endif()
- if(BUILD_ASYNCCRYPT)
- list(APPEND LIB_SOURCES wolfcrypt/src/async.c)
- endif()
- if(BUILD_RSA)
- if(NOT BUILD_FIPS_V2)
- list(APPEND LIB_SOURCES wolfcrypt/src/rsa.c)
- endif()
- endif()
- if(BUILD_SP)
- if(BUILD_SP_C)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/sp_c32.c
- wolfcrypt/src/sp_c64.c)
- endif()
- if(BUILD_SP_X86_64)
- list(APPEND LIB_SOURCES wolfcrypt/src/sp_x86_64.c)
- if(WOLFSSL_X86_64_BUILD_ASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/sp_x86_64_asm.S)
- endif()
- endif()
- if(NOT BUILD_FIPS_V2 AND BUILD_SP_ARM32)
- list(APPEND LIB_SOURCES wolfcrypt/src/sp_arm32.c)
- endif()
- if(BUILD_SP_ARM_THUMB)
- list(APPEND LIB_SOURCES wolfcrypt/src/sp_armthumb.c)
- endif()
- if(BUILD_SP_ARM64)
- list(APPEND LIB_SOURCES wolfcrypt/src/sp_arm64.c)
- endif()
- if(BUILD_SP_ARM_CORTEX)
- list(APPEND LIB_SOURCES wolfcrypt/src/sp_cortexm.c)
- endif()
- endif()
- if(BUILD_SP_INT)
- list(APPEND LIB_SOURCES wolfcrypt/src/sp_int.c)
- endif()
- if(NOT BUILD_FIPS_V2)
- if(BUILD_AES)
- list(APPEND LIB_SOURCES wolfcrypt/src/aes.c)
- if(BUILD_ARMASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-aes.c)
- endif()
- if(BUILD_AFALG)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/af_alg/afalg_aes.c)
- endif()
- endif()
- endif()
- if(NOT BUILD_FIPS_V2 AND BUILD_CMAC)
- list(APPEND LIB_SOURCES wolfcrypt/src/cmac.c)
- endif()
- if(NOT BUILD_FIPS_V2 AND BUILD_DES3)
- list(APPEND LIB_SOURCES wolfcrypt/src/des3.c)
- endif()
- if(NOT BUILD_FIPS_V2 AND BUILD_SHA)
- list(APPEND LIB_SOURCES wolfcrypt/src/sha.c)
- endif()
- if(NOT BUILD_FIPS_V2 AND BUILD_SHA512)
- if(BUILD_ARMASM)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/port/arm/armv8-sha512.c
- wolfcrypt/src/port/arm/armv8-sha512-asm.S
- wolfcrypt/src/port/arm/armv8-32-sha512-asm.S)
- else()
- list(APPEND LIB_SOURCES wolfcrypt/src/sha512.c)
- if(BUILD_INTELASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/sha512_asm.S)
- endif()
- endif()
- endif()
- if(NOT BUILD_FIPS_V2 AND BUILD_SHA3)
- list(APPEND LIB_SOURCES wolfcrypt/src/sha3.c)
- endif()
- endif()
- list(APPEND LIB_SOURCES
- wolfcrypt/src/logging.c
- wolfcrypt/src/wc_port.c
- wolfcrypt/src/error.c)
- if(BUILD_OQS_HELPER)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/port/liboqs/liboqs.c)
- endif()
- if(BUILD_ARIA)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/port/aria/aria-crypt.c
- wolfcrypt/src/port/aria/aria-cryptocb.c)
- endif()
- if(NOT BUILD_FIPS_RAND)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/wc_encrypt.c
- wolfcrypt/src/signature.c
- wolfcrypt/src/wolfmath.c)
- endif()
- if(BUILD_MEMORY)
- list(APPEND LIB_SOURCES wolfcrypt/src/memory.c)
- endif()
- if(NOT BUILD_FIPS_RAND)
- if(NOT BUILD_FIPS_V2 AND BUILD_DH)
- list(APPEND LIB_SOURCES wolfcrypt/src/dh.c)
- endif()
- if(BUILD_ASN)
- list(APPEND LIB_SOURCES wolfcrypt/src/asn.c)
- endif()
- endif()
- if(BUILD_CODING)
- list(APPEND LIB_SOURCES wolfcrypt/src/coding.c)
- endif()
- if(NOT BUILD_FIPS_RAND)
- if(BUILD_POLY1305)
- if(BUILD_ARMASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-poly1305.c)
- endif()
- list(APPEND LIB_SOURCES wolfcrypt/src/poly1305.c)
- if(BUILD_INTELASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/poly1305_asm.S)
- endif()
- endif()
- if(BUILD_RC4)
- list(APPEND LIB_SOURCES wolfcrypt/src/arc4.c)
- endif()
- if(BUILD_MD4)
- list(APPEND LIB_SOURCES wolfcrypt/src/md4.c)
- endif()
- if(BUILD_MD5)
- list(APPEND LIB_SOURCES wolfcrypt/src/md5.c)
- endif()
- if(BUILD_PWDBASED)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/pwdbased.c
- wolfcrypt/src/pkcs12.c)
- endif()
- if(BUILD_DSA)
- list(APPEND LIB_SOURCES wolfcrypt/src/dsa.c)
- endif()
- if(NOT BUILD_FIPS_V2 AND BUILD_AESNI)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/aes_asm.S
- wolfcrypt/src/aes_gcm_asm.S)
- endif()
- if(BUILD_CAMELLIA)
- list(APPEND LIB_SOURCES wolfcrypt/src/camellia.c)
- endif()
- if(BUILD_MD2)
- list(APPEND LIB_SOURCES wolfcrypt/src/md2.c)
- endif()
- if(BUILD_RIPEMD)
- list(APPEND LIB_SOURCES wolfcrypt/src/ripemd.c)
- endif()
- if(BUILD_BLAKE2)
- list(APPEND LIB_SOURCES wolfcrypt/src/blake2b.c)
- endif()
- if(BUILD_BLAKE2S)
- list(APPEND LIB_SOURCES wolfcrypt/src/blake2s.c)
- endif()
- if(BUILD_CHACHA)
- if(BUILD_ARMASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-chacha.c)
- else()
- list(APPEND LIB_SOURCES wolfcrypt/src/chacha.c)
- if(BUILD_INTELASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/chacha_asm.S)
- endif()
- endif()
- if(BUILD_POLY1305)
- list(APPEND LIB_SOURCES wolfcrypt/src/chacha20_poly1305.c)
- endif()
- endif()
- if(NOT BUILD_INLINE)
- list(APPEND LIB_SOURCES wolfcrypt/src/misc.c)
- endif()
- if(BUILD_FAST_MATH)
- list(APPEND LIB_SOURCES wolfcrypt/src/tfm.c)
- endif()
- if(BUILD_SLOW_MATH)
- list(APPEND LIB_SOURCES wolfcrypt/src/integer.c)
- endif()
- if(NOT BUILD_FIPS_V2 AND BUILD_ECC)
- list(APPEND LIB_SOURCES wolfcrypt/src/ecc.c)
- endif()
- if(BUILD_CURVE25519)
- list(APPEND LIB_SOURCES wolfcrypt/src/curve25519.c)
- endif()
- if(BUILD_ED25519)
- list(APPEND LIB_SOURCES wolfcrypt/src/ed25519.c)
- endif()
- if(BUILD_FEMATH)
- if(BUILD_CURVE25519_SMALL)
- list(APPEND LIB_SOURCES wolfcrypt/src/fe_low_mem.c)
- else()
- if(BUILD_INTELASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/fe_x25519_asm.S)
- else()
- if(BUILD_ARMASM)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/port/arm/armv8-32-curve25519.S
- wolfcrypt/src/port/arm/armv8-curve25519.S)
- else()
- list(APPEND LIB_SOURCES wolfcrypt/src/fe_operations.c)
- endif()
- endif()
- endif()
- endif()
- if(BUILD_GEMATH)
- if(BUILD_ED25519_SMALL)
- list(APPEND LIB_SOURCES wolfcrypt/src/ge_low_mem.c)
- else()
- list(APPEND LIB_SOURCES wolfcrypt/src/ge_operations.c)
- if(NOT BUILD_FEMATH)
- if(BUILD_INTELASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/fe_x25519_asm.S)
- else()
- if(BUILD_ARMASM)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-curve25519.S)
- else()
- list(APPEND LIB_SOURCES wolfcrypt/src/fe_operations.c)
- endif()
- endif()
- endif()
- endif()
- endif()
- if(BUILD_CURVE448)
- list(APPEND LIB_SOURCES wolfcrypt/src/curve448.c)
- endif()
- if(BUILD_ED448)
- list(APPEND LIB_SOURCES wolfcrypt/src/ed448.c)
- endif()
- if(BUILD_FE448)
- list(APPEND LIB_SOURCES wolfcrypt/src/fe_448.c)
- endif()
- if(BUILD_GE448)
- list(APPEND LIB_SOURCES wolfcrypt/src/ge_448.c)
- if(NOT BUILD_FE448)
- list(APPEND LIB_SOURCES wolfcrypt/src/fe_448.c)
- endif()
- endif()
- if(BUILD_FALCON)
- list(APPEND LIB_SOURCES wolfcrypt/src/falcon.c)
- endif()
- if(BUILD_SPHINCS)
- list(APPEND LIB_SOURCES wolfcrypt/src/sphincs.c)
- endif()
- if(BUILD_DILITHIUM)
- list(APPEND LIB_SOURCES wolfcrypt/src/dilithium.c)
- endif()
- if(BUILD_EXT_KYBER)
- list(APPEND LIB_SOURCES wolfcrypt/src/ext_kyber.c)
- endif()
- if(BUILD_LIBZ)
- list(APPEND LIB_SOURCES wolfcrypt/src/compress.c)
- endif()
- if(BUILD_PKCS7)
- list(APPEND LIB_SOURCES wolfcrypt/src/pkcs7.c)
- endif()
- if(BUILD_SRP)
- list(APPEND LIB_SOURCES wolfcrypt/src/srp.c)
- endif()
- if(BUILD_AFALG)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/af_alg/wc_afalg.c)
- endif()
- if(NOT BUILD_CRYPTONLY)
- # ssl files
- list(APPEND LIB_SOURCES
- src/internal.c
- src/wolfio.c
- src/keys.c
- src/ssl.c
- src/ocsp.c
- src/tls.c)
- if(BUILD_TLS13)
- list(APPEND LIB_SOURCES src/tls13.c)
- endif()
- if(BUILD_DTLS13)
- list(APPEND LIB_SOURCES src/dtls13.c)
- endif()
- if(BUILD_QUIC)
- list(APPEND LIB_SOURCES src/quic.c)
- endif()
- if(BUILD_OCSP)
- list(APPEND LIB_SOURCES src/ocsp.c)
- endif()
- if(BUILD_CRL)
- list(APPEND LIB_SOURCES src/crl.c)
- endif()
- if(BUILD_SNIFFER)
- list(APPEND LIB_SOURCES src/sniffer.c)
- endif()
- if(BUILD_DTLS_COMMON)
- list(APPEND LIB_SOURCES src/dtls.c)
- endif()
- if(BUILD_QUIC)
- list(APPEND LIB_SOURCES src/quic.c)
- endif()
- endif()
- endif()
- # Corresponds to wolfcrypt/src/include.am
- if(BUILD_CRYPTOCB)
- list(APPEND LIB_SOURCES wolfcrypt/src/cryptocb.c)
- endif()
- if(BUILD_PKCS11)
- list(APPEND LIB_SOURCES wolfcrypt/src/wc_pkcs11.c)
- endif()
- if(BUILD_DEVCRYPTO)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/port/devcrypto/devcrypto_hash.c
- wolfcrypt/src/port/devcrypto/devcrypto_aes.c
- wolfcrypt/src/port/devcrypto/wc_devcrypto.c)
- endif()
- if(BUILD_CAVIUM)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/cavium/cavium_nitrox.c)
- endif()
- if(BUILD_OCTEON_SYNC)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/cavium/cavium_octeon_sync.c)
- endif()
- if(BUILD_INTEL_QA)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/port/intel/quickassist.c
- wolfcrypt/src/port/intel/quickassist_mem.c)
- endif()
- if(BUILD_INTEL_QA_SYNC)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/intel/quickassist_sync.c)
- endif()
- if(BUILD_CRYPTOAUTHLIB)
- list(APPEND LIB_SOURCES wolfcrypt/src/port/atmel/atmel.c)
- endif()
- if(BUILD_CAAM)
- list(APPEND LIB_SOURCES
- wolfcrypt/src/port/caam/wolfcaam_init.c
- wolfcrypt/src/port/caam/wolfcaam_qnx.c
- wolfcrypt/src/port/caam/wolfcaam_seco.c
- wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c
- wolfcrypt/src/port/caam/wolfcaam_x25519.c
- wolfcrypt/src/port/caam/wolfcaam_ecdsa.c
- wolfcrypt/src/port/caam/wolfcaam_cmac.c
- wolfcrypt/src/port/caam/wolfcaam_aes.c
- wolfcrypt/src/port/caam/wolfcaam_hash.c
- wolfcrypt/src/port/caam/wolfcaam_rsa.c
- wolfcrypt/src/port/caam/wolfcaam_hmac.c)
- endif()
- if(BUILD_HPKE)
- list(APPEND LIB_SOURCES wolfcrypt/src/hpke.c)
- endif()
- set(LIB_SOURCES ${LIB_SOURCES} PARENT_SCOPE)
- endfunction()
- function(add_to_options_file DEFINITIONS OPTION_FILE)
- list(REMOVE_DUPLICATES DEFINITIONS)
- foreach(DEF IN LISTS DEFINITIONS)
- if(DEF MATCHES "^-D")
- if(DEF MATCHES "^-D(N)?DEBUG(=.+)?")
- message("not outputting (N)DEBUG to ${OPTION_FILE}")
- endif()
- # allow user to ignore system options
- if(DEF MATCHES "^-D_.*")
- file(APPEND ${OPTION_FILE} "#ifndef WOLFSSL_OPTIONS_IGNORE_SYS\n")
- endif()
- string(REGEX REPLACE "^-D" "" DEF_NO_PREFIX ${DEF})
- string(REGEX REPLACE "=.*$" "" DEF_NO_EQUAL_NO_VAL ${DEF_NO_PREFIX})
- string(REPLACE "=" " " DEF_NO_EQUAL ${DEF_NO_PREFIX})
- file(APPEND ${OPTION_FILE} "#undef ${DEF_NO_EQUAL_NO_VAL}\n")
- file(APPEND ${OPTION_FILE} "#define ${DEF_NO_EQUAL}\n")
- if(DEF MATCHES "^-D_.*")
- file(APPEND ${OPTION_FILE} "#endif\n")
- endif()
- file(APPEND ${OPTION_FILE} "\n")
- endif()
- endforeach()
- endfunction()
- # Function: set_wolfssl_definitions
- # Parameter: SEARCH_VALUE The string to search for. (e.g. "WOLFSSL_SHA3")
- # Returns: RESULT
- #
- # Searches WOLFSSL_DEFINITIONS for SEARCH_VALUE
- # Returns RESULT = 1 (true) if the search value is found
- #
- # Ensures setting is only added once and prints status messages.
- #
- # Also sets a parent (global in cmake file) variable by the same name to 1.
- #
- # See also get_wolfssl_definitions() for query-only.
- #
- function(set_wolfssl_definitions SEARCH_VALUE RESULT)
- if (${SEARCH_VALUE} STREQUAL "")
- message(FATAL_ERROR "Function set_wolfssl_definitions cannot have blank SEARCH_VALUE")
- endif()
- list(FIND WOLFSSL_DEFINITIONS "${SEARCH_VALUE}" pos)
- string(SUBSTRING "${SEARCH_VALUE}" 0 2 PREFIX_VALUE)
- if ("${PREFIX_VALUE}" STREQUAL "-D")
- message(FATAL_ERROR "Do not specify the -D prefix in set_wolfssl_definitions")
- endif()
- if(${pos} EQUAL -1)
- message(STATUS "${SEARCH_VALUE} not found in WOLFSSL_DEFINITIONS.")
- message(STATUS "Enabling ${SEARCH_VALUE}")
- list(APPEND WOLFSSL_DEFINITIONS "-D${SEARCH_VALUE}")
- set(${SEARCH_VALUE} 1 PARENT_SCOPE)
- # override_cache("${SEARCH_VALUE}" "yes") # Need to check that value is settable
- set(${RESULT} 1 PARENT_SCOPE)
- message(STATUS "Enabling ${SEARCH_VALUE} - success")
- else()
- message(STATUS "${SEARCH_VALUE} found in WOLFSSL_DEFINITIONS.")
- set(${RESULT} 0 PARENT_SCOPE)
- endif()
- endfunction()
- # Function: get_wolfssl_definitions
- # Parameter: SEARCH_VALUE The string to search for. (e.g. "WOLFSSL_SHA3")
- # Returns: RESULT
- #
- # Searches WOLFSSL_DEFINITIONS for SEARCH_VALUE
- # Returns RESULT = 1 (true) if the search value is found
- #
- # Unlike set_wolfssl_definitions(), this function only queries the WOLFSSL_DEFINITIONS.
- #
- function(get_wolfssl_definitions SEARCH_VALUE RESULT)
- if (${SEARCH_VALUE} STREQUAL "")
- message(FATAL_ERROR "Function get_wolfssl_definitions cannot have blank SEARCH_VALUE")
- endif()
- list(FIND WOLFSSL_DEFINITIONS "${SEARCH_VALUE}" pos)
- string(SUBSTRING "${SEARCH_VALUE}" 0 2 PREFIX_VALUE)
- if ("${PREFIX_VALUE}" STREQUAL "-D")
- message(FATAL_ERROR "Do not specify the -D prefix in get_wolfssl_definitions")
- endif()
- if(${pos} EQUAL -1)
- message(STATUS "${SEARCH_VALUE} not found in WOLFSSL_DEFINITIONS.")
- else()
- message(STATUS "${SEARCH_VALUE} found in WOLFSSL_DEFINITIONS.")
- endif()
- endfunction()
|