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解題思路亦類似。

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