Authenticated Encryption and Adaptive Chosen-Ciphertext Security #
This module formalizes symmetric authenticated encryption (AuthenticatedEncryption) and adaptive
chosen-ciphertext security (INDCCA) following
Boneh and Shoup, A Graduate Course in Applied Cryptography, Version 0.6,
Chapter 5 (Sections 5.3 and 5.10) and Chapter 9 (Sections 9.1 and 9.2.2–9.2.3):
- Symmetric ciphers and adaptive CPA security (
SymmetricCipher,cpaGame,INDCPA,not_indcpa_of_ciphertext_length_eq) ([BS23], Section 5.3, Attack Game 5.2, Definition 5.2, and Example 5.1, printed pp. 181–182; Exercise 5.10(a), printed p. 211): a uniform symmetric cipher onn-bit messages at security parameternconsists of strict PPT key generationkeyGen, strict PPT encryptionencrypt, and deterministic polynomial-time decryptiondecryptreturningOption (List Bool)(encoded viaencOption encBits). IncpaGame, an adaptiveOracleDistinguishersubmits left-or-right pairs(m0, m1)ofn-bit messages and receivesencrypt n k (if bit then m1 else m0). We also formalize Example 5.1 and Exercise 5.10(a) (not_indcpa_of_ciphertext_length_eq): if every supported ciphertext of ann-bit message has lengthn, decryption completeness forcesencryptto be a deterministic permutation onn-bit strings, which a 2-query CPA adversary (detCPAAdversary) breaks with advantage1. - Ciphertext integrity and authenticated encryption (
ciGame,CiphertextIntegrity,AuthenticatedEncryption) ([BS23], Section 9.1, Attack Game 9.1 and Definitions 9.1–9.2, printed pp. 358–359): inciGame, an adaptiveCIAdversaryqueries an encryption oracle onn-bit messages (logging returned ciphertexts inqueriedCiphertexts) and wins by outputting a candidate ciphertextctsuch that!queriedCiphertexts.contains ctand(decrypt n k ct).isSome. A cipher providesAuthenticatedEncryptionwhen it satisfies bothINDCPAandCiphertextIntegrity. - Adaptive chosen-ciphertext security and AE $\Rightarrow$ CCA (
ccaGame,INDCCA,ccaToCPAAdversary,ccaToCIAdversary,ccaToCIHiddenBitAdversary,advantage_ccaGame_le,advantage_ccaGame_le_two_mul,AuthenticatedEncryption.indcca) ([BS23], Sections 9.2.2–9.2.3, Attack Game 9.2, Definition 9.5, and Theorem 9.1, printed pp. 362–365): inccaGame, a two-channelCCAAdversary(Operation = Bool) may interleave left-or-right encryption queries (false, recording challenge ciphertexts) with decryption queries (true, rejecting recorded challenge ciphertexts and returningencOption encBits (decrypt n k ct)on all other ciphertexts). Using the difference lemma (OracleComp.IdenticalUntilBad.advantage_le, [BS23], Theorem 4.7) betweenccaGameandccaRejectGame(where all decryption queries are rejected), we prove that everyAuthenticatedEncryptioncipher isINDCCA-secure.
The generic Encrypt-then-MAC composition ([BS23], Section 9.4.1, Theorem 9.2, printed pp. 367–368) and its concrete non-vacuous PRF-based cipher instance ([BS23], Section 5.4.1, Example 5.2 and Theorem 5.2, printed pp. 183–187) are planned for PR 3 of #1000.
Specializations and losses relative to Boneh–Shoup Chapter 9 #
- Fixed
n-bit plaintext domain at security parametern: encryption queries taken-bit messages (msg.length = ninciGame,m0.length = n ∧ m1.length = nincpaGameandccaGame). Malformed encryption queries return[]without invokingencryptor recording a challenge ciphertext. - Challenge-ciphertext decryption queries in
ccaOracle: in Section 9.2.2 (printed p. 362), the text stipulates that "The restriction we impose is that the adversary may not ask for the decryptions of any of these ciphertexts." InccaOracle, decryption queries on previously returned challenge ciphertexts (queriedCiphertexts) are instead answered with[] = encOption encBits none(rejection), which is equivalent for adversaries respecting the restriction and makesccaOraclea total function on all queries. - Omitted 1AE $\Rightarrow$ 1CCA half and query-count preservation in Theorem 9.1: Theorem 9.1
in [BS23] (printed p. 363) also states that
"If E is 1AE-secure, then it is 1CCA-secure."
(using Definition 9.6 on p. 363) and that "Moreover, Bcpa and Bci both make at most Qe encryption
queries." This module formalizes the multi-query adaptive
AuthenticatedEncryption(Definition 9.2) andINDCCA(Definition 9.5) notions and theAE ⇒ CCAimplication; the one-time notions (1AE,1CCA) and a separate encryption-query count preservation theorem are omitted. - Total-query budget in Theorem 9.1: in equation (9.3) of [BS23] (printed p. 363),
the CI term has coefficient
2 * Qd(whereQdbounds decryption queries). HereccaToCIAdversarysamples a query index uniformly from{0, ..., dyadicSize (Q n) - 1}viaProbComp.sampleDyadicIndex (Q n)(whereQ n < dyadicSize (Q n) ≤ 2 * Q n + 2) and decrements the countdown on every external oracle call (Sum.inr) of(adversary n []).IsQueryBounded (Q n), whereQ nbounds total queriesQe + Qd. This yields factordyadicSize (Q n)inadvantage_ccaGame_leand2 * dyadicSize (Q n) ≤ 4 * Q n + 4inadvantage_ccaGame_le_two_mul, which remains polynomial innforAuthenticatedEncryption.indcca.
Main definitions #
Cslib.Crypto.CIAdversary,Cslib.Crypto.CCAAdversary: adaptive ciphertext-integrity and chosen-ciphertext adversaries.Cslib.Crypto.SymmetricCipher: uniform symmetric cipher onn-bit messages.Cslib.Crypto.SymmetricCipher.cpaGame,INDCPA,detCPAAdversary: adaptive symmetric CPA game, security predicate, and 2-query determinism distinguisher ([BS23], Attack Game 5.2 / Definition 5.2 / Example 5.1).Cslib.Crypto.SymmetricCipher.ciGame,CiphertextIntegrity,AuthenticatedEncryption: ciphertext-integrity game, CI predicate, and AE predicate ([BS23], Attack Game 9.1 / Definitions 9.1–9.2).Cslib.Crypto.SymmetricCipher.ccaGame,ccaRejectGame,INDCCA: adaptive CCA game, all-reject hybrid game, and CCA security predicate ([BS23], Attack Game 9.2 / Definition 9.5).Cslib.Crypto.SymmetricCipher.ccaToCPAAdversary,ccaToCIAdversary,ccaToCIHiddenBitAdversary: Theorem 9.1 reductions from CCA to CPA and CI.
Main results #
Cslib.Crypto.SymmetricCipher.isPPTOn_cpaGame,isPPT_cpaGame,isPPTOn_ciGame,isPPT_ciGame,isPPTOn_ccaGame,isPPT_ccaGame: strict PPT certificates for the CPA, CI, and CCA experiments.Cslib.Crypto.SymmetricCipher.encrypt_eq_of_ciphertext_length_eq,Cslib.Crypto.SymmetricCipher.advantage_cpaGame_detCPAAdversary,Cslib.Crypto.SymmetricCipher.not_indcpa_of_ciphertext_length_eq: any cipher whose ciphertexts onn-bit messages have lengthnis forced by decryption completeness to be deterministic and hence cannot satisfyINDCPA([BS23], Example 5.1 and Exercise 5.10(a)).Cslib.Crypto.SymmetricCipher.isOraclePPT_ccaToCPAAdversary,Cslib.Crypto.SymmetricCipher.isOraclePPT_ccaToCIAdversary,Cslib.Crypto.SymmetricCipher.isOraclePPT_ccaToCIHiddenBitAdversary:IsOraclePPTcertificates for the Theorem 9.1 reductions.Cslib.Crypto.SymmetricCipher.advantage_ccaGame_le,Cslib.Crypto.SymmetricCipher.advantage_ccaGame_le_two_mul,Cslib.Crypto.SymmetricCipher.AuthenticatedEncryption.indcca: quantitative and asymptotic AE $\Rightarrow$ CCA security ([BS23], Theorem 9.1).
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 5.3 (pp. 181–182), Exercise 5.10(a) (p. 211), and Chapter 9, Sections 9.1 and 9.2.2–9.2.3 (pp. 357–365).
An adaptive ciphertext-integrity adversary receives the unary security parameter and an auxiliary word, queries an encryption oracle on chosen messages, and outputs a candidate ciphertext.
Instances For
An adaptive chosen-ciphertext distinguisher receives the unary security parameter and an
auxiliary word, queries a left-or-right encryption oracle (false) and a decryption oracle
(true), and outputs a distinguishing bit.
Instances For
A uniform symmetric cipher on n-bit messages at security parameter n, with strict
probabilistic polynomial-time key generation and encryption, deterministic polynomial-time
decryption (returning Option (List Bool)), and perfect decryption completeness on supported keys,
n-bit messages, and ciphertexts ([BS23], Sections 5.3 and 9.1).
Sample a symmetric secret key
kat unary security parametern.Probabilistically encrypt a message
msgunder secret keykat security parametern.Deterministically decrypt a candidate ciphertext
ctunder secret keykat parametern, returningnoneon rejection andsome msgon acceptance.- keyGen_ppt : Probability.IsPPTOn Turing.MultiTapeTM.encUnary Turing.MultiTapeTM.encBits self.keyGen
Key generation is uniformly strict PPT in the unary security parameter.
- encrypt_ppt : Probability.IsPPTOn (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits)) Turing.MultiTapeTM.encBits fun (p : ℕ × List Bool × List Bool) => self.encrypt p.1 p.2.1 p.2.2
Encryption is uniformly strict PPT in
(n, k, msg). - decrypt_polyTime : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : ℕ × List Bool × List Bool) => self.decrypt p.1 p.2.1 p.2.2) (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits)) (Turing.MultiTapeTM.encOption Turing.MultiTapeTM.encBits)
Decryption is computable in plain polynomial time on
(n, k, ct). - decrypt_encrypt (n : ℕ) (k : List Bool) : k ∈ (self.keyGen n).eval.support → ∀ (msg : List Bool), msg.length = n → ∀ ct ∈ (self.encrypt n k msg).eval.support, self.decrypt n k ct = some msg
Every ciphertext produced by
encrypton ann-bit message under a supported secret key at security parameterndecrypts tosome msg.
Instances For
E.keyGen composed with a plain polynomial-time parameter selector is uniformly strict PPT.
E.encrypt composed with plain polynomial-time parameter, key, and message selectors is
uniformly strict PPT.
E.decrypt composed with plain polynomial-time parameter, key, and ciphertext selectors is
computable in plain polynomial time.
Stateful left-or-right CPA encryption oracle ([BS23], Section 5.3, Attack Game 5.2):
decode the request into m0 = unframe request.2 and m1 = dropFrame request.2; if both have
length n, encrypt if bit then m1 else m0 under k, and otherwise return [].
Instances For
The adaptive symmetric IND-CPA experiment ([BS23], Section 5.3, Attack Game 5.2):
sample k ← E.keyGen n and run adversary n [] against E.cpaEncryptionOracle n k bit.
Instances For
Running an oracle-PPT distinguisher against cpaEncryptionOracle is uniformly strict PPT in
(n, k) for each challenge bit bit.
The symmetric CPA experiment is uniformly strict PPT in the unary security parameter.
The symmetric CPA experiment is uniformly strict PPT, independently of unused auxiliary input.
Impossibility of Zero-Expansion CPA Security (Boneh–Shoup Example 5.1 & Exercise 5.10(a)) #
Zero ciphertext expansion forces deterministic encryption ([BS23],
Exercise 5.10(a), printed p. 211): if every supported ciphertext of an n-bit message under a
supported key ke at parameter n has length n, then decryption completeness
(E.decrypt_encrypt) gives an injection from the 2^n plaintexts BitString n into BitString n
by choosing one supported ciphertext per plaintext; by finiteness of BitString n, this map is
surjective, forcing all supported ciphertexts of any n-bit plaintext msg under ke to
coincide.
Two-query CPA distinguisher against any deterministic symmetric cipher
([BS23], Example 5.1, printed p. 182): queries (0^n, 1^n) followed by (0^n, 0^n) and
outputs true iff the two returned ciphertexts are equal (c₁ == c₂).
Instances For
detCPAAdversary is uniformly strict oracle-PPT (IsOraclePPT encBool).
In Experiment false, detCPAAdversary receives two encryptions of 0^n; when all supported
ciphertexts of n-bit plaintexts have length n, both encryptions return the same ciphertext and
detCPAAdversary outputs true with probability 1.
In Experiment true for n ≥ 1, detCPAAdversary receives an encryption of 1^n followed by
an encryption of 0^n; by decryption completeness the two ciphertexts are distinct, so
detCPAAdversary outputs false with probability 1.
At every security parameter n ≥ 1 where supported ciphertexts of n-bit plaintexts have
length n, detCPAAdversary achieves CPA advantage 1 ([BS23], Example 5.1).
No zero-expansion symmetric cipher is CPA-secure ([BS23], Example 5.1 and
Exercise 5.10(a), printed pp. 182, 211): if for every security parameter n, every supported key
ke, and every n-bit message msg, every supported ciphertext of msg has length n, then E
cannot satisfy INDCPA.
Ciphertext Integrity and Authenticated Encryption (ciGame, CiphertextIntegrity, #
Stateful encryption oracle for the ciphertext-integrity game ([BS23], Section 9.1,
Attack Game 9.1): if request.2.length == n, encrypt request.2 under k, prepend the resulting
ciphertext to queriedCiphertexts, and return it; otherwise return [] without modifying the
ciphertext log.
Instances For
The ciphertext-integrity experiment ([BS23], Section 9.1, Attack Game 9.1):
sample k ← E.keyGen n, run adversary n [] with oracle access to E.ciEncryptionOracle n k, and
accept when the adversary outputs a candidate ciphertext ct that was never returned by the
encryption oracle (!out.2.contains out.1) and decrypts without rejection
((E.decrypt n k out.1).isSome).
Instances For
Running an oracle-PPT CI adversary against ciEncryptionOracle is uniformly strict PPT in
(n, k).
The ciphertext-integrity experiment is uniformly strict PPT in the unary security parameter.
The ciphertext-integrity experiment is uniformly strict PPT, independently of unused auxiliary input.
Ciphertext integrity (CiphertextIntegrity, or CI) for a symmetric cipher
([BS23], Section 9.1, Attack Game 9.1 and Definition 9.1): every uniform strict
IsOraclePPT encBits adversary has negligible probability of outputting a fresh valid
ciphertext.
Instances For
Ciphertext integrity gives negligible winning probability in ciGame for every oracle-PPT CI
adversary.
Establish CiphertextIntegrity by bounding every oracle-PPT CI adversary's winning
probability.
Authenticated encryption (AuthenticatedEncryption, or AE-security) for a symmetric cipher
([BS23], Section 9.1, Definition 9.2): the cipher satisfies both INDCPA and
CiphertextIntegrity.
Instances For
Adaptive Chosen-Ciphertext Security (ccaGame, ccaRejectGame, INDCCA) #
Stateful two-channel oracle for the adaptive chosen-ciphertext experiment ([BS23], Section 9.2.2, Attack Game 9.2):
- On an encryption query
(false, req): decodem0 = unframe reqandm1 = dropFrame req; if both have lengthn, encryptif bit then m1 else m0underk, prepend the resulting ciphertextcttoqueriedCiphertexts, and returnct; otherwise return[]. - On a decryption query
(true, ct): ifqueriedCiphertexts.contains ctistrue, return[](prohibited challenge ciphertext); otherwise returnencOption encBits (E.decrypt n k ct).
Instances For
The adaptive chosen-ciphertext experiment ([BS23], Section 9.2.2, Attack Game 9.2):
sample k ← E.keyGen n and run adversary n [] against E.ccaOracle n k bit.
Instances For
Running an oracle-PPT CCA adversary against ccaOracle is uniformly strict PPT in (n, k) for
each challenge bit bit.
The adaptive CCA experiment is uniformly strict PPT in the unary security parameter.
The adaptive CCA experiment is uniformly strict PPT, independently of unused auxiliary input.
Adaptive chosen-ciphertext security (INDCCA, or CCA-security) for a symmetric cipher
([BS23], Section 9.2.2, Attack Game 9.2 and Definition 9.5, printed p. 362): every
uniform strict IsOraclePPT encBool CCA adversary has negligible advantage between
E.ccaGame adversary false and E.ccaGame adversary true.
In [BS23], Section 9.2.2, Definition 9.5 defines adaptive multi-query CCA security,
whereas one-time CCA security (1CCA) is defined separately in Definition 9.6 (printed p. 363).
Instances For
Authenticated Encryption Implies Adaptive CCA Security (Boneh–Shoup Theorem 9.1) #
Hybrid two-channel oracle for Game 1 in the proof of [BS23], Theorem 9.1
(Section 9.2.3, printed pp. 363–364): encryption queries (false, req) behave identically to
ccaOracle, whereas every decryption query (true, _) immediately returns [] (rejection) without
invoking decrypt.
Instances For
The all-reject hybrid CCA experiment (Game 1 in [BS23], Section 9.2.3,
Theorem 9.1): sample k ← E.keyGen n and run adversary n [] against
E.ccaRejectOracle n k bit.
Instances For
Stateful handler for ccaToCPAAdversary ([BS23], Section 9.2.3, Theorem 9.1):
reject all decryption queries (true, _) with [], and forward valid left-or-right encryption
queries (false, req) to the external CPA encryption oracle (truncating replies to ctBound).
Instances For
Reduction from the all-reject hybrid ccaRejectGame to the adaptive CPA experiment cpaGame
([BS23], Section 9.2.3, adversary $B_{\mathrm{cpa}}$ in Theorem 9.1): run adversary n []
against ccaToCPAHandler n (ctBound n).
Instances For
ccaToCPAAdversary preserves strict oracle-PPT admissibility (IsOraclePPT).
When ctBound n bounds all ciphertext lengths produced by E.encrypt n k on n-bit messages,
running ccaToCPAAdversary ctBound adversary in cpaGame has the exact same output distribution as
ccaRejectGame adversary ([BS23], Section 9.2.3, equation (9.7) in the proof of
Theorem 9.1, printed p. 365).
Stateful handler for ccaToCIAtIndexAdversary and ccaToCIAdversary
([BS23], Section 9.2.3, adversary $B_{\mathrm{ci}}$ in Theorem 9.1):
maintains (rem, (hasCaptured, capturedCt)) : ℕ × (Bool × List Bool).
- Once
hasCaptured = true, all subsequent queries return[]without calling the external CI encryption oracle. - While
hasCaptured = false:- if
rem == 0, a decryption query(true, ct)captures(0, (true, ct))and an encryption query(false, _)captures(0, (true, [])), both returning[]without calling the external CI oracle; - if
rem != 0, a decryption query(true, _)returns([], (rem - 1, (false, []))), and an encryption query(false, req)with(unframe req).length == n && (dropFrame req).length == nqueries the external CI encryption oracle onif bit then dropFrame req else unframe req(truncating the reply toctBound) and transitions to(rem - 1, (false, [])).
- if
Instances For
Deterministic-index ciphertext-integrity reduction at query countdown j
([BS23], Section 9.2.3, Theorem 9.1): run adversary n [] against
ccaToCIHandler n (ctBound n) bit starting from (j, (false, [])) and output the captured
ciphertext candidate out.2.2.2.
Instances For
Reduction from decryption-oracle forgery in ccaRejectGame to the ciphertext-integrity game
ciGame for fixed challenge bit bit ([BS23], Section 9.2.3, adversary $B_{\mathrm{ci}}$
in Theorem 9.1): sample a uniform dyadic query countdown
j ← ProbOracleComp.sample (ProbComp.sampleDyadicIndex (Q n)) and run
ccaToCIAtIndexAdversary ctBound j bit adversary.
Instances For
Single-adversary ciphertext-integrity reduction that samples a hidden challenge bit uniformly
via BitString.sampleList 1 and invokes ccaToCIAdversary ([BS23], Section 9.2.3,
proof of Theorem 9.1, printed p. 364).
Instances For
ccaToCIAdversary preserves strict oracle-PPT admissibility (IsOraclePPT).
ccaToCIHiddenBitAdversary preserves strict oracle-PPT admissibility (IsOraclePPT).
Difference-Lemma Hop and Query-Budget Induction for Theorem 9.1 #
Running ccaToCIAdversary in ciGame averages ccaToCIAtIndexAdversary uniformly over
Fin (dyadicSize (Q n)).
Quantitative AE $\Rightarrow$ CCA bound ([BS23], Section 9.2.3, Theorem 9.1,
printed pp. 363–365): for any CCAAdversary making at most Q n total oracle queries at security
parameter n, the adaptive CCA distinguishing advantage is bounded by the CPA advantage of
ccaToCPAAdversary plus dyadicSize (Q n) times the ciphertext-integrity winning probabilities of
ccaToCIAdversary for bit = false and bit = true.
Relative to equation (9.3) in [BS23]
(CCAadv[A, E] ≤ CPAadv[Bcpa, E] + 2 Qd · CIadv[Bci, E]), ccaToCIAdversary samples a query index
uniformly from {0, ..., dyadicSize (Q n) - 1} over the total query budget Q n ≥ Qe + Qd, giving
coefficient dyadicSize (Q n) ≤ 2 * Q n + 2 per bit.
Running ccaToCIHiddenBitAdversary in ciGame averages ccaToCIAdversary uniformly over
bit : Bool.
Single-adversary quantitative AE $\Rightarrow$ CCA bound ([BS23], Section 9.2.3,
Theorem 9.1, equation (9.3) and proof on printed pp. 363–364): using ccaToCIHiddenBitAdversary to
sample the hidden challenge bit uniformly yields factor 2 * dyadicSize (Q n) ≤ 4 * Q n + 4 (over
the total query budget Q n, vs. 2 * Qd over decryption queries in (9.3)) on the single CI
adversary.
Authenticated encryption implies adaptive CCA security ([BS23], Section 9.2.3,
Theorem 9.1, printed pp. 363–365): every symmetric cipher satisfying AuthenticatedEncryption
(INDCPA ∧ CiphertextIntegrity) also satisfies INDCCA (the multi-query AE ⇒ CCA half of
Theorem 9.1; the one-time 1AE ⇒ 1CCA half over Definition 9.6 is omitted).