Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
670d322
feat: implement SLH-DSA signing and verification using OpenSSL
Daelon02 Apr 22, 2026
9ced310
Remove accidental backup files and add *.orig to .gitignore
Daelon02 Apr 22, 2026
27ac9ad
Remove merge-reject artifacts
Daelon02 Apr 22, 2026
bbc2843
Fix rabbit-ai comments
Daelon02 Apr 22, 2026
0664d14
Remove orphaned export headers
Daelon02 Apr 22, 2026
f9fe62a
refactor: sort include headers and move P11 object creation to P11Obj…
Daelon02 Apr 26, 2026
f1ee958
refactor: replace printf with INFO_MSG for mechanism logging and refo…
Daelon02 Apr 26, 2026
ccd6cd3
Merge upstream/main and resolve conflict
Daelon02 Apr 26, 2026
aeebd0d
refactor: improve const correctness for SLH-DSA key setters, normaliz…
Daelon02 Apr 26, 2026
747b1af
feat: add missing setters and OpenSSL constructors for SLH-DSA key cl…
Daelon02 Apr 26, 2026
174589e
refactor: formalize SLH-DSA key constructors and improve error handli…
Daelon02 Apr 26, 2026
56229c1
chore: add Doxygen documentation comments to SLH-DSA crypto headers
Daelon02 Apr 26, 2026
9132f57
docs: add Doxygen documentation comments for SLH-DSA core components …
Daelon02 Apr 26, 2026
08a5583
Fix PR review comments
Daelon02 May 4, 2026
971f9ba
Merge branch 'main' into slh-dsa
Daelon02 May 4, 2026
e489500
Merge branch 'main' into slh-dsa
Daelon02 May 18, 2026
0a5925e
style: apply upstream astyle formatting (tabs and allman braces) to s…
Daelon02 May 18, 2026
5e935bc
Revert massive formatting changes in SoftHSM.cpp
Daelon02 May 18, 2026
f4c8a64
feat: enable SLH-DSA support by adding mandatory compile-time checks …
Daelon02 May 18, 2026
97671aa
refactor: standardize code formatting and remove unused function decl…
Daelon02 May 18, 2026
3350d92
refactor: clean up duplicate SLH-DSA test declarations and reformat c…
Daelon02 May 19, 2026
a3b024c
refactor: standardize formatting and header inclusion in SignVerifyTe…
Daelon02 May 19, 2026
2b270df
feat: add SLH-DSA support to SoftHSMv2 and improve key deserializatio…
Daelon02 May 19, 2026
a18ae20
feat: add error handling for SLH-DSA key conversion and initialize SL…
Daelon02 May 19, 2026
2d778ec
fix: ensure correct error return codes and cast EVP_PKEY to non-const…
Daelon02 May 19, 2026
59aa9ed
fix: add null check for SLH-DSA parameter set name to prevent potenti…
Daelon02 May 19, 2026
d992d61
fix: add null pointer check for EVP_PKEY in OSSLSLHDSAPublicKey::setF…
Daelon02 May 19, 2026
6260a3f
feat: implement multi-part signing and verification support for SLH-D…
Daelon02 May 23, 2026
643390c
feat: enable multi-part operations for ML-DSA and SLH-DSA, fix OSSL-S…
Daelon02 May 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ test-results.xml

# Temporary files
*~
*.orig

# Building directories
build
Expand Down
1 change: 1 addition & 0 deletions CMAKE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Some options (more can be found in CMakeLists.txt):
-DDISABLE_NON_PAGED_MEMORY=ON Disable non-paged memory for secure storage
-DENABLE_EDDSA=ON Enable support for EDDSA
-DENABLE_MLDSA=ON Enable support for ML-DSA
-DENABLE_SLHDSA=ON Enable support for SLH-DSA
-DWITH_MIGRATE=ON Build migration tool
-DWITH_CRYPTO_BACKEND=openssl Select crypto backend (openssl|botan)

