You are on page 1of 63

Classical Encryption Techniques

 Substitution Techniques
 Caesar Cipher
 Monoalphabetic Ciphers
 Polyalphabetic Ciphers
 Playfair Cipher
 Hill Cipher
 Transposition Techniques
 Rotor Machines
 Steganography

1 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Caesar Cipher
 Caesar cipher, also known as Caesar's
cipher, the shift cipher, Caesar's code or
Caesar shift, is one of the simplest and
most widely known encryption techniques.

 It is a type of substitution cipher in which


each letter in the plaintext is replaced by a
letter some fixed number of positions
down the alphabet.

2 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Caesar Cipher
 It’s simply a type of substitution cipher, i.e., each letter of a given text
is replaced by a letter some fixed number of positions down the
alphabet.
 The Caesar cipher involves replacing each letter of the alphabet with
the letter standing three places further down the alphabet.
 For example,

3 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Caesar Cipher
 Let us assign a numerical equivalent to each letter:

 Then the algorithm can be expressed as follows. For each plaintext


letter ‘p’, substitute the ciphertext letter ‘C’

4 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Caesar Cipher
 A shift may be of any amount, so that the general Caesar algorithm is

 where k, takes on a value in the range 1 to 25.


 The decryption algorithm is simply

5 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Caesar Cipher
Use Caesar cipher with key = 15 to encrypt the message “hello”
 Using the encryption algorithm

 Plaintext: h – 07 Encryption: (07+15) mod 26 Ciphertext: 22 – W


 Plaintext: e – 04 Encryption: (04+15) mod 26 Ciphertext: 19 – T
 Plaintext: l – 11 Encryption: (11+15) mod 26 Ciphertext: 00 – A
 Plaintext: l – 11 Encryption: (11+15) mod 26 Ciphertext: 00 – A
 Plaintext: o – 14 Encryption: (14+15) mod 26 Ciphertext: 03 – D
The result is “WTAAD”

6 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Caesar Cipher
Use Caesar cipher with key = 15 to encrypt the message “hello”
 Using the decryption algorithm

 Plaintext:W – 22 Encryption: (22-15) mod 26 Ciphertext: 07 -- h


 Plaintext:T – 19 Encryption: (19-15) mod 26 Ciphertext: 04 -- e
 Plaintext:A – 00 Encryption: (00-15) mod 26 Ciphertext: 11 -- l
 Plaintext:A – 00 Encryption: (00-15) mod 26 Ciphertext: 11 -- l
 Plaintext: D – 03 Encryption: (03-15) mod 26 Ciphertext: 14 -- o
The result is “hello”

7 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Additive Cipher

8 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Cryptanalysis of Caesar Cipher

 The encryption and decryption algorithms are known.


 There are only 25 keys to try.
 The language of the plaintext is known and easily recognizable.

9 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Cryptanalysis of Caesar Cipher
 Eve has intercepted the ciphertext “UVACLYFZLJBYL”. Show
how she can use a brute-force attack to break the cipher.
 Solution:
 Eve tries keys from 1 to 7. With a key of 7, the plaintext is “not very
secure”, which makes sense.

10 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Cryptanalysis of Caesar Cipher
Frequency of characters in English

11 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Cryptanalysis of Caesar Cipher
Eve has intercepted the following ciphertext. Using a statistical attack,
find the plaintext.

Solution
When Eve tabulates the frequency of letters in this ciphertext, she
gets: I =14, V =13, S =12, and so on. The most common character is I
with 14 occurrences.This means key = 4.

12 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Multiplicative Cipher

13 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Multiplicative Cipher
 We use a multiplicative cipher to encrypt the message “hello”
with a key of 7.The ciphertext is “XCZZU”.

14 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Affine Cipher

15 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Affine Cipher
 Use an affine cipher to encrypt the message “hello” with the
key pair (7, 2).

16 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Monoalphabetic Ciphers
 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.
 A better solution is to create a mapping between each plaintext
character and the corresponding ciphertext character.
 An example key for monoalphabetic substitution cipher:

The size of the key space is 26! (almost 4x10^26).


This makes a brute force attack extremely difficult.

17 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Monoalphabetic Ciphers
 We can use the key in above slide to encrypt the message

 The resultant cipher text is:

18 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Polyalphabetic Cipher
 In polyalphabetic substitution, each occurrence of a character may
have a different substitute.
 The relationship between a character in the plaintext to a character
in the ciphertext is one-to-many.
Auto Key Cipher:
 The key is a stream of subkeys, in which each subkey is used to
encrypt the corresponding character in the plaintext.

19 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Polyalphabetic Cipher
 Assume that Alice and Bob agreed to use an autokey cipher with
initial key value k1 = 12.
 Now Alice wants to send Bob the message “Attack is today”.
Enciphering is done character by character.

The first subkey can be only one of 25 values (1 to 25), i.e. small key domain.

