Keyfactor Days 2027 – Nehmen Sie an der „Trust Security Conference“ in San Diego teil Jetzt anmelden!
PQC

Key Encapsulation Mechanisms (KEMs) Explained

If you’re planning a migration to post-quantum cryptography (PQC), you’ve probably noticed one term showing up everywhere: the key encapsulation mechanism, or KEM. KEMs aren’t new in theory, but PQC has pushed them into the mainstream. They’re now a core building block that protocols, libraries, and browsers rely on.

This guide explains what a KEM is, how it differs from other key establishment methods that came before it, why post-quantum standards are built around KEMs, and where KEMs are already in use today.

What key establishment is and why it matters

Key establishment is the process two parties use to end up with the same secret key. Encryption only works when both sides share that key, so establishing it securely is one of the most important steps in any encrypted protocol.

Historically, there have been two main ways to do this: key agreement, as in Diffie-Hellman or ECDH; and key transport, as in RSA. KEMs are a third approach.

Key agreement: Diffie-Hellman and ECDH

In a key agreement, both parties use their key pairs to arrive at a shared secret together. Each party generates a public/private key pair, keeps the private value, publishes the public one, and then combines its own private value with the other party’s public value to establish a shared key.

In classic Diffie-Hellman, Alice and Bob both have access to public parameters, g and p, which are both numbers, with p being a large prime number. Alice keeps a private value a and sends gᵃ to Bob, or rather, the residue of dividing gᵃ by p. Bob keeps b private and sends the corresponding residue from gᵇ to Alice. Each side then computes the same shared secret, gᵃᵇ, without ever sending it. All of this is done modulo a large prime p to make it impossible to calculate a or b by knowing gᵃ or gᵇ.

Elliptic-curve Diffie-Hellman (ECDH) follows the same principle, but uses points and their multiples on an elliptic curve instead of numbers and powers of g. Curves such as P-256 and X25519 are widely used in ECDH implementations.

One useful feature of Diffie-Hellman is its symmetry: mathematically, neither party is special. Both parties can send their public keys at the same time, which means this step could be done offline. Also, both parties contribute randomness to the generation of the shared key, which means that neither party has full control of what the resulting shared key is. That matters for some applications. In practice, though, most protocols already assign distinct initiator and responder roles, so the symmetry is often less important than it first appears.

Key transport: RSA

In a key transport, one party picks the shared key and sends it using a public key encryption mechanism. The recipient (also referred to as the decryptor) creates a public/private key pair. The sender (or encryptor) generates a session key, encrypts it with the recipient’s public key, and sends the encrypted blob. The recipient decrypts it with their private key and recovers the session key.

Underneath, key transport is simply public key encryption where the message happens to be a key. Only one party contributes randomness to the shared key: the sender.

Key encapsulation mechanisms (KEMs)

A key encapsulation mechanism is a public key algorithm that lets one party use another party’s public key to produce a shared secret and an encapsulation of that secret. Only the holder of the matching private key can decapsulate it and recover the same secret. According to NIST SP 800-227, KEMs were first introduced by Ronald Cramer and Victor Shoup as a building block for efficient public key encryption. Shoup’s 2001 proposal for the ISO 18033-2 standard is one of the works that the National Institute of Standards and Technology (NIST) credits.

A KEM has three operations:

  1. Key generation: The recipient creates a public and private key pair.
  2. Encapsulation: The sender takes the recipient’s public key and runs the encapsulation step. It returns two things at once: the shared secret and a ciphertext (the encapsulation).
  3. Decapsulation: The sender transmits the ciphertext. The recipient uses its private key to recover the shared secret from it.

How a KEM relates to key agreement and key transport depends on its design. NIST SP 800-227 notes that a KEM can be viewed as either a key agreement scheme or a key transport scheme, meaning that it can be seen as a generalization of the two concepts.

ML-KEM (Module-Lattice-Based Key-Encapsulation Mechanism) is a post-quantum KEM standardized by the National Institute of Standards and Technology (NIST) in FIPS 203. Its security relies on a mathematical problem called Module Learning With Errors. NIST specifies three parameter sets that offer different security levels and key sizes.

