Abstract

In October I said farewell to tic-tac-toe. In December the NSA told the nation to get its post-quantum house in order, eight bug reports landed on the one part of the game that is post-quantum, and a series I’d closed was open again. Fittingly for 2026, there’s AI on every side of the table.

About 13 minutes

  • What you’ll learn: why RSA’s days are numbered, what the NSA actually asked for, eight quiet ways a Java security provider can break its contract, and how to tell when the right fix is the delete key.
  • Here for the punchline? An offer we can’t refuse has the NSA and the twist, and Who codes anymore? has the ending.
  • Here for the code? Eight ways to break a contract, then Fixing it anyway.

Ship's glossary

  • RSA — the public-key system most of the internet grew up on. Its security rests on how hard it is to factor a very large number.
  • KEM — a key encapsulation mechanism: a way to hand someone a fresh secret key in a locked box only they can open. ML-KEM (Kyber) is the post-quantum one.
  • Harvest now, decrypt later — recording encrypted traffic today, to read the day a quantum computer can break it.
  • CNSA 2.0 — the NSA’s list of algorithms national security systems must move to. For key exchange, that’s ML-KEM-1024.
  • SPI — a service provider interface: the socket in the JDK’s security architecture that lets KEM.getInstance("Kyber") find code the JDK didn’t ship.

Quote

”Just when I thought I was out, they pull me back in.” — Michael Corleone, The Godfather Part III (1990)

Welcome back to the series that won’t stay finished.

Previously, on Farewell Tic-Tac-Toe, I closed the book. Alpha had its homework marked, Beta had found its colour, and the booth was being reassigned to a million words of specifications. I meant it. I even renamed a repository so it wouldn’t have tic-tac-toe in its name.

Then December happened, and two envelopes arrived in as many days.

Quote

In the quiet after JDK 25, our weathered developer has hung up his keyboard. The war rig is parked, the side quests are done, and the only thing left on the table is a long-finished game of noughts and crosses.

Then a knock at the door. An envelope: eight issues, each politely noting it was “drafted with AI assistance”.

Behind it, a second envelope, this one with an eagle on the seal. Post-quantum. Immediately.

He looks at the board. He looks at the envelopes. He sighs and opens the IDE.

”It’s not personal,” he mutters. “It’s strictly business.”

The joke that stopped being one

Back in JDK 21, I wrote that SSL/TLS simply wasn’t strong enough to protect our game of tic-tac-toe in the post-quantum era, and fitted it with Kyber. In JDK 24 I asked whether you’d ever been anxious about someone quantum-hacking your noughts and crosses. Me neither.

It was a joke. As of this week, it’s US government guidance.

Why RSA had to go

RSA is a padlock built on a lopsided bit of maths: multiplying two huge primes is easy, and working back from the product to the primes is, for an ordinary computer, hopeless. Elliptic curves rest on a different problem with the same weakness. Shor’s algorithm gives a large enough quantum computer a shortcut through both.

Nobody has that machine. Yet. But the estimates of how big it needs to be only ever go one way. In 2019, breaking RSA-2048 was estimated to need about twenty million noisy qubits. In 2025, Craig Gidney brought that down to under a million, running for under a week1. That’s a twentyfold drop in six years, and the hardware is growing to meet it.

The bit that should keep you up at night is that you don’t have to wait for the machine to be in trouble. Adversaries can record encrypted traffic today and decrypt it later, and the NSA says they already are2. Anything that has to stay secret for longer than the time it takes to build a quantum computer is already exposed.

For the record: if anyone has been recording my games since 2024, waiting for the day, I’ll save them the trouble. X opened in the centre. Every time. The bots are no fools.

This is why the game has never used RSA to exchange keys. As we saw in JDK 24, a KEM is like exchanging a locked box with a secret inside: one side locks a fresh key in the box, the other side unlocks it, and the key encrypts everything after that. With ML-KEM, the lock is a lattice problem instead of factoring, and Shor’s shortcut doesn’t apply.

An offer we can’t refuse

