Section 03 - Classical Encryption Techniques II
Section 03 - Classical Encryption Techniques II
Section 3
1
Syllabus
Lab Lab Topics
1 Introduction
2 Classical Encryption techniques I
3 Classical Encryption techniques II
4 DES
5 block cipher operations & 3DES
6 AES
7 Quiz 1
8 Public-Key Cryptography & RSA
9 Hash functions & SHA-512
10 User Authentication (Kerberos)
11 IEEE 802.11 Wireless LAN protocol
2
Outlines:
Classical Encryption Techniques
Substitution Techniques
Hill Cipher
Polyalphabetic
Repeating key
AutoKey
One-Time
Transposition Technique
Rail fence
Columnar
Multistage Transposition
3
Hill Cipher
Mathematical Approach
Multiple letters substitution takes m successive P.T
letters and substitutes them by m C.T letters
Encryption is done by linear equation:
4
A 0
B 1
Example: F
G
5
6
5
A 0
B 1
Hill Cipher
C 2
D 3
Decryption? E 4
Solution F 5
G 6
H 7
I 8
J 9
K 10
L 11
M 12
N 13
O 14
P 15
Q 16
R 17
S 18
T 19
U 20
V 21
W 22
6
Hill Cipher - Decryption
🞂 Decryption is done by the inverse of encryption linear
equation:
7
Hill Cipher – Decryption(Cont.)
8
Hill Cipher - Decryption(Cont.)
10
11
Hill Cipher - Decryption(Cont.)
12
Hill Cipher - Decryption(Cont.)
13
Hill Cipher - Decryption
HOW to find the inverse key matrix (other method)
General rule:
14
Hill Cipher - Decryption
HOW to find the inverse key matrix K-1
15
A 0
B 1
Example: F
G
5
6
16
Hill Cipher - Decryption
First we have to find the inverse key matrix
1- Calculate det(k) mod 26
det(k) = 17(18*19-2*21)
-17(21*19-2x21)
+ 5(21*2-18*2) = -939 mod 26 = 23
18
A 0
B 1
Example: F 5
G 6
🞂 C.T = LNS HDL EWM TRW Cryptanalysis
H 7
?
🞂m = 3 I
J
8
9
🞂 K
L
10
11
M 12
N 13
Solution: O 14
P 15
Q 16
R 17
S 18
T 19
U 20
V 21
W 22
🞂 And so on …. P.T = pay….. X 23
Y 24
Z 25
19
Hill Cipher - Ctyptanalysis
🞂 High security against C.T only attack
🞂 Zero security against known P.T Attack (why !)
20
Outlines:
🞂Classical Encryption Techniques
🞂Substitution Techniques
🞂Hill Cipher
🞂Polyalphabetic
◻Repeating key
◻AutoKey
◻One-Time
🞂Transposition Technique
🞂Rail fence
🞂Columnar
🞂Multistage Transposition
21
Polyalphabetic
All of Polyalphabetic cipher versions based on using vigenere tableau
Steps:
🞂 Given a key word generate the key stream
🞂 Substitute each P. T letter with a C.T letter based on the corresponding key
letter using vigenere tableau
22
Polyalphabetic
All of Polyalphabetic cipher versions based on using vigenere tableau
23
Polyalphabetic: Vigenere with Repeating key
Example:
🞂 Keyword = hello
🞂 P.T = Computer
🞂 Key-stream =hellohel
P.T c o m p u t e r
k-stream h e l l o h e l
C.T J S X A I A I C
24
Polyalphabetic: Vigenere with Repeating key
Example:
🞂 Keyword = hello
🞂 P.T = Computer
🞂 Key-stream =hellohel
P.T c o m p u t e r
k-stream h e l l o h e l
C.T J S X A I A I C
Decryption?
25
Polyalphabetic: Vigenere with Auto-Key
Example:
🞂 Keyword = hello
🞂 P.T = Computer
🞂 Key-stream =hellocom
P.T c o m p u t e r
k-stream h e l l o h e l
C.T J S X A I A I C
26
Polyalphabetic: Vigenere with Auto-Key
Example:
🞂 Keyword = hello
🞂 P.T = Computer
🞂 Key-stream =hellocom
P.T c o m p u t e r
k-stream h e l l o c o m
C.T J S X A I V S D
Decryption?
27
Polyalphabetic: one-time-pad (Theoretical Scheme)
Example:
🞂 Keyword = key-stream = hilmotry
🞂 P.T = Computer
P.T c o m p u t e r
k-stream h e l l o h e l
C.T J S X A I A I C
28
Polyalphabetic: one-time-pad (Theoretical Scheme)
Example:
🞂 Keyword = key-stream = hilmotry
🞂 P.T = Computer
P.T c o m p u t e r
k-stream h i l m o t r y
C.T J W X B I M V P
🞂 Problems:
Decryption?
1. Key generation
2. Key distribution
29
Outlines:
🞂Classical Encryption Techniques
🞂Substitution Techniques
🞂Hill Cipher
🞂Polyalphabetic
◻Repeating key
◻AutoKey
◻One-Time
🞂Transposition Technique
🞂Rail fence
🞂Columnar
🞂Multistage Transposition
30
cryptanalys
Rail Fence is !
How
🞂 Write P.T column wise ( consider the depth ) and read it row wise
Example Example:
🞂 P.T : Computer Science 🞂 P.T : Computer Science
🞂 Key = depth = 2 🞂 Key = depth = 3
c m u e s i n e c p e c n
o p t r c e c o u r i c
m t s e e
31
Multistage !
Columnar
How
🞂 P.T row wise (consider number of columns) and read it column wise
( consider the permutation)
🞂 Key = number of columns with certain permutation = 1 3 4 2 5
Example Example
🞂 P.T : Computer Science P.T : Computer Science
🞂 Key = 1 3 4 2 5 Key = 1 4 3 2
c
c o m p u o m p
t e r s c u t e r
i e n c e s c i e
n c e x
32
A 0
B 1
Problems to be discussed
C 2
D 3
E 4
This problem explores the use of a one-time pad version of the Vigenère cipher. F 5
In this scheme, the key is a stream of random numbers between 0 and 26. G 6
H 7
For example, if the key is 3 19 5 ..., then the first letter of plaintext is encrypted with a I 8
shift of 3 letters, the second with a shift of 19 letters, the third with a shift of 5 letters, J 9
and so on. K 10
C.T W 22
? X 23
Y 24
Key Z 25
33
?
P. T c a s h n o t n e e d e d
Solution
PT s e n d m o r e m o n e y
PT 18 4 13 3 12 14 17 4 12 14 13 4 24
Key 9 0 1 7 23 15 21 14 11 11 2 8 9
CT 1 4 14 10 9 3 12 18 23 25 15 12 7
CT B E O K J D M S X Z P M H
Key 25 4 22 3 22 15 19 5 19 21 12 8 4
P. T c a s h n o t n e e d e d
34
A 0
B 1
Your turn ☺
C 2
D 3
E 4
Encrypt the following message F 5
G 6
“Advance the attack three hours” using H 7
35
Solution
Encrypt the following message
“Advance the attack three hours” using
A.) Double stage rail fence with depth 3.
a a e e t k r h r
d n t a a t e o s
v c h t c h e u x
aaeetkrhrdntaateosvchtcheux
a e r d a e v t e
a t h n a o c c u
e k r t t s h h x
aerdaevteathnaoccuekrttshhx
36
Solution
Encrypt the following message
“Advance the attack three hours” using
B.) Double stage Columnar with key 5 1 4 2 3.
5 1 4 2 3 5 1 4 2 3
a d v a n d e t t h
c e t h e x a h a r
a t t a c u x n e c
k t h r e e r x v t
e h o u r t h o x a
s x x x x c a k e s
detthxaharuxnecerxvtthoxacakes eaxrhataevxehrctasthnxokdxuetc
37
Additional Problems:
1 - Suppose plaintext “FRIDAY” encrypted using 2x2 hill cipher to yield text
“PQCFKU” Deduce and verify the key.
2- Cipher text “SDEK” is obtained by encrypting a message (M) using a playfair with
“Cryptography” as a keyword or by using Hill cipher (2x2) key. Find and verify
key. (Final 2009 – Midterm 2010)
3- Encrypt the following message
“Advance the attack three hours” using
a) Ceaser cipher with k=3.
b) Playfair key “beginning”
c) Vigenere with Auto key “Confusion”.
d) Vigenere with Repeating key “Confusion”.
e) Double stage rail fence with depth 3.
f) Double stage Columnar with key 5 1 4 2 3.
4- Decrypt cipher text generated in Question (3) using the same key and technique in
each point.
38
Package Milestone 2
Deadline: 30th October 2022
You should implement the following:
HillCipher
public List<int> Encrypt(List<int> plainText, List<int> key)
public List<int> Decrypt(List<int> cipherText, List<int> key)
public List<int> Analyse(List<int> plainText, List<int> cipherText) // 2*2
key
public List<int> Analyse3By3Key(List<int> plain3, List<int> cipher3)
In analysis, In case of invalid key throwInvalidAnlysisException
RepeatingkeyVigenere:
public string Encrypt(string plainText, int key)
public string Decrypt(string cipherText, int key)
public int Analyse(string plainText, string cipherText)
39
Package Milestone 2(Cont.)
Deadline: 30th October 2022
You should implement the following:
AutokeyVigenere
public string Encrypt(string plainText, int key)
public string Decrypt(string cipherText, int key)
public int Analyse(string plainText, string cipherText)
RailFence
public string Encrypt(string plainText, int key)
public string Decrypt(string cipherText, int key)
public int Analyse(string plainText, string cipherText)
Columnar
public string Encrypt(string plainText, List<int> key)
public string Decrypt(string cipherText, List<int> key)
public List<int> Analyse(string plainText, string cipherText)
40
41