Skip to content
Surf Wiki
Save to docs
general/public-key-encryption-schemes

From Surf Wiki (app.surf) — the open knowledge base

Key encapsulation mechanism

Public-key cryptosystem

Key encapsulation mechanism

Public-key cryptosystem

Flow diagram of a key encapsulation mechanism, relating the inputs and outputs of the Gen, Encap, and Decap algorithms of a KEM
A key encapsulation mechanism, to confidentially transport a ''random secret key'' <math>k</math> from a sender to a receiver, consists of three algorithms: Gen, Encap, and Decap. Circles shaded blue—the receiver's public key <math>pk</math> and the encapsulation <math>c</math>—can be safely revealed to an adversary, while boxes shaded red—the receiver's private key <math>sk</math> and the encapsulated secret key <math>k</math>—must be kept secret. The secret key <math>k</math> is chosen at random inside the logic of Encap, and the sender has no control over it.

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 confidentially, in spite of eavesdropping and intercepting adversaries.{{cite book |author-last=Galbraith |author-first=Steven |author-last=Shoup |author-first=Victor |author-link=Victor Shoup |editor-last=Preneel |editor-first=Bart |editor-link=Bart Preneel |conference-url=https://link.springer.com/book/10.1007/3-540-45539-6 |doi-access=free |author-last1=Cramer |author-first1=Ronald |author-link1=Ronald Cramer |author-last2=Shoup |author-first2=Victor |author-link2=Victor Shoup |url-access=subscription |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

Flow diagram of a public-ken encryption scheme, relating the inputs and outputs of its Gen, Encrypt, and Decrypt algorithms
A public-key encryption scheme, to confidentially transport an ''arbitrary message'' <math>m</math> from a sender to a receiver. The message <math>m</math> is chosen by the sender.

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 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 |chapter-url=https://cacr.uwaterloo.ca/hac/about/chap8.pdf#page=2 |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 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 |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. |author-last1=Hofheinz |author-first1=Dennis |author-last2=Hövelmanns |author-first2=Kathrin |author-last3=Kiltz |author-first3=Eike |editor-last1=Kalai |editor-first1=Yael |editor-last2=Reyzin |editor-first2=Leonid |conference-url=https://link.springer.com/book/10.1007/978-3-319-70500-2 |doi-access=free

  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").

In the asymptotic setting of theoretical cryptography, the algorithms are all probabilistic polynomial-time in a security parameter \lambda, and the length of the secret key k is a function of the security parameter \lambda.

In practical cryptography, the secret key k is usually of a fixed length for each algorithm. For example, ML-KEM always uses 256-bit secret keys, while the algorithms in vary between 256-, 384-, and 512-bit secret keys; secret keys of arbitrary length can be derived from k by a key derivation function.{{citation |author1-last=Alagic |author1-first=Gorjan |author2-last=Barker |author2-first=Elaine |author3-last=Chen |author3-first=Lily |author4-last=Dustin |author4-first=Moody |author5-last=Robinson |author5-first=Angela |author6-last=Silberg |author6-first=Hamilton |author7-last=Waller |author7-first=Noah |doi-access=free

Explicit ''vs.'' implicit rejection

Decapsulation can fail because its input c' is not an encapsulation c returned by Encap, but has been tampered with or maliciously crafted. KEMs which report failure by a distinguished symbol \bot (implemented in practice by returning an error code or raising an exception) are said to use explicit rejection. A KEM may instead return a random secret key in this event, or a secret key derived pseudorandomly from c' under the key sk; this is called implicit rejection.{{cite thesis

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 adaptive 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.

Applications

Public-key encryption

A key encapsulation mechanism can be used together with an authenticated symmetric cipher to construct a public-key encryption scheme for arbitrary messages. The security requirement for the symmetric cipher, called a data encapsulation mechanism or DEM, is indistinguishability against chosen-ciphertext attack for a single message encrypted by the sender.

Given a secure KEM with algorithms Gen/Encap/Decap, and a secure DEM E_k(m), the following hybrid public-key encryption scheme is also secure against adaptive chosen-ciphertext attack in the public-key setting:

  • Key generation: Same as the KEM.
  • To encrypt a message m for a public key \mathit{pk}:
    1. Let (k, c) := \operatorname{Encap}(\mathit{pk}).
    2. Let \sigma := E_k(m).
    3. Send (c, \sigma) as the ciphertext.
  • To decrypt a ciphertext (c', \sigma') with private key \mathit{sk}:
    1. Let k' := \operatorname{Decap}(\mathit{sk}, c'), or fail if it fails.
    2. Return the message E_{k'}^{-1}(\sigma'), or fail if it fails.

Note that—as with any public-key encryption on its own—this does not authenticate the sender: anyone with the public key can send a message to a recipient with the private key. Other cryptography, such as digital signatures, must be used in a protocol for a sender to prove its identity to the receiver.{{citation |author-last=An |author-first=Jee Hea

The use of an authenticated symmetric cipher is nevertheless required in this anonymous public-key encryption scheme to meet IND-CCA security. If an unauthenticated cipher were used, secure only against chosen-plaintext attack (IND-CPA), an adversary could selectively modify a message through its ciphertext in transit, which not only fails IND-CCA on a technicality{{cite conference |author-last1=Bellare |author-first1=Mihir |author-link1=Mihir Bellare |author-last2=Desai |author-first2=Anand |author-last3=Pointcheval |author-first3=David |author-link3=David Pointcheval |author-last4=Rogaway |author-first4=Phillip |author-link4=Phillip Rogaway |editor-last=Krawczyk |editor-first=Hugo |editor-link=Hugo Krawczyk |book-title=18th Annual International Cryptology Conference, Santa Barbara, California, USA, August 23–27, 1998, Proceedings |conference-url=https://link.springer.com/book/10.1007/BFb0055715 |doi-access=free |author-last1=Poddebniak |author-first1=Damian |author-last2=Dresen |author-first2=Christian |author-last3=Müller |author-first3=Jens |author-last4=Ising |author-first4=Fabian |author-last5=Schinzel |author-first5=Sebastian |author-last6=Friedberger |author-first6=Simon |author-last7=Somorovsky |author-first7=Juraj |author-last8=Schwenk |author-first8=Jörg |book-title=27th USENIX Security Symposium (USENIX Security 18)

Key agreement protocols

A KEM can also be used in an authenticated key agreement protocol such as TLS with forward secrecy for an online session, by having the client and server generate KEM key pairs and exchange signed encapsulations using those key pairs, which they then erase at the end of the session.

Combining KEMs

Different KEMs rely on different mathematical problems for their security. For example, the security of Rabin-KEM relies on the difficulty of integer factorization, which has been studied for centuries, but is known to be vulnerable to quantum computers capable of running Shor's algorithm. In contrast, the security of ML-KEM relies on the difficulty of learning with errors, which has only been studied for decades, but is not known to be vulnerable even to an adversary with a Shor-capable quantum computer.

A KEM combiner is a scheme for combining two KEMs, KEM1 and KEM2 with respective encapsulation algorithms KEM1.Encap and KEM2.Encap and so on, into a combined KEM which is secure if either KEM1 or KEM2 is secure.{{cite conference |author-last1=Giacon |author-first1=Federico |author-last2=Heuer |author-first2=Felix |author-last3=Poettering |author-first3=Bertram |editor-last1=Abdalla |editor-first1=Michel |editor-last2=Dahab |editor-first2=Ricardo |book-title=21st IACR International Conference on Practice and Theory of Public-Key Cryptography, Rio de Janeiro, Brazil, March 25–29, 2018, Proceedings, Part I |conference-url=https://link.springer.com/book/10.1007/978-3-319-76578-5 |doi-access=free

A KEM that combines a quantum-vulnerable KEM such as DH-KEM using X25519 with a post-quantum KEM such as ML-KEM is sometimes called a hybrid,{{cite conference |author-last1=Bindel |author-first1=Nina |author-last2=Brendel |author-first2=Jacqueline |author-last3=Fischlin |author-first3=Marc |author-last4=Goncalves |author-first4=Brian |author-last5=Stebila |author-first5=Douglas |editor-last1=Ding |editor-first1=Jintai |editor-last2=Steinwaldt |editor-first2=Rainer |book-title=10th International Conference, PQCrypto 2019, Chongqing, China, May 8–10, 2019 Revised Selected Papers |conference-url=https://link.springer.com/book/10.1007/978-3-030-25510-7 |url-access=subscription

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 |author-last=Stinson |author-first=Douglas R. |author-link=Doug Stinson |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 |doi-access=free

  • Key generation, (\mathit{pk}, \mathit{sk}) := \operatorname{Gen}():
  1. Generate a t-bit semiprime n with 2^{t - 1} 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
  • 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 .
  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 |editor-last=Krawczyk |editor-first=Hugo |editor-link=Hugo Krawczyk |conference-url=https://link.springer.com/book/10.1007/BFb0055715 |doi-access=free |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 |editor-last=Preneel |editor-first=Bart |editor-link=Bart Preneel |conference-url=https://link.springer.com/book/10.1007/3-540-45539-6 |doi-access=free

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

  • 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 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 |author-last=Elgamal |author-first=Taher |author-link=Taher Elgamal |editor-last1=Blakley |editor-first1=George Robert |editor-link=George Blakley |editor-last2=Chaum |editor-first2=David |editor-link2=David Chaum |conference-url=https://link.springer.com/book/10.1007/3-540-39568-7 |doi-access=free

  • 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 |doi-access=free

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 Elgamal-KEM or DH-KEM—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, or DHKEM(...) instances.

References

Info: Wikipedia Source

This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page.

Want to explore this topic further?

Ask Mako anything about Key encapsulation mechanism — get instant answers, deeper analysis, and related topics.

Research with Mako

Free with your Surf account

Content sourced from Wikipedia, available under CC BY-SA 4.0.

This content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.

Report