Title: Codes, Ciphers, and CryptographyCh 2'2
1Codes, Ciphers, and Cryptography-Ch 2.2
- Michael A. Karls
- Ball State University
- Fall 2004
2Breaking the Vigenère Cipher
- Suppose we have intercepted the following
ciphertext (handout) - DBZMG AOIYS OPVFH OWKBW XZPJL VVRFG NBKIX DVUIM
OPFQL VVPUD KPRVW OARLW DVLMW AWINZ DAKBW MMRLW
QIICG PAKYU CVZKM ZARPS DTRVD ZWEYG ABYYE YMGYF
YAFHL CMWLW LVCHL MMGYL DBZIF JNCYL OMIAJ JCGMA
IBVRL OPVFW OBVLK OPVUJ ZDVLQ XWDGG IQEYF BTZMZ
DVRMM ANZWA ZVKFQ GWEAL ZFKNZ ZZVCK VDVLQ BWFXU
CIEWW OPRMU JZIYK KWEXA IOIYH ZIKYV GMKNW MOIIM
KADUQ WMWIM ILZHL CMTCH CMINW SBRHV OPVSO
DTCMGHMKCE ZASYD JKRNW YIKCF OMIPS GAFZK JUVGM
GBZJD ZWWNZ ZVLGT ZZFZS GXYUT ZBJCF PAVNZ ZAVWS
IJVZG PVUVQ NKRHF DVXNZ ZKZJZ ZZKYP OIEXX MWDNZ
ZQIMH VKZHY DVKYD GQXYF OOLYK NMJGS YMRML JBYYF
PUSYJ JNRFH CISYL N - We suspect that this message may have been
enciphered using a Vigenère cipher. - How can we decipher the message?
3Breaking the Vigenère Cipher (cont.)
- In order to get an idea of what to do, consider
the following example. - In this example, the keyword VENUS is used with
our Vigenère square handout to encipher a message!
4Breaking the Vigenère Cipher (cont.)
- Example 3 Use the keyword VENUS and the
Vigenère square to encipher the cat in the hat
is near the mat. - Solution
plaintext
ciphertext
plaintext
ciphertext
5Breaking the Vigenère Cipher (cont.)
- How is the word the enciphered?
- the ? OLR, NZZ, and OLR
plaintext
ciphertext
plaintext
ciphertext
6Breaking the Vigenère Cipher (cont.)
- How is the word the enciphered?
- the ? OLR, NZZ, and OLR
plaintext
ciphertext
plaintext
ciphertext
7Breaking the Vigenère Cipher (cont.)
- The third occurrence of the is the same as the
first because the same key letters are used to
encrypt the t, h, and e. - Different key letters are used for the second
the.
plaintext
ciphertext
plaintext
ciphertext
8Breaking the Vigenère Cipher (cont.)
- Notice that the distance between the t in the
first the and the t in the third the is 20
letters. - 20 is a multiple of the length of the keyword
VENUS, which has 5 letters!
plaintext
ciphertext
plaintext
ciphertext
9Breaking the Vigenère Cipher (cont.)
- This is true for Vigenère ciphers in general!
- If a plaintext sequence is repeated at a distance
that is a multiple of the length of the keyword,
then the corresponding ciphertext sequences are
also repeated. - Handout example (Fig. 2.3 from Beutelspacher).
10Breaking the Vigenère Cipher (cont.)
- In 1854, Charles Babbage used this idea to guess
the length of a keyword for a Vigenère cipher! - John Hall Brock Thwaites claimed to have invented
a new cipher. - Babbage told Thwaites that his cipher was the
Vigenère cipher. - Thwaites challenged Babbage to break his cipher.
- Babbage never published this ideawhy?
- In 1863 Friedrich Wilhelm Kasiski independently
discovered the idea of looking for repeated
ciphertext sequences to find a Vigenère ciphers
key length.
11The Kasiski Test
- Look for repeated sequences of three or more
letters in a ciphertext. - Equal pairs can occur too often to be of use.
- Find the distances between these repeated
sequences and list the factors of each distance. - For example, if the distance is d 18 letters,
then the factors are 1, 2, 3, 6, 9, and 18.
12The Kasiski Test (cont.)
- Look for the most commonly occurring factors
greater than 1. - A keyword of length 1 corresponds to a
monoalphabetic cipher! - The most commonly occurring factors are
candidates for the length L of the keyword.
13The Kasiski Test (cont.)
- When using the Kasiski Test, keep the following
in mind - Ciphertext sequences may repeat accidentally at a
distance that is not a multiple of the keyword
length. - The most commonly occurring factors found in in
Step 3 of the Kasiski Test may be a factor of the
keyword length! - Therefore, one may need to consider multiples of
possible keyword lengths as potential keyword
lengths!
14The Kasiski Test (cont.)
- Example 4 Apply the Kasiski Test to the
following ciphertext, which is suspected of being
a Vigenere cipher! - ZRZNSPCWQGFWLWQGFRGRZNSTZBGTRMNEOXCXRPUBSEYWQGHLSI
JKGWDSXSSLSIXKKUJPHKBWHW - For Step 1 of the test, see Mathematica Handout
Kasiski Test Example 4 .
15The Kasiski Test (cont.)
- Other ways to find distances between repeated
sequences of ciphertext - Use a program on the web, such as this one
- http//www.uni-mainz.de/pommeren/Kryptologie/Clas
sic.html - Use Microsoft Words Find and Replace feature.
- The only drawback is you have to find the
repeated sequences by hand.
16The Kasiski Test (cont.)
- Step 2 Make a table of the distances and their
factors greater than or equal to two.
Factors of Distances
17The Kasiski Test (cont.)
- Step 2 Make a table of the distances and their
factors greater than or equal to two.
Factors of Distances
18The Kasiski Test (cont.)
- Step 2 Make a table of the distances and their
factors greater than or equal to two.
Factors of Distances
19The Kasiski Test (cont.)
- Step 2 Make a table of the distances and their
factors greater than or equal to two.
Factors of Distances
20The Kasiski Test (cont.)
- Step 2 Make a table of the distances and their
factors greater than or equal to two.
Factors of Distances
21The Kasiski Test (cont.)
- Step 3 The most commonly occurring factors in
the table are 2, 3, and 6.
Factors of Distances
22The Kasiski Test (cont.)
- The greatest common divisor of all distances
between repeated sequences of ciphertext is 6. - Guess that the keyword length is L 6.
- Note that L 12, 18, or 30 could be possible
(these are multiples of 6).
Factors of Distances
23Using Frequency Analysis to Attack the Vigenère
Cipher
- As Example 4 shows, we can use the Kasiski Test
to get an idea of the keyword length for a
Vigenère cipher. - Now that we know the keyword length, how do we
use this information to break the cipher? - Note that each time a certain keyword letter is
used to encrypt, the same row of the Vigenere
square is used, i.e. the same cipher alphabet is
used! - Therefore, we can apply frequency analysis to the
subsets of the ciphertext encrypted with each
keyword letter!
24Using Frequency Analysis to Attack the Vigenère
Cipher (cont.)
- For example, suppose the keyword in the cipher of
Example 4 is six letters long. - Write the keyword as S1S2S3S4S5S6, with unknown
letters Si to be determined. - Split up the ciphertext in the following way
25Using Frequency Analysis to Attack the Vigenère
Cipher (cont.)
Letter Si of keyword
i
i6
Position of letter in keyword
i12
i18
i24
26Using Frequency Analysis to Attack the Vigenère
Cipher (cont.)
Letter Si of keyword
i
i6
Position of letter in keyword
i12
i18
Column 1 is encrypted by S1
i24
27Using Frequency Analysis to Attack the Vigenère
Cipher (cont.)
Letter Si of keyword
i
i6
Position of letter in keyword
i12
i18
Column 2 is encrypted by S2
i24
28Using Frequency Analysis to Attack the Vigenère
Cipher (cont.)
Letter Si of keyword
i
i6
Position of letter in keyword
i12
i18
Column 3 is encrypted by S3
i24
29Using Frequency Analysis to Attack the Vigenère
Cipher (cont.)
Letter Si of keyword
i
i6
Position of letter in keyword
i12
i18
Column 4 is encrypted by S4
i24
30Using Frequency Analysis to Attack the Vigenère
Cipher (cont.)
Letter Si of keyword
i
i6
Position of letter in keyword
i12
i18
Column 5 is encrypted by S5
i24
31Using Frequency Analysis to Attack the Vigenère
Cipher (cont.)
Letter Si of keyword
i
i6
Position of letter in keyword
i12
i18
Column 6 is encrypted by S6
i24
32Using Frequency Analysis to Attack the Vigenère
Cipher (cont.)
- Since the letters in column 1 are encrypted by
the same cipher alphabet, we can use frequency
analysis on this set of cipher letters to figure
out keyword letter S1. - Repeat with column 2 letters to find S2, etc.
- In this way, frequency analysis is used to crack
a Vigenere cipher!
33Using Frequency Analysis to Attack the Vigenère
Cipher (cont.)
- Example 5 The Kasiski Test has been applied to
the Vigenère ciphertext below. Assuming that
the keyword has length 5, find the subsets of
ciphertext encrypted with each letter. Use
frequency analysis to determine each keyword
letter! - DBZMG AOIYS OPVFH OWKBW XZPJL VVRFG NBKIX DVUIM
OPFQL VVPUD KPRVW OARLW DVLMW AWINZ DAKBW MMRLW
QIICG PAKYU CVZKM ZARPS DTRVD ZWEYG ABYYE YMGYF
YAFHL CMWLW LVCHL MMGYL DBZIF JNCYL OMIAJ JCGMA
IBVRL OPVFW OBVLK OPVUJ ZDVLQ XWDGG IQEYF BTZMZ
DVRMM ANZWA ZVKFQ GWEAL ZFKNZ ZZVCK VDVLQ BWFXU
CIEWW OPRMU JZIYK KWEXA IOIYH ZIKYV GMKNW MOIIM
KADUQ WMWIM ILZHL CMTCH CMINW SBRHV OPVSO
DTCMGHMKCE ZASYD JKRNW YIKCF OMIPS GAFZK JUVGM
GBZJD ZWWNZ ZVLGT ZZFZS GXYUT ZBJCF PAVNZ ZAVWS
IJVZG PVUVQ NKRHF DVXNZ ZKZJZ ZZKYP OIEXX MWDNZ
ZQIMH VKZHY DVKYD GQXYF OOLYK NMJGS YMRML JBYYF
PUSYJ JNRFH CISYL N - Solution Mathematica Handout for Example 5.