Key encapsulation mechanism

{{Short description|Public-key cryptosystem}}

{{confused|key wrap}}

File:KEM.svg

In cryptography, a key encapsulation mechanism (KEM) is a public-key cryptosystem that allows a sender to generate a short secret key and transmit it to a receiver securely, in spite of eavesdropping and intercepting adversaries.{{cite book

|author-last=Galbraith

|author-first=Steven

|title=Mathematics of Public-Key Cryptography

|date=2012

|section=§23.1.1: The KEM/DEM paradigm

|pages=471–478

|publisher=Cambridge University Press

|isbn=978-1-107-01392-6

}}{{cite conference

|author-last=Shoup

|author-first=Victor

|author-link=Victor Shoup

|title=Using Hash Functions as a Hedge against Chosen Ciphertext Attack

|editor-last=Preneel

|editor-first=Bart

|editor-link=Bart Preneel

|date=May 2000

|conference=Advances in Cryptology – EUROCRYPT 2000

|conference-url=https://link.springer.com/book/10.1007/3-540-45539-6

|volume=1807

|series=Lecture Notes in Computer Science

|publisher=Springer

|location=Bruges, Belgium

|isbn=978-3-540-67517-4

|pages=275–288

|doi=10.1007/3-540-45539-6_19

|doi-access=free

|url=https://link.springer.com/chapter/10.1007/3-540-45539-6_19

}}{{cite journal

|author-last1=Cramer

|author-first1=Ronald

|author-link1=Ronald Cramer

|author-last2=Shoup

|author-first2=Victor

|author-link2=Victor Shoup

|title=Design and Analysis of Practical Public-Key Encryption Schemes Secure against Adaptive Chosen Ciphertext Attack

|journal=SIAM Journal on Computing

|volume=33

|issue=1

|pages=167–226

|year=2003

|publisher=Society for Industrial and Applied Mathematics

|doi=10.1137/S0097539702403773

|url=https://epubs.siam.org/doi/10.1137/S0097539702403773

}} Modern standards for public-key encryption of arbitrary messages are usually based on KEMs.{{citation

|title=FIPS 203: Module-Lattice-Based Key-Encapsulation Mechanism Standard

|publisher=National Institute of Standards and Technology

|date=2024-08-13

|url=https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.203.pdf

|doi=10.6028/NIST.FIPS.203

|doi-access=free

}}{{cite ietf

|title=Hybrid Public Key Encryption

|rfc=9180

|author-last1=Barnes

|author-first1=R.

|author-last2=Bhargavan

|author-first2=K.

|author-last3=Lipp

|author-first3=B.

|author-last4=Wood

|author-first4=C.

|date=February 2022

|publisher=Internet Engineering Task Force

|doi=10.17487/RFC9180

|doi-access=free

}}

A KEM allows a sender who knows a public key to simultaneously generate a short random secret key and an encapsulation or ciphertext of the secret key by the KEM's encapsulation algorithm.

The receiver who knows the private key corresponding to the public key can recover the same random secret key from the encapsulation by the KEM's decapsulation algorithm.

The security goal of a KEM is to prevent anyone who does not know the private key from recovering any information about the encapsulated secret keys, even after eavesdropping or submitting other encapsulations to the receiver to study how the receiver reacts.

Difference from public-key encryption

File:PKE.svg

The difference between a public-key encryption scheme and a KEM is that a public-key encryption scheme allows a sender to choose an arbitrary message from some space of possible messages, while a KEM chooses a short secret key at random for the sender.

The sender may take the random secret key produced by a KEM and use it as a symmetric key for an authenticated cipher whose ciphertext is sent alongside the encapsulation to the receiver.

This serves to compose a public-key encryption scheme out of a KEM and a symmetric-key authenticated cipher in a hybrid cryptosystem.

