Classical Techniques: Substitution  Substitute a character, digit or symbol for each

Classical Techniques: Substitution
 Substitute a character, digit or symbol for each
character in the plaintext
 Discussed:




The Caesar cipher
Monoalphabetic cipher
Playfair cipher
Polyalphabetic cipher
1
Caesar Cipher
 2000 years ago, by Julius Caesar
 A simple substitution cipher, known as Caesar cipher
 Replace each letter with the letter standing 3 places further
down the alphabet
 Plain:
meet me after the toga party
 Cipher: PHHW PH DIWHU WKH WRJD SDUWB
 No key, just one mapping (translation)
0123456...
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DEFGHIJKLMNOPQRSTUVWXYZABC
3456789...
ci=E(3,pi)=(pi+3) mod 26;
pi=D(3,ci)=(ci-3) mod 26
2
Generalized Caesar Cipher
 Can use any shift from 1 to 25, i.e., replace each letter by a
letter a fixed distance away
ci=E(k,pi)=(pi+k) mod 26;
pi=D(k,ci)=(ci-k) mod 26
Shift cipher
Key = k
Key letter: the letter a plaintext A maps to
 e.g. a key letter of F means A maps to F, B to G, …, Y to
D, Z to E
Hence have 26 (25 useful) ciphers
 Key space = 26
3
Brute-Force Cryptanalysis of Caesar Cipher
 Ciphertext only attack
 Charateristics for
success
1. The encryption and
decryption algorithms are
known
2. There are only 25 keys to
try
3. The language of the
plaintext is known and
easily recongnizable
4
Monoalphabetic Cipher
 Increased key space compared to Caesar
cipher
 Alphabet sequence is not required
 What is the key space?
 26! > 4 x 1026
 Monoalphabetic ciphers are easier to break
because they reflect frequency of alphabet
 E = 12.75, T = 9.25, R = 8.50, N = 7.75, etc.
5
Relative Frequency of Letters in English Text
6
Substitution Techniques
Frequency Statistics of Language
In addition to the frequency info of single letters,
the frequency info of two-letter (digram) or threeletter (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
7
Playfair Cipher
Best-known multiple-letter substitution cipher
Digram cipher (digram to digram, i.e., E(pipi+1) =
cici+1 through keyword-based 5x5 transformation
table)
Keyword = 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
Plaintext: H S E A A R M U
Ciphertext: B P I M R M C M
 Great advance over simple monoalphabetic cipher
(26 letters  26x26=676 digrams)
 Can be generalized to polygram cipher
8
Playfair Cipher - Rules
 Repeating plaintext letters are separated with a filler
letter, such as X.
 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.
 Plaintext letters that fall in the same column are each
replaced by the letter beneath, with the top element of
the row circularly following the last.
 Otherwise, each plaintext letter is replaced by the letter
that lies in its own row and the column occupied by the
other plaintext letter.
9
Polyalphabetic Cipher
Typically a set of monoalphabetic substitution rules
is used
Key determines which rule to use
10
Vigenère cipher
 Best-known polyalphabetic ciphers
 Each key letter determines one of 26 Caesar (shift) ciphers
ci = E(pi) = pi + ki mod(key length) mod 26
 Example:
Key:
Plaintext:
Cipheretxt:
deceptivedeceptivedeceptive
wearediscoveredsaveyourself
ZICVTWQNGRZGVTWAVZHCQYGLMGJ
 Keyword is repeated to make a key as long as the plaintext
11
Vigenère cipher - 2
12
Example:
 Encryption
 Decryption
13
Vigenère cipher - 3
Vigenère autokey system: after key is exhausted,
use plaintext for running key (to eliminate the
periodic nature)
Key:
Plaintext:
Cipheretxt:
deceptivewearediscoveredsav
wearediscoveredsaveyourself
ZICVTWQNGKZEIIGASXSTSLVVWLA
14
Transposition (Permutation) Techniques
 Hide the message by rearranging the letter order without
altering the actual letters used
 Rail Fence Cipher
 Write message on alternate rows, and read off cipher row by row
 Example:
M e m a t r h t g p r y
e t e f e t e o a a t
MEMATRHTGPRYETEFETEOAAT
 Block (Columnar) Transposition Ciphers
 Message is written in rectangle, row by row, but read off column by
column; The order of columns read off is the key
 Example:
Key:
4 3 1 2 5 6 7
Plaintext: a t t a c k p
o s t p o n e
d u n t i l t
w o a m x y z
Ciphertext:TTNAAPTMTSUOAODWCOIXKNLYPETZ
15