Skip to Content
CSE442TIntroduction to Cryptography (Lecture 22)

CSE442T Introduction to Cryptography (Lecture 22)

Chapter 7: Composability

So far we’ve sought security against

cEnck(m)c\gets Enc_k(m)

Adversary knows cc, but nothing else.

Attack models

Known plaintext attack (KPA)

Adversary has seen (m1,Enck(m1)),(m2,Enck(m2)),,(mq,Enck(mq))(m_1,Enc_k(m_1)),(m_2,Enc_k(m_2)),\cdots,(m_q,Enc_k(m_q)).

m1,,mqm_1,\cdots,m_q are known to the adversary.

Given new c=Enck(m)c=Enc_k(m), is previous knowledge helpful?

Chosen plaintext attack (CPA)

Adversary can choose m1,,mqm_1,\cdots,m_q and obtain Enck(m1),,Enck(mq)Enc_k(m_1),\cdots,Enc_k(m_q).

Then adversary see new encryption c=Enck(m)c=Enc_k(m). with the same key.

Example:

In WWII, Japan planned to attack “AF”, but US suspected it means Midway.

So US use Axis: Enck(AF)Enc_k(AF) and ran out of supplies.

Then US know Japan will attack Midway.

Chosen ciphertext attack (CCA)

Adversary can choose c1,,cqc_1,\cdots,c_q and obtain Deck(c1),,Deck(cq)Dec_k(c_1),\cdots,Dec_k(c_q).

Definition 168.1 (Secure private key encryption against attacks)

Capture these ideas with the adversary having oracle access.

Let Π=(Gen,Enc,Dec)\Pi=(Gen,Enc,Dec) be a private key encryption scheme. Let a random variable INDbO1,O2(Π,A,n)IND_b^{O_1,O_2}(\Pi,\mathcal{A},n) where A\mathcal{A} is an n.u.p.p.t. The security parameter is nNn\in \mathbb{N}, b{0,1}b\in\{0,1\} denoting the real scheme or the adversary’s challenge.

The experiment is the following:

  • Key kGen(1n)k\gets Gen(1^n)
  • Adversary AO1(k)(1n)\mathcal{A}^{O_1(k)}(1^n) queries oracle O1O_1
  • m0,m1AO1(k)(1n)m_0,m_1\gets \mathcal{A}^{O_1(k)}(1^n)
  • cEnck(mb)c\gets Enc_k(m_b)
  • AO2(c)(1n,c)\mathcal{A}^{O_2(c)}(1^n,c) queries oracle O2O_2 to distinguish cc is encryption of m0m_0 or m1m_1
  • A\mathcal{A} outputs bit bb' which is either zero or one

Π\Pi is CPA/CCA1/CCA2 secure if for all PPT adversaries A\mathcal{A},

{IND0O1,O2(Π,A,n)}n{IND1O1,O2(Π,A,n)}n\{IND_0^{O_1,O_2}(\Pi,\mathcal{A},n)\}_n\approx\{IND_1^{O_1,O_2}(\Pi,\mathcal{A},n)\}_n

where \approx is statistical indistinguishability.

SecurityO1O_1O2O_2
CPAEnckEnc_kEnckEnc_k
CCA1Enck,DeckEnc_k,Dec_kEnckEnc_k
CCA2 (or full CCA)Enck,DeckEnc_k,Dec_kEnck,DeckEnc_k,Dec_k^*

Note that DeckDec_k^* will not allowed to query decryption of a functioning ciphertext.

You can imagine the experiment is a class as follows:

n = 1024 @lru_cache(None) def oracle_1(m,key,**kwargs): """ Query oracle 1 """ pass @lru_cache(None) def oracle_2(c,key,**kwargs): """ Query oracle 2 """ pass class Experiment: def __init__(self, key, oracle_1, oracle_2): self.key = key self.oracle_1 = oracle_1 self.oracle_2 = oracle_2 def sufficient_trial(self): pass def generate_test_message(self): pass def set_challenge(self, c): self.challenge = c def query_1(self): while not self.sufficient_trial(): self.oracle_1(m,self.key,**kwargs) def challenge(self): """ Return m_0, m_1 for challenge """ m_0, m_1 = self.generate_test_message() self.m_0 = m_0 self.m_1 = m_1 return m_0, m_1 def query_2(self, c): while not self.sufficient_trial(): self.oracle_2(c,self.key,**kwargs) def output(self): return 0 if self.challenge==m_0 else 1 if __name__ == "__main__": key = random.randint(0, 2**n) exp = Experiment(key, oracle_1, oracle_2) exp.query_1() m_0, m_1 = exp.challenge() choice = random.choice([m_0, m_1]) exp.set_challenge(choice) exp.query_2() b_prime = exp.output() print(f"b'={b_prime}, b={choice==m_0}")

