InfoSec 2
InfoSec 2
InfoSec 2
Sugata Gangopadhyay
1
These slides are informal class notes that are heavily influenced by Douglas Stinson’s
Cryptography Theory and Practice Edition 4 CRC Press.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 1 / 139
Symmetric Ciphers
Each xhii = xi1 . . . xin , where each xij ∈ {0, 1}, is said to be a block.
n
There are (2n )! ≈ (2n )2 permutations. To attain perfect secrecy,
n
theoretically, we need to choose one permutation from (2n )2
permutations uniformly at random.
key schedule.
The round function, say g, takes two inputs: a round key (K r ) and a
current state denoted by wr−1 .
w0 ← x
w1 ← g(w0 , K 1 )
w2 ← g(w1 , K 2 )
.. .. ..
. . .
wNr−1 ← g(wNr−2 , K Nr−1 )
wNr ← g(wNr−1 , K Nr )
y ← wNr
For decryption to be possible the function g must have the property that
it is injective (one-to-one) if its second argument is fixed.
wNr ← y
wNr−1 ← g −1 (wNr , K Nr )
.. .. ..
. . .
w1 ← g −1 (w2 , K 2 )
w0 ← g −1 (w1 , K 1 )
x ← w0
Feistel Network.
A plaintext and ciphertex both are binary vectors of length `m, i.e., they
are elements of {0, 1}`m . The integer `m is said to be the blocklength of
the cipher.
πS j : F`2 → F`2 .
i
x 0 1 2 3 4 5 6 7
πS (x) E 4 D 1 2 F B 8
x 8 9 A B C D E F
πS (x) 3 A 6 C 5 9 0 7
This is the S-box used in Stinson’s Cryptography Theory and Practice, page
75, Example 3.1.
x 1 2 3 4 5 6 7 8
πP (x) 1 5 9 13 2 6 10 14
Figure 3: Substitution-Permutation
x 9 10 11 12 13 14 15 16
πP (x) 3 7 11 15 4 8 12 16 Network
x 0 1 2 3 4 5 6 7
πS (x) C 5 6 B 9 0 A D
x 8 9 A B C D E F
πS (x) 3 E F 8 4 7 1 2
This is the S-box used in the ultra lightweight block cipher PRESENT.
x 1 2 3 4 5 6 7 8
πP (x) 1 5 9 13 2 6 10 14
x 9 10 11 12 13 14 15 16 Figure 4: Substitution-Permutation
πP (x) 3 7 11 15 4 8 12 16 Network
Feistel function
Li = Ri−1 ,
Ri = Li−1 ⊕ f (Ri−1 ⊕ Ki ).
x = 26B7, K = 3494D63E.
Feistel function
Li = Ri−1 ,
Ri = Li−1 ⊕ f (Ri−1 ⊕ Ki ).
2
Stinson, D. R.: Cryptography – theory and practice. Discrete mathematics and its applications series, CRC Press (1995)
Sugata Gangopadhyay (CSE IITR) Information and Network Security 23 / 139
Probabilistic Formulation
Pr[Xi = 0, Xj = 0] = pi pj
Pr[Xi = 0, Xj = 1] = pi (1 − pj )
Pr[Xi = 1, Xj = 0] = (1 − pi )pj
Pr[Xi = 1, Xj = 1] = (1 − pi )(1 − pj ).
The distribution of the discrete random variable Xi ⊕ Xj is:
Pr[Xi ⊕ Xj = 0] = pi pj + (1 − pi )(1 − pj )
Pr[Xi ⊕ Xj = 1] = pi (1 − pj ) + (1 − pi )pj .
Lemma
Let i1 ,...,ik denote the bias of the random variable Xi1 ⊕ · · · ⊕ Xik . Then
i1 ,...,ik = 2k−1 kj=1 ij where ij is the bias of the random variable Xij , for
Q
j = 1, . . . , k.
Proof.
Pr[Xi1 ⊕ Xi2 = 0] = pi1 pi2 + (1 − pi1 )(1 − pi2 )
= ( 21 + i1 )( 12 + i2 ) + ( 21 − i1 )( 12 − i2 ) = 21 + 2i1 i2 .
n
M m
M
a·X ⊕b·Y = ai Xi ⊕ bi Yi .
i=1 i=1
For a 4 S-box
4
M 4
M
NL (a, b) = #{(x, y) : y = πS (x), ai xi ⊕ bi yi = 0}
i=1 i=1
x 0 1 2 3 4 5 6 7 8 9 A B C D E F
πS (x) E 4 D 1 2 F B 8 3 A 6 C 5 9 0 7
a/b 0 1 2 3 4 5 6 7 8 9 A B C D E F
0 16 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
1 8 8 6 6 8 8 6 14 10 10 8 8 10 10 8 8
2 8 8 6 6 8 8 6 6 8 8 10 10 8 8 2 10
3 8 8 8 8 8 8 8 8 10 2 6 6 10 10 6 6
4 8 10 8 6 6 4 6 8 8 6 8 10 10 4 10 8
5 8 6 6 8 6 8 12 10 6 8 4 10 8 6 6 8
6 8 10 6 12 10 8 8 10 8 6 10 12 6 8 8 6
7 8 6 8 10 10 4 10 8 6 8 10 8 12 10 8 10
8 8 8 8 8 8 8 8 8 6 10 10 6 10 6 6 2
9 8 8 6 6 8 8 6 6 4 8 6 10 8 12 10 6
A 8 12 6 10 4 8 10 6 10 10 8 8 10 10 8 8
B 8 12 8 4 12 8 12 8 8 8 8 8 8 8 8 8
C 8 6 12 6 6 8 10 8 10 8 10 12 8 10 8 6
D 8 10 10 8 6 12 8 10 4 6 10 8 10 8 8 10
E 8 10 10 8 6 4 8 10 6 8 8 6 4 10 6 8
F 8 6 4 6 6 8 10 8 8 6 12 6 6 8 10 8
NL (a, b) :
L= #{(x, y)Ly =
πS (x), 4i=1 ai xi ⊕ 4i=1 bi yi = 0}
NL (a,b)−8
(a, b) = 16 .
From the linear approximation table we
observe: NL (1, 2) = NL (1, 3) = 6,
NL (6, 3) = NL (A, 1) = NL (B, 1) =
NL (B, 4) = NL (C, 2) = 12.
The biases are (1, 2) = (1, 3) = − 18 ,
(6, 3) = (A, 1) = (B, 1) = (B, 4) =
Figure 10: A simple block cipher
(C, 2) = 14 .
NL (A, 1) = 12.
12
Pr[X2 ⊕ K2 ⊕ X4 ⊕ K4 ⊕ V1 = 0] = 16 .
Y1 = V1 ⊕ K5 , i.e., V1 = Y1 ⊕ K5 .
Pr[X2 ⊕ K2 ⊕ X4 ⊕ K4 ⊕ Y1 ⊕ K5 =
0] = 12
16 .
Pr[(X2 ⊕ X4 ⊕ Y1 ⊕ K5 ) ⊕ (K2 ⊕ K4 ) =
12
0] = 16 .
Figure 11: A simple block cipher Pr[(X2 ⊕X4 ⊕Y1 ⊕K5 ) = 0] ∈ { 12 4
16 , 16 }.
Pr[(X2 ⊕ X4 ⊕ Y1 ⊕ K5 ) = 0] ∈ { 12 4
16 , 16 }.
bias(T1 ) = 14 , bias(T2 ) = 38 .
1 3 3
By Piling-up lemma bias(T1 ⊕ T2 ) = 2 × 4 × 8 = 16 .
The theory says that if the guess of x5 is correct then the number of
times S = xj2 ⊕ xj4 ⊕ y1j ⊕ k5 divided by T is approximately 1611 5
or 16 .
For each candidate key, we compute the values of certain state bits, and
determine if their x-or has a certain value (namely, the most likely value
for the given input x-or).
For any x0 ∈ {0, 1}m , define ∆(x0 ) to consist of all the ordered pairs
(x, x∗ ) having input x-or equal to x0 .
x 0 1 2 3 4 5 6 7 8 9 A B C D E F
πS (x) E 4 D 1 2 F B 8 3 A 6 C 5 9 0 7
∆(1011) = {(0000, 1011), (0001, 1010), . . . , (1111, 0100)}
Following are the distributions of the output x-ors: small
0000 0001 0010 0011 0100 0101 0110 0111
0 0 8 0 0 2 0 2
ND (a0 , b0 )
Rp (a0 , b0 ) = .
2m
Rp (a0 , b0 ) can be interpreted as a conditional probability:
x 0 1 2 3 4 5 6 7 8 9 A B C D E F
πS (x) E 4 D 1 2 F B 8 3 A 6 C 5 9 0 7
Therefore,
3
1 3 27
Rp (0000101100000000, 0000010101010000) = × = .
2 8 1024
k1 E(x0 , k1 ) = y1
k2 E(x0 , k2 ) = y2
.. .. .. (4)
. . .
k2m E(x0 , k2m ) = y2m
Hellman proposed a middle path between these two extreme cases and
demonstrated a practical attack on DES.
3
Hellman, M.E.: A cryptanalytic time-memory trade-off. IEEE Trans. Information Theory 26(4), 401–406 (1980)
Sugata Gangopadhyay (CSE IITR) Information and Network Security 48 / 139
TMTO: Hellman’s Approach
P = K = C = Fn2 .
Block cipher: E : P × K → C.
f f f f
x10 −
→ x11 −
→ x12 −
→ ··· −
→ x1t
f f f f
→ x21 −
x20 − → x22 −
→ ··· −
→ x2t
.. .. .. ..
. . . .
f f f f
xm0 −
→ xm1 −
→ xm2 −
→ ··· −
→ xmt
4
Hellman, M.E.: A cryptanalytic time-memory trade-off. IEEE Trans. Information Theory 26(4), 401–406 (1980)
5
Biryukov, A., Shamir, A.: Cryptanalytic time/memory/data tradeoffs for stream ciphers. ASIACRYPT 2000. pp. 1–13.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 51 / 139
TMTO Matrix
TMTO-matrix:
x11 x12 ··· x1t
x21 x22 ··· x2t
.
. .. .. .. .. (5)
. . . . .
xm1 xm2 · · · xmt
Instead of storing all the mt keys of each of the t matrices, only the
starting and the ending keys are stored in a list.
In case all the keys are covered in the tables, the attack will be successful.
The memory requirement for each table is m. So for t tables the memory
requirement is M = mt.
If we assume that the tables are sorted, the time to search each table is
log2 m.
In case we have to search all t tables before finding a match, the time
complexity if t × log2 m.
T = (t − 1) × t × log2 m.
For each table we need m locations to store the first and the last points of
each row.
Since there are t tables and for each table computation is of the order t
we have the online phase time complexity T = t2 .
In case we include the time complexity of the table search in the online
phase T = t2 log2 m.
M = mt
P =N
N = mt2
T = t2
T M 2 = t2 m2 t2 = (mt2 )2 = N 2 .
6
These slides are notes from “Cryptography: Theory and Practice” by Douglas Stinson.
Several sentences are copied from that book. This is only for class room use.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 64 / 139
Hash functions: fingerprinting data, message digest
A message digest would typically be a fairly short binary string; 160 bits
is a common choice.
The fact that x has been altered can be detected by computing y 0 = h(x0 )
and verifying that y 0 6= y.
Suppose that Alice and Bob share a secret key K which determines a
hash function, say hK .
The pair (x, y) can be transmitted over an insecure channel from Alice to
Bob.
When Bob receives the pair (x, y), he can verify if y = hK (x).
One aim of the study of hash functions is to develop methods that resist
creation of valid pairs by adversaries.
|X | = N ,|Y| = M .
X ,Y
The number of all possible hash functions from X to Y is F = MN.
If a hash function h is well designed, it should be the case that the only
efficient way to determine the value h(x) for a given x is actually
evaluate the function h at the value x.
This should remain true even if many other values h(x1 ), h(x2 ), . . . have
already been calculated.
Theorem
Suppose that h ∈ F X ,Y is chosen randomly, and let X0 ⊆ X . Suppose that
the values h(x) have been determined (by querying an oracle h) if and only if
1
x ∈ X0 . The Pr[h(x) = y] = M for all x ∈ X \ X0 and all y ∈ Y.
The success probability is the average over all possible random choices
of h ∈ F X ,Y , and all possible random choices of x ∈ X or y ∈ Y, if x
and y are specified as part of the problem instance.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 76 / 139
Find-Preimage
Input: h, y, Q;
choose any X0 ⊆ X ,|X0 | = Q;
for x ∈ X0 do
if h(x) = y then
return x
end
return failure
end
Algorithm 3: Find-Preimage
Theorem
For any X0 ⊆ X with|X0 | = Q, the average-case success probability of
1 Q
Algorithm 3 is = 1 − (1 − M ) .
Proof.
Let y ∈ Y, and X0 = {x1 , . . . , xQ }. Let Ei denote the event “h(xi ) = y. ”
Pr[Ei ] = 1/M and Pr[Eic ] = 1 − 1/M .
Input: h, x, Q;
y ← h(x);
choose X0 ⊆ X \ {x},|X0 | = Q − 1;
for x ∈ X0 do
if h(x) = y then
return x
end
return failure
end
Algorithm 4: Find-Second-Preimage
Theorem
For any X0 ⊆ X with|X0 | = Q − 1, the average-case success probability of
1 Q−1
Algorithm 4 is = 1 − (1 − M ) .
Proof.
Let y ∈ Y, and X0 = {x1 , . . . , xQ−1 }. Let Ei denote the event “h(xi ) = y. ”
Pr[Ei ] = 1/M and Pr[Eic ] = 1 − 1/M .
Input: h, Q;
choose X0 ⊆ X ,|X0 | = Q;
for x ∈ X0 do
yx ← h(x);
end
if yx = yx0 for some x 6= x0 then
return (x, x0 )
end
else
return failure
end
Algorithm 5: Find-Collision
Proof.
Let X0 = {x1 , x2 , . . . , xQ }. For 1 ≤ i ≤ Q, let Ei denote the event
h(xi ) ∈
/ {h(x1 ), h(x2 ), . . . , h(xi−1 )}.
M −i+1
Pr[Ei |E1 ∧ E2 ∧ · · · ∧ Ei−1 ] = .
M
Therefore
Q−1
Y
i
Pr[E1 ∧ E2 ∧ · · · ∧ EQ ] = 1− .
M
i=1
Sugata Gangopadhyay (CSE IITR) Information and Network Security 82 / 139
Find-Collision
Q−1
Y
i
Pr[E1 ∧ E2 ∧ · · · ∧ EQ ] = 1−
M
i=1
Q−1
Y −i PQ−1 i −Q(Q−1)
= e M = e− i=1 M =e 2M .
i=1
−Q(Q−1)
The probability of finding at least one collision is = 1 − e 2M .
−Q(Q−1)
e 2M ≈ 1 − ; −Q(Q−1) 2M ≈ ln(1 − ); Q2 − Q ≈ 2M ln 1− 1
r
1
Q≈ 2M ln
1−
√
If we take = 0.5, then our estimate is Q ≈ 1.17 M .
Sugata Gangopadhyay (CSE IITR) Information and Network Security 83 / 139
Comparison of security criteria
C OLLISION -T O -S ECOND -P REIMAGE Finding a collision is easier than
finding the second-preimage. If we have an algorithm that solves the
second-primage problem, then it can be used to find collision. This is sail
to be a “reduction of the problem C OLLISION to the problem
S ECOND -P REIMAGE.
C OLLISION -T O -S ECOND -P REIMAGE
Input: external O RACLE -2 ND -P REIMAGE
choose x ∈ X uniformly at random;
if O RACLE -2 ND -P REIMAGE(h, x) = x0 then
return (x, x0 )
end
else
return failure
end
Algorithm 6: Collision-To-Second-Preimage
Sugata Gangopadhyay (CSE IITR) Information and Network Security 84 / 139
C OLLISION -T O -P REIMAGE
C OLLISION -T O -P REIMAGE Suppose that we have a (1, Q) algorithm to
solve preimage. The question is whether it can be used to solve collision.
The following randomized algorithm performs that task. The is a
“reduction of the problem C OLLISION to the problem P REIMAGE.
C OLLISION -T O -P REIMAGE
Input: external O RACLE -P REIMAGE
choose x ∈ X uniformly at random;
y ← h(x) ;
if O RACLE -P REIMAGE(h, y) = x0 and x 6= x0 then
return (x, x0 )
end
else
return failure
end
Algorithm 7: Collision-To-Preimage
Sugata Gangopadhyay (CSE IITR) Information and Network Security 85 / 139
Collision-to-Preimage
Processing step
Let IV be a public initial value that is a bitstring of length m. Then compute
the following:
z0 ← IV
z1 ← compress(z0 ky1 )
z2 ← compress(z1 ky2 )
.. ..
. .
zr ← compress(zr−1 kyr ).
Sugata Gangopadhyay (CSE IITR) Information and Network Security 88 / 139
Iterated Hash Functions
Output step
Let g : {0, 1}m → {0, 1}` be a public function. Define h(x) = g(zr ).
Padding
Padding function is a publicly disclosed function that is applied on x to
produce pad(x).
Typically pad(x) involves the length|x| and additional zeros so that the
length of y = xkpad(x) is divisible by t.
X = ∪∞ i
i=m+t+1 {0, 1} .
Case 1: t ≥ 2
n
Suppose x ∈ X , and|x| = n ≥ m + t + 1. k = d t−1 e and d = k(t − 1) − n.
We can express x as the concatenation: x = x1 kx2 k · · · kxk , where
|x1 | = |x2 | = · · · = |xk−1 | = t − 1 and xk = t − 1 − d.
y(x) = y1 ky2 k · · · kyk+1 . yk is formed from xk by padding on the right with
d zeroes, so that all the blocks yi (1 ≤ i ≤ k) are of length t − 1. yk+1 should
be padded on the left with zeroes so that|yk+1 | = t − 1.
Theorem
Suppose compress : {0, 1}m+t → {0, 1}m is a collision resistant
compression function, where t ≥ 2. Then the function
∞
[
h: {0, 1}i → {0, 1}m ,
i=m+t+1
Theorem
Suppose compress : {0, 1}m+1 → {0, 1}m is a collision resistant
compression function, where t ≥ 2. Then the function
∞
[
h: {0, 1}i → {0, 1}m ,
i=m+2
Sugata Gangopadhyay (CSE IITR) Information and Network Security 100 / 139
The Sponge Construction
The sponge function based on f works as follows:
Absorbing phase
Initially the state is a bitstring of length b consisting of zeroes.
The first block of the padded message is exclusive-ored with the first r
bits of the state. Then the function f is applied which updates the state.
This process is repeated with the remaining blocks of the padded
message.
Squeezing phase
Suppose ` output bits are desired.
Take the first r bits of the current state; this forms an output block.
If ` > r we apply f to the current state and take the first r output bits as
another output block.
The process is repeated until we have a total of at least ` bits.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 101 / 139
Diagram of the sponge construction
Sugata Gangopadhyay (CSE IITR) Information and Network Security 103 / 139
Generation of an internal collision
Suppose
Sugata Gangopadhyay (CSE IITR) Information and Network Security 105 / 139
SHA-3
Sugata Gangopadhyay (CSE IITR) Information and Network Security 106 / 139
Message Authentication Codes: keyed hash function
Keyed hash function from an unkeyed hash function
Suppose h is an unkeyed hash function with IV as the initial value that
required every input message x to have length that is a multiple of t.
h utilizes the compression function compress : {0, 1}m+t → {0, 1}m .
The initial value IV is set to the key K, i.e., IV = K.
z0 ← K
z1 ← compress(z0 ky1 )
z2 ← compress(z1 ky2 )
.. ..
. .
zr ← compress(zr−1 kyr ).
Sugata Gangopadhyay (CSE IITR) Information and Network Security 107 / 139
Unkeyed to keyed hash functions
IV = K
z0 ← K
z1 ← compress(z0 ky1 )
z2 ← compress(z1 ky2 )
.. ..
. .
zr ← compress(zr−1 kyr ).
Sugata Gangopadhyay (CSE IITR) Information and Network Security 108 / 139
Length extension attack with padding
Length extension attack with padding
Suppose y = xkpad(x), such that|y| = rt.
Let|w| = t. Define: x0 = xkpad(x)kw.
y 0 = x0 kpad(x0 ) = xkpad(x)kwkpad(x0 ). where y 0 = r0 t for some
integer r0 > r.
Computing hK (x0 )
Let zr = hK (x).
(x0 ) = z(CSE
hKGangopadhyay
SoSugata r0 . IITR) Information and Network Security 109 / 139
MAC attack models
Oscar might have access to some valid pairs for the key K:
Sugata Gangopadhyay (CSE IITR) Information and Network Security 110 / 139
Forgery
Sugata Gangopadhyay (CSE IITR) Information and Network Security 111 / 139
Two obvious attacks
Sugata Gangopadhyay (CSE IITR) Information and Network Security 112 / 139
Nested MACs
G ◦ H = {g ◦ h : g ∈ G, h ∈ H}
Sugata Gangopadhyay (CSE IITR) Information and Network Security 113 / 139
Nested MACs
The nested MAC is secure if the following two conditions are satisfied:
1 (Y, Z, L, H) is secure as a MAC, given a fixed (unknown) key.
2 (X , Y, K, G) is collision resistant, given a fixed (unknown) key.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 114 / 139
Adversaries
2 a collision-finder for the has family (X , Y, K, G), when the key is secret
(this is an “unknown-key collision attack”), and
3 a forger for the nested MAC (which we term a “big MAC attack”).
Sugata Gangopadhyay (CSE IITR) Information and Network Security 115 / 139
Types of attacks
Little MAC attack : a key L is chosen and kept secret. Oscar is allowed
to choose values for y and query a little MAC oracle for the value of
hL (y). Then Oscar attempts to output a pair (y 0 , z) such that z = hL (y 0 )
where y 0 was not one of his previous queries.
Unknown-key collision attack : a key K is chosen and kept secret.
Oscar is allowed to choose values for x and query a hash oracle for
values of gK (x). Then Oscar attempts to output a pair x0 , x00 such that
x0 6= x and gK (x0 ) = gK (x00 ).
Big MAC attack : a pair of keys (K, L) is chosen and kept secret. Oscar
is allowed to choose values for x and query a big MAC oracle for values
of hL (gK (x)). Then Oscar attempts to output a pair (x0 , z) such that
z = hL (gK (x0 )) where x0 was not one of its previous queries.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 116 / 139
Assumptions
We assume that:
1 there does not exist an (1 , Q + 1)-unknown-key collision attack for a
randomly chosen function gK ∈ G where K is secret.
2 there does not exist an (2 , Q)-little MAC attack for a randomly chosen
function hL ∈ H, where L is secret.
3 There exists an (, Q)-big MAC attack for a randomly chosen function
(g ◦ h)(K,L) ∈ G ◦ H, where (K, L) is a secret.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 117 / 139
The attack
The big MAC algorithm outputs a valid pair (x, z) after making at most
Q queries to a big MAC oracle.
x1 , . . . , xQ are the queries, say, generating valid message-tag pairs
(x1 , z1 ), . . . , (xQ , zQ ), as well the valid message-tag pair (x, z) with
probability at least .
Make Q + 1 queries to a hash oracle gK to obtain
y1 = gK (x1 ), . . . , yQ = gK (xQ ), and y = gK (x).
If y = yi for some i ∈ {1, . . . , Q} we have a collision. Else, we have a
valid pair for the little MAC, hence a forger for the little MAC.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 118 / 139
Probability bounds
Sugata Gangopadhyay (CSE IITR) Information and Network Security 119 / 139
Theorem
Suppose (X , Z, M, G ◦ H) is a nested MAC. Suppose that there does not exist
an (1 , Q + 1)-collision attack for a randomly chosen function gK ∈ G, when
the key K is secret. Further, suppose that there does not exist an
(2 , Q)-forger for a randomly chosen function hL ∈ H, where L is secret.
Finally, suppose there exist an (, Q)-forger for the nested MAC, for a
randomly chosen function (g ◦ h)(K,L) ∈ G ◦ H. Then ≤ 1 + 2 .
Sugata Gangopadhyay (CSE IITR) Information and Network Security 120 / 139
HMAC
Sugata Gangopadhyay (CSE IITR) Information and Network Security 121 / 139
CBC-MAC
CBC-MAC(x, K)
denote x = x1 kx2 k · · · kxn ;
IV ← 00 · · · 0;
y0 ← IV;
for i ← 1tok − 1 do
yi ← EK (yi−1 ⊕ xi );
end
return yy ;
Algorithm 10: MAC FROM BLOCK CIPHERS
Sugata Gangopadhyay (CSE IITR) Information and Network Security 122 / 139
Authenticated encryption
MAC-and-encrypt: Given a message x, compute a tag z = hK1 (x) and
a ciphertext y = eK2 (x). The pair (y, z) is transmitted. The receiver
would decrypt y, obtaining x, and then verify the correctness of the tag z
on x.
MAC-then-encrypt Here the tag z = hK1 (x) would be computed first.
Then the plaintext and tag would both be encrypted, yielding
y = eK2 (xkz). The ciphertext y would be transmitted. The receiver will
decrypt y, obtaining x and z, and then verify the correctness of the tag z
on x.
encrypt-then-MAC Here the first step is to encrypt x, producing a
ciphertext y = eK2 (x). Then a tag is created for the ciphertext y, namely,
z = hK1 (y). The pair (y, z) is transmitted. The receiver will first verify
the correctness of the tag z on y. Then, provided that the tag is valid, the
receiver will decrypt y to obtain x.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 123 / 139
Authenticated encryption
Sugata Gangopadhyay (CSE IITR) Information and Network Security 124 / 139
Counter with CBC MAC (CCM) mode of operation
Sugata Gangopadhyay (CSE IITR) Information and Network Security 125 / 139
Decryption
To decrypt and verify y, one would first decrypt y1 k · · · kyn using the
counter mode decryption with the counter sequence T1 , T2 , . . . , Tn ,
obtaining the plaintext string x.
The second step is to compute CBC-MAC(x, K) and see if it is equal to
y 0 ⊕ T0 .
The ciphertext is rejected if this condition does not hold.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 126 / 139
Galois Counter mode
Sugata Gangopadhyay (CSE IITR) Information and Network Security 127 / 139
Unconditionally secure MACS
Assumptions:
The adversary has infinite computational power.
Any given key is used to produce only one authentication tag.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 128 / 139
Unconditionally Secure MACs
Sugata Gangopadhyay (CSE IITR) Information and Network Security 129 / 139
Unconditionally Secure MACs
key 0 1 2
(0, 0) 0 0 0
(0, 1) 1 1 1
Example (0, 2) 2 2 2
Suppose X = Y = Z3 , and K = Z3 × Z3 . For (1, 0) 0 1 2
each K = (a, b) ∈ K and each x ∈ X , define (1, 1) 1 2 0
h(a,b) (x) = ax + b mod 3, and then define (1, 2) 2 0 1
H = {h(a,b) : (a, b) ∈ Z3 × Z3 }. Each of the (2, 0) 0 2 1
9 keys are used with probability 19 . (2, 1) 1 0 2
(2, 2) 2 1 0
Table 2: An authentication matrix
Sugata Gangopadhyay (CSE IITR) Information and Network Security 130 / 139
Unconditionally Secure MACs
Deception probabilities
key 0 1 2
Any message-tag pair (x, y) will be a (0, 0) 0 0 0
valid pair with probability 13 . (0, 1) 1 1 1
So P d0 = 13 . (0, 2) 2 2 2
If Oscar sees the message-tag pair (0, 0) (1, 0) 0 1 2
he knows that (1, 1) 1 2 0
K0 = {(0, 0), (1, 0), (2, 0)}. (1, 2) 2 0 1
(1, 1) is a forgery if K0 = (1, 0). This (2, 0) 0 2 1
happens with probability 13 . (2, 1) 1 0 2
(2, 2) 2 1 0
Repeating this for all possible
message-tag pairs gives us the same Table 3: An authentication matrix
probability. So P d1 = 13 .
Sugata Gangopadhyay (CSE IITR) Information and Network Security 131 / 139
Payoff: deception probability of impersonation
Let K0 denote the key chosen by Alice and Bob. For x ∈ X and y ∈ Y,
define payoff (x, y) to be the probability that the message-tag pair (x, y)
is valid.
payoff (x, y) = Pr[y = hK0 (x)]
{K ∈ K : hK (x) = y}
= .
|K|
Sugata Gangopadhyay (CSE IITR) Information and Network Security 132 / 139
Payoff: deception probability of substitution
V = {(x, y) : {K ∈ K : y = hK (x)} ≥ 1}.
P d1 = max(x,y)∈V {max(x0 ,y0 ),x0 6=x {payoff (x0 , y 0 ; x, y)}}.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 133 / 139
Strongly Universal Hash Families
Definition
Suppose (X , Y, K, H) is an (N, M ) hash family. This hash family is strongly
universal provided that the following condition is satisfied for every x, x0 ∈ X
such that x 6= x0 , and for every y, y 0 ∈ Y:
Sugata Gangopadhyay (CSE IITR) Information and Network Security 134 / 139
Strongly Universal Hash Families
{K ∈ K : hK (x) = y} = |K| ,
M
for every x ∈ X and for every y ∈ Y.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 135 / 139
Optimality of Deception Probabilities
Sugata Gangopadhyay (CSE IITR) Information and Network Security 136 / 139
Optimality of deception probabilities
Theorem
1
Suppose (X , Y, K, H) is an (N, M )-hash family. Then P d0 ≥ M. Further
1
P d0 = M if and only if
{K ∈ K : hK (x) = y} = |K|
M
for every x ∈ X and y ∈ Y.
Theorem
1
Suppose (X , Y, K, H) is an (N, M )-hash family. Then P d1 ≥ M.
Sugata Gangopadhyay (CSE IITR) Information and Network Security 137 / 139
Optimality of deception probabilities
Theorem
1
Suppose (X , Y, K, H) is an (N, M )-hash family. Then P d1 = M. Further
1
P d0 = M if and only if the hash family is strongly universal.
Theorem
1
Suppose (X , Y, K, H) is an (N, M )-hash family such that P d1 = M. Then
1
P d0 = M .
Sugata Gangopadhyay (CSE IITR) Information and Network Security 138 / 139
The End
Sugata Gangopadhyay (CSE IITR) Information and Network Security 139 / 139