MMH-Badger MAC

From HandWiki

Badger is a Message Authentication Code (MAC) based on the idea of universal hashing and was developed by Boesgaard, Scavenius, Pedersen, Christensen, and Zenner.[1] It is constructed by strengthening the ∆-universal hash family MMH using an ϵ-almost strongly universal (ASU) hash function family after the application of ENH (see below), where the value of ϵ is [math]\displaystyle{ 1/(2^{32}-5) }[/math].[2] Since Badger is a MAC function based on the universal hash function approach, the conditions needed for the security of Badger are the same as those for other universal hash functions such as UMAC.

Introduction

The Badger MAC processes a message of length up to [math]\displaystyle{ 2^{64}-1 }[/math] bits and returns an authentication tag of length [math]\displaystyle{ u\cdot32 }[/math] bits, where [math]\displaystyle{ 1\le u \le 5 }[/math]. According to the security needs, user can choose the value of [math]\displaystyle{ u }[/math], that is the number of parallel hash trees in Badger. One can choose larger values of u, but those values do not influence further the security of MAC. The algorithm uses a 128-bit key and the limited message length to be processed under this key is [math]\displaystyle{ 2^{64} }[/math].[3]

The key setup has to be run only once per key in order to run the Badger algorithm under a given key, since the resulting internal state of the MAC can be saved to be used with any other message that will be processed later.

ENH

Hash families can be combined in order to obtain new hash families. For the ϵ-AU, ϵ-A∆U, and ϵ-ASU families, the latter are contained in the former. For instance, an A∆U family is also an AU family, an ASU is also an A∆U family, and so forth. On the other hand, a stronger family can be reduced to a weaker one, as long as a performance gain can be reached. A method to reduce ∆-universal hash function to universal hash functions will be described in the following.

Theorem 2[1]

Let [math]\displaystyle{ H^\triangle }[/math] be an ϵ-AΔU hash family from a set A to a set B. Consider a message [math]\displaystyle{ (m, m_b) \in A \times B }[/math]. Then the family H consisting of the functions [math]\displaystyle{ h(m,m_b) = H^\triangle (m) + m_b }[/math] is ϵ-AU.

