Skip to content

SLH-DSA: fix configure parameter set options and reduced-build tests - #11907

Open
Arpan0995 wants to merge 1 commit into
wolfSSL:masterfrom
Arpan0995:slhdsa-param-set-options
Open

Arpan0995 wants to merge 1 commit into
wolfSSL:masterfrom
Arpan0995:slhdsa-param-set-options

Conversation

@Arpan0995

Copy link
Copy Markdown
Contributor

Description

Fixes for the parameter set options of --enable-slhdsa, and for two tests that fail in builds with fewer parameter sets.

configure:

  • An option string that names no parameter set, such as --enable-slhdsa=verify-only, small, small-mem, no-s or no-f, passes configure and then fails to compile (#error "No parameters defined" in wc_slhdsa.h), because every SHAKE set gets its NO flag and the SHA2 family is off. Such a string now starts from the six SHAKE sets, as yes does, in the same way configure enables all ML-DSA levels when none is named, and no-s or no-f then removes its group (below), so no-s gives the three fast SHAKE sets. The SHA2 sets stay opt-in.
  • no-s, no-f, no-sha2-s and no-sha2-f add a group NO macro, but wc_slhdsa.h drops a group NO macro when a set in that group is defined, and configure defines every selected set. So --enable-slhdsa=yes,no-s still builds all six SHAKE sets. These options now take their group out of the selected sets in configure, including sets named in the same option string (the header's macro rules are unchanged). If that leaves no SHA2 set, the SHA2 family is left out too, with its SHA-256, SHA-512 and HMAC requirements. If it leaves no set at all, configure stops with an error. That check runs after the FIPS section, which selects all twelve sets for any --enable-slhdsa value other than plain yes, so a FIPS v7 build with, for example, no-s,no-f or yes,no-s still gets all twelve sets, as before.

tests:

  • test_wc_slhdsa_param_disabled looks for an enabled set in a list that stops at SHA2-128s, so it fails in builds such as --enable-slhdsa=sha2-192f or sha2-128f,verify-only. It now uses TEST_SLHDSA_DEFAULT_PARAM, the file's own choice of the first compiled-in set.
  • test_wc_SignCRL_slhdsa always runs the SHAKE-128s case (its comment says the SHAKE sets are always built), so with --enable-crl --enable-certgen it fails with -174 (NOT_COMPILED_IN) in builds such as --enable-slhdsa=sha2, sha2-192f or 128f. Each case now needs its 128s set, the only sets with a root certificate in certs/slhdsa, and the test, like the SLH-DSA part of its helper's guard, needs at least one of them.

Testing

./configure --enable-slhdsa=verify-only --disable-shared
make
./configure --enable-slhdsa=yes,no-s --disable-shared
make
./tests/unit.test --api -test_wc_slhdsa_param_disabled
./configure --enable-slhdsa=sha2-192f --enable-crl --enable-certgen --disable-shared
make
./tests/unit.test --api -test_wc_slhdsa_param_disabled -test_wc_SignCRL_slhdsa
  • On master, --enable-slhdsa=verify-only, small and no-s fail to compile at #error "No parameters defined". With this change they build, with the six SHAKE sets for verify-only and small and the three fast SHAKE sets for no-s, and test_wc_slhdsa_param_disabled passes.
  • With yes,no-s, master builds all six SHAKE sets (checked by initializing a key for each set); with this change only 128f, 192f and 256f. yes,sha2,no-sha2-f gives the six SHAKE sets and the three small SHA2 sets. yes,sha2,no-sha2-s,no-sha2-f gives the six SHAKE sets without the SHA2 family, so it also builds with --disable-sha512. no-s,no-f, 128s,no-s and sha2,no-sha2-s,no-sha2-f stop at configure with the new error. In a configure-only check with a stub fips.c, --enable-fips=v7 with no-s,no-f or yes,no-s still selects all twelve sets.
  • On master, test_wc_slhdsa_param_disabled fails in sha2-192f and sha2-128f,verify-only builds (haveEnabled == 1 fails), and test_wc_SignCRL_slhdsa fails with -174 in sha2-192f, sha2 and 128f builds with --enable-crl --enable-certgen. With this change test_wc_slhdsa_param_disabled passes in both builds, and test_wc_SignCRL_slhdsa passes in the sha2 build (SHA2-128s case only) and is skipped in the sha2-192f and 128f builds, which have no 128s set.
  • Also built with no warnings, with the slhdsa group passing: --enable-slhdsa (also testwolfcrypt) and --enable-slhdsa=yes,sha2, both with --enable-crl --enable-certgen; --enable-slhdsa=no-s with ASan/UBSan, with no sanitizer reports; the slhdsa and slhdsa-verify-only entries of cryptocb-only.yml; and --enable-all --enable-all-quantum-crypto (full --api).
  • Tested on macOS (arm64) with Apple clang 21.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

An --enable-slhdsa string that names no parameter set, such as
verify-only, small or no-s, passed configure and then failed to
compile. Start such a string from the six SHAKE sets, as 'yes' does.
no-s, no-f, no-sha2-s and no-sha2-f added group NO macros that
wc_slhdsa.h drops when a set in the group is defined, so they were
ignored. Take the group out of the selected sets in configure instead,
leave the SHA2 family out when no SHA2 set is left, and stop with an
error when no set is left (checked after the FIPS section).

test_wc_slhdsa_param_disabled now probes TEST_SLHDSA_DEFAULT_PARAM, so
it passes in SHA2-only builds without SHA2-128s. test_wc_SignCRL_slhdsa
runs each case only when its 128s set is built and is skipped when
neither is (its helper's guard follows), so it no longer fails with
NOT_COMPILED_IN when SHAKE-128s, or SHA2-128s in a SHA2 build, is left
out.
Copilot AI balanced review requested due to automatic review settings October 27, 2026 15:53
@wolfSSL-Bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The selection logic and test guards are consistent with the parameter contracts and FIPS flow, with no unresolved issues identified.

No open issues 🎉

What changed in this PR

This PR fixes SLH-DSA parameter selection in Autotools builds and updates API tests to support reduced parameter sets while preserving FIPS selection behavior.

Changes:

  • Default modifier-only options to SHAKE sets, apply group exclusions, and reject empty selections after FIPS processing.
  • Disable SHA2 dependencies when no SHA2 parameter sets remain.
  • Use an enabled parameter for the disabled-set test and guard CRL cases by their required 128s sets.
File Description
tests/​api/​test_slhdsa.c Uses the shared default parameter selection for the enabled-set probe.
tests/​api.c Gates SLH-DSA CRL tests and their helper on available 128s sets.
configure.ac Corrects parameter defaults, exclusions, dependency handling, and empty-selection validation.

Review effort: Balanced

@dgarske

dgarske commented Oct 27, 2026

Copy link
Copy Markdown
Member

Okay to test. Contributor agreement on file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants