Introductionto Modern Cryptograph 第四章部分课后题答案(上)

Acknowledge
致敬Katz J, Lindell Y. Introduction to modern cryptography[M]. Chapman and Hall/CRC, 2014. 推荐该书正版。

4.1 Say Π=(Gen,Mac,Vrfy)\Pi = (\mathsf{Gen}, \mathsf{Mac}, \mathsf{Vrfy}) is a secure MAC, and for k{0,1}nk \in \{0, 1\}^n the tag-generation algorithm Mack\mathsf{Mac}_k always outputs tags of length t(n)t(n). Prove that tt must be super-logarithmic or, equivalently, that if t(n)=O(log n)t(n) = \mathcal{O}(\mathsf{log} ~ n) then Π\Pi cannot be a secure MAC.

假设t(n)=O(log n)t(n) = \mathcal{O}(\mathsf{log} ~ n),那么存在常数cc使得t(n)=clog nt(n) = c \cdot \mathsf{log} ~ n,即Mac\mathsf{Mac}算法的输出共有2clog n=nc2^{c \cdot log ~n} = n^c种可能,敌手A\mathcal{A}在挑战游戏中随机挑选消息mm^*,设置t{0,1}t(n)t^* \gets \{0, 1\}^{t(n)},成功使得Mack(m)=t\mathsf{Mac}_k(m^*) = t^*的概率为1/nc1 / n^c,而1/nc>negl(n)1 / n^c > \mathsf{negl}(n),显然方案Π\Pi不安全。


4.2 Consider the following fixed-length MAC for messages of length (n)=2n2\ell(n) = 2n-2 using a pseudorandom function FF: On input a message m0m1m_0 || m_1 (with m0=m1=n1|m_0| = |m_1| = n-1) and key k{0,1}nk \in \{0, 1\}^n, algorithm Mac\mathsf{Mac} outputs t=Fk(0m0)Fk(1m1)t = F_k(0 || m_0) || F_k(1 || m_1). Algorithm Vrfy\mathsf{Vrfy} is defined in the natural way. Is (Gen,Mac,Vrfy)(\mathsf{Gen}, \mathsf{Mac}, \mathsf{Vrfy}) existentially unforgeable under a chosen-message attack? Prove your answer.

方案Π\Pi依旧不安全,直觉上其安全性证明无法正确规约到相关困难问题假设上。接下来举一个例子来具体说明为何Π\Pi不安全:敌手A\mathcal{A}挑选m=m0m1m = m_0 || m_1提交给谕言机得到t=Fk(0m0)Fk(1m1)t = F_k(0 || m_0) || F_k(1 || m_1),接下来A\mathcal{A}挑选m=m0m1m' = m'_0 || m'_1提交给谕言机得到t=Fk(0m0)Fk(1m1)t' = F_k(0 || m'_0) || F_k(1 || m'_1),最后,A\mathcal{A}提交m=m0m1m^* = m_0 || m'_1t=Fk(0m0)Fk(1m1)t^* = F_k(0 || m_0) || F_k(1 || m'_1)作为有效伪造。


4.3 Let FF be a pseudorandom function. Show that the following MAC for messages of length 2n2n is insecure: The shared key is a random k{0,1}nk \in \{0, 1\}^n. To authenticate a message m1m2m_1 || m_2 with m1=m2=n|m_1| = |m_2| = n, compute the tag <Fk(m1),Fk(Fk(m2))>\big< F_k(m_1), F_k \big( F_k(m_2) \big) \big>.

类似题目4.2,首先,A\mathcal{A}提交m=m1m2m = m_1 || m_2得到t=<t1,t2>t = \big<t_1, t_2 \big>,然后提交m=m1m2m' = m'_1 || m'_2得到t=<t1,t2>t' = \big< t'_1, t'_2 \big>,最后提交m=m1m2m^* = m_1 || m'_2t=<t1,t2>t^* = \big< t_1, t'_2 \big>作为有效伪造。


