Dr. Muhammad Zubair Ahmad
Dr. Muhammad Zubair Ahmad
Dr. Muhammad Zubair Ahmad
Computational security
given limited computing resources (e.g. time
needed for calculations is greater than age of
Universe), the cipher cannot be broken
Average time to exhaustive Brute Force
The Types of Operations
The Substitution Cipher
A substitution cipher is one in which the
letters of plaintext are replaced by other
letters or by numbers or symbols.
Plaintext 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
Ciphertext 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
The Substitution Ciphers
The Caesar Cipher
Note that the alphabet is wrapped around,
so that the letter following Z is A.
We can define the transformation by
listing all possibilities, as follows:
Plaintext 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
Ciphertext 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
UZQSOVUOHXMOPVGPOZPEVSGZWSZ
OPFPESXUDBMETSXAIZVUEPHZHMDZ
SHZOWSFPAPPDTSVPQUZWYMXUZUH
SXEPYEPOPDZSZUFPOMBZWPFUPZHM
DJUDTMOHMQ
The Substitution Ciphers
The Mono-alphabetic Cipher - Problem
The Substitution Ciphers
The Mono-alphabetic Cipher - Problem
As a first step, the relative frequency of
the letters can be determined and
compared to a standard frequency
distribution for English.
If the message were long enough, this
technique alone might be sufficient, but
because this is a relatively short message,
we cannot expect an exact match.
The Substitution Ciphers
The Mono-alphabetic Cipher - Problem
Comparing this breakdown with frequency
distribution of English, it seems likely that
cipher letters P and Z are the equivalents of
plain letters e and t, but it is not certain which is
which.
The letters S,U,O,M, and H are all of relatively
high frequency and probably correspond to
plain letters from the set {a, h, i, n, o, r, s}.
The letters with the lowest frequencies (namely,
A,B,G,Y, I, J) are likely included in the set {b,
j, k, q, v, x, z}
The Substitution Ciphers
The Mono-alphabetic Cipher - Problem
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
t a e e te a that e e a a
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
e t t a t h a e ee a e t h t a
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
e e e tat e t he t
Plaintext d e f e n d t h e e a s t w a l l o f c a s t l e
Ciphertext F 7 E Z 5 F U C 2 1 D R 6 M 9 P P 0 E S D 4 U P 1
The Substitution Ciphers
The Playfair Cipher
The Playfair cipher was the first practical
digraph (pair of alphabets) substitution
cipher.
If
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
The Substitution Ciphers
The Playfair Cipher
Plaintext is encrypted two letters at a
time, according to the following rules:
Repeating plaintext letters that are in the same pair
are separated with a filler letter, such as x, so that
balloon would be treated as ba lx lo on.
x (sometime z) is also used to fill second letter in
the digram if there is an odd number of letter.
Two plaintext letters that fall in the same row of the
matrix are each replaced by the letter to the right,
with the first element of the row circularly
following the last. For example, AR is encrypted as
RM.
The Substitution Ciphers
The Playfair Cipher
Plaintext is encrypted two letters at a
time, according to the following rules:
Two plaintext letters that fall in the same column
are each replaced by the letter beneath, with the top
element of the column circularly following the last.
For example, MU is encrypted as CM.
Otherwise, 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, as the
encipherer wishes).
The Substitution Ciphers
The Playfair Cipher
If keyword is Monarchy and
plaintext is Instruments
Then first break the plaintext is converted into
cipher text as follows:
M O N A R
Plaintext in st ru me nt sx
C H Y B D
Ciphertext GA TL MZ CL RQ XA E F G I/J K
L P Q S T
U V W X Z
The Substitution Ciphers
The Hill Cipher
Hill cipher invented by Lester S. Hill in
1929.
It is the first polygraphic cipher in which
it was practical (though barely) to operate
on more than three symbols at once.
Each letter is represented by a number
modulo 26.
Often the simple scheme A = 0, B = 1, …,
Z = 25 is used, but this is not an essential
feature of the cipher.
The Substitution Ciphers
The Hill Cipher
To encrypt a message, each block of n
letters (considered as an n-component
vector) is multiplied by an invertible nxn
matrix, against modulus 26. To decrypt
the message, each block is multiplied by
the inverse of the matrix used for
encryption.
The Substitution Ciphers
The Hill Cipher
Suppose we have to encrypt the message
‘act’ (n=3).The key is ‘gybnqkurp’ which
can be written as the n x n matrix:
¿ 𝟔 𝟐𝟒 𝟏 ¿𝟎
[ ¿ 𝟏𝟑 𝟏𝟔 𝟏𝟎
¿ 𝟐𝟎 𝟏𝟕 𝟏𝟓 ] [ ] ¿𝟐
¿ 𝟏𝟗
act
gybnqkurp
The Substitution Ciphers
The Hill Cipher
Encryption
¿ 𝟔 𝟐𝟒 𝟏 ¿𝟎 ¿ 𝟔𝟕 ¿ 𝟏𝟓
[ ][ ] [ ] [ ]
¿ 𝟏𝟑 𝟏𝟔 𝟏𝟎 ¿ 𝟐 = ¿ 𝟐𝟐𝟐 ≡ ¿𝟏𝟒 ( 𝒎𝒐𝒅 𝟐𝟔 )
¿ 𝟐𝟎 𝟏𝟕 𝟏𝟓 ¿ 𝟏𝟗 ¿ 𝟑𝟏𝟗 ¿𝟕
gybnqkurp act POH
The Substitution Ciphers
The Hill Cipher
Decryption
−𝟏
¿ 𝟔 𝟐𝟒 𝟏 ¿ 𝟖𝟓 𝟏𝟎
[ ¿ 𝟏𝟑 𝟏𝟔 𝟏𝟎
¿ 𝟐𝟎 𝟏𝟕 𝟏𝟓
( gybnqkurp )
] [
−𝟏
¿ 𝟐𝟏𝟏𝟐 𝟖 ]
≡ ¿ 𝟐𝟏𝟖 𝟐𝟏 ( 𝒎𝒐𝒅 𝟐𝟔 )
¿ 𝟖 𝟓 𝟏𝟎 ¿ 𝟏𝟓 ¿ 𝟐𝟔𝟎 ¿𝟎
[ ¿ 𝟐𝟏 𝟖 𝟐𝟏
¿ 𝟐𝟏 𝟏𝟐 𝟖 ][ ] [ ] [ ]
¿ 𝟏𝟒 = ¿ 𝟓𝟕𝟒 ≡ ¿ 𝟐 ( 𝒎𝒐𝒅 𝟐𝟔 )
¿𝟕 ¿𝟓𝟑𝟗 ¿ 𝟏𝟗
act
POH
The Substitution Ciphers
The Hill Cipher
To conclude this Hill Cipher
𝐂=𝐊𝐏 𝑚𝑜𝑑 26
−𝟏
𝐏= 𝐊 𝐂 𝑚𝑜𝑑 26
Vigenère
Square
or Vigenère square or Vigenère table.
Vigenère
table.
The Substitution Ciphers
The Vigenère Cipher
The table consists of the alphabets written
out 26 times in different rows, each
alphabet shifted cyclically to the left
compared to the previous alphabet.
At different points in the encryption
process, the cipher uses a different
alphabet from one of the rows.
The alphabet used at each point depends
on a repeating keyword.
The Substitution Ciphers
The Vigenère Cipher (Example)
Plaintext : geeks for geeks
Keyword : ayush
Ciphertext : GCYCZFMLYLEIM
For generating key, the given keyword is
repeated in a circular manner until it
matches the length of the plain text.
The keyword "ayush" generates the key
"ayushayushayu"
The plain text is then encrypted using the
process explained below.
The Substitution Ciphers
Keyword
Encryption
Process Plaintext
Ciphertext
The Substitution Ciphers
Plaintext
Decryption
Process
Keyword
Ciphertext
The Substitution Ciphers
The Vernam Cipher (One time pad)
In Vernam Cipher we assign a number
to each character of the Plain-Text, like (a
= 0, b = 1, c = 2, … z = 25).
We take a key to encrypt the plain text
which length should be equal to the
length of the plain text.
The Substitution Ciphers
The Vernam Cipher
Assign a number to each character of the
plain-text and the key according to
alphabetical order.
Add both the number (Corresponding
plain-text character number and Key
character number).
Subtract 26 from the number if the added
number is greater than 25, if it isn’t then
leave it.
The Substitution Ciphers
The Vernam Cipher (One time pad)
The Substitution Ciphers
The Vernam Cipher (Encryption)
abcde f gh i j k l m n o p q r s t u v w x y z
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Plaintext r a m s w a m i
PN 17 0 12
18 22 0 12 8
Key r a n g e e l a
KN 17 0 136 4 4 11 0
J=PN+KN 34 0 25
24 26 4 23 8
Add -26, If J>25 -26 -26
Result 8 0 25 24 0 4 23 8
Ciphertext I A Z Y A E X I
The Substitution Ciphers
The Vernam Cipher (Decryption)
abcde f gh i j k l m n o p q r s t u v w x y z
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Ciphertext I A Z AY E X I
CN 8 0 25 24
0 4 23 8
Key r a n eg e l a
KN 17 0 13 46 4 11 0
J=CN-KN -9 0 12 18
-4 0 12 8
Add 26, If J<0 26 26
Result 17 0 12 18 22 0 12 8
Plaintext r a m s w a m i
The Substitution Ciphers
The VIC Cipher
The VIC Cipher uses a table which
allows changing letters of plaintext into
numbers. It is called a Straddling
checkerboard.
It differs from tables used in other
substitution ciphers because it produces
shorter sequences of numbers (it is much
more comfortable for sending to the
second party).
The Substitution Ciphers
The VIC Cipher
The straddling checkerboard can be
created in the following form.
The highest row is populated with the ten
digits from 0 to 9.
The second row is typically filled with
popular letters in any order.
In English, a mnemonic ESTONIA-R
can be used to remember the most
frequent letters.
The Substitution Ciphers
The VIC Cipher
Free cells should be left under any two
digits.
Each of both lower rows receives one of
the two remaining digits, which isn't used
in the second row.
Then, the two rows should be filled with
letters in alphabetical order.
Because of two empty remaining cells,
two additional special characters may be
entered into the table.
The Substitution Ciphers
The VIC Cipher
They can be used for special purposes or
shortcuts agreed previously between the
two parties.
0 1 2 3 4 5 6 7 8 9
Straddling E T A O N R I S
checkerboard
2 B C D F G H J K L M
6 P Q / U V W X Y Z .
The Substitution Ciphers
The VIC Cipher
During encryption, using VIC one should
replace letters of the message by numbers
created based on numbers of rows and
columns.
The most popular letters should be
replaced by only one digit of the column
(that results in producing shorter
ciphertext).
The Substitution Ciphers
The VIC Cipher
The next step is to add some specified
numbers to the all digits of the created
sequence.
One should add one by one all digits of
the changing message to all digits of the
secret sequence. The addition is done
modulo 10, so if the result is bigger than
10 then the tens digit should be discarded.
The Substitution Ciphers
The VIC Cipher
The received digits can be used as a
ciphertext and send to the second party.
Sometimes, it is a good idea to change
digits back into letters.
After finding one of the two digits which
are assigned to the two lower rows, one
should use a proper two-digit number.
The Substitution Ciphers
The VIC Cipher
Decrypting can be performed using the
same straddling checkerboard, the
same secret number and the steps
performed in reverse order.
The secret number's digits should be
subtracted from ciphertext's digits.
If any of the results are smaller than 0,
then one should add 10 to the ciphertext's
digits.
The Substitution Ciphers
The VIC Cipher
There are many modifications of the VIC
cipher. Changes can be introduced in the
straddling checkerboard by changing the
order of letters.
The received ciphertext's characters can
be modified at the end of encryption
using one of the transposition ciphers'
algorithms.
0 1 2 3 4 5 6 7 8 9
Straddling Checkerboard E T A O N R I S
2 B C D F G H J K L M
Encryption 6 P Q / U V W X Y Z .
Pairing the
3 4 7 9 7 20 3 7 8 4 26 9 65 0 7 5 62 4
Result's Digits
Ciphertext A O R S R B A R I O J S W E R N / O
0 1 2 3 4 5 6 7 8 9
Straddling Checkerboard E T A O N R I S
2 B C D F G H J K L M
Decryption 6 P Q / U V W X Y Z .
Pairing the
29 3 7 67 61 63 0 0 5 4 23 9 21 4 1 9
Result's Digitis
m a r y q u e e n o f s c o t s
Plaintext
mary queen of scots