Skip to content

Commit 67bef21

Browse files
committed
Add LMS/HSS wolfCrypt hooks.
1 parent 794425c commit 67bef21

12 files changed

Lines changed: 1554 additions & 1 deletion

File tree

INSTALL

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,43 @@
254254
The wolfssl port in vcpkg is kept up to date by wolfSSL.
255255

256256
We also have vcpkg ports for wolftpm, wolfmqtt and curl.
257+
258+
17. Building with hash-sigs lib for LMS/HSS support [EXPERIMENTAL]
259+
260+
Using LMS/HSS requires that the hash-sigs lib has been built on
261+
your system. At present we support the current master branch of
262+
the hash-sigs project.
263+
264+
At present the hash-sigs project only builds static libraries.
265+
It can be modified though to build and install a shared library
266+
in /usr/local.
267+
268+
wolfSSL supports either option, and by default will look for
269+
hss_lib_thread.a in a specified hash-sigs dir. If hash-sigs has
270+
been built as a shared lib and installed in /usr/local/ , then
271+
wolfSSL will look for libhss.so there.
272+
273+
How to get and build the hash-sigs library:
274+
$ mkdir ~/hash_sigs
275+
$ cd ~/hash_sigs
276+
$ git clone https://github.com/cisco/hash-sigs.git src
277+
$ cd src
278+
279+
In sha256.h, set USE_OPENSSl to 0:
280+
#define USE_OPENSSL 0
281+
282+
Now build:
283+
$ make
284+
$ ls *.a
285+
hss_lib.a hss_lib_thread.a hss_verify.a
286+
287+
Build wolfSSL with
288+
$ ./configure \
289+
--enable-static \
290+
--disable-shared \
291+
--enable-lms=yes \
292+
--with-liblms=<path to dir containing hss_lib_thread.a>
293+
$ make
294+
295+
Run the benchmark against LMS/HSS with:
296+
$ ./wolfcrypt/benchmark/benchmark -lms_hss

configure.ac

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,100 @@ then
11411141
fi
11421142

11431143

