Tools 5 min read 881 words

age asks you to replace your keys: time to re-encrypt with post-quantum

ES
age asks you to replace your keys: time to re-encrypt with post-quantum

The squirrel doesn’t eat its acorns in autumn: it stores them whole in a tree hollow and opens them in winter, when it needs them. It doesn’t need to open them now, it’s enough to have them.

That’s the idea behind what cryptography calls “harvest now, decrypt later”: someone copies your encrypted files today, even though they can’t read them, and waits until they have a quantum computer able to open them. And it’s exactly the reason for the warning age has just published, Filippo Valsorda’s file encryption tool, which comes very much to the point after yesterday’s lattice news.

What the warning says

The message is direct: age’s classic keys, based on X25519, are no longer considered sufficient to protect files in the long term, and you need to do two things:

  1. Generate new post-quantum keys.
  2. Re-encrypt the files that were encrypted with the old keys.

And a warning worth reading twice: if a file encrypted with the old keys is public, or an attacker has been able to copy it, you should assume its contents could be compromised in the future, whether you re-encrypt it or not. Re-encrypting protects the copy you have, not the acorn the squirrel has already taken.

Why now?

It’s not because of Anthropic’s paper yesterday, which is about lattices. In fact, age’s new keys are hybrid, ML-KEM-768 plus X25519, that is, lattices precisely (and that attack, as we saw, is still “galactic”).

The warning links to an April article by Valsorda where he explains his change of mind. Within a few weeks, two papers came out that sharply lowered what’s needed to break 256-bit elliptic curves: one from Google, drastically reducing the logical qubits and gates required, and another from Oratomic, bringing it down to around 10,000 physical qubits with the right connectivity. And security people at Google have set 2029 as their migration deadline.

His reasoning seems hard to argue with: the question isn’t “are you sure there will be a quantum computer able to break this in 2030?”, but “are you sure there won’t be?”. For files that need to stay secret ten years from now, you don’t need to be sure the risk will materialise in order to act.

How to tell whether a key or a file is secure

Post-quantum keys can be recognised by their prefix (and public ones also because they’re very long, around 2,000 characters):

Post-quantum (secure)Classic (need replacing)
age1pq1…age1… with no second 1
AGE-SECRET-KEY-PQ-1…AGE-SECRET-KEY-1…
age1tagpq1…ssh-ed25519 AAAA… and ssh-rsa AAAA…
age1tag1…, age1yubikey1…, age1se1…, age1tpm1…

For files, age 1.4 ships age-inspect, which tells you what type of key a file was encrypted to:

$ age-inspect secrets.age
secrets.age is an age file, version "age-encryption.org/v1".

This file is encrypted to the following recipient types:
  - "mlkem768x25519"

This file uses post-quantum encryption.

If X25519 appears instead of mlkem768x25519, the file will say This file does NOT use post-quantum encryption. With that, a simple loop (this bit is mine) lists the ones in a directory that need redoing:

for f in *.age; do
  age-inspect "$f" | grep -q "does NOT use post-quantum" && echo "$f"
done

How to migrate

First, upgrade to age 1.4.0 (or rage 0.13.0 if you use the Rust version). With that, age-keygen generates post-quantum keys by default, and re-encrypting a file means decrypting with the old key and encrypting with the new one:

age-keygen -o pq.txt
age -d -i old.txt file.age | age -e -i pq.txt -o new.age

There are a few special cases:

  • Password-encrypted files (age -p): already post-quantum, nothing to do.
  • SSH keys: that’s over. Encrypting to SSH keys was always a hack, because they’re authentication keys, and with post-quantum algorithms that hack is no longer possible.
  • YubiKey: age-plugin-yubikey 0.6.0 generates hybrid post-quantum keys, with a catch the warning itself admits: someone with a quantum computer, the YubiKey and the PIN could bypass touch enforcement. It’s the best that can be done until hardware supports ML-KEM.
  • Other plugins: age 1.4 warns if a plugin doesn’t assert it’s post-quantum; check each one’s documentation.
  • As a library (the Go module or the Rust crate): old keys are marked as deprecated, but you only see that in the IDE or linter, it doesn’t change behaviour.

As a note of my own: if you use age indirectly, for example to encrypt secrets in a repository with some tool that uses it underneath, it’s worth checking whether that tool already supports the new keys before changing anything.

What’s coming

Right now age only warns, but future versions will stop encrypting to old keys. You can get ahead of that with an environment variable, and once you’ve finished migrating it’s worth doing, so nothing slips through:

VariableValueEffect
AGE_PQC_REQUIREDALLOW_INSECUREToday’s behaviour: everything allowed
AGE_PQC_REQUIREDALLOW_ONLY_DECRYPTOnly decrypt with old keys (the future default)
AGE_PQC_REQUIREDYESAlso blocks decryption
AGE_PQC_WARNINGSVERBOSEDetails which keys aren’t post-quantum
AGE_PQC_WARNINGSSILENCE_I_KNOW_ITS_NOT_SAFESilences the warnings (the name says what they think of it)

What I like most about the warning is that it doesn’t beat about the bush: it doesn’t say “maybe”, it says “you need to act”, and it gives you the tools to do it. The squirrel will keep storing acorns, there’s no stopping that, but at least the ones it takes from today on won’t open in winter.