Documentation

CslibFrontier.Crypto.Computational.Encryption.CompositionCounterexamples

Generic Composition Counterexamples for Authenticated Encryption #

This module formalizes the generic composition separations and counterexamples of Katz and Lindell, Introduction to Modern Cryptography, 3rd ed., Chapter 5. They are stated in terms of fresh-message encryption unforgeability (SymmetricCipher.EncForge), which is defined, with its positive results, in CslibFrontier/Crypto/Computational/Encryption/EncForge.lean.

  1. Separation of INDCPA ∧ EncForge from INDCCA and CiphertextIntegrity (SymmetricCipher.tailFallback, INDCPA.tailFallback, EncForge.tailFallback, not_ciphertextIntegrity_tailFallback, not_indcca_tailFallback) ([KL20], Exercise 5.10, printed p. 165): for any E : SymmetricCipher, E.tailFallback keeps keyGen and encrypt unchanged and modifies decrypt n k ct to fall back to E.decrypt n k ct.tail whenever E.decrypt n k ct = none and !ct.isEmpty. This preserves INDCPA, OneTimeINDCPA, and EncForge, while unconditionally breaking OneTimeCiphertextIntegrity and CiphertextIntegrity (by prepending false to a queried ciphertext) and breaking OneTimeINDCCA and INDCCA whenever E.EncForge holds.
  2. Encrypt-then-MAC under a non-strong MAC (MACScheme.redundantTag, EUFCMA.redundantTag, not_sufCma_redundantTag, not_indcca_encryptThenMAC_redundantTag, encryptThenMAC_redundantTag_counterexample) ([KL20], Exercise 5.4, printed p. 164): for any M : MACScheme, M.redundantTag keeps keyGen, msgLen, and sign unchanged while accepting either M.verify sk msg tag or !tag.isEmpty && M.verify sk msg tag.tail. This preserves EUFCMA and OneTimeEUFCMA while breaking OneTimeSUFCMA and SUFCMA; when combined with any cipher E via encryptThenMAC E M.redundantTag hctLen, the resulting cipher satisfies INDCPA and EncForge (under E.INDCPA and M.EUFCMA) yet fails OneTimeCiphertextIntegrity and CiphertextIntegrity with adversary advantage 1, and OneTimeINDCCA and INDCCA with advantage 1 for every n ≥ 1.

Main definitions #

Main results #

References #

Katz–Lindell Exercise 5.10: INDCPA ∧ EncForge Does Not Imply INDCCA #

Given any symmetric cipher E, E.tailFallback has the same keyGen and encrypt as E, and decrypts ct by returning E.decrypt n k ct when it is some msg, or falling back to E.decrypt n k ct.tail when ct is non-empty and E.decrypt n k ct = none. This preserves INDCPA, OneTimeINDCPA, and EncForge, while unconditionally breaking OneTimeCiphertextIntegrity and CiphertextIntegrity (and breaking OneTimeINDCCA and INDCCA whenever E.EncForge holds, by querying decryption on false :: ct).

Modified symmetric cipher E.tailFallback ([KL20], Exercise 5.10, printed p. 165): keyGen and encrypt are identical to E, while decrypt n k ct returns E.decrypt n k ct whenever that succeeds and otherwise falls back to E.decrypt n k ct.tail on non-empty ct. Its ciphertext space is E.ctSpace together with the nonempty words whose tail lies in it.

@[simp]
theorem Cslib.Crypto.SymmetricCipher.cpaGame_tailFallback (E : SymmetricCipher) (adversary : OracleDistinguisher) (bit : Bool) (n : ℕ) :
E.tailFallback.cpaGame adversary bit n = E.cpaGame adversary bit n

E.tailFallback has the exact same cpaGame as E.

@[simp]

E.tailFallback has the exact same cpaOneTimeGame as E.

tailFallback preserves INDCPA ([KL20], Exercise 5.10, printed p. 165).

Reduction adversary that runs adversary and drops the leading bit of its candidate ciphertext (List.tail).

tailCIAdversary preserves any per-input query-count bound IsQueryBounded Q.

