Scrambling Frequences To get around the weakness of monoalphabetic - - PowerPoint PPT Presentation

scrambling frequences
SMART_READER_LITE
LIVE PREVIEW

Scrambling Frequences To get around the weakness of monoalphabetic - - PowerPoint PPT Presentation

Scrambling Frequences To get around the weakness of monoalphabetic ciphers, we need to somehow scramble letter frequences. Polyalphabetic and Polygraphic Ciphers A polyalphabetic substitution cipher is a cipher in which there is not a


slide-1
SLIDE 1

Polyalphabetic and Polygraphic Ciphers (Counting & Probability)

Jim Royer

  • Intro. to Cryptography

September 6, 2018

Scrambling Frequences

◮ To get around the weakness of monoalphabetic ciphers, we need to somehow scramble letter frequences. ◮ A polyalphabetic substitution cipher is a cipher in which there is not a 1–1 map between plaintext and ciphertext letters. Example 1. ➤ Let S = { 00, 01, 02, . . . , 99 } = two digit strings. ➤ Define a map ai → Si, a subset of S ∋

◮ S0, . . . , S25 are a partition of S. ◮ (freq. of ai) ≈ Si/S. So ‘e’ will have about 12 different codes, but ‘x’ will have just one. ➤ When encoding ai pick a random element of Si. ➤ In the ciphertext, the freq. of all two digit seqs. is about the same. To analyze such schemes we need counting & probability.

Counting: The Multiplication Principle

The Multiplication Principle (Andrews, §3-1)

If task 1 can be done p1 ways and task 2 can be done p2 ways and . . . task k can be done pk ways, then the total number of ways of doing all k tasks is p1 × p2 × · · · × pk

Sample Problems

How many different 4-letter radio station call letters can be made when

  • a. The first letter must be either K or W.
  • b. The first letter must be either K or W

and there are no repeated letters.

Answers

Counting: The Multiplication Principle

The Multiplication Principle (Andrews, §3-1)

If task 1 can be done p1 ways and task 2 can be done p2 ways and . . . task k can be done pk ways, then the total number of ways of doing all k tasks is p1 × p2 × · · · × pk

Sample Problems

How many different 4-letter radio station call letters can be made when

  • a. The first letter must be either K or W.
  • b. The first letter must be either K or W

and there are no repeated letters.

Answers

  • a. 2 · 26 · 26 · 26 = 35152.
slide-2
SLIDE 2

Counting: The Multiplication Principle

The Multiplication Principle (Andrews, §3-1)

If task 1 can be done p1 ways and task 2 can be done p2 ways and . . . task k can be done pk ways, then the total number of ways of doing all k tasks is p1 × p2 × · · · × pk

Sample Problems

How many different 4-letter radio station call letters can be made when

  • a. The first letter must be either K or W.
  • b. The first letter must be either K or W

and there are no repeated letters.

Answers

  • a. 2 · 26 · 26 · 26 = 35152.
  • b. 2 · 25 · 24 · 23 = 27600.

The Multiplication Principle: Puzzles

How many are there of:

  • a. license plates with three letters followed by four digits?
  • b. license plates as before, but no repeated letters?
  • c. monoalphabetic ciphers?

The Multiplication Principle: Puzzles

How many are there of:

  • a. license plates with three letters followed by four digits?
  • b. license plates as before, but no repeated letters?
  • c. monoalphabetic ciphers?

2018-09-06

  • Poly. Ciphers

Counting The Multiplication Principle: Puzzles The “multiplication principle” is some times called

  • “Rule of product”

