Documentation

CslibFrontier.Crypto.Computational.Encryption.LinearChecksum

A stream cipher with a linear checksum has no ciphertext integrity #

Boneh and Shoup's Attack 3 on WEP in Section 9.10 ([BS23], printed pp. 390–391) encrypts a message together with its CRC checksum by a stream cipher, c = (m, CRC(m)) ⊕ RC4(IV ‖ k), and uses that "there is a public function L such that for any m and Δ … CRC(m ⊕ Δ) = CRC(m) ⊕ L(Δ)". An attacker who XORs (Δ, L(Δ)) into c gets a ciphertext that "decrypts without errors to m ⊕ Δ", so "given the encryption of m, an attacker can create a valid encryption of m ⊕ Δ for any Δ of his choice."

prfChecksumCipher encrypts msg ++ checksum msg under the one-block PRF cipher prfCipher at parameter n + csLen n, and decryption rejects unless the checksum matches. When checksum is linear with a public L, XORing delta ++ L delta into the ciphertext after its initial value gives an encryption of msg ⊕ delta, for every delta of length n (ivStreamXorBody_mem_support_encrypt_prfChecksumCipher). The adversary prfChecksumCIAdversary asks for an encryption of 0ⁿ and outputs it modified by 1ⁿ ++ L 1ⁿ, which decrypts to 1ⁿ; it wins the one-time ciphertext-integrity game with probability 1 for every 1 ≤ n (eval_ciOneTimeGame_prfChecksumCipher).

Differences from the book: prfCipher stands for RC4 and any checksum with the stated linearity for CRC-32; WEP itself is not modelled, and nothing is proved about the chosen-plaintext security of prfChecksumCipher. The book says that WEP, in a sense, uses MAC-then-encrypt with a CRC instead of a MAC; prfChecksumCipher is not an instance of macThenEncrypt, which frames its plaintext with encPair. The attack needs 1 ≤ n: at n = 0 the adversary's output can be the ciphertext it was given.

Main definitions #

Main results #

References #

The PRF stream cipher over message ‖ checksum, modelling WEP's c = (m, CRC(m)) ⊕ RC4(IV ‖ k) ([BS23], Section 9.10, Attack 3): encrypt msg ++ checksum msg with prfCipher at parameter n + csLen n, where csLen gives the checksum length, and on decryption return the first n bits only if the rest is their checksum. Its ciphertext space is prfCipher's at parameter n + csLen n.

theorem Cslib.Crypto.ivStreamXorBody_mem_support_encrypt_prfChecksumCipher (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) (checksum : List Bool → List Bool) (hcsPoly : Turing.MultiTapeTM.ComputableInPolyTime checksum Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) (csLen : ℕ → ℕ) (hcsLenPoly : Turing.MultiTapeTM.ComputableInPolyTime csLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hcsLen : ∀ (m : List Bool), (checksum m).length = csLen m.length) (L : List Bool → List Bool) (hlinear : ∀ (m d : List Bool), m.length = d.length → checksum (List.zipWith xor m d) = List.zipWith xor (checksum m) (L d)) {n : ℕ} {k msg delta ct : List Bool} (hmsg : msg.length = n) (hdelta : delta.length = n) (hct : ct ∈ ((prfChecksumCipher family hpoly hlen checksum hcsPoly csLen hcsLenPoly hcsLen).encrypt n k msg).eval.support) :
ivStreamXorBody (n + csLen n) (delta ++ L delta) ct ∈ ((prfChecksumCipher family hpoly hlen checksum hcsPoly csLen hcsLenPoly hcsLen).encrypt n k (List.zipWith xor msg delta)).eval.support

Malleability of a stream cipher with a linear checksum ([BS23], Section 9.10, Attack 3): if checksum (m ⊕ d) = checksum m ⊕ L d whenever m and d have the same length, then XORing delta ++ L delta into an encryption of an n-bit msg after its initial value gives an encryption of msg ⊕ delta, for every n-bit delta.

One-query ciphertext-integrity adversary against prfChecksumCipher ([BS23], Section 9.10, Attack 3): ask for an encryption of 0ⁿ and output it with 1ⁿ ++ L 1ⁿ XORed in after its initial value.

theorem Cslib.Crypto.eval_ciOneTimeGame_prfChecksumCipher (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) (checksum : List Bool → List Bool) (hcsPoly : Turing.MultiTapeTM.ComputableInPolyTime checksum Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) (csLen : ℕ → ℕ) (hcsLenPoly : Turing.MultiTapeTM.ComputableInPolyTime csLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hcsLen : ∀ (m : List Bool), (checksum m).length = csLen m.length) (L : List Bool → List Bool) (hlinear : ∀ (m d : List Bool), m.length = d.length → checksum (List.zipWith xor m d) = List.zipWith xor (checksum m) (L d)) {n : ℕ} (hn : 1 ≤ n) :
((prfChecksumCipher family hpoly hlen checksum hcsPoly csLen hcsLenPoly hcsLen).ciOneTimeGame (prfChecksumCIAdversary csLen L) n).eval = PMF.pure true

prfChecksumCIAdversary wins the one-time ciphertext-integrity game against prfChecksumCipher with probability 1 for every linear checksum and every 1 ≤ n ([BS23], Section 9.10, Attack 3).

The PRF stream cipher over message ‖ linear checksum is not one-time ciphertext-integral ([BS23], Section 9.10, Attack 3).

theorem Cslib.Crypto.not_ciphertextIntegrity_prfChecksumCipher (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) (checksum : List Bool → List Bool) (hcsPoly : Turing.MultiTapeTM.ComputableInPolyTime checksum Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) (csLen : ℕ → ℕ) (hcsLenPoly : Turing.MultiTapeTM.ComputableInPolyTime csLen Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encUnary) (hcsLen : ∀ (m : List Bool), (checksum m).length = csLen m.length) (L : List Bool → List Bool) (hLPoly : Turing.MultiTapeTM.ComputableInPolyTime L Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) (hlinear : ∀ (m d : List Bool), m.length = d.length → checksum (List.zipWith xor m d) = List.zipWith xor (checksum m) (L d)) :
¬(prfChecksumCipher family hpoly hlen checksum hcsPoly csLen hcsLenPoly hcsLen).CiphertextIntegrity

The PRF stream cipher over message ‖ linear checksum has no ciphertext integrity ([BS23], Section 9.10, Attack 3).