Expand Down
1 change: 1 addition & 0 deletions CMAKE-WIN-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Some options (more can be found in CMakeLists.txt):
-DBUILD_TESTS=ON Compile tests along with libraries
-DENABLE_EDDSA=ON Enable support for EDDSA
-DENABLE_MLDSA=ON Enable support for ML-DSA
-DENABLE_SLHDSA=ON Enable support for SLH-DSA
-DWITH_MIGRATE=ON Build migration tool
-DWITH_CRYPTO_BACKEND= Select crypto backend (openssl|botan)
-DDISABLE_NON_PAGED_MEMORY=ON Disable non-paged memory for secure storage
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ option(ENABLE_64bit "Enable 64-bit compiling" OFF)
option(ENABLE_ECC "Enable support for ECC" ON)
option(ENABLE_EDDSA "Enable support for EDDSA" ON)
option(ENABLE_MLDSA "Enable support for ML-DSA" OFF)
option(ENABLE_SLHDSA "Enable support for SLH-DSA" OFF)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
option(ENABLE_GOST "Enable support for GOST" OFF)
option(ENABLE_FIPS "Enable support for FIPS 140-2 mode" OFF)
option(ENABLE_P11_KIT "Enable p11-kit integration" ON)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Options:
--enable-gost Enable support for GOST (default detect)
--enable-eddsa Enable support for EDDSA (default detect)
--enable-mldsa Enable support for ML-DSA (default detect)
--enable-slhdsa Enable support for SLH-DSA (default detect)
--disable-visibility Disable hidden visibilty link mode [enabled]
--with-crypto-backend Select crypto backend (openssl|botan)
--with-openssl=PATH Specify prefix of path of OpenSSL
Expand Down
20 changes: 20 additions & 0 deletions cmake/modules/CompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,26 @@ elseif(WITH_CRYPTO_BACKEND STREQUAL "openssl")
message(STATUS "OpenSSL: Support for ML-DSA is disabled")
endif(ENABLE_MLDSA)

# acx_openssl_slhdsa.m4
if(ENABLE_SLHDSA)
# SLH-DSA
set(testfile ${CMAKE_SOURCE_DIR}/cmake/modules/tests/test_openssl_slhdsa.c)
try_run(RUN_SLHDSA COMPILE_RESULT
"${CMAKE_BINARY_DIR}/prebuild_santity_tests" ${testfile}
LINK_LIBRARIES ${CRYPTO_LIBS}
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES=${CRYPTO_INCLUDES}"
)
if(COMPILE_RESULT AND RUN_SLHDSA EQUAL 0)
set(WITH_SLH_DSA 1)
message(STATUS "OpenSSL: Found SLH-DSA")
else()
set(error_msg "OpenSSL: Cannot find SLH-DSA! OpenSSL library has no SLH-DSA support!")
message(FATAL_ERROR ${error_msg})
endif()
else(ENABLE_SLHDSA)
message(STATUS "OpenSSL: Support for SLH-DSA is disabled")
endif(ENABLE_SLHDSA)
# acx_openssl_gost.m4
if(ENABLE_GOST)
set(testfile ${CMAKE_SOURCE_DIR}/cmake/modules/tests/test_openssl_gost.c)
Expand Down
12 changes: 12 additions & 0 deletions cmake/modules/tests/test_openssl_slhdsa.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <openssl/evp.h>
#include <openssl/objects.h>
int main()
{
EVP_PKEY_CTX *ctx;
ctx = EVP_PKEY_CTX_new_from_name(NULL, "SLH-DSA-SHA2-128s", NULL);

if (ctx == NULL)
return 1;
EVP_PKEY_CTX_free(ctx);
return 0;
}
3 changes: 3 additions & 0 deletions config.h.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@
/* Compile with ML-DSA support */
#cmakedefine WITH_ML_DSA @WITH_ML_DSA@

/* Compile with SLH-DSA support */
#cmakedefine WITH_SLH_DSA @WITH_SLH_DSA@

/* Compile with FIPS 140-2 mode */
#cmakedefine WITH_FIPS @WITH_FIPS@