1144+
# liblms
1145+
# Get the path to the hash-sigs LMS HSS lib.
1146+
ENABLED_LIBLMS="no"
1147+
tryliblmsdir=""
1148+
AC_ARG_WITH([liblms],
1149+
[AS_HELP_STRING([--with-liblms=PATH],[PATH to hash-sigs LMS/HSS install (default /usr/local) EXPERIMENTAL!])],
1150+
[
1151+
AC_MSG_CHECKING([for liblms])
1152+
1153+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <hss.h>]], [[ param_set_t lm_type; param_set_t lm_ots_type; hss_get_public_key_len(4, &lm_type, &lm_ots_type); ]])], [ liblms_linked=yes ],[ liblms_linked=no ])
1154+
1155+
if test "x$liblms_linked" = "xno" ; then
1156+
if test "x$withval" != "xno" ; then
1157+
tryliblmsdir=$withval
1158+
fi
1159+
if test "x$withval" = "xyes" ; then
1160+
tryliblmsdir="/usr/local"
1161+
fi
1162+
1163+
if test -e $tryliblmsdir/hss_lib_thread.a; then
1164+
CPPFLAGS="$AM_CPPFLAGS -DHAVE_LIBLMS -I$tryliblmsdir"
1165+
LIB_STATIC_ADD="$LIB_STATIC_ADD $tryliblmsdir/hss_lib_thread.a"
1166+
enable_shared=no
1167+
enable_static=yes
1168+
liblms_linked=yes
1169+
elif test -e $tryliblmsdir/lib/libhss.so; then
1170+
LIBS="$LIBS -lhss"
1171+
CPPFLAGS="$AM_CPPFLAGS -DHAVE_LIBLMS -I$tryliblmsdir/include/hss"
1172+
LDFLAGS="$AM_LDFLAGS $LDFLAGS -L$tryliblmsdir/lib"
1173+
1174+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <hss.h>]], [[ param_set_t lm_type; param_set_t lm_ots_type; hss_get_public_key_len(4, &lm_type, &lm_ots_type); ]])], [ liblms_linked=yes ],[ liblms_linked=no ])
1175+
else
1176+
AC_MSG_ERROR([liblms isn't found.
1177+
If it's already installed, specify its path using --with-liblms=/dir/])
1178+
fi
1179+
1180+
if test "x$liblms_linked" = "xno" ; then
1181+
AC_MSG_ERROR([liblms isn't found.
1182+
If it's already installed, specify its path using --with-liblms=/dir/])
1183+
fi
1184+
1185+
AC_MSG_RESULT([yes])
1186+
AM_CPPFLAGS="$CPPFLAGS"
1187+
AM_LDFLAGS="$LDFLAGS"
1188+
else
1189+
AC_MSG_RESULT([yes])
1190+
fi
1191+
1192+
AM_CFLAGS="$AM_CFLAGS -DHAVE_LIBLMS"
1193+
ENABLED_LIBLMS="yes"
1194+
]
1195+
)
1196+
1197+
1198+
# LMS
1199+
AC_ARG_ENABLE([lms],
1200+
[AS_HELP_STRING([--enable-lms],[Enable stateful LMS/HSS signatures (default: disabled)])],
1201+
[ ENABLED_LMS=$enableval ],
1202+
[ ENABLED_LMS=no ]
1203+
)
1204+
1205+
ENABLED_WC_LMS=no
1206+
for v in `echo $ENABLED_LMS | tr "," " "`
1207+
do
1208+
case $v in
1209+
yes)
1210+
;;
1211+
no)
1212+
;;
1213+
wolfssl)
1214+
ENABLED_WC_LMS=yes
1215+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_WC_LMS"
1216+
;;
1217+
*)
1218+
AC_MSG_ERROR([Invalid choice for LMS []: $ENABLED_LMS.])
1219+
break;;
1220+
esac
1221+
done
1222+
1223+
if test "$ENABLED_LMS" != "no"
1224+
then
1225+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_LMS"
1226+
1227+
if test "$ENABLED_WC_LMS" = "no";
1228+
then
1229+
# Default is to use hash-sigs LMS lib. Make sure it's enabled.
1230+
if test "$ENABLED_LIBLMS" = "no"; then
1231+
AC_MSG_ERROR([The default implementation for LMS is the hash-sigs LMS/HSS lib.
1232+
Please use --with-liblms.])
1233+
fi
1234+
fi
1235+
fi
1236+
1237+
11441238
# SINGLE THREADED
11451239
AC_ARG_ENABLE([singlethreaded],
11461240
[AS_HELP_STRING([--enable-singlethreaded],[Enable wolfSSL single threaded (default: disabled)])],
@@ -8665,6 +8759,7 @@ AM_CONDITIONAL([BUILD_FE448], [test "x$ENABLED_FE448" = "xyes" || test "x$ENABLE
86658759
AM_CONDITIONAL([BUILD_GE448], [test "x$ENABLED_GE448" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
86668760
AM_CONDITIONAL([BUILD_CURVE448],[test "x$ENABLED_CURVE448" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
86678761
AM_CONDITIONAL([BUILD_CURVE448_SMALL],[test "x$ENABLED_CURVE448_SMALL" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
8762+
AM_CONDITIONAL([BUILD_WC_LMS],[test "x$ENABLED_WC_LMS" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
86688763
AM_CONDITIONAL([BUILD_WC_KYBER],[test "x$ENABLED_WC_KYBER" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
86698764
AM_CONDITIONAL([BUILD_ECCSI],[test "x$ENABLED_ECCSI" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
86708765
AM_CONDITIONAL([BUILD_SAKKE],[test "x$ENABLED_SAKKE" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
@@ -8704,6 +8799,7 @@ AM_CONDITIONAL([BUILD_CRL],[test "x$ENABLED_CRL" != "xno" || test "x$ENABLED_USE
87048799
AM_CONDITIONAL([BUILD_CRL_MONITOR],[test "x$ENABLED_CRL_MONITOR" = "xyes"])
87058800
AM_CONDITIONAL([BUILD_USER_RSA],[test "x$ENABLED_USER_RSA" = "xyes"] )
87068801
AM_CONDITIONAL([BUILD_USER_CRYPTO],[test "x$ENABLED_USER_CRYPTO" = "xyes"])
8802+
AM_CONDITIONAL([BUILD_LIBLMS],[test "x$ENABLED_LIBLMS" = "xyes"])
87078803
AM_CONDITIONAL([BUILD_LIBOQS],[test "x$ENABLED_LIBOQS" = "xyes"])
87088804
AM_CONDITIONAL([BUILD_WNR],[test "x$ENABLED_WNR" = "xyes"])
87098805
AM_CONDITIONAL([BUILD_SRP],[test "x$ENABLED_SRP" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
@@ -9150,6 +9246,8 @@ echo " * ED25519 streaming: $ENABLED_ED25519_STREAM"
91509246
echo " * CURVE448: $ENABLED_CURVE448"
91519247
echo " * ED448: $ENABLED_ED448"
91529248
echo " * ED448 streaming: $ENABLED_ED448_STREAM"
9249+
echo " * LMS: $ENABLED_LMS"
9250+
echo " * LMS wolfSSL impl: $ENABLED_WC_LMS"
91539251
echo " * KYBER: $ENABLED_KYBER"
91549252
echo " * KYBER wolfSSL impl: $ENABLED_WC_KYBER"
91559253
echo " * ECCSI $ENABLED_ECCSI"
@@ -9204,6 +9302,7 @@ echo " * Persistent session cache: $ENABLED_SAVESESSION"
92049302
echo " * Persistent cert cache: $ENABLED_SAVECERT"
92059303
echo " * Atomic User Record Layer: $ENABLED_ATOMICUSER"
92069304
echo " * Public Key Callbacks: $ENABLED_PKCALLBACKS"
9305+
echo " * liblms: $ENABLED_LIBLMS"
92079306
echo " * liboqs: $ENABLED_LIBOQS"
92089307
echo " * Whitewood netRandom: $ENABLED_WNR"
92099308
echo " * Server Name Indication: $ENABLED_SNI"

src/include.am

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,10 @@ endif
654654
endif
655655
endif
656656

657+
if BUILD_WC_LMS
658+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_lms.c
659+
endif
660+
657661
if BUILD_CURVE25519
658662
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/curve25519.c
659663
endif
@@ -733,6 +737,10 @@ src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/sphincs.c
733737
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/ext_kyber.c
734738
endif
735739

740+
if BUILD_LIBLMS
741+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/ext_lms.c
742+
endif
743+
736744
if BUILD_LIBZ
737745
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/compress.c
738746
endif

0 commit comments

Comments
 (0)