Skip to content

Commit

Permalink
Zephyr: added algorithm selection
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Frauschi committed Dec 4, 2023
1 parent 65f0130 commit 2663a8e
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
56 changes: 56 additions & 0 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions zephyr/module.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: liboqs
build:
cmake: zephyr
kconfig: zephyr/Kconfig

0 comments on commit 2663a8e

Please sign in to comment.