1 codes, ciphers, and cryptography-ch 2.2 michael a. karls ball state university

33
1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

Upload: albert-jordan

Post on 03-Jan-2016

226 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

1

Codes, Ciphers, and Cryptography-Ch 2.2

Michael A. Karls

Ball State University

Page 2: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

2

Breaking 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?

Page 3: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

3

Breaking 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!

Page 4: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

4

Breaking 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:

V E N U S V E N U S V E N U

t h e c a t i n t h e h a t

O L R W S O M A N Z Z L N N

S V E N U S V E N U S V

i s n e a r t h e m a t

A N R R U J O L R G S O

plaintext

ciphertext

plaintext

ciphertext

Page 5: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

5

Breaking the Vigenère Cipher (cont.) How is the word “the” enciphered? “the” OLR, NZZ, and OLR

V E N U S V E N U S V E N U

t h e c a t i n t h e h a t

O L R W S O M A N Z Z L N N

S V E N U S V E N U S V

i s n e a r t h e m a t

A N R R U J O L R G S O

plaintext

ciphertext

plaintext

ciphertext

Page 6: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

6

Breaking the Vigenère Cipher (cont.) How is the word “the” enciphered? “the” OLR, NZZ, and OLR

V E N U S V E N U S V E N U

t h e c a t i n t h e h a t

O L R W S O M A N Z Z L N N

S V E N U S V E N U S V

i s n e a r t h e m a t

A N R R U J O L R G S O

plaintext

ciphertext

plaintext

ciphertext

Page 7: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

7

Breaking 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”.

V E N U S V E N U S V E N U

t h e c a t i n t h e h a t

O L R W S O M A N Z Z L N N

S V E N U S V E N U S V

i s n e a r t h e m a t

A N R R U J O L R G S O

plaintext

ciphertext

plaintext

ciphertext

Page 8: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

8

Breaking 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!

V E N U S V E N U S V E N U

t h e c a t i n t h e h a t

O L R W S O M A N Z Z L N N

S V E N U S V E N U S V

i s n e a r t h e m a t

A N R R U J O L R G S O

plaintext

ciphertext

plaintext

ciphertext

Page 9: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

9

Breaking 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).

Page 10: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

10

Breaking 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 idea—why? In 1863 Friedrich Wilhelm Kasiski independently

discovered the idea of looking for repeated ciphertext sequences to find a Vigenère cipher’s key length.

Page 11: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

11

The Kasiski Test

1. Look for repeated sequences of three or more letters in a ciphertext.

Equal pairs can occur too often to be of use.

2. 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.

Page 12: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

12

The Kasiski Test (cont.)

3. 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.

Page 13: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

13

The 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!

Page 14: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

14

The Kasiski Test (cont.)

Example 4: Apply the Kasiski Test to the following ciphertext, which is suspected of being a Vigenere cipher!

ZRZNSPCWQGFWLWQGFRGRZNSTZBGTRMNEOXCXRPUBSEYWQGHLSIJKGWDSXSSLSIXKKUJPHKBWHW

For Step 1 of the test, see Simon Singh's Vigenère Cipher Cracking Tool.

Page 15: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

15

The Kasiski Test (cont.)

Other ways to find distances between repeated sequences of ciphertext:

Use a program on the web – check with Google, but watch out for viruses!

Use Microsoft Word’s Find and Replace feature.• The only drawback is you have to find the repeated

sequences “by hand”.

Page 16: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

16

The Kasiski Test (cont.)

Step 2: Make a table of the distances and their factors greater than or equal to two.

Distance 2 3 4 5 6 9 10 12 15 18 30

6

12

18

30

Factors of Distances

Page 17: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

17

The Kasiski Test (cont.)

Step 2: Make a table of the distances and their factors greater than or equal to two.

Distance 2 3 4 5 6 9 10 12 15 18 30

6 x x x

12

18

30

Factors of Distances

Page 18: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

18

The Kasiski Test (cont.)

Step 2: Make a table of the distances and their factors greater than or equal to two.

Distance 2 3 4 5 6 9 10 12 15 18 30

6 x x x

12 x x x x x

18

30

Factors of Distances

