Skip to content

Commit d351120

Browse files
Merge pull request #6840 from philljj/xmss_hooks_support
Add XMSS/XMSSMT wolfCrypt hooks.
2 parents c23559a + 46b1a03 commit d351120

12 files changed

Lines changed: 2398 additions & 29 deletions

File tree

INSTALL

Lines changed: 49 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,51 @@ 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-wolfSSL-xmss-reference-integration.patch
403+
404+
To build patched xmss-reference:
405+
$ make xmss_lib.a
406+
407+
To build verify-only patched xmss-reference:
408+
$ make xmss_verify_lib.a
409+
410+
Note that this patch changes xmss-reference to use wolfCrypt SHA256 hashing,
411+
by registering a SHA callback function in xmss-reference. It
412+
thus benefits from all the same asm speedups as wolfCrypt SHA hashing.
413+
Depending on architecture you may build with --enable-intelasm, or
414+
--enable-armasm, and see 30-40% speedups in XMSS/XMSS^MT.
415+
416+
For full keygen, signing, verifying, and benchmarking support, build
417+
wolfSSL with:
418+
$ ./configure \
419+
--enable-xmss \
420+
--with-libxmss=<path to xmss src dir>
421+
$ make
422+
423+
Run the benchmark against XMSS/XMSS^MT with:
424+
$ ./wolfcrypt/benchmark/benchmark -xmss_xmssmt
425+
426+
For a leaner xmss verify-only build, build with
427+
$ ./configure \
428+
--enable-xmss=verify-only \
429+
--with-libxmss=<path to xmss src dir>
430+
$ make

configure.ac

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,100 @@ then
11431143
fi
11441144

11451145

