4. (a) Substitution Ciphers
• 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.
1. Ceaser Cipher
2. Monoalphabetic Cipher
3. Playfair Cipher
4. Hill Cipher
5. Polyalphabetic Cipher (Vigenere cipher)
5. (a.1). Caesar Cipher
• The earlier known and simplest substitution cipher
by Julius Caesar.
• Letters are replaced by other letters or symbols.
• Replacing each letter of alphabet with letter standing
three places further down the alphabet.
• Example: C = (p+3) mod 26
8. Shift cipher
• Key = 2,3,4,…………
• Shift cipher with key = 3 is called as Caesar cipher.
• Example:
– Plaintext: neso
– Key: 4
– Ciphertext: RIWS
9. Pros and Cons of Caesar cipher
• Pros:
1. Simple
2. Easy to implement
• Cons:
1. The encryption and decryption algorithms are
known.
2. There are only 25 keys to try. (Vulnerable to
Brute force attack).
3. The language of the plaintext is known and easily
recognizable.
10. Exercise
• Encrypt the plaintext “crytography” using shift
cipher (key = 4).
• Encrypt “neso” using shift cipher (key = 0).
11. (a.2) Monoalphabetic Cipher
• The ‘cipher’ line can be any permutation of the 26 alphabetic
characters.
• Permutation:
– 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.
– Example:
S = {a,b,c}
There are six permutations of S
• abc
• acb
• bac
• bca
• cab
• cba
There are (3!) 6 possible combinations
12. • Each plaintext letter maps to a different random ciphertext
letter.
• Rather than just shifting the alphabet, this could shuffle
(jumble) the letters arbitrarily.
• No uniform key difference between the plaintext and
ciphertex, it can be permutation.
• Eliminate brute-force techniques for cryptanalysis.
• Nature of plain text is known because the language used is
English.
14. Drawback with the nature of the language.
Relative frequency of English letter
15. Pros and Cons
• Pros:
1. Better security than Caesar cipher.
• Cons:
1. Easy to break because they reflect the frequency
data of the original alphabet.
2. Prone to guessing attack using the English letter
frequency of occurrence of letters.
3. A countermeasure is to provide multiple
substitutes, know as homophones, for a single
letter.
16. (a.3) Playfair Cipher
• Aka Playfair square or Wheatstone-Playfair
cipher.
• Invented in 1854 by Charles Wheatstone.
• Symmetric encryption technique i.e same key
is used for both encryption & decryption.
• Digram substitution technique.
17. Rules
• Rules to create 5 x 5 key matrix (or) playfair
square:
– Playfair square is filled row-by-row, starting with the
keyword followed by the rest of the alphabet.
– ‘J’ and ‘I’ placed in the same cell of key matrix.
– No repeating letters in key matrix.
• Rules to prepare message:
– Digrams – split the plaintext into pairs.
– Split all duplicate letters by inserting filler letter ‘X’.
– If there is an odd letter at the end of the message, insert
filler letter ‘X’.
– Ignore all spaces.
18. Rules
• Rules to encrypt message:
– If the pairs are in same row:
• Move each letter || right one.
• Up on reaching end of the table, wrap around.
– If the pairs are in same column:
• Move each letter || down one.
• Up on reaching end of the table, wrap around.
– If the pairs forms a rectangle:
• Swap ||the letters with the ones on the end of the rectangle.
• Rules to decrypt message:
– If the pairs are in same row:
• Move each letter || left one.
• Up on reaching end of the table, wrap around.
– If the pairs are in same column:
• Move each letter || up one.
• Up on reaching end of the table, wrap around.
– If the pairs forms a rectangle:
• Swap ||the letters with the ones on the end of the rectangle.
19. Playfair Matrix (or) Key Matrix
• 5 x 5 matrix constructed using a keyword
Example : consider the key “Monarchy”.
20. Example - 1
• Given;
• Key: MONARCHY
• PlainText: attack
• Digrams: at ta ck
28. (a.4). Hill Cipher
• Encrypt group of letters such as digrams,
trigraphs, polygraphs.
• Developed by Lester Hill in 1929.
• Encrypts a group of letters: digraph, trigraph,
or polygraph.
29. Review few terminologies from linear algebra
• Concepts to be known:
– Matrix arithmetic modulo 26.
– Square matrix (no.of rows = no.of columns).
– Determinant.
– Multiplicative inverse.
31. Example – 1 (Encryption )
• Given; Plain Text = ATTACK, and key
• Step1: Key matrix must be a square matrix.
– Ex: Consider the key
• Step2: Divide the plain text into a vector component , where
the size is based on key size.
– If the key size is 2x2, then consider the vector of length 2, if the size is
3x3, then consider the vector of length 3, and so on.
– Ex: consider the plain text P = ATTACK, then the vector component
will be;
32. • Step3: Assign numerical equivalent to each
letters in plain text.
• Ex:
33. • Step4: Convert the cipher text using the
following;
• C = E (K,P) = K x P mod 26
Plain Text: ATTACK
Cipher Text: FKMFIO
34. Decryption in Hill cipher
• Decryption:
– P = D (K,C) = C x K-1
mod 26
• Decryption requires K-1
,the inverse matrix K
35. Example – 1 (Decryption )
• Step1: Consider , where
• Step2: Find determinant of K
NOTE:
53. (a.5). Polyalphabetic Ciphers
• To improve on the simple monoalphabtic
technique.
• Features:
– Symbol in plaintext is mapped to multiple
substitution alphabets.
– The relationship between a character in the plain
text and the characters in the cipher text is one to
many.
54. Vigenere Cipher
• It consists of the 26 Caesar ciphers with shifts
of 0 through 25.
• Encryption process:
– Ci = (Pi + Ki ) mod 26
• Where Ci is the cipher text at ith
position.
• Decryption process:
– Pi = (Ci – Ki ) mod 26
– Where Pi is the plain text at ith
position.
55. Example
• Given;
– PlainText: wearediscoveredsaveyourself
– Key: deceptive
• Encryption Process:
– Step1: Repeat the key as long as plaintext gets
extended.
– PlainText: wearediscoveredsaveyourself
– Key: deceptivedeceptivedeceptive
56. • Step2: Assign numerical equivalent to each
letters in the key and plain text.
– Then use Ci = (Pi + Ki ) mod 26
• Step3: Replace the numbers in CiperText with
associated alphabet.
PlainText: wearediscoveredsaveyourself
CipherText: ZICVTWQNGRZGVTWAVZHCQYGLMGJ
57. Vigenere cipher - Cryptanalysis
• Determining the length of the keyword.
• Key and the plaintext share the same
frequency distribution of letters, a statistical
technique can be applied.
58. Auto key system
• The periodic nature of the keyword can be
eliminated by using a non-repeating keyword
that is as long as the message itself.
• Vigenere proposed autokey system, in which a
keyword is concatenated with the plaintext
itself to provide a running key.
– Example:
• PlainText: wearediscoveredsaveyourself
• Key: deceptivewearediscoveredsav
Editor's Notes
#5:Each alphabet is assigned with the number starting form 0.
#6:C = (p+k) mod 26
Consider p = n and the letter equivalent to 16 in the table is q.
C = (13+3) mod 26 = 16 mod 26 = 16
Letter equivalent to 16 in the table is q.
#11:With only 25 possible keys, the Caesar cipher is far from secure. A dramatic increase in the key space can be achieved by allowing an arbitrary substitution, where the translation alphabet can be any permutation of the 26 alphabetic characters.
See example translation alphabet, and an encrypted message using it.
#13:We can randomly map it to any letter even a permutation is allowed.
The difference b/w the p.txt and c.txt is not uniform unlike shift cipher and caesar cipher.