Introduction to Cryptography Basics
Introduction to Cryptography Basics
Cryptography
Basic Definitions
Encryption & Decryption
Transmission Technique
Symmetric Cryptography
Asymmetric Cryptography
Types of Ciphers
2
Cryptography is the study of transforming a secret message in such a
way that it can be understood only by an authorized recipient who has
been provided with a secret key for deciphering it.
3
Plaintext: Data that can be read and understood without any special
measures.
Encryption: The method of hiding plaintext in such a way as to hide its
substance is called encryption.
Cipher text: Encrypting plaintext results in unreadable data called
cipher text. i.e transformed message.
Decryption: The process of returning cipher text to its original plaintext
is called decryption.
Key: some secret piece of information that customizes how the cipher
text is produced.
4
Cryptanalysis: The art of breaking ciphers, i.e. retrieving the
plaintext without knowing the proper key.
Cryptanalysts: Experts of cryptanalysis.
Cryptology: The branch of mathematics that studies the
mathematical foundations of cryptographic methods.
Cipher: The Encrypted message is called cipher.
5
6
For “secret writing”
To establish a shared secret when other people (eavesdroppers)
are listening.
TYPES
1. Symmetric key cryptography
2. Asymmetric key cryptography
7
8
bla-bla
ciphertext
msg
decoder (ciphertext in
encoder - plaintext out)
(plaintext in - bla-bla
cmb-cmb
ciphertext out)
eavesdropper
(should understand
nothing about the msg)
9
Cryptology
Cryptography Cryptanalysis
Classical Modern
cryptography cryptography
10
In classical cryptography, a transposition cipher changes
one character from the plaintext to another i.e. the order of
the characters is changed.
11
Substitution cipher is a method of encryption by which units of
plaintext are substituted with cipher text according to a regular
system or A system of enciphering that uses the method of
substitution is called substitution cipher.
12
A Stream Cipher is a symmetric or secret-key encryption algorithm
that encrypts a single bit at a time. With a Stream Cipher, the same
plaintext bit or byte will encrypt to a different bit or byte every time it is
encrypted.
In stream cipher we use different keys for enciphering successive
letters.
e.g. Binary of plain text: 010111101 (hypothetical)
Key: 100101011 Perform XOR
Cipher text: 110010110
To decrypt make the XOR operation of the cipher text with the key.
13
Block cipher technique involves encryption of one block of text at a
time .Decryption also takes one block of encrypted text at a time.
Length of the block is usually 64 or 128 bits.
e.g. :
Plain text: four and five
Four and five
Key Key Key
Cipher text: wvfa ast wvfa
14
Public key cryptography is an asymmetric scheme that uses a
Pair of keys for encryption: a Public key, which encrypts data,
and a corresponding Private key (secret key) for decryption.
15
Cryptanalysis refers to the study of ciphers, cipher text, or
cryptosystems (that is, to secret code systems) with a view to
finding weaknesses in them that will license recovery of the plain
text from the cipher text, without necessarily knowing the key or
the algorithm. This is known as breaking the cipher, cipher text, or
cryptosystem.
Unlike cryptography which is a clearly defined science,
Cryptanalysis is as much an art as it is a science.
16
Known - plain text analysis
17
It is a side channel attack which exploits sounds emitted by computers or
machines.
Modern acoustic cryptanalysis mostly focuses on sounds emitted by
computer keyboards and internal computer components
Historically it has also been applied to impact printers and
electromechanical cipher machines.
18
It is a side channel attack which exploits sounds emitted by computers or
machines.
Modern acoustic cryptanalysis mostly focuses on sounds emitted by
computer keyboards and internal computer components
Historically it has also been applied to impact printers and
electromechanical cipher machines.
19
Use rubber keyboard or virtual keyboards to prevent keystroke
sounds.
Use acoustic printers.
Use Acoustic case for CPU.
20
Cryptography, being an art of encrypting and decrypting confidential
information and private messages, should be implemented in the network
security to prevent any leakage and threat.
It can be done by using any of these techniques discussed above for
fortifying the personal data transmission as well as for secure transaction.
Acoustic cryptanalysis, being an art of decrypting or leaking
confidential information from the sound generated from the CPU,
Keyboard, printers, etc may be used in both constructive as well as
destructive ways.
21
Books
22
Presented By : Shibani Sarangi
IT Branch, Regd no. 1001289324
Guided By : Prof. X
1
If we shift each letter forwarded by k places around
the circle, the resulting permutation of the alphabet
is called cyclic shift of length k. Enciphering done by
using cyclic shift is called shift cipher or Caesar
cipher. The actual cipher used by Caesar was a cyclic
shift with k=3. In this case the letter A shifts to D and
B shifts to E and so on. For example,
ABCDEFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMNOPQRSTUVWXYZABC
2
For example if k=3 we get key of shift cipher
ABCDEFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMNOPQRSTUVWXYZABC
Plain Text : ATTACK IS IMMINENT
Using above key we get cipher text is
Cipher Text: DWWDFNLVLPPLQHQW
Using above decipher the following
Cipher Text: SURFHHGWRURPH
Plain Text: PROCEED TO ROME
3
The Vigenère cipher is a method of encrypting
alphabetic text by using a series of linked
Caesar ciphers based on the letters of a keyword.
It is periodic substitution cipher composed of shift
cipher. In this cipher we use key as a key word for
example key word : PARIS
ABCDEFGHIJKLMNOPQRSTUVWXYZ
PQRSTUVWXYZABCDEFGHIJKLMNO
ABCDEFGHIJKLMNOPQRSTUVWXYZ
RSTUVWXYZABCDEFGHIJKLMNOPQ
I JKLMNOPQRSTUVWXYZABCDEFGH
STUVWXYZABCDEFGHIJKLMNOPQR 4
Example: Using the Vigenere cipher with the key word
PARIS
(a) Encipher the plain text: SEND MORE MONEY
(b) Decipher the cipher text: XADKCBPCMLTLPJJDKV
Solution: Here key word is PARIS so k=5 we make block
of 5 words and apply the keyword PARIS.
(a) Plain Text : SENDM OREMO NEY
Cipher Text: HEELE DRVUG CEP
so HEELEDRVUGCEP is required cipher text
(b) Cipher Text : XADKC BPCML TLPJJ DKV
9
SOLUTION:
(a) Since (7,26)=1
Plain Text : A L G E B R A
x : 1 12 7 5 2 18 1
7x+4 : 11 88 53 39 18 130 11
(7x+4 )mod 26 : 11 10 1 13 18 0 11
Cipher Text : K J A M R Z K
13
Choose a, b , 𝑥0 be any elements of ℤ𝑛 with gcd(a,n)=1
Let 𝑥𝑖 ∈ ℤ𝑛 represent ith letter in the plain text message.
We Encipher 𝑥𝑖 by using the affine mapping
𝜎𝑖 : ℤ𝑛 → ℤ𝑛 given by
𝜎𝑖 (x)=ax +b𝑥𝑖−1 , i=1,2,3,….
𝜎𝑖 (𝑥𝑖 )=a 𝑥𝑖 +b𝑥𝑖−1 i=1,2,3,…..
This type of stream cipher is known as Text-induced .
14
Example : Use the Text-induced stream affine cipher
𝜎𝑖 (x)=(5x +9𝑥𝑖−1 ) mod 26 , i=1,2,3,… With 𝑥0 =1 to Encipher HAPINESS Decipher ZLQRCP
SOLUTION: a)
Plain Text : H A P P I N E S S
𝑖 : 1 2 3 4 5 6 7 8 9
𝑥𝑖 : 8 1 16 16 9 14 5 19 19
(5 𝑥𝑖 +9 𝑥𝑖−1 )mod26: 23 25 11 16 7 21 21 10 6
Cipher Text : W Y K P G U U J F
16
Ω𝑟 → (ℤ𝑛 )𝑟 → ℤ𝑛𝑟 → ℤ𝑛𝑟 → (ℤ𝑛 )𝑟 → Ω𝑟
If the mapping for Affine cipher is 𝜎 ∶ ℤ𝑛𝑟 → ℤ𝑛𝑟 then the total
number of keys for this cipher is 𝑛𝑟 𝜙(𝑛𝑟 ).
If n=26 and r=2 then the possible total number of keys are
262 ϕ(262 )
= 262 ϕ(132 , 22 )
=676(156× 2)
=210910
So There are 210910 possible keys for affine cipher for r=2 and
n=26.
17
Example: Use the blocks of two letters and the affine
cipher 𝜎(𝑥) = (35𝑥 + 120)mod676
a) Encipher HELLO b) Decipher IUOZDG
Solution: a) We break the message into blocks of two
letters and adding an extra letter Z at the end to
complete block.
Plain Text : HE LL OZ
𝑥1 , 𝑥2 : 8,5 12,12 15,0
𝑥 = 26𝑥1 + 𝑥2 : 213 324 130
𝑦 = (35𝑥 + 120)mod676: 139 644 614
𝑦1 , 𝑦2 : 5,9 24,20 23,16
Cipher Text: EI XT WP
Hence we get cipher text is EIXTWP Corresponding
to HELLO
18
b) If 𝑦 = 35𝑥 + 120 𝑚𝑜𝑑676
𝑡ℎ𝑒𝑛 𝑥 = 35−1 𝑦 − 120 𝑚𝑜𝑑676
This implies that 𝑦 = 367𝑦 + 576 𝑚𝑜𝑑676
Cipher Text: IU OZ DG
𝒚𝟏 , 𝒚𝟐 : 9,21 15,0 4,7
y=26𝒚𝟏 +𝒚𝟐 : 255 390 111
x= 𝟑𝟔𝟕𝒚 + 𝟓𝟕𝟔 𝒎𝒐𝒅𝟔𝟕𝟔 197 394 77
𝒙𝟏 , 𝒙𝟐 : 7,15 15,4 2,25
Plain Text : GO OD BY
Hence we get plain text is GOODBY corresponding to
Cipher text IUOZDG
19
Presented By : Shibani Sarangi
IT Branch, Regd no. 1001289324
Guided By : Prof. X
1
Choose a, b , 𝑥0 be any elements of ℤ𝑛 with gcd(a,n)=1
Let 𝑥𝑖 ∈ ℤ𝑛 represent ith letter in the plain text message.
We Encipher 𝑥𝑖 by using the affine mapping
𝜎𝑖 : ℤ𝑛 → ℤ𝑛 given by
𝜎𝑖 (x)=ax +b𝑥𝑖−1 , i=1,2,3,….
𝜎𝑖 (𝑥𝑖 )=a 𝑥𝑖 +b𝑥𝑖−1 i=1,2,3,…..
This type of stream cipher is known as Text-induced .
2
Example : Use the Text-induced stream affine cipher
𝜎𝑖 (x)=(5x +9𝑥𝑖−1 ) mod 26 , i=1,2,3,… With 𝑥0 =1 to Encipher HAPINESS Decipher ZLQRCP
SOLUTION: a)
Plain Text : H A P P I N E S S
𝑖 : 1 2 3 4 5 6 7 8 9
𝑥𝑖 : 8 1 16 16 9 14 5 19 19
(5 𝑥𝑖 +9 𝑥𝑖−1 )mod26: 23 25 11 16 7 21 21 10 6
Cipher Text : W Y K P G U U J F
4
Ω𝑟 → (ℤ𝑛 )𝑟 → ℤ𝑛𝑟 → ℤ𝑛𝑟 → (ℤ𝑛 )𝑟 → Ω𝑟
If the mapping for Affine cipher is 𝜎 ∶ ℤ𝑛𝑟 → ℤ𝑛𝑟 then the total
number of keys for this cipher is 𝑛𝑟 𝜙(𝑛𝑟 ).
If n=26 and r=2 then the possible total number of keys are
262 ϕ(262 )
= 262 ϕ(132 , 22 )
=676(156× 2)
=210910
So There are 210910 possible keys for affine cipher for r=2 and
n=26.
5
Example: Use the blocks of two letters and the affine
cipher 𝜎(𝑥) = (35𝑥 + 120)mod676
a) Encipher HELLO b) Decipher IUOZDG
Solution: a) We break the message into blocks of two
letters and adding an extra letter Z at the end to
complete block.
Plain Text : HE LL OZ
𝑥1 , 𝑥2 : 8,5 12,12 15,0
𝑥 = 26𝑥1 + 𝑥2 : 213 324 130
𝑦 = (35𝑥 + 120)mod676: 139 644 614
𝑦1 , 𝑦2 : 5,9 24,20 23,16
Cipher Text: EI XT WP
Hence we get cipher text is EIXTWP Corresponding
to HELLO
6
b) If 𝑦 = 35𝑥 + 120 𝑚𝑜𝑑676
𝑡ℎ𝑒𝑛 𝑥 = 35−1 𝑦 − 120 𝑚𝑜𝑑676
This implies that 𝑦 = 367𝑦 + 576 𝑚𝑜𝑑676
Cipher Text: IU OZ DG
𝒚𝟏 , 𝒚𝟐 : 9,21 15,0 4,7
y=26𝒚𝟏 +𝒚𝟐 : 255 390 111
x= 𝟑𝟔𝟕𝒚 + 𝟓𝟕𝟔 𝒎𝒐𝒅𝟔𝟕𝟔 197 394 77
𝒙𝟏 , 𝒙𝟐 : 7,15 15,4 2,25
Plain Text : GO OD BY
Hence we get plain text is GOODBY corresponding to
Cipher text IUOZDG
7
ℤ𝑝 [𝑥]
≈ 𝐺𝐹 𝑝, 𝑟 = 𝐺𝐹(𝑝𝑟 )=ℱ𝑝𝑟
<𝑓 𝑥 >
Where f(x) is monic irreducible polynomial of degree r
over ℤ𝑝
ℱ𝑝𝑟 =൛𝑎1 𝑡 𝑟−1 + 𝑎2 𝑡 𝑟−2 + 𝑎3 𝑡 𝑟−3 + ⋯ + 𝑎𝑟−1 𝑡 + 𝑎𝑟 ∶
𝑎1 , 𝑎2 , 𝑎3 , … 𝑎𝑟 ∈ ℤ𝑝 ൟ
Where f(t)= 𝑡 𝑟 + 𝑐1 𝑡 𝑟−1 + 𝑐2 𝑡 𝑟−2 + ⋯ + 𝑐𝑟 =0
t is known as primitive element and ℱ𝑝𝑟 is Galois field
extension of the prime field ℤ𝑝 . Moreover ℱ𝑝𝑟 is vector
space over ℤ𝑝 with dimension r. However
(ℱ𝑝𝑟 )∗ = ℱ𝑝𝑟 − 0 Is multiplicative cyclic group of
order 𝑝𝑟 − 1 and t is its generator with order 𝑝𝑟 − 1 .
8
9
Galois Field
power form n-tuple form polynomial form
0 0000 0
0100
2 0010 2
3 0001 3
Table of Galois Field which is 4 1100 1
generated by primitive 5 0110 2
element ξ . 6 0011 2 3
ℤ𝑝 [𝑥] 7 1101 1 3
≈ 𝐺𝐹 𝑝, 𝑟 = 𝐺𝐹(𝑝𝑟 )=ℱ𝑝𝑟 8 1010 1 2
<𝑓 𝑥 >
Where f(x) is monic irreducible 9 0101 3
polynomial of degree r over ℤ𝑝 10 1110 1 2
11 0111 2 3
12 1111 1 2 3
13 1011 1 2 3
14 1001 10 1 3
15 1 1
Department of Mathematics
Ω → ℤ𝑝𝑟 → ℱ𝑝𝑟 → ℱ𝑝𝑟 → ℤ𝑝𝑟 → Ω
Here Ω is set of Alphabet of n order.
If we take n=27
𝑓 𝑥 = 𝑥 3 +2x+1 is monic irreducible over ℤ3
ℱ33 = ℱ27 ={𝑎𝑡 2 +bt+c : a, b, c∈ ℤ3 }
Where t satisfies the relation 𝑡 3 + 2𝑡 + 1 = 0,
𝑡 3 = −2𝑡 − 1
𝑡3 = 𝑡 + 2
By taking successive powers of t we can find the order of t is 26.
Thus t is primitive element and therefore every non zero element
in Field ℱ27 Is the power of t.
Now we make the table which shows that for each character in Ω
its numerical value in ℤ27 , the corresponding element in ℱ27 and
its expression as a power of t
11
Ω ℤ𝑝𝑟 ℱ𝑝 𝑟 ℱ𝑝 𝑟 Ω ℤ𝑝𝑟 ℱ𝑝𝑟 ℱ𝑝 𝑟
A 1 1 t0 N 14 t 2 +t+2 t11
B 2 2 t13 O 15 t 2 +2t t4
C 3 t t1 P 16 t 2 +2t+1 t18
D 4 t+1 t9 Q 17 t 2 +2t+2 t7
E 5 t+2 t3 R 18 2t 2 t15
F 6 2t t14 S 19 2t 2 +1 t 25
G 7 2t+1 t16 T 20 2t 2 +2 t8
H 8 2t+2 t 22 U 21 2t 2 +t t17
I 9 t2 t2 V 22 2t 2 +t+1 t 20
J 10 t 2 +1 t 21 W 23 2t 2 +𝑡 + 2 t5
K 11 t 2 +2 t12 X 24 2t 2 +2t t 23
L 12 t 2 +t t10 Y 25 2t 2 +2t+1 t 24
M 13 t 2 +t+1 t6 Z 26 2t 2 +2𝑡 + 2 t19
SPACE 0 0 0
12
Use the representation table of the alphabet by ℱ27 describe in
previous slide and the affine cipher 𝜎: ℱ27 → ℱ27 given by
𝜎 𝑢 = 𝑡 + 1 𝑢 + 𝑡2 + 2
(a) Encipher FIELD (b) Decipher FVC A
SOLUTION: (a)
We write for each letter in the plain text its representation 𝑢 ∈ ℱ27
and find
𝜎 𝑢 = 𝑡 + 1 𝑢 + 𝑡 2 + 2. The table shows the work
Plain Text: F I E L D
𝑢 ∈ ℱ27 : 2t 𝑡2 t+2 𝑡 2 +t t+1
𝜎 𝑢 : 2t+2 2𝑡 2 +t+1 2𝑡 2 +1 2t+1 2𝑡 2 +2t
Cipher text: H V S G X
13
(b) Decipher FVC A
SOLUTION: (b)
From the table we find that 𝑡 + 1 = 𝑡 9 , Hence the inverse of
𝑡 + 1 is 2𝑡 2 +t . Because (𝑡 + 1)−1 = (𝑡 9 )−1 = 𝑡 17 = 2𝑡 2 +t
Thus the inverse mapping 𝜎 −1 is given by
𝜎 −1 𝑣 = 2𝑡 2 + t v − 𝑡 2 + 2 = 2𝑡 2 + t v + 2t + 1
The table shows the work
Cipher Text: F V C SPACE D
V∈ ℱ27 : 2t 2𝑡 2 +𝑡 + 1 t 0 1
𝜎 −1 𝑣 : 2𝑡 2 𝑡2 𝑡 2 + 𝑡 + 2 2t+1 2𝑡 2 +1
Plain Text: R I N G S
14
Q1: Use the Text induced stream affine cipher with 𝑥0 =5
and 𝜎𝑖 (x)=(7𝑥 + 4𝑥𝑖−1 )mod26
(a)Encipher ABSTRACT (b) Decipher AJSKHDA
Guided By : Prof. X
1
•Invented by Lester. S. Hill in 1929.
•Inputs : String of English letters, A,B,…,Z.
An rr matrix B, with entries drawn from
0,1,…,25.
(The matrix B serves as the secret key. )
•Divide the input string into blocks of size r.
•Identify A=0, B=1, C=2, …, Z=25.
•Encryption: Multiply each block by B and then
reduce mod 26.
•Decryption: multiply each block by the inverse of
B, and reduce mod 26.
2
Let n be the number of characters in plain text alphabet
Ω, and let 𝑟 ∈ ℤ+ and 𝑟 > 1
𝜌: Ω𝑟 → (ℤ𝑛 )𝑟 is defined by
𝜌(𝒂𝟏 , 𝒂𝟐 , 𝒂𝟑 , … , 𝒂𝒓 ) = (𝜌 𝒂𝟏 , 𝜌 𝒂𝟐 , 𝜌 𝒂𝟑 , … , 𝜌 𝒂𝒓 )
is the extension of 𝜌: Ω → ℤ𝑛 .
𝑥1
𝑥2
(ℤ𝑛 )𝑟 = , 𝑥1 , 𝑥2 , … , 𝑥𝑟 ∈ ℤ𝑛
⋮
𝑥𝑟
𝒙𝟏𝟏 … 𝒙𝟏𝒓
⋮ ⋱ ⋮
(ℤ𝑛 )𝑟∗𝑟 = { 𝒙𝒓𝟏 ⋯ 𝒙𝒓𝒓 : 𝑥ij ∈ ℤ𝑛 1 ≤ 𝑖, 𝑗 ≤ 𝑟}
3
➢ An square matrix B over ℤ𝑛 is invertible if and only if det 𝐵 is
relatively prime to n.
𝝈−𝟏 𝒀 = 𝑩−𝟏 (𝒀 − 𝑫)
4
Use the Hill Cipher with n=26, r=2 given by
𝑥1 8 5 𝑥1 7
𝜎 𝑥 = + (mod 26)
2 5 6 𝑥2 9
a) Encipher MOUNTAIN
b) Decipher AJGLLRKE
SOLUTION:
8 5
a) First we Calculate the det B =det =23 and gcd(23,26)=1
5 6
This implies that B is invertible.
For Encipher , we divide the plain text message into blocks of two letters ,
represent each block by column of numbers given by the mapping and
apply the mapping 𝝈.
Plain Text : MO UN TA IN
𝑥1 13 21 20 9
𝑥2 :
15 14 01 14
𝑥1 4 11 16 19
𝜎 𝑥 :
2 8 16 11 8
Cipher Text: DH KP PK SH
5
Decipher AJGLLRKE
SOLUTION:
8 5
First we Calculate the det B =det =23 and gcd(23,26)=1
5 6
This implies that B is invertible.
For Decipher , we calculate inverse of B for this first calculate the (det
24 19
B)−1 =23−1 = 17 𝑜𝑣𝑒𝑟 𝑚𝑜𝑑 26 . Hence 𝐵−1 = 17 6 −5 𝑚𝑜𝑑26 = .
−5 8 19 6
𝑦1 24 19 𝑦1 7
To Decipher we use the mapping 𝝈−𝟏 𝑦 = 𝑦2 − mod 26 =
2 19 6 9
−𝟏
𝑦1 24 19 𝑦1 25
𝝈 𝑦2 = +
19 6 𝑦2 21
Cipher Text : AJ GL LR KE
𝑦1 1 7 12 11
𝑦2 :
10 12 18 5
−𝟏
𝑦1 5 5 5 20
𝝈 𝑦2 : 22 18 19 0
Plain Text: EV ER ES TZ
6
Select 𝑟 × 𝑟 matrices B, C over ℤ𝑛 when B is invertible
and fix 𝑋0 ∈ (ℤ𝑛 )𝑟 .
Let 𝑋𝑖 ∈ (ℤ𝑛 )𝑟 represent the ith block of r letters in the
plain text . We define the mapping 𝝈𝑖 : (ℤ𝑛 )𝑟 → (ℤ𝑛 )𝑟
by
𝝈𝑖 𝑋 = 𝐵𝑋 + 𝐶𝑿𝑖−1 ∀ 𝑋 ∈ (ℤ𝑛 )𝑟
The ith block 𝑋𝑖 is enciphered by using the Hill Cipher
𝝈𝑖 .
7
An Other Example
Message to encrypt
HELLOWORLD
HELLO WORLD has been encrypted to
SLHZY ATGZT
Change message into 2 x 1 letter vectors
Change each vector into 2 x 1 numeric
vectors
Multiply each numeric vector by decryption
matrix
Convert new vectors to letters
Message to Decrypt
SLHZYATGZT
SLHZYATGZT has been decrypted to
HELLO WORLD
Creating valid encryption/decryption
matrices is the most difficult part of Hill
Ciphers.
Otherwise, Hill Ciphers use simple linear
algebra and modular arithmetic
7 3
Q1: Use the Hill Cipher 𝜎 X = BX + D with B=
8 7
4
D= , Over ℤ26 .
5
a) Encipher HAPPY
b) Decipher JHFK
Q2: Use the Hill Cipher 𝜎 X = BX + D with
17 23 4 4
B= 17 12 7 , D= 5 Over ℤ26 . TO
11 15 25 9
a) Encipher LINEAR
b) Decipher RYLWMYGOA
18
Q3:
𝑎 𝑏
a) Show that a square matrix B= over Over ℤ𝑛 ,
𝑐 𝑑
with det B=-1, is involutory if and only a+d=0.
19
DATA ENCRYPTION STANDARD
(DES)
[Link] Asif
Department of Mathematics
University of Management and Technology Sialkot
History
Row Column
Use the Row and Column number to find the corresponding output
number from the S-box.
Besides, the n-th block must use the n-th S-box.
S-Box 1: Substitution Box 1
Row / Column 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
1 0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
2 4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0
3 15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13
Row / Column 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 15 1 8 14 6 11 3 4 9 7 2 13 12 0 5 10
1 3 13 4 7 15 2 8 14 12 0 1 10 6 9 11 5
2 0 14 7 11 10 4 13 1 5 8 12 6 9 3 2 15
3 13 8 10 1 3 15 4 2 11 6 7 12 0 5 14 9
S-Box 3: Substitution Box 3
Row / Column 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 10 0 9 14 6 3 15 5 1 13 12 7 11 4 2 8
1 13 7 0 9 3 4 6 10 2 8 5 14 12 11 15 1
2 13 6 4 9 8 15 3 0 11 1 2 12 5 10 14 7
3 1 10 13 0 6 9 8 7 4 15 14 3 11 5 2 12
1 15 23 26 5 18 31 10
2 8 24 14 32 27 3 9
9 13 30 6 22 11 4 25
Final Permutation
◼ IP-1
40 8 48 16 56 24 64 32
39 7 47 15 55 23 63 31
38 6 46 14 54 22 62 30
37 5 45 13 53 21 61 29
36 4 44 12 52 20 60 28
35 3 43 11 51 19 59 27
34 2 42 10 50 18 58 26
33 1 41 9 49 17 57 25
Key Schedule Algorithm
Input Key
C0 D0
▪ ▪
▪ ▪
▪ ▪
Ci-1 Di-1
Permuted Choice Two (PC-2)
Round 1 2 3 4 5 6 7 8
Iterations 1 1 2 2 2 2 2 2
Round 9 10 11 12 13 14 15 16
Iterations 1 2 2 2 2 2 2 1
PERMUTED CHOICE 2 (PC-2)
14 17 11 24 1 5
3 28 15 6 21 10
23 19 12 4 26 8
16 7 27 20 13 2
41 52 31 37 47 55
30 40 51 45 33 48
44 49 39 56 34 53
46 42 50 36 29 32
Decryption
◼ The same algorithm as
encryption.
◼ Reversed the order of key
(Key16, Key15, … Key1).
◼ For example:
IP undoes IP-1 step of
encryption.
1st round with SK16
undoes 16th encrypt round.
[1]
Strength of DES
◼ Criticism
Reduction in key size of 72 bits
◼ Too short to withstand with brute-force attack
T h a t s m y K u n g F u
54 68 61 74 73 20 6D 79 20 4B 75 6E 67 20 46 75
Tw o O n e N i n e Tw o
54 77 6F 20 4F 6E 65 20 4E 69 6E 65 20 54 77 6F
1
AES Example - The first Roundkey
• Key in Hex (128 bits): 54 68 61 74 73 20 6D 79 20 4B 75 6E 67 20 46 75
• w[0] = (54, 68, 61, 74), w[1] = (73, 20, 6D, 79), w[2] = (20, 4B, 75, 6E), w[3] = (67, 20, 46, 75)
• g(w[3]):
• circular byte left shift of w[3]: (20, 46, 75, 67)
• Byte Substitution (S-Box): (B7, 5A, 9D, 85)
• Adding round constant (01, 00, 00, 00) gives: g(w[3]) = (B6, 5A, 9D, 85)
2
AES Example - All RoundKeys
• Round 0: 54 68 61 74 73 20 6D 79 20 4B 75 6E 67 20 46 75
• Round 1: E2 32 FC F1 91 12 91 88 B1 59 E4 E6 D6 79 A2 93
• Round 2: 56 08 20 07 C7 1A B1 8F 76 43 55 69 A0 3A F7 FA
• Round 3: D2 60 0D E7 15 7A BC 68 63 39 E9 01 C3 03 1E FB
• Round 4: A1 12 02 C9 B4 68 BE A1 D7 51 57 A0 14 52 49 5B
• Round 5: B1 29 3B 33 05 41 85 92 D2 10 D2 32 C6 42 9B 69
• Round 6: BD 3D C2 B7 B8 7C 47 15 6A 6C 95 27 AC 2E 0E 4E
• Round 7: CC 96 ED 16 74 EA AA 03 1E 86 3F 24 B2 A8 31 6A
• Round 8: 8E 51 EF 21 FA BB 45 22 E4 3D 7A 06 56 95 4B 6C
• Round 9: BF E2 BF 90 45 59 FA B2 A1 64 80 B4 F7 F1 CB D8
• Round 10: 28 FD DE F8 6D A4 24 4A CC C0 A4 FE 3B 31 6F 26
3
AES Example - Add Roundkey, Round 0
• State Matrix and Roundkey No.0 Matrix:
54 4F 4E 20 54 73 20 67
77 6E 69 54 68 20 4B 20
6F 65 6E 77 61 6D 75 46
20 20 65 6F 74 79 6E 75
• XOR the corresponding entries, e.g., 69 ⊕ 4B = 22
0110 1001
0100 1011
0010 0010
• the new State Matrix is
00 3C 6E 47
1F 4E 22 74
0E 08 1B 31
54 59 0B 1A
4
AES Example - Round 1, Substitution Bytes
• current State Matrix is
00 3C 6E 47
1F 4E 22 74
0E 08 1B 31
54 59 0B 1A
• substitute each entry (byte) of current state matrix by corresponding entry in AES
S-Box
• for instance: byte 6E is substituted by entry of S-Box in row 6 and column E, i.e.,
by 9F
• this leads to new State Matrix
63 EB 9F A0
C0 2F 93 92
AB 30 AF C7
20 CB 2B A2
• this non-linear layer is for resistance to differential and linear cryptanalysis attacks
5
AES Example - Round 1, Shift Row
6
AES Example - Round 1, Mix Column
03 01 01 02 A2 20 CB 2B 7A 32 0E 5D
• entry BA is result of (02 • 63) ⊕ (03 • 2F ) ⊕ (01 • AF ) ⊕ (01 • A2):
• 02 • 63 = 00000010 • 01100011 = 11000110
• 03 • 2F = (02 • 2F ) ⊕ 2F = (00000010 • 00101111) ⊕ 00101111 = 01110001
• 01 • AF = AF = 10101111 and 01 • A2 = A2 = 10100010
• hence
11000110
01110001
10101111
10100010
10111010
7
AES Example - Add Roundkey, Round 1
8
AES Example - Round 2
6A 59 CB BD 6A 59 CB BD
A0 4E 48 12 4E 48 12 A0
30 9C 98 9E 98 9E 30 9B
3D F 4 9B 8B 8B 3D F 4 9B
15 C9 7F 9D 43 0E 09 3D
CE 4D 4B C2 C6 57 08 F 8
89 71 BE 88 A9 C0 EB 7F
65 47 97 CD 62 C8 F E 37
9
AES Example - Round 3
1A AB 01 27 1A AB 01 27
B4 5B 30 41 5B 30 41 B4
D3 BA E9 D2 E9 D2 D3 BA
AA E8 BB 9A A9 AA E8 BB
AA 65 F A 88 78 70 99 4B
16 0C 05 3A 76 76 3C 39
3D C1 DE 2A 30 7D 37 34
B3 4B 5A 0A 54 23 5B F 1
10
AES Example - Round 4
BC 51 EE B3 BC 51 EE B3
38 38 EB 12 38 EB 12 38
04 F F 9A 18 9A 18 04 F F
20 26 39 A1 A1 20 26 39
10 BC D3 F 3 B1 08 04 E7
D8 94 E0 E0 CA F C B1 B2
53 EA 9E 25 51 54 C9 6C
24 40 73 7B ED E1 D3 20
11
AES Example - Round 5
C8 30 F 2 94 C8 30 F 2 94
74 B0 C8 37 B0 C8 37 74
D1 20 DD 50 DD 50 D1 20
55 F 8 66 B7 B7 55 F 8 66
2A 26 8F E9 9B 23 5D 2F
78 1E 0C 7A 51 5F 1C 38
1B A7 6F 0A 20 22 BD 91
5B 62 00 3F 68 F 0 32 56
12
AES Example - Round 6
14 26 4C 15 14 26 4C 15
D1 CF 9C 07 CF 9C 07 D1
B7 93 7A 81 7A 81 B7 93
45 8C 23 B1 B1 45 8C 23
A9 37 AA F 2 14 8F C0 5E
AE D8 0C 21 93 A4 60 0F
E7 6C B1 9C 25 2B 24 92
F 0 F D 67 3B 77 E8 40 75
13
AES Example - Round 7
F A 73 BA 58 F A 73 BA 58
DC 49 D0 76 49 D0 76 DC
3F F 1 36 4F 36 4F 3F F 1
F 5 9B 09 9D 9D F 5 9B 09
9F 37 51 37 53 43 4F 85
AF EC 8C F A 39 06 0A 52
63 39 04 66 8E 93 3B 57
4B F B B1 D7 5D F 8 95 BD
14
AES Example - Round 8
ED 1A 84 97 ED 1A 84 97
12 6F 67 00 6F 67 00 12
19 DC E2 5B E2 5B 19 DC
4C 41 2A 7A 7A 4C 41 2A
E8 8A 4B F 5 66 70 AF A3
74 75 EE E6 25 CE D3 73
D3 1F 75 58 3C 5A 0F 13
55 8A 0C 38 74 A8 0A 54
15
AES Example - Round 9
33 51 79 0A 33 51 79 0A
3F 8B 66 8F 8B 66 8F 3F
EB BE 76 7D 76 7D EB BE
92 C2 67 20 20 92 C2 67
B6 E7 51 8C 09 A2 F 0 7B
84 88 98 CA 66 D1 F C 3B
34 60 66 F B 8B 9A E6 30
E8 D7 70 51 78 65 C4 89
16
AES Example - Round 10
17