Dev.to Security šŸ” Cybersecurity šŸ‘ 0 šŸ“– 10 min read

Is your stack post-quantum ready? A hands-on checklist with real outputs

In Part 1 I went through the "AI broke post-quantum crypto" story and why it's not a reason to panic. The takeaway was simple: keep migrating, use hybrid, and you're probably already using it. This part is the hands-on

Is your stack post-quantum ready? A hands-on checklist with real outputs

In Part 1 I went through the "AI broke post-quantum crypto" story and why it's not a reason to panic. The takeaway was simple: keep migrating, use hybrid, and you're probably already using it.

This part is the hands-on version. Every command below ran on my laptop, and every output and number is real. By the end you'll know exactly where your SSH, your websites, your code and your signatures stand, plus a script that checks all of it in one go.

What you need: OpenSSL 3.5+ and OpenSSH 9.0+. Check with openssl version and ssh -V. Most current Linux distros and macOS (via Homebrew) already have both.

Check 1: SSH (2 minutes)

Part 1 showed the quick test. Here it is again, because it's the fastest win:

ssh -v -T [email protected] 2>&1 | grep "kex: algorithm"

If you see mlkem768x25519-sha256 or sntrup761x25519-sha512, that connection is post-quantum. OpenSSH 10 uses ML-KEM by default, so for most people this is already done.

Want to enforce it on your own server? Add this to /etc/ssh/sshd_config:

KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,[email protected]

Then test the config and reload:

sudo sshd -t && sudo systemctl reload ssh

(The service is called sshd instead of ssh on Fedora and RHEL.)

āš ļø Keep your current session open and test a new login from a second terminal before you log out. Clients older than OpenSSH 8.5 won't be able to connect anymore. That's the point, but make sure none of them are yours.

Check 2: HTTPS (5 minutes)

This command tells you which key exchange a site actually negotiates when your client offers the hybrid post-quantum group:

echo | openssl s_client -connect cloudflare.com:443 -groups X25519MLKEM768:X25519 2>/dev/null \
  | grep -E "Negotiated TLS1.3 group|Peer Temp Key"

I ran it against eight big sites:

Table of 8 sites: 5 negotiate X25519MLKEM768, GitHub, Amazon and Wikipedia use classical X25519

Five of eight already speak post-quantum. Fun detail: GitHub's SSH is post-quantum (that's where git push happens), but its HTTPS isn't yet.

Turn it on in nginx: one line

If your nginx is linked against OpenSSL 3.5+ (check with nginx -V), add one line to your server block:

ssl_ecdh_curve X25519MLKEM768:X25519;

The hybrid group needs TLS 1.3, which every modern client speaks. The order matters: modern clients get the hybrid post-quantum group, older ones fall back to plain X25519, and nobody gets locked out. I tested it on a local nginx 1.30:

nginx with ssl_ecdh_curve X25519MLKEM768:X25519 negotiates the hybrid group, old clients fall back to X25519

If your stack is Go (Caddy, Traefik and friends), you get X25519MLKEM768 by default from Go 1.24 on.

Check 3: your own code (10 minutes)

Most apps never touch key exchange directly, because TLS does it for you. But if you build protocols, encrypt files or design APIs, here is ML-KEM in the standard library of two popular languages. Same idea in both: Alice publishes a public key, Bob uses it to create a shared secret plus a ciphertext, and Alice opens the ciphertext to get the same secret.

Node.js (built-in node:crypto, tested on Node 25.6):

// ML-KEM-768 key exchange with Node.js built-in crypto (tested on Node 25.6)
import { generateKeyPairSync, encapsulate, decapsulate } from 'node:crypto';

// Alice creates a key pair and sends her public key to Bob
const { publicKey, privateKey } = generateKeyPairSync('ml-kem-768');

// Bob uses Alice's public key to create a shared secret + a ciphertext
const { sharedKey: bobSecret, ciphertext } = encapsulate(publicKey);

// Alice opens the ciphertext with her private key and gets the same secret
const aliceSecret = decapsulate(privateKey, ciphertext);

console.log('public key :', publicKey.export({ format: 'der', type: 'spki' }).length, 'bytes (DER)');
console.log('ciphertext :', ciphertext.length, 'bytes');
console.log('secret     :', bobSecret.toString('hex').slice(0, 32) + '...');
console.log('match      :', bobSecret.equals(aliceSecret));

Go (standard library crypto/mlkem, Go 1.24+):

// ML-KEM-768 key exchange with Go's standard library (Go 1.24+)
package main

