← Back to section · Tutorials & Labs

Deployment in Practice: Switching Code Signing to LMS / XMSS

Firmware and software signing is the first-priority post-quantum migration scenario: LMS and XMSS already have RFC and SP 800-208 backing. This article covers parameter selection, state management — the real engineering difficulty — and the dual-signing transition.

Published 22 November 2026 · 5 min read · PQ Frontier

Deployment in Practice: Switching Code Signing to LMS / XMSS
AI-generated site artwork
Video explainer · Deployment tutorials: into real systems

Why does code signing rank first in migration order? Because its time scale is the longest: a verification public key burned into a device at the factory must still verify firmware update signatures credibly ten or more years later; by the time the quantum threat materializes, the devices are already deployed. Industry consensus points the same way: NIST SP 800-208 (2020) specifically approves the stateful hash-based signatures LMS and XMSS for scenarios like code signing, and NSA’s CNSA 2.0 suite likewise lists them as preferred for software and firmware signing. This article covers the operational side of switching a real signing pipeline over.

Prerequisites: Understand the Parameters Before Choosing

The security of LMS (RFC 8554) and XMSS (RFC 8391) rests only on hash functions, not on any number-theoretic hardness assumption — that is why they are trusted. Both schemes’ core parameters are two-dimensional: hash output length (corresponding to the security level, e.g., 32 bytes for SHA-256) and Merkle tree height h — the height decides how many times one key can sign in its life (2^h times): h=20 is about a million, h=25 about 33 million. The Winternitz parameter w trades signature size against computation. Selection essentials: derive the tree height backwards from “how many versions will this key sign in its whole lifetime,” with generous headroom; prefer one height larger (the cost is longer key generation time; the public key is unchanged) over changing keys midway — a key change means every shipped device’s trust anchor must change too, which is a recall-class event. Key generation time grows exponentially with height, so pre-generate large-h keys on the signing machine ahead of time instead of stalling the release process. On library support: libraries such as Botan and Bouncy Castle provide XMSS/LMS implementations, while OpenSSL’s LMS support is limited to scenarios like verification and varies by version — consult official documentation for your specific toolchain rather than hard-coding assumptions from memory.

The Core Difficulty: State Management Decides Success or Failure

The “state” of a stateful signature is the next available one-time key index. Sign twice with the same index and an attacker can forge signatures — this is not a theoretical risk; it is this scheme family’s only, and fatal, failure mode. Deployment design must answer three questions first. Who holds the state? There must be a single authoritative source; the recommended pattern concentrates signing into one signing service (or an HSM-internal counter), with the pipeline only submitting files to be signed and never touching indices itself. How do backups restore? Never restore “key plus old state” onto another machine and keep signing — the restore procedure must guarantee indices only move forward; a common approach reserves an index range at backup time, and after a restore, signing resumes from a fresh range while the old range is permanently voided. How is concurrency handled? Hot standbys and simultaneous releases by several people must all go through the same state allocator, drawing indices in non-overlapping segments (draw a segment, use it up, draw more). Writing these three rules into the deployment document and rehearsing them matters more than any algorithm tuning.

Steps: Retrofitting the Pipeline for Dual Signing

The recommended transition is dual signing in parallel: build artifacts receive both a classical signature (e.g., ECDSA/RSA, compatible with existing verifiers) and an LMS/XMSS signature (for upgraded verifiers). The pipeline retrofit has four points. First, the signing service gains an HBS signing interface that internally performs index allocation and state persistence; state must be persisted in the same transaction as the signing action — the index advances and is persisted immediately after signing, so even a process crash cannot return to an old index. Second, the release package format carries the second signature and an algorithm identifier. Third, the verifier side (device bootloader or updater) upgrades its verification logic to “if an HBS signature is present, verify the HBS.” Fourth, monitoring gains a “remaining signature count” item, alerting one release cycle ahead based on the consumption rate. Verification does three things: a positive case (a normal signature verifies), a negative case (flip one byte and verification fails), and a state negative case (deliberately re-sign with an old index and confirm the audit detects the duplicate index — detection comes from the signing service’s logs, not from the cryptography itself).

Toolchain Landing: The Minimal Loop from Key Generation to Verification

Landing the scheme on tools, the minimal loop has four links, none dispensable. Key generation happens inside the signing environment, and the parameters (algorithm, tree height, Winternitz parameter) are registered in the key ledger together with the public key fingerprint; the public key then enters the product’s trust-anchor distribution channel (firmware embedding, release-page publication). The signing link accepts digests only: the build machine computes the artifact hash and sends it to the signing service, which signs, advances state, and returns the signature block — the build machine never touches the private key or the index. Verification happens in two places: a factory self-check in the release pipeline (cross-verified with an official or independent implementation’s verifier, so a home-grown implementation cannot be wrong in both signing and verifying at once), and the real verification path on target devices/updaters. State backup is its own item: the state database gets the same backup grade as the private key, but restores follow the “reserved range” rule above, with an audit reconciliation after every restore. On tool selection, prefer mature library implementations that have passed interoperability testing, pinned to a version; home-grown implementations may appear only in the cross-check verifier, never in production signing — write the state handling wrong once in production signing and the price is an entire key voided, which is not a place to practice.

Rollback and Retirement Path

Under the dual-signing structure, rollback is naturally simple: the pipeline stops issuing HBS signatures and returns to pure classical signing; already-published dual-signed packages are unaffected. Conversely, retiring the classical signature is the endgame action, gated on verifier coverage: use device check-in data to count the share of the installed base still on old verification logic, and only announce the classical signing stop date when that share reaches zero or an acceptable threshold. Final caution: LMS/XMSS are not general-purpose signature replacements — high-frequency, distributed signing scenarios like TLS and document signing are ML-DSA’s territory, not theirs. Stateful hash-based signatures belong only to scenarios that are “centrally issued, countable in number, long-lived” — and code signing happens to match all three.

Tags: Code SigningLMSXMSSSP 800-208