CBC mode with a random IV: typed random-function, random-permutation and keyed bounds #
Cipher block chaining with a random initialization vector ([BS23], Section 5.4.3,
printed pp. 194–195) encrypts the blocks m₁, …, m_k under a block function f as c₀ = iv
uniform and cᵢ = f (cᵢ₋₁ + mᵢ) (cbcEncryptBlocks). Theorem 5.4 of [BS23]
(printed pp. 195–199) states that it is CPA secure for a secure block cipher, with bound (5.22),
CPAadv ≤ 2 Q² ℓ² / N + 2 BCadv, for Q queries of at most ℓ blocks over N blocks.
This file proves the concrete typed steps of Theorem 5.4, not the asymptotic theorem: Games 1 to 3
and bound (5.28) against a uniform random function, the resulting bound with the block cipher
replaced by a uniform random permutation of BitString n, and the concrete keyed PRF and
block-cipher bounds (advantage_cbcCpaGame_prf_le and advantage_cbcCpaGame_le). The security
notion is the left-or-right experiment of RandomFunctionHybrid.lean (blockModeCpaExperiment),
and the advantage is the distance between the experiments for the two challenge bits, the book's
CPAadv. The word-level cipher, the certified oracle-PPT distinguisher and the asymptotic Theorem
5.4 are in CslibFrontier/Crypto/Computational/Encryption/CBCMode/Uniform.lean.
The proof:
- The CBC experiment is the real PRF experiment for the reduction
cbcReduction, which computes each ciphertext with its oracle (cbcCpaGame_eq_realExperiment, an application ofblockModeCpaExperiment_eq_realExperiment_simulate); the reduction makes one oracle call per block (isQueryBounded_cbcReduction). - Against a uniform random function sampled afresh, every ciphertext block is uniform, and a
query of
kblocks against a table oftinputs repeats an input with probability at most(k t + k.choose 2) / 2 ^ n(toOuterMeasure_badChain_le). The generic stepadvantage_idealExperiment_simulate_leofRandomFunctionHybrid.leanthen bounds the distance toblockModeIdealExperimentbyK.choose 2 / 2 ^ nwhen the queries ask at mostKblocks in total (advantage_idealExperiment_cbcReduction_le). - The ideal experiment does not depend on the challenge bit. With the PRP/PRF switching bound
PRP.advantage_idealExperiment_prfIdealExperiment_le(Theorem 4.6; the book's proof cites its block-cipher form, Theorem 4.4) for each bit, the advantage against a uniform random permutation is at most4 K.choose 2 / 2 ^ n(advantage_cbcCpaGame_randomPermutation_le). - For a keyed function
F, combiningcbcCpaGame_eq_realExperimentwith the two random-function hybrids bounds the CPA advantage by the two PRF advantages plus2 K.choose 2 / 2 ^ n(advantage_cbcCpaGame_prf_le). For a keyed permutationE, applyingPRP.prfAdvantage_le_advantage_add(Theorem 4.4) to eachK-query reduction gives the keyed boundPRP.advantage E (cbcReduction ℓ false adversary) + PRP.advantage E (cbcReduction ℓ true adversary) + 4 K.choose 2 / 2 ^ n(advantage_cbcCpaGame_le).
The bounds hold for every adversary. The query bound of the reduction is proved
(isQueryBounded_cbcReduction); no running-time certificate is claimed here (tracked in #4894 and
#5293 section 2).
Comparison with the book:
Kcounts the blocks of all queries. WithQqueries of at mostℓblocks,K ≤ Q ℓ, so the per-bit random-function boundK.choose 2 / 2 ^ nis at most (5.28)'sQ² ℓ² / (2N), and4 K.choose 2 / 2 ^ n ≤ 2 Q² ℓ² / N, the additive term of (5.22).- Equation (5.22) uses one coin-flipping block-cipher distinguisher with factor
2(2 BCadv[B, E]);advantage_cbcCpaGame_lesums the PRP advantages of the two fixed-bit reductionscbcReduction ℓ false adversaryandcbcReduction ℓ true adversary. - On p. 199 the book states the bit-guessing bound before the switching step as
CPAadv* ≤ Q² ℓ² / N + PRFadv[B, E]. This is a misprint in one displayed line: the printed inequality is true but too weak; (5.22)/(5.23)/(5.28) stand. For a uniform random function the bound proved here givesCPAadv* = CPAadv / 2 ≤ K.choose 2 / 2 ^ n ≤ Q² ℓ² / (2N), the constant that steps (5.24)–(5.29) give. - The bit-guessing form (5.23) is half of (5.22) and is not stated separately.
- A query whose two messages differ in length, or exceed
ℓblocks, encrypts the empty message and costs nothing (blockModeSelect); the book requires equal-length messages of at mostℓblocks.ℓ = 0is allowed.
Main definitions #
Cslib.Crypto.cbcCpaGame: the CBC left-or-right experiment for a keyed block function.Cslib.Crypto.cbcChainQueries,Cslib.Crypto.cbcQueryProgram,Cslib.Crypto.cbcReduction: the PRF distinguisher built from aBlockModeAdversary.
Main results #
Cslib.Crypto.cbcCpaGame_eq_realExperiment: the CBC experiment is the real PRF experiment for the reduction.Cslib.Crypto.isQueryBounded_cbcReduction: the reduction makes at mostKoracle calls.Cslib.Crypto.advantage_idealExperiment_cbcReduction_le: with a uniform random function, the reduction's view is withinK.choose 2 / 2 ^ nofblockModeIdealExperiment.Cslib.Crypto.advantage_cbcCpaGame_randomFunction_le: CBC mode with a uniform random function has left-or-right advantage at most2 K.choose 2 / 2 ^ n.Cslib.Crypto.advantage_cbcCpaGame_randomPermutation_le: CBC mode with a uniform random permutation has left-or-right advantage at most4 K.choose 2 / 2 ^ n.Cslib.Crypto.advantage_cbcCpaGame_prf_le: keyed PRF CPA bound for CBC mode.Cslib.Crypto.advantage_cbcCpaGame_le: keyed block-cipher CPA bound for CBC mode, corresponding to (5.22).
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Section 5.4.3, Theorem 5.4 and its proof, (5.22) and (5.28); Theorems 4.4 and 4.6.
The CBC left-or-right experiment for the keyed block function F with challenge bit b
([BS23], Attack Game 5.2, Section 5.4.3): a uniform key, then the adversary with access
to random-IV CBC encryption under that key.
The CBC ciphertext blocks of ms from chaining value c, computed with one call to the
function oracle per block: the input of each call is the previous ciphertext block plus the next
message block.
One CBC encryption computed with a function oracle: a private uniform initialization vector, then the ciphertext blocks of the selected plaintext from the oracle.
The PRF distinguisher built from a left-or-right adversary against CBC mode ([BS23],
proof of Theorem 5.4, adversary B): run the adversary and answer each query by CBC encryption
with the oracle, under the challenge bit b.
The CBC experiment for the keyed block function F is the real PRF experiment for F and
the reduction cbcReduction ℓ b adversary.
The chain makes one oracle call per block.
If the queries of adversary ask at most K blocks in total, the reduction makes at most
K oracle calls.
Fresh sampling #
Security of CBC mode #
The reduction against a uniform random function ([BS23], proof of
Theorem 5.4, Games 1 to 3 and (5.28)). If the queries of adversary ask at most K blocks in
total, then with a uniform random function the output of cbcReduction ℓ b adversary is within
K.choose 2 / 2 ^ n of blockModeIdealExperiment, whatever the challenge bit b.
CBC mode with a uniform random function. If the queries of adversary ask at most K
blocks in total, its left-or-right advantage against CBC mode with a uniform random block
function is at most 2 K.choose 2 / 2 ^ n.
Keyed PRF step of [BS23], Theorem 5.4, not the asymptotic theorem (typed
reduction without a running-time certificate, tracked in #4894 and #5293 section 2; see
CslibFrontier/Crypto/Computational/Encryption/CBCMode/Uniform.lean for the certified uniform
theorem). If the queries of adversary ask at most K blocks in total, its left-or-right
advantage against CBC mode with the keyed function F is at most the PRF advantages of
cbcReduction ℓ false adversary and cbcReduction ℓ true adversary, each making at most K
oracle calls (isQueryBounded_cbcReduction), plus 2 K.choose 2 / 2 ^ n.
Keyed block-cipher step (5.22) of [BS23], Theorem 5.4, not the asymptotic theorem
(typed reduction without a running-time certificate, tracked in #4894 and #5293 section 2; see
CslibFrontier/Crypto/Computational/Encryption/CBCMode/Uniform.lean for the certified uniform
theorem). If the queries of adversary ask at most K blocks in total, its left-or-right
advantage against CBC mode with the keyed permutation E is at most the PRP advantages of
cbcReduction ℓ false adversary and cbcReduction ℓ true adversary, each making at most K
oracle calls (isQueryBounded_cbcReduction), plus 4 K.choose 2 / 2 ^ n. With Q queries of at
most ℓ blocks, K ≤ Q ℓ and 4 K.choose 2 ≤ 2 Q ^ 2 ℓ ^ 2, matching (5.22).
CBC mode with a uniform random permutation: a step of the proof of [BS23],
Theorem 5.4, not the theorem. The block cipher is replaced by a uniform random permutation of
BitString n. If the queries of adversary ask at most K blocks in total, its left-or-right
advantage is at most 4 K.choose 2 / 2 ^ n: advantage_cbcCpaGame_le for the identity family on
Equiv.Perm (BitString n). With Q queries of at most ℓ blocks, K ≤ Q ℓ and
4 K.choose 2 ≤ 2 Q ^ 2 ℓ ^ 2, the additive term of (5.22).