import (
    "bytes"
    "crypto/mlkem"
    "fmt"
)

func main() {
    // Alice creates a key pair and sends her public key to Bob
    alice, err := mlkem.GenerateKey768()
    if err != nil {
        panic(err)
    }
    pub := alice.EncapsulationKey()

    // Bob creates a shared secret + a ciphertext from Alice's public key
    bobSecret, ciphertext := pub.Encapsulate()

    // Alice opens the ciphertext and gets the same secret
    aliceSecret, err := alice.Decapsulate(ciphertext)
    if err != nil {
        panic(err)
    }

    fmt.Println("public key :", len(pub.Bytes()), "bytes")
    fmt.Println("ciphertext :", len(ciphertext), "bytes")
    fmt.Printf("secret     : %x...\n", bobSecret[:16])
    fmt.Println("match      :", bytes.Equal(bobSecret, aliceSecret))
}

Both print match: true:

Node and Go ML-KEM-768 demos both print match: true

Note the sizes: a 1,184-byte public key and a 1,088-byte ciphertext. An X25519 public key is 32 bytes. Post-quantum keys are bigger, but for key exchange the cost is small, as you'll see next.

āš ļø In real systems, combine this with a classical key exchange (hybrid), like TLS and SSH already do. Don't replace X25519 with ML-KEM alone.

The benchmark: is post-quantum slow?

This is the question I get most, so I measured it. Same laptop (an Intel Core i5-8350U), same OpenSSL 3.6.5, one core:

openssl speed -seconds 2 rsa2048 ecdhx25519 ed25519 ML-KEM-768 ML-DSA-65 ML-DSA-87

Key exchange: post-quantum wins.

Benchmark: ML-KEM-768 key generation 18,650/s vs RSA-2048 18/s; handshake server side 18,099/s vs 1,700/s

ML-KEM-768 generates key pairs about 1,000 times faster than RSA-2048, and the server side of a handshake is about 10 times faster. Only X25519 is quicker, and hybrid TLS runs both anyway.

Signatures: here's the real cost.

Benchmark: ML-DSA-65 signs slower than Ed25519 and RSA, and its signature is 3,309 bytes vs 64 for Ed25519

On my machine ML-DSA-65 signs slower than RSA-2048 and Ed25519, and its signatures are about 50 times bigger than Ed25519's. This is why certificates and code signing are the slow part of the migration. Not broken math: bigger certificate chains, more bytes in every handshake, and a lot of hardware that was never designed for that.

The X trick: sign messages you can actually verify

You've probably seen "post-quantum signed messages" going around on X: a block of text, a giant signature, and no public key. Looks cool, but nobody can verify it, so it proves nothing.

Here's a small script, pq-sign.sh, that does it properly with ML-DSA. It creates a key pair, signs any text file in a readable "armored" format, and verifies it. Lines that start with - are escaped, so a message can't fake the signature markers.

pq-sign.sh signs Hello World with ML-DSA-65, verifies it, then rejects a tampered copy

Change one character and verification fails. Share your pub.pem (never key.pem), and anyone can check that the message really came from you.

pq-sign.sh (click to expand)
#!/usr/bin/env bash
# pq-sign.sh - post-quantum signed messages you can actually verify (ML-DSA)
#
#   ./pq-sign.sh keygen [ML-DSA-44|ML-DSA-65|ML-DSA-87]   -> key.pem (secret) + pub.pem (share it)
#   ./pq-sign.sh sign   key.pem message.txt > message.asc
#   ./pq-sign.sh verify pub.pem message.asc
#
# Needs OpenSSL 3.5+. Lines starting with "-" are escaped as "- -" in the
# armor (like PGP), so a message can't fake the signature markers.

set -euo pipefail

BEGIN_MSG='-----BEGIN POST-QUANTUM SIGNED MESSAGE-----'
BEGIN_SIG='-----BEGIN POST-QUANTUM SIGNATURE-----'
END_SIG='-----END POST-QUANTUM SIGNATURE-----'

die() { echo "pq-sign: $*" >&2; exit 1; }
tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT

fingerprint() {   # SHA-256 of the public key, like SSH fingerprints
  openssl pkey -pubin -in "$1" -outform DER 2>/dev/null \
    | openssl dgst -sha256 -binary | base64 | tr -d '='
}

