You are on page 1of 38

CS-381 Network Security

Week 3 – Lecture 1
Classical Encryption Techniques

Dr. Razi Arshad


Outline
Classical Encryption Techniques
 Substitution
 Transposition
Caesar Cipher
 Used by Julius Caesar
 A simple substitution cipher
 M = { sequences of letters }
 K = { i | i is an integer and 0 ≤ i ≤ 25 }
 E = { Ek | k K and for all letters in m,
Ek(m) = (m + k) mod 26 }
 D = { Dk | k K and for all letters c,
Dk(c) = (c – k) mod 26 }
 Plain: MEET ME AFTER THE TOGA PARTY
 Cipher: PHHW PH DIWHU WKH WRJD SDUWB
Cryptanalysis
 Exhaustive search
 If the key space is small enough, try all
possible keys until you find the right
one
 Frequency analysis
 Compare to 1-gram model of English
Cryptanalysis-Caesar Cipher
 Key space : 25
 Cryptanalysis: Once you know the algorithm, simply
try all 25 possible keys to recover the plaintext
 Ciphertext only attack is possible.
Three important motivations to launch brute force:
 The encryption and decryption algorithms are
known
 There are only 25 keys to try
 The language of the plaintext is known andeasily
recognizable
Brute-Force Attack on
Caesar Cipher
How to make Caesar Cipher
hard?
 Key is too short
 Can be found by exhaustive search
 Statistical frequencies not concealed well
 They look too much like regular English letters

 So make it longer
 Multiple letters in key
 Idea is to smooth the statistical frequencies to
make cryptanalysis harder
How to make Caesar Cipher
hard?
The input may be abbreviated or compressed in some
fashion, making recognition difficult. Below it shows a
portion of a text file compressed using an algorithm called
ZIP. If this file is then encrypted with a simple substitution
cipher (expanded to include more than just 26 alphabetic
characters), then the plaintext may not be recognized when
it is uncovered in the brute-force cryptanalysis.
Frequency Analysis Attack
 Ciphertext: KHOOR ZRUOG
 Compute frequency of each letter in ciphertext:
K 1 H 1 O 3 R 2
Z 1 U 1 G 1
 Apply 1-gram model of English
 The statistical distribution of letter frequencies
of a message (text) written in any language tend
towards a known letter frequency distribution
profile of the language
Frequency Analysis Attack
 This is particularly true for long messages (i.e.,
the longer the text, the closer the letter
frequency distributions match the language’s
letter frequency distributions)
 The simple substitution cipher preserves the
letter frequency distributions of the plaintext
in the ciphertext (i.e., information about the
plaintext is leaked in the ciphertext)
 The attacker takes a frequency count of the
ciphertext letters and tries to match them to
the letter frequency distribution profile of the
plaintext language
Frequency Statistics of English
Language
 In addition to the frequency info of single letters, the
frequency info of two-letter (di-gram) or three-letter
(tri-gram) combinations can be used for the
cryptanalysis
 Most frequent diagrams
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
Example: Frequency Analysis
Relative Frequency Distributions
(English & Ciphertext)
Example: Frequency
Analysis
Example: Frequency Analysis
Polyalphabetic Cipher
 Poly: a Greek word means “Many”
 Polyalphabetic cipher uses multiple alphabets
 Avoids the problem of frequency analysis as in
case of mono-alphabetic substitution because of
one to many mappings of alphabets i.e., A to D,
F, T, etc.
 The best known and the simplest example of
polyalphabetic cipher is referred to as Vigenere
Cipher
Classical Encryption
Techniques
 Substitution Ciphers
 Monoalphabetic Ciphers
• Caesar Cipher
 Polyalphabetic Ciphers
 Vigenere Cipher
 Playfair Cipher
 Hill Cipher
 One-Time Pad
Vigenère Cipher
 Best-known polyalphabetic cipher
 The cipher uses multiple key letters to encrypt. The first key