In ML-KEM, the shared secret depends on both the encapsulator’s fresh randomness and the recipient’s public key, so it resembles key agreement, while also having the asymmetry of a key transport. By contrast, in a KEM built from RSA or other public key encryption, the encapsulator effectively generates the secret, so it behaves like key transport. In both cases, encapsulation outputs the shared secret and a ciphertext. The application can then use the secret to derive an encryption key, rather than choosing a session key and encrypting it.

Key agreement vs. key transport vs. KEM at a glance

Key agreementKey transportKEM
Who generates the keyBoth parties derive it togetherThe sender picks itThe encapsulation step outputs it; depending on the design, this works like key agreement or key transport
Source of randomnessBoth parties’ private valuesSender onlySender’s fresh randomness, plus the recipient’s key in designs such as ML-KEM
Direction of rolesMathematically symmetricOne way, sender to recipientOne way: encapsulator and decapsulator
How the secret travelsNever sent; each side computes itEncrypted key is sentA ciphertext is sent, and the secret is recovered from it
Example algorithmsDiffie-Hellman, ECDH, X25519RSA key transportML-KEM, HQC, FrodoKEM, Classic McEliece, DHKEM, RSASVE

How do you get confidentiality with a KEM?

A KEM doesn’t encrypt your data directly. It establishes a shared secret, and a symmetric cipher uses that secret to encrypt the data. This combination of asymmetric and symmetric cryptography is the same pattern that most existing encryption protocols already follow.

Here’s a simplified example of the flow. A sender uses an ephemeral private key and the recipient’s public key to establish a shared secret. Both parties run that secret through a key derivation function (KDF) to produce an encryption key, and if necessary a nonce. The sender then encrypts the message with a symmetric cipher, such as AES. The recipient derives the same values and uses them to decrypt and verify the message. This example shows the general flow; it isn’t the entire protocol. A complete protocol also needs to handle sender authentication and safe nonce use.

Asymmetric and symmetric cryptography working together

Think of the process in two steps:

  • The public key step (the KEM): establishes a shared secret between parties who may never have communicated before.
  • The bulk encryption step (symmetric): uses that secret to encrypt data efficiently.

The overall structure is familiar. What changes is the public key step. With RSA key transport, the session key is created independently, before the public key operation. With most KEMs, the public key operation is used to create the session key. That shift means many protocols designed around key transport have to be adjusted so they can accept a session key that is generated during encapsulation rather than chosen up front.

Why PQC standards favor the KEM form

Many cryptographers view most of the existing quantum-safe key agreement and key transport designs as too inefficient for practical use. According to NIST SP 800-227, NIST received community feedback that KEMs are best suited for standardization and widespread deployment.

That’s why the NIST post-quantum standardization call for proposals sought encryption and key encapsulation schemes, not only Diffie-Hellman-style key exchanges. The shift made some people uneasy at first. The research community pushed hard to find practical post-quantum key exchanges, and it remained an active area of research for a few years.

Turning key agreements and key transports into KEMs

Classical algorithms don’t have to be left behind. Diffie-Hellman key agreement can be adapted into a KEM, and RSA can be used to construct one as well. NIST Special Publication (SP) 800-227 illustrates both with ECDH-KEM and RSASVE-KEM, presented as examples rather than requirements. These classical examples are quantum-vulnerable.

Here’s a simplified example of building a KEM from Diffie-Hellman. Intuitively, the transformation amounts to considering one party as an encapsulator, while the other one becomes the decapsulator. In more detail, the parties use a cyclic group Cp of prime order p with a generator g:

  1. Key generation: The recipient chooses a private value a from Cp and calculates the public key _g_ᵃ.
  2. Encapsulation: The sender chooses a fresh private value b from Cp. The sender calculates the ciphertext _g_ᵇ and the shared value (_g_ᵃ)ᵇ.
  3. Decapsulation: The recipient uses its private value a and the ciphertext to calculate the same shared value: (_g_ᵇ)ᵃ.

