You are on page 1of 15

20CS2222

COMPUTER NETWORKS AND SECURITY

© 2020-21 KL University – The contents of this presentation are an intellectual and copyrighted property of KL
University. ALL RIGHTS RESERVED

1
Session-38

Substitution Techniques

© 2020-21 KL University – The contents of this presentation are an intellectual and copyrighted property of KL
University. ALL RIGHTS RESERVED
2
Substitution Techniques
A character of plaintext is replaced by another character
or
A sequence of bits of plain text is replaced by another
sequence of bits.

3
Caesar Cipher
• It replaces each letter by next 3rd letter
example: meet me after the toga party
PHHW PH DIWHU WKH WRJD SDUWB
• Can define transformation as:
plain: 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 = IN
cipher :D E F G H I J K L M N O P Q R S T U V W X Y Z A B C = OUT

• If a=0, b=1, … z =25, then for each plaintext letter p,


substitute the ciphertext letter C,
C = E(k, p) = (p + k) mod (26) for Encryption
p = D(k, C) = (C – k) mod (26) for Decryption
where k takes on a value in the range 1 to 25.
4
Brute-Force Cryptanalysis of Caesar Cipher

5
Caesar Cipher
• Three important characteristics of this problem enabled
us to use a brute-force cryptanalysis:
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
recognizable.

6
Monoalphabetic Cipher
• Rather than just shifting the alphabet could shuffle the letters
arbitrarily
• Each plaintext letter maps to a different random cipher text
letter
• Hence key is 26 letters long
Letters: abcdefghijklmnopqrstuvwxyz
Key : DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
• If, instead, the "cipher" line can be any permutation of the 26
alphabetic characters, then there are 26! or greater than 4 x
1026 possible keys.4x1026 Keys are possibe, is it secure ? No.
7
8
Language character frequency analysis
cipher text (120 characters) =
ZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
• The relative frequencies of the letters in the cipher text in % :

• Compare this frequencies with a standard frequency


distribution

9
English Letter Frequencies

10
Playfair Cipher
• Not even the large number of keys in a monoalphabetic
cipher provides security
• So we can go for multiple letters substitution at a time
• The Play fair Cipher is an example of 2 letter substitution
at a time

11
Playfair Key Matrix
• A 5X5 matrix of letters based on a keyword
• fill the letters of keyword in table first, then other letters
• using the keyword MONARCHY the table is

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

12
Playfair Cipher Encryption
Plaintext is encrypted two letters at a time, according to the following
rules:
1. Repeating plaintext letters that are in the same pair are separated
with a filler letter, such as x, so that balloon would be treated as ba lx lo
on.
2. Two 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. For example, ar is encrypted as RM.
3. Two plaintext letters that fall in the same column are each replaced by
the letter beneath, with the top element of the column circularly
following the last. For example, mu is encrypted as CM.
4. Otherwise, each plaintext letter in a pair is replaced by the letter that
lies in its own row and the column occupied by the other plaintext letter.
Thus, hs becomes BP and ea becomes IM (or JM, as the encipherer
wishes).

13
Play fair Example
• PlainText: "instruments"
• After Split: 'in' 'st' 'ru' 'me' 'nt' 'sz‘
• Here z is padded to make even number of characters
• Key text: Monarchy
• Plain text: instruments
• Cipher text: gatlmzclrqtx

14
Security of Playfair Cipher
• Security is much improved over monoalphabetic cipher,
because 26 x 26 = 676 pairs are possible.
• We need a 676 entry frequency table to analyse (versus
26 for a monoalphabetic)
• It was widely used for many years by US & British
military
• It can be broken, given a few hundred letters

15

You might also like