2021-02-10 00:21:31 +00:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
2021-04-14 08:04:14 +01:00
|
|
|
project(cryptocore VERSION 0.0.1 LANGUAGES C)
|
2021-05-26 08:01:47 +01:00
|
|
|
include(FetchContent)
|
2021-06-19 01:11:49 +01:00
|
|
|
include(ExternalProject)
|
2021-02-10 00:21:31 +00:00
|
|
|
|
2021-06-14 21:11:07 +01:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
2021-06-14 21:16:14 +01:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
2021-06-14 21:11:07 +01:00
|
|
|
|
2021-02-10 00:21:31 +00:00
|
|
|
enable_language(C)
|
|
|
|
enable_language(CXX)
|
|
|
|
enable_language(ASM)
|
|
|
|
|
2021-06-23 08:24:04 +01:00
|
|
|
set_property(GLOBAL PROPERTY obj_libs "")
|
|
|
|
|
|
|
|
# Build with address sanitizer
|
|
|
|
if(ADDRSAN)
|
2021-07-10 00:33:09 +01:00
|
|
|
string(APPEND EXTRA_C_CXX_FLAGS " -fsanitize=undefined,address,leak -fno-omit-frame-pointer")
|
2021-06-23 08:24:04 +01:00
|
|
|
set(EXTRA_LDFLAGS " -fsanitize=undefined,address,leak")
|
|
|
|
endif()
|
|
|
|
|
2021-06-19 01:11:49 +01:00
|
|
|
if(MEMSAN)
|
|
|
|
# PQC_MEMSAN enables usage of some internals from clang
|
|
|
|
if (NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
|
|
message(FATAL_ERROR "Must use clang if compiled with memory sanitizer.")
|
|
|
|
endif()
|
|
|
|
if(ADDRSAN)
|
|
|
|
message(FATAL_ERROR "Can't use MSAN and ASAN")
|
|
|
|
endif()
|
2021-06-22 01:10:08 +01:00
|
|
|
include(.cmake/libstd-memory_sanitizer.mk)
|
2021-06-19 01:11:49 +01:00
|
|
|
|
|
|
|
# LLVM project location
|
|
|
|
set(LLVM_PRJ ${CMAKE_CURRENT_BINARY_DIR}/3rd/llvm-project)
|
|
|
|
set(LLVM_PRJ_LIB ${LLVM_PRJ}/usr/local/lib)
|
|
|
|
set(LLVM_PRJ_INC ${LLVM_PRJ}/usr/local/include)
|
|
|
|
|
|
|
|
# Add memory sanitizer instrumented libraries
|
2021-07-10 00:33:09 +01:00
|
|
|
set(CMAKE_ARGS_MEMCHECK_LIB "-stdlib=libc++ -L${LLVM_PRJ_LIB}")
|
2021-06-19 01:11:49 +01:00
|
|
|
set(CMAKE_ARGS_MEMCHECK_INC "-isystem -I${LLVM_PRJ_INC} -I${LLVM_PRJ_INC}/c++/v1")
|
2021-07-10 00:33:09 +01:00
|
|
|
set(CMAKE_ARGS_MEMCHECK_FLAGS "-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -Wno-unused-command-line-argument -fno-optimize-sibling-calls")
|
2021-06-25 09:05:54 +01:00
|
|
|
# Enablin "keep-going" flag alows two things:
|
|
|
|
# 1. Enables CT_EXPECT_UMR()/CT_REQUIRE_UMR() in tests. For some reason MSan will halt
|
|
|
|
# on error even if it expects UMR. And hence, CT can't be tested. This is probably a bug.
|
|
|
|
# 2. reports all the errors from the run, not only the first one (don't fail-fast)
|
|
|
|
string(APPEND CMAKE_ARGS_MEMCHECK_FLAGS " -mllvm -msan-keep-going=1")
|
2021-07-10 00:33:09 +01:00
|
|
|
set(EXTRA_C_CXX_FLAGS "${CMAKE_ARGS_MEMCHECK_FLAGS} ${CMAKE_ARGS_MEMCHECK_LIB} ${CMAKE_ARGS_MEMCHECK_INC} -DPQC_MEMSAN_BUILD")
|
2021-06-22 01:14:17 +01:00
|
|
|
set(CXXLIBS_FOR_MEMORY_SANITIZER cxx cxxabi)
|
2021-06-19 01:11:49 +01:00
|
|
|
endif()
|
|
|
|
|
2021-06-25 09:05:54 +01:00
|
|
|
# Contant time memory checks with CTGRIND (requires clang and -DMEMSAN)
|
|
|
|
if(CTSAN)
|
|
|
|
if (NOT MEMSAN)
|
|
|
|
message(FATAL_ERROR "Constant time sanitizer requires -DMEMSAN")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
|
|
message(FATAL_ERROR "Constant time sanitizer requires Clang")
|
|
|
|
endif()
|
|
|
|
|
2021-07-10 00:33:09 +01:00
|
|
|
string(APPEND EXTRA_C_CXX_FLAGS " -DPQC_USE_CTSANITIZER")
|
2021-06-25 09:05:54 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Contant time memory checks with CTGRIND (requires valgrind)
|
|
|
|
if (CTGRIND)
|
|
|
|
if (MEMSAN OR CTSAN)
|
|
|
|
message(FATAL_ERROR "Can't use memory sanitizer (MEMSAN) and CTGRIND")
|
|
|
|
endif()
|
2021-07-10 00:33:09 +01:00
|
|
|
string(APPEND EXTRA_C_CXX_FLAGS " -DPQC_USE_CTGRIND")
|
2021-06-25 09:05:54 +01:00
|
|
|
endif()
|
|
|
|
|
2021-02-10 00:21:31 +00:00
|
|
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "~/.cmake/Modules")
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "3rd/cmake-modules")
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
2021-03-24 10:25:45 +00:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
2021-02-10 00:21:31 +00:00
|
|
|
|
|
|
|
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
|
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
|
2021-02-17 13:38:23 +00:00
|
|
|
set(ARCH "ARCH_x86_64")
|
2021-02-10 00:21:31 +00:00
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
|
2021-02-17 13:38:23 +00:00
|
|
|
set(ARCH "ARCH_x86_64")
|
2021-02-10 00:21:31 +00:00
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
|
2021-02-17 13:38:23 +00:00
|
|
|
set(ARCH "ARCH_x86_64")
|
2021-02-10 00:21:31 +00:00
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
|
2021-02-17 13:38:23 +00:00
|
|
|
set(ARCH "ARCH_x86")
|
2021-02-10 00:21:31 +00:00
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
|
2021-02-17 13:38:23 +00:00
|
|
|
set(ARCH "ARCH_x86")
|
2021-02-10 00:21:31 +00:00
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
|
2021-02-17 13:38:23 +00:00
|
|
|
set(ARCH "ARCH_x86")
|
2021-02-10 00:21:31 +00:00
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
|
2021-02-17 13:38:23 +00:00
|
|
|
set(ARCH "ARCH_aarch64")
|
2021-02-10 00:21:31 +00:00
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
|
2021-02-17 13:38:23 +00:00
|
|
|
set(ARCH "ARCH_aarch64")
|
2021-02-10 00:21:31 +00:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Arch settings
|
|
|
|
|
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
set(MACOSX TRUE)
|
|
|
|
endif()
|
|
|
|
|
2021-09-20 17:25:51 +01:00
|
|
|
if (${PQC_NO_ASM})
|
|
|
|
set(NO_ASM TRUE)
|
|
|
|
endif()
|
|
|
|
|
2021-02-10 00:21:31 +00:00
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
2021-06-16 07:48:47 +01:00
|
|
|
# Additional flags only useful when compiling with clang
|
2021-06-23 08:24:04 +01:00
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wconditional-uninitialized -Wno-missing-variable-declarations -Wno-unused-command-line-argument")
|
2021-02-10 00:21:31 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (MACOSX)
|
|
|
|
set(CMAKE_C_COMPILER /usr/bin/cc CACHE PATH "" FORCE)
|
|
|
|
set(CMAKE_CXX_COMPILER /usr/bin/c++ CACHE PATH "" FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Global configuration
|
|
|
|
|
2021-07-10 00:33:09 +01:00
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wall")
|
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Werror")
|
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wextra")
|
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wshadow")
|
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wno-variadic-macros")
|
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wunused-result")
|
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wno-unused-command-line-argument")
|
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wno-undef")
|
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wno-ignored-qualifiers")
|
2021-06-19 01:11:49 +01:00
|
|
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 11.0)
|
2021-06-23 08:24:04 +01:00
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wno-stringop-overread \
|
2021-06-19 01:11:49 +01:00
|
|
|
-Wno-stringop-overflow \
|
|
|
|
-Wno-array-parameter")
|
|
|
|
endif()
|
2021-02-10 00:21:31 +00:00
|
|
|
|
2021-03-03 06:50:25 +00:00
|
|
|
include(.cmake/common.mk)
|
|
|
|
|
2021-02-10 00:21:31 +00:00
|
|
|
# Control Debug/Release mode
|
|
|
|
if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
|
2021-06-23 08:24:04 +01:00
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -g3 -O0 -Wno-unused")
|
2021-02-10 00:21:31 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Set CPU architecture
|
2021-06-23 08:24:04 +01:00
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -D${ARCH}")
|
2021-06-16 07:48:47 +01:00
|
|
|
|
|
|
|
# Build for haswell if on x86_64
|
|
|
|
if(${ARCH} STREQUAL "ARCH_x86_64")
|
2021-06-23 08:24:04 +01:00
|
|
|
add_compile_options("-march=haswell")
|
2021-06-16 07:48:47 +01:00
|
|
|
endif()
|
|
|
|
|
2021-06-23 08:24:04 +01:00
|
|
|
# Dependencies
|
|
|
|
ExternalProject_Add(
|
|
|
|
gtest_project
|
|
|
|
SOURCE_DIR ${PROJECT_SOURCE_DIR}/3rd/gtest
|
|
|
|
GIT_REPOSITORY https://github.com/google/googletest.git
|
|
|
|
GIT_TAG a3460d1aeeaa43fdf137a6adefef10ba0b59fe4b
|
|
|
|
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/3rd/gtest
|
|
|
|
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/3rd/gtest
|
2021-07-10 00:33:09 +01:00
|
|
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/3rd/gtest -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS=${EXTRA_C_CXX_FLAGS} -DCMAKE_C_FLAGS=${EXTRA_C_CXX_FLAGS} -Dgtest_disable_pthreads=ON
|
2021-06-23 08:24:04 +01:00
|
|
|
)
|
|
|
|
if(MEMSAN)
|
|
|
|
add_dependencies(gtest_project ${CXXLIBS_FOR_MEMORY_SANITIZER})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
FetchContent_Declare(
|
|
|
|
gbench
|
|
|
|
SOURCE_DIR ${PROJECT_SOURCE_DIR}/3rd/gbench
|
|
|
|
GIT_REPOSITORY https://github.com/kriskwiatkowski/benchmark.git
|
2022-07-05 20:58:38 +01:00
|
|
|
GIT_TAG hdc/release_crypto
|
2021-06-23 08:24:04 +01:00
|
|
|
)
|
|
|
|
FetchContent_Populate(gbench)
|
|
|
|
|
|
|
|
FetchContent_Declare(
|
|
|
|
cpu_features
|
|
|
|
SOURCE_DIR ${PROJECT_SOURCE_DIR}/3rd/cpu_features
|
|
|
|
GIT_REPOSITORY https://github.com/kriskwiatkowski/cpu_features.git
|
2021-06-25 09:05:54 +01:00
|
|
|
GIT_TAG 38f4324533390b09079a38b524be8b178be8e435
|
2021-06-23 08:24:04 +01:00
|
|
|
)
|
|
|
|
FetchContent_Populate(cpu_features)
|
2021-02-10 00:21:31 +00:00
|
|
|
|
2021-03-30 01:12:11 +01:00
|
|
|
if(PQC_WEAK_RANDOMBYTES)
|
2021-06-23 08:24:04 +01:00
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -DPQC_WEAK_RANDOMBYTES")
|
2021-03-30 01:12:11 +01:00
|
|
|
endif()
|
|
|
|
|
2021-06-23 08:24:04 +01:00
|
|
|
# Build CPU features
|
2021-07-10 00:33:09 +01:00
|
|
|
set(CMAKE_C_FLAGS "${PQC_CMAKE_C_CXX_FLAGS} ${EXTRA_C_CXX_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS "$${PQC_CMAKE_C_CXX_FLAGS} {EXTRA_C_CXX_FLAGS}")
|
2021-06-23 08:24:04 +01:00
|
|
|
set(BUILD_PIC ON CACHE BOOL "")
|
|
|
|
add_subdirectory(3rd/cpu_features)
|
|
|
|
|
|
|
|
# PQC library
|
|
|
|
|
|
|
|
# Set C, CXX, and LD flags
|
2021-06-25 09:05:54 +01:00
|
|
|
string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wpedantic")
|
2021-07-10 00:33:09 +01:00
|
|
|
set(CMAKE_C_FLAGS "${PQC_CMAKE_C_CXX_FLAGS} ${EXTRA_C_CXX_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${PQC_CMAKE_C_CXX_FLAGS} ${EXTRA_C_CXX_FLAGS}")
|
2021-06-23 08:24:04 +01:00
|
|
|
string(APPEND LDFLAGS "${EXTRA_LDFLAGS}")
|
|
|
|
include_directories(
|
|
|
|
public
|
|
|
|
src/common/
|
|
|
|
src
|
|
|
|
3rd/cpu_features/include
|
|
|
|
)
|
|
|
|
|
2021-02-17 13:38:23 +00:00
|
|
|
# Define sources of the components
|
2021-03-03 06:50:25 +00:00
|
|
|
add_subdirectory(src/sign/dilithium/dilithium2/clean)
|
|
|
|
add_subdirectory(src/sign/dilithium/dilithium3/clean)
|
|
|
|
add_subdirectory(src/sign/dilithium/dilithium5/clean)
|
2021-05-25 08:20:31 +01:00
|
|
|
add_subdirectory(src/sign/falcon)
|
2021-03-03 06:50:25 +00:00
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-192f-simple/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-256f-simple/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-192f-robust/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-128f-simple/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-256s-simple/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-128s-simple/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-128f-robust/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-192s-robust/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-128f-robust/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-128s-robust/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-256s-robust/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-192s-simple/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-192s-simple/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-192s-robust/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-192f-simple/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-simple/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-128s-simple/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-256f-robust/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-robust/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-simple/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-robust/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-128s-robust/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-128f-simple/clean)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-192f-robust/clean)
|
2021-03-24 10:25:45 +00:00
|
|
|
|
2021-03-23 09:25:18 +00:00
|
|
|
add_subdirectory(src/kem/kyber/kyber512/clean)
|
|
|
|
add_subdirectory(src/kem/kyber/kyber768/clean)
|
|
|
|
add_subdirectory(src/kem/kyber/kyber1024/clean)
|
2021-03-27 00:34:03 +00:00
|
|
|
add_subdirectory(src/kem/hqc/hqc-rmrs-128/clean)
|
|
|
|
add_subdirectory(src/kem/hqc/hqc-rmrs-192/clean)
|
|
|
|
add_subdirectory(src/kem/hqc/hqc-rmrs-256/clean)
|
2021-04-06 23:41:01 +01:00
|
|
|
add_subdirectory(src/kem/sike)
|
2021-05-26 13:09:25 +01:00
|
|
|
add_subdirectory(src/kem/mceliece/mceliece348864/clean)
|
|
|
|
add_subdirectory(src/kem/mceliece/mceliece460896/clean)
|
|
|
|
add_subdirectory(src/kem/mceliece/mceliece6688128/clean)
|
|
|
|
add_subdirectory(src/kem/mceliece/mceliece6960119/clean)
|
|
|
|
add_subdirectory(src/kem/mceliece/mceliece8192128/clean)
|
|
|
|
add_subdirectory(src/kem/mceliece/mceliece348864f/clean)
|
|
|
|
add_subdirectory(src/kem/mceliece/mceliece460896f/clean)
|
|
|
|
add_subdirectory(src/kem/mceliece/mceliece6688128f/clean)
|
|
|
|
add_subdirectory(src/kem/mceliece/mceliece6960119f/clean)
|
|
|
|
add_subdirectory(src/kem/mceliece/mceliece8192128f/clean)
|
2021-03-23 09:25:18 +00:00
|
|
|
# Hardware optimized targets
|
|
|
|
|
2021-06-16 07:48:47 +01:00
|
|
|
if(${ARCH} STREQUAL "ARCH_x86_64")
|
2021-06-23 08:24:04 +01:00
|
|
|
set(COMMON_EXTRA_SRC "src/common/keccak4x/KeccakP-1600-times4-SIMD256.c")
|
2021-03-23 09:25:18 +00:00
|
|
|
|
|
|
|
# Sign
|
2021-03-03 06:50:25 +00:00
|
|
|
add_subdirectory(src/sign/dilithium/dilithium2/avx2)
|
|
|
|
add_subdirectory(src/sign/dilithium/dilithium3/avx2)
|
|
|
|
add_subdirectory(src/sign/dilithium/dilithium5/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-128s-simple/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-128f-robust/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-128s-robust/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-128f-simple/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-192s-simple/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-192f-robust/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-192s-robust/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-192f-simple/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-256f-robust/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-256f-simple/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-256s-simple/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-shake256-256s-robust/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-128f-robust/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-128s-simple/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-128s-robust/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-128f-simple/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-192s-simple/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-192f-simple/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-192s-robust/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-192f-robust/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-simple/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-robust/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-simple/avx2)
|
|
|
|
add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-robust/avx2)
|
2021-03-23 09:25:18 +00:00
|
|
|
# KEMs
|
2021-03-03 06:50:25 +00:00
|
|
|
add_subdirectory(src/kem/kyber/kyber512/avx2)
|
|
|
|
add_subdirectory(src/kem/kyber/kyber768/avx2)
|
|
|
|
add_subdirectory(src/kem/kyber/kyber1024/avx2)
|
2021-03-27 00:34:03 +00:00
|
|
|
add_subdirectory(src/kem/hqc/hqc-rmrs-128/avx2)
|
|
|
|
add_subdirectory(src/kem/hqc/hqc-rmrs-192/avx2)
|
|
|
|
add_subdirectory(src/kem/hqc/hqc-rmrs-256/avx2)
|
2021-02-17 13:38:23 +00:00
|
|
|
endif()
|
|
|
|
|
2021-03-23 09:25:18 +00:00
|
|
|
# The rest of the library
|
2021-06-23 08:24:04 +01:00
|
|
|
add_library(
|
|
|
|
common
|
|
|
|
OBJECT
|
|
|
|
|
2021-03-23 09:25:18 +00:00
|
|
|
src/common/aes.c
|
|
|
|
src/common/fips202.c
|
|
|
|
src/common/sp800-185.c
|
|
|
|
src/common/randombytes.c
|
|
|
|
src/common/sha2.c
|
2021-03-27 00:34:03 +00:00
|
|
|
src/common/nistseedexpander.c
|
2021-07-10 00:33:09 +01:00
|
|
|
src/common/utils.c
|
2021-03-23 09:25:18 +00:00
|
|
|
src/capi/pqapi.c
|
2021-06-23 08:24:04 +01:00
|
|
|
${COMMON_EXTRA_SRC})
|
2021-02-17 13:38:23 +00:00
|
|
|
|
2021-02-17 12:40:38 +00:00
|
|
|
add_library(
|
2021-03-25 00:59:41 +00:00
|
|
|
pqc
|
2021-02-17 12:40:38 +00:00
|
|
|
SHARED
|
|
|
|
)
|
2021-02-10 00:21:31 +00:00
|
|
|
|
2021-02-17 12:40:38 +00:00
|
|
|
add_library(
|
2021-03-25 00:59:41 +00:00
|
|
|
pqc_s
|
2021-02-17 12:40:38 +00:00
|
|
|
STATIC
|
2021-02-10 00:21:31 +00:00
|
|
|
)
|
2021-03-24 10:25:45 +00:00
|
|
|
get_property(OBJ_LIBS GLOBAL PROPERTY obj_libs)
|
2021-02-10 00:21:31 +00:00
|
|
|
|
2021-02-17 12:40:38 +00:00
|
|
|
target_link_libraries(
|
2021-03-25 00:59:41 +00:00
|
|
|
pqc
|
2021-04-14 08:04:14 +01:00
|
|
|
|
2021-03-24 10:25:45 +00:00
|
|
|
${OBJ_LIBS}
|
2021-04-14 08:04:14 +01:00
|
|
|
cpu_features
|
|
|
|
common
|
2021-02-10 00:21:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(
|
2021-03-25 00:59:41 +00:00
|
|
|
pqc_s
|
2021-04-14 08:04:14 +01:00
|
|
|
|
|
|
|
cpu_features
|
2021-02-17 12:40:38 +00:00
|
|
|
common
|
2021-03-24 10:25:45 +00:00
|
|
|
${OBJ_LIBS}
|
2021-02-10 00:21:31 +00:00
|
|
|
)
|
2021-03-23 09:31:12 +00:00
|
|
|
|
2021-06-16 07:48:47 +01:00
|
|
|
SET(UT_SRC test/ut.cpp)
|
2021-06-25 09:05:54 +01:00
|
|
|
if(CTGRIND OR CTSAN)
|
2021-06-16 07:48:47 +01:00
|
|
|
SET(UT_SRC ${UT_SRC} test/ct.cpp)
|
|
|
|
endif()
|
|
|
|
|
2021-03-23 09:31:12 +00:00
|
|
|
add_executable(
|
2021-03-24 10:25:45 +00:00
|
|
|
ut
|
2021-06-16 07:48:47 +01:00
|
|
|
${UT_SRC}
|
2021-03-23 09:31:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(
|
2021-03-24 10:25:45 +00:00
|
|
|
ut
|
2021-06-19 01:11:49 +01:00
|
|
|
|
2021-03-23 09:31:12 +00:00
|
|
|
gtest
|
2021-03-24 10:25:45 +00:00
|
|
|
gtest_main
|
2021-06-22 01:14:17 +01:00
|
|
|
pqc_s
|
|
|
|
${CXXLIBS_FOR_MEMORY_SANITIZER})
|
2021-03-23 09:31:12 +00:00
|
|
|
|
2021-06-19 01:11:49 +01:00
|
|
|
ExternalProject_Get_Property(gtest_project INSTALL_DIR)
|
2021-03-23 09:31:12 +00:00
|
|
|
target_include_directories(
|
2021-03-24 10:25:45 +00:00
|
|
|
ut PRIVATE
|
2021-06-19 01:11:49 +01:00
|
|
|
|
|
|
|
${CMAKE_SOURCE_DIR}
|
|
|
|
${INSTALL_DIR}/include)
|
|
|
|
|
|
|
|
target_link_directories(
|
|
|
|
ut
|
|
|
|
PRIVATE
|
|
|
|
${INSTALL_DIR}/lib)
|
|
|
|
|
|
|
|
# github CI requires that
|
|
|
|
add_dependencies(ut gtest_project)
|
2021-03-23 09:31:12 +00:00
|
|
|
|
2021-07-10 00:33:09 +01:00
|
|
|
|
2022-02-03 09:02:08 +00:00
|
|
|
# settings below are required by benchmark library
|
|
|
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
|
|
|
|
# Target for benchmark - it also builds gtest library
|
|
|
|
set(BENCHMARK_ENABLE_GTEST_TESTS ON CACHE BOOL "Enable testing of the benchmark library." FORCE)
|
|
|
|
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable benchmark tests" FORCE)
|
|
|
|
set(GOOGLETEST_PATH "${CMAKE_SOURCE_DIR}/3rd/gtest" CACHE PATH "Path to the gtest sources" FORCE)
|
|
|
|
#if (NOT MACOSX)
|
|
|
|
# set(BENCHMARK_ENABLE_LTO ON CACHE BOOL "Enable link time optim" FORCE)
|
|
|
|
#endif()
|
|
|
|
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
|
|
|
|
set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "" FORCE)
|
|
|
|
set(CMAKE_C_FLAGS "${EXTRA_C_CXX_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${EXTRA_C_CXX_FLAGS}")
|
|
|
|
if (MEMSAN)
|
|
|
|
set(BENCHMARK_USE_LIBCXX ON CACHE BOOL "" FORCE)
|
|
|
|
# Since build requires C++20 it is safe to assume that std::regex is available.
|
|
|
|
# It seems I need to force it as benchmark build doesn't work very well with libc++
|
|
|
|
set(HAVE_STD_REGEX ON CACHE BOOL "OK" FORCE)
|
2021-04-22 21:41:40 +01:00
|
|
|
endif()
|
2021-03-23 09:31:12 +00:00
|
|
|
|
2022-02-03 09:02:08 +00:00
|
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/3rd/gbench)
|
|
|
|
add_subdirectory(test/bench)
|
|
|
|
|
2021-03-25 00:59:41 +00:00
|
|
|
install(TARGETS pqc pqc_s
|
2021-03-23 09:31:12 +00:00
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib)
|
|
|
|
install(FILES
|
|
|
|
${QRS_PUBLIC_INC}
|
2021-03-25 00:59:41 +00:00
|
|
|
DESTINATION include/pqc)
|