From d9fb4e0e81ccd0a0972b38743404d982fe0a90c1 Mon Sep 17 00:00:00 2001 From: John Schanck Date: Thu, 24 Jun 2021 20:57:34 -0400 Subject: [PATCH] Add OQS_PERMIT_UNSUPPORTED_ARCHITECTURE flag (#1021) * Add OQS_PERMIT_UNSUPPORTED_ARCHITECTURE flag * Add warning for unsupported architecture Co-authored-by: Douglas Stebila --- CMakeLists.txt | 6 +++++- src/common/common.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c09671c6c..ee7b285d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ project(liboqs C ASM) option(OQS_DIST_BUILD "Build distributable library with optimized code for several CPU microarchitectures. Enables run-time CPU feature detection." OFF) option(OQS_BUILD_ONLY_LIB "Build only liboqs and do not expose build targets for tests, documentation, and pretty-printing available." OFF) option(OQS_MINIMAL_BUILD "Only build the default KEM and Signature schemes." OFF) +option(OQS_PERMIT_UNSUPPORTED_ARCHITECTURE "Permit compilation on an an unsupported architecture." OFF) set(OQS_OPT_TARGET auto CACHE STRING "The target microarchitecture for optimization.") @@ -46,8 +47,11 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armel|armhf|armv7|arm32v7") if(${OQS_DIST_BUILD}) set(OQS_DIST_ARM32v7_BUILD ON) endif() +elseif(OQS_PERMIT_UNSUPPORTED_ARCHITECTURE) + message(WARNING "Unknown or unsupported processor: " ${CMAKE_SYSTEM_PROCESSOR}) + message(WARNING "Compilation on an unsupported processor should only be used for testing, as it may result an insecure configuration, for example due to variable-time instructions leaking secret information.") else() - message(FATAL_ERROR "Unknown or unsupported processor: " ${CMAKE_SYSTEM_PROCESSOR}) + message(FATAL_ERROR "Unknown or unsupported processor: " ${CMAKE_SYSTEM_PROCESSOR} ". Override by setting OQS_PERMIT_UNSUPPORTED_ARCHITECTURE=ON") endif() # intentionally don't switch to variables to avoid --warn-uninitialized report diff --git a/src/common/common.c b/src/common/common.c index e50f62ff4..fa4a991a3 100644 --- a/src/common/common.c +++ b/src/common/common.c @@ -103,6 +103,9 @@ static void set_available_cpu_extensions(void) { cpu_ext_data[OQS_CPU_EXT_ARM_NEON] = 1; } } +#elif defined(OQS_DIST_BUILD) +static void set_available_cpu_extensions(void) { +} #endif OQS_API int OQS_CPU_has_extension(OQS_CPU_EXT ext) {