4.4 Let FF be a pseudorandom function. Show that each of the following message authentication codes is insecure. (In each case the shared key is a random k{0,1}nk \in \{0, 1\}^n.)

  • To authenticate a message m=m1mm = m_1 || \cdots || m_\ell, where mi{0,1}nm_i \in \{0, 1\}^n, compute t:=Fk(m1)Fk(m)t := F_k(m_1) \oplus \cdots \oplus F_k(m_\ell).
  • To authenticate a message m=m1mm = m_1 || \cdots || m_\ell, where mi{0,1}nm_i \in \{0, 1\}^n, choose r{0,1}nr \gets \{0, 1\}^n at random, compute t:=Fk(r)Fk(m1)Fk(m)t := F_k(r) \oplus F_k(m_1) \oplus \cdots \oplus F_k(m_\ell), and send <r,t>\big< r, t \big>.
  • To authenticate a message m=m1mm = m_1 || \cdots || m_\ell, where mi{0,1}n/2m_i \in \{0, 1\}^{n/2}, choose r{0,1}nr \gets \{0, 1\}^n at random, compute
    t:=Fk(r)Fk(<1>m1)Fk(<>m) t:=F_k(r) \oplus F_k(\big<1\big>||m_1) \oplus \cdots \oplus F_k(\big<\ell\big> || m_\ell)
    where <i>\big<i\big> is an n/2n/2-bit encoding of the interger ii, and send <r,t>\big<r, t\big>.

注意MAC的输入是任意长度的消息m{0,1}m \in \{0, 1\}^*
第一种情形,A\mathcal{A}向谕言机问询m=m1m2m=m_1||m_2得到t=Fk(m1)Fk(m2)t=F_k(m_1)\oplus F_k(m_2),随后提交m=m2m1m^* = m_2 || m_1t=tt^* = t
第二种情形,攻击跟第一种情形类似。
第三种情形,加入了<i>\big<i\big>防止A\mathcal{A}打乱消息块的顺序,但仍然存在缺陷,注意消息mm是任意长度,A\mathcal{A}可以设置m=m1m^* = m_1t=<<1>m1,0n>t^* = \big< \big<1\big>||m_1, 0^n \big>,直接输出伪造。


4.5 Consider an extension of the definition of secure message authentication where the adversary is provided with both a Mac\mathsf{Mac} and a Vrfy\mathsf{Vrfy} oracle.

  • Provide a formal definition of security in this case, and explain what real-world adversarial actions are modeled by providing the adversary with a Vrfy\mathsf{Vrfy} oracle.
  • Show that if Π\Pi has unique tags (c.f. Section 4.8), then Π\Pi satisfies your definition if it satisfies Definition 4.2.
  • Show that if Π\Pi does not have unique tags, then Π\Pi may satisfy Definition 4.2 but not your definition.

对Definition 4.2作出轻微修改,考虑如下实验Mac-forgeA,Π(λ)\mathsf{Mac}\text{-}\mathsf{forge}_{\mathcal{A}, \Pi}(\lambda)

  1. A random key kk is generated by running Gen(1λ)\mathsf{Gen}(1^\lambda).
  2. The adversary A\mathcal{A} is given input 1λ1^\lambda and oracle access to Mack()\mathsf{Mac}_k(\cdot) and Vrfyk()\mathsf{Vrfy}_k(\cdot). The adversary eventually outputs a pair (m,t)(m^*, t^*). Let Q\mathcal{Q} denote the set of all queries that A\mathcal{A} asked to oracle Mack()\mathsf{Mac}_k(\cdot).
    OMac(m)\mathcal{O}_\mathsf{Mac}(m): given a message mm, output a tag tt on mm.
    OVrfy(m,t)\mathcal{O}_\mathsf{Vrfy}(m, t): given a pair (m,t)(m, t), output a bit bb.
  3. The output of the experiment is defined to be 11 if and only if (1) Vrfyk(m,t)=1\mathsf{Vrfy}_k(m^*, t^*) = 1 and (2) mQm^* \notin \mathcal{Q}.