encrypts the first plaintext character, the second key encrypts
the second plaintext character and so on. After all the key
letters are used, they are re-cycled i.e.,

 Key is repeating word. If key length is 6, every 6th letter will


be replaced with the same key letter. This number (in this case
6) is called as period of the cipher.
 The security of the system depends on the fact that neither the
keyword nor its length is known.
 Length of the key = period
Vigenère Cipher: Encryption

 Example : To improve understanding, a matrix


known as Vigenère tableau is constructed

 Key Length = 9
Vigenère Cipher Tableau
Vigenère Cipher: Decryption

 Decryption is equally simple

 Example
Vigenère Cipher Tableau
Vigenère Cipher
 Strength of the algorithm
 Multiple ciphertext letters for each plaintext
letter
 Letter frequency information is obscured
 Weakness
 Not all knowledge of plaintext is lost
 Improvement over the Playfair cipher, but
language structure and frequency
information still remain
Classical Encryption
Techniques
 Substitution Ciphers
 Monoalphabetic Ciphers
• Caesar Cipher
 Polyalphabetic Ciphers
• Vigenere Cipher
• Playfair Cipher
• Hill Cipher
• One-Time Pad
Playfair Cipher
 Best-known multiple-letter substitution cipher
 Digram cipher through keyword-based 5x5
transformation table
 The 5x5 matrix is constructed by filling the letter of
keywords (minus duplicates) from left to right & from top
to bottom first and then filling the rest of the matrix with
the remaining letters in alphabetic order
 The I/J count as one letter
 Keyword= MONARCHY
 Key Space=25!
Playfair Cipher
 Repeating plaintext letters in the same pair:
 Separate with a filler x. e.g. balloon with ba lx lo on
 Plaintext letters in the same row
 Each replaced by the letter to the right
 Plaintext letters in the same column
 Each replaced by the letter beneath
 Otherwise
 Each letter in a pair is replaced by the letter that lies in
its own row and the column occupied by the other
plaintext letter in the pair
 Keyword= MONARCHY
Plaintext: HB HD HP HV HX
Ciphertext: YD YC FV FO BV
Playfair Cipher: Decryption
 Simply reverse the process:
 Ciphertext letters in the same row replaced
by the letter to the left
 Ciphertext letters in the same column
replaced by the letter directly above
 Else each letter in a pair is replaced by the letter that
lies in its own row and column occupied by the other
ciphertext letter
 Keyword= MONARCHY

Ciphertext: YD YC FV FO BV
Plaintext: HB HD HP HV HX
Playfair Cipher
“In the Playfair system, there is no rule for
enciphering or deciphering a double letter in the
same digraph. When double letters are encountered
in plaintext in the same digraph, the cryptographer
must break up the double letters with a null letter,
such as inserting an X between them. As a result,
double letters will never be encountered in the
ciphertext, except in error. This is only true of the
Playfair system.” (Basic Cryptanalysis, Issues 34-42 of
Field Manual, United States Department of the Army, 1990)
Playfair Cipher: Example 1
 Keyword: APPLE
 Step 01: APLE
A P L E B
 Step 02: C D F G H
I/J K M N O
Where, I=J
Q R S T U
V W X Y Z

 Step 03: Encrypt “hide the gold”


 Plaintext: HI DE TH EG OL DX
 Ciphertext: CO GP UG GN MB FW
Playfair Cipher: Example 2
 Keyword: JUICE
 Step 01: JUCE or UICE
I/J U C E A
 Step 02: B D F G H
K L M N O
Where, I=J
P Q R S T
V W X Y Z

 Step 03: Encrypt “BALLOON”


 Plaintext: BA LX LO ON
 Ciphertext: HJ MW MK KO
Classical Encryption
Techniques
 Substitution Ciphers
 Monoalphabetic Ciphers
• Caesar Cipher
 Polyalphabetic Ciphers
• Vigenere Cipher
• Playfair Cipher
• Hill Cipher
• One-Time Pad
Hill Cipher
Hill Cipher
Hill Cipher
Overview- Classical
Cryptography

You might also like