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

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

Upload: gregory-harrell

Post on 18-Dec-2015

226 views

Category:

Documents


0 download

TRANSCRIPT

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

1

Codes, Ciphers, and Cryptography-Ch 2.1

Michael A. Karls

Ball State University

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

2

Making Ciphers Stronger

In Chapter 1 we saw several examples of monoalphabetic substitution ciphers.

Caesar cipher Keyword cipher Rearrangement cipher Affine cipher All of these ciphers can be broken using the

technique developed by Arab cryptanalysts in the 8th century A.D.—frequency analysis.

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

3

Ways to Strengthen Monoalphabetic Ciphers New encryption methods needed to be invented

to overcome this flaw in monoalphabetic ciphers. Examples of techniques used to strengthen

these ciphers include: Misspell words in a message before encrypting. Add in dummy symbols called nulls. • For example, assign the double digit numbers 00-25 to the letters a-

z and add in the null symbols 26-99.

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

4

Ways to Strengthen Monoalphabetic Ciphers Examples of techniques used to strengthen

these ciphers (cont.) Add in codewords or symbols along with a cipher

alphabet.• Mary Queen of Scots’s nomenclature is an example of this

technique.• Her nomenclature also had four nulls!

Note that all of these modified monoalphbetic ciphers can be broken using frequency analysis.

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

5

Homophonic Substitution Ciphers

Frequency analysis of a ciphertext works because of the fact that each letter of the plain text is replaced with only one ciphertext symbol.

For example, suppose we have a monoalphabetic cipher in which

eX tB hW. Check relative frequency table for the English

language (see Table 1.2 on handout).

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

6

Homophonic Substitution Ciphers (cont.) Since e, t, and h appear in a large amount of

plaintext approximately 13%, 9%, and 6% of the time, respectively,

In a piece of ciphertext, X, B, and W will occur approximately 13%, 9%, and 6% of the time, respectively.

Furthermore, every occurrence of “the” in the plaintext will be encrypted as “BWX” in the ciphertext.

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

7

Homophonic Substitution Ciphers (cont.) Here is a way to get around this problem:

Assign more than one ciphertext symbol to a given plaintext symbol!

In order to take frequency analysis “out of the picture”, we’ll use the following rules:

Rule 1: In order to make deciphering unique, the sets of symbols belonging to plaintext letters must be disjoint, i.e. have no common elements.

Rule 2: The number of ciphertext symbols assigned to a plaintext letter is determined by the frequency of the letter, i.e. the relative frequency of the letter in a given language.

Basically, if the relative frequency of a letter is n%, choose n symbols for that letter!

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

8

Homophonic Substitution Ciphers (cont.) Here is an example of

a homophonic substitution cipher.

In the following table, pairs of digits 00 – 99 have been assigned to the letters a – z!

Handout Table 2.1

Table 2.1

a05, 18, 26, 38, 45, 54, 62, 84

n 20, 36, 53, 65, 97, 98

b 10 o22, 30, 34, 60, 64, 67, 72

c 28, 06, 80 p 04, 39

d 24, 46, 85, 88 q 59

e15, 16, 23, 31, 44, 61, 69, 77, 83, 87, 91, 95

r 08, 56, 57, 71, 79, 92

f 02, 32 s 21, 42, 49, 63, 70, 94

g 17, 52 t12, 50, 51, 55, 75, 78, 86, 93, 96, 99

h 03, 09, 33, 76, 82, 89 u 29, 01, 58

i27, 47, 66, 73, 74, 81, 90

v 14

j 11 w 13, 25

k 43 x 41

l 19, 37, 48, 68 y 40

m 00, 35 z 07

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

9

Homophonic Substitution Ciphers (cont.) Example 1: Use Table

2.1 to encrypt this message: the cat in the hat is here.

Solution: Randomly choose a ciphertext

letter for each plaintext letter. How do we do this?• Draw pieces of paper numbered 1-

