Skip to content

Commit af40171

Browse files
committed
LMS fixes
* Add support for CMake * Add support for Zephyr * Make sure the internal key state is properly handled in case a public key is imported into a reloaded private key. Signed-off-by: Tobias Frauenschläger <tobias.frauenschlaeger@oth-regensburg.de>
1 parent 9db5499 commit af40171

5 files changed

Lines changed: 38 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,16 @@ else()
655655
endif()
656656
endif()
657657

658+
# LMS
659+
add_option(WOLFSSL_LMS
660+
"Enable the wolfSSL LMS implementation (default: disabled)"
661+
"no" "yes;no")
662+
663+
# XMSS
664+
add_option(WOLFSSL_XMSS
665+
"Enable the wolfSSL XMSS implementation (default: disabled)"
666+
"no" "yes;no")
667+
658668
# TODO: - Lean PSK
659669
# - Lean TLS
660670
# - Low resource
@@ -668,8 +678,6 @@ endif()
668678
# - Atomic user record layer
669679
# - Public key callbacks
670680
# - Microchip/Atmel CryptoAuthLib
671-
# - XMSS
672-
# - LMS
673681
# - dual-certs
674682

675683
# AES-CBC

cmake/functions.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ function(generate_build_flags)
208208
set(BUILD_EXT_KYBER "yes" PARENT_SCOPE)
209209
set(BUILD_OQS_HELPER "yes" PARENT_SCOPE)
210210
endif()
211+
if(WOLFSSL_LMS OR WOLFSSL_USER_SETTINGS)
212+
set(BUILD_WC_LMS "yes" PARENT_SCOPE)
213+
endif()
214+
if(WOLFSSL_XMSS OR WOLFSSL_USER_SETTINGS)
215+
set(BUILD_WC_XMSS "yes" PARENT_SCOPE)
216+
endif()
211217
if(WOLFSSL_ARIA OR WOLFSSL_USER_SETTINGS)
212218
message(STATUS "ARIA functions.cmake found WOLFSSL_ARIA")
213219
# we cannot actually build, as we only have pre-compiled bin
@@ -818,6 +824,16 @@ function(generate_lib_src_list LIB_SOURCES)
818824
list(APPEND LIB_SOURCES wolfcrypt/src/ext_kyber.c)
819825
endif()
820826

827+
if(BUILD_WC_LMS)
828+
list(APPEND LIB_SOURCES wolfcrypt/src/wc_lms.c)
829+
list(APPEND LIB_SOURCES wolfcrypt/src/wc_lms_impl.c)
830+
endif()
831+
832+
if(BUILD_WC_XMSS)
833+
list(APPEND LIB_SOURCES wolfcrypt/src/wc_xmss.c)
834+
list(APPEND LIB_SOURCES wolfcrypt/src/wc_xmss_impl.c)
835+
endif()
836+
821837
if(BUILD_LIBZ)
822838
list(APPEND LIB_SOURCES wolfcrypt/src/compress.c)
823839
endif()

cmake/options.h.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,14 @@ extern "C" {
382382
#cmakedefine HAVE_ECC_KOBLITZ
383383
#undef HAVE_ECC_CDH
384384
#cmakedefine HAVE_ECC_CDH
385+
#undef WOLFSSL_HAVE_LMS
386+
#cmakedefine WOLFSSL_HAVE_LMS
387+
#undef WOLFSSL_WC_LMS
388+
#cmakedefine WOLFSSL_WC_LMS
389+
#undef WOLFSSL_HAVE_XMSS
390+
#cmakedefine WOLFSSL_HAVE_XMSS
391+
#undef WOLFSSL_WC_XMSS
392+
#cmakedefine WOLFSSL_WC_XMSS
385393

386394
#ifdef __cplusplus
387395
}

wolfcrypt/src/wc_lms.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,8 @@ int wc_LmsKey_ImportPubRaw(LmsKey* key, const byte* in, word32 inLen)
11621162
if (ret == 0) {
11631163
XMEMCPY(key->pub, in, inLen);
11641164

1165-
key->state = WC_LMS_STATE_VERIFYONLY;
1165+
if (key->state != WC_LMS_STATE_OK)
1166+
key->state = WC_LMS_STATE_VERIFYONLY;
11661167
}
11671168

11681169
return ret;

zephyr/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ if(CONFIG_WOLFSSL)
119119
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_encrypt.c)
120120
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_kyber.c)
121121
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_kyber_poly.c)
122+
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_lms.c)
123+
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_lms_impl.c)
122124
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_pkcs11.c)
123125
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wc_port.c)
124126
zephyr_library_sources(${ZEPHYR_CURRENT_MODULE_DIR}/wolfcrypt/src/wolfevent.c)

0 commit comments

Comments
 (0)