case ${1:-} in
  keygen)
    alg=${2:-ML-DSA-65}
    [[ -e key.pem ]] && die "key.pem already exists, not overwriting it"
    openssl genpkey -algorithm "$alg" -out key.pem
    chmod 600 key.pem
    openssl pkey -in key.pem -pubout -out pub.pem
    echo "Created key.pem (keep it secret) and pub.pem (share it)."
    echo "Fingerprint: SHA256:$(fingerprint pub.pem)"
    ;;

  sign)
    [[ $# -eq 3 ]] || die "usage: $0 sign key.pem message.txt"
    key=$2; msg=$3
    # Normalize: the signed text always ends with exactly one newline.
    { cat "$msg"; [[ -z $(tail -c1 "$msg") ]] || echo; } > "$tmp/msg"
    openssl pkey -in "$key" -pubout -out "$tmp/pub.pem"
    alg=$(openssl pkey -in "$key" -noout -text 2>/dev/null | grep -m1 -oE 'ML-DSA-[0-9]+' || true)
    alg=${alg:-ML-DSA}
    openssl pkeyutl -sign -inkey "$key" -in "$tmp/msg" -rawin -out "$tmp/sig"
    echo "$BEGIN_MSG"
    echo "Algorithm: $alg"
    echo "Key-Fingerprint: SHA256:$(fingerprint "$tmp/pub.pem")"
    echo
    sed 's/^-/- -/' "$tmp/msg"
    echo "$BEGIN_SIG"
    base64 -w 64 "$tmp/sig"
    echo "$END_SIG"
    ;;

  verify)
    [[ $# -eq 3 ]] || die "usage: $0 verify pub.pem message.asc"
    pub=$2; asc=$3
    grep -qxF -- "$BEGIN_MSG" "$asc" || die "not a post-quantum signed message"
    # Message: after the first blank line, up to the signature marker.
    awk -v b="$BEGIN_SIG" '
      body && $0 == b { exit }
      body { sub(/^- /, ""); print }
      !body && $0 == "" { body = 1 }' "$asc" > "$tmp/msg"
    awk -v b="$BEGIN_SIG" -v e="$END_SIG" '
      $0 == e { exit } s { print } $0 == b { s = 1 }' "$asc" | base64 -d > "$tmp/sig"
    want=$(grep -m1 '^Key-Fingerprint:' "$asc" | sed 's/.*SHA256://')
    have=$(fingerprint "$pub")
    [[ -z $want || $want == "$have" ]] || die "signed with a different key (SHA256:$want)"
    if openssl pkeyutl -verify -pubin -inkey "$pub" -in "$tmp/msg" -rawin \
         -sigfile "$tmp/sig" >/dev/null 2>&1; then
      echo "āœ… Good signature from SHA256:$have"
      echo "---"
      cat "$tmp/msg"
    else
      echo "āŒ BAD signature: the message or the signature was changed" >&2
      exit 1
    fi
    ;;

  *)
    sed -n '2,8p' "$0" | sed 's/^# \{0,1\}//'
    exit 1
    ;;
esac

Bonus: check everything with one script

pq-check.sh puts all of the above in one place. It checks your local OpenSSL and OpenSSH, then the key exchange each server actually negotiates, over TLS or SSH. It never logs in, never offers your SSH keys and never changes anything.

./pq-check.sh yoursite.com api.yoursite.com ssh://yourserver

pq-check.sh output: 5 post-quantum, 2 classical-only

It exits with code 1 if anything is classical-only, so you can drop it into a CI job or a cron check.

pq-check.sh (click to expand)
#!/usr/bin/env bash
# pq-check.sh - is your stack post-quantum ready?
#
# Checks your local tools, then the key exchange that each server actually
# negotiates. Read-only: it never logs in and never changes any config.
#
# Usage:
#   ./pq-check.sh example.com                 # TLS on port 443
#   ./pq-check.sh example.com:8443            # TLS on another port
#   ./pq-check.sh ssh://github.com            # SSH on port 22
#   ./pq-check.sh ssh://myserver:2222         # SSH on another port
#
# Needs: OpenSSL 3.5+ and OpenSSH 9.0+ on this machine.

set -uo pipefail

PQ_KEX='mlkem768x25519-sha256|mlkem768nistp256-sha256|mlkem1024nistp384-sha384|sntrup761x25519-sha512'
PQ_TLS='MLKEM'
TIMEOUT=10
pass=0; fail=0

if [[ -t 1 ]]; then G=$'\033[32m' R=$'\033[31m' N=$'\033[0m'; else G='' R='' N=''; fi
ok()  { printf '  %sāœ… %s%s\n' "$G" "$*" "$N"; pass=$((pass+1)); }
bad() { printf '  %sāŒ %s%s\n' "$R" "$*" "$N"; fail=$((fail+1)); }

check_local() {
  echo "Local tools"
  local v
  v=$(openssl version 2>/dev/null | awk '{print $2}')
  if openssl list -kem-algorithms 2>/dev/null | grep -qi 'ML-KEM-768'; then
    ok "OpenSSL $v supports ML-KEM"
  else
    bad "OpenSSL ${v:-not found} has no ML-KEM (needs 3.5+)"
  fi
  v=$(ssh -V 2>&1 | awk -F'[_ ,]' '{print $2}')
  if ssh -Q kex 2>/dev/null | grep -qE "$PQ_KEX"; then
    ok "OpenSSH $v supports post-quantum key exchange"
  else
    bad "OpenSSH ${v:-not found} has no post-quantum key exchange (needs 9.0+)"
  fi
}

check_tls() {
  local host=${1%%:*} port=443 out group
  [[ $1 == *:* ]] && port=${1##*:}
  echo "TLS  $host:$port"
  out=$(echo | timeout "$TIMEOUT" openssl s_client -connect "$host:$port" -servername "$host" \
          -groups X25519MLKEM768:X25519:secp256r1 2>/dev/null)
  group=$(grep -E 'Negotiated TLS1.3 group|Peer Temp Key' <<<"$out" | head -1 \
          | sed -E 's/.*group: //; s/Peer Temp Key: //; s/, [0-9]+ bits//')
  if [[ -z $group ]]; then
    bad "no TLS answer"
  elif [[ $group == *$PQ_TLS* ]]; then
    ok "$group (hybrid post-quantum)"
  else
    bad "$group (classical only)"
  fi
}

check_ssh() {
  local target=${1#ssh://} host port=22 kex
  target=${target#*@}
  host=${target%%:*}
  [[ $target == *:* ]] && port=${target##*:}
  echo "SSH  $host:$port"
  # Only the key exchange runs: no keys are offered and no password is tried.
  kex=$(timeout "$TIMEOUT" ssh -v -p "$port" \
          -o BatchMode=yes -o ConnectTimeout="$TIMEOUT" \
          -o PubkeyAuthentication=no -o PasswordAuthentication=no \
          -o KbdInteractiveAuthentication=no -o GSSAPIAuthentication=no \
          -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
          "probe@$host" true 2>&1 | tr -d '\r' | grep -m1 'kex: algorithm:' | awk '{print $NF}')
  if [[ -z $kex ]]; then
    bad "no SSH answer"
  elif grep -qE "^($PQ_KEX)" <<<"$kex"; then
    ok "$kex (post-quantum)"
  else
    bad "$kex (classical only)"
  fi
}

check_local
for t in "$@"; do
  echo
  case $t in
    ssh://*) check_ssh "$t" ;;
    *)       check_tls "$t" ;;
  esac
done

echo
printf 'Result: %d post-quantum āœ…  %d not yet āŒ\n' "$pass" "$fail"
[[ $fail -eq 0 ]]

What NOT to do

  • Don't write your own crypto. Use OpenSSL, your language's standard library, or your TLS stack. Everything above uses built-in code.
  • Don't drop classical crypto. Use hybrid (X25519MLKEM768, mlkem768x25519-sha256). If one side ever gets broken, the other still protects you. That's exactly what the experts recommended after this week's news.
  • Don't swap your TLS certificates yet. Post-quantum certificates aren't broadly supported by browsers and CAs yet. Cloudflare plans its first ones for early 2027. Key exchange is the part to fix today, because that's what protects you from "harvest now, decrypt later."
  • Don't hardcode one algorithm. Make it a config value. The lesson of 2026 is that assumptions can change fast.

Your checklist

  • [ ] ssh -V shows OpenSSH 10+, and your servers negotiate mlkem768x25519-sha256
  • [ ] Your sites negotiate X25519MLKEM768 (one line in nginx, default in Go)
  • [ ] OpenSSL 3.5+ on your servers and CI images
  • [ ] New code uses hybrid key exchange, never ML-KEM alone
  • [ ] Crypto algorithms are configurable, not hardcoded
  • [ ] You know your signature-size budget before moving to ML-DSA

Your turn: run pq-check.sh on your own domains and drop your score in the comments. How many āœ… did you get?

This is Part 2 of "Post-Quantum, No Panic". Part 1: Did AI just break post-quantum encryption? No. Here's what actually happened.

šŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.