Documentation

CslibFrontier.Crypto.Computational.Encryption.Authenticated.Malleability

Ciphertext-mauling attacks on symmetric ciphers #

A symmetric cipher fails ciphertext integrity as soon as an adversary can transform (maul) an honest ciphertext into a different word that still decrypts ([BS23], Section 9.1). It fails chosen-ciphertext security when, in addition, what the mauled word decrypts to reveals which message was encrypted ([BS23], Section 9.2.1). A mauled word that decrypts to the same plaintext in both worlds breaks ciphertext integrity but not CCA security. This module packages the two attacks that the cipher counterexamples of the library share. Each result here is an attack theorem: it concludes that a cipher is not secure.

maulCIAdversary maul bit ctBound asks for an encryption of bit^n, reads the first ctBound n bits of the reply and outputs maul n of them. If, on every honest key and ciphertext, the mauled word differs from the ciphertext and decrypts, it wins the ciphertext-integrity games with probability 1.

maulCCAAdversary maul target ctBound asks for the challenge encryption of (0^n, 1^n), asks the decryption oracle on maul n of the (truncated) ciphertext, and outputs whether the first n + 1 bits of the oracle's reply equal encOption encBits (some target^n), which is n + 1 bits long. The CCA hypothesis is world-dependent: in world bit the mauled word must differ from the challenge and decrypt to (cond target bit !bit)^n, the challenge message itself when target = true and its complement when target = false. The adversary then outputs bit for n ≥ 1. A variant allows any other outcome on a bad event of negligible probability in each world.

Main definitions #

Main results #

References #

The mauling forger #

One-query ciphertext-mauling forger: it asks for an encryption of bit^n, reads the first ctBound n bits of the reply and outputs maul n of them.

theorem Cslib.Crypto.SymmetricCipher.eval_ciOneTimeGame_maulCIAdversary (E : SymmetricCipher) {maul : ℕ → List Bool → List Bool} (bit : Bool) (ctBound : ℕ → ℕ) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) (hmaul : ∀ k ∈ (E.keyGen n).eval.support, ∀ ct ∈ (E.encrypt n k (List.replicate n bit)).eval.support, maul n ct ≠ ct ∧ (E.decrypt n k (maul n ct)).isSome = true) :
(E.ciOneTimeGame (maulCIAdversary maul bit ctBound) n).eval = PMF.pure true

The mauling forger wins ciOneTimeGame with probability 1 at a parameter n where ctBound n bounds the ciphertext lengths and, on every honest key and ciphertext of bit^n, the mauled word differs from the ciphertext and decrypts.

theorem Cslib.Crypto.SymmetricCipher.eval_ciGame_maulCIAdversary (E : SymmetricCipher) {maul : ℕ → List Bool → List Bool} (bit : Bool) (ctBound : ℕ → ℕ) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) (hmaul : ∀ k ∈ (E.keyGen n).eval.support, ∀ ct ∈ (E.encrypt n k (List.replicate n bit)).eval.support, maul n ct ≠ ct ∧ (E.decrypt n k (maul n ct)).isSome = true) :
(E.ciGame (maulCIAdversary maul bit ctBound) n).eval = PMF.pure true

The mauling forger wins ciGame with probability 1 under the conditions of eval_ciOneTimeGame_maulCIAdversary.

A polynomial-time ciphertext maul breaks one-time ciphertext integrity. If, for every n ≥ n₀, on every honest key and ciphertext of bit^n, maul n changes the ciphertext into a word that decrypts, then E is not OneTimeCiphertextIntegrity.

The mauling distinguisher #

def Cslib.Crypto.SymmetricCipher.maulCCAAdversary (maul : ℕ → List Bool → List Bool) (target : Bool) (ctBound : ℕ → ℕ) :

Two-query ciphertext-mauling distinguisher: it asks for the challenge encryption of (0^n, 1^n), reads the first ctBound n bits of the reply, asks the decryption oracle on maul n of them, and outputs whether the first n + 1 bits of the reply encode target^n.