On 2 December, the NSA told the owners, operators and vendors of National Security Systems to immediately accelerate their move to post-quantum cryptography2. Prioritise CNSA 2.0, inventory where your cryptography lives, and put quantum-resistant firmware signatures and hardware roots of trust first, because those are the parts you can’t easily change after you’ve bought them3. The deadlines were already on the books: new national security systems must support quantum-resistant algorithms from 2027, and legacy systems that can’t are out by 20304.

None of that would surprise anyone who’s been following along. What surprised me was the trigger. It wasn’t a quantum computer. The advisory credits frontier AI companies who had come to the government to disclose recent discoveries4.

Days earlier, Anthropic had published research describing a theoretical quantum attack on the structured lattices underneath ML-KEM and ML-DSA5. Those are the NIST standards that replaced RSA in our game. Before anyone panics: at the smallest parameter sets, the attack is estimated to need far more than 2^1000 quantum operations, a cost reviewers cheerfully called “galactic”6. CNBC’s headline had Claude finding a way to “crack” the maths7, but the specialist coverage is clear that it’s theoretical. It doesn’t break anything deployed.

What it does is dent confidence in structured lattices over the long term, and the advice that came out of it is the boring, correct one: keep migrating, and make your algorithms easy to swap5.

If you’re keeping score: the lock we picked because RSA was doomed got a scratch on it, from an AI, two years after we fitted it to a game of noughts and crosses.

That word swap matters. In Java, swapping algorithms is what the provider architecture is for: you ask for an algorithm by name with KEM.getInstance(...), and whichever provider is registered does the work. Writing our own provider back in JDK 21 was easily the most over-engineered thing in this repository. It turns out it was also the right shape.

Which is a shame, because that provider is exactly where the eight issues (that envelope) landed.

Eight ways to break a contract

A quick refresher on why that provider exists. JDK 21 gave us the KEMSpi interface (JEP 452) but no post-quantum algorithm to plug into it, and nobody else had implemented it yet. So I wrote KyberKEMSpi, an adapter that wraps Bouncy Castle’s Kyber in the JDK’s new API. Two years later it’s still there, still on Bouncy Castle 1.78.1, and still registered as BCPQC.KEM.

On 2 and 3 December, eight issues arrived against it8. The first, #32, was one report, and the other seven were split out of it so each tracks a single problem:

#IssueIn plain terms
#32Null parameter spec throws NullPointerExceptionCall kem.newEncapsulator(key) without a spec, and it falls over
#33KyberParametersSpi ignores the encoding formatAsk for any format you like; you get the same bytes
#34Key algorithm not validatedHand it an RSA key and it says thank you, then fails somewhere else
#35Declared parameters not matched to the keyA Kyber-512 key can wear a Kyber-1024 badge
#36Parameter reconstruction ignores the levelEvery spec you read back is Kyber-1024, whatever you set
#37Requested slice and algorithm ignoredAsk for 16 bytes labelled AES; get all 32, labelled Kyber
#38Size queries conflate bits and bytesBoth sizes say 256, which is the secret in bits
#39No exact ciphertext-length checkAdd a byte to the ciphertext and nobody notices

What I like about these reports is their manners. None of them claims Kyber is broken, and each is careful to say what it hasn’t proven. They’re contract violations: the adapter doesn’t do what KEMSpi and AlgorithmParametersSpi promise their callers. In cryptographic code, that’s where the real trouble usually starts. Nobody breaks the maths; somebody forgets to check a length.

My favourite is #36, because it’s the kind of bug you can stare at for an hour without seeing it. The code built a HashMap from each spec’s class to the spec, and all three Kyber levels share one class. So the third put quietly overwrote the first two, and every spec ever read back was Kyber-1024. I wrote that. I was very pleased with myself at the time - if you’re not creating bugs you’re not engineering, right?

