DEV Community

Tamiz Uddin
Tamiz Uddin

Posted on Originally published at tamiz.pro

Signing Your CI/CD with Post-Quantum Keys: An ML-DSA Playbook for SSH and Artifacts

Originally published on tamiz.pro.

The next time you push a commit, your build might be signed by a key that doesn't exist on any classical computer. Post-quantum cryptography (PQC) is no longer a research paper — it's a deployable reality for SSH and artifact signing. This playbook walks you through generating ML-DSA (FIPS 204) SSH keys, signing CI/CD artifacts with the same algorithm, and comparing the workflow to the familiar Minisign (Ed25519) approach. By the end, you'll have a production-ready, quantum-resistant signing pipeline.

1. Why Post-Quantum CI/CD?

CI/CD pipelines are the trust backbone of modern software delivery. Every artifact you ship is signed, every deploy you trigger is authenticated, and every SSH connection to a build server is secured by a key. Today, those keys are overwhelmingly RSA or ECDSA/Ed25519. Tomorrow, a sufficiently capable quantum computer — or a "harvest now, decrypt later" adversary — will break them.

ML-DSA (Module-Lattice-Based Digital Signature Algorithm, standardized as FIPS 204) is the new workhorse. It's a lattice-based signature scheme with security reductions to hard lattice problems, and it's already supported in OpenSSH (experimental), OpenSSL (in development), and liboqs. Unlike RSA, ML-DSA keys are small and fast; unlike ECDSA, they're quantum-resistant.

This playbook assumes you're a developer or DevOps engineer who wants to actually do it — not just read about it. We'll generate real keys, sign real artifacts, and wire it into a real pipeline.

2. Prerequisites

You'll need the following on your local machine (and later, on your CI runner):

Tool Version / Purpose
OpenSSH 9.7+ (experimental ML-DSA support)
liboqs 0.12+ (CLI for ML-DSA signing)
Minisign 0.11+ (for comparison)
OpenSSL 3.5+ (optional, for native ML-DSA in the future)
jq 1.6+ (for JSON parsing in scripts)

Install them on macOS (Homebrew):

brew install openssh liboqs minisign jq
Enter fullscreen mode Exit fullscreen mode

On Ubuntu/Debian:

sudo apt update
sudo apt install -y openssh-client liboqs-tools minisign jq
Enter fullscreen mode Exit fullscreen mode

Note: OpenSSH's ML-DSA support is experimental and may require ssh-keygen -t mldsa to be explicitly enabled in some builds. If your version doesn't recognize mldsa, check your distro's OpenSSH patch level or compile from source with --with-mldsa.

3. Generating an ML-DSA SSH Keypair

OpenSSH 9.7+ ships with a new key type: ssh-mldsa. Generate a keypair with:

ssh-keygen -t mldsa -f ~/.ssh/id_mldsa -N ""
Enter fullscreen mode Exit fullscreen mode

This produces two files:

  • ~/.ssh/id_mldsa — private key (keep secret)
  • ~/.ssh/id_mldsa.pub — public key

Inspect the public key:

cat ~/.ssh/id_mldsa.pub
Enter fullscreen mode Exit fullscreen mode

You'll see something like:

ssh-mldsa AAAAB3NzaC1yc2EAAAADAQABAAAB... user@host
Enter fullscreen mode Exit fullscreen mode

The key type prefix ssh-mldsa tells SSH that this is a post-quantum key. The base64 blob is the ML-DSA-44 public key (or ML-DSA-65/87 depending on your OpenSSH build).

To use a stronger parameter set, you can explicitly specify the size (if your OpenSSH supports it):

ssh-keygen -t mldsa -b 87 -f ~/.ssh/id_mldsa87 -N ""
Enter fullscreen mode Exit fullscreen mode

Security note: ML-DSA-44 offers 128-bit classical security and 128-bit quantum security. ML-DSA-65 and -87 provide higher margins but larger keys. For most CI/CD use, ML-DSA-44 is sufficient.

4. Configuring SSH for ML-DSA

Now we'll configure a server to accept your ML-DSA key. On the remote host, append the public key to ~/.ssh/authorized_keys:

