Skip to content

[skus,fake_keygen] Migrate from SPHINCS+ to SLH-DSA signing - #26

Merged
AlexJones0 merged 7 commits into
lowRISC:mainfrom
AlexJones0:slh_dsa_migration
Oct 28, 2026
Merged

AlexJones0 merged 7 commits into
lowRISC:mainfrom
AlexJones0:slh_dsa_migration

Conversation

@AlexJones0

@AlexJones0 AlexJones0 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

This PR migrates the fake SPHINCS+ keys in the SoftHSM2 test instance to standardized SLH-DSA keys. It defines the fake keygen flow to support these keys and makes improvements to the documentation and supporting scripts to make it more clear how to use these flows to run keygen (aside: some improvements still need to be made to general documentation about the changes that are needed outside of SoftHSM2). To completely remove the SPHINCS+ keys from the SoftHSM2 token and insert new SLH-DSA keys, the fake keygen instance is recreated from scratch -- as a result, all existing keys (including ECDSA keys) are effectively rotated by this change. Relevant key material is then propagated to the OTP configuration.

Targets are created for the SLH-DSA signatures, and the open SKU signing flows are updated to use SLH-DSA signing. Note that, although I've run a test signing/release flow from my fork, this will still need to be run for the changes in this PR so that the release archives are updated appropriately. The handling of this should be clarified before this is merged.

One additional note: the downstream perso signing flows rely on the signature directory having an spx_keyset, which this PR retains. It might be worth thinking about how we handle this case, as for example maybe we might want to support different keysets / keyset names?

See the commit messages for more information.

Comment on lines +138 to +140
// The keys may be exported in plaintext so that they can be
// imported into another HSM.
CKA_SENSITIVE: false,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some background on this choice:

We'd normally want this to be true: the private keys should always live inside the HSM security boundary. However:

  • We are skeptical of HSM backup/restore solutions.
  • We don't want HSM vendor lock-in.
  • We don't want to have a dependency on the long-term stability/existence of a particular vendor (Google's first-generation RoT chip already has a longer-than-expected lifetime).

Comment thread skus/open/fake_keygen/softhsm_sourceme.sh Outdated
@cfrantz

cfrantz commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Overall, this LGTM.

@AlexJones0

Copy link
Copy Markdown
Contributor Author

The last force push replaces the checked-in owner/app keys to match, and updates the X.509 DICE CA cert as well. It standardizes to use the spx_keyset name (in relation to the open question in the PR), since this is probably going to be the easiest solution for now.

Small clarifications just to make the documentation a little bit clearer
about the manual steps that must be performed to use SoftHSM.

Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
Now that upstream hsmtool supports SLH-DSA, we can update the fake
keygen templates (root, owner, application) to use SLH-DSA keys instead
of SPHINCS+ keys. This requires tweaking some of the parameters, and
moving the export to happen via the `export` command, rather than at
generation time, as before (with `hsmtool spx`).

Also update the status of two TODOs related to this in the docs.

Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
- Change the bash shebang used for increased compatibility with
  different systems/environments.
- Add some basic status prints to the keygen and export which describe
  which subdir we are generating keys for - this helps a bit with
  debugging misconfigured keygen & export templates.
- Since the CA subdir currently doesn't export any keys in PEM format,
  the shell expansion of the `*.pem` globs will fail in the final tar.
  Since this is expected, set the shell option to not error on null
  globs whilst executing these tars to silence some noise.
- The last time this script was run, only the CA key was generated - and
  the commenting out of other subdirs was kept in. Restore this to its
  original state.

Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
Most of the subdirs (root, owner, application, but not ca) have changed
from using SPHINCS+ keys to SLH-DSA keys. Completely re-generate the
SoftHSM2 token from scratch using the full keygen & exporting flow.

For posterity, this was generated by following the commands documented
in `skus/open/fake_keygen/README.md`.

Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
Replace the root, owner and CA keys with the fake keys that were
generated by the latest round of keygen. The owner and application keys
are documented as TBD, but they match the previous fake keygen round, so
these are updated to match.

Changes to use SLH-DSA keys instead of SPHINCS+ keys mean that the
SoftHSM2 token containing the fake keys has been regenerated. As such,
all fake keys (including existing ECDSA keys) have been rotated.

Rotating the root keys also involves updating the OTP configuration,
which is included here. The SPHINCS+ keysets now identify the keys as
SLH-DSA keys for the downstream OpenTitan signing rules. Some outdated
documentation is also replaced - removed a couple of stale TODOs, and
changed some extensions from `.pem` to `.der` where required for ECDSA
keys.

Since the ECDSA CA key has been rotated, the X.509 DICE CA cert is
also correspondingly updated. This was done via OpenSSL:
```
openssl req -new -x509 \
  -config skus/open/keys/ca/dice_ca.conf \
  -engine pkcs11 -keyform engine \
  -key "pkcs11:token=temp;object=nuvoton-ot00-ca-ecdsa-0;type=private?pin-value=123456" \
  -sha256 -days 99999 \
  -out skus/open/keys/ca/dice_ca.pem
```
And self-verified with `openssl verify -CAfile ...`

Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
This needs to be updated with the rotated CA key (and thus self-signed
cert), and was out-of-date before the latest round of keygen, anyhow.

Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
We no longer need to define a custom `HSMTOOL_SPX_MODULE` in our SoftHSM
configuration for hsmtool, and the docs should now properly describe how
we export our ECDSA and SLH-DSA keys as valid, standard encodings.

Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
@AlexJones0
AlexJones0 merged commit 6bbf05d into lowRISC:main Oct 28, 2026
2 of 4 checks passed
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.

3 participants