120 likes | 263 Views
DTTF/NB479: Dszquphsbqiz Day 6. Announcements: Pass in Assignment 1 now Meet my assistant Kevin Reed Assignment 2 (tentative) posted Questions? Today: Finish Vigenere, start Hill ciphers. Vigenere Ciphers. Idea: the key is a vector of shifts Ex. Use a word like hidden (7 8 3 3 4 13) .
E N D
DTTF/NB479: Dszquphsbqiz Day 6 • Announcements: • Pass in Assignment 1 now • Meet my assistant Kevin Reed • Assignment 2 (tentative) posted • Questions? • Today: Finish Vigenere, start Hill ciphers
Vigenere Ciphers • Idea: the key is a vector of shifts • Ex. Use a word like hidden (7 8 3 3 4 13). • Example: • The recent development of various methods of 7 8 3 3 413 7 8 3 3 413 7 8 3 3 413 7 8 3 3 413 7 8 3 3 4 13 7 8 3 3 413 7 8 015 7 20 815112122 6 8 811191718161720 1 17 8 25132416172322 2511 11017 7 5 2113 • aph uiplvw giiltrsqrub ri znyqrxw zlbkrhf vn • Encryption: • Repeat the vector as many times as needed to get the same length as the plaintext • Add this repeated vector to the plaintext. • Demo
Summary from yesterday • What makes a Vigenere cipher more secure than a shift cipher? • How do we find the key length? • Why does the max of dot(A0,Ai) occur when i==0? • What are the advantages and disadvantages of using the dot product method (method 2) vs. method 1 to decrypt the key?
English letter frequencies H 0.061 I 0.070 J 0.002 K 0.008 L 0.040 M 0.024 N 0.067 O 0.075 P 0.019 Q 0.001 R 0.060 S 0.063 T 0.091 U 0.028 V 0.010 W 0.023 X 0.001 Y 0.020 Z 0.001 A 0.082 B 0.015 C 0.028 D 0.043 E 0.127 F 0.022 G 0.020 Graph:
Finding the key length • What if the frequency of letters in the plaintext approximates A? • Then for each k, frequency of each group of letters in position p = k (mod L) in the ciphertext approximates A. • Then loop, displacing the ciphertext by i, and counting the number of coincidences. • Get max when displace by correct key length • So just look for the max! shift APHUIPLVWGIILTRSQRUBRIZNYQRXWZLBKRHFVN (0) NAPHUIPLVWGIILTRSQRUBRIZNYQRXWZLBKRHFV (1) VNAPHUIPLVWGIILTRSQRUBRIZNYQRXWZLBKRHF (2) … KRHFVNAPHUIPLVWGIILTRSQRUBRIZNYQRXWZLB (6) 5matches
Visualization • http://www.usafa.af.mil/df/dfcs/acis/applets/Vigenere.html • Play with now and for homework • Thanks to Dr. Dino Schweitzer, USAFA, who I met last Friday, for pointing me to his demo! • Aren’t you glad I was at SIGCSE?
Vigenere Closing Thought • What if we modified the Vigenere cipher so that each individual letter was not simply shifted, but the result of an affine function?
Block Ciphers • So far, changing 1 character in the plaintext changes ___ characters in the ciphertext. • Shannon outlined qualities of good ciphers: • Diffusion: Changing one character of the plaintext changes _____ characters in the ciphertext • Makes frequency analysis much tougher! • Confusion: Each character of the ciphertext interacts with several parts of the key • Block ciphershave both qualities: • DES (64 bits), AES (128 bits), Hill ciphers (smaller; today)
Hill Ciphers • Lester Hill, 1929. Not used much, but first time linear algebra used in crypto • Use an n x n matrix M. Encrypt by breaking plaintext into blocks of length n (padding with x’s if needed) and multiplying each by M. • Example: Encrypt “hereissomeonetoencrypt” using M • her eis som eon eto enc ryp txx • (7, 4, 17) (4, 8, 18) … (19, 23, 23) • (2, 5, 25) (0, 2, 22) … (0, 22, 15) • cfz acw yga vns ave anc sdd awp • “CFZACWYGAVNSAVEANCSDDAWP”
Decrypting • Reverse the process, multiplying each block by M inverse • Theorem: If a matrix M is invertible mod n, then gcd(det(M), n) = 1 • Proof on board (uses a lemma from Ch 3)
How to break via known plaintext? • Think about this…