Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 24

Network Management and

Security

Classical Encryption Techniques


Cryptanalysis of Monoalphabetic Cipher,
Playfair Cipher

Week 04-I

Shakeel Ahmad
Playfair Cipher
• Symmetric encryption, also referred to as conventional encryption or
single-key encryption, was the only type of encryption in use prior to the
development of publickey
• encryption in the 1970s. It remains by far the most widely used of the two
types of encryption. We examinee a number of symmetric ciphers.
• In this section, we begin with a look at a general model for the symmetric
encryption process; this will enable us to understand the context within
which the algorithms are used.
• Next, we examine a variety of algorithms in use before the computer era.
Finally, we look briefly at a different approach known as steganography.
• Section 4 and 6 introduce the two most widely used symmetric cipher:
DES and AES.
Playfair Cipher
• The Playfair cipher was the first practical digraph substitution cipher.

• The scheme was invented in 1854 by Charles Wheatstone but was


named after Lord Playfair who promoted the use of the cipher.
• In playfair cipher unlike traditional cipher we encrypt a pair of
alphabets(digraphs) instead of a single alphabet.
• 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 Australians
during World War II.
• This was because Playfair is reasonably fast to use and requires no
special equipment.
Playfair Cipher
The technique encrypts pairs of letters (bigrams or digrams),
instead of single letters as in the simple substitution cipher and
rather more complex Vigenère cipher systems then in use.

The Playfair is thus significantly harder to break since the


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

The frequency analysis of bigrams is possible, but considerably


more difficult. With 600 possible bigrams rather than the 26
possible monograms (single symbols, usually letters in this
context), a considerably larger cipher text is required in order to
be useful.
Playfair Cipher
• Superseded

• Playfair is no longer used by military forces because


of the advent of digital encryption devices. This cipher
is now regarded as insecure for any purpose, because
modern computers could easily break it within
microseconds.
• The first published solution of the Playfair cipher was
described in a 19-page pamphlet by Lieutenant 
Joseph O. Mauborgne, published in 1914
Playfair Cipher
The best-known multiple-letter encryption cipher is the Playfair, which treats
digrams in the plaintext as single units and translates these units into ciphertext
digrams.

• Treats digrams in the plaintext as single units and translates these units
into ciphertext digrams
• Based on the use of a 5 x 5 matrix of letters constructed using a keyword

• Invented by British scientist Sir Charles Wheatstone in 1854

• Used as the standard field system by the British Army in World War I and
the U.S. Army and other Allied forces during World War II
Playfair Key Matrix
• Fill in letters of keyword (minus duplicates) from
left to right and from top to bottom, then fill in
the remainder of the matrix with the remaining
letters in alphabetic order
• Using the 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
Playfair Key Matrix
In this case, the keyword is monarchy . The matrix is constructed by filling in the letters of the
keyword (minus duplicates) from left to right and from top to bottom, and then filling in the
remainder of the matrix with the remaining letters in alphabetic order. The letters I and J count as
one letter. 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.
M O N A R
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
C H Y B D
following the last. E F G I/J K

L P Q S T
U V W X Z
Playfair Key Matrix
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).

The Playfair cipher is a great advance over simple monoalphabetic ciphers.

For one thing, whereas there are only 26 letters, there are 26 * 26 = 676 digrams, so that
identification of individual digrams is more difficult. Furthermore, the relative frequencies of
individual letters exhibit a much greater range than that of digrams, making frequency analysis
much more difficult. For these reasons, the Playfair cipher was for a
long time considered unbreakable. It was used as the standard field M O N A R
system by the British Army in World War I and still enjoyed considerable C H Y B D
use by the U.S. Army and other Allied forces during World War II.
E F G I/ K
Despite this level of confidence in its security, the Playfair cipher is J
relatively easy to break, because it still leaves much of the structure L P Q S T
of the plaintext language intact. A few hundred letters of ciphertext are
generally sufficient. U V W X Z
Playfair Key Matrix
• Despite this level of confidence in its security, the Playfair cipher is relatively easy to break,
because it still leaves much of the structure of the plaintext language intact. A few hundred
letters of ciphertext are generally sufficient. One way of revealing the effectiveness of the
Playfair and other ciphers is shown in Figure 3.6. The line labeled plaintext plots a typical
frequency distribution of the 26 alphabetic characters (no distinction between upper and
lower case) in ordinary text. This is also the frequency distribution of any monoalphabetic
substitution cipher, because the frequency values for individual letters are the same, just
with different letters substituted for the original letters.

The plot is developed in the following way: The number of occurrences of each letter in the text
is counted and divided by the number of occurrences of the most frequently used letter. Using
the results of Figure 2.5, we see that e is the most frequently used letter. As a result, e has a
relative frequency of 1, t of 9.056/12.702 0.72, and so on. The points on the horizontal axis
correspond to the letters in order of decreasing frequency.
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
Playfair Key Matrix
Figure 3.6 also shows the frequency distribution that results when the
text is encrypted using the Playfair cipher.

To normalize the plot, the number of occurrences of each letter in the ciphertext was again divided
by the number of occurrences of e in the plaintext.

The resulting plot therefore shows the extent to which the frequency distribution of letters,
which makes it trivial to solve substitution ciphers, is masked by encryption.