Theorem: Our mms private key encryption scheme is CPA, CCA1 secure.

Have a PRF family {fk}:{0,1}k{0,1}k\{f_k\}:\{0,1\}^{|k|}\to\{0,1\}^{|k|}

Gen(1n)Gen(1^n) outputs k{0,1}nk\in\{0,1\}^n and samples fkf_k from the PRF family.

Enck(m)Enc_k(m) samples r{0,1}nr\in\{0,1\}^n and outputs (r,fk(r)m)(r,f_k(r)\oplus m). For multi-message security, we need to encrypt m1,,mqm_1,\cdots,m_q at once.

Deck(r,c)Dec_k(r,c) outputs fk(r)cf_k(r)\oplus c.

Familiar Theme:

  • Show the R.F. version is secure.
    • FRFnF\gets RF_n
  • If the PRF version were insecure, then the PRF can be distinguished from a random function…

INDbO1,O2(Π,A,n),FRFnIND_b^{O_1,O_2}(\Pi,\mathcal{A},n), F\gets RF_n

  • EncEnc queries (m1,(r1,m1Fk(r1))),,(mq1,(rq1,mq1Fk(rq1)))(m_1,(r_1,m_1\oplus F_k(r_1))),\cdots,(m_{q_1},(r_{q_1},m_{q_1}\oplus F_k(r_{q_1})))
  • DecDec queries (s1,c1),,(sq2,cq2)(s_1,c_1),\cdots,(s_{q_2},c_{q_2}), where mi=ciFk(si)m_i=c_i-F_k(s_i)
  • m0,m1AO2(k)(1n)m_0,m_1\gets \mathcal{A}^{O_2(k)}(1^n), EncF(mb)=(R,Mb+F(R))Enc_F(m_b)=(R,M_b+F(R))
  • Query round similar to above.

As long as RR was never seen in querying rounds, P[A guesses correctly]=1/2P[\mathcal{A} \text{ guesses correctly}]=1/2.

P[R was seen before]p(n)2nP[R\text{ was seen before}]\leq \frac{p(n)}{2^n} (by the total number of queries in all rounds.)

This encryption scheme is not CCA2 secure.

After round 1, On,1nAO1(k)(1n)O^n,1^n\gets \mathcal{A}^{O_1(k)}(1^n),

(r,m+F(r))=(r,c)(r,m+F(r))=(r,c) in round 2.

Query DecF(r,c+001)=001 or 110Dec_F(r,c+0\ldots 01)=0\ldots 01 \text{ or } 1\ldots 10.

c+001F(r)=M+001c+0\ldots 01-F(r)=M+0\ldots 01

Encrypt then authenticate

Have a PRF family {fk}:{0,1}k{0,1}k\{f_k\}:\{0,1\}^|k|\to\{0,1\}^{|k|}

Gen(1n)Gen(1^n) outputs k1,k2{0,1}nk_1,k_2\in\{0,1\}^n and samples fkf_k from the PRF family.

Enck1,k2(m)Enc_{k_1,k_2}(m) samples r{0,1}nr\in\{0,1\}^n and let c1=fk1(r)mc_1=f_{k_1}(r)\oplus m and c2=fk2(c1)c_2=f_{k_2}(c_1). Then we output (r,c1,c2)(r,c_1,c_2). where c1c_1 is the encryption, and c2c_2 is the tag. For multi-message security, we need to encrypt m1,,mqm_1,\cdots,m_q at once.

Deck1,k2(r,c1,c2)Dec_{k_1,k_2}(r,c_1,c_2) checks if c2=fk2(c1)c_2=f_{k_2}(c_1). If so, output c1fk1(r)c_1-f_{k_1}(r). Otherwise, output \bot.

Show that this scheme is CPA secure.

  1. Show that the modifier version ΠRF\Pi'^{RF} where fk2f_{k_2} is replaced with a random function is CCA2 secure.
  2. If ours isn’t, then PRF detector can be created.

Suppose ΠRF\Pi^RF is not secure, then A\exists \mathcal{A} which can distinguish INDiO1,O2(ΠRF,A,n)IND_i^{O_1,O_2}(\Pi'^{RF},\mathcal{A},n) with non-negligible probability. We will use this to construct BB which breaks the CPA security of Π\Pi.

Let BB be the PPT algorithm that on input 1n1^n, does the following:

  • Run AO1,O2(ΠRF,A,n)\mathcal{A}^{O_1,O_2}(\Pi'^{RF},\mathcal{A},n)
  • Let m0,m1m_0,m_1 be the messages that A\mathcal{A} asked for in the second round.
  • Choose b{0,1}b\in\{0,1\} uniformly at random.
  • Query Enck1,k2(mb)Enc_{k_1,k_2}(m_b) to the oracle.
  • Let cc be the challenge ciphertext.
  • Return whatever A\mathcal{A} outputs.
Last updated on