Both parties can then use a KDF to turn the shared value into a secret key. Notice that the ciphertext carries the sender’s ephemeral public value, not the secret itself. This example illustrates the mechanics only; a complete construction such as DHKEM also specifies key derivation and validation requirements.

RSA-based KEMs work slightly differently than something like ML-KEM. They consist of the same steps; however, for RSA-based KEMs the sender generates the randomness used to establish the secret. An RSA KEM keeps the structure of key transport. Only one party contributes randomness. That isn’t a requirement of the KEM definition, but it’s a practical difference worth knowing. In order to guarantee the sender does not have full control over the shared key, this is derived from the secret using a key derivation function.

Why this makes hybrid cryptography easier

Hybrid cryptography combines a well-studied classical scheme, such as elliptic-curve Diffie-Hellman or RSA, with a post-quantum scheme to create a single scheme. Post-quantum constructions aren’t considered insecure, but they’re newer and cryptanalysis continues to evolve. A hybrid gives security-conscious teams the best of both worlds:

  • It’s never weaker than the classical scheme alone.
  • It’s post-quantum secure as long as the post-quantum component holds.

Combining two primitives is much easier when they’re the same kind. Because classical key agreement and key transport can be turned into KEMs, it is easier to turn one of these classical schemes into a KEM and then combine it with a PQC KEM.

Static and ephemeral combinations

KEM key pairs can be static (long-term and reused) or ephemeral (generated fresh for each session).

Ephemeral KEM keys inject fresh randomness into every session. If a session key is compromised, later sessions start over with new keys, which gives a self-healing property. Ephemeral keys also support forward secrecy: once a session’s keys are discarded, compromising a long-term key later won’t expose past traffic. This is practical for ML-KEM, because its key generation is fast. By contrast, generating a new RSA key pair for every connection is expensive, which is one reason RSA key transport is a poor fit for ephemeral use in protocols like TLS.

Static KEM keys are long-term keys tied to an identity. Because only the holder of the private key can decapsulate, a party that successfully uses the resulting shared secret implicitly proves it holds that key. Some protocols use this as a form of authentication, as an alternative to signatures. However, static keys on their own do not provide forward secrecy.

Many protocol designs combine both. An ephemeral KEM provides fresh randomness and forward secrecy, while a static KEM or a signature provides authentication.

Protocols using KEMs

Protocols aren’t being replaced; they’re being adapted. For each major protocol, there now exists a PQC version that swaps in KEMs and PQC signatures for the original key exchange and signature algorithms. Teams had to check carefully that the new primitive still fit each protocol’s structure.

TLS

Transport Layer Security (TLS) lets a client and server establish encryption keys and verify identity before exchanging application data.

In TLS 1.3, the handshake works like this:

  1. The client sends a ClientHello listing its supported cipher suites and key exchange groups. It usually includes a key share for a group it expects the server to support.
  2. The server replies with a ServerHello that selects a cipher suite and provides its own key share. Both sides use the key shares to establish a shared secret and derive encryption keys.
  3. The server sends its certificate, proves it holds the corresponding private key, and sends a Finished message that helps confirm the handshake wasn’t altered.
  4. The client validates the certificate and hostname, verifies the server’s signature, and sends its own Finished message.

This version of TLS was designed to leverage ephemeral keys; that is, key pairs are generated fresh in every handshake. This is done with the goal of achieving forward secrecy; however, it makes it impractical to use RSA for key establishment.

As of November 2026, Chrome 131+ and Firefox desktop 132+ use the hybrid X25519MLKEM768 group by default for TLS 1.3 key agreement. This does not make TLS a completely post-quantum scheme, since it covers key agreement only, not certificates or signatures.

The client’s ClientHello includes both an X25519 key share and an ML-KEM public key in a hybrid scheme referred to as X25519MLKEM768. The server responds with its X25519 key share and an ML-KEM ciphertext. Both sides combine the two secrets to derive the handshake keys. Because generating a fresh ML-KEM key pair is fast, this ephemeral exchange is practical and helps support forward secrecy.

Other protocols adopting KEMs

