Documentation

CslibFrontier.Crypto.Computational.Encryption.ECB

ECB mode of a word-level block cipher #

The asymptotic form of Boneh–Shoup §4.1.4 ([BS23], pp. 102–106) for a uniform block cipher E : BlockCipher. A message word is cut into blockLen n-bit blocks, each block is encrypted under the key, and the results are concatenated (BlockCipher.ecbEncrypt). Security is one-time semantic security, Attack Game 2.1 with a uniform keyLen n-bit key (Encryption.DEMOneTimeKeyINDCPAOn), against uniform strict PPT adversaries.

The reduction certificate rewrites the distinguisher as a word program that sends the blocks of the challenge message to the oracle in one list traversal, certified by Cslib.Probability.IsOraclePPTOn.mapM_query_take.

Main definitions #

Main results #

References #

@[reducible, inline]

The blockLen n-bit blocks of a message word: the rows of BitString.listRows, dropping a final partial block.

ECB encryption of a message word: encrypt each blockLen n-bit block under the key and concatenate.

def Cslib.Crypto.BlockCipher.ecbAdmissible (E : BlockCipher) (ℓ : ℕ → ℕ) (n : ℕ) (_pk m₀ m₁ : List Bool) :

The challenge pairs of Attack Game 2.1 for word ECB on X^{≤ℓ}: two messages of the same length, a multiple of the block length (blockPairValid), of at most ℓ n blocks.

def Cslib.Crypto.BlockCipher.ecbValid (E : BlockCipher) (ℓ : ℕ → ℕ) (n : ℕ) (pk m₀ m₁ : List Bool) :

The challenge pairs of Theorem 4.1 on words (X_*^{≤ℓ}): admissible pairs on X^{≤ℓ} whose two messages each consist of distinct blocks.

The block-cipher distinguisher of Theorem 4.1 on words: the typed reduction ECB.reduction, for the typed one-time adversary that A induces (its messages cut into blockLen n-bit blocks, its challenge flattened back into a word), run against the word oracle, each block query sent as its blockLen n bits and each reply read back as a block.

Admissible pairs #

theorem Cslib.Crypto.BlockCipher.ecbValid_eq_ecbAdmissible_of_le_one (E : BlockCipher) {ℓ : ℕ → ℕ} {n : ℕ} (hℓ : ℓ n ≤ 1) (pk m₀ m₁ : List Bool) :
E.ecbValid ℓ n pk m₀ m₁ = E.ecbAdmissible ℓ n pk m₀ m₁

When the block bound is at most 1, every admissible pair on X^{≤ℓ} has at most one block in each message, so ecbValid coincides with ecbAdmissible.

The real and ideal experiments #

Theorem 4.1, equation (4.3), on words: at each parameter, the one-time advantage of a word adversary against word ECB with challenge pairs ecbValid E ℓ is twice the block-cipher advantage of ecbToPrpDistinguisher E ℓ A.

Efficiency of the distinguisher #

Efficiency of the distinguisher. For a polynomial-time block bound ℓ and every uniform strict PPT one-time adversary A, ecbToPrpDistinguisher E ℓ A is uniform strict oracle PPT.

Theorem 4.1 on words #

Theorem 4.1 ([BS23], pp. 104–106): if E is a secure block cipher, its ECB cipher restricted to messages of at most ℓ n distinct blocks is semantically secure (Attack Game 2.1 with a uniform keyLen n-bit key), for every block bound ℓ computable in unary in polynomial time.

Single-block ECB semantic security ([BS23], §4.1.4, pp. 102, 104): if E is a secure block cipher, its ECB cipher on messages of at most one blockLen n-bit block (ecbAdmissible E (fun _ => 1)) is semantically secure. Here X^{≤1} admits pairs of empty messages (which are equal) and pairs of single blockLen n-bit blocks (the data block space).

The two-block attack on words #

The word-level two-block attack on ECB ([BS23], §4.1.4, pp. 103–104): submit m₀ = 0^{2 · blockLen n} (two equal 0^{blockLen n} blocks) and m₁ = 0^{blockLen n} ‖ 1^{blockLen n} (two unequal blocks when 1 ≤ blockLen n), and output true when the first blockLen n bits of the challenge ciphertext equal the remaining bits.

At any parameter n with 2 ≤ ℓ n and 1 ≤ E.blockLen n, the word-level two-block attack ecbTwoBlockAdversary has one-time semantic-security advantage 1 against ecbEncrypt on ecbAdmissible E ℓ ([BS23], §4.1.4, pp. 103–104).

Word-level ECB is not semantically secure ([BS23], §4.1.4, pp. 103–104): for every block cipher E and block bound ℓ, if 2 ≤ ℓ n and 1 ≤ E.blockLen n hold for infinitely many parameters n, then ecbEncrypt does not satisfy one-time semantic security on ecbAdmissible E ℓ.