Two of the others make each other worse. The JDK passes encapsulate(from, to, algorithm) straight through to the provider; KEMSpi leaves it to us to check the slice and throw IndexOutOfBoundsException. Ours checked nothing, and advertised a secret size of 256, the secret’s length in bits read as bytes. So a caller sizing their slice from secretSize() could ask for bytes 0 to 200 of a 32-byte secret (#38), and we’d cheerfully hand back all 32 anyway (#37).

And here’s the annoying part. In November, I built mutastic for mutation testing and then pointed it at this same repository9. Among the survivors it reported was a mutant in KyberParametersSpi’s spec check, and more on both provider registrations: no test needed that code to be right. Mutation testing told me the tests weren’t watching this corner about a month before an issue tracker did but I wanted to keep the codebase pure and free from AI-assistance, but I wasn’t going to type fixes for it like it was 1999.

Here’s what mutastic says about the adapter today, run against aa88d99, the same commit the issues were filed against (paths shortened):

❯ …/security/KyberKEMSpi.java (17 mutants | 4 missed | 2 not covered)
  × engineNewEncapsulator() :41 publicKey == null is always false
  × engineNewDecapsulator() :56 privateKey == null is always false
  × engineEncapsulate() :111 random == null is always true
  × engineSecretSize() :144 returns 0 instead
  ○ engineEncapsulate() :114 no test reaches this line
  ○ engineEncapsulationSize() :149 no test reaches this line
❯ …/security/KyberParametersSpi.java (7 mutants | 1 missed | 3 not covered)
  × engineGetParameterSpec() :43 KyberParameterSpec.class.isAssignableFrom(paramSpec) is always true
  ○ engineGetEncoded() :51 no test reaches this line
  ○ engineGetEncoded() :56 no test reaches this line
  ○ engineToString() :61 no test reaches this line
❯ …/security/KyberParams.java (5 mutants | 1 missed)
  × fromEncoded() :84 returns null instead

Look at engineSecretSize() :144 returns 0 instead. The secret size could have been zero and not one test would have blinked. That’s #38, hiding in plain sight, and its twin engineEncapsulationSize() was never even called. Meanwhile, two files down the same report, SecureKyberClient and SecureKyberServer, the JDK 24 path, have every mutant caught.

Who codes anymore?

Let’s be honest about how this went, because it’s 2026 and pretending otherwise would be silly.

The issues were drafted with AI. When I asked for fixes, AI wrote eight tidy patches before my coffee had cooled, each with the negative tests the issues asked for. In 2024 I spent several evenings reading Bouncy Castle source to write this adapter. I spent days poring over YouTube videos to understand lattice encryption. In 2026 its bugs were found, split, triaged and patched in a blink of an eye, and most of the code-writing wasn’t mine.

So who codes anymore? Not me, much. What’s left is the part that was always the job: deciding what right means, and asking questions the AI wasn’t asked.

I keep thinking of Captain Picard here. He never once rebuilt a warp core. He had Geordi and a computer for that. What he did was listen to his crew, ask the awkward question, own the call, and then say the two words every engineer wants to hear: make it so. That’s the job now. And the awkward question here was whether this code should still exist at all.

Because here’s the thing. Since JDK 24, the game doesn’t even use it. TcpTransportServer and TcpTransports build SecureKyberServer and SecureKyberClient, which call KEM.getInstance("ML-KEM-1024") straight from the JDK. No Bouncy Castle, no provider of ours. The adapter and its SecureBouncyCastleKyber* handlers are now only called from their own tests, and from the older branches that go with the articles. Meanwhile bcprov is still a dependency of two modules, one of which (app) never imports it.

So the answer is two answers.

For the game: the delete key

The game stops shipping code it doesn’t run. Bouncy Castle leaves the published modules:

app/build.gradle.kts, tcp-gameserver/build.gradle.kts
- implementation("org.bouncycastle:bcprov-jdk18on:1.78.1")

That also makes the agility argument for us. With no provider of our own in the game’s path, keeping up with the algorithms is the JDK’s job. When the names change, a string changes, and the game follows the platform.

And since ML-DSA-87 is already in its tests, the game now uses both CNSA 2.0 algorithms out of the box. Tic-tac-toe is ready for the NSA’s 2027 deadline, which is more than many national security systems can say.

Those two algorithms are where my JDK 21 side quest through two galaxies ended up. ML-KEM is Kyber, the crystal at the heart of a lightsaber. ML-DSA is Dilithium, the crystal that powers the Enterprise’s warp drive. The cryptographers clearly had as much fun naming them as I did over-engineering with them. Star Wars got the key exchange and Star Trek got the signatures, and for once the two fandoms are on the same side.

In memoriam

Which brings me to Sir Patrick Stewart, who we lost this year. For a generation of engineers, Captain Picard was the picture of how to lead a crew: curious, principled, unafraid to say “I was wrong”, and calm on a bridge that was, more often than not, on fire. A lot of us learned what good leadership sounds like from a bald Englishman in a red uniform, long before we had anyone to lead.

The Dilithium keeps the lights on, Captain. Thank you.

For the example: fixing it anyway

But I’m not deleting the adapter. The JDK 21 post sends readers to it as the worked example of how to plug your own algorithm into the JDK, and an example people learn from has a higher bar than production code, not a lower one. If someone copies it, they should copy something right. So it moves out of the game into its own module, kem-provider-example, which isn’t published and takes Bouncy Castle with it, and it gets all eight fixes. Taking classes out of a published artifact is a breaking change, so main goes to 4.0.0.

The key decides, with Java 21’s case null finally earning its keep (#32, #34, #35):

The first patch defaulted a null spec to Kyber-1024, the CNSA 2.0 level. Then I noticed that a Kyber-512 key wearing a Kyber-1024 label is just #35 by another route. So the key decides its own level, which is what the JDK’s own KEMSpi example does too. A spec is optional, and if you give one, it has to agree with the key. Pattern matching for switch (JEP 441) lets null be a case of its own, and a guarded when case does the agreeing:

private static KyberParams levelOf(Key key, AlgorithmParameterSpec spec)
    throws InvalidAlgorithmParameterException, InvalidKeyException {
  if (key == null) {
    throw new InvalidKeyException("input key is null");
  }
  if (!(key instanceof KyberKey kyberKey)) {
    throw new InvalidKeyException("Not a Kyber key: " + key.getAlgorithm());
  }
  var keyLevel = KyberParams.byKyberParameterSpec(kyberKey.getParameterSpec());
  return switch (spec) {
    case null -> keyLevel;
    case KyberParameterSpec kSpec when kSpec.getName().equals(keyLevel.spec().getName()) ->
        keyLevel;
    case KyberParameterSpec kSpec ->
        throw new InvalidAlgorithmParameterException(
            "The key is " + keyLevel.spec().getName() + " but the spec says " + kSpec.getName());
    default ->
        throw new InvalidAlgorithmParameterException(
            "Incompatible spec " + spec.getClass() + " for Kyber.");
  };
}

Letting the enum carry each level’s facts (#36, #38):

Instead of looking specs up by class, each level knows its own spec and ciphertext size. engineGetParameterSpec returns the level it was initialised with, and the size queries finally answer in bytes:

public enum KyberParams {
  Kyber512(KyberParameters.kyber512, KyberParameterSpec.kyber512, 768),
  Kyber768(KyberParameters.kyber768, KyberParameterSpec.kyber768, 1088),
  Kyber1024(KyberParameters.kyber1024, KyberParameterSpec.kyber1024, 1568);
 
  public static final int SECRET_BYTES = 32;
  // parameters(), spec(), ciphertextBytes() …
}
@Override public int engineSecretSize() { return KyberParams.SECRET_BYTES; }
@Override public int engineEncapsulationSize() { return level.ciphertextBytes(); }

Honouring the slice, the label and the length (#37, #39):

@Override
public SecretKey engineDecapsulate(byte[] encapsulation, int from, int to, String algorithm)
    throws DecapsulateException {
  Objects.requireNonNull(encapsulation, "encapsulation");
  checkSlice(from, to, algorithm);
  if (encapsulation.length != level.ciphertextBytes()) {
    throw new DecapsulateException(
        "Expected a " + level.ciphertextBytes() + "-byte " + level
            + " ciphertext, got " + encapsulation.length + " bytes.");
  }
  // … Bouncy Castle extracts the shared secret as before …
  return slice(keyGenerator.generateKey().getEncoded(), from, to, algorithm);
}
 
private static void checkSlice(int from, int to, String algorithm) {
  Objects.checkFromToIndex(from, to, KyberParams.SECRET_BYTES);
  Objects.requireNonNull(algorithm, "algorithm");
}
 
private static SecretKey slice(byte[] secret, int from, int to, String algorithm) {
  try {
    return new SecretKeySpec(Arrays.copyOfRange(secret, from, to), algorithm);
  } finally {
    Arrays.fill(secret, (byte) 0);
  }
}

Encapsulation goes through the same slice, so both sides hand back exactly the bytes, and the algorithm, that the caller asked for.

Saying no to formats we don’t speak (#33):

Our parameters encode as the level’s name and nothing else, so any other format should fail loudly rather than quietly get the default:

private static void checkFormat(String format) throws IOException {
  if (format != null) {
    throw new IOException("Unsupported format " + format + "; Kyber parameters encode as their name");
  }
}

The tests are the ones the issues asked for, and they’re the part I wrote the brief for myself. For each of Kyber-512, 768 and 1024: sizes in bytes, the spec read back after both kinds of initialisation, and keys paired with matching and mismatched specs. Ciphertexts one byte long, one byte short, and exact. A (0, 16, "AES") slice from both sides. And a null spec through the public, no-argument KEM methods, without a NullPointerException in sight. Thirty tests in all, every one green. Then mutastic got another go at the module, because I’ve learnt my lesson about tests nobody checks.

The tests passed. mutastic said they checked nothing.

❯ …/security/KyberKEMSpi.java (27 mutants | 9 missed | 1 not covered)
  × levelOf() :69 the condition is always true
  × levelOf() :75 kSpec.getName().equals(keyLevel.spec().getName()) is always true
  × engineDecapsulate() :152 encapsulation.length != level.ciphertextBytes() is always false
  × checkSlice() :187 the call to checkFromToIndex() is removed
  …
❯ …/security/KyberParametersSpi.java (16 mutants | 10 missed | 3 not covered)

That first line is impossible. “The condition is always true” means every key is refused as not-Kyber, so every single contract test should fall over. Instead, mutastic explain said the twelve tests covering that line all still passed.

The culprit is one of the oldest corners of the JDK. The JCA’s provider list is JVM-wide, and Security.addProvider quietly ignores a provider whose name is already registered. So whichever test registered BCPQC.KEM first won, for good. When mutastic swapped in a mutated KyberKEMSpi, the JCA kept handing out the original from the provider registered before it. The tests were green because they never met the code they were testing.

It’s the same reason November’s run reported those addProvider() survivors in the Bouncy Castle handlers, and it’s now mutastic#377. The fix on our side is two lines in the test’s setup: take the old provider out before putting ours in.

Security.removeProvider("BCPQC.KEM");
Security.addProvider(new KyberKEMProvider());

The rerun, after a few more tests for the guards the JDK’s own wrappers had been hiding:

❯ …/security/KyberKEMSpi.java (27 mutants | 1 missed)
  × slice() :196 the call to fill() is removed
✓ …/security/KyberParametersSpi.java (16 mutants)
✓ …/security/KyberParams.java (12 mutants)

The one survivor zeroes a copy of the secret that nothing reads again: good hygiene, but no test can see it, so it’s proposed as an ignore with that reason for me to accept. Across the module, the score went from 37.5% to 53.8%, or 57.0% to 74.7% where the tests reach. (One of KyberParams’ kills came from a socket test I don’t entirely trust, but that’s a story for mutastic’s issue tracker.)

Quote

”The first duty of every Starfleet officer is to the truth.” — Captain Jean-Luc Picard, Star Trek: The Next Generation, “The First Duty” (1992)

For the branches: being a good citizen

There’s one more wrinkle. This series keeps a branch per article, jdk21 through jdk25, so you can check out the code exactly as each post describes it. Fixing main alone would leave the bugs sitting in every branch a reader is most likely to copy from.

Worse, on jdk21, jdk22 and jdk23 the adapter isn’t an example at all. Before JDK 24 there was no ML-KEM in the JDK, so Bouncy Castle and our provider are the game’s key exchange there.

So the fixes are backported to every branch from jdk21 onward, each as a single commit on top of the article’s code: the same eight fixes, the same thirty tests, nothing else moved, and each built and tested on its own JDK, from 21 through 25. The branches still match their posts; they just don’t carry the bugs any more. Only main gets the bigger tidy-up, with Bouncy Castle leaving the game and the adapter moving into kem-provider-example.

Merged

  • main, version 4.0.0: #45 fixes the provider, moves it into kem-provider-example, and closes all eight issues.
  • The article branches: #40 jdk21, #41 jdk22, #42 jdk23, #43 jdk24 and #44 jdk25.

That’s all folks — and this time I mean it. Probably. The lattice is holding, the game is CNSA 2.0 compliant, and the example finally does what it says. But if the last month has taught me anything, it’s that a public repository is never finished. It’s just unwatched. Who’s going to knock next?

Disclaimer:

The views and opinions expressed in this blog are based on my personal experiences and knowledge acquired throughout my career. They do not necessarily reflect the views of or experiences at my current or past employers.

The rules, epilogue edition

  1. Never say you’re out. A public repository is never finished, only unwatched. ← new
  2. Agility beats any one algorithm. RSA sent us to lattices, and lattices are now under scrutiny. Make the next swap a one-line change. ← new
  3. Ask whether the code should exist before asking anyone, human or AI, to fix it. ← new

Next

  • Comment if an AI-drafted issue has landed on one of your side projects, and how you handled it.
  • Follow my blog (or sympathetic engineering digital garden) for future updates on my sympathetic engineering exploits and professional / personal development tips.
  • Connect with @briancorbinxyz on social media channels.
  • Enjoyed what you read? I like coffee, buy me a coffee so I have an excuse to write more.

Footnotes

  1. Gidney, Craig. “How to Factor 2048 Bit RSA Integers with Less than a Million Noisy Qubits.” arXiv, 2025. Accessed December 3, 2026. https://arxiv.org/abs/2505.15917. ↩

  2. “NSA Advises Immediate Transition to Post-Quantum Cryptography to Protect National Security Systems.” National Security Agency, December 2, 2026. Accessed December 3, 2026. https://www.nsa.gov/Press-Room/Press-Releases-Statements/Press-Release-View/Article/4662430/nsa-advises-immediate-transition-to-post-quantum-cryptography-to-protect-nation/. ↩ ↩2

  3. “NSA Urges National Security Systems to Accelerate Post-Quantum Cryptography Migration.” The Quantum Insider, December 2, 2026. Accessed December 3, 2026. https://thequantuminsider.com/2026/12/02/nsa-faster-post-quantum-cryptography-migration/. ↩

  4. Lanz, Jose Antonio. “NSA Urges Immediate Switch to Post-Quantum Cryptography After AI Discoveries.” Decrypt, December 2, 2026. Accessed December 3, 2026. https://decrypt.co/384450/nsa-urges-post-quantum-cryptography-ai-discoveries. ↩ ↩2

  5. Swayne, Matt. “Anthropic Finds Theoretical Quantum Attack on Math Behind U.S. Security Standards.” The Quantum Insider, November 30, 2026. Accessed December 3, 2026. https://thequantuminsider.com/2026/11/30/anthropic-finds-theoretical-quantum-attack-on-math-behind-u-s-security-standards/. ↩ ↩2

  6. Lanz, Jose Antonio. “Anthropic’s Cryptography Breakthrough Is Academic Theory.” Decrypt, December 1, 2026. Accessed December 3, 2026. https://decrypt.co/384358/anthropic-cryptography-breakthrough-academic-theory. ↩

  7. Subin, Samantha. “NSA Urges Post-Quantum Cryptography Shift after AI Discovery.” CNBC, December 2, 2026. Accessed December 3, 2026. https://www.cnbc.com/2026/12/02/nsa-post-quantum-cryptography-ai-risk.html. ↩

  8. “Issues · briancorbinxyz/overengineering-tictactoe.” GitHub. Accessed December 3, 2026. https://github.com/briancorbinxyz/overengineering-tictactoe/issues. ↩

  9. See Mutastic on overengineering-tictactoe, 8 November 2026. ↩

BLUESKY — START THE THREAD KO-FI / RSS