KEMs are already showing up across a wide range of protocols and formats:

  • HPKE (Hybrid Public-Key Encryption) and the protocols built on it, including Oblivious HTTP (OHTTP), JOSE, and Encrypted Client Hello
  • Signal, which mixes ML-KEM-based keys into its ratchet, per Signal’s post-quantum ratchet announcement
  • X-Wing, a separate published hybrid KEM combining X25519 and ML-KEM-768 (Barbosa et al.)
  • SSH, where OpenSSH defaulted to sntrup761x25519 in version 9.0 and to mlkem768x25519 in version 10.0
  • IKEv2/IPsec and WireGuard for VPNs
  • OpenPGP, X.509, and S/MIME for email, certificates, and signing infrastructure

Adoption is broad, but it isn’t finished. Many systems are still mid-migration.

Security properties of KEMs

KEM security is well understood and closely resembles the security of schemes already in use. The overall model of using a public key primitive to establish a key and then using symmetric cryptography for the data is unchanged. Moving to KEMs is more of a tweak than an overhaul.

That said, new protocol designs built on KEMs still need fresh analysis. Attackers look for small gaps, and a change in how keys are generated and used can open them to exploitation if a protocol isn’t reviewed carefully.

IND-CCA2

INDistinguishability under adaptive Chosen-Ciphertext Attack (IND-CCA2) is the strong security standard expected of modern KEMs. In plain terms: even if an attacker can ask for the decapsulation of any ciphertexts they choose, except the specific challenge ciphertext, they still can’t tell the real shared secret apart from a random value.

IND-CPA (indistinguishability under chosen-plaintext attack) is a weaker model. It doesn’t give the attacker access to decapsulation, so it doesn’t protect against attackers who can feed crafted ciphertexts to a real system and watch how it responds.

According to NIST’s call for proposals, IND-CCA2 was the stated security goal for KEMs intended for general use. The call also allowed IND-CPA schemes for ephemeral-only use.

In technical terms, FIPS 203 explains that ML-KEM applies a Fujisaki–Okamoto (FO) transform to reach IND-CCA2 security.

Trade-offs and security between different constructions

Different standardized post-quantum KEMs rely on different mathematical problems, and that diversity is deliberate. If researchers find a weakness in one approach, organizations need alternatives that don’t share the same underlying problem.

According to FIPS 203, NIST began its post-quantum standardization process in 2016 and received 82 candidate algorithms covering both KEMs and signatures. Its call for proposals set a submission deadline of November 30, 2017. Many candidates were broken quickly.

After three main rounds, NIST selected Kyber in 2022, as reported in NIST IR 8413-upd1. It published ML-KEM, derived from Kyber, in Federal Information Processing Standard (FIPS) 203 on August 13, 2024. Backup candidates, including HQC, Classic McEliece, and SIKE, moved to a fourth round.

In March 2025, NIST selected HQC as its second post-quantum KEM, a code-based alternative to ML-KEM. As of November 2026, the final HQC standard is still pending.

The fourth round showed why diversity matters. In 2022, Castryck and Decru published an efficient key-recovery attack on SIDH, the basis of the isogeny-based candidate SIKE. Their implementation broke SIKEp434 in about ten minutes on a single core.

According to NIST IR 8545, the attacks relied on torsion-point information specific to SIKE’s public key. Lattice-based and code-based schemes don’t share that structure, and NIST still believes the code-based fourth-round candidates are IND-CCA2 secure.

Standardization work also extends beyond NIST. According to the FrodoKEM team, ISO/IEC 18033-2:2006/Amd 2:2026 adds FrodoKEM; the amendment also covers ML-KEM and Classic McEliece.

As of November 2026, Germany’s Federal Office for Information Security (BSI) advises against Classic McEliece because of new developments in cryptanalysis. The same BSI TR-02102 page reports no practical attack on the parameter sets it recommends.

