From 2663a8eb10c1c50451fdc60509644a709ab11035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Frauenschl=C3=A4ger?= Date: Fri, 1 Dec 2023 10:19:08 +0100 Subject: [PATCH] Zephyr: added algorithm selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The algorithms can now be selected with Kconfig. Per default, we only enable the algorithms selected by NIST to be standardized. However, all supported algorithms can be enabled or disabled individually on a per project basis. Signed-off-by: Tobias Frauenschläger --- zephyr/CMakeLists.txt | 56 +++++++++++++++++++++++++++++++++++++++++++ zephyr/Kconfig | 51 +++++++++++++++++++++++++++++++++++++++ zephyr/module.yml | 1 + 3 files changed, 108 insertions(+) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index a172d7c6a4..a215dbeccd 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -25,6 +25,62 @@ if(CONFIG_LIBOQS) set(CC_SUPPORTS_WA_NOEXECSTACK OFF) set(LD_SUPPORTS_WL_Z_NOEXECSTACK OFF) + # Algorithm selection + if(CONFIG_LIBOQS_ENABLE_KEM_BIKE) + set(OQS_ENABLE_KEM_BIKE ON) + else() + set(OQS_ENABLE_KEM_BIKE OFF) + endif() + + if(CONFIG_LIBOQS_ENABLE_KEM_FRODOKEM) + set(OQS_ENABLE_KEM_FRODOKEM ON) + else() + set(OQS_ENABLE_KEM_FRODOKEM OFF) + endif() + + if(CONFIG_LIBOQS_ENABLE_KEM_NTRUPRIME) + set(OQS_ENABLE_KEM_NTRUPRIME ON) + else() + set(OQS_ENABLE_KEM_NTRUPRIME OFF) + endif() + + if(CONFIG_LIBOQS_ENABLE_KEM_CLASSIC_MCELIECE) + set(OQS_ENABLE_KEM_CLASSIC_MCELIECE ON) + else() + set(OQS_ENABLE_KEM_CLASSIC_MCELIECE OFF) + endif() + + if(CONFIG_LIBOQS_ENABLE_KEM_HQC) + set(OQS_ENABLE_KEM_HQC ON) + else() + set(OQS_ENABLE_KEM_HQC OFF) + endif() + + if(CONFIG_LIBOQS_ENABLE_KEM_KYBER) + set(OQS_ENABLE_KEM_KYBER ON) + else() + set(OQS_ENABLE_KEM_KYBER OFF) + endif() + + if(CONFIG_LIBOQS_ENABLE_SIG_DILITHIUM) + set(OQS_ENABLE_SIG_DILITHIUM ON) + else() + set(OQS_ENABLE_SIG_DILITHIUM OFF) + endif() + + if(CONFIG_LIBOQS_ENABLE_SIG_FALCON) + set(OQS_ENABLE_SIG_FALCON ON) + else() + set(OQS_ENABLE_SIG_FALCON OFF) + endif() + + if(CONFIG_LIBOQS_ENABLE_SIG_SPHINCS) + set(OQS_ENABLE_SIG_SPHINCS ON) + else() + set(OQS_ENABLE_SIG_SPHINCS OFF) + endif() + + # Add the actual liboqs targets add_subdirectory(.. build) # Add compiler options from Zephyr to all liboqs targets diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 75ab350679..71a7ad3e11 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -4,3 +4,54 @@ config LIBOQS bool "Enable liboqs" help This option enables the liboqs as a Zephyr module. + +menu "Liboqs algorithm configuration" + +config LIBOQS_ENABLE_KEM_BIKE + bool "Enable the BIKE KEM algorithm" + default n + depends on LIBOQS + help + This option enables the BIKE KEM algorithm. + +config LIBOQS_ENABLE_KEM_FRODOKEM + bool "Enable the FRODOKEM KEM algorithm" + default n + depends on LIBOQS + +config LIBOQS_ENABLE_KEM_NTRUPRIME + bool "Enable the NRTUPRIME KEM algorithm" + default n + depends on LIBOQS + +config LIBOQS_ENABLE_KEM_CLASSIC_MCELIECE + bool "Enable the CLASSIC_MCELIECE KEM algorithm" + default n + depends on LIBOQS + +config LIBOQS_ENABLE_KEM_HQC + bool "Enable the HQC KEM algorithm" + default n + depends on LIBOQS + +config LIBOQS_ENABLE_KEM_KYBER + bool "Enable the KYBER KEM algorithm" + default y + depends on LIBOQS + +config LIBOQS_ENABLE_SIG_DILITHIUM + bool "Enable the DILITHIUM signature algorithm" + default y + depends on LIBOQS + +config LIBOQS_ENABLE_SIG_FALCON + bool "Enable the FALCON signature algorithm" + default y + depends on LIBOQS + +config LIBOQS_ENABLE_SIG_SPHINCS + bool "Enable the SPHINCS signature algorithm" + default y + depends on LIBOQS + +endmenu diff --git a/zephyr/module.yml b/zephyr/module.yml index cbff6a1aef..6753ab869d 100644 --- a/zephyr/module.yml +++ b/zephyr/module.yml @@ -1,3 +1,4 @@ +name: liboqs build: cmake: zephyr kconfig: zephyr/Kconfig