🌑

Explore / Study / Computer Science / Cryptography 913 words | 5 minutes

§9 Message Authentication Codes

  1. Message Authentication Code (MAC): Definition
  2. Message Authentication Experiment Mac-forgeA,Π(n)\text {Mac-forge}_{\mathscr{A}, \Pi}(n)Mac-forgeA,Π​(n)
  3. MAC Security: Formal Definition
  4. Replay Attacks
  5. A Fixed-Length MAC Construction
  6. Security of the Fixed-Length MAC Construction
  7. MAC for longer messages: CBC-MAC (CipherBlock Chaining) Construction
  8. Security of the Basic CBC-MAC construction

Message Authentication Code (MAC): Definition

  • A Message Authentication Code (MAC) consists of three probabilistic polynomial-time algorithms (Gen,Mac,Vrfy)(Gen, Mac, Vrfy) such that:
    1. GenGen takes as input the security parameter 1n1^n and outputs a key kk with kn|k| \ge n.
    2. MacMac is the tag-generation algorithm that takes as input a key kk and a message m{0,1}m \in \{0,1\}^* and outputs a tag tt, i.e., tMack(m)t \leftarrow Mac_k (m).
    3. VrfyVrfy is a deterministic verification algorithm that takes as input a key kk, a message mm, and a tag tt. It outputs a bit bb, with b=1b = 1 meaning the tag is valid and b=0b = 0 meaning the tag is invalid, i.e., b:=Vrfyk(m,t)b := Vrfy_k (m, t).
  • Correctness: It is required that for every nn, every key kk output by Gen(1n)Gen (1^n), and every m{0,1}m \in \{0,1\}^*, it holds that Vrfyk(m,Mack(m))=1Vrfy_k (m, Mac_k (m)) = 1.

Message Authentication Experiment Mac-forgeA,Π(n)\text {Mac-forge}_{\mathscr{A}, \Pi}(n)

  • For a Message Authentication Code Π=(Gen,Mac,Vrfy)\Pi = (Gen, Mac, Vrfy), an adversary A\mathscr A, and security parameter nn, define the message authentication experiment Mac-forgeA,Π(n)\text {Mac-forge}_{\mathscr{A}, \Pi}(n) as follows:
    1. A key kk is generated by running Gen(1n)Gen (1^n).
    2. Adversary A\mathscr A is given input 1n1^n and oracle access to Mack()Mac_k ( \cdot ). Let Q\mathscr Q denote the set of all queries that A\mathscr A asked its oracle. Adversary eventually outputs (m,t)(m, t).
    3. A\mathscr A succeeds and the experiment outputs 11 if and only if
      1. Vrfyk(m,t)=1Vrfy_k (m, t) = 1, and
      2. mQm \notin \mathscr Q.

MAC Security: Formal Definition

  • Definition. A Message Authentication Code Π=(Gen,Mac,Vrfy)\Pi = (Gen, Mac, Vrfy) is existentially unforgeable under an adaptive chosen-message attack, or just secure, if for all probabilistic polynomial-time adversaries A\mathscr A, there is a negligible function ϵ\epsilon such that:

    Pr[Mac-forgeA,Π(n)=1]ϵ(n)\Pr \left[ \text {Mac-forge}_{\mathscr{A}, \Pi}(n) =1\right] \le \epsilon(n)

Replay Attacks

  • The MAC security definition does not prevent Replay Attacks
    • Replay Attack: Attacker simply replays a message transmitted by the sender.
    • No stateless mechanism can prevent replay attacks: VrfyVrfy cannot distinguish whether it is being given (m,t)(m, t) that it has seen before since it does not maintain state.
  • Need to protect against replay attacks at a higher level than the MAC, by something that maintains state (typically sequence numbers (synchronized counters) and time-stamps).

A Fixed-Length MAC Construction

  • Construction MAC1{MAC}_1: Let FF be a pseudorandom function. Define a fixed-length MAC for messages of length nn as follows:
    • MacMac: Given input a key k{0,1}nk \in \{0,1\}^n and a message m{0,1}nm \in \{0,1\}^n, output the tag t:=Fk(m)t := F_k(m). If mk|m| \ne |k| then output nothing.
    • VrfyVrfy: Given input a key k{0,1}nk \in \{0,1\}^n, a message m{0,1}nm \in \{0,1\}^n, and a tag t{0,1}nt \in \{0,1\}^n, output 11 if and only if t=Fk(m)t = F_k(m). (If mk|m| \ne |k|, then output 00.)

Security of the Fixed-Length MAC Construction

  • Theorem. If FF is a pseudorandom function, then the Construction MAC1MAC_1 is a secure fixed-length MAC for messages of length nn.

MAC for longer messages: CBC-MAC (CipherBlock Chaining) Construction

  • Let FF be a pseudorandom function, and fix a length function l>0l > 0. The basic CBC-MAC construction is as follows:
    • MacMac: Given input a key k{0,1}nk \in \{0,1\}^n and a message mm of length l(n)nl(n) \cdot n, do the following:
      1. Parse mm as m=m1,,mlm = m_1, \ldots , m_l where each mim_i is of length nn.
      2. Set t0:=0nt_0 := 0^n. Then, for i=1i = 1 to ll, set ti=Fk(ti1mi)t_i = F_k (t_{i-1} \oplus m_i).
      3. Output tlt_l as the tag.
    • VrfyVrfy: Given input a key k{0,1}nk \in \{0,1\}^n, a message mm, and a tag tt, do:
      • If mm is not of length l(n)nl(n) ⋅ n, then output 00.
      • Otherwise output 11 if and only if t=Mack(m)t = Mac_k(m).

Security of the Basic CBC-MAC construction

  • Theorem. Let ll be a polynomial. If FF is a pseudorandom function, then the Basic CBC-MAC construction is a secure MAC for messages of length l(n)nl(n) \cdot n.

— Feb 21, 2023

Creative Commons License
§9 Message Authentication Codes by Lu Meng is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Permissions beyond the scope of this license may be available at About.