Professional Documents
Culture Documents
• Example 4.2. The set R of real numbers is a field with the neutral element 0 for
the additive group and the neutral element 1 for the multiplicative group. Every
real number a has an additive inverse, namely −a, and every nonzero element a
has a multiplicative inverse 1/a.
• In cryptography, we are interested in fields with a finite number of elements,
which we call finite fields or Galois fields. The number of elements in the field is
called the order or cardinalityComputer
of theScience,
field.Univ. of Madras 9
• 3 A Brief Introduction to Galois Fields
• The following theorem is of fundamental importance :
Theorem: A field with order m only exists if m is a prime power,
i.e., m = pn, for some positive integer n and prime integer p. p is
called the characteristic of the finite field.
• This theorem implies that there are finite fields with 13 elements or 27
elemnts (27= 33, 3 is prime), 256 elements (256 = 28) etc.
• This means that if we consider the integer ring Zm = {0,1,. . .,m-1} with
modular addition and multiplication, and m is prime, Zm is not only a ring but
also a finite field. (Definition of integer ring page 16(32))
• Ex. GF(5) is a finite field, ( GF – stands for Galois field). For + and x tables
see page 94(109) Computer Science, Univ. of Madras 11
• 3 A Brief Introduction to Galois Fields
• A very important prime field is GF(2), which is the smallest finite field
that exists.
• Example 4.4. Consider the small finite field GF(2)={0,1}. Arithmetic is
simply done modulo 2, yielding the following arithmetic tables:
• addition multiplication
• + 0 1 x 0 1
• 0 0 1 0 0 0
• 1 1 0 1 0 1
• XOR gate AND gate
• GF(2) addition, i.e., modulo 2 addition, is equivalent to an XOR gate.
What we learn from the example above is that GF(2) multiplication is
equivalent to the logical AND gate. The field GF(2) is important for AES.
Computer Science, Univ. of Madras 12
• 3.3 Extension Fields GF(2m) ( m > 1)
• In AES the finite field contains 256 elements and is denoted as GF(28). This
field was chosen because each of the field elements can be represented by
one byte.
• For the S-Box and MixColumn transforms, AES treats every byte of the
internal data path as an element of the field GF(28) and manipulates the data
by performing arithmetic in this finite field.
• Fields with m > 1 are called extension fields.
• In order to deal with extension fields we need
• (1) a different notation for field elements and
• (2) different rules for performing arithmetic with the elements.
• Elements can be represented as polynomials, and computation can be done
with a certain type of polynomial arithmetic.
Computer Science, Univ. of Madras 13
• 3.3 Extension Fields GF(2m)
• In the field GF(28), which is used in AES, each element
• A ∈ GF(28) is thus represented as: A(x) = a4x4+a0 = x4+1
• A(x) = a7x7+· · ·+a1x+a0, ai ∈ GF(2) = {0,1}.
• There are exactly 256 = 28 such polynomials.
• The set of these 256 polynomials is the finite field GF(28).
• Every polynomial can be stored in digital form as an 8-bit vector
• A = (a7,a6,a5,a4,a3,a2,a1,a0). =(0001 0001) = x4+1
• 3.4 Addition and Subtraction in GF(2m)
• The key addition layer of AES uses addition. They are simply standard
polynomial addition and subtraction: We merely add or subtract coefficients with
equal powers of x. The coefficient additions or subtractions are done in the
underlying field GF(2). Computer Science, Univ. of Madras 14
• Page 96 (111) addition subtraction definition
• Addition and subtraction modulo 2 are the same operation. Moreover, addition modulo 2 is
equal to bitwise XOR.
• Example 4.5. Sum C(x)=A(x) + B(x) of two elements from GF(28) is computed:
• A(x) = x7+ x6+ x4 + 1 =(11010001)
• B(x) = x4 + x2 +1 =(00010101)
• Addition C(x) = x7+ x6 + x2 =(11000100)
•
• 3.5 Multiplication in GF(2m)
• MixColumn transformation of AES uses multiplication in GF(28).
• First perform usual polynomial multiplication.
• A(x) ·B(x) = (am−1xm−1 + · · · + a0) · (bm−1xm−1 + · · · + b0)
• C(x) = c΄2m−2x2m−2 + · · · + c΄0
• where c΄0 = a0b0 mod 2 ; c΄1 = a0b1+a1b0 mod 2
• . . . c΄2m−2 = am−1bm−1 modComputer
2. Science, Univ. of Madras 15
• Note that all coefficients ai, bi and ci are elements of GF(2), and that
coefficient arithmetic is performed in GF(2).
• In general, the product polynomial C(x) will have a degree higher than
m−1 and has to be reduced.
• We use similar idea as in the case of multiplication in prime fields: in
GF(p), we multiply the two integers, divide the result by a prime, and
consider only the remainder.
• Here the product of the multiplication is divided by a certain polynomial,
and we consider only the remainder after the polynomial division.
• We need an irreducible polynomial for the module reduction.
• The irreducible polynomials are roughly comparable to prime numbers,
i.e., their only factors are 1 and the polynomial itself.
Computer Science, Univ. of Madras 16
• We use similar idea as in the case of multiplication in prime fields.
• GF(13) = Z13= {0, 1, 2...12};
• Z26 = {0,1, ...25} is not a field.
• Here 8*9 = 72 mod 13 = 7 mod 13
• For Polynomial multiplication, the product is divided by a certain
polynomial, called irreducible polynomial and we consider only the
remainder after the polynomial division.
•
Computer Science, Univ. of Madras 17
•
Definition: Extension field multiplication
Let A(x),B(x) ∈ GF(2m) and let
m
P( x) pi x i , pi GF (2)
i 0
be an irreducible polynomial. Multiplication of the two elements
A(x),B(x) is performed as
C(x) ≡ A(x) ·B(x) mod P(x).
• Note that not all polynomials are irreducible. For example, the polynomial x4+x3+x+1 is
reducible since
• x4+x3+x+1 = (x2+x+1)(x2+1)
• and hence this cannot be used to construct the extension field GF(24)
• In AES, the irreducible polynomial
• P(x) = x8 + x4 + x3 + x + 1
• is used. It is part of the AES specification.
Computer Science, Univ. of Madras 18
• Example 4.6. Multiply the two polynomials A(x) = x3 + x2 + 1 and B(x) = x2 + x in the field
GF(24). The irreducible polynomial of this Galois field is given as P(x) = x4 + x + 1.
• The plain polynomial product is computed as:
• C(x) = A(x) ·B(x) = x5 + x3 + x2 + x.
• We can now reduce C(x) using the polynomial division method.
• However, sometimes it is easier to reduce each of the leading terms x4 and x5 individually:
• x4 = 1 ·P(x) + (x + 1) [ 1(x4 + x + 1) + (x+1) = x4 ]
• x4 ≡ (x + 1) mod P(x) [= q(x)P(x)+r(x)]
• x5 ≡ x2 + x mod P(x).
• Now, we only have to insert the reduced expression for x5 into the intermediate result C(x):
• C(x) ≡ x5 + x3 + x2 + x mod P(x)
• C(x) ≡ (x2 + x) + (x3 + x2 + x) = x3
• A(x) ·B(x) ≡ x3. [(1 1 0 1) · (0 1 1 0) = (1 0 0 0);
• Note that 11012·01102=1310·610 =7810=10011102 – Galois Field arithmetic is different from
integer arithmetic.
• Ai Bi΄8)
GF(2 Bi
affine
inverse mapping
• The first part of the substitution is a Galois field inversion. For each input element Ai, the inverse is
computed:
Bi' Ai1
•
• where both Ai and Bi΄ are considered elements in the field GF(28) with the fixed irreducible
polynomial P(x) = x8 + x4 + x3 + x + 1. A lookup table(? - precomputed and stored table) with all
inverses is shown in Table 4.2. (Page 99 (114))
• Note that the inverse of the zero element does not exist. However, for AES it is defined that the zero
element Ai = 0 is mapped to itself.
Computer Science, Univ. of Madras 25
• 4.1 Byte Substitution Layer
• In the second part of the substitution, each byte Bi'
is multiplied by a constant bit
matrix followed by the addition of a constant 8-bit vector. The operation is described
by:
• b0 10001111 b0΄ 1
• b1 11000111 b1΄ 1
• b2 11100011 b2΄ 0
• b3 = 11110001 b3΄ + 0 mod 2
• b4 11111000 b4΄ 0
• b5 01111100 b5΄ 1
• b6 00111110 b6΄ 1
• b7 00011111
B ' ( b 7' ,..., b 0' )
b7΄ 0
• Note' that is the bitwise vector representation of
Bi ( x) Ai1 ( x)
• . This second step is referred to as affine mapping.
Computer Science, Univ. of Madras 26
• Example 4.10. We assume the S-Box input Ai = (11000010)2 = (C2)hex.
From Table 4.2 we can see that the inverse is:
• Ai1 Bi' ( 2 F ) hex ( 00101111 ) 2
•
Bi'
• We now apply the bit vector as input to the affine transformation.
• Note that the least significant bit (lsb) b0 of is atB the
i
' rightmost
position.
• Bi = (00100101) = (25)hex
• Thus, S((C2)hex) = (25)hex, which is exactly the result that is also given
in the S-Box Table 4.3.
• Page 101(116)
Computer Science, Univ. of Madras 27
• Affine mapping matrix
•
•
• 10001111 1 1 B = (2F) =( 0010 1111) = (b7b6b5...b0)
• 11000111 1 1 b0’ = 1+1 +1 = 1; b1’ = 1+1 +1+1= 0
• 11100011 1 0 b2’ = 1+1 +1 = 1; b3’ = 1+1 +1+1= 0
• 11110001 1 + 0 mod 2 b4’ = 1+1 +1+1+0 = 0;
• 11111000 0 0 b5’ = 1+1 +1+1 +1= 1
• 01111100 1 1 b6’ = 1+1 +1+1= 0
• 00111110 0 1 b7’ = 1+1 +0 = 0
• 00011111 0 0
• b0’ = (b0+b4+b5+b6+b7 + 1) mod2;
• B’ = (0010 0101)2 = (25)hex
1A FB C3 65
2D 49 A4 67
6F 6D 9A 75
2C 39 76 F 2
• The advantage of using inversion in GF(28) as the core function of the Byte
Substitution layer is that it provides a high degree of nonlinearity, which in turn
provides optimum protection against some of the strongest known analytical
attacks.
• The affine step “destroys” the algebraic structure of the Galois field, which in
turn is needed to prevent attacks that would exploit the finite field inversion.30
Computer Science, Univ. of Madras
• 4.2 Diffusion Layer
• It consists of two sublayers, the ShiftRows and the MixColumn. Diffusion is for spreading
the influence of individual bits over the entire state. The diffusion layer performs a linear
operation on state matrices A,B, i.e., DIFF(A) + DIFF(B) = DIFF(A +B).
• ShiftRows Sublayer: (row2 – 3bytes right, R3 2bytes, R4 1byte,R1 0byte)
• The ShiftRows transformation cyclically shifts the second row of the state matrix by three
bytes to the right, the third row by two bytes to the right and the fourth row by one byte to
the right. The first row is not changed by the ShiftRows transformation. The purpose of
the ShiftRows transformation is to increase the diffusion properties of AES. If the input of
the ShiftRows sublayer is given as a state matrix B = (B0,B1, . . . ,B15):
• The output is
B0 B4 B8 B12 B0 B4 B8 B12
B1 B5 B9 B13 B5 B9 B13 B1
B2 B6 B10 B14 B10 B14 B2 B6
• B3 B7 B11 B15 B15 B3 B7 B11
Computer Science, Univ. of Madras 31
• Example: Perform Shift row transformation and
find output of the following 4 x 4 state matrix. (For
you)
1A FB C3 65
2D 49 A4 67
6F 6D 9A 75
2C 39 76 F 2
• where (b7, . . . ,b0) is the bitwise vector representation of Bi(x), and (b′7, . . . ,b′0) the result
after the inverse affine transformation.
• In the second step of the inverse S-Box operation, the Galois field inverse has to be reversed.
For this, note that
• Ai = (A−1i )−1.
Computer Science, Univ. of Madras 59
• That is the inverse operation is reversed by computing the inverse again.
• In our notation we thus have to compute
• Ai = (B′i)−1 ∈ GF(28)
• Decryption Key Schedule
• Since decryption round one needs the last subkey, the second decryption
round needs the second-to-last subkey and so on, we need the subkey in
reversed order as shown in Fig.4.8. (Page 111(126))
• This is achieved by computing the entire key schedule first and storing
all 11, 13 or 15 subkeys, depending on the number or rounds AES is
using.
• This precomputation adds usually a small latency to the decryption
operation relative to encryption.
Computer Science, Univ. of Madras 60
THE END