Module-II Block Cipher
Module-II Block Cipher
Symmetric Encrypted
Data Block
Algorithm Block
Ciphertext
Data Block
Symmetric Algorithm
• Symmetric algorithm uses only one key (a
secret key) is used to both encrypt and
decrypt the message.
GITAM GITAM
University University
Symmetric Algorithm
Shared
Key
Public
Network
Data Data
10
P10
5 5
LS-1 LS-1
P8
K1
LS-2 LS-2
5 5
P8
K2
S-DES - Two Rounds Encryption Steps
The Encryption Algorithm involves 5 Steps:
Permutation
3. The function (f )
k
IP
fk F
fk F
IP-1
8 – Bit Ciphertext
S-DES – 8 bit Encryption
8 – Bit Plaintext
IP
4 4 1101
fk F
4 4
1011 1111
0100
1101 0100
fk F
1101 1100
0001
IP-1
8 – Bit Ciphertext
S-DES – 8 bit Expansion/Permutation
F function Process:
How will get F(R,SK) = 1111?
1. Take right 4 bits of IP (1101).
2. Apply E/P rule on right 4 bits of IP.
3. XoR with sub-key K1.
4. Divide output into two equal parts (Left & Right).
5. Use substitution boxes(S-Boxes) S0 &S1 on Left &
Right.
6. The 4 bits produced by S0 and S1 undergo
permutation P4.
7. The output of P4 is the output of the function F.
S-DES – 8 bit One Round
Expansion/Permutation
Right Permuted 4 Bits
1101
E/P
11101011
10100100
K1
0100 1111
S0 S1
11 11
P4
1111
S-DES Decryption
Irrev
Rever
ersibl
sible
e
Reversible
• Reversible or nonsingular: There are 2n
possible different plaintext blocks each must
produce a unique ciphertext.
• If n = 2
Reversible Mapping
Plaintext Ciphertext
00 11
01 10
10 00
11 01
Irreversible
• A ciphertext could have been produced by one
or two plaintext blocks.
Irreversible Mapping
Plaintext Ciphertext
00 11
01 10
10 01
11 01
Confusion:
The mechanism of confusion seeks to make the
statistical relationship between the ciphertext
and key as complex as possible.
The Feistel Cipher Structure
• The input to the encryption algorithm
are a plaintext block of length 2w bits
and a key K.
• The plaintext block is divided into two
halves L0 and R0.
• The two halves of the data pass through
“n‟ rounds of processing and then
combine to produce the ciphertext
block.
• Each round “i‟ has inputs Li-1 and Ri-1,
derived from the previous round, as well
as the sub-key Ki, derived from the
overall key K.
• The sub-keys Ki are different from K and
from each other.
The Feistel Cipher Structure
The Feistel Cipher Structure
• All rounds have the same structure.
• A substitution is performed on the left half of the data
(as similar to S-DES).
• This is done by applying a round function F to the right
half of the data.
• Then taking the XOR of the output of F function and
the left half of the data.
• The round function has the same general structure for
each round but is parameterized by the round sub-key
ki.
• Following this substitution, a permutation is performed
that consists of the interchange of the two halves of
the data.
The Feistel Cipher Structure - Design
Features
• Block size - Increasing size improves security
• Key size - Increasing size improves security, makes
exhaustive key searching harder
• Number of rounds - Increasing number improves
security
• Sub-key generation - Greater complexity can make
analysis harder
• Round function - Greater complexity can make analysis
harder
• Fast software en/decryption & ease of analysis -are
more recent concerns for practical use and testing.
The Feistel Cipher Encryption & Decryption
First consider the
encryption process,
LE16 = RE15
RE16 = LE15 XoR F(RE15, K16)
Decryption Process,
LD1 = RD0 = LE16 = RE15
RD1 = LD0 XoR F(RD0, K16)
= RE16 XoR F(RE15, K16)
= LE15 XoR F(RE15, K16) XoR F(RE15, K16)
• Therefore, LD1 = RE15 and RD1 = LE15
• In general, for the ith iteration of the encryption
algorithm,
LEi = REi-1
REi = LEi-1 XoR F(REi-1, Ki) = REi XoR F(LEi, Ki)
• Finally, the output of the last round of the
decryption process is RE0 || LE0 A 32-bit swap
recovers the original plaintext.
DES History
• Most widely used block cipher in world
• Adopted in 1977 by NBS (now NIST)
– as FIPS PUB 46
• Encrypts 64-bit data using 56-bit Key
• IBM developed Lucifer cipher
– by team led by Feistel
– used 64-bit data blocks with 128-bit key
• Then redeveloped as a commercial cipher with input from
NSA and others
• In 1973 NBS issued request for proposals for a national
cipher standard
• IBM submitted their revised Lucifer which was eventually
accepted as the DES
• DES has become widely used, especially in financial
applications
DES Encryption Overview
DES Encryption
• 64 – bit Plaintext
• Initial Permutation (IP)
• 16 rounds with 16 sub-keys
• Swapping
• Inverse Initial Permutation (IP-1)
DES Rules
• Initial Permutation (IP) • Inverse Initial Permutation (IP-1)
48
f
k
F XOR Ki
48
Permutation/contraction
(permuted choice 2)
48
Substitution/
choice (S-box)
32
Permutation
(P)
32
XOR
Li Ri C D i
i
Li = Ri-1
Ri = Li-1 F(Ri-1 , Ki)
First Round (i=1) of DES Algorithm
32bits 32bits 28 bits 28 bits
L R 0 C 0 D 0
0
32
32 Expansion/ Left shift (s)
permutation (E table)
Left shift (s)
48
f
k
F XOR
48
K1 Permutation/contraction
(permuted choice 2)
48
Substitution/
choice (S-box)
32
Permutation
(P)
32
XOR
L1 R1 C D 1
1
L1 = R1-1 = R0
R1 = L1-1 F(R1-1 , K1) = L0 F(R0 , K1)
IP & IP-1
• IP(plaintext) = L(0): R(0), where L(0) and R(0) are
the left –half and the right-half of the output after
the permutation done through IP.
Expansion/Permutation:
• To get 48 bits from 32 bits of Ri
• Each input block of 4 bits contributes 2 bits to each
output block.
• E(Ri-1) Ki
Function: S-Box Permutation
Expansion
Output Sub-Key Ki
Permutation
32 bits Output
S-Boxes
Function: S-Box Permutation Functionality
Double DES
Triple DES
Double DES Encryption
64 bit Plaintext • Given a plaintext P
and two encryption
56 bits key – K1 DES Cipher
keys K1 & K2
• Generated ciphertext
X Centre Cipher
by
C = Ek2 [Ek1 [P]]
56 bits key – K2 DES Cipher
• This approach uses a
Ciphertext
key length is
56 * 2 = 112 bits.
Double DES Decryption
64 bit Ciphertext
DES
56 bits key – K2
De-Cipher
Centre
X De-Cipher
P = Dk1 [Dk2 [C]]
DES
56 bits key – K1
De-Cipher
Plaintext
Meet-in-the-middle attack
• This attack requires pair of known plaintext
and ciphertext.
• Attack works from both ends of double DES.
• Encrypt from one end and decrypt from
another end.
• Cryptanalyst analysis on X, which is center
ciphertext.
• X produces the same result, while encrypting
plaintext with K1 and decrypting ciphertext
with K2 .
Meet-in-the-middle attack
2 Keys 3 Keys
Triple DES with Two Keys
64 bit Plaintext • This approach process
Encrypt-Decrypt-Encrypt
56 bits key – K1 DES Cipher (EDE).
A C = Ek1[Dk2 [Ek1 [P]]
56 bits key – K2
DES Reverse • The Key length is 56 * 3 =
Cipher
168 bits.
B
• The drawback of this
56 bits key – K1 DES Cipher
approach is large key
length.
Ciphertext
Triple DES with Three Keys
64 bit Plaintext
Ciphertext
Modes of Operation
Modes of Operation
• Block ciphers encrypt fixed size blocks
e.g., DES encrypts 64-bit blocks
• Need some way to en/decrypt arbitrary
amounts of data in practice
• NIST SP 800-38A defines 5 modes
• Have block and stream modes
Modes of Operation
Electronic Cipher Block
Code Book Chaining (CBC)
(ECB) Mode Mode
Cipher Output
Feedback Feedback
(CFB) Mode (OFB) Mode
Counter (CTR)
Mode
Electronic Codebook Book (ECB)
• Message is broken into independent blocks that
are encrypted.
• Each block is a value which is substituted, like a
codebook.
7.95
Data units used in AES
7.96
Block-to-state and
state-to-block transformation
7.97
Changing plaintext to state
7.98
Structure of each round
at the encryption site
7.99
Overall Structure
AES TRANSFORMATIONS
Input block:
=
1 5 9 13 S1,0 S1,1 S1,2 S1,3
2 6 10 14 S2,0 S2,1 S2,2 S2,3
3 7 11 15
0 1 2 3 4 5 6 7 8 9 S10
3,0 S S3,213
113,1 12 S3,314 15
• 32 2b = 00110010 00101011
= 00011001
= 1 9 = 19
SubBytes Transformation
=
Shiftrows Transformation
=
Mix Columns Transformation
• Addition (XOR)
• (x6 + x4 + x2 + x + 1) + (x7 + x + 1) = x7 + x6 + x4 + x2
• {01010111} {10000011} = {11010100}
• {57} {83} = {d4}
Finite Field Multiplication ()
x13 + x11 + x9 + x8 + x7 + x7 + x5 + x3 + x2 + x + x6 + x4 + x2 + x +1
and
Irreducible Polynomial
Mix Column Calculation
= b 3
= b3
Mix Column Calculation - Output
=
Key Expansion in AES-128
7.113
Key Expansion submodule
• RotWord performs a one-byte circular left shift on a word For
example:
RotWord[b0,b1,b2,b3] = [b1,b2,b3,b0]