MAC-then-Encrypt Composition and Chosen-Ciphertext Counterexample #
This module formalizes the generic MAC-then-Encrypt symmetric encryption construction
(macThenEncrypt), proves that it preserves INDCPA (indcpa_macThenEncrypt), and gives an
explicit counterexample showing that generic MAC-then-Encrypt does not achieve chosen-ciphertext
security (INDCCA or OneTimeINDCCA) or ciphertext integrity (CiphertextIntegrity), even when
the underlying cipher is INDCPA-secure and the MAC is SUFCMA-secure ([KL20],
Section 5.2; [BS23], Section 9.4.1).
- Generic MAC-then-Encrypt construction (
macThenEncrypt) andINDCPApreservation: given a symmetric cipherE, a MAC schemeMauthenticatingn-bit messages (M.msgLen n = n), and a polynomial-time length scheduleptLen : ℕ → ℕsuch that every encoded(msg, tag)pair on ann-bit message has lengthptLen n,macThenEncrypt E M ptLen ...generates keys at(ptLen n, n)and encrypts/decrypts the framed(msg, tag)pair underEat security parameterptLen n, discharging decryption completeness directly fromE.decrypt_encrypt. WhenptLenis strictly monotone andEisINDCPA,macThenEncryptisINDCPA(indcpa_macThenEncrypt). - Malleable CPA-preserving cipher extension (
extendCipher): appendsfalseto every ciphertext on encryption and ignores the last bit (ct.take (ct.length - 1)) during decryption. We proveextendCipherpreservesINDCPA(INDCPA.extendCipher) andOneTimeINDCPA(OneTimeINDCPA.extendCipher). - Explicit CI/CCA attack and PRF instantiation (
macThenEncrypt_extendCipher_counterexample,prfMacThenEncryptExtend_counterexample): replacing the trailingfalsebit of any ciphertext withtrueyields a distinct ciphertext with identical decryption undermacThenEncrypt E.extendCipher M ptLen ..., breakingOneTimeINDCCAandINDCCAwith exact advantage1for everyn ≥ 1andCiphertextIntegritywith probability1. Combining withindcpa_macThenEncryptand instantiating on(prfCipher ...).extendCipher+prfMAC ...gives a non-vacuous counterexample from anyPseudorandomFunction.
Main definitions #
Cslib.Crypto.macThenEncrypt: MAC-then-Encrypt symmetric cipher with plaintext-tag length scheduleptLen.Cslib.Crypto.mteToCPAHandler,Cslib.Crypto.mteToCPAAdversary:INDCPAreduction frommacThenEncryptatntoEatptLen n.Cslib.Crypto.SymmetricCipher.extendCipher: trailing-bit malleable symmetric cipher extension.Cslib.Crypto.SymmetricCipher.extendCPAAdversary,Cslib.Crypto.SymmetricCipher.extendOneTimeCPAAdversary: CPA reductions toE.Cslib.Crypto.macThenEncryptExtendCCAAdversary: two-query CCA distinguisher againstmacThenEncrypt E.extendCipher M ptLen ....Cslib.Crypto.macThenEncryptExtendCIAdversary: one-query CI adversary againstmacThenEncrypt E.extendCipher M ptLen ....Cslib.Crypto.prfMacThenEncryptExtend: end-to-end PRF-backed counterexample cipher atptLen n = 3 * n + 1.
Main results #
Cslib.Crypto.indcpa_macThenEncrypt:E.INDCPAimpliesINDCPAformacThenEncryptunder a strictly monotone polynomial-timeptLen.Cslib.Crypto.SymmetricCipher.INDCPA.extendCipher,Cslib.Crypto.SymmetricCipher.OneTimeINDCPA.extendCipher:extendCipherpreservesINDCPAandOneTimeINDCPA.Cslib.Crypto.advantage_ccaOneTimeGame_macThenEncrypt_extendCipher_eq_one: the explicit CCA attacker achieves exact distinguishing advantage1againstmacThenEncrypt E.extendCipher Mfor alln ≥ 1.Cslib.Crypto.not_oneTimeCiphertextIntegrity_macThenEncrypt_extendCipher,Cslib.Crypto.not_ciphertextIntegrity_macThenEncrypt_extendCipher,Cslib.Crypto.not_oneTimeINDCCA_macThenEncrypt_extendCipher,Cslib.Crypto.not_indcca_macThenEncrypt_extendCipher:macThenEncrypt E.extendCipher Mfails one-time/adaptive ciphertext integrity and CCA security.Cslib.Crypto.macThenEncrypt_extendCipher_counterexample,Cslib.Crypto.PseudorandomFunction.prfMacThenEncryptExtend_counterexample: joint separation theorems witnessingE'.INDCPA,M.SUFCMA, composedINDCPA, and all four negative bounds.
References #
- J. Katz, Y. Lindell, Introduction to Modern Cryptography, 3rd ed., Section 5.2 (MAC-then-Encrypt).
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 9.4.1.
MAC-then-Encrypt symmetric cipher: signs n-bit messages under km ← M.keyGen n and
encrypts the framed pair encPair encBits encBits (msg, tag) under ke ← E.keyGen (ptLen n) at
security parameter ptLen n. Because hpairLen guarantees the framed (msg, tag) pair has length
ptLen n, decryption completeness follows directly from E.decrypt_encrypt (ptLen n). Its
ciphertext space is E's at parameter ptLen n.
IND-CPA Preservation for MAC-then-Encrypt #
Oracle handler used by mteToCPAAdversary to simulate the CPA oracle of macThenEncrypt E M ptLen against E's CPA oracle at parameter ptLen n. On valid n-bit message pairs
(m0, m1), it signs both messages under km and forwards the pair of framed (msg, tag) pairs
to E's CPA oracle, truncating the reply to ctCap bits.
Reduction from cpaGame on macThenEncrypt E M ptLen (at security parameter n) to cpaGame
on E (at security parameter m = ptLen n): recovers n := GeneratorReindex.parameter ptLen m,
checks ptLen n == m, samples a MAC key km ← M.keyGen n, and interprets adversary n [] via
mteToCPAHandler.
mteToCPAAdversary preserves strict oracle-PPT admissibility (IsOraclePPT).
When ptLen is strictly monotone and ctBound (ptLen n) bounds all ciphertexts produced by
E.encrypt (ptLen n) on ptLen n-bit plaintexts under supported keys, E.cpaGame running
mteToCPAAdversary at security parameter ptLen n has the exact same output distribution as
(macThenEncrypt E M ptLen ...).cpaGame running adversary at n.
IND-CPA security preserves under MAC-then-Encrypt: when ptLen is strictly monotone and
computable in polynomial time, every encoded (msg, tag) pair on an n-bit message has length
ptLen n, and E is INDCPA-secure, then macThenEncrypt E M ptLen hptLenPoly hmsgLen hpairLen
is INDCPA-secure.
Trailing-bit malleable extension of E: appends false to every ciphertext on encryption and
ignores the final bit (ct.take (ct.length - 1)) during decryption. Its ciphertext space is the
nonempty words whose prefix without the final bit lies in E.ctSpace.
Oracle handler used by extendCPAAdversary to answer E.extendCipher CPA queries using
E's CPA oracle, truncating each response to ctBound bits and appending false.
Reduction from cpaGame on E.extendCipher to cpaGame on E: appends false to every
valid ciphertext returned by E's CPA oracle.
extendCPAAdversary preserves strict oracle-PPT admissibility (IsOraclePPT).
When ctBound n bounds E ciphertexts on n-bit plaintexts, E.cpaGame running
extendCPAAdversary ctBound adversary has the exact same distribution as E.extendCipher.cpaGame
running adversary.
Appending and ignoring a constant trailing bit preserves INDCPA.
Stateful oracle handler used by extendOneTimeCPAAdversary to answer at most one
E.extendCipher CPA query using E's one-time CPA oracle.
Reduction from cpaOneTimeGame on E.extendCipher to cpaOneTimeGame on E.
extendOneTimeCPAAdversary preserves strict oracle-PPT admissibility (IsOraclePPT).
Equivalence between E.cpaOneTimeGame running extendOneTimeCPAAdversary and
E.extendCipher.cpaOneTimeGame running adversary.
Appending and ignoring a constant trailing bit preserves OneTimeINDCPA.
Explicit CI and CCA Attacks on macThenEncrypt E.extendCipher M ptLen ... #
One-query ciphertext-integrity adversary against macThenEncrypt E.extendCipher M ptLen ...:
encrypts 0^n and flips the trailing false bit of the ciphertext to true.
macThenEncryptExtendCIAdversary is uniformly strict oracle-PPT.
macThenEncryptExtendCIAdversary succeeds with probability 1 in ciOneTimeGame against
macThenEncrypt E.extendCipher M ptLen ....
macThenEncrypt E.extendCipher M ptLen ... fails OneTimeCiphertextIntegrity for every
cipher E and MAC M satisfying hmsgLen and hpairLen.
macThenEncrypt E.extendCipher M ptLen ... fails CiphertextIntegrity for every cipher E
and MAC M satisfying hmsgLen and hpairLen.
Two-query chosen-ciphertext distinguisher against macThenEncrypt E.extendCipher M ptLen ...:
queries the challenge encryption oracle on (0^n, 1^n), flips the trailing false bit of the
returned ciphertext ct to true, queries the decryption oracle on the distinct ciphertext ct',
and outputs true iff the plaintext equals 1^n.
macThenEncryptExtendCCAAdversary is uniformly strict oracle-PPT.
In ccaOneTimeGame against macThenEncrypt E.extendCipher M ptLen ...,
macThenEncryptExtendCCAAdversary outputs bit with probability 1 whenever bit = true or
1 ≤ n.
macThenEncryptExtendCCAAdversary achieves exact one-time CCA advantage 1 against
macThenEncrypt E.extendCipher M ptLen ... for every n ≥ 1.
macThenEncrypt E.extendCipher M ptLen ... fails OneTimeINDCCA for every cipher E and
MAC M satisfying hmsgLen and hpairLen.
macThenEncrypt E.extendCipher M ptLen ... fails INDCCA for every cipher E and MAC M
satisfying hmsgLen and hpairLen.
Combined Separation Theorem and PRF Instantiation #
Generic MAC-then-Encrypt CCA/CI counterexample theorem: given any INDCPA-secure cipher
E, any SUFCMA-secure MAC M on n-bit messages, and a strictly monotone polynomial-time
plaintext-tag length schedule ptLen, the trailing-bit malleable extension E.extendCipher remains
INDCPA, macThenEncrypt E.extendCipher M ptLen ... remains INDCPA, yet fails
OneTimeCiphertextIntegrity, CiphertextIntegrity, OneTimeINDCCA, and INDCCA.
On an n-bit message under a supported key, every encoded (msg, tag) pair produced by
prfMAC family hpoly has exact length 3 * n + 1.
Concrete MAC-then-Encrypt counterexample cipher instantiated on
(prfCipher family).extendCipher and prfMAC family with plaintext-tag length schedule
ptLen n := 3 * n + 1.
Non-vacuous end-to-end MAC-then-Encrypt counterexample from any PseudorandomFunction:
for every uniform PseudorandomFunction family, (prfCipher ...).extendCipher is INDCPA,
prfMAC ... is SUFCMA, prfMacThenEncryptExtend is INDCPA, and prfMacThenEncryptExtend
fails OneTimeCiphertextIntegrity, CiphertextIntegrity, OneTimeINDCCA, and INDCCA.