Lec 6
Lec 6
Applied Cryptography
Advanced Encryption Standards
Algorithm (AES)
Lecture slides by
Dr. Eman Daraghmi
Associate Prof
PTUK
2021
Eman Yaser Daraghmi, Ph.D
1
[email protected]
Topics To be Covered ….
v AES Origin
v AES Encryption/Decryption
v Key Expansion Algorithm
v AES security
2
Part I : AES Origin
3
Origins
4
Origins
5
Origins
6
Origins
v final criteria
ü general security
ü software & hardware implementation ease
ü implementation attacks
ü flexibility (in en/decrypt, keying, other factors)
v 5 were shortlisted in Aug-99
ü MARS (IBM) - complex, fast, high security margin
ü RC6 (USA) - v. simple, v. fast, low security margin
ü Rijndael (Belgium) - clean, fast, good security margin
ü Serpent (Euro) - slow, clean, v. high security margin
ü Twofish (USA) complex, v. fast, high security margin
v then subject to further analysis & comment 7
Origins
8
Part II: The AES Cipher
9
The Rijndael Structure
v designed by Rijmen-Daemen in Belgium
v has 128/192/256 bit keys, 128 bit data
v an iterative rather than feistel cipher
ü operates on entire data block in every round
v data block of 4 columns of 4 bytes is state
v key is expanded to array of words
v has 9/11/13 rounds in which state undergoes:
ü byte substitution
ü shift rows
ü mix columns
ü add round key (XOR state with the round key)
v initial XOR key material & incomplete last round
v with fast XOR & table lookup implementation
v Chosen by the National Institute of Science and
Technology (NIST) as AES 10
AES- Rijndael
Structure
11
Data Units
12
Advanced Encryption Algorithm (AES)
13
Advanced Encryption Algorithm (AES)
v The 128-bit key is depicted as a square
matrix of bytes. The ordering of bytes
within a matrix is by column.
14
AES in Details: THE FOUR STEPS IN EACH
ROUND OF PROCESSING
v Four different stages are
used:
ü Substitute bytes: Uses an S-box
to perform a byte-by-byte
substitution of the block
ü ShiftRows: A simple
permutation
ü MixColumns: A substitution
that makes use of GF(2^8)
ü AddRoundKey: A simple XOR of
the current block with a portion
of the expanded key (with the
round key)
v Note: The different steps that
are carried out in each round
except the last one.
15
Stage 1: Byte Substitution Transformation
v STEP 1:
ü SubBytes for byte-by-byte substitution during the forward
process (Encryption)
ü InvSubBytes for byte-by-byte substitution during the
inverse transformation (Decryption)
• This step consists of using a 16 × 16 lookup table, called S-box
to find a replacement byte for a given byte in the input state
array.
16
Stage 1: Byte Substitution Transformation
v Each individual byte of State is mapped into a new byte in the
following way:
ü The leftmost 4 bits of the byte are used as a row value and the rightmost
4 bits are used as a column value.
v These row and column values serve as indexes into the S-box to
select a unique 8-bit output value.
17
Stage 1: Byte Substitution Transformation
v Here is an example of the SubBytes transformation:
ü For example, the hexadecimal value {0C} is referenced to row 0, column C
of the S-box, which contains the value {FE}.
18
Implementation of Byte Substitution
1 1 0 0 0 1 1 1
21
Polynomial and Binary Representation
• A binary can be presented as a Polynomial and a
polynomial can be presented as a binary as well
As our calculation is based on GF(2^8) = {0, …, 255} =
{00000000, ….,11111111}, a polynomial of 7 degrees is used
for representation (max power is 7)
𝑎𝑥 # + 𝑎𝑥 % + 𝑎𝑥 & + 𝑎𝑥 ' +𝑎𝑥 ( +𝑎𝑥 ) + 𝑎𝑥 * +𝑎𝑥 +
Example: Convert 1100 0111 to polynomial
1 1 0 0 0 1 1 1
22
Polynomial and Binary Representation
• Example:
1 0 1 1 0 0 1 1
23
Polynomial and Binary Representation
• Example:
0 1 0 1 0 0 1 1
0101 0011
24
Addition and Multiplication in GF(2^8)
If results consist of bits >8 then xor the result with the
binary representation of the irreducible polynomial
x8 + x4 + x3+ x + 1 = 1 0001 1011 25
Implementation of Byte Substitution
26
Implementation of Byte Substitution
27
Multiplicative Inverse in GF(2^8) via
Euclidian Algorithm
- Multiplicative Inverse means find a number in GF(2^8) such that
(0C X = 1)
q r1 r2 r t1 t2 t=t1-(q*t2)
28
Multiplicative Inverse in GF(2^8) via Euclidian
Algorithm
- Multiplicative Inverse means find a number in GF(2^8) such that (0C X = 1)
q r1 r2 r t1 t2 t=t1-(q*t2)
29
30
Multiplicative Inverse in GF(2^8) via Euclidian
Algorithm
- Multiplicative Inverse means find a number in GF(2^8) such that (0C X = 1)
q r1 r2 r t1 t2 t=t1-(q*t2)
31
Multiplicative Inverse in GF(2^8) via Euclidian
Algorithm
- Multiplicative Inverse means find a number in GF(2^8) such that (0C X = 1)
q r1 r2 r t1 t2 t=t1-(q*t2)
32
33
Multiplicative Inverse in GF(2^8) via Euclidian
Algorithm
- Multiplicative Inverse means find a number in GF(2^8) such that (0C X = 1)
q r1 r2 r t1 t2 t=t1-(q*t2)
34
Multiplicative Inverse in GF(2^8) via Euclidian
Algorithm
- Multiplicative Inverse means find a number in GF(2^8) such that (0C X = 1)
q r1 r2 r t1 t2 t=t1-(q*t2)
35
Multiplicative Inverse in GF(2^8) via Euclidian
Algorithm
- Multiplicative Inverse means find a number in GF(2^8) such that (0C X = 1)
q r1 r2 r t1 t2 t=t1-(q*t2)
36
Multiplicative Inverse in GF(2^8) via Euclidian
Algorithm
- Multiplicative Inverse means find a number in GF(2^8) such that (0C X = 1)
q r1 r2 r t1 t2 t=t1-(q*t2)
37
Multiplicative Inverse in GF(2^8) via Euclidian
Algorithm
- Multiplicative Inverse means find a number in GF(2^8) such that (0C X = 1)
q r1 r2 r t1 t2 t=t1-(q*t2)
38
Multiplicative Inverse in GF(2^8) via Euclidian
Algorithm
- Multiplicative Inverse means find a number in GF(2^8) such that (0C X = 1)
q r1 r2 r t1 t2 t=t1-(q*t2)
1 0 X^7+x^5+x^4 0
39
Multiplicative Inverse in GF(2^8) via Euclidian
Algorithm
- Multiplicative Inverse means find a number in GF(2^8) such that (0C X = 1)
q r1 r2 r t1 t2 t=t1-(q*t2)
40
Multiplicative Inverse in GF(2^8) via Euclidian
Algorithm
- Multiplicative Inverse means find a number in GF(2^8) such that (0C X = 1)
q r1 r2 r t1 t2 t=t1-(q*t2)
41
This is the number we are looking for = 10110000 = B0
Implementation of Byte Substitution
42
AES Stages – Stage 2: Shift Rows
v STEP 2:
ü ShiftRows for shifting the rows of the state array during
the forward process
ü InvShiftRows for Inverse ShiftRow Transformation
43
AES Stages – Stage 2: Shift Rows
v This operation on the state array can be represented by
Encryption
Left Shift 44
AES Stages – Stage 2: Shift Rows
v For decryption, the corresponding step shifts the rows in
exactly the opposite fashion.
v The first row is left unchanged, the second row is shifted
to the right by one byte, the third row to the right by two
bytes, and the last row to the right by three bytes, all
shifts being circular.
Decryption
Right shift
45
AES Stages – Stage 2: Shift Rows
46
MIX COLUMNS
v STEP 3:
ü called MixColumns for mixing up of the bytes in each column
separately during the forward process
ü InvMixColumns for inverse mix column transformation.
v The goal is here is to further scramble up the 128-bit input block.
v The shift-rows step along with the mix-column step causes strong
avalanche effect.
ü In DES, one bit of plaintext affected roughly 31 bits of ciphertext.
ü In AES, each bit of the plaintext to affect every bit position of the
ciphertext block of 128 bits.
47
AES Stages – THE MIX COLUMNS STEP 3:
MixColumns and InvMixColumns
48
THE MIX COLUMNS
49
Example: MixColumn
50
InvMixColumns
51
STEP 4: AddRoundKey
v STEP 4:
ü called AddRoundKey for adding the round key to the
output of the previous step during the forward process
ü InvAddRoundKey for inverse add round key
transformation
v XOR state with 128-bits of the round key
v again processed by column (though effectively a series of
byte operations)
52
AES-
Decryption
53
THE KEY EXPANSION ALGORITHM
54
THE KEY EXPANSION ALGORITHM
55
THE KEY EXPANSION ALGORITHM
56
THE KEY EXPANSION ALGORITHM
57
THE KEY EXPANSION ALGORITHM
v The beginning word of each round key is obtained by:
w4 = w0 ⊗ g(w3)
ü G function includes:
- SubWord: Perform a one-byte left circular shift.
– Perform a byte substitution for each byte of the word returned by the
previous step by using the same 16 × 16 lookup table as used in the SubBytes
– XOR the bytes obtained from the previous step with a round constant.
The round constant is a word whose three rightmost bytes are always zero.
Therefore, XOR’ing with the round constant amounts to XOR’ing with just its
leftmost byte.
58
The constant round key generator
x^8 + x^4+x^3 +x+1 ....
g Round # polynomial binary Decimal Hexadecimal
59
Key Expansion Algorithm Example
60
Security
AES was designed after DES. Most of the known attacks
on DES were already tested on AES.
• Brute-Force Attack
AES is definitely more secure than DES due to the
larger-size key.
7.61
Summary
v have considered:
ü the AES selection process
62