Classical Encryption Techniques
Classical Encryption Techniques
• Alice:- C = Ek(P)
• How PT is processed
CRYPTANALYSIS
Cryptanalysis Techniques on Encrypted Data
CT:-
• The letter ‘e’ is the most frequently used English alphabet for plaintext.
• Hence, for the above CT, the attacker makes a best case guess that most
probably the ciphertext character ‘w’ maps to the plaintext character ‘e’.
Statistical Attack (Contd..)
Pattern Attack
Ciphertext Only Attack
Known Plaintext Attack
Chosen Plaintext Attack
Chosen Ciphertext Attack
HIERARCHY OF CLASSICAL CIPHERS
Classical Ciphers
Substitution Transposition
Additive Columnar
Cipher Hill
Permutation
Multiplicative Vernam
Vigenere
Cipher
Route
Affine Cipher Playfair
Default Numerical Values
Encrypt the message “manipal” using key = 13, and additive cipher in Z26. Assume
that the alphabets are case-insensitive and use the default numerical equivalents.
Solution:-
m a n i p a l
12 0 13 8 15 0 11
25 13 0 21 2 13 24
z n a v c n y
Decrypt the message “znavcny” using key = 13, and additive cipher in Z26. Assume
that the alphabets are case-insensitive and use the default numerical equivalents.
Solution:-
z n a v c n y
25 13 0 21 2 13 24
12 0 13 8 15 0 11
m a n i p a l
Assume that Additive cipher is used with some special characters with their corresponding
numerical equivalents as displayed in the table below. Assume that the alphabets which are
used are case-insensitive and use the default numerical equivalents. Decrypt the ciphertext
“>d@$d>>h$d@w” using key = 23.
Special Characters Numerical Equivalents
? 26
> 27
< 28
@ 29
# 30
$ 31
! 32
Example 3 (Solution)
Encrypt the message “software” using key = 500, and additive cipher
using digrams. Assume that the alphabets are case-insensitive and use
the default numerical equivalents.
Solution:-
so ft wa re
lu yz pg kk
Decrypt the message “luyzpgkk” using key = 500, and additive cipher
using digrams. Assume that the alphabets are case-insensitive and use
the default numerical equivalents.
Solution:-
lu yz pg kk
so ft wa re
• d = (c-3) mod 26
Solution:-
e n 4 13
g i 6 8
• P= =
n e 13 4
e r 4 17
7 11 𝐡 𝐥
2 4 𝐜 𝐞
• C= =
25 10 𝐳 𝐤
19 21 𝐭 𝐯
Solution:-
• det(K) = 27
h l 7 11
c e 2 4
• C= =
z k 25 10
t v 19 21
Example 2 (Contd..)
-1 9 −6 -1
• K = * 27 (mod 26)
−3 5
q a b r u1 u2 u
1 27 26 1 1 0 1
26 26 1 0 0 1 -26
1 0 1 -26
9 −6 9 20
• K-1 = * 1 (mod 26) =
−3 5 23 5
Example 2 (Contd..)
7 11
2 4 9 20
• D = C*K-1 (mod 26) = * (mod 26)
25 10 23 5
19 21
316 195 4 13 𝐞 𝐧
110 60 6 8 𝐠 𝐢
• D= (mod 26) = =
455 550 13 4 𝐧 𝐞
654 485 4 17 𝐞 𝐫
Solution:-
𝑟 𝑟 𝑙 17 17 11
𝑚 𝑤 𝑏 12 22 1
C= =
𝑘 𝑎 𝑠 10 0 18
𝑝 𝑑 ℎ 15 3 7
Example 3 (Contd..)
300 −313 267
• K-1 = −357 313 −252 * (-939)-1 (mod 26)
6 0 −51
Cons of Hill • Limited key size and key space if 2*2 matrix is
Cipher used as the key.
• Poor efficiency for encrypting and decrypting
data using large key matrices.
VIGENERE CIPHER
• The length of the key is made equal to that
of the plaintext or ciphertext if its not the
case already.
• ci = (pi + ki mod m) mod 26
• pi = (ci – ki mod m) mod 26
Vigenere • Typically, m is lesser than the length of
Cipher plaintext or ciphertext.
Example 1
• Encrypt the plaintext “karnataka” using Vigenere Cipher and the key “hello”. Assume
that the encryption/decryption is done using only alphabets by ignoring the case.
Solution:-
k a r n a t a k a
PT (10) (0) (17) (13) (0) (19) (0) (10) (0)
+
Key h e l l o h e l l
(7) (4) (11) (11) (14) (7) (4) (11) (11)
(mod 26) =
Example 1 (Contd..)
CT 17 4 2 24 14 0 4 21 11
(r) (e) (c) (y) (o) (a) (e) (v) (l)
Solution:- r e c y o a e v l
CT (17) (4) (2) (24) (14) (0) (4) (21) (11)
-
Key h e l l o h e l l
(7) (4) (11) (11) (14) (7) (4) (11) (11)
(mod 26) =
Example 2 (Contd..)
PT 10 0 17 13 0 19 0 10 0
(k) (a) (r) (n) (a) (t) (a) (k) (a)
Solution:- CT y i t p i y x u g u b n m t f
(24) (8) (19) (15) (8) (24) (23) (20) (6) (20) (1) (13) (12) (19) (5)
-
Key m a n i p a l m a n i p a l m
(12) (0) (13) (8) (15) (0) (11) (12) (0) (13) (8) (15) (0) (11) (12)
(mod 26) =
Example 3 (Contd..)
PT 12 8 6 7 19 24 12 8 6 7 19 24 12 8 19
(m) (i) (g) (h) (t) (y) (m) (i) (g) (h) (t) (y) (m) (i) (t)
• If both the alphabets of a digram are in the same row, then each
alphabet is replaced by the alphabet immediately towards its right (the
alphabet in the last column is replaced by the alphabet in the first
column).
• If both the alphabets of a digram are in the same column, then each
alphabet is replaced by the alphabet immediately below it (the alphabet
in the last row is replaced by the alphabet in the first row).
• Else, in a digram each alphabet is replaced by the alphabet which is in
the same row but in the column of the other alphabet of the digraph.
Steps for Decrypting a Ciphertext
• If both the alphabets of a digram are in the same row, then each
alphabet is replaced by the alphabet immediately towards its left (the
alphabet in the first column is replaced by the alphabet in the last
column).
• If both the alphabets of a digram are in the same column, then each
alphabet is replaced by the alphabet immediately above it (the alphabet
in the first row is replaced by the alphabet in the last row).
• Else, in a digraph each alphabet is replaced by the alphabet which is in
the same row but in the column of the other alphabet of the digram.
Example 1
• Encrypt the plaintext “CHENNAI” using the key “MANGALORE”.
Solution:-
• Key matrix:-
M A N G L
O R E B C
D F H I K
P Q S T U
V W X Y Z
• Modified PT = CHENNAIX
Example 1 (Contd..)
• CH ➔ EK
• EN ➔ HE
• NA ➔ GN
• IX ➔ HY
• Modified PT = HELXLOINDIAX
Example 3 (Contd..)
• HE ➔ KG
• LX ➔ YV
• LO ➔ RV
• IN ➔ EU
• DI ➔ IR
• AX ➔ YW
• Generation of large random key for every session, when the plaintext is
huge.
• Key Management becomes harder.
• Most probably its used for only low bandwidth channels.
RAIL FENCE CIPHER
Rail Fence Cipher
Solution:-
K N I A U A I
A N Y K M R
• The ciphertext is “KNIAUAIANYKMR”.
Example 2
• Decrypt the ciphertext “KNIAUAIANYKMR” using Rail fence cipher
with a depth of 2.
Solution:-
• Iteration 1:-
K N I A U A I
_ _ _ _ _ _
Example 2 (Contd..)
• Iteration 2:-
K N I A U A I
A N Y K M R
Solution:-
C U N O
O P T R E W R S
M E T K
Solution:-
• Iteration 1:-
C U N O
_ _ _ _ _ _ _ _
_ _ _ _
Example 4 (Contd..)
• Iteration 2:-
C U N O
O P T R E W R S
M E T K
Solution:-
• Iteration 1:-
M L R
_ _ _ _ _
_ _ _ _ _ _
_ _ _
Example 5 (Contd..)
• Iteration 2:-
M L R
A A U E S
N P N V I Y
I I T
Solution:-
• “HELLO” → “2 1 3 4 5”
G O C O R
O N A G O
Solution:-
• “HELLO” → “2 1 3 4 5”
• IT1:-
O
N
Example 2 (Contd..)
• IT2:-
G O
O N
• IT3:- G O C O R
O N A G O
Solution:-
• “HELLO” → “2 1 3 4 5”
G O C O R
O N A G O
Solution:-
• “HELLO” → “2 1 3 4 5”
O N G O C
A O G R O
• Decrypted text after first stage decryption:- “ONGOCAOGRO”.
Example 4 (Contd..)
• Now decrypt “ONGOCAOGRO” again.
2 1 3 4 5
G O C O R
O N A G O
Solution:-
• “MANIPAL” →
5 1 6 3 7 2 4
Example 5 (Contd..)
5 1 6 3 7 2 4
A C F E O A M
H A X I D I U
X L Y E T X M
A O R I N A H
D N P E G C X