Software Engineering Glossary

Key Encapsulation Mechanism

Also known as: KEM Key encapsulation

A key encapsulation mechanism is a way for two parties to end up with the same shared secret over a public network. One side holds a key pair. The other side runs an encapsulate operation on the public key and gets back a fresh secret plus a ciphertext. Only the private key can turn that ciphertext back into the secret. TLS then uses the secret to key a fast symmetric cipher. ML-KEM, standardized in FIPS 203, is the KEM NIST expects most systems to deploy.

Key Takeaways

  • Encapsulation creates the secret. It does not encrypt a secret the sender already chose.
  • The output you keep is short, 32 bytes for every ML-KEM parameter set. The public key and ciphertext are the large parts.
  • In TLS the client sends the encapsulation key and the server encapsulates. That is the opposite of the mental picture most people bring from RSA key transport.
  • A hybrid handshake runs a KEM beside X25519 or a NIST elliptic curve and mixes the two secrets.

How It Works

  1. Key generation produces an encapsulation key, which is public, and a decapsulation key, which stays private.
  2. Encapsulate takes the public key and returns a ciphertext and a shared secret.
  3. Decapsulate takes the ciphertext and the private key and returns that same shared secret.
  4. The shared secret is fed into a key schedule. The bulk data is then encrypted with AES-GCM or a similar authenticated cipher.

Where It Is Used

  • ML-KEM-768 is NIST’s default parameter set. Its encapsulation key is 1,184 bytes and its ciphertext is 1,088 bytes.
  • X25519MLKEM768 in TLS 1.3 is ML-KEM-768 combined with X25519. RFC 10024 specifies the wire format.
  • AWS KMS can hold an ML-KEM private key and run encapsulate and decapsulate while the private key stays in the module.

Related glossary terms