Expand Down
36 changes: 36 additions & 0 deletions m4/acx_crypto_backend.m4
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ AC_DEFUN([ACX_CRYPTO_BACKEND],[
[enable_mldsa="detect"]
)

# Add SLH-DSA check

AC_ARG_ENABLE(slhdsa,
AS_HELP_STRING([--enable-slhdsa],
[Enable support for SLH-DSA (default detect)]
),
[enable_slhdsa="${enableval}"],
[enable_slhdsa="detect"]
)

# Second check for the FIPS 140-2 mode

AC_ARG_ENABLE(fips,
Expand Down Expand Up @@ -119,6 +129,15 @@ AC_DEFUN([ACX_CRYPTO_BACKEND],[
detect-no) enable_mldsa="no";;
esac

case "${enable_slhdsa}" in
yes|detect) ACX_OPENSSL_SLHDSA;;
esac
case "${enable_slhdsa}-${have_lib_openssl_slhdsa_support}" in
yes-no) AC_MSG_ERROR([OpenSSL library has no SLH-DSA support]);;
detect-yes) enable_slhdsa="yes";;
detect-no) enable_slhdsa="no";;
esac

case "${enable_gost}-${enable_fips}" in
yes-yes) AC_MSG_ERROR([GOST is not FIPS approved]);;
yes-no|detect-no) ACX_OPENSSL_GOST;;
Expand Down Expand Up @@ -189,6 +208,10 @@ AC_DEFUN([ACX_CRYPTO_BACKEND],[
AC_MSG_ERROR([Botan does not support ML-DSA])
fi

if test "x${enable_slhdsa}" = "xyes"; then
AC_MSG_ERROR([Botan does not support SLH-DSA])
fi

case "${enable_gost}" in
yes|detect) ACX_BOTAN_GOST;;
esac
Expand Down Expand Up @@ -267,6 +290,19 @@ AC_DEFUN([ACX_CRYPTO_BACKEND],[
fi
AM_CONDITIONAL([WITH_ML_DSA], [test "x${enable_mldsa}" = "xyes"])

AC_MSG_CHECKING(for SLH-DSA support)
if test "x${enable_slhdsa}" = "xyes"; then
AC_MSG_RESULT(yes)
AC_DEFINE_UNQUOTED(
[WITH_SLH_DSA],
[],
[Compile with SLH-DSA support]
)
else
AC_MSG_RESULT(no)
fi
AM_CONDITIONAL([WITH_SLH_DSA], [test "x${enable_slhdsa}" = "xyes"])


AC_SUBST(CRYPTO_INCLUDES)
AC_SUBST(CRYPTO_LIBS)
Expand Down
44 changes: 44 additions & 0 deletions m4/acx_openssl_slhdsa.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
AC_DEFUN([ACX_OPENSSL_SLHDSA],[
AC_MSG_CHECKING(for OpenSSL SLH-DSA support)

tmp_CPPFLAGS=$CPPFLAGS
tmp_LIBS=$LIBS

CPPFLAGS="$CPPFLAGS $CRYPTO_INCLUDES"
LIBS="$CRYPTO_LIBS $LIBS"

AC_LANG_PUSH([C])
AC_CACHE_VAL([acx_cv_lib_openssl_slhdsa_support],[
acx_cv_lib_openssl_slhdsa_support=no
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <openssl/evp.h>
#include <openssl/objects.h>
int main()
{
EVP_PKEY_CTX *pctx =
EVP_PKEY_CTX_new_from_name(NULL, "SLH-DSA-SHA2-128s", NULL);
if (pctx == NULL)
return 1;
EVP_PKEY_CTX_free(pctx);
return 0;
}
]])
],[
AC_MSG_RESULT([yes])
acx_cv_lib_openssl_slhdsa_support=yes
],[
AC_MSG_RESULT([no])
acx_cv_lib_openssl_slhdsa_support=no
],[
AC_MSG_WARN([Cannot test, SLH-DSA])
acx_cv_lib_openssl_slhdsa_support=no
])
])

AC_LANG_POP([C])

