Skip to content

Commit 33d4b33

Browse files
committed
Add XMSS/XMSSMT wolfCrypt hooks.
1 parent 96205fc commit 33d4b33

12 files changed

Lines changed: 2288 additions & 29 deletions

File tree

INSTALL

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ We also have vcpkg ports for wolftpm, wolfmqtt and curl.
371371
resulting packages are placed in the root directory of the
372372
project.
373373

374-
18. Building for RHEL, Fedora, CentOS, SUSE, and openSUSE
374+
19. Building for RHEL, Fedora, CentOS, SUSE, and openSUSE
375375

376376
To generate a .rpm package, configure wolfSSL with the desired
377377
configuration. Then run `make rpm` to generate a .rpm package
@@ -380,3 +380,44 @@ We also have vcpkg ports for wolftpm, wolfmqtt and curl.
380380
resulting packages are placed in the root directory of the
381381
project.
382382

383+
20. Building with xmss-reference lib for XMSS/XMSS^MT support [EXPERIMENTAL]
384+
385+
Experimental support for XMSS/XMSS^MT has been achieved by integration
386+
with the xmss-reference implementation from RFC 8391 (XMSS: eXtended
387+
Merkle Signature Scheme). We support a patched version of xmss-reference
388+
based on this git commit:
389+
171ccbd26f098542a67eb5d2b128281c80bd71a6
390+
At the time of writing this, this is the HEAD of the master branch of
391+
the xmss-reference project.
392+
393+
How to get the xmss-reference library:
394+
$ mkdir ~/xmss
395+
$ cd ~/xmss
396+
$ git clone https://github.com/XMSS/xmss-reference.git src
397+
$ cd src
398+
$ git checkout 171ccbd26f098542a67eb5d2b128281c80bd71a6
399+
$ git apply <path to xmss reference patch>
400+
401+
The patch may be found in the wolfssl-examples repo here:
402+
pq/stateful_hash_sig/0001-Patch-to-support-xmss-reference-integration.patch
403+
404+
Note that this patch adds wolfCrypt SHA256 hashing to xmss-reference, and
405+
thus benefits from all the same asm speedups as wolfCrypt SHA hashing.
406+
Depending on architecture you may build with --enable-intelasm, or
407+
and --enable-armasm, and see 30-50% speedups in XMSS/XMSS^MT.
408+
409+
For full keygen, signing, verifying, and benchmarking support, build
410+
wolfSSL with:
411+
$ ./configure \
412+
--enable-xmss \
413+
--with-libxmss=<path to xmss src dir>
414+
$ make
415+
416+
Run the benchmark against XMSS/XMSS^MT with:
417+
$ ./wolfcrypt/benchmark/benchmark -xmss_xmssmt
418+
419+
For a leaner xmss verify-only build, build with
420+
$ ./configure \
421+
--enable-xmss=verify-only \
422+
--with-libxmss=<path to xmss src dir>
423+
$ make

configure.ac

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

11431143

