0% found this document useful (0 votes)
88 views177 pages

Unit 1 - 2022

Uploaded by

Ghetiya Niraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views177 pages

Unit 1 - 2022

Uploaded by

Ghetiya Niraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 177

Information

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

 Symmetric Cipher Model: Cryptography,


Cryptanalysis and Attacks
 Substitution techniques
 Transposition techniques
Basic Terminology
 Plaintext - the original message
 Ciphertext – encrypted or the coded message
 enciphering (encryption) - The process of converting from
plaintext to ciphertext
 Encryption algorithm: performs encryption
 Two inputs: a plaintext and a secret key
 deciphering (decryption) – process of recovering ciphertext
from plaintext
 Decryption algorithm: performs decryption
 Two inputs: ciphertext and secret key
 Secret key: key used for encryption and decryption
 If same key is used then known as symmetric cryptology
 If Different key is used then known as asymmetric
cryptology
Basic Terminology
 Cipher – a particular algorithm (cryptographic system)
 cryptography - study of algorithms used in encryption
 cryptanalysis (codebreaking) - the study of techniques used in
decryption without knowing plaintext (i.e. he study of the
cryptographic algorithm and the breaking of those secret codes)
 Cryptanalysis is the process of studying cryptographic systems
to look for weaknesses or leaks of information
 Cryptanalysis is a process of finding weaknesses in
cryptographic algorithms and using these weaknesses to
decipher the ciphertext without knowing the secret key
(instance deduction).
Basic Terminology
 cryptology - the field of both cryptography and cryptanalysis

 The person practicing Cryptanalysis is called a Cryptanalyst.


 It helps us to better understand the cryptosystems and also
helps us improve the system by finding any weak point and thus
work on the algorithm to create a more secure secret code.
 For example, a Cryptanalyst might try to decipher a ciphertext
to derive the plaintext. It can help us to deduce the plaintext or
the encryption key.
Symmetric Cypher model (Conventional Encryption)
Symmetric Cypher model (Conventional Encryption)
Symmetric Cypher model (Conventional Encryption)

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.

 All encryption algorithms are based on two general principle:


 Substitution - in which each element in the plaintext is
mapped into another element
 transposition, in which elements in the plaintext are
rearranged.
 The fundamental requirement is that no information be lost.
(i.e., that all operations are reversible).
 Most systems, referred to as product systems, involve multiple
stages of substitutions and transpositions
Cryptography
Cryptographic systems are characterized along three independent
dimensions:
2. The number of keys used.

 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

56 256 = 7.2  1016 255 µs = 1142 years 10.01 hours

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

 Symmetric Cipher Model: Cryptography,


Cryptanalysis and Attacks
 Substitution techniques
 Transposition techniques
Substitution techniques
 A substitution technique is one in which the letters of plaintext are
replaced by other letters or by numbers or symbols.
 If the plaintext is viewed as a sequence of bits, then substitution
involves replacing plaintext bit patterns with ciphertext bit patterns.

A substitution cipher replaces one


symbol with another.
Caesar Cipher
 The earliest known, and the simplest, use of a substitution
cipher was by Julius Caesar.
 The Caesar cipher involves replacing each letter of the alphabet
with the letter standing three places further down the
alphabet.
 Note that the alphabet is wrapped around, so that the letter
following Z is A.
Caesar Cipher

Caesar ciphers are sometimes referred


to as shift ciphers or Additive cipher.
Caesar Cipher
Caesar Cipher
 A shift may be of any amount, so that the general Caesar
algorithm is

 where k takes on a value in the range 1 to 25. The decryption


algorithm is simply
Caesar Cipher: Example
Use the Caesar cipher with key = 15 to encrypt the message
“hello”.

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:

 The encryption and decryption algorithms are known.


 There are only 25 keys to try.
 The language of the plaintext is known and easily
recognizable.
Brute force attack on Caesar Cipher
Cryptanalysis of Caesar Cipher
 Three important characteristics of this problem enabled us to
use a brute-force cryptanalysis:

 The encryption and decryption algorithms are known.


 There are only 25 keys to try.
 The language of the plaintext is known and easily
recognizable.

 The third characteristic is also significant. If the language of the


plaintext is unknown, then plaintext output may not be
recognizable.
 Furthermore, the input may be abbreviated or compressed in
some fashion, again making recognition difficult.
Monoalphabetic Cipher (simple substitution)

A permutation of a finite set of elements S is an ordered sequence


of all the elements of S, with each element appearing exactly
once.

For example, if S = {a, b, c}, there are six permutations of S:


abc, acb, bac, bca, cab, cba

In general, there are n! permutations of a set of n elements,


