Moving to Post Quantum With Sops
NOTE: I wrote this blog post in Spring 2026, but never got around to publishing it because I was afraid it was somehow incorrect, and also because I got addicted to several federated social media platforms (Continuwuity, GoToSocial). I blame Erwan.
Why?
I was actually going to play with fluxcd’s tofu-controller and provision things in OVHCloud tonight. As I was generating the application secret and putting it into my public GitOps repo in a SOPS-encrypted secret, I remembered reading this article:
https://words.filippo.io/crqc-timeline/
Which says that there’s a very serious chance that quantum computers will be able to break regular encryption within a few years’ time.
This means that (there is a big risk that) anything we transmit or publish now, encrypted with normal old non-quantum-resistant encryption, will effectively be out in the open in a few years, at least to everyone who stored it.
The good news is that we already have ways to encrypt that don’t require a quantum computer, but also can’t be cracked by quantum computers. This is called post-quantum encryption, and software support for them is growing rapidly. SOPS already supports it.
So, because in my cluster-template based setup, I am publishing SOPS-encrypted secrets to a public Git repo, I will need to do 2 things before the quantum computers are here:
- Change SOPS over to post-quantum encryption
- Rotate all my secrets afterward, as I need to assume they have leaked by then
So, rather than having to re-generate that OVHCloud secret, let’s move everything to post-quantum first. (Some yaks need shaving I guess)
The how-to part
Some of you reading this may be thinking:
Pff, another nerd writing how-to blog posts.. Why doesn’t he just improve the docs of the open-source project?
Anyway, here’s the complete step-by-step:
Adding a post-quantum key
First, generate a post-quantum age key. You need to have age>=1.3.1 for this, and sops>=3.12.0.
I’m writing it to a different file, to make sure I don’t lose my existing age.key:
age-keygen -pq -o age-pq.key
You’ll get the public key in your terminal. Add it to .sops.yaml receivers:
- path_regex: kubernetes/.*\.sops\.ya?ml
encrypted_regex: "^(data|stringData)$"
mac_only_encrypted: true
key_groups:
- age:
# old key starts with `age1`
- "age1th0ayw6msyjqrehtp00pp0tj20l70vr4jn7jsuga8katkg69xd7snevqy4"
# new post-quantum key starts with `age1pq` and is very long...
- "age1pq14eqp74d8cl2de9drsvq99z28hjxxn0hnd3h256s5xjmrtg47j7ee2fg9taqyxfue..."
Next, while still using your old key (probably via the SOPS_AGE_KEY_FILE env var pointing at the old age.key file), run sops updatekeys on every SOPS-encrypted file. You can use this shell script if all encrypted files end in .sops.yaml (courtesy of @Kariton from Home Operations):
find "${1:-./}" -regextype posix-extended -regex '.*/[[:alnum:]_-]+\.sops\.ya?ml$' -type f | while IFS= read -r file; do
sops updatekeys "${file}"
done
Before pushing your changes to Git, carefully review that all files are encrypted again and that you are not committing unencrypted secrets. Push your changes.
Switching to using the post-quantum key
- on your workstation, point SOPS to the post-quantum age key file (probably via
.mise.tomlor a.envfile) - on the cluster, update the secret in the
flux-systemnamespace that flux uses to decrypt the files from Git.
Remove the quantum-vulnerable key
You might think that you can remove the old key from the .sops.yaml receivers file and run the updatekeys script again, and that you can then add new secrets (such
as the OVHCloud credentials this all started with), which will be safe from quantum attacks. But this is not true!
Why this is not enough
SOPS uses a 2-step encryption model: each file has its own data encryption key, which uses AES-2561 to encrypt the data. Each receiver key gives access to the data key. This means that removing an age key from the receivers does not actually remove access to the encrypted data for that receiver: they already had access to the data encryption key, so if you keep using that data encryption key, they can still decrypt your secrets. You have to also rotate the data encryption key.
The SOPS project actually recommends running sops rotate frequently.
So what do we do?
- We have to first remove the vulnerable key from
.sops.yaml - and then rotate the data key and re-encrypt the secrets with that new data key, like this:
find "${1:-./}" -regextype posix-extended -regex '.*/[[:alnum:]_-]+\.sops\.ya?ml$' -type f | while IFS= read -r file; do
sops updatekeys "${file}"
sops rotate --in-place "${file}"
done
I am not an expert in cryptography, but the crypto nerds seem to agree that AES-256 is quantum-resistant in a practical sense, so your whole SOPS encryption chain should be safe when the first proper quantum computers start hacking: https://crypto.stackexchange.com/questions/6712/is-aes-256-a-post-quantum-secure-cipher-or-not/98281#98281 ↩︎