<<

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

Scrambling Frequences

I To get around the weakness of monoalphabetic , we need to somehow scramble letter frequences. Polyalphabetic and Polygraphic Ciphers I A polyalphabetic substitution is a cipher in which there is not a 1–1 (Counting & Probability) map between plaintext and letters. Example 1. Jim Royer ® Let S = { 00, 01, 02, . . . , 99 } = two digit strings. ® Define a map ai 7→ Si, a subset of S 3 Intro. to I S0,..., S25 are a partition of S. I (freq. of a ) ≈ kS k/kSk. September 6, 2018 i i 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 Counting: The Multiplication Principle

The Multiplication Principle (Andrews, §3-1) The Multiplication Principle (Andrews, §3-1)

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

Sample Problems Sample Problems How many different 4-letter radio station call letters Answers How many different 4-letter radio station call letters Answers can be made when can be made when a. 2 · 26 · 26 · 26 = 35152. a. The first letter must be either K or W. a. The first letter must be either K or W. b. 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. and there are no repeated letters. Counting: The Multiplication Principle The Multiplication Principle: Puzzles

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, How many are there of: then the total number of ways of doing all k tasks is a. license plates with three letters followed by four digits? p1 × p2 × · · · × pk b. license plates as before, but no repeated letters? c. monoalphabetic ciphers? Sample Problems How many different 4-letter radio station call letters Answers can be made when a. 2 · 26 · 26 · 26 = 35152. a. The first letter must be either K or W. b. 2 · 25 · 24 · 23 = 27600. b. The first letter must be either K or W and there are no repeated letters.