12, 1-6, etc. from a hat.• Use dice: 6-sided, 8-sided, etc.

a05, 18, 26, 38, 45, 54, 62, 84

n 20, 36, 53, 65, 97, 98

b 10 o22, 30, 34, 60, 64, 67, 72

c 28, 06, 80 p 04, 39

d 24, 46, 85, 88 q 59

e15, 16, 23, 31, 44, 61, 69, 77, 83, 87, 91, 95

r 08, 56, 57, 71, 79, 92

f 02, 32 s 21, 42, 49, 63, 70, 94

g 17, 52 t12, 50, 51, 55, 75, 78, 86, 93, 96, 99

h 03, 09, 33, 76, 82, 89 u 29, 01, 58

i27, 47, 66, 73, 74, 81, 90

v 14

j 11 w 13, 25

k 43 x 41

l 19, 37, 48, 68 y 40

m 00, 35 z 07

Table 2.1

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

10

Homophonic Substitution Ciphers (cont.) Remarks on this type of cipher: Since we are choosing each cipher text symbol

randomly, any symbol has the same chance of occurring.

The word “homophonic” comes from Greek!• “homos””same”• “phonos””sound”

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

11

Breaking a Homophonic Substitution Cipher Frequency analysis cannot be used to break a cipher in

which every symbol appears with the same frequency. We can use the idea of digraphs and trigraphs to help us

decipher a homophonic substitution cipher! See digraph and trigraph tables 1.2 and 1.3 on handout! For example, The digraph “of” can only be encrypted in 7x2 = 14 ways. Also, there are only 6 choices for ciphertext symbols that stand for

plaintext “h”, so if we know the symbols for “t”, we have a good chance of figuring out what stands for “h”, since “h” often follows “t”.

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

12

The Vigenère Cipher

So far, all the enciphering schemes we’ve seen use just one alphabet.

Enciphering methods have been developed that use more than one alphabet!

Such ciphers are called polyalphabetic substitution ciphers.

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

13

The Vigenère Cipher (cont.)

The most famous polyalphabetic cipher is the Vigenère (pronounced “vision-air”) cipher.

Published in 1586 (same year as Mary Queen of Scots’ death).

Created by the French diplomat Blaise de Vigenère (1523-1596).

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

14

The Vigenère Cipher (cont.)

As is the case with many great ideas, Vigenère was not the first to discover this method!

Other people who came up with the idea of ciphers involving multiple alphabets:

Leone Battista Alberti (1404-1472). Johannes Trithemius (1462-1516). Giovanni Della Porta (1535-1615). Vigenère took their ideas and combined them to

produce a revolutionary new cipher!

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

15

The Vigenère Cipher (cont.)

Here’s how the Vigenère cipher works:

1. Choose a keyword and make a Vigenère square. (Handout Vigenère square—see next page.)

Note: This square is just all 26 possible additive ciphers written in rows!

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

16

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

B C D E F G H I J K L M N O P Q R S T U V W X Y Z A

C D E F G H I J K L M N O P Q R S T U V W X Y Z A B

D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

E F G H I J K L M N O P Q R S T U V W X Y Z A B C D

G H I J K L M N O P Q R S T U V W X Y Z A B C D E F

H I J K L M N O P Q R S T U V W X Y Z A B C D E F G

I J K L M N O P Q R S T U V W X Y Z A B C D E F G H

J K L M N O P Q R S T U V W X Y Z A B C D E F G H I

K L M N O P Q R S T U V W X Y Z A B C D E F G H I J

L M N O P Q R S T U V W X Y Z A B C D E F G H I J K

M N O P Q R S T U V W X Y Z A B C D E F G H I J K L

N O P Q R S T U V W X Y Z A B C D E F G H I J K L M

O P Q R S T U V W X Y Z A B C D E F G H I J K L M N

P Q R S T U V W X Y Z A B C D E F G H I J K L M N O

Q R S T U V W X Y Z A B C D E F G H I J K L M N O P