How the constructions differ

  • ML-KEM relies on the mathematical problem Module Learning With Errors (Module-LWE) being difficult to solve. It is a structured lattice problem that generalizes the original Learning With Errors problem. It offers relatively small keys and ciphertexts, and is standardized in FIPS 203.
  • HQC relies on the difficulty of the decoding problems over Hamming quasi-cyclic codes. NIST selected it as an alternative to ML-KEM, with standardization pending as of November 2026.
  • FrodoKEM relies on plain LWE, without the ring or module structure used by some other lattice schemes. Its keys and ciphertexts are larger than ML-KEM’s; however, it is seen as a more conservative option.
  • Classic McEliece is code-based, with a tiny ciphertext and a huge public key, suiting keys distributed once and reused. BSI now advises against it due to recent developments in cryptanalysis.
  • NTRU uses structured lattice problems. Its security depends on the specific construction and parameters chosen.

The numbers

The table below compares the sizes for one party’s public key and the other party’s ciphertext or reply. The figures exclude protocol framing, certificates, and other handshake data. Classical security levels apply against classical attackers only; they offer no protection against a sufficiently capable quantum computer.

ML-KEM sizes come from FIPS 203, X25519 sizes from RFC 7748, and Classic McEliece sizes from the Classic McEliece team. FrodoKEM sizes come from the Open Quantum Safe FrodoKEM page. The ephemeral variant, eFrodoKEM-976, uses a smaller 15,744-byte ciphertext. HQC is omitted because its published sizes depend on the specification version; see the Open Quantum Safe HQC page for current figures.

SchemeSecurity levelPublic key or shareCiphertext or replyTotal
X25519Approximately 128-bit32 bytes32 bytes64 bytes
ECDH P-256128-bit65 bytes65 bytes130 bytes
RSA-2048 key transport112-bit256 bytes256 bytes512 bytes
RSA-3072 key transport128-bit384 bytes384 bytes768 bytes
ML-KEM-512NIST category 1800 bytes768 bytes1,568 bytes

ML-KEM offers a trade-off: in terms of speed, its operations can match or beat X25519, but its keys and ciphertexts need more bandwidth. Hybrid exchanges carry both classical and post-quantum data, so test their impact on your networks and infrastructure. It is important to use vetted implementations.

Where to find KEM implementations

KEMs are widely available in mainstream cryptography libraries, including:

  • Bouncy Castle (Java and C#, plus the upcoming Bouncy Castle Rust library)
  • liboqs from the Open Quantum Safe project
  • AWS-LC
  • OpenSSL

Wie Keyfactor helfen Keyfactor

Moving to KEMs requires both a vetted cryptographic implementation and a safe place to try post-quantum key establishment before it reaches production.

Bouncy Castle is a set of cryptographic APIs for Java and C# that run on everything from Windows and Linux servers to Android and iOS devices. It provides the latest NIST-approved quantum-safe algorithms alongside classical ciphers such as AES, elliptic curve, and RSA, and it supports standards including TLS, CMS, and X.509 certificates. FIPS-certified versions are available across all supported platforms, with support directly from the Bouncy Castle developers. Development teams can add post-quantum algorithms through the same vetted APIs they already use for classical cryptography.

Keyfactor PQC Lab is a free hub for post-quantum readiness. Its no-setup sandbox spins up a working environment in minutes to test drive quantum-resilient certificates, code signing, and lifecycle management. A short readiness assessment shows where your organization stands, and expert videos cover topics such as what KEMs are and what crypto-agility means. Teams can see how post-quantum cryptography behaves in practice before committing to a migration plan.

Together, Bouncy Castle and Keyfactor PQC Lab help teams move from understanding KEMs to building and testing with post-quantum cryptography.

Keyfactor gives security teams visibility and control over the identities and cryptography that secure every digital interaction, so your business keeps running—uninterrupted.

Häufig gestellte Fragen

Got KEM questions?
We’ve got answers.

Die Quelle abonnieren

Stay ahead of the curve with Keyfactor’s monthly newsletter — packed with curated insights, expert tips, must-watch videos, and practical guides to help you stay secure, agile, and quantum-ready.

Lesen Sie weiter

Post-Quantum-Kryptographie-Konferenz
PQC

What is Cryptographic Debt? Causes, Risks, and Fixes

Mehr lesen
PQC

What is Harvest Now, Decrypt Later (HNDL)?

Mehr lesen
PQC

PQC-Migrationsleitfaden: So migrieren Sie zur postquanten Kryptografie

Mehr lesen