Most public-key encryption schemes such as RSAES-PKCS1-v1_5, RSAES-OAEP, and Elgamal encryption are limited to small messages{{cite ietf

|title=PKCS #1: RSA Cryptography Specifications Version 2.2

|rfc=8017

|editor-last=Moriarity

|editor-first=K.

|author-last1=Kaliski

|author-first1=B.

|author-link1=Burt Kaliski

|author-last2=Jonsson

|author-first2=J.

|author-last3=Rusch

|author-first3=A.

|date=November 2016

|publisher=Internet Engineering Task Force

|doi=10.17487/RFC8017

|doi-access=free

}}{{cite book

|author-last1=Menezes

|author-first1=Alfred J.

|author-link1=Alfred Menezes

|author-last2=van Oorschot

|author-first2=Paul C.

|author-link2=Paul van Oorschot

|author-last3=Vanstone

|author-first3=Scott A.

|author-link3=Scott Vanstone

|title=Handbook of Applied Cryptography

|publisher=CRC Press

|date=October 1996

|isbn=0-8493-8523-7

|chapter=8. Public-Key Encryption

|url=http://cacr.uwaterloo.ca/hac/about/chap8.pdf#page=2

|pages=283–319

}} and are almost always used to encrypt a short random secret key in a hybrid cryptosystem anyway.{{cite book

|author-last1=Ferguson

|author-first1=Niels

|author-link1=Niels Ferguson

|author-last2=Kohno

|author-first2=Tadayoshi

|author-link2=Tadayoshi Kohno

|author-last3=Schneier

|author-first3=Bruce

|author-link3=Bruce Schneier

|title=Cryptography Engineering

|year=2010

|publisher=Wiley

|isbn=978-0-470-47424-2

|chapter=12. RSA

|pages=195–211

}}{{cite ietf

|title=OpenPGP Message Format

|rfc=4880

|author-last1=Callas

|author-first1=J.

|author-link1=Jon Callas

|author-last2=Donnerhacke

|author-first2=L.

|author-last3=Finney

|author-first3=H.

|author-link3=Hal Finney (computer scientist)

|author-last4=Shaw

|author-first4=D.

|author-last5=Thayer

|author-first5=R.

|date=November 2007

|publisher=Internet Engineering Task Force

|doi=10.17487/RFC4880

|doi-access=free

}}

And although a public-key encryption scheme can conversely be converted to a KEM by choosing a random secret key and encrypting it as a message, it is easier to design and analyze a secure KEM than to design a secure public-key encryption scheme as a basis.

So most modern public-key encryption schemes are based on KEMs rather than the other way around.{{cite web

|title=Post-Quantum Cryptography: FAQs

|publisher=National Institute of Standards and Technology

|date=2024-07-19

|url=https://csrc.nist.gov/Projects/Post-Quantum-Cryptography/faqs

|access-date=2024-07-20

|archive-date=2024-06-26

|archive-url=https://web.archive.org/web/20240626090150/https://csrc.nist.gov/Projects/post-quantum-cryptography/faqs

}}

Definition

=Syntax=

A KEM consists of three algorithms:{{citation

|author-last=Dent

|author-first=Alexander W.

|title=A Designer’s Guide to KEMs

|year=2002

|issue=2002/174

|series=Cryptology ePrint Archive

|publisher=International Association for Cryptologic Research

|url=https://eprint.iacr.org/2002/174

}}{{cite conference

|author-last1=Hofheinz

|author-first1=Dennis

|author-last2=Hövelmanns

|author-first2=Kathrin

|author-last3=Kiltz

|author-first3=Eike

|title=A Modular Analysis of the Fujisaki-Okamoto Transformation

|editor-last1=Kalai

|editor-first1=Yael

|editor-last2=Reyzin

|editor-first2=Leonid

|date=November 2017

|conference=Theory of Cryptography – TCC 2017

|conference-url=https://link.springer.com/book/10.1007/978-3-319-70500-2

|volume=10677

|series=Lecture Notes in Computer Science

|publisher=Springer

|location=Baltimore, MD, United States

|isbn=978-3-319-70499-9

|pages=341–371

|doi=10.1007/978-3-319-70500-2_12

|doi-access=free

|url=https://link.springer.com/chapter/10.1007/978-3-319-70500-2_12

}}

  1. Key generation, (\mathit{pk}, \mathit{sk}) := \operatorname{Gen}(), takes no inputs and returns a pair of a public key \mathit{pk} and a private key \mathit{sk}.
  2. Encapsulation, (k, c) := \operatorname{Encap}(\mathit{pk}), takes a public key \mathit{pk}, randomly chooses a secret key k, and returns k along with its encapsulation c.
  3. Decapsulation, k' := \operatorname{Decap}(\mathit{sk}, c'), takes a private key \mathit{sk} and an encapsulation c', and either returns an encapsulated secret key k' or fails, sometimes denoted by returning \bot (called ‘bottom’).

=Correctness=

A KEM is correct if, for any key pair (\mathit{pk}, \mathit{sk}) generated by \operatorname{Gen}, decapsulating an encapsulation c returned by (k, c) := \operatorname{Encap}(\mathit{pk}) with high probability yields the same key k, that is, \operatorname{Decap}(\mathit{sk}, c) = k.

=Security: IND-CCA=