CPPFLAGS=$tmp_CPPFLAGS
LIBS=$tmp_LIBS
have_lib_openssl_slhdsa_support="${acx_cv_lib_openssl_slhdsa_support}"
])
80 changes: 80 additions & 0 deletions src/lib/P11Objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1989,3 +1989,83 @@ bool P11DHDomainObj::init(OSObject *inobject)
initialized = true;
return true;
}

// Constructor
P11SLHDSAPublicKeyObj::P11SLHDSAPublicKeyObj()
{
initialized = false;
}

// Add attributes
bool P11SLHDSAPublicKeyObj::init(OSObject *inobject)
{
if (initialized) return true;
if (inobject == NULL) return false;

if (!inobject->attributeExists(CKA_KEY_TYPE) || inobject->getUnsignedLongValue(CKA_KEY_TYPE, CKK_VENDOR_DEFINED) != CKK_SLH_DSA) {
OSAttribute setKeyType((unsigned long)CKK_SLH_DSA);
inobject->setAttribute(CKA_KEY_TYPE, setKeyType);
}

// Create parent
if (!P11PublicKeyObj::init(inobject)) return false;

// Create attributes
P11Attribute* attrParameterSet = new P11AttrParameterSet(osobject, P11Attribute::ck3);
P11Attribute* attrValue = new P11AttrValue(osobject, P11Attribute::ck1 | P11Attribute::ck4);

// Initialize the attributes
if (!attrParameterSet->init() || !attrValue->init()) {
ERROR_MSG("Could not initialize the attribute");
delete attrParameterSet;
delete attrValue;
return false;
}

// Add them to the map
attributes[attrParameterSet->getType()] = attrParameterSet;
attributes[attrValue->getType()] = attrValue;

initialized = true;
return true;
}

// Constructor
P11SLHDSAPrivateKeyObj::P11SLHDSAPrivateKeyObj()
{
initialized = false;
}

// Add attributes
bool P11SLHDSAPrivateKeyObj::init(OSObject *inobject)
{
if (initialized) return true;
if (inobject == NULL) return false;

if (!inobject->attributeExists(CKA_KEY_TYPE) || inobject->getUnsignedLongValue(CKA_KEY_TYPE, CKK_VENDOR_DEFINED) != CKK_SLH_DSA) {
OSAttribute setKeyType((unsigned long)CKK_SLH_DSA);
inobject->setAttribute(CKA_KEY_TYPE, setKeyType);
}

// Create parent
if (!P11PrivateKeyObj::init(inobject)) return false;

// Create attributes
P11Attribute* attrParameterSet = new P11AttrParameterSet(osobject, P11Attribute::ck4 | P11Attribute::ck6);
P11Attribute* attrValue = new P11AttrValue(osobject, P11Attribute::ck1 | P11Attribute::ck4 | P11Attribute::ck6 | P11Attribute::ck7);

// Initialize the attributes
if (!attrParameterSet->init() || !attrValue->init()) {
ERROR_MSG("Could not initialize the attribute");
delete attrParameterSet;
delete attrValue;
return false;
}

// Add them to the map
attributes[attrParameterSet->getType()] = attrParameterSet;
attributes[attrValue->getType()] = attrValue;

initialized = true;
return true;
}
31 changes: 31 additions & 0 deletions src/lib/P11Objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,35 @@ class P11DHDomainObj : public P11DomainObj
bool initialized;
};

/** \brief SLH-DSA public key object */
class P11SLHDSAPublicKeyObj : public P11PublicKeyObj
{
public:
/** \brief Constructor */
P11SLHDSAPublicKeyObj();

/** \brief Initialize the object */
virtual bool init(OSObject *inobject);

protected:
/** \brief Is the object initialized? */
bool initialized;
};

/** \brief SLH-DSA private key object */
class P11SLHDSAPrivateKeyObj : public P11PrivateKeyObj
{
public:
/** \brief Constructor */
P11SLHDSAPrivateKeyObj();

/** \brief Initialize the object */
virtual bool init(OSObject *inobject);

protected:
/** \brief Is the object initialized? */
bool initialized;
};

#endif // !_SOFTHSM_V2_P11OBJECTS_H

Loading