Quantitative EncForge bound for E.tailFallback ([KL20], Exercise 5.10, printed p. 165): any fresh-message forgery against E.tailFallback either already succeeds directly against E on ct or succeeds against E on ct.tail via tailCIAdversary.

tailFallback preserves EncForge ([KL20], Exercise 5.10, printed p. 165).

One-query ciphertext-integrity / EncForge adversary that queries encryption on bit^n (truncating the reply to ctBound n) and prepends false to the returned ciphertext.

In ciOneTimeGame against E.tailFallback, prependFalseBitCIAdversary bit ctBound wins with probability 1 at every security parameter n where ctBound n bounds ciphertext lengths.

In ciGame against E.tailFallback, prependFalseBitCIAdversary bit ctBound wins with probability 1 at every security parameter n where ctBound n bounds ciphertext lengths.

E.tailFallback never satisfies CiphertextIntegrity ([KL20], Exercise 5.10, printed p. 165).

Two-query CCA adversary against E.tailFallback ([KL20], Exercise 5.10, printed p. 165): queries left-or-right encryption on (0^n, 1^n) to obtain ct, queries decryption on false :: ct, and outputs whether the decrypted message equals some 1^n.

If E.EncForge holds, then E.tailFallback fails OneTimeINDCCA ([KL20], Exercise 5.10, printed p. 165).

If E.EncForge holds, then E.tailFallback fails INDCCA ([KL20], Exercise 5.10, printed p. 165).

Katz–Lindell Exercise 5.10 counterexample ([KL20], Exercise 5.10, printed p. 165): from any INDCPA and EncForge symmetric cipher E, E.tailFallback simultaneously satisfies INDCPA and EncForge while failing OneTimeCiphertextIntegrity, CiphertextIntegrity, OneTimeINDCCA, and INDCCA.

Katz–Lindell Exercise 5.4: Encrypt-then-MAC Under a Non-Strong MAC #

Given any M : MACScheme, M.redundantTag keeps msgLen, keyGen, and sign unchanged, while verify accepts tag whenever either M.verify sk msg tag holds or tag is non-empty and M.verify sk msg tag.tail holds. Consequently:

Redundant-tag MAC transformation ([KL20], Exercise 5.4, printed p. 164): M.redundantTag keeps msgLen, keyGen, and sign unchanged, while verify accepts tag when either M.verify sk msg tag holds or tag is non-empty and M.verify sk msg tag.tail holds.

noncomputable def Cslib.Crypto.MACScheme.tailTagForger (adversary : Forger) :

Forger reduction that strips the leading bit of the candidate forgery tag.

Quantitative EUFCMA bound for M.redundantTag ([KL20], Exercise 5.4, printed p. 164): any fresh-message forgery against M.redundantTag either succeeds directly against M or succeeds after stripping the leading bit of the tag via tailTagForger.

redundantTag preserves EUFCMA ([KL20], Exercise 5.4, printed p. 164).

noncomputable def Cslib.Crypto.MACScheme.redundantTagForger (M : MACScheme) (tagBound : ℕ → ℕ) :

One-query strong-MAC forger against M.redundantTag: queries 0^(M.msgLen n) (truncating the reply to tagBound n) and prepends false to the returned tag.

theorem Cslib.Crypto.MACScheme.eval_sufOneTimeGame_redundantTag_redundantTagForger (M : MACScheme) (tagBound : ℕ → ℕ) (n : ℕ) (htagBound : ∀ sk ∈ (M.keyGen n).eval.support, ∀ (msg : List Bool), msg.length = M.msgLen n → ∀ tag ∈ (M.sign sk msg).eval.support, tag.length ≤ tagBound n) :

In sufOneTimeGame against M.redundantTag, M.redundantTagForger tagBound wins with probability 1 at every security parameter n where tagBound n bounds tag lengths.

theorem Cslib.Crypto.MACScheme.eval_sufCmaGame_redundantTag_redundantTagForger (M : MACScheme) (tagBound : ℕ → ℕ) (n : ℕ) (htagBound : ∀ sk ∈ (M.keyGen n).eval.support, ∀ (msg : List Bool), msg.length = M.msgLen n → ∀ tag ∈ (M.sign sk msg).eval.support, tag.length ≤ tagBound n) :