because the first element can be chosen in one of n ways, the
second in n - 1 ways, the third in n – 2 ways, and so on
Monoalphabetic Cipher (simple substitution)
 Each plaintext letter maps to a different random ciphertext
letter .
 Hence key is 26 letters long

Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN

 “Cipher” line can be any permutation of the 26 alphabetic char

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

 Human languages are not random.


 Letters are not equally frequently used.
 In English, E is by far the most common letter, followed by T, R,
N, I, O, A, S.
 Other letters like Z, J, K, Q, X are fairly rare.
 In addition to the frequency info of single letters, the frequency
info of two-letter (digram) or three-letter (trigram)
combinations can be used for the cryptanalysis
 Most frequent digrams - TH, HE, IN, ER, AN, RE, ED, ON, ES, ST,
EN, AT, TO, NT, HA, ND, OU, EA, NG, AS, OR, TI, IS, ET, IT, AR, TE,
SE, HI, OF
 Most frequent trigrams - THE, ING, AND, HER, ERE, ENT, THA,
NTH, WAS, ETH, FOR, DTH
Relative Frequency of Letters in English Text
Monoalphabetic Cipher Security- Example

 Consider the following ciphertext

UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ

 Count the relative letter frequencies


P 13.33 H 5.83 F 3.33 B 1.67 C 0.00
Z 11.67 D 5.00 W 3.33 G 1.67 K 0.00
S 8.33 E 5.00 Q 2.50 Y 1.67 L 0.00
U 8.33 V 4.17 T 2.50 I 0.83 N 0.00
O 7.50 X 4.17 A 1.67 J 0.83 R 0.00
M 6.67
Monoalphabetic Cipher Security- Example

 Consider the following ciphertext

UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ

 Guess {P, Z} = {e, t}


 Of double letters, ZW has highest frequency, so guess ZW = th
 and hence ZWP = the
 Next, notice the sequence ZWSZ in the first line. We do not
know that these four letters form a complete word, but if they
do, it is of the form th_t. If so, S equates with a.
Monoalphabetic Cipher Security- Example

 Consider the following ciphertext

UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
Monoalphabetic Cipher Security- Example

 Consider the following ciphertext

UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ

Proceeding with trial and error finally get:

it was disclosed yesterday that several informal but


direct contacts have been made with political
representatives of the viet cong in moscow

Monoalphabetic ciphers are easy to break because they reflect the frequency
data of the original alphabet
To avoid frequency analysis

 Two method can used


 Encrypt multiple letters of plaintext – Playfair Cipher
 Use multiple cipher alphabets – Hill Cipher
Playfair Cipher

 Not even the large number of keys in a monoalphabetic cipher



provides security.
 One approach to improving security is to encrypt multiple
letters at a time.
 The Playfair Cipher is the best known such cipher which treats
digrams in the plaintext as single units and translates these units
into ciphertext digrams.
 Invented by Charles Wheatstone in 1854, but named after his
friend Baron Playfair.
Playfair Cipher

 The Playfair algorithm is based on the use of a 5 * 5 matrix of


letters (consider as key).
 The matrix is constructed by filling in the letters of the keyword
(Exclude duplicates) from left to right and from top to bottom,
and then filling in the remainder of the matrix with the
remaining letters in alphabetic order. The letters I and J count as
one letter.

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

Plaintext is encrypted two letters at a time, according to the


following rules:
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

Cypher text is decrypted two letters at a time, according to the


following rules:
1. If both letters fall in the same row, replace each with the letter
to its left (circularly).
2. If both letters fall in the same column, replace each with the
Letter above it (circularly).
3. if two letter are on different row and column
Playfair Cipher- Decrypt Examples
Key=“engineering”

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

How to find 275 mod 26?

=275/26
=10.5769

10.5769-10

0.5769x26=15

ciphertext = "APADJ TFTWLFJ".


Hill Cipher – Encryption-Example -2

ciphertext = "APADJ TFTWLFJ".


Hill Cipher – Encryption-Example -3
Hill Cipher – Encryption-Example -3
Hill Cipher – Encryption-Example -3
Hill Cipher – Encryption-Example -3

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

Step 1: Calculate the multiplicative inverse for the determinant.


Step 2: Multiply it with Adjoin matrix
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
Hill Cipher – Decryption: Example 2x2 Key matrix
Step 1: Calculate the multiplicative inverse for the determinant.

1.1 Find Determinate of the Matrix

Key Matrix =

D=15
Hill Cipher – Decryption: Example 2x2 Key matrix
Step 2: Calculate the multiplicative inverse for the determinant.

1.2 Find multiplicative inverse of Determinate of the Matrix

dd-1  1 mod 26