20 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher

 The Playfair cipher or Playfair square


or Wheatstone-Playfair cipher is a
manual symmetric encryption technique
and was the first literal digram substitution
cipher.

 The scheme was invented in 1854 by


Charles Wheatstone, but bears the name of
Lord Playfair for promoting its use.

21 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher

 The technique encrypts pairs of letters (bigrams or digrams), instead


of single letters as in the simple substitution cipher.

 The Playfair is thus significantly harder to break since the frequency


analysis used for simple substitution ciphers does not work with it.

 It was used for tactical purposes by British forces in the Second Boer
War and in World War I and for the same purpose by the British and
Australians during World War II.

22 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher
 The Playfair cipher uses a 5 by 5 table containing a key word or phrase.
 Memorization of the keyword and 4 simple rules was all that was
required to create the 5 by 5 table and use the cipher.

KEYWORD or PHRASE
 To generate the key table, one would first fill in the spaces in the table (a
modified Polybius square) with the letters of the keyword (dropping any
duplicate letters),
 Then fill the remaining spaces with the rest of the letters of the alphabet in
order (usually omitting "J" or "Q" to reduce the alphabet to fit; other
versions put both "I" and "J" in the same space).

23 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher
KEYWORD or PHRASE (OR)
 The key can be written in the top rows of the table, from left to right,
or in some other pattern, such as a spiral beginning in the upper-left-
hand corner and ending in the center.
 The keyword together with the conventions for filling in the 5 by 5 table
constitute the cipher key.

24 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher: Substitution Rules

 If both letters are the same (or only one letter is left), add an
"X" after the first letter.
 Encrypt the new pair and continue. Some variants of Playfair use "Q" instead
of "X", but any letter, itself uncommon as a repeated pair, will do.

 If the letters appear on the same row of your table, replace


them with the letters to their immediate right respectively
 (wrapping around to the left side of the row if a letter in the original pair was
on the right side of the row)

25 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher: Substitution Rules

 If the letters appear on the same column of your table, replace


them with the letters immediately below respectively
 (wrapping around to the top side of the column if a letter in the original pair
was on the bottom side of the column).

 If the letters are not on the same row or column, replace them
with the letters on the same row respectively but at the other
pair of corners of the rectangle defined by the original pair.
 The order is important – the first letter of the encrypted pair is the one that
lies on the same row as the first letter of the plaintext pair.

26 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher
Using "playfair example" as the key (assuming that I and J are interchangeable),
the table becomes (omitted letters in red):

27 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher
 Encrypting the message "Hide the gold in the tree stump"
(note the null "X" used to separate the repeated "E"s) :

28 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher

 1.The pair HI forms a rectangle, replace it with BM

29 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher

 2.The pair DE is in a column, replace it with OD

30 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher

 3.The pair TH forms a rectangle, replace it with ZB

31 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher

 4.The pair EG forms a rectangle, replace it with XD

32 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher

 5.The pair OL forms a rectangle, replace it with NA

33 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher
 6.The pair DI forms a rectangle, replace it with BE
 7.The pair NT forms a rectangle, replace it with KU
 8.The pair HE forms a rectangle, replace it with DM
 9.The pair TR forms a rectangle, replace it with UI
 10.The pair EX (X inserted to split EE) is in a row, replace it with XM

34 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher
 11.The pair ES forms a rectangle, replace it with MO
 12.The pair TU is in a row, replace it with UV
 13.The pair MP forms a rectangle, replace it with IF

 Ciphertext: BM OD ZB XD NA BE KU DM UI XM MO UV IF

 Thus the message "Hide the gold in the tree stump" becomes
"BMODZ BXDNA BEKUD MUIXM MOUVI F".

35 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Playfair Cipher
 Let us encrypt the plaintext “hello” using the key

36 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Hill Cipher
 In classical cryptography, the Hill cipher is a polygraphic
substitution cipher based on linear algebra.
 Invented by Lester S. Hill in 1929, it was the first polygraphic cipher
in which it was practical (though barely) to operate on more than
three symbols at once.
 The following discussion assumes an elementary knowledge of
matrices.

37 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Hill Cipher
 Each letter is represented by a number modulo 26.

 To encrypt a message, each block of n letters (considered as an n-


component vector) is multiplied by an invertible n × n matrix, against
modulus 26.
 To decrypt the message, each block is multiplied by the inverse of the
matrix used for encryption.

38 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Hill Cipher
 We define the inverse M-1 of a square matrix M by the equation
M(M-1) = M-1M = I
 where I is the identity matrix. I

 The matrix used for encryption is the cipher key and it should be
chosen randomly from the set of invertible n × n matrices (modulo 26).

39 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Hill Cipher
 Consider the message 'ACT', and the key below

 Since 'A' is 0, 'C' is 2 and 'T' is 19, the message is the vector:

40 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Hill Cipher
 Thus the enciphered vector is given by:

 which corresponds to a ciphertext of 'POH‘


 In order to decrypt, we turn the ciphertext back into a vector, then
simply multiply by the inverse matrix of the key
 We find that, modulo 26, the inverse of the matrix used in the
previous example is: matrix

41 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Hill Cipher
 Decryption of ‘POH’:

 which gets us back to 'ACT', as expected

42 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Hill Cipher
Two complications exist in picking the encrypting matrix:
1. Not all matrices have an inverse (see invertible matrix). The matrix
will have an inverse if and only if its determinant is not zero.
2. The determinant of the encrypting matrix must not have any
common factors with the modular base.
For our example key matrix:

 So, modulo 26, the determinant is 25. Since this has no common factors
with 26, this matrix can be used for the Hill cipher.

43 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Transposition Cipher
 A transposition cipher does not substitute one symbol for another,
instead it changes the location of the symbols.
 Simple transposition ciphers, which were used in the past, are keyless.
 The simplest such cipher is the rail fence technique, in which the
plaintext is written down as a sequence of diagonals and then read off
as a sequence of rows.
Example 1:To send the message “Meet me at the park” to Bob,Alice writes

She then creates the ciphertext “MEMATEAKETETHPR”.

44 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Transposition Cipher
Example 2:
 Alice and Bob can agree on the number of columns and use the second
method. Alice writes the same plaintext, row by row, in a table of four
columns.

 She then creates the ciphertext “MMTAEEHREAEKTTP”.

45 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Transposition Cipher
 The cipher in Example 2 is actually a transposition cipher.
 The following shows the permutation of each character in the plaintext
into the ciphertext based on the positions.

 The second character in the plaintext has moved to the fifth position in the
ciphertext;
 The third character has moved to the ninth position; and so on. Although
the characters are permuted,
 There is a pattern in the permutation: (01, 05, 09, 13), (02, 06, 10, 13), (03, 07,
11, 15), and (08, 12).
 In each section, the difference between the two adjacent numbers is 4.

46 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Keyed Transposition Cipher

 The keyless ciphers permute the characters by using writing


plaintext in one way and reading it in another way.

 The permutation is done on the whole plaintext to create the whole


ciphertext.

 Another method is to divide the plaintext into groups of


predetermined size, called blocks, and then use a key to permute the
characters in each block separately.

47 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Keyed Transposition Cipher
 Alice needs to send the message “Enemy attacks tonight” to Bob.

 The key used for encryption and decryption is a permutation key, which
shows how the characters are permuted.

 The permutation yields

48 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Keyed Transposition Cipher

49 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Keyed Transposition Cipher

 In the above Example a single key was used in two directions for the
column exchange: downward for encryption, upward for decryption.

 It is customary to create two keys.

50 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Keyed Transposition Cipher
 Key inversion in a transposition cipher

51 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Double Transposition Ciphers

52 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Rotor Machines
 Before modern ciphers, rotor machines were most common
complex ciphers in use.
 Widely used in WW2 (German Enigma, Allied Hagelin, Japanese
Purple)
 implemented a very complex, varying substitution cipher

 Used a series of cylinders, each giving one substitution, which rotated


and changed after each letter was encrypted
 with 3 cylinders have 263=17576 alphabets

53 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Rotor Machines :Hagelin Rotor Machine

54 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Rotor Machines
 The machine consists of a set of independently rotating
cylinders through which electrical pulses can flow.
 Each cylinder has 26 input pins and 26 output pins, with
internal wiring that connects each input pin to a unique output
pin.

55 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


56 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT
Stream and Block Ciphers
 The literature divides the symmetric ciphers into two broad
categories: stream ciphers and block ciphers.
 Although the definitions are normally applied to modern
ciphers, this categorization also applies to traditional ciphers.

57 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Stream Ciphers
 Call the plaintext stream P, the ciphertext stream C, and the
key stream K.

58 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Block Ciphers
 In a block cipher, a group of plaintext symbols of size m (m > 1)
are encrypted together creating a group of ciphertext of the
same size.
 A single key is used to encrypt the whole block even if the key
is made of multiple values.

59 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Combination
 In practice, blocks of plaintext are encrypted individually, but
they use a stream of keys to encrypt the whole message block
by block.
 In other words, the cipher is a block cipher when looking at
the individual blocks, but it is a stream cipher when looking at
the whole message considering each block as a single unit.

60 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Steganography
 An alternative to encryption
 Hides existence of message
 using only a subset of letters/words in a longer message
marked in some way
 using invisible ink, selected marking, Pin punctures
 hiding in LSB in graphic image or sound file
 hide in “noise”
 has drawbacks
 high overhead to hide relatively few info bits
 advantage is can obscure encryption use

61 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Steganography

62 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT


Thank You..!!

63 Dr. R.K.Mugelan, Asst. Prof. (Sr), SENSE, VIT

You might also like