1146+
# XMSS
1147+
AC_ARG_ENABLE([xmss],
1148+
[AS_HELP_STRING([--enable-xmss],[Enable stateful XMSS/XMSS^MT signatures (default: disabled)])],
1149+
[ ENABLED_XMSS=$enableval ],
1150+
[ ENABLED_XMSS=no ]
1151+
)
1152+
1153+
ENABLED_WC_XMSS=no
1154+
for v in `echo $ENABLED_XMSS | tr "," " "`
1155+
do
1156+
case $v in
1157+
yes)
1158+
;;
1159+
no)
1160+
;;
1161+
verify-only)
1162+
XMSS_VERIFY_ONLY=yes
1163+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_XMSS_VERIFY_ONLY -DXMSS_VERIFY_ONLY"
1164+
;;
1165+
wolfssl)
1166+
ENABLED_WC_XMSS=yes
1167+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_WC_XMSS"
1168+
;;
1169+
*)
1170+
AC_MSG_ERROR([Invalid choice for XMSS []: $ENABLED_XMSS.])
1171+
break;;
1172+
esac
1173+
done
1174+
1175+
if test "$ENABLED_XMSS" != "no"
1176+
then
1177+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_XMSS"
1178+
1179+
if test "$ENABLED_WC_XMSS" = "no";
1180+
then
1181+
# Default is to use hash-sigs XMSS lib. Make sure it's enabled.
1182+
if test "$ENABLED_LIBXMSS" = "no"; then
1183+
AC_MSG_ERROR([The default implementation for XMSS is the xmss-reference lib.
1184+
Please use --with-libxmss.])
1185+
fi
1186+
fi
1187+
fi
1188+
1189+
# libxmss
1190+
# Get the path to xmss-reference.
1191+
ENABLED_LIBXMSS="no"
1192+
trylibxmssdir=""
1193+
AC_ARG_WITH([libxmss],
1194+
[AS_HELP_STRING([--with-libxmss=PATH],[PATH to xmss-reference root dir. EXPERIMENTAL!])],
1195+
[
1196+
AC_MSG_CHECKING([for libxmss])
1197+
1198+
trylibxmssdir=$withval
1199+
1200+
if test -e $trylibxmssdir; then
1201+
libxmss_linked=yes
1202+
else
1203+
AC_MSG_ERROR([libxmss isn't found.
1204+
If it's already installed, specify its path using --with-libxmss=/dir/])
1205+
fi
1206+
if test "$XMSS_VERIFY_ONLY" = "yes"; then
1207+
if test -e $trylibxmssdir/xmss_verify_lib.a; then
1208+
CPPFLAGS="$AM_CPPFLAGS -DHAVE_LIBXMSS -I$trylibxmssdir"
1209+
LIB_STATIC_ADD="$LIB_STATIC_ADD $trylibxmssdir/xmss_verify_lib.a"
1210+
enable_shared=no
1211+
enable_static=yes
1212+
libxmss_linked=yes
1213+
else
1214+
AC_MSG_ERROR([xmss_verify_lib.a isn't found.
1215+
If it's already installed, specify its path using --with-libxmss=/dir/])
1216+
fi
1217+
elif test -e $trylibxmssdir/xmss_lib.a; then
1218+
CPPFLAGS="$AM_CPPFLAGS -DHAVE_LIBXMSS -I$trylibxmssdir"
1219+
LIB_STATIC_ADD="$LIB_STATIC_ADD $trylibxmssdir/xmss_lib.a"
1220+
enable_shared=no
1221+
enable_static=yes
1222+
libxmss_linked=yes
1223+
else
1224+
AC_MSG_ERROR([libxmss isn't found.
1225+
If it's already installed, specify its path using --with-libxmss=/dir/])
1226+
fi
1227+
1228+
XMSS_ROOT=$trylibxmssdir
1229+
1230+
AC_MSG_RESULT([yes])
1231+
AM_CPPFLAGS="$CPPFLAGS"
1232+
1233+
AM_CFLAGS="$AM_CFLAGS -DHAVE_LIBXMSS -I$trylibxmssdir"
1234+
ENABLED_LIBXMSS="yes"
1235+
AC_SUBST([XMSS_ROOT])
1236+
],
1237+
[XMSS_ROOT=""]
1238+
)
1239+
11461240
# LMS
11471241
AC_ARG_ENABLE([lms],
11481242
[AS_HELP_STRING([--enable-lms],[Enable stateful LMS/HSS signatures (default: disabled)])],
@@ -9024,6 +9118,7 @@ AM_CONDITIONAL([BUILD_GE448], [test "x$ENABLED_GE448" = "xyes" || test "x$ENABLE
90249118
AM_CONDITIONAL([BUILD_CURVE448],[test "x$ENABLED_CURVE448" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
90259119
AM_CONDITIONAL([BUILD_CURVE448_SMALL],[test "x$ENABLED_CURVE448_SMALL" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
90269120
AM_CONDITIONAL([BUILD_WC_LMS],[test "x$ENABLED_WC_LMS" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
9121+
AM_CONDITIONAL([BUILD_WC_XMSS],[test "x$ENABLED_WC_XMSS" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
90279122
AM_CONDITIONAL([BUILD_WC_KYBER],[test "x$ENABLED_WC_KYBER" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
90289123
AM_CONDITIONAL([BUILD_ECCSI],[test "x$ENABLED_ECCSI" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
90299124
AM_CONDITIONAL([BUILD_SAKKE],[test "x$ENABLED_SAKKE" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
@@ -9064,6 +9159,7 @@ AM_CONDITIONAL([BUILD_CRL_MONITOR],[test "x$ENABLED_CRL_MONITOR" = "xyes"])
90649159
AM_CONDITIONAL([BUILD_USER_RSA],[test "x$ENABLED_USER_RSA" = "xyes"] )
90659160
AM_CONDITIONAL([BUILD_USER_CRYPTO],[test "x$ENABLED_USER_CRYPTO" = "xyes"])
90669161
AM_CONDITIONAL([BUILD_LIBLMS],[test "x$ENABLED_LIBLMS" = "xyes"])
9162+
AM_CONDITIONAL([BUILD_LIBXMSS],[test "x$ENABLED_LIBXMSS" = "xyes"])
90679163
AM_CONDITIONAL([BUILD_LIBOQS],[test "x$ENABLED_LIBOQS" = "xyes"])
90689164
AM_CONDITIONAL([BUILD_WNR],[test "x$ENABLED_WNR" = "xyes"])
90699165
AM_CONDITIONAL([BUILD_SRP],[test "x$ENABLED_SRP" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
@@ -9497,6 +9593,11 @@ echo " * ED448: $ENABLED_ED448"
94979593
echo " * ED448 streaming: $ENABLED_ED448_STREAM"
94989594
echo " * LMS: $ENABLED_LMS"
94999595
echo " * LMS wolfSSL impl: $ENABLED_WC_LMS"
9596+
echo " * XMSS: $ENABLED_XMSS"
9597+
echo " * XMSS wolfSSL impl: $ENABLED_WC_XMSS"
9598+
if test "$ENABLED_LIBXMSS" = "yes"; then
9599+
echo " * XMSS_ROOT: $XMSS_ROOT"
9600+
fi
95009601
echo " * KYBER: $ENABLED_KYBER"
95019602
echo " * KYBER wolfSSL impl: $ENABLED_WC_KYBER"
95029603
echo " * ECCSI $ENABLED_ECCSI"
@@ -9552,6 +9653,7 @@ echo " * Persistent session cache: $ENABLED_SAVESESSION"
95529653
echo " * Persistent cert cache: $ENABLED_SAVECERT"
95539654
echo " * Atomic User Record Layer: $ENABLED_ATOMICUSER"
95549655
echo " * Public Key Callbacks: $ENABLED_PKCALLBACKS"
9656+
echo " * libxmss: $ENABLED_LIBXMSS"
95559657
echo " * liblms: $ENABLED_LIBLMS"
95569658
echo " * liboqs: $ENABLED_LIBOQS"
95579659
echo " * Whitewood netRandom: $ENABLED_WNR"

src/include.am

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,10 @@ if BUILD_WC_LMS
731731
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_lms.c
732732
endif
733733

734+
if BUILD_WC_XMSS
735+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/wc_xmss.c
736+
endif
737+
734738
if BUILD_CURVE25519
735739
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/curve25519.c
736740
endif
@@ -836,6 +840,10 @@ if BUILD_LIBLMS
836840
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/ext_lms.c
837841
endif
838842

843+
if BUILD_LIBXMSS
844+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/ext_xmss.c
845+
endif
846+
839847
if BUILD_LIBZ
840848
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/compress.c
841849
endif

0 commit comments

Comments
 (0)