d * d-1 mod 26 =1

= 15 * d-1 mod 26 =1 (Hit and trial Method)

If d-1 = 7 then 15*7 mod 26 = 105 mod 26=1


hence d-1 =7
Hill Cipher – Decryption: Example 2x2 Key matrix
Step 2: Calculate the multiplicative inverse for the determinant.

1.2 Find multiplicative inverse of Determinate of the Matrix

d-1= ((26 * I ) +1)/d


dd-1  1 mod 26
15 *x mod 26 =1

(26*1 +1)/15 = 1.8


d * d-1 mod 26 =1 (26*2+1)/15 =3.53
(26*3+1)/15 =5.27
(26*4+1)/15=7 (continue until result becomes
integer value)
Hill Cipher – Decryption: Example 2x2 Key matrix
Step 2: Multiply multiplicative inverse of the determinant with
adjoin matrix

2.1 Calculate 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.
Hill Cipher – Decryption: Example 2x2 Key matrix
Step 2: Multiply multiplicative inverse of the determinant with
adjoin matrix

2.2 Multiply d-1 with Adjoin matrix


Hill Cipher – Decryption: Example 2x2 Key matrix
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
ciphertext as ‘ELSC’
Hill Cipher Decryption: Example 2

Key: HILL

Ciphertext: APADJ TFTWLFJ

Step 1: Calculate the multiplicative inverse for the determinant.


Step 2: Multiply it with Adjoin matrix
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
Hill Cipher – Decryption: Example 2
Step 1: Calculate the multiplicative inverse for the determinant.

1.1 Find Determinate of the Matrix

Key Matrix =

D=15
Hill Cipher – Decryption: Example :2
Step 2: Calculate the multiplicative inverse for the determinant.

1.2 Find multiplicative inverse of Determinate of the Matrix

dd-1  1 mod 26

d * d-1 mod 26 =1

= 15 * d-1 mod 26 =1 (Hit and trial Method)

If d-1 = 7 then 15*7 mod 26 = 105 mod 26=1


hence d-1 =7
Hill Cipher – Decryption: Example :2
Step 2: Multiply multiplicative inverse of the determinant with
adjoin matrix

2.1 Calculate 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.
Hill Cipher – Decryption: Example :2
Step 2: Multiply multiplicative inverse of the determinant with
adjoin matrix

2.2 Multiply d-1 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’

Plain text: short example


Hill Cipher Decryption: Example 3

Key: CDDG

Ciphertext:FKMFIO

Step 1: Calculate the multiplicative inverse for the determinant.


Step 2: Multiply it with Adjoin matrix
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
Hill Cipher – Decryption: Example 3
Step 1: Calculate the multiplicative inverse for the determinant.

1.1 Find Determinate of the Matrix

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.

1.2 Find multiplicative inverse of Determinate of the Matrix

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

2.1 Calculate 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

2.2 Multiply d-1 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

Step 1: Calculate the multiplicative inverse for the determinant.


Step 2: Multiply it with Adjoin matrix
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext
Hill Cipher – Decryption: Example
Step 1: Calculate the multiplicative inverse for the determinant.

1.1 Find Determinate of the Matrix

𝐶 𝐷 2 3
=
𝐷 𝐺 3 6
Hill Cipher – Decryption: Example
Step 1: Calculate the multiplicative inverse for the determinant.

1.1 Find Determinate of the Matrix

D=11
Hill Cipher – Decryption: Example
Step 2: Calculate the multiplicative inverse for the determinant.

1.2 Find multiplicative inverse of Determinate of the Matrix

dd-1  1 mod 26

d * d-1 mod 26 =1

= 11 * d-1 mod 26 =1 (Hit and trial Method)

If d-1 = 19 then 11*19 mod 26 = 209 mod 26=1


hence d-1 =19
Hill Cipher – Decryption: Example
Step 2: Calculate the multiplicative inverse for the determinant.

1.2 Find multiplicative inverse of Determinate of the Matrix

d-1= ((26 * I ) +1)/11

11 *x mod 26 =1

(26*1 +1)/11 = 2.45


(26*2 +1)/11 = 4.82
(26*3 +1)/11 = 7.18
(26*4 +1)/11 = 9.45
(26*5+1)/11 = 11.90
(26*6 +1)/11 = 14.27
(26*7 +1)/11 = 16.64
(26*8+1)/11 = 19
(continue until result becomes integer value)
Hill Cipher – Decryption: Example
Step 2: Multiply multiplicative inverse of the determinant with
adjoin matrix

2.1 Calculate Adjoin matrix (Method 1)


Hill Cipher – Decryption: Example
Step 2: Multiply multiplicative inverse of the determinant with
adjoin matrix