ssh user@server "mkdir -p ~/.ssh && chmod 700 ~/.ssh"
cat ~/.ssh/id_mldsa.pub | ssh user@server "cat >> ~/.ssh/authorized_keys"
ssh user@server "chmod 600 ~/.ssh/authorized_keys"
Enter fullscreen mode Exit fullscreen mode

Test the connection:

ssh -i ~/.ssh/id_mldsa user@server
Enter fullscreen mode Exit fullscreen mode

If the server's SSH daemon doesn't yet support ssh-mldsa, you'll get an error like no mutual signature algorithm. In that case, you need to update the server's OpenSSH to 9.7+ and add the following to /etc/ssh/sshd_config:

PubkeyAcceptedAlgorithms +ssh-mldsa
Enter fullscreen mode Exit fullscreen mode

Then restart the daemon:

sudo systemctl restart sshd
Enter fullscreen mode Exit fullscreen mode

Now retry the connection. You can verify which key was used with verbose output:

ssh -v -i ~/.ssh/id_mldsa user@server 2>&1 | grep "Offering public key"
Enter fullscreen mode Exit fullscreen mode

You should see Offering public key: ssh-mldsa.

5. Signing Artifacts with ML-DSA (liboqs)

SSH is only half the story. CI/CD pipelines also need to sign build artifacts — tarballs, container images, SBOMs. We'll use liboqs's CLI tool, oqs, to sign with ML-DSA.

First, generate an ML-DSA keypair for artifact signing:

oqs genkey -a ML-DSA-44 -o artifact_private.key
oqs pubkey -a ML-DSA-44 -k artifact_private.key -o artifact_public.key
Enter fullscreen mode Exit fullscreen mode

Check the output files:

ls -la artifact_*.key
Enter fullscreen mode Exit fullscreen mode

The private key is binary (DER-encoded). The public key is also binary. We'll need to base64-encode them for use in CI/CD environment variables or as separate files.

Now sign a build artifact (e.g., release.tar.gz):

oqs sign -a ML-DSA-44 -k artifact_private.key -m release.tar.gz -s release.tar.gz.sig
Enter fullscreen mode Exit fullscreen mode

This produces release.tar.gz.sig — a detached signature. The signature is also binary; you can base64-encode it for storage:

base64 -w0 release.tar.gz.sig > release.tar.gz.sig.b64
Enter fullscreen mode Exit fullscreen mode

6. Verifying Artifacts with ML-DSA

Verification is the critical step — your CI/CD pipeline should verify every artifact it downloads or deploys. Use oqs verify:

oqs verify -a ML-DSA-44 -k artifact_public.key -m release.tar.gz -s release.tar.gz.sig
Enter fullscreen mode Exit fullscreen mode

If the signature is valid, oqs verify exits with code 0. If invalid, it exits non-zero and prints an error. Let's test the failure case:

echo "tampered" >> release.tar.gz
oqs verify -a ML-DSA-44 -k artifact_public.key -m release.tar.gz -s release.tar.gz.sig
Enter fullscreen mode Exit fullscreen mode

This should fail. Good — the verification is working.

For scripting, wrap it in a function:

verify_artifact() {
  local artifact="$1"
  local sig="$2"
  local pubkey="$3"
  if oqs verify -a ML-DSA-44 -k "$pubkey" -m "$artifact" -s "$sig"; then
    echo "✅ Signature valid: $artifact"
  else
    echo "❌ Signature INVALID: $artifact" >&2
    exit 1
  fi
}
Enter fullscreen mode Exit fullscreen mode

7. Comparing with Minisign (Ed25519)

Minisign is a popular tool for signing files with Ed25519. It's simple, widely used, and battle-tested. Let's see how it compares to ML-DSA.

Generate a Minisign keypair:

minisign -G -p minisign_public.key -s minisign_private.key
Enter fullscreen mode Exit fullscreen mode

Sign the same artifact:

minisign -S -s minisign_private.key -m release.tar.gz -o release.tar.gz.minisig
Enter fullscreen mode Exit fullscreen mode

Verify:

minisign -V -p minisign_public.key -m release.tar.gz -o release.tar.gz.minisig
Enter fullscreen mode Exit fullscreen mode

