Skip to content

Commit

Permalink
WolfSSL Kyber fixes
Browse files Browse the repository at this point in the history
* Make sure wc_kyber implementation is compiled using CMake (also for
  Zephyr)
* Fix compilation issue when Liboqs is also enabled

Signed-off-by: Tobias Frauenschläger
<[email protected]>
  • Loading branch information
Frauschi committed Jul 23, 2024
1 parent a9ff773 commit f89e229
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ function(generate_build_flags)
if(WOLFSSL_XCHACHA OR WOLFSSL_USER_SETTINGS)
set(BUILD_XCHACHA "yes" PARENT_SCOPE)
endif()
if(WOLFSSL_KYBER OR WOLFSSL_USER_SETTINGS)
set(BUILD_WC_KYBER "yes" PARENT_SCOPE)
endif()
if(WOLFSSL_OQS OR WOLFSSL_USER_SETTINGS)
set(BUILD_FALCON "yes" PARENT_SCOPE)
set(BUILD_SPHINCS "yes" PARENT_SCOPE)
Expand Down Expand Up @@ -794,6 +797,15 @@ function(generate_lib_src_list LIB_SOURCES)
list(APPEND LIB_SOURCES wolfcrypt/src/dilithium.c)
endif()

if(BUILD_WC_KYBER)
list(APPEND LIB_SOURCES wolfcrypt/src/wc_kyber.c)
list(APPEND LIB_SOURCES wolfcrypt/src/wc_kyber_poly.c)

if(BUILD_INTEL_ASM)
list(APPEND LIB_SOURCES wolfcrypt/src/wc_kyber_asm.S)
endif()
endif()

if(BUILD_EXT_KYBER)
list(APPEND LIB_SOURCES wolfcrypt/src/ext_kyber.c)
endif()
Expand Down
4 changes: 2 additions & 2 deletions wolfcrypt/src/ext_kyber.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/logging.h>

#ifdef WOLFSSL_HAVE_KYBER
#if defined(WOLFSSL_HAVE_KYBER) && !defined(WOLFSSL_WC_KYBER)
#include <wolfssl/wolfcrypt/ext_kyber.h>

#ifdef NO_INLINE
Expand Down Expand Up @@ -750,4 +750,4 @@ int wc_KyberKey_EncodePublicKey(KyberKey* key, unsigned char* out, word32 len)
return ret;
}

#endif /* WOLFSSL_HAVE_KYBER */
#endif /* WOLFSSL_HAVE_KYBER && !WOLFSSL_WC_KYBER */
2 changes: 2 additions & 0 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ if(CONFIG_WOLFSSL)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/tfm.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_dsp.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_encrypt.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_kyber.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_kyber_poly.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_pkcs11.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_port.c)
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wolfevent.c)
Expand Down

0 comments on commit f89e229

Please sign in to comment.