2.1 Calculate Adjoin matrix (Method 2)


First calculate cofactor matrix

Then transpose the cofactor matrix


Hill Cipher – Decryption: Example
Step 2: Multiply multiplicative inverse of the determinant with
adjoin matrix
2.1 Calculate Adjoin matrix (Using Method 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

2.2 Multiply d-1 with Adjoin matrix


Hill Cipher – Decryption: Example
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext ciphertext = ‘SYICHOLER’
Hill Cipher – Decryption: Example
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext ciphertext = ‘SYICHOLER’
Hill Cipher – Decryption: Example
Step 3: Multiple inverse key matrix with Cipher text matrix to
obtain plaintext ciphertext = ‘SYICHOLER’

Plaintext=we are safe


Cryptanalysis of Hill Cipher
• As with Playfair, the strength of the Hill cipher is
that it completely hides single-letter frequencies.
Indeed, with Hill, the use of a larger matrix hides
more frequency information.
• Thus, a 3*3 Hill cipher hides not only single-letter
but also two-letter frequency information
• The Hill Cipher's weaknesses to the known-
plaintext attack is considered as its most
important security imperfection since it can be
cracked by taking n distinct pairs of plaintext
and corresponding cipher-text
GTU Question
• Encrypt the message "meet me at the usual place " using the Hill
9 4
cipher with the key [winter 2018] [7 Marks]
5 7
17 17 5
• Given key K= 21 18 21 and plaintext =”ney”. Find out the
2 2 19
ciphertext applying Hill Cipher. [ 7 Marks] [Summer 2019]
• Encrypt the message “GTU Examination” using the Hill cipher
5 17
algorithm with the key matrix . Show your calculations
4 15
and the result. [Winter 2019] [7 marks]
Polyalphabetic Cipher

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

One of the simplest, polyalphabetic ciphers is the Vigenère 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

Decryption is performed by going


to the row in the table
corresponding to the key, finding
the position of the ciphertext
letter in this row, and then using
the column’s label as the
plaintext.
Polyalphabetic Cipher –Vigenere Cipher
Polyalphabetic Cipher –Vigenere Cipher
Polyalphabetic Cipher –Vigenere Cipher
Polyalphabetic Cipher –Vigenere Cipher
Method-2
 When the vigenere table is not given, the encryption and decryption are done
by Vigenar algebraically formula in this method (convert the letters (A-Z) into
the numbers (0-25)).
 It generate Keystream from KEY by repeatedly writing key until length of
keystream and Plaintext/Ciphertext are equal

 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.

Kasiski tests to determine length of key


Cryptanalysis of Vigenere Cipher

Kasiski tests to determine length of key

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

 Even this scheme is vulnerable to cryptanalysis.


 Because the key and the plaintext share the same frequency
distribution of letters, a statistical technique can be applied.
Vernam Cipher
 The Vernam cipher was created by Gilbert Vernam
 Keyword is long as the plaintext (has no statistical relationship
with plaintext)
 The essence of this technique is the means of construction of the
key.
 Vernam proposed the use of a running loop of tape that eventually
repeated the key, so that in fact the system worked with a very
long but repeating keyword.
 Each character of the plaintext and the key is converted to binary
using a character coding system like ASCII.
 The plaintext binary is then XOR'd with the key binary to produce a
new binary value.
 This is then converted to a character and is part of the ciphertext.
 The same technique is applied in reverse to decrypt information.
Vernam Cipher
Vernam Cipher
Vernam Cipher-Example 1

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

Now, write down Ciphertext, row by row where X is written

M E M A T E A K
E T E T H P R

Then, write down letter in Zig-Zag fashion

Plaintext: MEETMEATTHEPARK
Rail Fence Transposition - Example

Plaintext: THIS IS A QUICK WAY TO MIX


Depth: 3

Ciphertext: TIUWOHSSQIKATMXIACYI

Plaintext: Hello World


Depth: 3

Ciphertext: HORELOLLWD
Rail Fence Transposition

Attacker can try


for different
depth and find
the plain text
Row/Column Transposition
 Plaintext is written in tabular form row by row where length of row
determined by length of key.
 Ciphertext is read out column by column where order of column is
specified by Key.
 Key = permutation of order of Column

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.

Solution: Multiple transposition


Double Row/Column Transposition
 The transposition cipher can be made significantly more secure by performing
more than one stage of transposition.
 The result is a more complex permutation that is not easily reconstructed.
1st level
transposition

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.

 After the first transposition, we have

 which has a somewhat regular structure. But after the second transposition,
we have

 This is a much less structured permutation and is much more difficult to


cryptanalyze.

You might also like