MESSAGE AUTHENTICATION CODES and PRF DOMAIN EXTENSION
Total Page:16
File Type:pdf, Size:1020Kb
MESSAGE AUTHENTICATION CODES and PRF DOMAIN EXTENSION Daniele Micciancio UCSD 1 Integrity and authenticity The goal is to ensure that • M really originates with Alice and not someone else • M has not been modified in transit Daniele Micciancio UCSD 2 Integrity and authenticity example Bob Alice (Bank) Alice Pay $100 to Charlie - Adversary Eve might • Modify \Charlie" to \Eve" • Modify \$100" to \$1000" Integrity prevents such attacks. Daniele Micciancio UCSD 3 Message authentication codes A message authentication code T : Keys × D ! R is a family of functions. The envisaged usage is shown below, where A is the adversary: Keys ?$ K ? ? M - T - T - - T 0 - A V - d - - M0 - We refer to T as the MAC or tag. We have defined 0 0 Algorithm VK (M ; T ) 0 0 If TK (M ) = T then return 1 else return 0 Daniele Micciancio UCSD 4 MAC usage Sender and receiver share key K. To authenticate M, sender transmits (M; T ) where T = TK (M). Upon receiving (M0; T 0), the receiver accepts M0 as authentic iff 0 0 0 0 VK (M ; T ) = 1, or, equivalently, iff TK (M ) = T . Daniele Micciancio UCSD 5 UF-CMA Let T : Keys × D ! R be a message authentication code. Let A be an adversary. Game UFCMAT procedure Initialize procedure Finalize(M; T ) K $ Keys ; S ; If M 2 S then return false procedure Tag(M) If M 62 D then return false Return (T = TK (M)) T TK (M); S S [ fMg return T The uf-cma advantage of adversary A is uf-cma h A i AdvT (A) = Pr UFCMAT ) true Daniele Micciancio UCSD 6 UF-CMA: Explanations Adversary A does not get the key K. It can call Tag with any message M of its choice to get back the correct tag T = TK (M). To win, the adversary A must output a message M 2 D and a tag T that are • Correct: T = TK (M) • New: M 62 S, meaning M was not a query to Tag Interpretation: Tag represents the sender and Finalize represents the receiver. Security means that the adversary can't get the receiver to accept a message that is not authentic, meaning was not already transmitted by the sender. Daniele Micciancio UCSD 7 Exercise: Tag lengths Let T : Keys × D ! f0; 1g` be a message authentication code. Specify in pseudocode an efficient adversary A making zero Tag queries and uf-cma −` achieving AdvT (A) = 2 . Conclusion: Tags have to be long enough. For 80 bit security, tags have to be at least 80 bits. Daniele Micciancio UCSD 8 Example: Basic CBC MAC Let E : f0; 1gk × B ! B be a blockcipher, where B = f0; 1gn. View a message M 2 B∗ as a sequence of n-bit blocks, M = M[1] ::: M[m]. The basic CBC MAC T : f0; 1gk × B∗ ! B is defined by Alg TK (M) C[0] 0n for i = 1;:::; m do C[i] EK (C[i − 1] ⊕ M[i]) return C[m] M[1] M[2] M[m − 1] M[m] EK EK EK EK C[m] = TK (M) Daniele Micciancio UCSD 9 Splicing attack on basic CBC MAC adversary A Alg TK (M) Let x 2 f0; 1gn C[0] 0n T Tag(x) for i = 1;:::; m do 1 M xjjT ⊕ x C[i] E (C[i − 1] ⊕ M[i]) 1 K Return M; T return C[m] 1 Then, xT 1 ⊕ x TK (M) = EK (EK (x) ⊕ T1 ⊕ x) E E K K = EK (T1 ⊕ T1 ⊕ x) = EK (x) T1 T1 = T1 Daniele Micciancio UCSD 10 Insecurity of basic CBC MAC adversary A Alg TK (M) Let x 2 f0; 1gn C[0] 0n T Tag(x) for i = 1;:::; m do 1 M xjjT ⊕ x C[i] E (C[i − 1] ⊕ M[i]) 1 K Return M; T return C[m] 1 uf-cma Then AdvT (A) = 1 and A is efficient, so the basic CBC MAC is not UF-CMA secure. Daniele Micciancio UCSD 11 Exercise Let E: f0; 1gk × f0; 1gn ! f0; 1gn be a blockcipher. Let D = f M 2 f0; 1g∗ : 0 < jMj < n2n and jMj mod n = 0 g : Let T : f0; 1gk × D ! f0; 1gn be defined as follows: Alg TK (M) M[1] ::: M[m] M; M[m + 1] hmi; C[0] 0n For i = 1;:::; m + 1 do C[i] EK (C[i − 1] ⊕ M[i]) T C[m + 1]; return T Above, hmi denotes the n-bit binary representation of the integer m. Show that T is not UF-CMA-secure by presenting in pseudocode a practical adversary A making at most 4 Tag queries and achieving uf-cma AdvT (A) = 1. Daniele Micciancio UCSD 12 Replay Suppose Alice transmits (M1; T1) to Bank where M1 =\Pay $100 to Bob". Adversary • Captures (M1; T1) • Keeps re-transmitting it to bank Result: Bob gets $100, $200, $300,... Our UF-CMA notion of security does not ask for protection against replay, because A will not win if it outputs M; T with M 2 S, even if T = TK (M) is the correct tag. Question: Why not? Answer: Replay is best addressed as an add-on to standard message authentication. Daniele Micciancio UCSD 13 Obviously forgery is possible within a ∆ interval. But the main problem is that TimeA is not authenticated, so adversary can transmit (M; TK (M); Time1); (M; TK (M); Time2);::: for any times Time1; Time2;::: of its choice, and Bob will accept. Preventing Replay Using Timestamps Let TimeA be the time as per Alice's local clock and TimeB the time as per Bob's local clock. • Alice sends (M; TK (M); TimeA) • Bob receives (M; T ; Time) and accepts iff T = TK (M) and jTimeB − Timej ≤ ∆ where ∆ is a small threshold. Does this work? Daniele Micciancio UCSD 14 Preventing Replay Using Timestamps Let TimeA be the time as per Alice's local clock and TimeB the time as per Bob's local clock. • Alice sends (M; TK (M); TimeA) • Bob receives (M; T ; Time) and accepts iff T = TK (M) and jTimeB − Timej ≤ ∆ where ∆ is a small threshold. Does this work? Obviously forgery is possible within a ∆ interval. But the main problem is that TimeA is not authenticated, so adversary can transmit (M; TK (M); Time1); (M; TK (M); Time2);::: for any times Time1; Time2;::: of its choice, and Bob will accept. Daniele Micciancio UCSD 15 Preventing Replay Using Timestamps Let TimeA be the time as per Alice's local clock and TimeB the time as per Bob's local clock. • Alice sends (M; TK (MkTimeA); TimeA) • Bob receives (M; T ; Time) and accepts iff TK (MkTime) = T and jTimeB − Timej ≤ ∆ where ∆ is a small threshold. Daniele Micciancio UCSD 16 Preventing Replay Using Counters Alice maintains a counter ctrA and Bob maintains a counter ctrB . Initially both are zero. • Alice sends (M; TK (MkctrA)) and then increments ctrA • Bob receives (M; T ). If TK (MkctrB ) = T then Bob accepts and increments ctrB . Counters need to stay synchronized. Daniele Micciancio UCSD 17 Any PRF is a MAC If F is PRF-secure then it is also UF-CMA-secure: Theorem [GGM86,BKR96]: Let F : f0; 1gk × D ! f0; 1gn be a family of functions. Let A be a uf-cma adversary making q Tag queries and having running time t. Then there is a prf-adversary B such that 2 Advuf-cma(A) ≤ Advprf (B) + : F F 2n Adversary B makes q + 1 queries to its Fn oracle and has running time t plus some overhead. We do not prove this here, but we give a little intuition. Daniele Micciancio UCSD 18 1 2n because A did not query Fn(x). Intuition for why PRFs are UF-CMA-secure 1 Random functions make good (UF-CMA) MACs 2 PRFs are pretty much as good as random functions For (1), suppose Fn : D ! f0; 1gn is random and consider A who • Can query Fn at any points x1;:::; xq 2 D it likes • To win, must output x; T such that x 2= fx1;:::; xqg but T = Fn(x) Then, Pr[A wins] = Daniele Micciancio UCSD 19 Intuition for why PRFs are UF-CMA-secure 1 Random functions make good (UF-CMA) MACs 2 PRFs are pretty much as good as random functions For (1), suppose Fn : D ! f0; 1gn is random and consider A who • Can query Fn at any points x1;:::; xq 2 D it likes • To win, must output x; T such that x 2= fx1;:::; xqg but T = Fn(x) Then, 1 Pr[A wins] = 2n because A did not query Fn(x). Daniele Micciancio UCSD 20 Intuition for why PRFs are UF-CMA-secure 1 Random functions make good (UF-CMA) MACs 2 PRFs are pretty much as good as random functions For (2), consider A who • Can query FK at any points x1;:::; xq 2 D it likes • To win, must output x; T such that x 2= fx1;:::; xqg but T = FK (x) If Pr[A wins] is significantly more then 2−n then we are detecting a difference between FK and a random function. Daniele Micciancio UCSD 21 PRF domain extension A family of functions F : Keys × D ! R is • FIL (Fixed-input-length) if D = f0; 1g` for some ` • VIL (Variable-input-length) if D is a \large" set like D = f0; 1g∗ or D = f M 2 f0; 1g∗ : 0 < jMj < n2n and jMj mod n = 0 g : for some n ≥ 1 or ... We have families we are willing to assume are PRFs, namely blockciphers and compression functions, but they are FIL.