If [math]\displaystyle{ m \ne m' }[/math], then the probability that [math]\displaystyle{ h(m,m_b) =h(m',m'_b) }[/math] is at most ϵ, since [math]\displaystyle{ H^\triangle }[/math] is an ϵ-A∆U family. If [math]\displaystyle{ m = m' }[/math] but [math]\displaystyle{ m_b\ne m_b' }[/math], then the probability is trivially 0. The proof for Theorem 2 was described in [1]

The ENH-family is constructed based on the universal hash family NH (which is also used in UMAC):

[math]\displaystyle{ NH_K (M)= \sum_{i=1}^ \frac{\ell}{2} (k_{(2i-1)} +_w m_{(2i-1)})\times (k_{2i} +_w m_{2i} ) \mod 2^{2w} }[/math]

Where '[math]\displaystyle{ +_w }[/math]' means 'addition modulo [math]\displaystyle{ 2^w }[/math]', and [math]\displaystyle{ m_i,k_i \in \big\{0,\ldots, 2^w-1\big\} }[/math]. It is a [math]\displaystyle{ 2^{-w} }[/math]-A∆U hash family.

Lemma 1[1]

The following version of NH is [math]\displaystyle{ 2^{-w} }[/math]-A∆U:

[math]\displaystyle{ NH_K (M)=(k_1 +_w m_1 )\times(k_2 +_w m_2 ) \mod 2^{2w} }[/math]

Choosing w=32 and applying Theorem 1, one can obtain the [math]\displaystyle{ 2^{-32} }[/math]-AU function family ENH, which will be the basic building block of the badger MAC:

[math]\displaystyle{ ENH_{k_1,k_2} (m_1,m_2,m_3,m_4 )=(m_1 +_{32} k_1)(m_2 +_{32} k_2) +_{64} m_3 +_{64} 2^{32} m_4 }[/math]

where all arguments are 32-bits long and the output has 64-bits.

Construction

Badger is constructed using the strongly universality hash family and can be described as

[math]\displaystyle{ \mathcal{H}=H^* \times F, }[/math][1]

where an [math]\displaystyle{ \epsilon_{H^*} }[/math]-AU universal function family H* is used to hash messages of any size onto a fixed size and an [math]\displaystyle{ \epsilon_{F} }[/math]-ASU function family F is used to guarantee the strong universality of the overall construction. NH and ENH are used to construct H*. The maximum input size of the function family H* is [math]\displaystyle{ 2^{64}-1 }[/math] and the output size is 128 bits, split into 64 bits each for the message and the hash. The collision probability for the H*-function ranges from [math]\displaystyle{ 2^{-32} }[/math] to [math]\displaystyle{ 2^{-26.14} }[/math]. To construct the strongly universal function family F, the ∆-universal hash family MMH* is transformed into a strongly universal hash family by adding another key.

Two steps on Badger

There are two steps that have to be executed for every message: processing phase and finalize phase.[3]

Processing phase

In this phase, the data is hashed to a 64-bit string. A core function h : [math]\displaystyle{ \left\{0,1\right\}^{64}\times \left\{0,1\right\}^{128} \to \left\{0,1\right\}^{64} }[/math] is used in this processing phase, that hashes a 128-bit string [math]\displaystyle{ m_2 \parallel m_1 }[/math] to a 64-bit string [math]\displaystyle{ h( k, m_2, m_1 ) }[/math] as follows:

[math]\displaystyle{ h(k, m_2, m_1 )= (L(m_1 ) +_{32} L(k) )\cdot(U(m_1) +_{32} U(k) ) +_{64} m_2 \, }[/math]

for any n, [math]\displaystyle{ +_n }[/math] means addition modulo [math]\displaystyle{ 2^n }[/math]. Given a [math]\displaystyle{ 2n }[/math]-bit string x, [math]\displaystyle{ L(x) }[/math] means least significant n bits, and [math]\displaystyle{ U(x) }[/math] means most significant n bits.

A message can be processed by using this function. Denote level_key[j][i] by [math]\displaystyle{ k_j^i }[/math].

Pseudo-code of the processing phase is as follow.

L = |M|
if L = 0
    [math]\displaystyle{ M^1 = \cdots = M^u = 0 }[/math]
    Go to finalization
r = L mod 64
if r ≠ 0:
    [math]\displaystyle{ M = 0^{64-r} \parallel M }[/math]
for i = 1 to u:
    [math]\displaystyle{ M^i = M }[/math]
    [math]\displaystyle{ v' = \max\{ 1, \lceil\log_2 L\rceil - 6 \} }[/math]
for j = 1 to v′:
    divide [math]\displaystyle{ M^i }[/math] into 64-bit blocks, [math]\displaystyle{ M^i = m_t^i \parallel \cdots \parallel m_1^i }[/math]
if t is even:
    [math]\displaystyle{ M^i = h(k_j^i, m_t^i, m_{t-1}^i) \parallel \cdots \parallel h(k_j^i, m_2^i, m_1^i) }[/math]
else
    [math]\displaystyle{ M^i = m_t^i \parallel h(k_j^i, m_{t-1}^i, m_{t-2}^i) \parallel \cdots \parallel h(k_j^i, m_2^i, m_1^i) }[/math]

Finalize phase

In this phase, the 64-string resulting from the processing phase is transformed into the desired MAC tag. This finalization phase uses the Rabbit stream cipher and uses both key setup and IV setup by taking the finalization key final_key[j][i] as [math]\displaystyle{ k_j^i }[/math].

Pseudo-code of the finalization phase

RabbitKeySetup(K)
RabbitIVSetup(N)
for i = 1 to u:
    [math]\displaystyle{ Q^i =0^7 \parallel L \parallel M^i }[/math]
    divide [math]\displaystyle{ Q^i }[/math] into 27-bit blocks, [math]\displaystyle{ Q^i=q_5^i \parallel \cdots \parallel q_1^i }[/math]
    [math]\displaystyle{ S^i =(\sum_{j=1}^5 (q_j^i K_j^i))+K_6^i \bmod p }[/math]
[math]\displaystyle{ S = S^u \parallel \cdots \parallel S^1 }[/math]
S = S ⨁ RabbitNextbit(u∙32)
return S

Notation

From the pseudocode above, k denotes the key in the Rabbit Key Setup(K) which initializes Rabbit with the 128-bit key k. M denotes the message to be hashed and |M| denotes the length of the message in bits. [math]\displaystyle{ q_i }[/math] denotes a message M that is divided into i blocks. For the given [math]\displaystyle{ 2n }[/math]-bit string x then L(x) and U(x) respectively denoted its least significant n bits and most significant n bits.

Performance

Boesgard, Christensen and Zenner report the performance of Badger measured on a 1.0 GHz Pentium III and on a 1.7 GHz Pentium 4 processor.[1] The speed-optimized versions were programmed in assembly language inlined in C and compiled using the Intel C++ 7.1 compiler.

The following table presents Badger's properties for various restricted message lengths. "Memory req." denotes the amount of memory required to store the internal state including key material and the inner state of the Rabbit stream cipher . "Setup" denotes the key setup, and "Fin." denotes finalization with IV-setup.

Max. Message Size Forgery Bound Memory Reg. Setup Pentium III Fin. Pentium III Setup Pentium III Fin. Pentium III
[math]\displaystyle{ 2^{11} }[/math] bytes (e.g.IPsec) [math]\displaystyle{ 2^{-57.7} }[/math] 400 bytes 1133 cycles 409 cycles 1774 cycles 776 cycles
[math]\displaystyle{ 2^{15} }[/math] bytes (e.g.TLS) [math]\displaystyle{ 2^{-56.6} }[/math] 528 bytes 1370 cycles 421 cycles 2100 cycles 778 cycles
[math]\displaystyle{ 2^{32} }[/math] bytes [math]\displaystyle{ 2^{-54.2} }[/math] 1072 bytes 2376 cycles 421 cycles 3488 cycles 778 cycles
[math]\displaystyle{ 2^{61}-1 }[/math] bytes [math]\displaystyle{ 2^{-52.2} }[/math] 2000 bytes 4093 cycles 433 cycles 5854 cycles 800 cycles

MMH (Multilinear Modular Hashing)

The name MMH stands for Multilinear-Modular-Hashing. Applications in Multimedia are for example to verify the integrity of an on-line multimedia title. The performance of MMH is based on the improved support of integer scalar products in modern microprocessors.

MMH uses single precision scalar products as its most basic operation. It consists of a (modified) inner product between the message and a key modulo a prime [math]\displaystyle{ p }[/math]. The construction of MMH works in the finite field [math]\displaystyle{ F_p }[/math] for some prime integer [math]\displaystyle{ p }[/math].

MMH*

MMH* involves a construction of a family of hash functions consisting of multilinear functions on [math]\displaystyle{ F_p^k }[/math] for some positive integer k. The family MMH* of functions from [math]\displaystyle{ F_p^k }[/math] to [math]\displaystyle{ F_p }[/math] is defined as follows.

[math]\displaystyle{ \mathrm{MMH}^* = \{ g_x : F_p^k \rightarrow F_p | x \in F_p^k \} }[/math]

where x, m are vectors, and the functions [math]\displaystyle{ g_x }[/math] are defined as follows.

[math]\displaystyle{ g_x(m) = m x\bmod p = \sum_{i=1}^n m_i\,x_i\bmod p }[/math]

In the case of MAC, m is a message and x is a key where [math]\displaystyle{ m = (m_1,\ldots,m_k) }[/math] and [math]\displaystyle{ x = (x_1,\ldots,x_k), x_i, m_i \in \!F_p }[/math].

MMH* should satisfy the security requirements of a MAC, enabling say Ana and Bob to communicate in an authenticated way. They have a secret key x. Say Charles listens to the conversation between Ana and Bob and wants to change the message into his own message to Bob which should pass as a message from Ana. So, his message m' and Ana's message m will differ in at least one bit (e.g. [math]\displaystyle{ m_1 \ne m'_1 }[/math]).

Assume that Charles knows that the function is of the form [math]\displaystyle{ g_x (m) }[/math] and he knows Ana's message m but he does not know the key x then the probability that Charles can change the message or send his own message can be explained by the following theorem.

Theorem 1[4]:The family MMH* is ∆-universal.

Proof:

Take [math]\displaystyle{ a\in F_p }[/math], and let [math]\displaystyle{ m , m' }[/math] be two different messages. Assume without loss of generality that [math]\displaystyle{ m_1 \ne m'_1 }[/math]. Then for any choice of [math]\displaystyle{ x_2,x_3,\ldots,x_s }[/math], there is

[math]\displaystyle{ \begin{align} {\Pr}_{x_1}[g_x (m)-g_x (m')\equiv a \mod p] &= {\Pr}_{x_1}[(m_1 x_1+m_2 x_2+ \cdots +m_k x_k )-(m'_1 x_1+m'_2 x_2+\cdots+m'_k x_k )\equiv a \mod p]\\ &= {\Pr}_{x_1}[(m_1-m'_1)x_1+(m_2-m'_2)x_2+ \cdots +(m_k-m'_k)x_k]\equiv a \mod p]\\ &= {\Pr}_{x_1}[(m_1-m'_1)x_1+\textstyle \sum_{k=2}^s(m_k-m'_k)x_k\equiv a \mod p]\\ &= {\Pr}_{x_1}[(m_1-m'_1)x_1\equiv a - \textstyle \sum_{k=2}^s(m_k-m'_k)x_k \mod p]\\ &=\frac {1}{p} \end{align} }[/math]

To explain the theorem above, take [math]\displaystyle{ F_p }[/math] for [math]\displaystyle{ p }[/math] prime represent the field as [math]\displaystyle{ F_p = \underbrace{\big\{ 0,1,\ldots,p-1 \big\}}_p }[/math]. If one takes an element in [math]\displaystyle{ F_p }[/math], let say [math]\displaystyle{ 0\in F_p }[/math] then the probability that [math]\displaystyle{ x_1=0 }[/math] is

[math]\displaystyle{ {\Pr}_{x_1 \in \!{F_p}}(x_1=0)= \frac {1}{p} }[/math]

So, what one actually needs to compute is

[math]\displaystyle{ {\Pr}_{(x_1,\ldots,x_k)\in \!{F_p^k}} (g_x(m)\equiv g_x(m')\mod p) }[/math]

But,

[math]\displaystyle{ \begin{align} {\Pr}_{(x_1,\ldots,x_k)\in \!{F_p^k}}(g_x(m)\equiv g_x(m')\mod p) &= \sum_{(x_2,\ldots,x_k)\in \!{F_p^{k-1}}} {\Pr}_{(x_2^'\cdots,x_k^')\in \!{F_p^{k-1}}}({x_2 = x_2^'},\ldots,{x_k = x_k^'})\cdot {\Pr}_{x_1\in \!F_p}(g_x(m)\equiv g_x(m')\mod p)\\ &= \sum_{(x_2,\ldots,x_k)\in \!{F_p^{k-1}}} \frac {1}{p^{k-1}} \cdot \frac {1}{p}\\ &=p^{k-1}\cdot \frac {1}{p^{k-1}} \cdot \frac {1}{p}\\ &=\frac {1}{p} \end{align} }[/math]

From the proof above, [math]\displaystyle{ \frac{1}{p} }[/math] is the collision probability of the attacker in 1 round, so on average p verification queries will suffice to get one message accepted. To reduce the collision probability, it is necessary to choose large p or to concatenate n such MACs using n independent keys so that the collision probability] becomes [math]\displaystyle{ \frac{1}{p^n} }[/math]. In this case the number of keys are increased by a factor of n and the output is also increased by n.

MMH*32

Halevi and Krawczyk[4] construct a variant called [math]\displaystyle{ \mathrm{MMH}^*_{32} }[/math]. The construction works with 32-bit integers and with the prime integer [math]\displaystyle{ p=2^{32}+15 }[/math]. Actually the prime p can be chosen to be any prime which satisfies [math]\displaystyle{ 2^{32}\lt p\lt 2^{32}+2^{16} }[/math]. This idea is adopted from the suggestion by Carter and Wegman to use the primes [math]\displaystyle{ 2^{16}+1 }[/math] or [math]\displaystyle{ 2^{31}-1 }[/math].

[math]\displaystyle{ \mathrm{MMH}^*_{32} }[/math] is defined as follows:
[math]\displaystyle{ \mathrm{MMH}^*_{32}=\left\{g_x (\left\{0,1\right\}^{32} )^k \right\} \to F_p, }[/math]

where [math]\displaystyle{ \left\{0,1\right\}^{32} }[/math] means [math]\displaystyle{ \left\{0, 1, \ldots, 2^{32}-1\right\} }[/math] (i.e., binary representation)

The functions [math]\displaystyle{ g_x }[/math] are defined as follows.

[math]\displaystyle{ \begin{align} g_x (m)&\ \overset{\underset{\mathrm{def}}{}}{=}\ m \cdot x \bmod (2^{32}+15)\\ &=\textstyle \sum_{i=1}^k m_i \cdot x_i \bmod (2^{32}+15) \end{align} }[/math]

where

[math]\displaystyle{ x= (x_1,\ldots,x_k ),\ m=(m,\ldots,m_k ) }[/math]

By theorem 1, the collision probability is about [math]\displaystyle{ \epsilon = 2^{-32} }[/math], and the family of [math]\displaystyle{ \mathrm{MMH}^*_{32} }[/math] can be defined as ϵ-almost ∆ Universal with [math]\displaystyle{ \epsilon = 2^{-32} }[/math].

The value of k

The value of k that describes the length of the message and key vectors has several effects:

  • Since the costly modular reduction over k is multiply and add operations increasing k should decrease the speed.
  • Since the key x consist of k 32-bit integers increasing k will results in a longer key.
  • The probability of breaking the system is [math]\displaystyle{ 1/p }[/math] and [math]\displaystyle{ p\approx 2^k }[/math] so increasing k makes the system harder to break.

Performance

Below are the timing results for various implementations of MMH[4] in 1997, designed by Halevi and Krawczyk.

  • A 150 MHz PowerPC 604 RISC machine running AIX
150 MHz PowerPC 604 Message in Memory Message in Cache
64-bit 390 Mbit/second 417 Mbit/second
32-bit output 597 Mbit/second 820 Mbit/second
150 MHz PowerPC 604 Message in Memory Message in Cache
64-bit 296 Mbit/second 356 Mbit/second
32-bit output 556 Mbit/second 813 Mbit/second
  • A 200 MHz Pentium-Pro machine running Linux
150 MHz PowerPC 604 Message in Memory Message in Cache
64-bit 380 Mbit/second 500 Mbit/second
32-bit output 645 Mbit/second 1080 Mbit/second


See also

References

  1. 1.0 1.1 1.2 1.3 1.4 1.5 Boesgaard, Martin; Scavenius, Ove; Pedersen, Thomas; Christensen, Thomas; Zenner, Erik (2005). "Badger- A fast and provably secure MAC". https://eprint.iacr.org/2004/319.pdf. 
  2. Lucks, Stefan; Rijmen, Vincent (2005). "Evaluation of Badger". http://www.cryptico.com/Files/Filer/Badger_Security_Report.pdf. 
  3. 3.0 3.1 "Badger Message Authentication Code,Algorithm Specification". 2005. http://www.cryptico.com/Files/Filer/WP_Badger_Specification.pdf. 
  4. 4.0 4.1 4.2 Halevi, Shai; Krawczyk, Hugo (1997). "MMH: Software message authentication in the Gbit/Second rates". MMH:Software Message Authentication in the Gbit/second rates. Lecture Notes in Computer Science. 1267. pp. 172–189. doi:10.1007/BFb0052345. ISBN 978-3-540-63247-4.