1144+
# XMSS
1145+
AC_ARG_ENABLE([xmss],
1146+
[AS_HELP_STRING([--enable-xmss],[Enable stateful XMSS/XMSS^MT signatures (default: disabled)])],
1147+
[ ENABLED_XMSS=$enableval ],
1148+
[ ENABLED_XMSS=no ]
1149+
)
1150+
1151+
ENABLED_WC_XMSS=no
1152+
for v in `echo $ENABLED_XMSS | tr "," " "`
1153+
do
1154+
case $v in
1155+
yes)
1156+
;;
1157+
no)
1158+
;;
1159+
verify-only)
1160+
XMSS_VERIFY_ONLY=yes
1161+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_XMSS_VERIFY_ONLY -DXMSS_VERIFY_ONLY"
1162+
;;
1163+
wolfssl)
1164+
ENABLED_WC_XMSS=yes
1165+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_WC_XMSS"
1166+
;;
1167+
*)
1168+
AC_MSG_ERROR([Invalid choice for XMSS []: $ENABLED_XMSS.])
1169+
break;;
1170+
esac
1171+
done
1172+
1173+
if test "$ENABLED_XMSS" != "no"
1174+
then
1175+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_XMSS"
1176+
1177+
if test "$ENABLED_WC_XMSS" = "no";
1178+
then
1179+
# Default is to use hash-sigs XMSS lib. Make sure it's enabled.
1180+
if test "$ENABLED_LIBXMSS" = "no"; then
1181+
AC_MSG_ERROR([The default implementation for XMSS is the xmss-reference lib.
1182+
Please use --with-libxmss.])
1183+
fi
1184+
fi
1185+
fi
1186+
1187+
# libxmss
1188+
# Get the path to xmss-reference.
1189+
ENABLED_LIBXMSS="no"
1190+
trylibxmssdir=""
1191+
AC_ARG_WITH([libxmss],
1192+
[AS_HELP_STRING([--with-libxmss=PATH],[PATH to xmss-reference root dir. EXPERIMENTAL!])],
1193+
[
1194+
AC_MSG_CHECKING([for libxmss])
1195+
1196+
trylibxmssdir=$withval
1197+
1198+
if test -e $trylibxmssdir; then
1199+
libxmss_linked=yes
1200+
else
1201+
AC_MSG_ERROR([libxmss isn't found.
1202+
If it's already installed, specify its path using --with-libxmss=/dir/])
1203+
fi
1204+
1205+
XMSS_ROOT=$trylibxmssdir
1206+
1207+
AC_MSG_RESULT([yes])
1208+
1209+
AM_CFLAGS="$AM_CFLAGS -DHAVE_LIBXMSS -I$trylibxmssdir"
1210+
ENABLED_LIBXMSS="yes"
1211+
AC_SUBST([XMSS_ROOT])
1212+
],
1213+
[XMSS_ROOT=""]
1214+
)
1215+
1216+
11441217
# LMS
11451218
AC_ARG_ENABLE([lms],
11461219
[AS_HELP_STRING([--enable-lms],[Enable stateful LMS/HSS signatures (default: disabled)])],
@@ -8999,6 +9072,7 @@ AM_CONDITIONAL([BUILD_CRL_MONITOR],[test "x$ENABLED_CRL_MONITOR" = "xyes"])
89999072
AM_CONDITIONAL([BUILD_USER_RSA],[test "x$ENABLED_USER_RSA" = "xyes"] )
90009073
AM_CONDITIONAL([BUILD_USER_CRYPTO],[test "x$ENABLED_USER_CRYPTO" = "xyes"])
90019074
AM_CONDITIONAL([BUILD_LIBLMS],[test "x$ENABLED_LIBLMS" = "xyes"])
9075+
AM_CONDITIONAL([BUILD_LIBXMSS],[test "x$ENABLED_LIBXMSS" = "xyes"])
90029076
AM_CONDITIONAL([BUILD_LIBOQS],[test "x$ENABLED_LIBOQS" = "xyes"])
90039077
AM_CONDITIONAL([BUILD_WNR],[test "x$ENABLED_WNR" = "xyes"])
90049078
AM_CONDITIONAL([BUILD_SRP],[test "x$ENABLED_SRP" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
@@ -9431,6 +9505,11 @@ echo " * ED448: $ENABLED_ED448"
94319505
echo " * ED448 streaming: $ENABLED_ED448_STREAM"
94329506
echo " * LMS: $ENABLED_LMS"
94339507
echo " * LMS wolfSSL impl: $ENABLED_WC_LMS"
9508+
echo " * XMSS: $ENABLED_XMSS"
9509+
echo " * XMSS wolfSSL impl: $ENABLED_WC_XMSS"
9510+
if test "$ENABLED_LIBXMSS" = "yes"; then
9511+
echo " * XMSS_ROOT: $XMSS_ROOT"
9512+
fi
94349513
echo " * KYBER: $ENABLED_KYBER"
94359514
echo " * KYBER wolfSSL impl: $ENABLED_WC_KYBER"
94369515
echo " * ECCSI $ENABLED_ECCSI"
@@ -9486,6 +9565,7 @@ echo " * Persistent session cache: $ENABLED_SAVESESSION"
94869565
echo " * Persistent cert cache: $ENABLED_SAVECERT"
94879566
echo " * Atomic User Record Layer: $ENABLED_ATOMICUSER"
94889567
echo " * Public Key Callbacks: $ENABLED_PKCALLBACKS"
9568+
echo " * libxmss: $ENABLED_LIBXMSS"
94899569
echo " * liblms: $ENABLED_LIBLMS"
94909570
echo " * liboqs: $ENABLED_LIBOQS"
94919571
echo " * Whitewood netRandom: $ENABLED_WNR"

src/include.am

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,18 @@ if BUILD_LIBLMS
807807
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/ext_lms.c
808808
endif
809809

810+
if BUILD_LIBXMSS
811+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/ext_xmss.c
812+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += $(XMSS_ROOT)/params.c
813+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += $(XMSS_ROOT)/thash.c
814+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += $(XMSS_ROOT)/hash_address.c
815+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += $(XMSS_ROOT)/wots.c
816+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += $(XMSS_ROOT)/xmss.c
817+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += $(XMSS_ROOT)/xmss_core_fast.c
818+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += $(XMSS_ROOT)/xmss_commons.c
819+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += $(XMSS_ROOT)/utils.c
820+
endif
821+
810822
if BUILD_LIBZ
811823
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/compress.c
812824
endif

0 commit comments

Comments
 (0)