Randomized counter mode from a uniform pseudorandom function #
Randomized counter mode ([BS23], Section 5.4.2, printed p. 189) encrypts a message of
v blocks m[0], …, m[v - 1] under a key k by drawing a uniform initial value x and sending
(x, c) with c[j] = F(k, x + j mod N) ⊕ m[j]. Here the security parameter n is the block
length and N = 2 ^ n: the PRF family takes n-bit keys and n-bit inputs to n-bit outputs,
and the j-th counter block is ctrWordCounter n x j, the n-bit little-endian representation
of x + j mod 2 ^ n. A message is any word made of whole blocks. ctrWordEncrypt outputs the
word x ++ c, and ctrWordDecrypt inverts it; both are the shared envelope ivStreamEncrypt,
ivStreamDecrypt with the counter keystream ctrWordKeystream.
Security is many-query left-or-right CPA security (SymmetricINDCPAOn, Attack Game 5.2) on
equal-length pairs of whole blocks (blockPairValid), in the standard model, against uniform
strict oracle-PPT adversaries. The PRF distinguisher ctrToPrfDistinguisher adversary bit is the
shared stream reduction ivStreamToPrfDistinguisher with the counter keystream queries
ctrKeystreamQueries: it runs the adversary and answers each admissible request itself, drawing
the initial value and obtaining each keystream block with one query to its own function oracle,
keeping at most n bits of the reply.
- It is uniform strict oracle PPT whenever the adversary is
(
isOraclePPT_ctrToPrfDistinguisher). - Against the keyed oracle, its output law is that of the adversary in the CPA game with
challenge bit
bit(eval_prfRealGame_ctrToPrfDistinguisher). - Against a uniform random function, it is the typed reduction
ctrReduction ctrModCounterofCTRMode.leanrun on the adversary read as a block-mode adversary (blockModeWordAdversary), and the typed collision boundadvantage_idealExperiment_ctrReduction_leapplies. This gives the concrete boundadvantage_ctrWordCPAGame_leand thenPseudorandomFunction.indcpa_ctrWordEncrypt.
Deviations from Theorem 5.3 #
- No cap on the number of blocks. The source fixes a poly-bounded
ℓand the message spaceY^{≤ℓ}. Here every whole-block length is admitted, 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 for
prfCipher, the bound uses the PRF advantages ofctrToPrfDistinguisher adversary falseandctrToPrfDistinguisher adversary trueinstead of one distinguisher that flips the bit. Its collision term is2 (Q L) ^ 2 / 2 ^ nforQrequests of at mostLbits, rather than2 Q ^ 2 ℓ / N, because it bounds the blocks of all requests byQ Land the typed bound is quadratic in that total.
Main definitions #
Cslib.Crypto.ctrWordCounter,Cslib.Crypto.ctrWordKeystream: counter blocks and keystream.Cslib.Crypto.ctrWordEncrypt,Cslib.Crypto.ctrWordDecrypt: the cipher on whole-block words.Cslib.Crypto.ctrKeystreamStep,Cslib.Crypto.ctrKeystreamQueries: the keystream from the function oracle.Cslib.Crypto.ctrToPrfDistinguisher: the reduction to the PRF game.
Main results #
Cslib.Crypto.ctrWordDecrypt_ctrWordEncrypt: decryption inverts encryption.Cslib.Crypto.isPPTOn_ctrWordEncrypt,Cslib.Crypto.computableInPolyTime_ctrWordDecrypt: efficiency of the honest algorithms.Cslib.Crypto.isOraclePPTOn_ctrKeystreamQueries,Cslib.Crypto.isOraclePPT_ctrToPrfDistinguisher: the keystream queries and reduction are strict oracle PPT.Cslib.Crypto.eval_prfRealGame_ctrToPrfDistinguisher: the real PRF game of the reduction is the CPA game.Cslib.Crypto.advantage_ctrWordCPAGame_le: the concrete CPA bound.Cslib.Crypto.PseudorandomFunction.indcpa_ctrWordEncrypt: counter mode is CPA-secure for everyPseudorandomFunction.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 5.3 (Attack Game 5.2, printed pp. 181–182), Section 5.4.2 (printed p. 189) and Theorem 5.3 (printed p. 191).
The cipher #
Under a key of length n, a family with n-bit outputs on n-bit inputs produces a
keystream of blocks * n bits.
Decryption inverts encryption on whole-block messages under keys of length n.
Efficiency of the honest algorithms #
Counter blocks are computable in polynomial time from a unary width, the initial value and a unary offset.
The keystream is computable in polynomial time from the family's evaluator.
Counter-mode encryption is uniformly strict PPT in (n, k, msg).
Counter-mode decryption is computable in polynomial time on (n, k, ct).
The reduction to the PRF game #
The keystream of blocks blocks from the function oracle, with one query per block.
The PRF distinguisher built from a left-or-right CPA adversary against counter mode
([BS23], proof of Theorem 5.3): the shared stream reduction
ivStreamToPrfDistinguisher with the counter keystream queries ctrKeystreamQueries.
Answered by a deterministic oracle g with n-bit answers on n-bit requests, the keystream
queries return the concatenated answers at the counter blocks.
Answered by the keyed oracle under a key of length n, the keystream queries compute the
keystream.
Real game. Against the keyed oracle, ctrToPrfDistinguisher adversary bit has the output
law of adversary in the counter-mode CPA game with challenge bit bit.
The keystream queries are strict oracle PPT: each step makes one charged query and grows the
encoded state by at most n + 2 bits.
Efficiency of the reduction. For every uniform strict oracle-PPT adversary,
ctrToPrfDistinguisher adversary bit is uniform strict oracle PPT.
The ideal game #
Concrete CPA bound for counter mode, after [BS23], Theorem 5.3, (5.14). At
parameter n, an adversary making at most Q requests of at most L ≤ 2 ^ n bits has CPA
advantage against ctrWordEncrypt family at most the PRF advantages of
ctrToPrfDistinguisher adversary false and ctrToPrfDistinguisher adversary true plus
2 (Q L) ^ 2 / 2 ^ 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.14), which has one distinguisher with a factor 2
and the collision term 2 Q ^ 2 ℓ / N for ℓ blocks per request; see the module's deviations.
Counter mode is CPA-secure for a pseudorandom function ([BS23], Section 5.4.2,
Theorem 5.3): if family is a PseudorandomFunction, randomized counter mode with n-bit
blocks at security parameter n has negligible many-query left-or-right CPA advantage on
equal-length pairs of whole blocks, against every uniform strict oracle-PPT adversary. The
source fixes a poly-bounded cap ℓ on the number of blocks; here there is no cap, which implies
the statement for every ℓ.