theorem Cslib.Crypto.SymmetricCipher.eval_ccaOneTimeGame_maulCCAAdversary (E : SymmetricCipher) {maul : ℕ → List Bool → List Bool} (target bit : Bool) (ctBound : ℕ → ℕ) (n : ℕ) (hctBound : E.CiphertextLengthLE n (ctBound n)) (msg : List Bool) (hmaul : ∀ k ∈ (E.keyGen n).eval.support, ∀ ct ∈ (E.encrypt n k (List.replicate n bit)).eval.support, maul n ct ≠ ct ∧ E.decrypt n k (maul n ct) = some msg) :

The mauling distinguisher's output in world bit at a parameter n where ctBound n bounds the ciphertext lengths and, on every honest key and ciphertext of bit^n, the mauled word differs from the ciphertext and decrypts to msg: it is the test of the first n + 1 bits of the encoding of msg against target^n.

theorem Cslib.Crypto.SymmetricCipher.eval_ccaOneTimeGame_maulCCAAdversary_eq_pure (E : SymmetricCipher) {maul : ℕ → List Bool → List Bool} (target bit : Bool) (ctBound : ℕ → ℕ) {n : ℕ} (hn : bit = true ∨ 1 ≤ n) (hctBound : E.CiphertextLengthLE n (ctBound n)) (hmaul : ∀ k ∈ (E.keyGen n).eval.support, ∀ ct ∈ (E.encrypt n k (List.replicate n bit)).eval.support, maul n ct ≠ ct ∧ E.decrypt n k (maul n ct) = some (List.replicate n (bif target then bit else !bit))) :
(E.ccaOneTimeGame (maulCCAAdversary maul target ctBound) bit n).eval = PMF.pure bit

The mauling distinguisher outputs the challenge bit with probability 1 in world bit, for bit = true or n ≥ 1, when on every honest key and ciphertext of bit^n the mauled word differs from the ciphertext and decrypts to (cond target bit !bit)^n.

theorem Cslib.Crypto.SymmetricCipher.not_oneTimeINDCCA_of_maul_or_bad (E : SymmetricCipher) {maul : ℕ → List Bool → List Bool} (hmaulPoly : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => maul p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits) (target : Bool) (bad : ℕ → Bool → List Bool → List Bool → Bool) (hbadNeg : ∀ (bit : Bool), Negligible fun (n : ℕ) => Game.succProbability do let k ← (E.keyGen n).eval let ct ← (E.encrypt n k (List.replicate n bit)).eval pure (bad n bit k ct)) (n₀ : ℕ) (hmaul : ∀ (n : ℕ), n₀ ≤ n → ∀ (bit : Bool), ∀ k ∈ (E.keyGen n).eval.support, ∀ ct ∈ (E.encrypt n k (List.replicate n bit)).eval.support, maul n ct ≠ ct ∧ (E.decrypt n k (maul n ct) = some (List.replicate n (bif target then bit else !bit)) ∨ bad n bit k ct = true)) :

A polynomial-time ciphertext maul breaks one-time CCA security, up to a bad event. If, for every n ≥ n₀ and world bit, on every honest key k and ciphertext ct of bit^n, maul n changes ct into a word that decrypts to (cond target bit !bit)^n unless bad n bit k ct holds, and the bad event has negligible probability in each world, then E is not OneTimeINDCCA.

theorem Cslib.Crypto.SymmetricCipher.not_oneTimeINDCCA_of_maul (E : SymmetricCipher) {maul : ℕ → List Bool → List Bool} (hmaulPoly : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool) => maul p.1 p.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits) (target : Bool) (n₀ : ℕ) (hmaul : ∀ (n : ℕ), n₀ ≤ n → ∀ (bit : Bool), ∀ k ∈ (E.keyGen n).eval.support, ∀ ct ∈ (E.encrypt n k (List.replicate n bit)).eval.support, maul n ct ≠ ct ∧ E.decrypt n k (maul n ct) = some (List.replicate n (bif target then bit else !bit))) :

A polynomial-time ciphertext maul breaks one-time CCA security. If, for every n ≥ n₀ and world bit, on every honest key and ciphertext of bit^n, maul n changes the ciphertext into a word that decrypts to (cond target bit !bit)^n, then E is not OneTimeINDCCA.