Unit 1 - 2022
Unit 1 - 2022
Security
U N I T 1 : S Y M M E T R I C C I P H E R M O D E L , C R Y P TO G R A P H Y, C R Y P TA N A LY S I S
A N D AT TA C K S ; S U B S T I T U T I O N A N D T R A N S P O S I T I O N T E C H N I Q U E S
R E F E R E N C E B O O K - C R Y P TO G R A P H Y A N D N E T W O R K S E C U R I T Y, P R I N C I P L E S
A N D P R A C T I C E S I X T H E D I T I O N , W I L L I A M S TA L L I N G S , P E A R S O N
CHAPTER -2 CLASSICAL ENCRYPTION TECHNIQUES
Road Map
X=D(K,Y)
Requirement and Assumption
Requirement
a strong encryption algorithm-given algorithm and cipher
text , attacker can not obtained key or plain text
a shared secret key: Sender and receiver must have
obtained copies of the secret key in a secure fashion and
must keep the key secure.
Y = EK(X)
X = DK(Y)
Assumption
encryption algorithm is known
a secure channel to distribute key
Symmetric encryption
Mathematically:
Y = EK(X) or Y = E(K, X)
X = DK(Y) or X = D(K, Y)
X = plaintext
Y = ciphertext
K = secret key
E = encryption algorithm
D = decryption algorithm
Both E and D are known to public
Model of Symmetric Cryptosystem
Model of Symmetric Cryptosystem
X
X
Cryptography
Cryptographic systems are characterized along three independent
dimensions:
1. The type of operations used for transforming plaintext to
ciphertext.
If both sender and receiver use the same key, the system is
referred to as symmetric, single-key, secret-key, or conventional
Encryption
If the sender and receiver use different keys, the system is
referred to as asymmetric, two-key, or public-key encryption.
Cryptography
Cryptographic systems are characterized along three independent
dimensions:
3. The method used to process plaintext –block cipher, stream
cipher
Cryptanalysis and Brute-Force Attack
Types of Cryptanalytic Attacks
ciphertext only
know a) algorithm b) ciphertext
known plaintext
know some given plaintext/ciphertext pairs
chosen plaintext
select plaintext and obtain ciphertext
chosen ciphertext
select ciphertext and obtain plaintext
chosen text
select either plaintext or ciphertext to en/decrypt
to attack cipher
Types of Cryptanalytic Attacks: Ciphertext only
In the ‘cipher-only’ attack, the attacker knows the ciphertext of
various messages which have been encrypted using the same
encryption algorithm.
The attacker’s challenge is to figure the ‘key’ which can then be
used to decrypt all messages.
Only relatively weak algorithms fail to withstand a ciphertext-
only attack.
Types of Cryptanalytic Attacks: Known Plaintext (KPA)
The attacker has a collection of plaintext-ciphertext pairs and is
trying to find the key or to decrypt some other ciphertext that
has been encrypted with the same key.
Example: linear cryptanalysis against block ciphers.
Types of Cryptanalytic Attacks: Chosen Plaintext
In this type of attack, the attacker chooses random plaintexts and
obtains the corresponding ciphertexts and tries to find the encryption
key.
Its very simple to implement like KPA but the success rate is quite low.
Example: differential cryptanalysis applied against block ciphers as well
as hash functions.
A popular public key cryptosystem, RSA is also vulnerable to chosen-
plaintext attacks.
Types of Cryptanalytic Attacks: Chosen Ciphertext
In this type of attack, the attacker chooses random ciphertexts and
obtains the corresponding plaintexts and tries to find the encryption key.
Types of Cryptanalytic Attacks: Chosen text
Unconditionally secure algorithm
An encryption scheme is unconditionally secure if the
ciphertext generated by the scheme does not contain enough
information to determine uniquely the corresponding plaintext,
no matter how much ciphertext is available.
That is, no matter how much time an opponent has, it is
impossible for him or her to decrypt the ciphertext simply
because the required information is not there.
With the exception of a scheme known as the one-time pad,
there is no encryption algorithm that is unconditionally secure.
i.e. no matter how much computer power is available, the
cipher cannot be broken since the ciphertext provides
insufficient information to uniquely determine the
corresponding plaintext.
Computationally secure algorithm
An encryption scheme is said to be computationally secure if
either of the foregoing two criteria are met.
1. The cost of breaking the cipher exceeds the value of the
encrypted information.
2. The time required to break the cipher exceeds the useful
lifetime of the information.
Unfortunately, it is very difficult to estimate the amount of
effort required to cryptanalyze ciphertext successfully
i.e. given limited computing resources (eg time needed for
calculations is greater than age of universe), the cipher cannot
be broken
Brute Force Attack
Try every key to decipher the ciphertext.
On average, need to try half of all possible keys
Time needed proportional to size of key space
Key Size (bits) Number of Alternative Time required at 1 Time required at 106
Keys decryption/µs decryptions/µs
32 232 = 4.3 109 231 µs = 35.8 minutes 2.15 milliseconds
128 2128 = 3.4 1038 2127 µs = 5.4 1024 years 5.4 1018 years
168 2168 = 3.7 1050 2167 µs = 5.9 1036 years 5.9 1030 years
26 characters 26! = 4 1026 2 1026 µs = 6.4 1012 years 6.4 106 years
(permutation)
Road Map
Solution
We apply the encryption algorithm to the plaintext, character by
character:
Caesar Cipher: Example
Use the Caesar cipher with key = 15 to decrypt the message
“WTAAD”.
Solution
We apply the decryption algorithm to the plaintext character by
character:
Cryptanalysis of Caesar Cipher
brute-force cryptanalysis is easily performed: simply try all the
25 possible keys.
Three important characteristics of this problem enabled us to
use a brute-force cryptanalysis:
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
Monoalphabetic Cipher Security
Now we have a total of 26! 4 x 1026 keys.
With so many keys, it is secure against brute-force attacks.
But not secure against some cryptanalytic attacks.
Problem is language characteristics (frequency analysis of
alphabets)
Monoalphabetic Cipher Security-Language Statistics and
Cryptanalysis
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
Monoalphabetic Cipher Security- Example
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
Monoalphabetic ciphers are easy to break because they reflect the frequency
data of the original alphabet
To avoid frequency analysis
M O N A R
C H Y B D
key = MONARCHY
E F G I/J K
L P Q S T
U V W X Z
Playfair Cipher- Matrix generation Example
key = KEYWORD
key = OCCURRENCE
Playfair Cipher- Matrix generation Example
key = ENGINEERING
key = MOONMISSION
Playfair Cipher- Encrypt Cipher
If both letters fall in the same row, replace each with the letter
to its right (circularly).
Playfair Cipher- Encrypt Cipher
If both letters fall in the same column, replace each with the
Letter below it (circularly).
Playfair Cipher- Encrypt Cipher
Playfair Cipher- Encrypt Cipher
Playfair Cipher- Examples
Encrypted Message
te st th is pr oc es sx
pi tu pm gt ue lf gp xg
Playfair Cipher- Examples
Encrypted Message
co me to th ew in do wx
lc nk zk vf yo gq ce bw
Playfair Cipher- Examples
Playfair Cipher- Decrypt Cipher
Ciphertext
pitu pmgt uelfgpxg
Plaintext
TEST THIS PROCESSX
Playfair Cipher- Decrypt Examples
Playfair Cipher- is it Breakable?
Limitation
Only 25 alphabets are supported.
It does not support numeric characters.
Only either upper cases or lower cases are supported.
The use of special characters (such as blank space, newline,
punctuations, etc.) is prohibited.
It does not support other languages, except English.
Encryption of media files is also not supported.
GTU Question
Encrypt the Message “Surgical Strike” with key “GUJAR” using
PLAYFAIR technique. [Winter 2018] [4 Marks]
Explain Playfair Cipher in detail. Find out cipher text for the
following given plain text and key. [Winter 2017] [7 Marks]
Key = GOVERNMENT
Plain text = PLAYFAIR
Use the key “hidden” and encrypt the message “Message” using
playfair cipher. [Summer 2019] [7 Marks]
Explain playfair cipher substitution technique in detail. Find out
cipher text for the following given key and plaintext. [Summer
2017] [7 Marks]
Key = ENGINEERING
Plaintext=COMPUTER
GTU Question
Perform encryption in Playfair Cipher algorithm with plain text as
“INFORMATION AND NETWORK SECURITY”, Keyword is
“MONARCHY”. (Note: 1.Put j and i both combine as a single field in
5*5 matrix) [ Winter 2019] [07 Marks]
Encrypt the Message “test this balloon” with key “engineering”
using PLAYFAIR technique. [Winter 2021] [4 Marks]
Hill Cipher
Hill Cipher was invented and developed in 1929 by Lester S. Hill.
The Hill cipher is an example of a block cipher.
A block cipher is a cipher in which groups of letters are
enciphered together in equal length blocks .
The Hill cipher is a polygraphic substitution cipher built on
concepts from Linear Algebra.
Key is represented in form of matrix (2 x2 or 3x3 , etc..) (Note:
Determinate of Key matrix must be non-zero)
Each letter is represented by number 0 to 25 and calculation are
based on mod 26.
The Hill cipher makes use of modulo arithmetic, matrix
multiplication, and matrix inverses; hence, it is a more
mathematical cipher than others
Hill Cipher - Encryption
Encrypting with the Hill cipher is built on the following operation:
C = (K*P) mod 26
Where K is our key matrix and P is the plaintext in vector form.
Matrix multiplying these two terms produces the encrypted
ciphertext.
Example:
Key= HILL
Plaintext=exam
Key Matrix=
Plain Text =
Hill Cipher-Encryption
Hill Cipher – Encryption-Example -2
Encrypting with the Hill cipher is built on the following operation:
C = (K*P) mod 26
Where K is our key matrix and P is the plaintext in vector form.
Matrix multiplying these two terms produces the encrypted
ciphertext.
Example:
Key= HILL
Plaintext=short example
Key Matrix=
Plain Text: =
Hill Cipher – Encryption-Example -2
=275/26
=10.5769
10.5769-10
0.5769x26=15
ciphertext = “FKMFIO".
Hill Cipher
Encryption Example
Using
3x3 Key Matrix
Hill Cipher - Encryption
Encrypting with the Hill cipher is built on the following operation:
C = (K*P) mod 26
Where K is our key matrix and P is the plaintext in vector form.
Matrix multiplying these two terms produces the encrypted
ciphertext.
Example:
Key= BACKUPABC
Plaintext= retreat now
𝑩 𝑨 𝑪 𝟏 𝟎 𝟐
Key Matrix= 𝑲 𝑼 𝑷 = 𝟏𝟎 𝟐𝟎 𝟏𝟓
𝑨 𝑩 𝑪 𝟎 𝟏 𝟐
𝒓 𝒓 𝒕 𝒘 𝟏𝟕 𝟏𝟕 𝟏𝟗 𝟐𝟐
Plain Text = 𝒆 𝒆 𝒏 𝒙 = 𝟒 𝟒 𝟏𝟑 𝟐𝟑
𝒕 𝒂 𝒐 𝒙 𝟏𝟗 𝟎 𝟏𝟒 𝟐𝟑
Hill Cipher – Encryption
C= P*K mod 26
Hill Cipher – Encryption
C= P*K mod 26
Hill Cipher – Encryption
C= P*K mod 26
Hill Cipher – Encryption
C= P*K mod 26
Ciphertext=DPQRQ EVKPQ LR
Hill Cipher – Decryption
Hill Cipher – Decryption
Key Matrix =
D=15
Hill Cipher – Decryption: Example 2x2 Key matrix
Step 2: Calculate the multiplicative inverse for the determinant.
dd-1 1 mod 26
d * d-1 mod 26 =1
And for negative values, we have to add them with 26 to get the desired values
between 0 and 25 for use in the decryption formula.
Hill Cipher – Decryption: Example 2x2 Key matrix
Step 2: Multiply multiplicative inverse of the determinant with
adjoin matrix
Key: HILL
Key Matrix =
D=15
Hill Cipher – Decryption: Example :2
Step 2: Calculate the multiplicative inverse for the determinant.
dd-1 1 mod 26
d * d-1 mod 26 =1
And for negative values, we have to add them with 26 to get the desired values
between 0 and 25 for use in the decryption formula.
Hill Cipher – Decryption: Example :2
Step 2: Multiply multiplicative inverse of the determinant with
adjoin matrix
105
Hill Cipher – Decryption: Example :2
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
ciphertext as ‘APADJ TFTWLFJ’
Hill Cipher – Decryption: Example :2
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
ciphertext as ‘APADJ TFTWLFJ’
Hill Cipher – Decryption: Example :2
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
ciphertext as ‘APADJ TFTWLFJ’
Hill Cipher – Decryption: Example :2
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
ciphertext as ‘APADJ TFTWLFJ’
Hill Cipher – Decryption: Example:2
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
ciphertext as ‘APADJ TFTWLFJ’
Hill Cipher – Decryption: Example :2
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
ciphertext as ‘APADJ TFTWLFJ’
Key: CDDG
Ciphertext:FKMFIO
Key Matrix = 𝐶 𝐷 2 3
=
𝐷 𝐺 3 6
2 3
= 2 ∗ 6 − 3 ∗ 3 = 3 𝑚𝑜𝑑 26 = 3
3 6
D=3
Hill Cipher – Decryption: Example :3
Step 2: Calculate the multiplicative inverse for the determinant.
dd-1 1 mod 26
d-1= ((26 * I ) +1)/d
d * d-1 mod 26 =1 3 *x mod 26 =1
(26*1 +1)/3 = 9
= 3 * d-1 mod 26 =1 (Hit and trial Method) (continue until result becomes integer
value)
If d-1 = 9 then 3*9 mod 26 = 27 mod 26=1
hence d-1 =9
Hill Cipher – Decryption: Example :2
Step 2: Multiply multiplicative inverse of the determinant with
adjoin matrix
And for negative values, we have to add them with 26 to get the desired values
between 0 and 25 for use in the decryption formula.
2 3 6 −3 6 −3 + 26 6 23
𝑎𝑑𝑗 = = =
3 6 −3 2 −3 + 26 2 23 2
Hill Cipher – Decryption: Example :3
Step 2: Multiply multiplicative inverse of the determinant with
adjoin matrix
6 23 54 207 2 25
9× 𝑚𝑜𝑑 26 = 𝑚𝑜𝑑 26 =
23 2 207 18 25 18
2 3 2 25
If k = , 𝑡ℎ𝑒𝑛 𝑘 −1 =
3 6 25 18
Hill Cipher – Decryption: Example :3
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
ciphertext = ‘FKMFIO’
2 25 𝐹 2 25 5
= mod 26
25 18 𝐾 25 18 10
2 ∗ 5 + 25 ∗ 10
= mod 26
25 ∗ 5 + 18 ∗ 10
260
= 𝑚𝑜𝑑 26
305
0
=
19
𝐴
=
𝑇
Hill Cipher – Decryption: Example :3
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
ciphertext = ‘FKMFIO’
2 25 𝑀 2 25 12
= mod 26
25 18 𝐹 25 18 5
2 ∗ 12 + 25 ∗ 5
= mod 26
25 ∗ 12 + 18 ∗ 5
149
= 𝑚𝑜𝑑 26
390
19
=
0
𝑇
=
𝐴
Hill Cipher – Decryption: Example :3
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
ciphertext = ‘FKMFIO’
2 25 𝐼 2 25 8
= mod 26
25 18 𝑂 25 18 14
2 ∗ 8 + 25 ∗ 14
= mod 26
25 ∗ 8 + 18 ∗ 14
366
= 𝑚𝑜𝑑 26
452
2
=
10
𝐶
=
𝐾
Hill Cipher
Decryption Example
Using
3x3 Key Matrix
Hill Cipher Decryption
Key:
Ciphertext: SYICHOLER
𝐶 𝐷 2 3
=
𝐷 𝐺 3 6
Hill Cipher – Decryption: Example
Step 1: Calculate the multiplicative inverse for the determinant.
D=11
Hill Cipher – Decryption: Example
Step 2: Calculate the multiplicative inverse for the determinant.
dd-1 1 mod 26
d * d-1 mod 26 =1
11 *x mod 26 =1
And for negative values, we have to add them with 26 to get the desired values
between 0 and 25 for use in the decryption formula.
Hill Cipher – Decryption: Example
Step 2: Multiply multiplicative inverse of the determinant with
adjoin matrix
If two letters are the same in the ciphertext it does not mean
they must decipher to the same plaintext letter.
Polyalphabetic Cipher –Vigenere Cipher
Method-1
It uses
Vigenere’ table
of size 26 x26
Each row one
shift is made
towards right in
Cyclic Manner
Polyalphabetic Cipher –Vigenere Cipher
Polyalphabetic Cipher –Vigenere Cipher
Ciphertext=R
Polyalphabetic Cipher –Vigenere Cipher
Ciphertext=RW
Ciphertext=RWXOXCPOJ
Polyalphabetic Cipher –Vigenere Cipher
Ciphertext=RW
Ciphertext=RWXOXCPOJ
Polyalphabetic Cipher –Vigenere Cipher
Encryption
Ci = (Pi + Ki) mod 26
Decryption
Pi = (Ci - Ki) mod 26
Polyalphabetic Cipher –Vigenere Cipher
Polyalphabetic Cipher –Vigenere Cipher
Method-2
Encryption
Ci = (Pi + Ki) mod 26
PLAINTEXT G I V E M O N E Y
06 08 21 04 12 14 13 04 24
KEY L O C K L O C K L
11 14 2 10 11 14 2 10 11
CIPHERTEXT
Polyalphabetic Cipher –Vigenere Cipher
Method-2
Encryption
Ci = ( Pi+ Ki) mod 26
PLAINTEXT G I V E M O N E Y
06 08 21 04 12 14 13 04 24
KEY L O C K L O C K L
11 14 2 10 11 14 2 10 11
CIPHERTEXT R W X O X C P O J
Polyalphabetic Cipher –Vigenere Cipher
Method-2
Decryption
Pi = (Ci - Ki) mod 26
Ciphertext R W X O X C P O J
17 22 23 14 23 02 15 14 09
KEY L O C K L O C K L
11 14 2 10 11 14 2 10 11
Plaintext G I V E M O N E Y
GTU Question
Encrypt the word “explanation” using the key leg with help of
Viennese cipher [Winter 2021] [03 marks]
Cryptanalysis of Vigenere Cipher
The Vigenere Cipher initially seems very secure, however it can be
broken fairly easily once the length of the keyword is known.
If we know that the length of the keyword is n, we can break the
ciphertext into n cosets and attack the cipher using frequency
analysis if the ciphertext sample is long enough.
Example:
Plaintext T H E C H I L D I S F A T H E R O F T H E M A N
Keyword P O E T R Y P O E T R Y P O E T R Y P O E T R Y
Ciphertext I V E V Y G A R M L M Y I V E K F D I V E F R L
The second group of repeated letters IVE occurs 12 letters after the
first.
The third group of letters appears 6 letters after the first.
GCD(6,12) is 6, this suggests that the length of the keyword is 6.
Cryptanalysis of Vigenere Cipher
The periodic nature of the keyword can be eliminated by using a
nonrepeating keyword that is as long as the message itself.
Vigenère proposed what is referred to as an autokey system, in
which a keyword is concatenated with the plaintext itself to
provide a running key.
For our example,
key: deceptivewearediscoveredsav
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGKZEIIGASXSTSLVVWLA
Decryption
C-0010011111
K-1100110101
----------------------
P-1110101010
Vernam Cipher-Example 2
Decryption
C-01001001000010011111
K-11001101011100110101
----------------------
P-10000100011110101010
Vernam Cipher
Although such a scheme, with a long key, presents formidable
cryptanalytic difficulties, it can be broken with sufficient
ciphertext, the use of known or probable plaintext sequences, or
both.
Solution: One- Time Pad
One Time Pad
An Army Signal Corp officer, Joseph Mauborgne, proposed an
improvement to the Vernam cipher that yields the ultimate in
security.
Mauborgne suggested using a random key that is as long as the
message, so that the key need not be repeated.
In addition, the key is to be used to encrypt and decrypt a single
message, and then is discarded,
Each new message requires a new key of the same length as the
new message. Such a scheme, known as a one-time pad, is
unbreakable.
It produces random output that bears no statistical relationship to
the plaintext.
One Time Pad
One Time Pad
One Time Pad
The one-time pad is the only cryptosystem that exhibits what is referred
to as perfect secrecy.
Transposition
Transposition
Transposition
Rail Fence Transposition - Decryption
Ciphertext: MEMATEAKETETHPR
Create a table
Number of column = number of letter in Ciphertext
Number of row = depth
Put X in Zig Zag fashion
X X X X X X X X
X X X X X X X
Rail Fence Transposition - Decryption
Ciphertext: MEMATEAKETETHPR
M E M A T E A K
E T E T H P R
Plaintext: MEETMEATTHEPARK
Rail Fence Transposition - Example
Ciphertext: TIUWOHSSQIKATMXIACYI
Ciphertext: HORELOLLWD
Rail Fence Transposition
Example:
Key=ZEBRAS (the key is 6 letters long hence there are 6 column in
Plaintext table)
Row/Column Transposition-Encryption
Row/Column Transposition-Decryption
Row/Column Transposition-Decryption
Row/Column Transposition-Encryption
In this example, the key is 4312567. To encrypt, start with the column that is labeled
1, in this case column 3. Write down all the letters in that column. Proceed to column
4, which is labeled 2, then column 2, then column 1, then columns 5, 6, and 7
GTU Question
Encrypt the message “Asymmetric key cryptography” using the key
(3,2,6,1,5,4) with help of Transposition cipher [Winter 2021] [03
marks]
Cryptanalysis of Row/Column Transposition
For columnar/Row transposition, cryptanalysis is fairly straightforward and
involves laying out the ciphertext in a matrix and playing around with column
positions.
Digram and trigram frequency tables can be useful.
2nd level
transposition
Double Row/Column Transposition
To visualize the result of this double transposition, designate the letters in the
original plaintext message by the numbers designating their position.
Thus, with 28 letters in the message, the original sequence of letters is.
which has a somewhat regular structure. But after the second transposition,
we have