R S T U V W X Y Z A B C D E F G H I J K L M N O P Q

S T U V W X Y Z A B C D E F G H I J K L M N O P Q R

T U V W X Y Z A B C D E F G H I J K L M N O P Q R S

U V W X Y Z A B C D E F G H I J K L M N O P Q R S T

V W X Y Z A B C D E F G H I J K L M N O P Q R S T U

W X Y Z A B C D E F G H I J K L M N O P Q R S T U V

X Y Z A B C D E F G H I J K L M N O P Q R S T U V W

Y Z A B C D E F G H I J K L M N O P Q R S T U V W X

Z A B C D E F G H I J K L M N O P Q R S T U V W X Y

Vigenère Square

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

17

The Vigenère Cipher (cont.)

2. Write the keyword above the plaintext letters.

For example, choose VENUS as the keyword and polyalphabetic as the plaintext.

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

p o l y a l p h a b e t i c

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

18

The Vigenère Cipher (cont.)

3. Enciphering Rule: The keyword letter above a plaintext letter

determines which row of the Vigenère square to use.

The plaintext letter determines which column of the Vigenère square to use.

To encrypt, choose the letter where a row and column intersect!

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

19

The Vigenère Cipher (cont.)

For example, to encrypt the “p” in “polyalphabetic”, use the row starting with “V” and column below “p”. (See next page!)

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

20

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

B C D E F G H I J K L M N O P Q R S T U V W X Y Z A

C D E F G H I J K L M N O P Q R S T U V W X Y Z A B

D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

E F G H I J K L M N O P Q R S T U V W X Y Z A B C D

G H I J K L M N O P Q R S T U V W X Y Z A B C D E F

H I J K L M N O P Q R S T U V W X Y Z A B C D E F G

I J K L M N O P Q R S T U V W X Y Z A B C D E F G H

J K L M N O P Q R S T U V W X Y Z A B C D E F G H I

K L M N O P Q R S T U V W X Y Z A B C D E F G H I J

L M N O P Q R S T U V W X Y Z A B C D E F G H I J K

M N O P Q R S T U V W X Y Z A B C D E F G H I J K L

N O P Q R S T U V W X Y Z A B C D E F G H I J K L M

O P Q R S T U V W X Y Z A B C D E F G H I J K L M N

P Q R S T U V W X Y Z A B C D E F G H I J K L M N O

Q R S T U V W X Y Z A B C D E F G H I J K L M N O P

R S T U V W X Y Z A B C D E F G H I J K L M N O P Q

S T U V W X Y Z A B C D E F G H I J K L M N O P Q R

T U V W X Y Z A B C D E F G H I J K L M N O P Q R S

U V W X Y Z A B C D E F G H I J K L M N O P Q R S T

V W X Y Z A B C D E F G H I J K L M N O P Q R S T U

W X Y Z A B C D E F G H I J K L M N O P Q R S T U V

X Y Z A B C D E F G H I J K L M N O P Q R S T U V W

Y Z A B C D E F G H I J K L M N O P Q R S T U V W X

Z A B C D E F G H I J K L M N O P Q R S T U V W X Y

Vigenère Square

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

21

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

B C D E F G H I J K L M N O P Q R S T U V W X Y Z A

C D E F G H I J K L M N O P Q R S T U V W X Y Z A B

D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

E F G H I J K L M N O P Q R S T U V W X Y Z A B C D

G H I J K L M N O P Q R S T U V W X Y Z A B C D E F

H I J K L M N O P Q R S T U V W X Y Z A B C D E F G

I J K L M N O P Q R S T U V W X Y Z A B C D E F G H

J K L M N O P Q R S T U V W X Y Z A B C D E F G H I

K L M N O P Q R S T U V W X Y Z A B C D E F G H I J

L M N O P Q R S T U V W X Y Z A B C D E F G H I J K

M N O P Q R S T U V W X Y Z A B C D E F G H I J K L