(https://en.wikipedia.org/wiki/Rule_of_product)

  • “general combinatorial principle” (Andrews, page 31)

How many are there of:

  • a. license plates with three letters followed by four digits?

26 · 26 · 26 · 10 · 10 · 10 · 10 = 263 · 104 = 175760000

  • b. license plates as before, but no repeated letters?

26 · 25 · 24 · 10 · 10 · 10 · 10 = 156000000.

  • c. monoalphabetic ciphers?

26! = 403291461126605635584000000.

Permutations

Definition 2.

A permutation is an ordering of a set of objects.

Puzzles

  • a. Q: How many permutations of { a, b, c } are there?
  • b. There are four spies. We choose one a pilot and another as co-pilot. Q: How

many ways are there of doing this?

  • c. There are five spies. Choose one to go to Miami and another to go to
  • Watertown. Q: How many ways can we do this?
  • d. Same as above, but choose a 3rd to go to Kalamazoo.
  • e. Q: How many permutations are there of r objects selected from a set of size n.

(Notation: P(r, n).)

slide-3
SLIDE 3

Permutations Definition 2.

A permutation is an ordering of a set of objects. Puzzles

  • a. Q: How many permutations of { a, b, c } are there?
  • b. There are four spies. We choose one a pilot and another as co-pilot. Q: How

many ways are there of doing this?

  • c. There are five spies. Choose one to go to Miami and another to go to
  • Watertown. Q: How many ways can we do this?
  • d. Same as above, but choose a 3rd to go to Kalamazoo.
  • e. Q: How many permutations are there of r objects selected from a set of size n.

(Notation: P(r, n).)

2018-09-06

  • Poly. Ciphers

Counting Permutations ❖ How many permutations of { a, b, c } are there? An answer:

  • There are 3 choices for the 1st

letter.

  • There are 2 choices for the

2nd letter.

  • There is 1 choice for the 3rd

letter.

  • By the Mult. principle, there

are a total of 3 · 2 · 1 = 6 choices. ❖ There are four spies. We choose

  • ne a pilot and another as co-pilot.

Question: How many ways are there of doing this? An answer:

  • There are 4 choices for the 1st

spy.

  • There are 3 choices for the

2nd spy.

  • By the Mult. principle, there

are a total of 4 · 3 = 12 choices.

Permutations Definition 2.

A permutation is an ordering of a set of objects. Puzzles

  • a. Q: How many permutations of { a, b, c } are there?
  • b. There are four spies. We choose one a pilot and another as co-pilot. Q: How

many ways are there of doing this?

  • c. There are five spies. Choose one to go to Miami and another to go to
  • Watertown. Q: How many ways can we do this?
  • d. Same as above, but choose a 3rd to go to Kalamazoo.
  • e. Q: How many permutations are there of r objects selected from a set of size n.

(Notation: P(r, n).)

2018-09-06

  • Poly. Ciphers

Counting Permutations

❖ There are five spies. Choose one to go to Miami and another to go to Water-

  • town. Question: How many ways are there of doing this?

An answer: 5 · 4 = 20. ❖ Same setup as above, but choose a 3rd to go to Kalamazoo. Question: How many ways are there of doing this? An answer: 5 · 4 · 3 = 60. ❖ Question: How many permutations are there of r objects selected from a set

  • f size n.

An answer: P(r, n) = n · (n − 1) · . . . · (n − r + 1) = n! (n − r)!.

Combinations

Definition 3.

  • a. A combination is a selection of r objects from a size-n set.

(We don’t worry about order.)

  • b. C(n, r) =

(n

r)

=

n! r!(n−r)!

=

1 r! · P(n, r).

= The number of ways of selecting (choosing) r

  • bjects from a set of size n

is:

Puzzles

Suppose a lottery ticket contains 6 numbers from the set { 0, . . . , 39 }.

  • a. How many tickets are possible when orders matters?
  • b. How many when order doesn’t matter?

Combinations Definition 3.

  • a. A combination is a selection of r objects from a size-n set.

(We don’t worry about order.)

  • b. C(n, r) =

(n

r)

=

n! r!(n−r)!

=

1 r! · P(n, r).

= The number of ways of selecting (choosing) r

  • bjects from a set of size n

is: Puzzles Suppose a lottery ticket contains 6 numbers from the set { 0, . . . , 39 }.

  • a. How many tickets are possible when orders matters?
  • b. How many when order doesn’t matter?

2018-09-06

  • Poly. Ciphers

Counting Combinations Suppose a lottery ticket contains 6 numbers from the set { 0, . . . , 39 }.

  • a. How many tickets are possible when orders matters?

P(6, 40) = 2763633600.

  • b. How many when order doesn’t matter?

C(6, 40) = 3838380.

slide-4
SLIDE 4

Probability

Definition 4.

  • a. Sample space: the possible outcomes of an experiment

E.g.: Rolls of a six-sided die =

  • ✶, ✷, ✸, ✹, ✺, ✻
  • b. Event: a subset of a sample space

E.g.: Even rolls of a six-sided die =

  • ✷, ✹, ✻
  • !! In this course, sample spaces are usually finite.

To determine the probability of an event in a finite sample space, S:

  • 1. Determine the elements of S
  • 2. Assign a weight to each element of S

∋ (a) each weight is ≥ 0 and (b) the weights sum to 1.

  • 3. Probability of E = ∑a∈E weight(a).

E.g.: Roll of a fair die.

  • a. p(rolling an odd #) = 1/2.
  • b. p(rolling a prime) = 1/2.
  • c. p(rolling an odd prime) = 1/3.

Basic Properties of Probability

◮ ¬E = { x ∈ S x / ∈ E }. ◮ p(¬E) = 1 − p(E). ◮ For all E, 0 ≤ p(E) ≤ 1. ◮ If E and F are events of S, then p(E ∪ F) = p(E) + p(F) − p(E ∩ F). !!! Computing p(E ∩ F) can be tricky.

Independence

Definition 5.

Suppose E, F ⊆ S.

  • a. E and F are independent iff p(E ∩ F) = p(E) · p(F).
  • b. E and F are dependent iff p(E ∩ F) = p(E) · p(F).
  • c. If an experiment is repeated in n independent trials

& if the probability of an event E is p, then the expected number of events (Exp(E)) is p · n.

Examples: Flipping a coin 5 times, S = { HHHHH, . . . , TTTTT }.

p(no heads) = 1/32 (1 head) = 5/32 p(2 heads) = 10/32 p(3 heads) = 10/32 p(4 heads) = 5/32 p(5 heads) = 1/32

  • Expected. num. of heads = 1

2 · 5 = 2.5.

← how to interp.?

Back to Ciphers

The problem with the monoalphabetic ciphers is that the frequency of characters is unchanged.

Viger` ere Cipher

Plaintext = mollywillneverbreakthis. Key = chaos. m o l l y w i l l + c h a o s c h a o O V L Z Q T P L Z

  • c h a o s c h a o

m o l l y w i l l

slide-5
SLIDE 5

Viger` ere Cipher: History

◮ First described by an Italian cryptologist Battista Bellaso in La cifra del Sig. Giovan Battista Bellaso, 1553. It was called le chiffre ind´ echiffrable (the indecipherable cipher). ◮ Broken by Charles Babbage (≈ 1850) and Friedrich Kasiski (1863) who was first the publish the cryptanalysis.

Cryptanalysis of the Viger` ere Cipher

The Kasiski Test If a string of characters appears repeatedly in a polyalphabetic ciphertext, then

the distance between these occurrences may be a multiple of the keyword length. ◮ Why is this plausible? ◮ How is this useful? Time for an experiment

The Friedman Test

Definition 6 (Friedman).

The index of coincidence = the probability of selecting two random letters from a text and getting the same letter. ◮ Suppose n= # of letters in a text and ni = # of ai in a text. ◮ The probability of selecting two random letters & getting two ’a’s is = n0 2

  • ÷

n 2

  • = n0(n0 − 1)/2

n(n − 1)/2 = n0(n0 − 1) n(n − 1)

∴ The probability that two randomly chosen letters are the same is

= ∑25

i=0 ni(ni−1) n(n−1)

= IC(T) ≈ ∑25

i=1

ni

n

2 For English: IC ≈ 0.065 For French: IC ≈ 0.078 For German: IC ≈ 0.076 For random text: IC ≈ 0.038 Time for another experiment

Breaking the Viger` ere Cipher

◮ Figure out the code word length, n, using the Kasiski and Friedman tests ◮ Then you have n difference shift ciphers to break. Time for a final experiment

slide-6
SLIDE 6

Polygraphic Substitution Ciphers

Definition 7.

A polygraphic substitution cipher substitutes a block of n-letters for another block of n-letters. In pencil-and-paper settings the block size, n, is typically 2 or 3.

The Playfair Cipher

◮ Invented in 1854 by Charles Wheatstone. ◮ Promoted by Lyon Playfair for the British government. ◮ Quick to encrypt and decrypt. ◮ Used through WW II. Wheatstone Playfair

Playfair: The Set Up

◮ We eliminate ‘j‘ from our alphabet (so we have 25 letters). ◮ In the plaintext, replace all ‘j‘s with ‘i‘s and, if the message length is odd, add an ‘x‘ at the end. E.g.: john meet at school house

  • io hn me et at sc ho ol ho us ex

◮ Choose a codeword (that doesn’t use ‘j‘) and remove repeated letters. E.g.: playfair → playir. ◮ Then form a 5-by-5 square of your codeword followed by the remaining letters in your alphabet (in order). E.g.:

p l a y f i r b c d e g h k m n

  • q

s t u v w x z

Playfair: Encryption

Codeword: playfair Plantext: io hn me et at sc ho ol ho us ex Encryption: Map plaintext blocks (p1p2) to ciphertext blocks (c1c2) by: MATRIX RULE 1 RULE 2 RULE 3 p l a y f i r b c d e g h k m n

  • q

s t u v w x z p1 c1 c2 p2 p1c1p2c2 p1 c1 p2 c2 RULE 4 If p1 = p2, treat p2 as an ’x’. Ciphertext: RN EQ EG MN FQ XK GQ VR GQ NX KU io → RN by Rule 1. hn → EQ by Rule 1. me → EG by Rule 2. ...

The Playfair scheme is susceptible to

  • freq. analysis
  • n letter pairs.

Playfair: Encryption

Codeword: playfair Plantext: io hn me et at sc ho ol ho us ex Encryption: Map plaintext blocks (p1p2) to ciphertext blocks (c1c2) by: MATRIX RULE 1 RULE 2 RULE 3 p l a y f i r b c d e g h k m n

  • q

s t u v w x z p1 c1 c2 p2 p1c1p2c2 p1 c1 p2 c2 RULE 4 If p1 = p2, treat p2 as an ’x’. Ciphertext: RN EQ EG MN FQ XK GQ VR GQ NX KU io → RN by Rule 1. hn → EQ by Rule 1. me → EG by Rule 2. ... The Playfair scheme is susceptible to

  • freq. analysis
  • n letter pairs.

2018-09-06

  • Poly. Ciphers

Polyalphabetic Ciphers Cryptanalysis Playfair: Encryption

  • For decrypting, reverse rules.
  • Even if you know how to break a Playfair cipher, it takes a few hours

via pencil and paper — which during WWII made it usable for things you need to keep secret for 30 minutes or so.