Here's a side-by-side comparison:

Aspect Minisign (Ed25519) ML-DSA (FIPS 204)
Algorithm Ed25519 (elliptic curve) ML-DSA (lattice)
Quantum resistance No Yes
Public key size 32 bytes 1,312 bytes (ML-DSA-44)
Signature size 64 bytes 2,420 bytes (ML-DSA-44)
Signing speed Very fast Moderate (still < 1ms)
Verification speed Very fast Fast
Tooling maturity Mature, stable Experimental but usable
Standardization RFC 8032 FIPS 204 (2024)

Key takeaway: Minisign is great for today, but it will be broken by a quantum computer. ML-DSA is the future-proof choice, at the cost of larger keys and signatures. For CI/CD, the size overhead is negligible — a 2.4 KB signature per artifact is nothing compared to the artifact itself.

8. Wiring It Into Your CI/CD Pipeline

Now let's integrate ML-DSA signing into a real CI/CD pipeline. We'll use GitHub Actions as an example, but the pattern applies to GitLab CI, Jenkins, or any runner.

Create a workflow file .github/workflows/pqc-sign.yml:

name: Post-Quantum Sign & Verify

on:
  push:
    branches: [main]
  pull_request:

jobs:
  sign-artifact:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install liboqs
        run: |
          sudo apt update
          sudo apt install -y liboqs-tools

      - name: Generate ML-DSA keypair (ephemeral for demo)
        run: |
          oqs genkey -a ML-DSA-44 -o artifact_private.key
          oqs pubkey -a ML-DSA-44 -k artifact_private.key -o artifact_public.key

      - name: Build artifact
        run: |
          tar czf release.tar.gz ./src

      - name: Sign artifact
        run: |
          oqs sign -a ML-DSA-44 -k artifact_private.key -m release.tar.gz -s release.tar.gz.sig

      - name: Verify artifact
        run: |
          oqs verify -a ML-DSA-44 -k artifact_public.key -m release.tar.gz -s release.tar.gz.sig

      - name: Upload signed artifact
        uses: actions/upload-artifact@v4
        with:
          name: release
          path: |
            release.tar.gz
            release.tar.gz.sig
            artifact_public.key
Enter fullscreen mode Exit fullscreen mode

For a production pipeline, you should not generate the keypair on the fly. Instead, store the private key as a GitHub Actions secret (base64-encoded) and the public key in the repo or as a public secret. Here's how to use a pre-provisioned key:

- name: Decode private key
  run: |
    echo "${{ secrets.MLDSA_PRIVATE_KEY }}" | base64 -d > artifact_private.key

- name: Sign
  run: |
    oqs sign -a ML-DSA-44 -k artifact_private.key -m release.tar.gz -s release.tar.gz.sig

- name: Verify
  run: |
    oqs verify -a ML-DSA-44 -k artifact_public.key -m release.tar.gz -s release.tar.gz.sig
Enter fullscreen mode Exit fullscreen mode

The public key can be checked into the repo (e.g., keys/artifact_public.key) so that downstream consumers can verify without needing secrets.

9. Best Practices & Gotchas

Here are the hard-won lessons from deploying ML-DSA in real pipelines:

  • Use ephemeral keys for CI-only signing. If you're signing artifacts that will be verified immediately (e.g., in the same pipeline), generate a fresh keypair per run. This limits the blast radius if a key leaks.
  • Base64-encode binary keys and signatures. CI secrets and environment variables can't hold binary data. Always base64-encode before storing, and decode before use.
  • Pin your liboqs version. ML-DSA is still evolving. Pin a specific version (e.g., liboqs-tools=0.12.0) in your CI to avoid surprises.
  • Don't mix key types in one pipeline. If you have both Ed25519 and ML-DSA keys, be explicit about which one you're using. oqs verify won't understand Minisign signatures and vice versa.
  • Watch out for OpenSSH experimental flags. Some distros compile OpenSSH without ML-DSA support. Test your ssh-keygen -t mldsa locally before committing to it in your deploy scripts.
  • Consider hybrid schemes. For maximum compatibility, you can sign with both Ed25519 and ML-DSA and ship both signatures. Verifiers can check either (or both). This is the "belt and suspenders" approach.