(Definition) Amessage authentication code Π=(Gen,Mac,Vrfy)\Pi = (\mathsf{Gen}, \mathsf{Mac}, \mathsf{Vrfy}) is existentially unforgeable under an adaptive chosen-message attack, or just secure, if for all probabilistic polynomial-time adversaries A\mathcal{A}, there exists a negligible function negl\mathsf{negl} such that
Pr[Mac-forgeA,Π(λ)=1]negl(λ). \mathrm{Pr} [ \mathsf{Mac}\text{-}\mathsf{forge}_{\mathcal{A}, \Pi}(\lambda) = 1 ] \leq \mathsf{negl}(\lambda).

考虑侧信道攻击环境下的谕言机OVrfy()\mathcal{O}_{\mathsf{Vrfy}}(\cdot),假设此时敌手不仅可以获知Vrfy\mathsf{Vrfy}的输出bb,并且可以获知算法运行时间。接下来举一个例子。当MAC采用确定性算法时,算法Vrfy(k,m,t)\mathsf{Vrfy}(k, m, t)工作如下:计算t~:=Mac(k,m)\tilde{t} := \mathsf{Mac}(k, m),比较t~=?t\tilde{t} \overset{?}{=} t,输出布尔变量bb,比较(t~,t)(\tilde{t}, t)时使用C语言函数strcmp。思考C语言对于布尔表达式False & True的判断,strcmp算法对于不同的tt会有不同的运行时间,敌手监听运行MAC算法的智能家电用具,对消息mm伪造t=0λt = 0^\lambda,跟着根据strcmp算法的运行时间,逐次修改特定比特位,此时仅需访问λ\lambdaOVrfy\mathcal{O}_{\mathsf{Vrfy}}。上述例子就是OVrfy\mathcal{O}_{\mathsf{Vrfy}}的意义,同时可见本题所给定义仍然不够strong(推荐反复思考书中关于安全定义是否太过strong的原话,以进一步加深理解)。

当算法Mac\mathsf{Mac}是确定性算法时(即对于一条密钥kk一个消息mm仅有一个有效标签tt),上述定义中仅输出bb值的谕言机OVrfy\mathcal{O}_{\mathsf{Vrfy}}对于敌手A\mathcal{A}来说意义不大,A\mathcal{A}完全不能从OVrfy\mathcal{O}_{\mathsf{Vrfy}}中学到新的知识

思考如下方案Π=(Gen,Mac,Vrfy)\Pi' = (\mathsf{Gen}', \mathsf{Mac}', \mathsf{Vrfy}'),它满足安全定义Definition 4.2,但不满足本题安全定义。

假设Π=(Gen,Mac,Vrfy)\Pi = (\mathsf{Gen}, \mathsf{Mac}, \mathsf{Vrfy})是满足安全定义Definition 4.2的消息鉴别码方案。

  • Gen(1λ)k\mathsf{Gen}'(1^\lambda) \to k:运行kGen(1λ)k \gets \mathsf{Gen}(1^\lambda),设置k:=kk' := k并输出。
  • Mac(k,m)t\mathsf{Mac}'(k', m) \to t':运行t:=Mac(k,m)t := \mathsf{Mac}(k, m),设置t:=t<0>t' := t || \big<0\big>并输出(注意本算法符号\gets和符号:=:=的运用)。
  • Vrfy(k,m,t)b\mathsf{Vrfy}'(k', m, t') \to b':解析t=t<i>t' = t || \big<i\big>,运行bVrfy(k,m,t)b \gets \mathsf{Vrfy}(k, m, t),若b=1b = 1i=0i = 0,设置b:=bb' := b并输出;若b=1b = 1i>0i > 0,设置b:=k[i]b' := k[i]并输出(其中k[i]k[i]表示密钥kk的第ii个比特);否则设置b:=0b' := 0并输出。