The Multiplication Principle: Puzzles Poly. Ciphers Permutations Counting 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 2018-09-06 The “multiplication principle” is some times called Definition 2. A permutation is an ordering of a set of objects. • “Rule of product” (https://en.wikipedia.org/wiki/Rule_of_product) Puzzles • “general combinatorial principle” (Andrews, page 31) { } How many are there of: a.Q: How many permutations of a, b, c are there? a. license plates with three letters followed by four digits? b. There are four spies. We choose one a pilot and another as co-pilot. Q: How 26 · 26 · 26 · 10 · 10 · 10 · 10 = 263 · 104 = 175760000 many ways are there of doing this? b. license plates as before, but no repeated letters? 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? 26 · 25 · 24 · 10 · 10 · 10 · 10 = 156000000. d. Same as above, but choose a 3rd to go to Kalamazoo. c. monoalphabetic ciphers? e.Q: How many permutations are there of r objects selected from a set of size n. 26! = 403291461126605635584000000. (Notation: P(r, n).) Permutations Permutations

Poly. Ciphers Definition 2. Poly. Ciphers Definition 2. A permutation is an ordering of a set of objects. A permutation is an ordering of a set of objects. Counting Puzzles Counting Puzzles a.Q: How many permutations of { a, b, c } are there? 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 b. There are four spies. We choose one a pilot and another as co-pilot. Q: How many ways are there of doing this? many ways are there of doing this? c. There are five spies. Choose one to go to Miami and another to go to 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? Watertown. Q: How many ways can we do this? Permutations d. Same as above, but choose a 3rd to go to Kalamazoo. Permutations 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. e.Q: How many permutations are there of r objects selected from a set of size n.

2018-09-06 (Notation: P(r, n).) 2018-09-06 (Notation: P(r, n).)

O How many permutations of O There are four spies. We choose O There are five spies. Choose one to go to Miami and another to go to Water- { a, b, c } are there? one a pilot and another as co-pilot. town. Question: How many ways are there of doing this? An answer: Question: How many ways are An answer: 5 · 4 = 20. there of doing this? • There are 3 choices for the 1st O Same setup as above, but choose a 3rd to go to Kalamazoo. Question: How letter. An answer: many ways are there of doing this? An answer: 5 · 4 · 3 = 60. • There are 2 choices for the • There are 4 choices for the 1st 2nd letter. spy. O Question: How many permutations are there of r objects selected from a set of size n. • There is 1 choice for the 3rd • There are 3 choices for the n! An answer: P(r, n) = n · (n − 1) · ... · (n − r + 1) = . letter. 2nd spy. (n − r)! • By the Mult. principle, there • By the Mult. principle, there are a total of 3 · 2 · 1 = 6 are a total of 4 · 3 = 12 choices. choices.

Combinations

Poly. Ciphers Definition 3. a. A combination is a selection of r objects from a size-n set. Combinations (We don’t worry about order.) b.C (n, r) = (n) = n! = 1 · P(n, r). Counting r r!(n−r)! r! = The number of ways of selecting (choosing) r objects from a set of size n

is: Puzzles Combinations Suppose a lottery ticket contains 6 numbers from the set { 0, . . . , 39 }. a. How many tickets are possible when orders matters? Definition 3. 2018-09-06 b. How many when order doesn’t matter? a. A combination is a selection of r objects from a size-n set. Suppose a lottery ticket contains 6 numbers from the set { 0, . . . , 39 }. (We don’t worry about order.) a. How many tickets are possible when orders matters? ( ) = (n) = n! = 1 · ( ) b.C n, r r r!(n−r)! r! P n, r . P(6, 40) = 2763633600. = The number of ways of selecting (choosing) r b. How many when order doesn’t matter? objects from a set of size n C(6, 40) = 3838380. 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? Probability Basic Properties of Probability Definition 4. a. Sample space: the possible outcomes of an experiment  E.g.: Rolls of a six-sided die = 1, 2, 3, 4, 5, 6 b. Event: a subset of a sample space I ¬E = { x ∈ S x ∈/ E }.  p(¬E) = 1 − p(E). E.g.: Even rolls of a six-sided die = 2, 4, 6 I !! In this course, sample spaces are usually finite. I For all E, 0 ≤ p(E) ≤ 1. I If E and F are events of S, then To determine the probability of an event in a finite sample space, S: p(E ∪ F) = p(E) + p(F) − p(E ∩ F). E.g.: Roll of a fair die. 1. Determine the elements of S !!! Computing p(E ∩ F) can be tricky. a.p (rolling an odd #) = 1/2. 2. S 3 Assign a weight to each element of b.p (rolling a prime) = 1/2. (a) each weight is ≥ 0 and ( ) = (b) the weights sum to 1. c.p rolling an odd prime 1/3.

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

Independence Back to Ciphers

Definition 5. The problem with the monoalphabetic ciphers is that the frequency of characters is Suppose E, F ⊆ S. unchanged. a.E and F are independent iff p(E ∩ F) = p(E) · p(F). b.E F p(E ∩ F) 6= p(E) · p(F) and are dependent iff . Vigerere` Cipher c. If an experiment is repeated in n independent trials Plaintext = mollywillneverbreakthis. = chaos. & if the probability of an event E is p, ( ) · then the expected number of events (Exp E ) is p n. m o l l y w i l l Examples: Flipping a coin 5 times, S = { HHHHH,..., TTTTT }. + c h a o s c h a o OVLZQTPLZ p(no heads) = 1/32 (1 head) = 5/32 - c h a o s c h a o p(2 heads) = 10/32 p(3 heads) = 10/32 m o l l y w i l l p(4 heads) = 5/32 p(5 heads) = 1/32

1 Expected. num. of heads = 2 · 5 = 2.5. ← how to interp.? Vigerere` Cipher: History of the Vigerere` Cipher

I First described by an Italian The Kasiski Test cryptologist Battista Bellaso in La cifra If a string of characters appears repeatedly in a polyalphabetic ciphertext, then del Sig. Giovan Battista Bellaso, 1553. It the distance between these occurrences may be a multiple of the keyword length. was called le chiffre ind´echiffrable (the indecipherable cipher). I Why is this plausible? I How is this useful?

I Broken by (≈ 1850) and Time for an experiment Friedrich Kasiski (1863) who was first the publish the cryptanalysis.

The Friedman Test Breaking the Vigerere` Cipher

Definition 6 (Friedman). The = the probability of selecting two random letters from a text and getting the same letter. I Figure out the word length, n, using the Kasiski and Friedman tests I Then you have n difference shift ciphers to break. I Suppose n= # of letters in a text and ni = # of ai in a text. I The probability of selecting two random letters & getting two ’a’s is n  n n (n − 1)/2 n (n − 1) = 0 ÷ = 0 0 = 0 0 2 2 n(n − 1)/2 n(n − 1) Time for a final experiment ∴ The probability that two randomly chosen letters are the same is ( − ) 2 = 25 ni ni 1 = ( ) ≈ 25 ni  ∑i=0 n(n−1) IC T ∑i=1 n 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 Ciphers Playfair: The Set Up

Definition 7. I We eliminate ‘j‘ from our alphabet (so we have 25 letters). A polygraphic substitutes a block of n-letters for another block of I In the plaintext, replace all ‘j‘s with ‘i‘s and, if the message length is odd, n-letters. add an ‘x‘ at the end. E.g.: john meet at school house io hn me et at sc ho ol ho us ex In pencil-and-paper settings the block size, n, is typically 2 or 3. I Choose a codeword (that doesn’t use;‘j‘) and remove repeated letters. E.g.: playf6air → playir. The Playfair Cipher I Then form a 5-by-5 square of your codeword followed by the remaining I Invented in 1854 by Charles letters in your alphabet (in order). E.g.: Wheatstone. p l a y f I Promoted by Lyon Playfair for the i r b c d British government. e g h k m I Quick to encrypt and decrypt. n o q s t u v w x z I Used through WW II. Wheatstone Playfair

Playfair:

Poly. Ciphers Codeword: playf6air Plantext: io hn me et at sc ho ol ho us ex Encryption: Map plaintext blocks (p1p2) to ciphertext blocks (c1c2) Playfair: Encryption by: Polyalphabetic Ciphers MATRIX RULE 1 RULE 2 RULE 3 p l a y f The Playfair p1 i r b c d scheme is p c c e g h k m 1 1 p c p c 1 susceptible to c p 1 1 2 2 p n o q s t 2 2 2 freq. analysis Cryptanalysis c2 on letter pairs. u v w x z RULE 4 If p1 = p2, treat p2 as an ’x’. playf6air io hn me et at sc ho ol ho us ex Ciphertext: RN EQ EG MN FQ XK GQ VR GQ NX KU Playfair: Encryption io → RN by Rule 1. hn → EQ by Rule 1. me → EG by Rule 2.

Codeword: Plantext: 2018-09-06 ... Encryption: Map plaintext blocks (p1p2) to ciphertext blocks (c1c2) by: • For decrypting, reverse rules. MATRIX RULE 1 RULE 2 RULE 3 • 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 p l a y f The Playfair you need to keep secret for 30 minutes or so. p1 i r b c d scheme is p c c e g h k m 1 1 p c p c 1 susceptible to c p 1 1 2 2 p n o q s t 2 2 2 freq. analysis c u v w x z 2 on letter pairs. 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. ...