Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

ML-DSA signatures and a small CA

After this lesson: I can sign a file and issue a certificate with ML-DSA using OpenSSL.

70 min lesson14 commandsPost-quantum cryptography lab: ML-KEM, ML-DSA, hybrid TLS and post-quantum SSH with OpenSSL 3.5 and OpenSSH 10

What ML-DSA is and why certificates need it

ML-DSA is the post-quantum digital signature standardised in 2024. It will sign certificates, software updates and documents once quantum computers can forge today's RSA and ECDSA signatures.

A forged certificate lets an attacker pose as your bank. Signatures only need to be safe on the day they are checked, but every certificate authority has to move first.

By the end of this lesson

Note

I can sign a file and issue a certificate with ML-DSA using OpenSSL.

Key words

WordWhat it meansExample
ML-DSAthe standard post-quantum signature, built on lattices
Signaturebytes that prove who signed a message and that it is unchanged
Certificate authoritya key trusted to sign other keys' certificates
Root certificatea CA certificate that signs itself
Signing requesta file asking a CA to certify a keyshop.csr
Chaincertificates from a server back to a root

The cells students fill in are left blank in this preview.

Post-quantum signatures are much bigger

ML-DSA comes in ML-DSA-44, ML-DSA-65 and ML-DSA-87, with rising strength and size. Its signatures are kilobytes where Ed25519's are 64 bytes. Every certificate in a chain carries one signature and one public key, so a chain grows fast.

A second standard, SLH-DSA, is built only on hashes. It is slower and bigger again, and kept for when caution matters most.

Worked example: signature and key sizes

AlgorithmPublic keySignatureBroken by Shor?
Ed2551932 bytes64 bytesYes
RSA-2048256 bytes256 bytesYes
ML-DSA-441312 bytes2420 bytesNo
ML-DSA-651952 bytes3309 bytesNo
ML-DSA-872592 bytes4627 bytesNo

The cells students fill in are left blank in this preview.

Sign and check a notice

The lab wrote notice.txt, a short payment notice. The Runs make an ML-DSA-65 key pair, sign the notice and check the signature with the public key.

Then they change 480 pounds to 980 in a copy and check again. A good signature must fail on the changed copy.

Make an ML-DSA-65 key pair

Command
docker exec pq openssl genpkey -algorithm ML-DSA-65 -out signer.pem

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Copy out the public key

Command
docker exec pq openssl pkey -in signer.pem -pubout -out signer.pub

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Sign the notice

Command
docker exec pq openssl pkeyutl -sign -rawin -inkey signer.pem -in notice.txt -out notice.sig

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check the signature

Command
docker exec pq openssl pkeyutl -verify -rawin -pubin -inkey signer.pub -in notice.txt -sigfile notice.sig

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Measure the notice and its signature

Command
docker exec pq wc -c notice.txt notice.sig

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Change the amount in a copy

Command
docker exec pq sh -c "sed s/480/980/ notice.txt > changed.txt"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check the old signature on the copy

Command
docker exec pq sh -c "openssl pkeyutl -verify -rawin -pubin -inkey signer.pub -in changed.txt -sigfile notice.sig 2>/dev/null"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

What the signing Runs print

RunWhat it prints
Check the signatureSignature Verified Successfully
wc -c69 notice.txt, 3309 notice.sig, 3378 total
Check on the changed copySignature Verification Failure

The cells students fill in are left blank in this preview.

A small certificate authority

A certificate authority, or CA, signs certificates. The Runs make a root CA that signs itself with ML-DSA-65. A shop server makes its own ML-DSA-44 key and a signing request, and the CA signs it.

openssl verify then checks the shop's certificate against the root. The serial numbers are set by hand so the output is the same every time.

The CA makes its key

Command
docker exec pq openssl genpkey -algorithm ML-DSA-65 -out root.key

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

The CA signs its own certificate

Command
docker exec pq openssl req -x509 -new -key root.key -subj "/CN=Class Root CA" -days 365 -set_serial 1 -out root.crt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

The shop makes an ML-DSA-44 key

Command
docker exec pq openssl genpkey -algorithm ML-DSA-44 -out shop.key

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

The shop writes a signing request

Command
docker exec pq openssl req -new -key shop.key -subj /CN=shop.lab -out shop.csr

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

The CA issues the shop's certificate

Command
docker exec pq openssl x509 -req -in shop.csr -CA root.crt -CAkey root.key -days 90 -set_serial 1001 -out shop.crt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Verify the shop's certificate

Command
docker exec pq openssl verify -CAfile root.crt shop.crt

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Read who signed what

Command
docker exec pq sh -c "openssl x509 -in shop.crt -noout -text | grep -E 'Issuer:|Subject:|Algorithm'"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

What the CA Runs print

RunWhat it prints
Issue the certificateCertificate request self-signature ok, then subject=CN=shop.lab
Verifyshop.crt: OK
Read who signed whatSignature Algorithm: ML-DSA-65, Issuer: CN=Class Root CA, Subject: CN=shop.lab, Public Key Algorithm: ML-DSA-44, then Signature Algorithm: ML-DSA-65 again

The cells students fill in are left blank in this preview.

A common mistake

Warning

Many people think a certificate uses one algorithm. It holds two: the key it certifies and the signature its issuer made. The shop's key is ML-DSA-44, but the CA signed it with ML-DSA-65. Check both when you list what must change.

About this lab and its source: Post-quantum cryptography lab: ML-KEM, ML-DSA, hybrid TLS and post-quantum SSH with OpenSSL 3.5 and OpenSSH 10

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.