N O P Q R S T U V W X Y Z A B C D E F G H I J K L M

O P Q R S T U V W X Y Z A B C D E F G H I J K L M N

P Q R S T U V W X Y Z A B C D E F G H I J K L M N O

Q R S T U V W X Y Z A B C D E F G H I J K L M N O P

R S T U V W X Y Z A B C D E F G H I J K L M N O P Q

S T U V W X Y Z A B C D E F G H I J K L M N O P Q R

T U V W X Y Z A B C D E F G H I J K L M N O P Q R S

U V W X Y Z A B C D E F G H I J K L M N O P Q R S T

V W X Y Z A B C D E F G H I J K L M N O P Q R S T U

W X Y Z A B C D E F G H I J K L M N O P Q R S T U V

X Y Z A B C D E F G H I J K L M N O P Q R S T U V W

Y Z A B C D E F G H I J K L M N O P Q R S T U V W X

Z A B C D E F G H I J K L M N O P Q R S T U V W X Y

Vigenère Square

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

22

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

B C D E F G H I J K L M N O P Q R S T U V W X Y Z A

C D E F G H I J K L M N O P Q R S T U V W X Y Z A B

D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

E F G H I J K L M N O P Q R S T U V W X Y Z A B C D

G H I J K L M N O P Q R S T U V W X Y Z A B C D E F

H I J K L M N O P Q R S T U V W X Y Z A B C D E F G

I J K L M N O P Q R S T U V W X Y Z A B C D E F G H

J K L M N O P Q R S T U V W X Y Z A B C D E F G H I

K L M N O P Q R S T U V W X Y Z A B C D E F G H I J

L M N O P Q R S T U V W X Y Z A B C D E F G H I J K

M N O P Q R S T U V W X Y Z A B C D E F G H I J K L

N O P Q R S T U V W X Y Z A B C D E F G H I J K L M

O P Q R S T U V W X Y Z A B C D E F G H I J K L M N

P Q R S T U V W X Y Z A B C D E F G H I J K L M N O

Q R S T U V W X Y Z A B C D E F G H I J K L M N O P

R S T U V W X Y Z A B C D E F G H I J K L M N O P Q

S T U V W X Y Z A B C D E F G H I J K L M N O P Q R

T U V W X Y Z A B C D E F G H I J K L M N O P Q R S

U V W X Y Z A B C D E F G H I J K L M N O P Q R S T

V W X Y Z A B C D E F G H I J K L M N O P Q R S T U

W X Y Z A B C D E F G H I J K L M N O P Q R S T U V

X Y Z A B C D E F G H I J K L M N O P Q R S T U V W

Y Z A B C D E F G H I J K L M N O P Q R S T U V W X

Z A B C D E F G H I J K L M N O P Q R S T U V W X Y

Vigenère Square

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

23

The Vigenère Cipher (cont.)

Thus, plaintext “p” is enciphered as “K”. Encipher “polyalphabetic”… Solution:

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

p o l y a l p h a b e t i c

K S Y S S G T U U T Z X V W

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

24

The Vigenère Cipher (cont.)

Notes on the Vigenère cipher: In the last example, • p K, T• aS, U• o, a, y S• p, b T• h, a U Thus, each plaintext letter can map to more than one ciphertext letter • Depends on the size of the keyword!• Longer keywords use more rows of the Vigenère square.• More rows used means more possibilities for how to encrypt a plain text letter! Note also that more than one plaintext letter can map to the same

ciphertext letter, making it harder to decipher messages!

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

25

The Vigenère Cipher (cont.)

Ciphertext letters tend to be “evenly distributed”.

For example, in the example above, here is the frequency of each ciphertext letter:

This protects the ciphered message from frequency analysis attacks!

K S Y G T U Z X V W

1 3 1 1 2 2 1 1 1 1

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

26

The Vigenère Cipher (cont.)

Vigenère’s cipher remained secure for over 200 years!

Next week we’ll see how to crack the Vigenère cipher!