From 388eaa5b76963df2137f941c5b1a8606049a3801 Mon Sep 17 00:00:00 2001 From: Kris Kwiatkowski Date: Mon, 20 Sep 2021 17:25:51 +0100 Subject: [PATCH] PQC_NO_ASM: disable assembly optimized implementations --- CMakeLists.txt | 4 ++++ src/capi/pqapi.c | 2 ++ src/kem/sike/CMakeLists.txt | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9b3def1..7d5dc74a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,10 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(MACOSX TRUE) endif() +if (${PQC_NO_ASM}) + set(NO_ASM TRUE) +endif() + if(CMAKE_C_COMPILER_ID MATCHES "Clang") # Additional flags only useful when compiling with clang string(APPEND PQC_CMAKE_C_CXX_FLAGS " -Wconditional-uninitialized -Wno-missing-variable-declarations -Wno-unused-command-line-argument") diff --git a/src/capi/pqapi.c b/src/capi/pqapi.c index 11189a1b..c0d0fc90 100644 --- a/src/capi/pqapi.c +++ b/src/capi/pqapi.c @@ -148,5 +148,7 @@ uint32_t pqc_private_key_bsz(const pqc_ctx_t *p) { void static_initialization(void) __attribute__((constructor)); void static_initialization(void) { +#ifdef PQC_ASM CPU_CAPS = GetX86Info().features; +#endif } diff --git a/src/kem/sike/CMakeLists.txt b/src/kem/sike/CMakeLists.txt index f5543d67..bd736a75 100644 --- a/src/kem/sike/CMakeLists.txt +++ b/src/kem/sike/CMakeLists.txt @@ -6,7 +6,7 @@ set( p434/params.c p434/sike.c) -if(${ARCH} STREQUAL "ARCH_x86_64") +if(${ARCH} STREQUAL "ARCH_x86_64" AND NOT ${NO_ASM}) add_definitions(-DPQC_ASM=1) set( SRC_CLEAN_SIKE_P434