In sufCmaGame against M.redundantTag, M.redundantTagForger tagBound wins with probability 1 at every security parameter n where tagBound n bounds tag lengths.

M.redundantTag never satisfies OneTimeSUFCMA ([KL20], Exercise 5.4, printed p. 164).

M.redundantTag never satisfies SUFCMA ([KL20], Exercise 5.4, printed p. 164).

If M.EUFCMA holds, then encryptThenMAC E M.redundantTag hctLen satisfies EncForge ([KL20], Exercise 5.4, printed p. 164).

One-query ciphertext-integrity adversary against encryptThenMAC E M.redundantTag hctLen ([KL20], Exercise 5.4, printed p. 164): queries encryption on 0^n (truncating the reply to ctBound n) to obtain ct = encPair encBits encBits (c, tag), and outputs encPair encBits encBits (unframe ct, false :: dropFrame ct).

In ciOneTimeGame against encryptThenMAC E M.redundantTag hctLen, etmRedundantCIAdversary ctBound wins with probability 1 at every security parameter n where ctBound n bounds ciphertext lengths.

In ciGame against encryptThenMAC E M.redundantTag hctLen, etmRedundantCIAdversary ctBound wins with probability 1 at every security parameter n where ctBound n bounds ciphertext lengths.

encryptThenMAC E M.redundantTag hctLen never satisfies OneTimeCiphertextIntegrity ([KL20], Exercise 5.4, printed p. 164).

encryptThenMAC E M.redundantTag hctLen never satisfies CiphertextIntegrity ([KL20], Exercise 5.4, printed p. 164).

encryptThenMAC E M.redundantTag hctLen never satisfies OneTimeAuthenticatedEncryption.

encryptThenMAC E M.redundantTag hctLen never satisfies AuthenticatedEncryption.

Two-query CCA adversary against encryptThenMAC E M.redundantTag hctLen ([KL20], Exercise 5.4, printed p. 164): queries left-or-right encryption on (0^n, 1^n) to obtain ct, queries decryption on encPair encBits encBits (unframe ct, false :: dropFrame ct), and outputs whether the decrypted message equals some 1^n.

In ccaOneTimeGame against encryptThenMAC E M.redundantTag hctLen at challenge bit bit, etmRedundantCCAAdversary ctBound outputs true iff some (List.replicate n bit) encodes to encOption encBits (some (List.replicate n true)).

encryptThenMAC E M.redundantTag hctLen never satisfies OneTimeINDCCA ([KL20], Exercise 5.4, printed p. 164).

encryptThenMAC E M.redundantTag hctLen never satisfies INDCCA ([KL20], Exercise 5.4, printed p. 164).

Katz–Lindell Exercise 5.4 counterexample ([KL20], Exercise 5.4, printed p. 164): for any INDCPA symmetric cipher E and any EUFCMA message authentication code M, M.redundantTag is EUFCMA-secure yet not SUFCMA-secure, and encryptThenMAC E M.redundantTag hctLen satisfies INDCPA and EncForge while failing OneTimeCiphertextIntegrity, CiphertextIntegrity, OneTimeINDCCA, and INDCCA.

Concrete Non-Vacuous PRF-Based Instantiations #

End-to-end PRF-based instantiation of Exercise 5.10: for any secure PseudorandomFunction family, (prfEncryptThenMAC family hprf.polyTime hprf.length_eq).tailFallback satisfies INDCPA and EncForge while failing OneTimeCiphertextIntegrity, CiphertextIntegrity, OneTimeINDCCA, and INDCCA.

Concrete PRF-based Encrypt-then-MAC cipher with a non-strong redundant-tag MAC ([KL20], Exercise 5.4, printed p. 164).

End-to-end PRF-based instantiation of Exercise 5.4: for any secure PseudorandomFunction family, prfEncryptThenMACRedundantTag satisfies INDCPA and EncForge while failing OneTimeCiphertextIntegrity, CiphertextIntegrity, OneTimeINDCCA, and INDCCA.