If the frequency distribution information were totally concealed in the encryption process, the
ciphertext plot of frequencies would be flat, and cryptanalysis using ciphertext only would be
effectively impossible.
M O N A R
As the figure shows, the Playfair cipher has a flatter distribution than C H Y B D
does plaintext, but nevertheless, it reveals plenty of structure for a
cryptanalyst to work with. The plot also shows the Vigenère cipher, E F G I/ K
discussed subsequently. The Hill and Vigenère curves on the plot J
are based on results reported in [SIMM93].
L P Q S T
U V W X Z
Playfair Cipher Example

The Playfair Cipher Encryption Algorithm:


The Algorithm consists of 2 steps:

1. Generate the key Square(5×5):


2. Algorithm to encrypt the plain text: 
Playfair Cipher Example
Generate the key Square(5×5):

• The key square is a 5×5 grid of alphabets that acts as


the key for encrypting the plaintext. Each of the 25
alphabets must be unique and one letter of the alphabet
(usually J) is omitted from the table (as the table can
hold only 25 alphabets). If the plaintext contains J, then
it is replaced by I.

• The initial alphabets in the key square are the unique


alphabets of the key in the order in which they appear
followed by the remaining letters of the alphabet in
order.
Playfair Cipher Example
• For example:
The key is "monarchy"

Thus the initial entries are

'm', 'o', 'n', 'a', 'r', 'c', 'h', 'y'

followed by remaining characters of

a-z(except 'j') in that order.


Playfair Cipher Example
2. Algorithm to encrypt the plain text: 
The plaintext is split into pairs of two letters (digraphs). If there is an odd number of letters, a Z is added to the last
letter.

For example:

PlainText: "instruments"

After Split: 'in' 'st' 'ru' 'me' 'nt' 'sz'


Playfair Cipher Example
Rules for Encryption:

If both the letters are in the same column: Take the letter below each one (going back to the top if at the bottom).

For example:

Diagraph: "me"

Encrypted Text: cl

Encryption:

m -> c

e -> l
Playfair Cipher Example
• If both the letters are in the same row: Take the letter to the right
of each one (going back to the leftmost if at the rightmost position).

For example:

• Diagraph: "st"

• Encrypted Text: tl

• Encryption:

• s -> t

• t -> l
Playfair Cipher Example
• If neither of the above rules is true: Form a rectangle with the two
letters and take the letters on the horizontal opposite corner of the
rectangle.

• For example:

• Diagraph: "nt"

• Encrypted Text: rq

• Encryption:

• n -> r

• t -> q
Playfair Cipher Example
For example: Plain Text: "instrumentsz“
Encrypted Text: gatlmzclrqtx

Encryption:
i -> g
n -> a
s -> t
t -> l
r -> m
u -> z
m -> c
e -> l
n -> r
t -> q
s -> t
z -> x
Playfair Cipher Example
For example: Plain Text: "instrumentsz“
Encrypted Text: gatlmzclrqtx

Encryption:
i -> g
n -> a
s -> t
t -> l
r -> m
u -> z
m -> c
e -> l
n -> r
t -> q
s -> t
z -> x
Playfair Cryptanalysis
• Like most classical ciphers, the Playfair cipher can be easily cracked if there is
enough text.

• Obtaining the key is relatively straightforward if both plaintext and ciphertext are


known.

• When only the ciphertext is known, brute force cryptanalysis of the cipher involves
searching through the key space for matches between the frequency of occurrence
of digrams (pairs of letters) and the known frequency of occurrence of digrams in
the assumed language of the original message.

• Cryptanalysis of Playfair is similar to that of four-square and two-square ciphers,


though the relative simplicity of the Playfair system makes identifying candidate
plaintext strings easier.
Playfair Cryptanalysis
• Most notably, a Playfair digraph and its reverse (e.g. AB and BA) will decrypt to the
same letter pattern in the plaintext (e.g. RE and ER).

• In English, there are many words which contain these reversed digraphs such as
REceivER and DEpartED.

• Identifying nearby reversed digraphs in the ciphertext and matching the pattern to a
list of known plaintext words containing the pattern is an easy way to generate
possible plaintext strings with which to begin constructing the key.
Playfair Cryptanalysis
• A different approach to tackling a Playfair cipher is the shotgun hill climbing method.
This starts with a random square of letters. Then minor changes are introduced (i.e.
switching letters, rows, or reflecting the entire square) to see if the candidate
plaintext is more like standard plaintext than before the change (perhaps by
comparing the digrams to a known frequency chart).

• If the new square is deemed to be an improvement, then it is adopted and then


further mutated to find an even better candidate. Eventually, the plaintext or
something very close is found to achieve a maximal score by whatever grading
method is chosen.

• This is obviously beyond the range of typical human patience, but computers can
adopt this algorithm to crack Playfair ciphers with a relatively small amount of text.

• Another aspect of Playfair that separates it from four-square and two-square ciphers
is the fact that it will never contain a double-letter digram, e.g. EE. If there are no
double letter digrams in the ciphertext and the length of the message is long enough
to make this statistically significant, it is very likely that the method of encryption is
Playfair.

You might also like