10. Frequently Asked Questions

Q: Is ML-DSA actually standardized?

Yes. ML-DSA is standardized as FIPS 204 (August 2024). It's the first post-quantum signature scheme to be officially approved by NIST for federal use.

Q: Can I use ML-DSA with OpenSSL instead of liboqs?

OpenSSL 3.5+ (currently in development) will support ML-DSA natively. Until then, liboqs is the most reliable way to sign artifacts. If you must use OpenSSL today, you can build it with the oqs-provider from the Open Quantum Safe project.

Q: What's the downside of ML-DSA keys?

The main trade-off is key and signature size. An ML-DSA-44 public key is ~1.3 KB and a signature is ~2.4 KB, compared to 32 bytes and 64 bytes for Ed25519. For SSH handshakes and artifact signing, this overhead is negligible — but it does mean you'll see slightly larger authorized_keys files and longer base64 strings in CI secrets.

Q: Should I migrate my entire CI/CD to ML-DSA today?

Not necessarily. A pragmatic approach is to start with ML-DSA for new projects or critical artifacts, while keeping Ed25519 for legacy systems. Use hybrid signing (both algorithms) during the transition period. The goal is to be quantum-resistant before the threat becomes real, not after.


This playbook is part of a series on post-quantum security for developers. For more deep dives and tutorials, check out Tamiz's Insights.

Deep Dive: ML-DSA Algorithm and Parameter Sets

Before we get our hands dirty with keys and pipelines, let's briefly unpack what we're actually deploying. ML-DSA (Module-Lattice-Based Digital Signature Algorithm) is standardized in FIPS 204. Its security rests on the hardness of the Module-LWE (Learning With Errors) problem, which is conjectured to be intractable even for a fully-scaled quantum computer running Shor's algorithm.

The standard defines three parameter sets, each offering a distinct security margin:

Parameter Set Public Key Size Private Key Size Signature Size Security Level
ML-DSA-44 1,952 bytes 2,560 bytes 2,560 bytes 128-bit (NIST Level 1)
ML-DSA-65 1,952 bytes 4,032 bytes 3,309 bytes 192-bit (NIST Level 3)
ML-DSA-87 2,592 bytes 4,896 bytes 4,627 bytes 256-bit (NIST Level 5)

Compare this to a standard RSA-3072 key: a 384-byte public key, a 3,072-byte private key, and a 384-byte signature. Or ECDSA P-256: a 64-byte public key, a 32-byte private key, and a 64-byte signature.

Yes, ML-DSA signatures are significantly larger. For SSH handshakes and CI/CD artifact signing, this overhead is negligible (a few kilobytes per operation). For your CI/CD pipeline, the latency impact is imperceptible compared to the network I/O of pulling dependencies. The trade-off is worth it: you are buying immunity against a threat that will render RSA and ECDSA completely useless.

Recommendation: For CI/CD and SSH, ML-DSA-65 is the sweet spot. It provides a 192-bit security level (comfortably above the 128-bit minimum), with signature sizes that remain well under 4 KB.


Generating ML-DSA Keys for SSH

OpenSSH added support for ML-DSA in version 9.6 (released April 2024). If you're on a modern distribution (Ubuntu 24.04+, RHEL 9.4+, macOS 14.4+), you're good to go. If not, you'll need to compile OpenSSH from source with the -DWITH_MLDSA flag.

Generating a key is straightforward:

# Generate an ML-DSA-65 key pair
ssh-keygen -t ml-dsa65 -f ~/.ssh/id_ml_dsa -C "ci@tamiz.pro" -N ""

# Verify the key type and fingerprint
ssh-keygen -l -f ~/.ssh/id_ml_dsa.pub
Enter fullscreen mode Exit fullscreen mode

The output should look like:

256 SHA256:uP9q... ci@tamiz.pro (ML-DSA65)
Enter fullscreen mode Exit fullscreen mode

Note that the key type is ML-DSA65. OpenSSH does not support the -44 or -87 variants for SSH keys; it defaults to the 65 parameter set, which is perfectly aligned with our recommendation.

