Cipher block chaining with a random IV from a uniform block cipher #
Cipher block chaining (CBC) with a random initialization vector ([BS23], Section 5.4.3,
printed p. 194) encrypts a message of v blocks m[0], …, m[v - 1] under a key k by drawing a
uniform initial value c[0] = iv and computing c[j + 1] = E(k, c[j] ⊕ m[j]), outputting
c[0] ++ c[1] ++ … ++ c[v]; decryption recovers m[j] = c[j] ⊕ D(k, c[j + 1]). Unlike CTR and OFB
modes, CBC decryption applies the block cipher's inverse D, so the cipher
(BlockCipher.cbcEncrypt, BlockCipher.cbcDecrypt) is parameterized by an arbitrary uniform
E : BlockCipher with key length E.keyLen n and block length E.blockLen n (with no id
restriction on either schedule), built from the width-parameterized core cbcWordEncrypt and
cbcWordDecrypt via ivModeEncrypt and ivModeDecrypt with the chained bodies cbcWordBody and
cbcWordDecBody (truncating each step output to the block width so encryption and decryption are
polynomial-time on arbitrary keys, which changes nothing on valid outputs).
Security is many-query left-or-right CPA security (SymmetricINDCPAOn, Attack Game 5.2 and
Definition 5.2) on equal-length pairs of whole blocks (blockPairValid), in the standard model,
against uniform strict oracle-PPT adversaries. For a BlockCipher E, the distinguisher
E.cbcToPrpDistinguisher adversary bit runs ivModeToPrfDistinguisher cbcBodyQueries at block
width E.blockLen n on adversary n [], answering each admissible pair by drawing a uniform
E.blockLen n-bit initial value and querying its encryption oracle sequentially on c[j] ⊕ m[j].
E.cbcToPrpDistinguisher adversary bitis uniform strict oracle PPT whenever the adversary is (BlockCipher.isOraclePPT_cbcToPrpDistinguisher).- Against
E.prpRealGame, it has the exact output law ofadversaryin the random-IV CBC CPA game forE.cbcEncryptwith challenge bitbit(BlockCipher.eval_prpRealGame_cbcToPrpDistinguisher). - Against a uniform random permutation, for an adversary whose requests have at most
Lbits, it has the output law of the typed CBC experiment (CBCMode.lean), giving the concrete block-cipher boundBlockCipher.advantage_cbcEncrypt_le(after Theorem 5.4, (5.22)) and the asymptotic CPA security theoremBlockCipher.PRP.indcpa_cbcEncrypt([BS23], Theorem 5.4, for anyE : BlockCipherwithE.PRPand super-polynomial block spaceNegligible fun n => ((2 : ℝ≥0) ^ E.blockLen n)⁻¹).
Deviations from Theorem 5.4 #
- Any number of whole blocks. Section 5.4.3 fixes a poly-bounded
ℓand the message spaceX^{≤ℓ}. HereblockPairValidadmits equal-length pairs of any number of wholeE.blockLen n-bit blocks, which implies the statement for everyℓ(a PPT adversary can only write polynomially long requests). - Two fixed-bit distinguishers and a cruder collision term. As in
CslibFrontier/Crypto/Computational/Encryption/CTRMode/Uniform.leanandCslibFrontier/Crypto/Computational/Encryption/OFBMode/Uniform.lean,BlockCipher.advantage_cbcEncrypt_lesums the PRP advantages of thefalseandtruedistinguishers instead of one coin-flipping distinguisher with factor2, and bounds the total encrypted blocks ofQrequests of at mostLbits byQ * L, giving the additive term4 * ((Q * L).choose 2 / 2 ^ E.blockLen n)rather than(5.22)'s2 Q ^ 2 ℓ ^ 2 / Nforℓblocks per request. - Uniform strict oracle-PPT adversaries in place of concrete/circuit adversaries, following the asymptotic reading of [BS23], Sections 2.3 and 4.1.5.
Main definitions #
Cslib.Crypto.cbcWordBody,Cslib.Crypto.cbcWordDecBody: the CBC encryption and decryption bodies after the initial value.Cslib.Crypto.cbcWordEncrypt,Cslib.Crypto.cbcWordDecrypt: width-parameterized random-IV CBC encryption and decryption core.Cslib.Crypto.BlockCipher.cbcEncrypt,Cslib.Crypto.BlockCipher.cbcDecrypt: random-IV CBC encryption and decryption for an arbitraryBlockCipher.Cslib.Crypto.cbcBodyStep,Cslib.Crypto.cbcBodyQueries: the CBC body computed from a word oracle.Cslib.Crypto.BlockCipher.cbcToPrpDistinguisher: the certified word-oracle block-cipher reduction.
Main results #
Cslib.Crypto.cbcWordDecrypt_cbcWordEncrypt,Cslib.Crypto.BlockCipher.cbcDecrypt_cbcEncrypt: round-trip decryption correctness.Cslib.Crypto.BlockCipher.isPPTOn_cbcEncrypt,Cslib.Crypto.BlockCipher.computableInPolyTime_cbcDecrypt: efficiency of the honest algorithms.Cslib.Crypto.run_cbcBodyQueries:cbcBodyQueriescomputescbcWordBodyagainst any deterministic oracle.Cslib.Crypto.BlockCipher.isOraclePPT_cbcToPrpDistinguisher: the reduction is uniform strict oracle PPT.Cslib.Crypto.BlockCipher.eval_prpRealGame_cbcToPrpDistinguisher: exact real-game bridge.Cslib.Crypto.BlockCipher.advantage_cbcEncrypt_le: concrete word-level CPA bound (after Theorem 5.4, (5.22)).Cslib.Crypto.BlockCipher.PRP.indcpa_cbcEncrypt: CBC mode with a random IV is CPA-secure for anyBlockCipher.PRPwith super-polynomial block space ([BS23], Theorem 5.4).
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 5.3 (Attack Game 5.2 and Definition 5.2, printed pp. 181–182), Section 5.4.3 (random-IV CBC, Theorem 5.4 and equation (5.22), printed pp. 194–199), and Section 4.4.3 (Theorems 4.4 and 4.6 and Corollary 4.5, printed pp. 134–136).
The cipher #
The CBC ciphertext body (after the initial value iv) of the msg.length / n blocks of msg
under encFamily k: starting from (iv, []), XOR the current chaining block with the next n-bit
message block, apply encFamily k truncated to n bits, and append it to the body so far.
Random-IV CBC encryption ([BS23], Section 5.4.3, printed pp. 194–195): draw a uniform
n-bit initial value iv and output iv followed by cbcWordBody encFamily n k iv msg.
The CBC decryption body (from initial value iv and ciphertext body body): recover each
n-bit plaintext block as the XOR of the previous ciphertext block with decFamily k of the
current ciphertext block (truncated to n bits).
Random-IV CBC decryption ([BS23], Section 5.4.3, printed p. 194): accept an n-bit
initial value followed by whole n-bit ciphertext blocks (ivModeDecrypt), and recover the
plaintext blocks via cbcWordDecBody. Malformed ciphertexts (shorter than n bits, or whose body
is not a multiple of n bits) return none.
Decryption inverts encryption on whole-block messages whenever encFamily k preserves
n-bit blocks and decFamily k left-inverts encFamily k on n-bit blocks.
Random-IV CBC encryption for an arbitrary uniform BlockCipher E ([BS23],
Section 5.4.3, printed p. 194): at parameter n, draw a uniform E.blockLen n-bit initial
value iv and output iv followed by cbcWordBody (E.encrypt n) (E.blockLen n) k iv msg.
Random-IV CBC decryption for an arbitrary uniform BlockCipher E ([BS23],
Section 5.4.3, printed p. 194): accept an E.blockLen n-bit initial value followed by whole
E.blockLen n-bit ciphertext blocks (ivModeDecrypt), and recover the plaintext blocks via
cbcWordDecBody (E.decrypt n).
For every BlockCipher E, E.cbcDecrypt inverts E.cbcEncrypt on whole-block messages
under E.keyLen n-bit keys.
Efficiency of the honest algorithms #
For every BlockCipher E, E.cbcEncrypt is uniformly strict PPT in (n, k, msg).
For every BlockCipher E, E.cbcDecrypt is computable in polynomial time on (n, k, ct).
Certified word-oracle reduction #
One CBC encryption query step: send the XOR of the chaining block prev and the next message
block to the function oracle, keep at most n bits of the reply as the next chaining block, and
append it to the ciphertext body so far.
The CBC ciphertext body of msg from initial value iv, computed with one query to the
function oracle per n-bit block.
Answered by any deterministic oracle g, cbcBodyQueries computes cbcWordBody for g.
Ideal games and concrete CPA bounds #
The block-cipher distinguisher built from a left-or-right CPA adversary against E.cbcEncrypt
([BS23], proof of Theorem 5.4, adversary B): run ivModeToPrfDistinguisher cbcBodyQueries at block width E.blockLen n on adversary n [].
Efficiency of the block-cipher reduction. For every BlockCipher E and every uniform
strict oracle-PPT adversary, E.cbcToPrpDistinguisher adversary bit is uniform strict oracle
PPT.
Real block-cipher game. Against E.prpRealGame, E.cbcToPrpDistinguisher adversary bit has
the exact output law of adversary in the random-IV CBC CPA game for E.cbcEncrypt with challenge
bit bit.
Concrete word-level CPA bound for random-IV CBC mode, after [BS23], Theorem 5.4,
(5.22). For any BlockCipher E, an adversary at parameter n making at most Q requests of at
most L bits has CPA advantage against E.cbcEncrypt at most the PRP advantages of
E.cbcToPrpDistinguisher adversary false and E.cbcToPrpDistinguisher adversary true plus
4 * ((Q * L).choose 2 / 2 ^ E.blockLen n). Requests of L bits ask for at most L blocks, so
Q * L bounds the blocks encrypted in total. This is not the bound (5.22), which has one
distinguisher with a factor 2 and the collision term 2 Q ^ 2 ℓ ^ 2 / N for ℓ blocks per
request; see the module's deviations.
Asymptotic CPA security (Theorem 5.4) #
Random-IV CBC mode is CPA-secure for a pseudorandom permutation ([BS23],
Section 5.4.3, Theorem 5.4, printed pp. 195–199): for any uniform BlockCipher E with E.PRP
and super-polynomial block space Negligible fun n => ((2 : ℝ≥0) ^ E.blockLen n)⁻¹, random-IV CBC
mode E.cbcEncrypt has negligible many-query left-or-right CPA advantage on equal-length pairs of
whole E.blockLen n-bit blocks under uniform E.keyLen n-bit keys, against every uniform strict
oracle-PPT adversary.