Modern Symmetric Block Ciphers
Modern Symmetric Block Ciphers
and Block
Cipher
Differences between Stream and Block Ciphers
Stream Block
One Bit or Byte is processed (encrypted or Fixed size block is processed at a time (64 bits,
decrypted) at a time 128 bits, etc.)
Usually Variable Key size A given algorithm will have a fixed key size
Padding is not required Most probably requires padding
Processing is faster Processing is slower
Error Propagation is limited Error propagation could be significant and can
produce a completely different output
Examples:- RC4, Rabbit, ChaCha, etc. Examples:- AES, DES, Triple DES, Serpent,
etc.
Used for real-time data stream encryptions Used for applications which can handle large
and decryptions, where minimum latency is data chunks.
expected.
MOTIVATION FOR FEISTEL
CIPHER STRUCTURE
n-bit to n-bit Block Substitution
• Block Cipher (n-bit PT block ➡️n-bit CT block, and vice-versa)
• Number of PT blocks possible = 2n.
• Decryption is possible when each PT block can produce a unique CT
block (Reversible or Non-Singular Transformation).
PT Block CT Block
00 11
01 10
10 01
11 01
n
• Number of Reversible sets of transformations = 2 !
4-bit to 4-bit Block Substitution Example
n-bit to n-bit Block Substitutions (Contd..)
• We noticed with n=2, and n=4, that the corresponding tables define
straightforward mappings between PT blocks and CT blocks.
• Increasing the block size makes the block cipher more resistant to
cryptanalysis.
n
• The mappings can be defined by a key whose length is n*2 bits.
• Ease of Analysis
• Key Size
• Number of Rounds
• Round Function
Solution:-
• PT = 0x3C
• LE0 = (0011)2
• RE0 = (1100)2
Example 1 (Contd..)
Round 1:-
• LE1 = (1100)2
• RE1 = LE0 ⊕ F(RE0, K1)
• RE1 = (0011)2 ⊕ F((1100)2,(1111)2)
• RE1 = (0011)2 ⊕ (1100)2
• RE1 = (1111)2
• Therefore, Round 1 Output = 0xCF
Example 1 (Contd..)
Round 2:-
• LE2 = (1111)2
• RE2 = LE1 ⊕ F(RE1, K2)
• RE2 = (1100)2 ⊕ F((1111)2,(1010)2)
• RE2 = (1100)2 ⊕ (1010)2
• RE2 = (0110)2
• Therefore, Round 2 Output = 0xF6.
Example 2
• Assume that Feistel Cipher uses 16 rounds. The output of the
14th Round is 0x8D; K15 = 0x7, K16 = 0xC. F(x,y) = Logical
OR of x and y. Calculate CT.
Solution:-
• LE14 = (1000)2
• RE14 = (1101)2
Example 2 (Contd..)
Round 15:-
• LE15 = RE14 = (1101)2
• RE15 = LE14 ⊕ F(RE14, K15)
• RE15 = (1000)2 ⊕ F((1101)2, (0111)2)
• RE15 = (1000)2 ⊕ (1111)2
• RE15 = (0111)2
Example 2 (Contd..)
Round 16:-
• LE16 = RE15 = (0111)2
• RE16 = LE15 ⊕ F(RE15, K16)
• RE16 = (1101)2 ⊕ F((0111)2, (1100)2)
• RE16 = (1101)2 ⊕ (1111)2
• RE16 = (0010)2
• Output of Round 16 = 0x72
• Therefore, CT = 0x27
Example 3
• Assume that Feistel Cipher uses 16 rounds. The CT is 0xAB, K16 =
0x7. The Round Function F(x,y) = bitwise XOR (1-bit right rotation of
x, 1-bit right rotation of y). What’s the output of the first round during
decryption?
Solution:-
• LD0 = (1010)2
• RD0 = (1011)2
Example 3 (Contd..)
• LD1 = RD0 = (1011)2
• RD1 = LD0 ⊕ F(RD0, K16)
• RD1 = (1010)2 ⊕ F((1011)2, (0111)2)
• RD1 = (1010)2 ⊕ ((1101)2 ⊕ (1011)2)
• RD1 = (1010)2 ⊕ (0110)2
• RD1 = (1100)2
• The primary goal is to increase diffusion for a cipher, by permuting the input
bits.
• Permutation of the bits makes the cryptanalysis more challenging.
• Types of P-Boxes: Straight P-Box, Compression P-Box, and Expansion P-
Box.
Straight P-Box
Expansion P-Box
Compression P-Box
Data Encryption
Standard (DES)
• Developed by IBM.
• Adopted as a federal standard by NIST in
1977.
• Input = 64-bit block
• Output = 64-bit block
• Original Key Length = 64 bits
DES • Effective Key Length = 56 bits
• Round Key = 48 bits
• Consists of 16 rounds.
• Each Round consists of different operations
like Substitution, Permutation, Key-Mixing,
and Expansion.
DES
Encryption
DES
Decryption
One
Round of
DES
Example 1
• PT 1 = 0x46868bd449786458
• Key 1 = 0x144573e006467894
• CT 1 = 0xae8180eb706729d3
• Key 2 = 0x144573e016467894
• CT 2 = 0xa14a01e6c590db61
Example 2
• PT 1 = 0xfedcba9876543210
• Key 1 = 0x0123456789abcdef
• CT 1 = 0x12c626af058b433b
• PT 2 = 0xfedcba9876543211
• CT 2 = 0x7b129948ca8d29d6
• Number of possible keys = 7.2057 * 1016.
• Maximum time required for a PC to execute a
successful DES decryption at 109
decryptions/second = (7.2057
*1016)/(109/second) = 7.2057*107 seconds ≈ 2
Strength of years and 3 months.
• Cryptanalysis is possible by exploiting the
DES characteristics of DES.
• DES is moderately resistant to a successful
timing attack.
Advanced Encryption Standard (AES)
• Published by NIST in 2001.
• Input Block = 128 bits
• Output Block = 128 bits
• Variants of AES:- AES-128, AES-192, and
Overview of AES-256.
AES • AES-128 (10 rounds, 128 bits key)
• AES-192 (12 rounds, 192 bits key)
• AES-256 (14 rounds, 256 bits key)
• Round Key size = 128 bits
• All the operations are performed in GF(28).
• The irreducible polynomial m(x) = x8 + x4 +
3
x + x + 1.
n
Galois Field • In GF(2 ), any polynomial can be
represented as a n-bit value.
for AES • For example, the binary value corresponding
7 6 5 4 3 2
to the polynomial x + x + x + x + x + x
1 8
+ x + 1 in GF(2 ) = (11111111)2 = 0xFF.
6 5 3 2
• x + x + x + x + x = 0x6E.
General
Structur
e of AES
Encrypti
on
CT Block (128 bits)
General
Structur Round N-1 Key
(128 bits)
Round 1 (4
Transformations
e of AES
Decrypti
………
on Round 1 Key Round N-1 ( 4
(128 bits) Transformations)
Round N (3
Round 0 Key
Transformations)
(128 bits)
General
Structur
• Output State Array:-
e of AES
AES Parameters
Structure of
AES-128
S Box
Steps to Construct S Box
1) Initialize the S Box row-wise for 16 rows and 16 columns (Row and
Column Indices are 0 to F), in ascending order.
2) Map each of the 256 values in Output of Step 1 with its multiplicative
8
inverse over GF(2 ).
• Therefore, RHS = B
Numerical 1
• If Input to S Box is 0x1D, what’s the corresponding output?
Solution:-
Step 1:-
4 3 2
0x1D = (00011101)2 = x + x + x + 1
Step 2:-
Iteration 1:-
8 4 3 4 3 2
a(x) = x + x + x + x + 1; b(x) = x + x + x + 1;
q(x) = x4 + x3 + x + 1; r(x) = x2;
v1(x) = 0; v2(x) = 1; v(x) = x4 + x3 + x + 1
Numerical 1 (Contd..)
Iteration 2:-
4 3 2 2 2
a(x) = x + x + x + 1; b(x) = x ; q(x) = x + x + 1; r(x) = 1;
v1(x) = 1; v2(x) = x4 + x3 + x + 1; v(x) = x6
Iteration 3:-
a(x) = x2; b(x) = 1; q(x) = x2; r(x) = 0;
4 3 6
v1(x) = x + x + x + 1; v2(x) = x ; v(x) = 0;
Iteration 4:-
6
a(x) = 1; b(x) = 0; v1(x) = x ; v2(x) = 0;
Numerical 1 (Contd..)
4 3 2 8 4 3 6
MI(x + x + x + 1) mod (x + x + x + x + 1) = x
Step 3:-
(b7b6b5b4b3b2b1b0) = (01000000)2
Step 4:-
Numerical 1 (Contd..)
Numerical 1 (Contd..)
•=
• Output = 0xA4
Numerical 2
• If Input to S Box is 0x7D, what’s the corresponding output?
Solution:-
Step 1:-
0x7D = (01111101)2 = (x6+x5+x4+x3+x2+1)
Step 2:-
Iteration 1:-
a(x) = x8 + x4 + x3 + x + 1; b(x) = x6 + x5 + x4 + x3 + x2 + 1; q(x) = x2 + x;
4 2 2
r(x) = x + x + 1; v1(x) = 0; v2(x) = 1; v(x) = x + x
Numerical 2 (Contd..)
Iteration 2:-
a(x) = x6 + x5 + x4 + x3 + x2 + 1; b(x) = x4 + x2 + 1; q(x) = x2 + x; r(x) = x + 1;
v1(x) = 1; v2(x) = x2 + x; v(x) = x4 + x2 + 1
Iteration 3:-
4 2 3 2
a(x) = x + x + 1; b(x) = x + 1; q(x) = x + x ; r(x) = 1;
v1(x) = x2 + x; v2(x) = x4 + x2 + 1; v(x) = x7 + x6 + x5 + x4 + x3 + x
Iteration 4:-
a(x) = x + 1; b(x) = 1; q(x) = x + 1; r(x) = 0;
v1(x) = x4 + x2 + 1; v2(x) = x7 + x6 + x5 + x4 + x3 + x; v(x) = 0
Numerical 2 (Contd..)
Iteration 5:-
7 6 5 4 3
a(x) = 1; b(x) = 0; v1(x) = x + x + x + x + x + x; v2(x) = 0
6 5 4 3 2 8 4 3 7 6 5 4 3
MI(x + x + x + x + x + 1) mod (x + x + x + x + 1) = x + x + x + x + x + x
Step 3:-
(b7b6b5b4b3b2b1b0) = (11111010)2
Step 4:-
Numerical 2 (Contd..)
Numerical 2 (Contd..)
=
• Output = 0xFF
Numerical 3
• If Input to Inverse S Box is 0xA4, what’s the corresponding output?
Solution:-
Step 1:-
(b7b6b5b4b3b2b1b0) = (10100100)2
Step 2:-
Numerical 3 (Contd..)
Numerical 3 (Contd..)
• (01000000)2 = x6
Numerical 3 (Contd..)
Step 3:-
Iteration 1:-
a(x) = x8 + x4 + x3 + x + 1; b(x) = x6; q(x) = x2; r(x) = x4 + x3 + x + 1;
v1(x) = 0; v2(x) = 1; v(x) = x2
Iteration 2:-
6 4 3 2
a(x) = x ; b(x) = x + x + x + 1; q(x) = x + x + 1; r(x) = 1;
2 4 3 2
v1(x) = 1; v2(x) = x ; v(x) = x + x + x + 1
Numerical 3 (Contd..)
Iteration 3:-
a(x) = x4 + x3 + x + 1; b(x) = 1; q(x) = x4 + x3 + x + 1; r(x) = 0;
v1(x) = x2; v2(x) = x4 + x3 + x2 + 1; v(x) = 0
Iteration 4:-
a(x) = 1; b(x) = 0; v1(x) = x4 + x3 + x2 + 1
Step 4:-
• Output = (00011101)2 = 0x1D
Numerical 4
• If Input to Inverse S Box is 0x55, what’s the corresponding output?
Solution:-
Step 1:-
(b7b6b5b4b3b2b1b0) = (01010101)2
Step 2:-
Numerical 4 (Contd..)
Numerical 4 (Contd..)
6 4
• (01010000)2 = x + x
Numerical 4 (Contd..)
Step 3:-
Iteration 1:-
a(x) = x8 + x4 + x3 + x + 1; b(x) = x6 + x4; q(x) = x2 + 1; r(x) = x3 + x + 1;
v1(x) = 0; v2(x) = 1; v(x) = x2 + 1
Iteration 2:-
6 4 3 3
a(x) = x + x ; b(x) = x + x + 1; q(x) = x + 1; r(x) = x + 1;
2 5 3 2
v1(x) = 1; v2(x) = x + 1; v(x) = x + x + x
Iteration 3:-
Numerical 4 (Contd..)
a(x) = x3 + x + 1; b(x) = x + 1; q(x) = x2 + x; r(x) = 1;
2 5 3 2 7 6 5 3 2
v1(x) = x + 1; v2(x) = x + x + x ; v(x) = x + x + x + x + x + 1
Iteration 4:-
a(x) = x + 1; b(x) = 1; q(x) = x + 1; r(x) = 0;
v1(x) = x5 + x3 + x2; v2(x) = x7 + x6 + x5 + x3 + x2 + 1; v(x) = 0
Iteration 5:-
a(x) = 1; b(x) = 0; v1(x) = x7 + x6 + x5 + x3 + x2 + 1
Step 4:-
Output = (11101101)2 = 0xED
Substitute Bytes Operation
Substitute Bytes Operation (Example 1)
• Enhances Confusion
Key
Expansion
in AES-128
g-
Function
for Key
Expansio
n in
AES-128
Round Constant for Key Expansion in AES-128
• Rcon[j] = (RC[j],0,0,0)
Solution:-
Step 1:-
w0 = 0 x 0F 15 71 C9
w1 = 0 x 47 D9 E8 59
w2 = 0 x 0C B7 AD D6
w3 = 0 x AF 7F 67 98
Numerical 5 (Contd..)
Step 2:-
x = RotWord(w3) = 0 x 7F 67 98 AF
y = SubWord(x) = 0 x D2 85 46 79
Rcon(1) = 0 x 01 00 00 00
z = y ⊕ Rcon(1) = (0 x D2 85 46 79) ⊕ (0 x 01 00 00 00)
z = 0 x D3 85 46 79
Step 3:-
w4 = w0 ⊕ z = (0 x 0F 15 71 C9) ⊕ (0 x D3 85 46 79)
w4 = 0 x DC 90 37 B0
Numerical 6
• During Key Expansion in AES-128, the output array of Round 6 is as given in
the array below. Generate the Output array of Round 7 for key expansion.
71 8C 83 CF
C7 29 E5 A5
4C 74 EF A9
C2 EF 52 EF
Numerical 6 (Contd..)
Solution:-
71 8C 83 CF
C7 29 E5 A5
4C 74 EF A9
C2 EF 52 EF
• w28 = w24 ⊕ z = 0 x 37 14 93 48
• w29 = w28 ⊕ w25 = 0 x BB 3D E7 A7
• w30 = w29 ⊕ w26 = 0 x 38 D8 08 F5
• w31 = w30 ⊕ w27 = 0 x F7 7D A1 1A
Numerical 6 (Contd..)
• Output array for 7th Round:-
37 BB 38 F7
14 3D D8 7D
93 E7 08 A1
48 F7 A5 4A
Rationale of Key Expansion in AES
• Knowledge of a part of the cipher key or round key does not enable calculation
of many other round-key bits.
• An invertible transformation
• Speed on a wide range of processors.
• Usage of round constants to eliminate symmetries.
• Impact of cipher key differences on the round keys.
• Enough nonlinearity to prohibit the full determination of round key differences
from cipher key differences only.
• Simplicity of description.
Add Round Key Transformation in AES-128
Input State Block (16 Bytes)
Solution:-
• State Array after Initial Transformation = PT ⊕ Key =
Numerical 7 (Contd..)
01 89 FE 76 0F 47 0C AF
23 AB DC 54 15 D9 B7 7F
45 CD BA 32 71 E8 AD 67
67 EF 98 10 C9 59 D6 98
0E CE F2 D9
36 72 6B 2B
34 25 17 55
AE B6 4E 88
Shift Rows Transformation in AES-128
x11 x12 x13 x14 x11 x12 x13 x14
x21 x22 x23 x24 x22 x23 x24 x21
x31 x32 x33 x34 x33 x34 x31 x32
x41 x42 x43 x44 x44 x41 x42 x43
Inverse Shift Rows Transformation in AES-128
x11 x12 x13 x14 x11 x12 x13 x14
x21 x22 x23 x24 x24 x21 x22 x23
x31 x32 x33 x34 x33 x34 x31 x32
x41 x42 x43 x44 x42 x43 x44 x41
Numerical 8
• When the array (as shown below) is the input to Shift Rows Transformation
in AES-128, what’s the output array just after the transformation?
• Enhances Diffusion
Assume that X =
Proof that Mix Column Operation is Invertible (Contd..)
*
Rationale of Mix Column
Transformation
• Enhances Diffusion
Numerical 10
• If the input to Mix Column Transformation in AES-128 is as shown in the array
below, then what’s the output of the transformation in the 1 st row 1st column?
0x87 0xF2 0x4D 0x97
0x6E 0x4C 0x90 0xEC
0x46 0xE7 0x4A 0xC3
0xA6 0x8C 0xD8 0x95
Solution:-
8 4 3
• m(x) = x + x + x + x + 1
• Output = (0x02) * (0x87) ⊕ (0x03) * (0x6E) ⊕ (0x46) ⊕ (0xA6)
Numerical 10 (Contd..)
• (0x02) * (0x87) = x * (x7 + x2 + x + 1) mod m(x)
• (0x02) * (0x87) = (x8 + x3 + x2 + x) mod m(x)
• (0x02) * (0x87) = (x4 + x2 + 1) = (00010101)2
6 5 3 2
• (0x03) * (0x6E) = (x + 1) (x + x + x + x + x) mod m(x)
7 5 4
• (0x03) * (0x6E) = (x + x + x + x) = (10110010)2
Solution:-
8 4 3
• m(x) = x + x + x + x + 1
Numerical 12 (Contd..)
• Output = (0x0E) * (0x47) ⊕ (0x0B) * (0x37) ⊕ (0x0D) * (0x94) ⊕ (0x09) *
(0xED)
3 2 6 2
• (0x0E) * (0x47) = (x + x + x) (x + x + x + 1) mod m(x)
9 8 7 5 3
• (0x0E) * (0x47) = (x + x + x + x + x + x) mod m(x)
• (0x0E) * (0x47) = (x7 + x2 + x + 1) = (10000111)2
3 5 4 2
• (0x0B) * (0x37) = (x + x + 1) * (x + x + x + x + 1) mod m(x)
8 7 6 5
• (0x0B) * (0x37) = (x + x + x + x + 1) mod m(x)
• (0x0B) * (0x37) = (x7 + x6 + x5 + x4 + x3 + x) mod m(x) = (11111010)2
Numerical 12 (Contd..)
• (0x0D) * (0x94) = (x3 + x2 + 1) (x7 + x4 + x2) mod m(x)
• (0x0D) * (0x94) = (x10 + x9 + x6 + x5 + x2) mod m(x)
• (0x0D) * (0x94) = (x5 + x4 + x3 + x2 + x) = (00111110)2
Solution:-
8 4 3
• m(x) = x + x + x + x + 1
Numerical 13 (Contd..)
• Output = (0x0E) * (0xB9) ⊕ (0x0B) * (0xE4) ⊕ (0x0D) * (0x47) ⊕ (0x09) *
(0xC5)
3 7 6 5 2
• (0x0B) * (0xE4) = (x + x + 1) * (x + x + x + x ) mod m(x)
10 9 3 2
• (0x0B) * (0xE4) = (x + x + x + x ) mod m(x)
6 4 2
• (0x0B) * (0xE4) = (x + x + x + x) mod m(x) = (01010110)2
Numerical 13 (Contd..)
• (0x0D) * (0x47) = (x3 + x2 + 1) (x6 + x2 + x + 1) mod m(x)
• (0x0D) * (0x47) = (x9 + x8 + x6 + x5 + x + 1) mod m(x)
• (0x0D) * (0x47) = (x6 + x3 + x2 + x) = (01001110)2
• The Inverse Shift Rows and Inverse Sub Bytes can be interchanged.
• The Add Round Key and Inverse Mix Columns can be interchanged.
Equivalent
Inverse
Cipher in
AES
(Contd..)
Interchanging Inverse Shift Rows and Inverse
Sub Bytes
• Inverse Shift Rows transformation affects the sequence of Bytes in State array,
without altering the Bytes contents.
• Inverse Sub Bytes affects the Bytes contents in State array, without altering the
sequence of Bytes.
• Inverse Shift Rows [Inverse Sub Bytes (Si)] = Inverse Sub Bytes [Inverse Shift
Rows (Si)]
Interchanging Add Round key and Inverse Mix
Columns
• Inverse Mix Columns (Si ⊕ Ri) = Inverse Mix Columns (Si) ⊕ Inverse Mix
Columns(Ri)
AES Implementation aspects on 8-bit Processors
• Can be implemented very efficiently on an 8-bit processor.
• (0x03)*x = (0x02)*x ⊕ x
AES Implementation aspects on 8-bit Processors
(Contd..)
• Byte Multiplication by 0x02 may be vulnerable to timing attack.
• The multiplication can be replaced by a lookup table to counter timing attack,
and to reduce the computation time.
• X2[i] = (0x02) * i
AES Implementation aspects on 32-bit
Processors
• Operations can be defined on 32-bit words.
• The 4 transformations of a round can be expressed in algebraic form:-
AES Implementation aspects on 32-bit
Processors (Contd..)
• All the expressions of the 4 transformations can be expressed as a single
equation:-
AES Implementation aspects on 32-bit
Processors (Contd..)
• Four 256-word tables:-