06/06/22 K.Marimuthu,SCSE Network Securi ty 1 Substitution Techniques
Nov 21, 2014
04/08/23 K.Marimuthu,SCSE Network Security 1
Substitution Techniques
04/08/23 K.Marimuthu,SCSE Network Security 2
Classical Ciphers
• Plaintext is viewed as a sequence of elements (e.g., bits or characters)
• Substitution cipher: replacing each element of the plaintext with another element.
• Transposition (or permutation) cipher: rearranging the order of the elements of the plaintext.
• Product cipher: using multiple stages of substitutions and transpositions
04/08/23 K.Marimuthu,SCSE Network Security 3
Classical Substitution Ciphers
• where letters of plaintext are replaced by other letters or by numbers or symbols
• or if plaintext is viewed as a sequence of bits, then substitution involves replacing plaintext bit patterns with ciphertext bit patterns
04/08/23 K.Marimuthu,SCSE Network Security 4
Caesar Cipher
• Earliest known substitution cipher• Invented by Julius Caesar
• Each letter is replaced by the letter three positions further down the alphabet.
• Plain: a b c d e f g h i j k l m n o p q r s t
• Cipher: D E F G H I J K L M N O P Q R S T U V W
u v w x y z
X Y Z A B C
04/08/23 K.Marimuthu,SCSE Network Security 5
Example
• Plain text : meet me after the toga party
• Ciphertext: PHHW PH DIWHU WKH WRJD SDUWB
04/08/23 K.Marimuthu,SCSE Network Security 6
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: (Modified Caesar Cipher)
c = EK(p) =E (k ,p)= (p + k) mod 26
p = DK(c) =D (k ,c)= (c – k) mod 26
04/08/23 K.Marimuthu,SCSE Network Security 7
Cryptanalysis of Caesar Cipher
• Key space: {0, 1, ..., 25} • Vulnerable to brute-force attacks. • Major weakness of Caesar cipher is its Predictability
04/08/23 K.Marimuthu,SCSE Network Security 8
04/08/23 K.Marimuthu,SCSE Network Security 9
Monoalphabetic Substitution Cipher
• Shuffle the letters and map each plaintext letter to a different random ciphertext letter:
• Plain letters: • 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
D K V Q F I B J W P E S C X H T M Y A U O L R G Z N
Plaintext: if we wish to replace letters
Ciphertext: WI RF RWAJ UH YFTSDVF SFUUFYA
04/08/23 K.Marimuthu,SCSE Network Security 10
Homophonic Cipher
• One Plaintext alphabet is replaced with fixed alphabet set.
• Ex: A is replaced by the set { D,H,P,R}
04/08/23 K.Marimuthu,SCSE Network Security 11
PolyGram Cipher
• Replacement of plaintext happens block-by-block
• Ex:
plaintext: Hello Hell
Ciphertext: YUQQW TEUI
04/08/23 K.Marimuthu,SCSE Network Security 12
Playfair Cipher
• One approach to improving security is to encrypt multiple letters at a time.
• The Playfair Cipher is the best known such cipher.
• Invented by Charles Wheatstone in 1854, but named after his friend Baron Playfair.
04/08/23 K.Marimuthu,SCSE Network Security 13
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 =PLAYFAIR EXAMPLE
PP LL AA YY FF
I/JI/J RR EE XX MM
BB CC DD GG HH
KK NN OO QQ SS
TT UU VV WW ZZ
04/08/23 K.Marimuthu,SCSE Network Security 14
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 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.
04/08/23 K.Marimuthu,SCSE Network Security 15
Example
• Plaintext: My name is Atul
My na me is at ul
• Ciphertext: XF OL IX MK PV LR
• Example : Plaintext: Balloon
Ba ll oo n ba lx lo on
04/08/23 K.Marimuthu,SCSE Network Security 16
Polyalphabetic Substitution Ciphers
• A sequence of monoalphabetic ciphers (M1, M2, M3, ..., Mk) is used in turn to encrypt letters.
• A key determines which sequence of ciphers to use.• Each plaintext letter has multiple corresponding ciphertext
letters.• This makes cryptanalysis harder since the letter frequency
distribution will be flatter.
04/08/23 K.Marimuthu,SCSE Network Security 17
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.
04/08/23 K.Marimuthu,SCSE Network Security 18
04/08/23 K.Marimuthu,SCSE Network Security 19
Example
• write the plaintext out • write the keyword repeated above it• use each key letter as a caesar cipher key • encrypt the corresponding plaintext letter• eg using keyword deceptive
key: deceptivedeceptivedeceptive
plaintext: we are discovered save yourself
wearediscoveredsaveyourself
ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ
04/08/23 K.Marimuthu,SCSE Network Security 20
Autokey cipher• ideally want a key as long as the message• Vigenère proposed the autokey cipher • with keyword is prefixed to message as key• knowing keyword can recover the first few letters • use these in turn on the rest of the message• but still have frequency characteristics to attack • eg. given key deceptive
key: deceptivewearediscoveredsav
plaintext: wearediscoveredsaveyourself
ciphertext:ZICVTWQNGKZEIIGASXSTSLVVWLA
04/08/23 K.Marimuthu,SCSE Network Security 21
Hill Cipher• Multiletter cipher
• Invented by the mathematician Lester Hill in 1929
• m successive Plaintext letters encrypted at a time• Substitution is determined by m linear equations• For each character ,numerical value is assigned a=0,b=1,c=2,………..z=25
For m=3,system can be described as follows
04/08/23 K.Marimuthu,SCSE Network Security 22
Hill Cipher ….
04/08/23 K.Marimuthu,SCSE Network Security 23
C=KP mod 26C ,P are column Vectors of length 3,representing
ciphertext and plain text. K is 3x3 matrix, key
04/08/23 K.Marimuthu,SCSE Network Security 24
Hill Cipher …..
• Ex: Plain text: paymoremoney
04/08/23 K.Marimuthu,SCSE Network Security 25
Hill cipher…
• Ciphertext: LNSHDLEWMTRW
• For decryption,