Page 19: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

19

The Kasiski Test (cont.)

Step 2: Make a table of the distances and their factors greater than or equal to two.

Distance 2 3 4 5 6 9 10 12 15 18 30

6 x x x

12 x x x x x

18 x x x x x

30

Factors of Distances

Page 20: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

20

The Kasiski Test (cont.)

Step 2: Make a table of the distances and their factors greater than or equal to two.

Factors of Distances

Distance 2 3 4 5 6 9 10 12 15 18 30

6 x x x

12 x x x x x

18 x x x x x

30 x x x x x x x

Page 21: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

21

The Kasiski Test (cont.)

Step 3: The most commonly occurring factors in the table are 2, 3, and 6.

Distance 2 3 4 5 6 9 10 12 15 18 30

6 x x x

12 x x x x x

18 x x x x x

30 x x x x x x x

Factors of Distances

Page 22: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

22

The 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).

Distance 2 3 4 5 6 9 10 12 15 18 30

6 x x x

12 x x x x ?

18 x x x x ?

30 x x x x x x ?

Factors of Distances

Page 23: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

23

Using 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!

Page 24: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

24

Using 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:

Page 25: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

25

Using Frequency Analysis to Attack the Vigenère Cipher (cont.)

S1 S2 S3 S4 S5 S6

Z R Z N S P

C W Q G F W

L W Q G F R

G R Z N S T

Z B G T R M

… … … … … …

Letter Si of keyword

Positionof letterin keyword

i

i+6

i+12

i+18

i+24

Page 26: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

26

Using Frequency Analysis to Attack the Vigenère Cipher (cont.)

S1 S2 S3 S4 S5 S6

Z R Z N S P

C W Q G F W

L W Q G F R

G R Z N S T

Z B G T R M

… … … … … …

Letter Si of keyword

Positionof letterin keyword

i

i+6

i+12

i+18

i+24Column 1 is encrypted by S1

Page 27: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

27

Using Frequency Analysis to Attack the Vigenère Cipher (cont.)

S1 S2 S3 S4 S5 S6

Z R Z N S P

C W Q G F W

L W Q G F R

G R Z N S T

Z B G T R M

… … … … … …

Letter Si of keyword

Positionof letterin keyword

i

i+6

i+12

i+18

i+24Column 2 is encrypted by S2

Page 28: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

28

Using Frequency Analysis to Attack the Vigenère Cipher (cont.)

S1 S2 S3 S4 S5 S6

Z R Z N S P

C W Q G F W

L W Q G F R

G R Z N S T

Z B G T R M

… … … … … …

Letter Si of keyword

Positionof letterin keyword

i

i+6

i+12

i+18

i+24Column 3 is encrypted by S3

Page 29: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

29

Using Frequency Analysis to Attack the Vigenère Cipher (cont.)

S1 S2 S3 S4 S5 S6

Z R Z N S P

C W Q G F W

L W Q G F R

G R Z N S T

Z B G T R M

… … … … … …

Letter Si of keyword

Positionof letterin keyword

i

i+6

i+12

i+18

i+24Column 4 is encrypted by S4

Page 30: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

30

Using Frequency Analysis to Attack the Vigenère Cipher (cont.)

S1 S2 S3 S4 S5 S6

Z R Z N S P

C W Q G F W

L W Q G F R

G R Z N S T

Z B G T R M

… … … … … …

Letter Si of keyword

Positionof letterin keyword

i

i+6

i+12

i+18

i+24Column 5 is encrypted by S5

Page 31: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

31

Using Frequency Analysis to Attack the Vigenère Cipher (cont.)

S1 S2 S3 S4 S5 S6

Z R Z N S P

C W Q G F W

L W Q G F R

G R Z N S T

Z B G T R M

… … … … … …

Letter Si of keyword

Positionof letterin keyword

i

i+6

i+12

i+18

i+24Column 6 is encrypted by S6

Page 32: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

32

Using 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!

Page 33: 1 Codes, Ciphers, and Cryptography-Ch 2.2 Michael A. Karls Ball State University

33

Using 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: Simon Singh's Vigenère Cipher Cracking Tool.