Lecture 06 - Classical Ciphers - I
Lecture 06 - Classical Ciphers - I
and
Network Security
Classical Ciphers - I
Lecture 06
3
Caesar Cipher
• Earliest known substitution cipher
• Invented by Julius Caesar
• Each letter is replaced by the letter three positions further
down the alphabet.
• 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
Cipher: DEFGHIJKLMNOPQRSTUVWXYZABC
• Example: rgukt nuzvid UJXNW QXCYLG
4
Caesar Cipher
• Mathematically, map letters to numbers:
a, b, c, ..., x, y, z
0, 1, 2, ..., 23, 24, 25
• Then the general Caesar cipher is:
c = EK(p) = (p + k) mod 26
p = DK(c) = (c – k) mod 26
• Can be generalized with any alphabet.
5
Cryptanalysis of Caesar Cipher
• Key space: {0, 1, ..., 25}
• Vulnerable to brute-force attacks.
• E.g., break ciphertext “FkLS WQOVMA“
6
Monoalphabetic Substitution Cipher
7
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.
8
Language Statistics and Cryptanalysis
• Human languages are not random.
• There are tables of single, double & triple letter frequencies for
various languages
9
English Letter Frequencies
10
Statistics for double & triple letters
• In decreasing order of frequency
• Double letters:
th he an in er re es on, …
• Triple letters:
the and ent ion tio for nde, …
11
Use in Cryptanalysis
• Key concept: monoalphabetic substitution does not change
relative letter frequencies
• To attack, we
• calculate letter frequencies for ciphertext
• compare this distribution against the known one
12
Example Cryptanalysis
• Given ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
14
Playfair Cipher
• Not even the large number of keys in a monoalphabetic cipher
provides security.
•
15
Playfair Key Matrix
• Use a 5 x 5 matrix.
• Fill in letters of the key (w/o duplicates).
• Fill the rest of matrix with other letters.
• E.g., key = MONARCHY.
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
16
Encrypting and Decrypting
Plaintext is encrypted two letters at a time.
1. If a pair is a repeated letter, insert filler like 'X’.
2. If both letters fall in the same row, replace each with the letter to its right
(circularly).
3. If both letters fall in the same column, replace each with the letter below
it (circularly).
4. Otherwise, each letter is replaced by the letter in the same row but in the
column of the other letter of the pair.
17
Encrypting and Decrypting
M O N A R Example:
C H Y B D 1. balloon = ba lx lo on
E F G I/J K 2. ar = RM
L P Q S T 3. mu = CM
U V W X Z
4. hs = BP
ea = IM or JM
18
Security of Playfair Cipher
• Equivalent to a monoalphabetic cipher with an alphabet of 26 x 26 =
676 characters.
20
Vigenère Cipher
• Simplest polyalphabetic substitution cipher
• Consider the set of all Caesar ciphers:
{ Ca, Cb, Cc, ..., Cz }
• Key: e.g. security
• Encrypt each letter using Cs, Ce, Cc, Cu, Cr, Ci, Ct, Cy in turn.
• Repeat from start after Cy.
• Decryption simply works in reverse.
21
Example of Vigenère Cipher
• Keyword: deceptive
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ
22
Security of Vigenère Ciphers
• There are multiple (how many?) ciphertext letters corresponding to
each plaintext letter.
• So, letter frequencies are obscured but not totally lost.
24
Thanks