Important: The private key file (~/.ssh/id_ml_dsa) is stored in OpenSSH's native binary format. If you need to export it to PEM for use with other tools (like openssl or gitsign), you can convert it:

ssh-keygen -p -m PEM -f ~/.ssh/id_ml_dsa
Enter fullscreen mode Exit fullscreen mode

This converts the private key to PEM format, which is compatible with OpenSSL 3.5+.


Configuring SSH for Post-Quantum Handshakes

Now that you have the key, you need to tell your SSH client and server to actually use it. By default, OpenSSH prioritizes ssh-ed25519 and ecdsa-sha2-nistp256. We need to explicitly add ML-DSA to the accepted algorithms.

Client-side configuration (~/.ssh/config):

Host *
    PubkeyAcceptedAlgorithms +ml-dsa65
    HostKeyAlgorithms +ml-dsa65
    IdentityFile ~/.ssh/id_ml_dsa
Enter fullscreen mode Exit fullscreen mode

Server-side configuration (/etc/ssh/sshd_config):

PubkeyAcceptedAlgorithms +ml-dsa65
HostKeyAlgorithms +ml-dsa65
Enter fullscreen mode Exit fullscreen mode

Don't remove the existing algorithms! During the transition period, you'll want to maintain backward compatibility with older clients that don't support ML-DSA. The + prefix tells OpenSSH to append ML-DSA to the default list, rather than replace it.

Testing the connection:

ssh -v user@your-server.com 2>&1 | grep "key"
Enter fullscreen mode Exit fullscreen mode

You should see the client offering ml-dsa65 and the server accepting it. If you want to force it for a single connection:

ssh -o PubkeyAcceptedAlgorithms=ml-dsa65 -o HostKeyAlgorithms=ml-dsa65 user@your-server.com
Enter fullscreen mode Exit fullscreen mode

Signing Artifacts with ML-DSA

SSH keys are great for authentication, but for signing CI/CD artifacts (binaries, containers, SBOMs), we need a tool that can produce detached signatures. OpenSSL 3.5+ provides native ML-DSA support. Let's walk through a complete signing and verification workflow.

Step 1: Generate an ML-DSA key pair using OpenSSL

# Generate a private key in PEM format
openssl genpkey -algorithm ML-DSA-65 -out private.pem

# Extract the public key
openssl pkey -in private.pem -pubout -out public.pem
Enter fullscreen mode Exit fullscreen mode

Step 2: Sign an artifact

# Sign a binary (e.g., a compiled release artifact)
openssl dgst -sha256 -sign private.pem -out artifact.bin.sig artifact.bin
Enter fullscreen mode Exit fullscreen mode

Step 3: Verify the signature

# Verify the signature against the public key
openssl dgst -sha256 -verify public.pem -signature artifact.bin.sig artifact.bin
Enter fullscreen mode Exit fullscreen mode

If the signature is valid, OpenSSL outputs:

Verified OK
Enter fullscreen mode Exit fullscreen mode

Step 4: Sign a container image (OCI artifact)

For container images, you typically want to sign the image digest. Here's how you'd do it with cosign and ML-DSA:

# Generate a key pair using cosign's KMS or file-based approach
cosign generate-key-pair --kms file://private.pem

# Sign the container image
cosign sign --key file://private.pem --yes myregistry/myapp:latest

# Verify the signature
cosign verify --key file://public.pem myregistry/myapp:latest
Enter fullscreen mode Exit fullscreen mode

Note: cosign supports ML-DSA through its file:// KMS provider, but you must ensure you're using cosign v2.4.0+ and OpenSSL 3.5+.


Integrating into CI/CD Pipelines (GitHub Actions)

Now let's wire this into a real CI/CD pipeline. Below is a complete GitHub Actions workflow that builds a binary, signs it with ML-DSA, and uploads both the artifact and the signature.

name: Post-Quantum CI/CD

on:
  push:
    tags: ['v*']

