Network Security
(Lec 3)
“Introduction to Key concepts in
Cryptography”
Dr. Khurram Gulzar Rana
Playfair Cipher
Invented by charles wheatstone in 1854
The best known multiple-letter encryption.
Treat digrams in the plaintext as single units
and translate these units into ciphertext.
Based on 5x5 matrix letters , using keyword.
Playfair cipher
Playfair cipher
In this case, the keyword is monarchy.
The plaintext is encrypted according to the
following rule.
Letter I and J count as one letter.
Plaintext is encrypted two letters at a time.
Repeating plaintext letters that are in the
same pair are separated with a filler letter like
X, so the balloon would be treated as ba lx lo
on.
PlayFair Cipher
• Two letters that fall in the same row are
replaced by letters to the right , with the first
element of the row circularly following the
last. E.g ar is encypted by RM.
• Two plaintext that fall in the same column are
replaced by letters beneath , the top element
of the column circularly following the last e.g
mu is encrypted as CM.
Playfair Cipher
Each , plaintext letter in a pair is replaced by
the letter that lies in its own row and the
column occupied by the other plaintext letter,
thus hs becomes BP and ea becomes IM (or JM )
Simple monoalphbetic ciphers only 26 letters,
26x26= 676 digrams(identification is difficult).
Making relative frequency difficult.
Polyalphabetic ciphers
The simple substitution cipher is weak because the attacker can exploit the
fact that:
The letter frequency distribution of the ciphertext will match the letter
frequency distribution of the plaintext
These will generally follow the letter frequency distribution of the plaintext
language
A simple way to defeat frequency analysis is to encipher each plaintext letter
with a different substitution alphabet
The use of multiple substitution alphabets will mean that a plaintext letter
can encrypt to different ciphertext letters, thus causing the letter frequency
distribution to appear “flatter” (the individual letter frequencies are
averaged out)
A cipher that uses multiple substitution alphabets is called a polyalphabetic
substitution cipher
Vigènere cipher
• The Vigènere cipher is a polyalphabetic substitution cipher
• A secret word or phrase, representing the key, is agreed by the sender
and receiver
• Each letter of the key is used to encrypt a plaintext letter using the
Caesar cipher; each key letter represents the “shift” amount (i.e., A=0,
B=1, …, Z=25).
• After the final key letter is used to encrypt a plaintext letter, the first
key letter is used (again) to encrypt the next plaintext letter, and the
cipher continues like this; this type of cipher is called repeated key.
Vigènere tableau
1. A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
2.
3.
B
C
C
D
D
E
E
F
F
G
G
H
H
I
I
J
J
K
K
L
L
M
M
N
N
O
O
P
P
Q
Q
R
R
S
S
T
T
U
U
V
V
W
W
X
X
Y
Y
Z
Z
A
A
B
If n is the length of the key,
4. D E F G H I J K L M N O P Q R S T U V W X Y Z A B C then:
5. E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
6. F G H I J K L M N O P Q R S T U V W X Y Z A B C D E Ci = Pi + K (i + n) mod n
7. G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
8. H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
9.
10.
I
J
J
K
K
L
L
M
M
N
N
O
O
P
P
Q
Q
R
R
S
S
T
T
U
U
V
V
W
W
X
X
Y
Y
Z
Z
A
A
B
B
C
C
D
D
E
E
F
F
G
G
H
H
I
Example:
11. K L M N O P Q R S T U V W X Y Z A B C D E F G H I J Plaintext letter: T
12. L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
13. M N O P Q R S T U V W X Y Z A B C D E F G H I J K L Key letter: N
14. N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
15. O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
16. P Q R S T U V W X Y Z A B C D E F G H I J K L M N O T = 19, N = 13
17. Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
18. R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
19.
20.
S
T
T
U
U
V
V
W
W
X
X
Y
Y
Z
Z
A
A
B
B
C
C
D
D
E
E
F
F
G
G
H
H
I
I
J
J
K
K
L
L
M
M
N
N
O
O
P
P
Q
Q
R
R
S
C = 19 + 13
21. U V W X Y Z A B C D E F G H I J K L M N O P Q R S T = 32
22. V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
23. W X Y Z A B C D E F G H I J K L M N O P Q R S T U V = 6 (mod 26)
24. X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
25. Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
26. Z A B C D E F G H I J K L M N O P Q R S T U V W X Y Ciphertext letter: G
Vigènere cipher
To encrypt , the key is needed that is as long
as the message, usually repeated key word
The strength of this cipher is that , there are
multiple cipher text letters for each plain-text. one for
each unique letter of keyword.
Cryptanalysis of vigenere cipher
How the key length can be detemined.
If two identical sequences of plaintext letters occur at a
distance that is integral multiple of keyword length, then
we generate identical cipher-text sequenes.
The attacker, looking at the ciphertext will detect
repeated sequences is at displacement of 9, and
assumes that keyword is 3 or nine letters in length.
If the keyword length is N, then the cipher will
consists of N monoalpahbetic sustitution ciphers.
Cryptanalysis of vigenere cipher
So we can use relative frequency mechanism
for each monoalphabetic ciphers.
This can be eliminated by using non-repeating
key word that are as long as the message, known
as autokey system.
In this keyword is concentrated with plaintext
to provide the running key.
Transposition cipher
(Railfence cipher)
• A transposition cipher rearranges the plaintext letters according to a secret
transformation defined by the key.
• The simplest example of this is the railfence cipher, in which the plaintext is
written in rows of n-letter blocks (the number of columns n is the key) and
then the ciphertext is read in columns
• Example:
– Plaintext: TRANSPOSITIONCIPHERX
– In this example, the key is: 5
– Re-write as rows of 5-letter blocks:
TRANS
POSIT
IONCI
PHERX
– Ciphertext: TPIPROOHASNENICRSTIX
Transposition cipher
• Problems with the railfence cipher:
– The first and last letters of the plaintext do not move
– The key is a number that divides the total message length
• In a single columnar transposition cipher, the key is a word or phrase whose letters,
in alphabetic order, indicate the order of the columns as they are read
• Example:
– Plaintext: TRANSPOSITIONCIPHER
– Key is “SECRET”, so re-write as rows of 6-letter blocks:
SECRET CEERST
521436 123456
TRANSP ARSNTP
OSITIO ISITOO
NCIPHE ICHPNE
R R
– Ciphertext: AIIRSCSIHNTPTONRPOE