Documentation

CslibFrontier.Crypto.Computational.Encryption.StreamMalleability

The one-block PRF cipher is not CCA-secure #

Boneh and Shoup open Section 9.2.1 ([BS23], printed pp. 360–361) with an attack on randomized counter mode: from an encryption c of u ‖ m an attacker builds ĉ, "the same as c except that ĉ[1] := c[1] ⊕ u ⊕ v", which decrypts to v ‖ m, so that "by querying for the decryption of ĉ, Mel was able to deduce the decryption of c". They conclude: "We proved that both encryption modes are CPA secure, and yet we just showed how to break them."

This file proves that conclusion in the chosen-ciphertext game for the one-block cipher prfCipher, which PseudorandomFunction.indcpa_prfCipher proves CPA-secure for a pseudorandom family. prfCipher encrypts as the stream envelope ivStreamEncrypt with one block, so ivStreamXorBody turns an encryption of msg into one of msg ⊕ delta (ivStreamXorBody_mem_support_ivStreamEncrypt). The adversary prfCipherCCAAdversary asks for the challenge encryption of 0ⁿ or 1ⁿ, flips every bit after the initial value and asks the decryption oracle for the result, which is a different ciphertext when 1 ≤ n; it decrypts to the other message, and the adversary wins with probability 1 (eval_ccaOneTimeGame_prfCipher).

Differences from the book: the attack is carried out in a game only against the one-block cipher prfCipher, since the library has no chosen-ciphertext game for multi-block modes; for counter mode and output feedback mode ivStreamDecrypt_ivStreamXorBody says what the modified ciphertext decrypts to. The randomized CBC half of Section 9.2.1 is not covered. The attack needs 1 ≤ n: at n = 0 the modified ciphertext is the challenge itself, which the oracle refuses to decrypt.

Main definitions #

Main results #

References #

Two-query chosen-ciphertext adversary against prfCipher ([BS23], Section 9.2.1): ask for the challenge encryption of (0ⁿ, 1ⁿ), XOR 1ⁿ into the ciphertext after its n-bit initial value, ask the decryption oracle for the result, and output true iff it decrypts to 0ⁿ.

theorem Cslib.Crypto.eval_ccaOneTimeGame_prfCipher (family : List Bool → List Bool → List Bool) (hpoly : Turing.MultiTapeTM.ComputableInPolyTime (fun (pair : List Bool × List Bool) => family pair.1 pair.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits) (hlen : ∀ (key query : List Bool), query.length = key.length → (family key query).length = key.length) (bit : Bool) {n : ℕ} (hn : 1 ≤ n) :

prfCipherCCAAdversary guesses the challenge bit of the one-time chosen-ciphertext game against prfCipher with probability 1, for every family and every 1 ≤ n ([BS23], Section 9.2.1).

theorem Cslib.Crypto.not_oneTimeINDCCA_prfCipher (family : List Bool → List Bool → List Bool) (hpoly : Turing.MultiTapeTM.ComputableInPolyTime (fun (pair : List Bool × List Bool) => family pair.1 pair.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits) (hlen : ∀ (key query : List Bool), query.length = key.length → (family key query).length = key.length) :
¬(prfCipher family hpoly hlen).OneTimeINDCCA

The one-block PRF cipher prfCipher is not one-time CCA-secure, for any family ([BS23], Section 9.2.1), although it is CPA-secure for a pseudorandom family (PseudorandomFunction.indcpa_prfCipher).

theorem Cslib.Crypto.not_indcca_prfCipher (family : List Bool → List Bool → List Bool) (hpoly : Turing.MultiTapeTM.ComputableInPolyTime (fun (pair : List Bool × List Bool) => family pair.1 pair.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encBits) (hlen : ∀ (key query : List Bool), query.length = key.length → (family key query).length = key.length) :
¬(prfCipher family hpoly hlen).INDCCA

The one-block PRF cipher prfCipher is not CCA-secure, for any family ([BS23], Section 9.2.1).