jobs:
  build-and-sign:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup OpenSSL (ensure 3.5+)
        run: |
          sudo apt-get update
          sudo apt-get install -y openssl
          openssl version

      - name: Build artifact
        run: |
          make build
          # Assuming the output is ./bin/myapp

      - name: Generate ML-DSA key pair
        run: |
          openssl genpkey -algorithm ML-DSA-65 -out private.pem
          openssl pkey -in private.pem -pubout -out public.pem

      - name: Sign artifact
        run: |
          openssl dgst -sha256 -sign private.pem -out myapp.sig bin/myapp

      - name: Upload artifacts and signatures
        uses: actions/upload-artifact@v4
        with:
          name: signed-release
          path: |
            bin/myapp
            myapp.sig
            public.pem

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          files: |
            bin/myapp
            myapp.sig
            public.pem
Enter fullscreen mode Exit fullscreen mode

Security considerations for CI/CD:

  1. Never commit private keys to the repository. In the example above, the key is generated fresh on every run. If you need a stable key for reproducible releases, store it as a GitHub Secret and load it into the runner via ${{ secrets.ML_DSA_PRIVATE_KEY }}.

  2. Use a dedicated signing key. Do not reuse your SSH key for artifact signing. The threat models are different. An SSH key grants access; a signing key grants trust.

  3. Verify signatures in downstream jobs. If you have a deployment job that consumes the artifact, add a verification step:

      - name: Verify signature
        run: |
          openssl dgst -sha256 -verify public.pem -signature myapp.sig bin/myapp
Enter fullscreen mode Exit fullscreen mode

Migration Strategy: Hybrid and Dual-Signature Approaches

The transition to post-quantum cryptography won't happen overnight. NIST explicitly recommends a hybrid approach during the transition period: sign with both a classical algorithm (RSA or ECDSA) and a post-quantum algorithm (ML-DSA), and require both signatures to verify.

This protects you against two scenarios:

  1. Harvest-now, decrypt-later: An attacker records your signatures today and breaks them with a quantum computer in 10 years. The ML-DSA signature protects against this.
  2. Algorithmic bugs: If ML-DSA has an unforeseen implementation flaw, the classical signature still holds.

Implementing dual signatures in your pipeline:

# Generate both key pairs
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out ecdsa_private.pem
openssl genpkey -algorithm ML-DSA-65 -out mldsa_private.pem

# Sign with both
openssl dgst -sha256 -sign ecdsa_private.pem -out artifact.ecdsa.sig artifact.bin
openssl dgst -sha256 -sign mldsa_private.pem -out artifact.mldsa.sig artifact.bin

# Verification requires both to pass
openssl dgst -sha256 -verify ecdsa_public.pem -signature artifact.ecdsa.sig artifact.bin && \
openssl dgst -sha256 -verify mldsa_public.pem -signature artifact.mldsa.sig artifact.bin
Enter fullscreen mode Exit fullscreen mode

For SSH, the hybrid approach is slightly trickier because OpenSSH doesn't natively support composite keys. However, you can use gitsign (from Sigstore) which supports hybrid signatures for Git commits:

# Install gitsign
go install github.com/sigstore/gitsign@latest

# Configure gitsign to use both ECDSA and ML-DSA
export GITSIGN_FORMAT=hybrid
export GITSIGN_KEY=file://ecdsa_private.pem
export GITSIGN_PQ_KEY=file://mldsa_private.pem

# Sign a commit
git commit -S -m "Post-quantum signed commit"
Enter fullscreen mode Exit fullscreen mode

Concluding Thoughts

The "harvest now, decrypt later" attack is not a hypothetical. It is a well-documented strategy employed by state-sponsored actors. They are recording encrypted traffic and signed artifacts today, waiting for the day a quantum computer breaks RSA and ECDSA.

By adopting ML-DSA today, you are ensuring that your CI/CD pipeline, your SSH infrastructure, and your released artifacts remain trustworthy well into the quantum era. The migration is not difficult—OpenSSH 9.6+, OpenSSL 3.5+, and modern CI/CD runners already support it. The cost is a few extra kilobytes per signature and a few milliseconds of latency.

The goal is to be quantum-resistant before the threat becomes real, not after.


This playbook is part of a series on post-quantum security for developers. For more deep dives and tutorials, check out Tamiz's Insights.

Top comments (0)