Professional Documents
Culture Documents
Classical Encryption Techniques: Cryptanalysis of Monoalphabetic Cipher, Playfair Cipher
Classical Encryption Techniques: Cryptanalysis of Monoalphabetic Cipher, Playfair Cipher
Security
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.
• 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
• 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).
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
For example:
PlainText: "instruments"
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.
• 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.
• 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).
• 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.