Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added certs/slhdsa/cms-slhdsa-sha2-128s-noattr.der
Binary file not shown.
Binary file added certs/slhdsa/cms-slhdsa-shake-128s-sha224.der
Binary file not shown.
Binary file added certs/slhdsa/cms-slhdsa-shake-128s.der
Binary file not shown.
22 changes: 22 additions & 0 deletions certs/slhdsa/gen-slhdsa-mldsa-certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,27 @@ check_result $? "Export ${BENCH} public key"
tail -c 32 "${BENCH}_pub.der" > "${BENCH}_pub.bin"
rm -f "${BENCH}_pub.der"

# RFC 9814 SignedData interop vectors, verified by
# pkcs7signed_slhdsa_interop_test() in wolfcrypt/test/test.c. One per hash
# family, covering both the signed-attributes and the no-signed-attributes
# form. OpenSSL picks the RFC 9814 digestAlgorithm for the parameter set.
printf 'RFC 9814 SLH-DSA SignedData from OpenSSL' > cms-content.tmp
openssl cms -sign -binary -nodetach -outform DER -in cms-content.tmp \
-signer root-slhdsa-shake-128s.pem -inkey root-slhdsa-shake-128s-priv.pem \
-out cms-slhdsa-shake-128s.der
check_result $? "Sign SLH-DSA-SHAKE-128s SignedData"
openssl cms -sign -binary -nodetach -noattr -outform DER -in cms-content.tmp \
-signer root-slhdsa-sha2-128s.pem -inkey root-slhdsa-sha2-128s-priv.pem \
-out cms-slhdsa-sha2-128s-noattr.der
check_result $? "Sign SLH-DSA-SHA2-128s SignedData without attributes"
# Negative vector: SHA-224 is shorter than RFC 9814 allows for 128-bit
# parameter sets when signed attributes are present. Must fail to verify.
openssl cms -sign -binary -nodetach -md sha224 -outform DER \
-in cms-content.tmp -signer root-slhdsa-shake-128s.pem \
-inkey root-slhdsa-shake-128s-priv.pem \
-out cms-slhdsa-shake-128s-sha224.der
check_result $? "Sign SLH-DSA-SHAKE-128s SignedData with SHA-224"
rm -f cms-content.tmp

echo
echo "All SLH-DSA / ML-DSA-44 test certificates regenerated."
3 changes: 3 additions & 0 deletions certs/slhdsa/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ EXTRA_DIST += \
certs/slhdsa/root-slhdsa-sha2-128s-priv.der \
certs/slhdsa/root-slhdsa-sha2-128s.pem \
certs/slhdsa/root-slhdsa-sha2-128s.der \
certs/slhdsa/cms-slhdsa-shake-128s.der \
certs/slhdsa/cms-slhdsa-shake-128s-sha224.der \
certs/slhdsa/cms-slhdsa-sha2-128s-noattr.der \
certs/slhdsa/server-mldsa44-sha2.pem \
certs/slhdsa/client-mldsa44-sha2.pem \
certs/slhdsa/server-slhdsa-shake-128f-priv.pem \
Expand Down
12 changes: 12 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13925,6 +13925,18 @@ then
ENABLED_X963KDF="yes"
AM_CFLAGS="$AM_CFLAGS -DHAVE_X963_KDF"
fi
# RFC 9814: SHAKE128 is the MUST-support digestAlgorithm for the SLH-DSA
# SHAKE-128 parameter sets. SHA-3 is already forced on for SLH-DSA.
if test "$ENABLED_SLHDSA" != "no" &&
(test "$SLHDSA_PARAM_128S" = "yes" ||
test "$SLHDSA_PARAM_128F" = "yes") &&
(test "$ENABLED_SHAKE128" = "no" || test "$ENABLED_SHAKE128" = "") &&
(test "$ENABLED_FIPS" = "no" || test $HAVE_FIPS_VERSION -ge 6)
then
ENABLED_SHAKE128="yes"
AM_CFLAGS=$(echo "$AM_CFLAGS" | sed 's/-DWOLFSSL_NO_SHAKE128//g')
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SHAKE128"
fi
fi

if test "x$ENABLED_DES3" = "xno"
Expand Down
9 changes: 8 additions & 1 deletion doc/dox_comments/header_files/pkcs7.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,18 @@ int wc_PKCS7_EncodeData(wc_PKCS7* pkcs7, byte* output,
the PKCS7 structure into a buffer containing a parsable PKCS7
signed data packet. For RSA-PSS signers (WC_RSA_PSS), see \ref PKCS7_RSA_PSS.

For an SLH-DSA signer (RFC 9814), pkcs7->hashOID may be left at 0. It is
then set to the digestAlgorithm RFC 9814 requires for the parameter set
(SHA-256 or SHA-512 for the SHA2 sets, SHAKE128 or SHAKE256 for the SHAKE
sets) and keeps that value after the call. With signed attributes, the
digest must be at least twice the SLH-DSA tree hash size (2n).

\return Success On successfully encoding the PKCS7 data into the buffer,
returns the index parsed up to in the PKCS7 structure. This index also
corresponds to the bytes written to the output buffer.
\return BAD_FUNC_ARG Returned if the PKCS7 structure is missing one or
more required elements to generate a signed data packet
more required elements to generate a signed data packet, or if the
digestAlgorithm is too short for an SLH-DSA signer
\return MEMORY_E Returned if there is an error allocating memory
\return PUBLIC_KEY_E Returned if there is an error parsing the public key
\return RSA_BUFFER_E Returned if buffer error, output too small or input
Expand Down
Loading
Loading