Documentation

CslibFrontier.Crypto.Computational.Encryption.EncryptThenMAC.PartialTag

Partial-Tag Encrypt-then-MAC Counterexample #

This module formalizes the ciphertext-integrity failure of partial-tag Encrypt-then-MAC ([BS23], Section 9.4.1.1, printed pp. 368–369): given a symmetric cipher producing 2 * n-bit ciphertexts r ++ c (an n-bit IV r and n-bit body c), the scheme signs and verifies only the second half c while leaving r unauthenticated.

We construct partialTagMAC M hmsgLen (wrapping any MACScheme M with ∀ n, M.msgLen n = n into a 2 * n-bit MACScheme that authenticates only the second half msg.drop (msg.length / 2)) and define prfCipherPartialTag directly via encryptThenMAC (prfCipher ...) (partialTagMAC ...). The explicit 1-query IsOraclePPT adversary partialTagCIAdversary ctBound queries 0^n, truncates the reply to ctBound n, and flips the first IV bit via Cslib.Crypto.flipHeadBit, winning ciOneTimeGame with probability 1 for every n ≥ 1 and unconditionally refuting OneTimeCiphertextIntegrity, CiphertextIntegrity, and AuthenticatedEncryption, while indcpa_encryptThenMAC immediately preserves INDCPA under any PseudorandomFunction.

Scope and deviations #

Boneh–Shoup Section 9.4.1.1 (printed pp. 368–369) illustrates partial-tag Encrypt-then-MAC over randomized CBC mode, where changing (r, c, t) to (r ⊕ Δ, c, t) both breaks ciphertext integrity and deterministically shifts the first decrypted plaintext block (m'[0] = m[0] ⊕ Δ). Here prfCipherPartialTag replaces randomized CBC with prfCipher (r ++ (F(k, r) ⊕ m)): flipping r evaluates the PRF on a fresh nonce rather than XORing into m, so only the ciphertext-integrity failure and preserved INDCPA are formalized here; the CBC plaintext-shift effect needs a CBC SymmetricCipher, and chosen-ciphertext security (INDCCA) of prfCipherPartialTag is neither proved nor refuted here.

Main definitions #

Main results #

References #

noncomputable def Cslib.Crypto.partialTagMAC (M : MACScheme) (hmsgLen : ∀ (n : ℕ), M.msgLen n = n) :

Lifts any MACScheme M on n-bit messages (∀ n, M.msgLen n = n) to a MACScheme on 2 * n-bit messages that signs and verifies only the second half msg.drop (msg.length / 2), leaving the n-bit prefix unauthenticated.

noncomputable def Cslib.Crypto.prfCipherPartialTag (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) (M : MACScheme) (hmsgLen : ∀ (n : ℕ), M.msgLen n = n) :

Partial-tag Encrypt-then-MAC over prfCipher ([BS23], Section 9.4.1.1, printed pp. 368–369): instantiates encryptThenMAC with prfCipher family hpoly hlen (2 * n-bit ciphertexts r ++ c) and partialTagMAC M hmsgLen, signing only the n-bit body c and leaving the n-bit IV r unauthenticated.

Note: this covers the partial-tag construction over prfCipher rather than randomized CBC mode, so the CBC plaintext-shift effect m'[0] = m[0] ⊕ Δ is not covered, and INDCCA security of this scheme is neither proved nor refuted here.

1-Query IV-Bit-Flip Attack and Ciphertext-Integrity Break #

Explicit 1-query ciphertext-integrity adversary against prfCipherPartialTag ([BS23], Section 9.4.1.1, printed pp. 368–369): queries 0^n, cuts the reply to ctBound n bits, splits (cFull, tag), and outputs encPair encBits encBits (flipHeadBit cFull, tag), flipping the first IV bit while leaving the body and MAC tag unchanged.

partialTagCIAdversary is uniformly strict oracle-PPT (IsOraclePPT) when ctBound is computable in plain polynomial time.

partialTagCIAdversary makes at most 1 encryption query.

theorem Cslib.Crypto.eval_ciOneTimeGame_prfCipherPartialTag_partialTagCIAdversary (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) (M : MACScheme) (hmsgLen : ∀ (n : ℕ), M.msgLen n = n) (ctBound : ℕ → ℕ) {n : ℕ} (hn : 1 ≤ n) (hctBound : (prfCipherPartialTag family hpoly hlen M hmsgLen).CiphertextLengthLE n (ctBound n)) :
((prfCipherPartialTag family hpoly hlen M hmsgLen).ciOneTimeGame (partialTagCIAdversary ctBound) n).eval = PMF.pure true

partialTagCIAdversary wins ciOneTimeGame against prfCipherPartialTag with probability 1 at every security parameter n ≥ 1 where ctBound n bounds ciphertext lengths.

theorem Cslib.Crypto.not_oneTimeCiphertextIntegrity_prfCipherPartialTag (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) (M : MACScheme) (hmsgLen : ∀ (n : ℕ), M.msgLen n = n) :

prfCipherPartialTag unconditionally fails OneTimeCiphertextIntegrity for every MACScheme on n-bit messages.

theorem Cslib.Crypto.not_ciphertextIntegrity_prfCipherPartialTag (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) (M : MACScheme) (hmsgLen : ∀ (n : ℕ), M.msgLen n = n) :
¬(prfCipherPartialTag family hpoly hlen M hmsgLen).CiphertextIntegrity

prfCipherPartialTag unconditionally fails CiphertextIntegrity for every MACScheme on n-bit messages.

theorem Cslib.Crypto.not_authenticatedEncryption_prfCipherPartialTag (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) (M : MACScheme) (hmsgLen : ∀ (n : ℕ), M.msgLen n = n) :
¬(prfCipherPartialTag family hpoly hlen M hmsgLen).AuthenticatedEncryption

prfCipherPartialTag unconditionally fails AuthenticatedEncryption for every MACScheme on n-bit messages.

IND-CPA Preservation and Combined Counterexample #

theorem Cslib.Crypto.PseudorandomFunction.indcpa_prfCipherPartialTag {family : List Bool → List Bool → List Bool} (hprf : PseudorandomFunction family) (M : MACScheme) (hmsgLen : ∀ (n : ℕ), M.msgLen n = n) :
(prfCipherPartialTag family ⋯ ⋯ M hmsgLen).INDCPA

For any secure PseudorandomFunction family, prfCipherPartialTag satisfies INDCPA by indcpa_encryptThenMAC and hprf.indcpa_prfCipher.

theorem Cslib.Crypto.PseudorandomFunction.prfCipherPartialTag_counterexample {family : List Bool → List Bool → List Bool} (hprf : PseudorandomFunction family) (M : MACScheme) (hmsgLen : ∀ (n : ℕ), M.msgLen n = n) :
(prfCipherPartialTag family ⋯ ⋯ M hmsgLen).INDCPA ∧ ¬(prfCipherPartialTag family ⋯ ⋯ M hmsgLen).OneTimeCiphertextIntegrity

End-to-end partial-tag Encrypt-then-MAC counterexample ([BS23], Section 9.4.1.1, printed pp. 368–369): for any secure PseudorandomFunction family and any MACScheme M on n-bit messages, prfCipherPartialTag remains INDCPA yet unconditionally fails OneTimeCiphertextIntegrity.