Cryptography Engineering

Cryptographic Agility: Designing to Replace Your Own Crypto

June 4, 2026 9 min read Haven Team

Every cryptographic algorithm has an expiration date — you just don't know it in advance. MD5, SHA-1, RC4, DES, and 1024-bit RSA all looked permanent until they weren't. Cryptographic agility is the unglamorous engineering discipline of building systems that can retire a broken algorithm without a ground-up rewrite. With the post-quantum migration underway, it has stopped being optional.


Cryptography fails on a schedule no one controls. Sometimes a flaw is found in the math; more often, computing power and cryptanalysis simply catch up to a key size or hash that was adequate a decade ago. The history is consistent and a little humbling:

In every case the algorithm itself was the easy part to replace. The hard part was the systems that had hard-coded it — assumed its output length, baked its identifier into a file format, stored data signed with it, or never built a way to negotiate anything else. That gap between "the algorithm is broken" and "we have actually stopped using it" is the problem agility exists to close.

What Cryptographic Agility Actually Means

Cryptographic agility is the property that a system can change the cryptographic primitives it uses — hash, cipher, signature scheme, key-exchange method, key size — without redesigning the system around them. It is an architectural commitment made before you need it, because by the time an algorithm is publicly broken, retrofitting agility under pressure is exactly when mistakes happen.

In practice it rests on a few concrete habits:

The discipline, in one line

Agility is the difference between "we need to change our hash function" being a config change plus a migration job, versus a multi-year forensic hunt for every place the old one was silently assumed.

TLS: The Canonical Success Story

The cipher-suite negotiation in TLS is the textbook example of agility done well. A client and server announce supported algorithms and pick a mutually acceptable suite at handshake time. When RC4 had to go, the ecosystem could deprecate it through configuration and policy rather than reinventing the protocol. TLS 1.3 went further, pruning the menu of options down to a short list of vetted suites — a reminder that agility and minimalism are partners, not opposites.

The cautionary counter-example is also instructive: agility implemented carelessly created the downgrade attack. If an attacker can force two parties to negotiate the weakest algorithm both happen to support, flexibility becomes a vulnerability. Good agility therefore pairs a flexible menu with a hard floor — minimum versions, forbidden-algorithm lists, and authenticated negotiation so the handshake itself can't be tampered into choosing something weak.

The Hard Part: Stored Data and Long-Lived Keys

Agility on a live connection is comparatively easy — both ends are present and can renegotiate. Agility for data at rest is where systems break, because the data outlives the decision. An email encrypted in 2018, a signed document, a backup, a key wrapped under a deprecated KDF — these have no live party to renegotiate with.

This is why versioned, self-describing formats matter so much. If every encrypted record carries its algorithm and parameter set, a system can read old records, re-encrypt them under a new scheme, and roll forward. If it doesn't, you face the worst migration: data you can still decrypt with the weak algorithm but cannot safely re-protect without first reverse-engineering how it was protected. Key-derivation schemes face the same pressure — a reason layered KDF designs include version markers so the chain can be upgraded.

Why This Is Urgent Now: Post-Quantum

The reason cryptographic agility moved from "good practice" to "active program" is the transition to post-quantum cryptography. In 2024, NIST finalized its first PQC standards — ML-KEM (FIPS 203, the key-encapsulation scheme derived from CRYSTALS-Kyber) and ML-DSA (FIPS 204, a signature scheme from CRYSTALS-Dilithium) — and organizations are now migrating the public-key cryptography that secures the internet.

Two things make this the largest cryptographic migration in history. First, the new algorithms have different shapes — larger keys, larger signatures, different performance — so systems that assumed the dimensions of RSA or elliptic curves need real changes, not a drop-in. Second, the threat is retroactive: the "harvest now, decrypt later" risk means data encrypted today with classical public-key crypto could be stored by an adversary and decrypted once a cryptographically relevant quantum computer exists. Long-confidentiality data is at risk now, even though the machine doesn't exist yet.

Approach What it gets you
Hybrid key exchange Combine a classical (e.g. X25519) and a post-quantum (ML-KEM) exchange so the result is safe if either holds — the safest migration step today
Algorithm IDs in every payload Lets old and new ciphertexts coexist during a multi-year transition
Crypto isolated behind an interface Swapping the primitive touches one module, not the whole codebase
Inventory of where crypto lives You can't migrate what you can't find — a crypto bill of materials is step zero
You don't earn cryptographic agility when you need it. You either built it in years earlier, or you spend the crisis discovering everywhere you didn't.

The Tension With Simplicity

Agility is not a free virtue. Every additional algorithm a system supports is more code, more configuration, and more chance of a downgrade path or a misconfiguration. The TLS history shows both edges: the flexibility to retire RC4, and the BEAST, FREAK, and Logjam attacks that exploited legacy options left enabled too long. Mature agility means a small, curated, current set of strong algorithms plus a clean mechanism to rotate the set — not an ever-growing junk drawer of every cipher ever shipped.

What to Take Away

If you build anything that stores secrets or protects communication, the practical questions are concrete: Does your data carry the identity of the algorithm that protected it? Can you change a primitive in one place? Do you have a migration path for already-encrypted data? Can you enumerate everywhere crypto is used? If the answer is no, the post-quantum transition will surface it the hard way.

Haven's architecture treats this as a first-class constraint: cryptographic operations sit behind a defined interface, key-derivation and storage formats are versioned so the chain can be upgraded without stranding existing data, and the primitive set is kept deliberately small. None of that is visible to a user — and that is the point. Good cryptographic agility is infrastructure you only notice when an algorithm dies and your data quietly keeps working.

Try Haven free for 15 days

Encrypted email and chat in one app. No credit card required.

Get Started →