算法正确性易分析,满足定义4.2同样易证明。

敌手有了验证谕言机后,先访问标签生成谕言机得到(m,t<0>)(m, t||\big<0\big>),再通过修改<i>\big<i\big>访问λ1\lambda - 1次验证谕言机可恢复出密钥kk


4.7 Prove that Construction 4.5 is secure if it is changed as follows: Instead of including \ell in every block, set ti:=Fk(rbimi)t_i := F_k(r \| b \| i \| m_i) where bb is a single bit such that b=0b = 0 in all blocks but the last one, and b=1b=1 in the last block. What is the advantage of this modification?

本题安全性证明与Construction 4.5大同小异,易证A\mathcal{A}q(λ)q(\lambda)次谕言机访问出现重复的rr的概率可忽略,假设A\mathcal{A}最终输出有效伪造(m,t)(m^*, t^*),分为3种情况:

(1)rr^*q(λ)q(\lambda)次谕言机访问中的rr都不相同,那么(r01m1,t1)(r^* \| 0 \| 1 \| m^*_1, t^*_1)可作为Π\Pi'的有效伪造;
(2)rr^*q(λ)q(\lambda)次谕言机访问中的某个rr相同,而m|m^*|与该rr对应的m|m|不相同,那么bb值为11(r1imi,ti)(r^* \| 1 \| i \| m_i, t^*_i)可作为Π\Pi'的有效伪造;
(3)rr^*q(λ)q(\lambda)次谕言机访问中的某个rr相同,且m|m^*|与该rr对应的m|m|相同,又mm^*不等于mm,必存在ii使得rbimir \| b \| i \| m_i不等于ribimir^*_i \| b \| i \| m^*_i,则(ribimi,ti)(r^*_i \| b \| i \| m^*_i, t^*_i)可作为Π\Pi'的有效伪造。

无论上述哪一种情况,只要A\mathcal{A}最终输出针对Π\Pi的有效伪造,那么必然可以找到针对Π\Pi'的有效伪造,这与前提Π\Pi'是安全的相矛盾,故该构造是安全的。


4.8 Show that the basic CBC-MAC construction is not secure when used to authenticate messages of different lengths.

回顾Construction 4.9,算法Mac\mathsf{Mac}工作如下:

  • Parse mm as m=m1,,mm = m_1, \dots, m_\ell where each mim_i is of length nn, and set t0:=0λt_0 := 0^\lambda.
  • For i=1i=1 to \ell, set ti:=Fk(ti1mi)t_i := F_k(t_{i-1} \oplus m_i).
  • Output tt_\ell as the tag.

当消息长度m|m|不定时,敌手A\mathcal{A}可通过访问两次OMac\mathcal{O}_{\mathsf{Mac}}谕言机完成攻击:

  • 第一次设置m(1)=mm^{(1)} = m得到t(1)=Fk(0λm)t^{(1)} = F_k(0^\lambda \oplus m)
  • 第二次设置m(2)=t(1)m^{(2)} = t^{(1)}得到t(2)=Fk(0λt(1))t^{(2)} = F_k(0^\lambda \oplus t^{(1)})
  • 最终输出伪造(m=m0λ,t=t(2))(m^* = m \| 0^\lambda, t^* = t^{(2)})

附加题:Show that appending the message length to the end of the message before applying basic CBC-MAC does not result in a secure MAC for arbitrary-length messages.