Security of a KEM is quantified by its indistinguishability against chosen-ciphertext attack, IND-CCA, which is loosely how much better an adversary can do than a coin toss to tell whether, given a random key and an encapsulation, the key is encapsulated by that encapsulation or is an independent random key.

Specifically, in the IND-CCA game:

  1. The key generation algorithm is run to generate (\mathit{pk}, \mathit{sk}) := \operatorname{Gen}().
  2. \mathit{pk} is revealed to the adversary.
  3. The adversary can query \operatorname{Decap}(\mathit{sk}, c') for arbitrary encapsulations c' of the adversary's choice.
  4. The encapsulation algorithm is run to randomly generate a secret key and encapsulation (k_0, c) := \operatorname{Encap}(\mathit{pk}), and another secret key k_1 is generated independently at random.
  5. A fair coin is tossed, giving an outcome b \in \{0,1\}.
  6. The pair (k_b, c) is revealed to the adversary.
  7. The adversary can again query \operatorname{Decap}(\mathit{sk}, c') for arbitrary encapsulations c' of the adversary's choice, except for c.
  8. The adversary returns a guess b' \in \{0,1\}, and wins the game if b = b'.

The IND-CCA advantage of the adversary is \left|\Pr[b' = b] - 1/2\right|, that is, the probability beyond a fair coin toss at correctly distinguishing an encapsulated key from an independently randomly chosen key.

Examples and motivation

=RSA=

Traditional RSA encryption, with t-bit moduli and exponent e, is defined as follows:{{cite book

|author-last=Aumasson

|author-first=Jean-Philippe

|title=Serious Cryptography: A Practical Introduction to Modern Encryption

|year=2018

|publisher=No Starch Press

|isbn=978-1-59327-826-7

|chapter=10. RSA

|pages=181–199

}}{{cite book

|author-last=Stinson

|author-first=Douglas R.

|author-link=Doug Stinson

|title=Cryptography Theory and Practice

|edition=3rd

|year=2006

|publisher=Chapman & Hall/CRC

|isbn=978-1-58488-508-5

|chapter=5. The RSA Cryptosystem and Factoring Integers

|pages=161–232

}}{{cite journal

|author-last1=Rivest

|author-first1=R.L.

|author-link1=Ron Rivest

|author-last2=Shamir

|author-first2=A.

|author-link2=Adi Shamir

|author-last3=Adleman

|author-first3=L.

|author-link3=Leonard Adleman

|title=A method for obtaining digital signatures and public-key cryptosystems

|journal=Communications of the ACM

|volume=21

|issue=2

|date=1978-02-01

|publisher=Association for Computer Machinery

|pages=120–126

|doi=10.1145/359340.359342

|doi-access=free

|url=https://people.csail.mit.edu/rivest/Rsapaper.pdf

}}

  • Key generation, (\mathit{pk}, \mathit{sk}) := \operatorname{Gen}():
  1. Generate a t-bit semiprime n with 2^{t - 1} < n < 2^t at random satisfying \gcd(e, \lambda(n)) = 1, where \lambda(n) is the Carmichael function.
  2. Compute d := e^{-1} \bmod \lambda(n).
  3. Return \mathit{pk} := n as the public key and \mathit{sk} := (n, d) as the private key. (Many variations on key generation algorithms and private key formats are available.{{cite conference

|author-last1=Švenda

|author-first1=Petr

|author-last2=Nemec

|author-first2=Matúš

|author-last3=Sekan

|author-first3=Peter

|author-last4=Kvašňovský

|author-first4=Rudolf

|author-last5=Formánek

|author-first5=David

|author-last6=Komárek

|author-first6=David

|author-last7=Matyáš

|author-first7=Vashek

|title=The Million-Key Question—Investigating the Origins of RSA Public Keys

|conference=25th USENIX Security Symposium

|date=August 2016

|publisher=USENIX Association

|location=Austin, TX, United States

|isbn=978-1-931971-32-4

|pages=893–910

|url=https://www.usenix.org/conference/usenixsecurity16/technical-sessions/presentation/svenda

}})

  • Encryption of (t - 1)-bit message m to public key \mathit{pk} = n, giving c := \operatorname{Encrypt}(\mathit{pk}, m):
  1. Encode the bit string m as an integer r with 0 \leq r < n.
  2. Return c := r^e \bmod n.
  • Decryption of ciphertext c' with private key \mathit{sk} = (n, d), giving m' := \operatorname{Decrypt}(\mathit{sk}, c'):
  1. Compute r' := (c')^d \bmod n.
  2. Decode the integer r' as a bit string m'.

This naive approach is totally insecure.

For example, since it is nonrandomized, it cannot be secure against even known-plaintext attack—an adversary can tell whether the sender is sending the message ATTACK AT DAWN versus the message ATTACK AT DUSK simply by encrypting those messages and comparing the ciphertext.

Even if m is always a random secret key, such as a 256-bit AES key, when e is chosen to optimize efficiency as e = 3, the message m can be computed from the ciphertext c simply by taking real number cube roots, and there are many other attacks against plain RSA.

Various randomized padding schemes have been devised in attempts—sometimes failed, like RSAES-PKCS1-v1_5{{cite conference

|author-last=Bleichenbacher

|author-first=Daniel

|author-link=Daniel Bleichenbacher

|title=Chosen ciphertext attacks against protocols based on the RSA encryption standard PKCS #1

|editor-last=Krawczyk

|editor-first=Hugo

|editor-link=Hugo Krawczyk

|conference=Advances in Cryptology – CRYPTO '98

|date=August 1998

|conference-url=https://link.springer.com/book/10.1007/BFb0055715

|volume=1462

|series=Lecture Notes in Computer Science

|publisher=Springer

|location=Santa Barbara, CA, United States

|isbn=978-3-540-64892-5

|pages=1–12

|doi=10.1007/BFb0055716

|doi-access=free

|url=https://link.springer.com/chapter/10.1007/BFb0055716

}}{{cite conference

|author-last1=Coron

|author-first1=Jean-Sébastien

|author-last2=Joye

|author-first2=Marc

|author-last3=Naccache

|author-first3=David

|author-link3=David Naccache

|author-last4=Paillier

|author-first4=Pascal

|title=New Attacks on PKCS#1 v1.5 Encryption

|editor-last=Preneel

|editor-first=Bart

|editor-link=Bart Preneel

|conference=Advances in Cryptology – EUROCRYPT 2000

|date=May 2000

|conference-url=https://link.springer.com/book/10.1007/3-540-45539-6

|volume=1807

|series=Lecture Notes in Computer Science

|publisher=Springer

|location=Bruges, Belgium

|isbn=978-3-540-67517-4

|pages=369–381

|doi=10.1007/3-540-45539-6_25

|doi-access=free

|url=https://link.springer.com/chapter/10.1007/3-540-45539-6_25

}}—to make it secure for arbitrary short messages m.

Since the message m is almost always a short secret key for a symmetric-key authenticated cipher used to encrypt an arbitrary bit string message, a simpler approach called RSA-KEM is to choose an element of \mathbb Z/n\mathbb Z at random and use that to derive a secret key using a key derivation function H, roughly as follows:{{citation

|author-last=Shoup

|author-first=Victor

|author-link=Victor Shoup

|title=A Proposal for an ISO Standard for Public Key Encryption (version 2.1)

|year=2001

|issue=2001/112

|series=Cryptology ePrint Archive

|publisher=International Association for Cryptologic Research

|url=https://eprint.iacr.org/2001/112

}}

  • Key generation: As above.
  • Encapsulation for a public key \mathit{pk} = n, giving (k, c) := \operatorname{Encap}(\mathit{pk}):
  1. Choose an integer r with 0 \leq r < n uniformly at random.
  2. Return k := H(r) and c := r^e \bmod n as its encapsulation.
  • Decapsulation of c' with private key \mathit{sk} = (n, d), giving k' := \operatorname{Decap}(\mathit{sk}, c'):
  1. Compute r' := (c')^d \bmod n.
  2. Return k' := H(r').

This approach is simpler to implement, and provides a tighter reduction to the RSA problem, than padding schemes like RSAES-OAEP.

=Elgamal=

Traditional Elgamal encryption is defined over a multiplicative subgroup of the finite field \mathbb Z/p\mathbb Z with generator g of order q as follows:{{cite book

|author-last=Galbraith

|author-first=Steven

|title=Mathematics of Public-Key Cryptography

|date=2012

|section=§20.3: Textbook Elgamal encryption

|pages=471–478

|publisher=Cambridge University Press

|isbn=978-1-107-01392-6

}}{{cite conference

|author-last=Elgamal

|author-first=Taher

|author-link=Taher Elgamal

|title=A Public Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms

|editor-last1=Blakley

|editor-first1=George Robert

|editor-link=George Blakley

|editor-last2=Chaum

|editor-first2=David

|editor-link2=David Chaum

|conference=Advances in Cryptology – CRYPTO 1984

|date=August 1984

|conference-url=https://link.springer.com/book/10.1007/3-540-39568-7

|volume=196

|series=Lecture Notes in Computer Science

|publisher=Springer

|location=Santa Barbara, CA, United States

|isbn=978-3-540-15658-1

|pages=10–18

|doi=10.1007/3-540-39568-7_2

|doi-access=free

|url=https://link.springer.com/chapter/10.1007/3-540-39568-7_2

}}

  • Key generation, (pk, sk) := \operatorname{Gen}():
  1. Choose x \in \mathbb Z/q\mathbb Z uniformly at random.
  2. Compute y := g^x \bmod p.
  3. Return \mathit{sk} := x as the private key and \mathit{pk} := y as the public key.
  • Encryption of a message m \in \mathbb Z/p\mathbb Z to public key \mathit{pk} = y, giving c := \operatorname{Encrypt}(\mathit{pk}, m):
  1. Choose r \in \mathbb Z/q\mathbb Z uniformly at random.
  2. Compute: \begin{align} t &:= y^r \bmod p \\ c_1 &:= g^r \bmod p \\ c_2 &:= (t \cdot m) \bmod p\end{align}
  3. Return the ciphertext c := (c_1, c_2).
  • Decryption of a ciphertext c' = (c'_1, c'_2) for a private key \mathit{sk} = x, giving m' := \operatorname{Decrypt}(\mathit{sk}, c'):
  1. Fail and return \bot if (c'_1)^{(p - 1)/q} \not\equiv 1 \pmod p or if (c'_2)^{(p - 1)/q} \not\equiv 1 \pmod p, i.e., if c'_1 or c'_2 is not in the subgroup generated by g.
  2. Compute t' := (c'_1)^x \bmod p.
  3. Return m' := t^{-1} c'_2 \bmod p.

This meets the syntax of a public-key encryption scheme, restricted to messages in the space \mathbb Z/p\mathbb Z (which limits it to message of a few hundred bytes for typical values of p).

By validating ciphertexts in decryption, it avoids leaking bits of the private key x through maliciously chosen ciphertexts outside the group generated by g.

However, this fails to achieve indistinguishability against chosen ciphertext attack.

For example, an adversary having a ciphertext c = (c_1, c_2) for an unknown message m can trivially decrypt it by querying the decryption oracle for the distinct ciphertext c' := (c_1, c_2 g), yielding the related plaintext m' := m g \bmod p, from which m can be recovered by m = m' g^{-1} \bmod p.

Traditional Elgamal encryption can be adapted to the elliptic-curve setting, but it requires some way to reversibly encode messages as points on the curve, which is less trivial than encoding messages as integers mod p.{{cite journal

|author-last=Koblitz

|author-first=Neal

|author-link=Neal Koblitz

|title=Elliptic Curve Cryptosystems

|journal=Mathematics of Computation

|volume=48

|issue=177

|date=January 1987

|pages=203–209

|publisher=American Mathematical Society

|doi=10.1090/S0025-5718-1987-0866109-5

|doi-access=free

|url=https://www.ams.org/journals/mcom/1987-48-177/S0025-5718-1987-0866109-5/S0025-5718-1987-0866109-5.pdf

}}

Since the message m is almost always a short secret key for a symmetric-key authenticated cipher used to encrypt an arbitrary bit string message, a simpler approach is to derive the secret key from t and dispense with m and c_2 altogether, as a KEM, using a key derivation function H:

  • Key generation: As above.
  • Encapsulation for a public key \mathit{pk} = y, giving (k, c) := \operatorname{Encap}(\mathit{pk}):
  1. Choose r \in \mathbb Z/q\mathbb Z uniformly at random.
  2. Compute t := y^r \bmod p.
  3. Return k := H(t) and c := g^r \bmod p as its encapsulation.
  • Decapsulation of c' with private key \mathit{sk} = x, giving k' := \operatorname{Decap}(\mathit{sk}, c'):
  1. Fail and return \bot if (c')^{(p - 1)/q} \not\equiv 1 \pmod p, i.e., if c' is not in the subgroup generated by g.
  2. Compute t' := (c')^x \bmod p.
  3. Return k' := H(t').

When combined with an authenticated cipher to encrypt arbitrary bit string messages, the combination is essentially the Integrated Encryption Scheme.

Since this KEM only requires a one-way key derivation function to hash random elements of the group it is defined over, \mathbb Z/p\mathbb Z in this case, and not a reversible encoding of messages, it is easy to extend to more compact and efficient elliptic curve groups for the same security, as in the ECIES, Elliptic Curve Integrated Encryption Scheme.

See also

References

{{reflist}}

{{DEFAULTSORT:Key encapsulation}}

Category:Public-key encryption schemes

Category:Key management