敌手A\mathcal{A}仅需访问3次谕言机OMac\mathcal{O}_{\mathsf{Mac}}即可完成攻击:

  • 第一次提交m1m_1,得到t:=Fk(Fk(m1)1)t := F_k(F_k(m_1) \oplus 1)
  • 第二次提交m1m'_1,得到t:=Fk(Fk(m1)1)t' := F_k(F_k(m'_1) \oplus 1)
  • 第三次提交m11m3m_1 \| 1 \| m''_3,得到t:=Fk(Fk(Fk(Fk(m1)1)m3)3)t'' :=F_k(F_k(F_k(F_k(m_1) \oplus 1) \oplus m''_3) \oplus 3)

从上述三个式子,有t=Fk(Fk(tm3)3)t'' =F_k(F_k(t \oplus m''_3) \oplus 3),而tm3=tm3ttt \oplus m''_3 = t \oplus m''_3 \oplus t' \oplus t',设m3=tm3tm^*_3 = t \oplus m''_3 \oplus t',有t=Fk(Fk(tm3)3)t'' = F_k(F_k(t' \oplus m^*_3) \oplus 3),即当m:=m11m3m^* := m'_1 \| 1 \| m^*_3时,有t:=tt^* := t''


4.9 Prove that the following modifications of CBC-MAC do not yield a secure fixed-length MAC:

  • Modify CBC-MAC so that a random IVIV is used each time a tag is computed (and the IVIV is output along with tt_\ell). I.e., t0{0,1}nt_0 \gets \{0, 1\}^n is chosen uniformly at random rather than being fixed to 0n0^n, and the tag is t0,tt_0, t_\ell.
  • Modify CBC-MAC so that all blocks t1,,tt_1, \dots, t_\ell are output (rather than just tt_\ell).

第一种情形,A\mathcal{A}提交m:=0nm := 0^{\ell n}得到t=<t0,t>t = \big<t_0, t_\ell\big>,此时A\mathcal{A}可伪造m:=t00(1)nm^* := t_0 \| 0^{(\ell - 1)n}t:=<0n,t>t^* := \big<0^n, t_\ell\big>。 留意,Fk(m1t0)=t1=Fk(m1t0)F_k(m_1 \oplus t_0) = t_1 = F_k(m^*_1 \oplus t^*_0)

第二种情形,A\mathcal{A}提交m:=m1m2mm:=m_1 \| m_2 \| \dots \| m_\ell,得到t=<t1,t2,,t>t = \big< t_1, t_2, \dots, t_\ell\big>,接着提交m:=m1m2mm':=m'_1 \| m'_2 \| \dots \| m'_\ell,得到t=<t1,t2,,t>t' = \big< t'_1, t'_2, \dots, t'_\ell\big>,最后伪造m:=m1(m2t1t1)m3mm^* := m_1 \| (m'_2 \oplus t'_1 \oplus t_1) \| m'_3 \| \dots m'_\ellt:=<t1,t2,t3,,t>t^* := \big<t_1, t'_2, t'_3, \dots, t'_\ell\big>


附加题(原书第2版题目):Show that Construction 4.18 might not be CCA-secure if it is instantiated with a secure MAC that is not strongly secure.

回顾strongly secure MAC的定义,游戏输出1的条件改为“Vrfyk(m,t)=1\mathsf{Vrfy}_k(m^*, t^*)=1(m,t)Q(m^*, t^*) \notin \mathcal{Q}”,历史记录列表形式改为Q=(m,t)\mathcal{Q}=(m, t)

参考题目4.5第3小题的方案构造,它依旧不满足strong secure MAC的定义,具体来说,A\mathcal{A}提交mm^*OMac\mathcal{O}_{\mathsf{Mac}}得到t=t<0>t = t' \| \big<0\big>,随机挑选i[λ]i^* \gets [\lambda](m,t=t<i>)(m^*, t^*=t' \| \big<i^*\big>)有效的概率为1/λ1/\lambda。若Construction 4.18中的MAC方案采用该构造,那么在CCA-secure安全游戏中,A\mathcal{A}易得到MAC的密钥kk,这样A\mathcal{A}就可以对挑战密文做逻辑修改,并且有效访问解密谕言机,与Construction 4.18的设计初衷相违背。

原书第2版题目4.23解题思路亦类似。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章