0% found this document useful (0 votes)
50 views

Day05 200607spring Vigenere

The document discusses Vigenere ciphers, including how they work by repeating a key to encrypt plaintext, and different methods for cryptanalysis including finding the key length by looking for the maximum number of coincidences between ciphertext letters.

Uploaded by

Muhammad Nabawi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Day05 200607spring Vigenere

The document discusses Vigenere ciphers, including how they work by repeating a key to encrypt plaintext, and different methods for cryptanalysis including finding the key length by looking for the maximum number of coincidences between ciphertext letters.

Uploaded by

Muhammad Nabawi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

DTTF/NB479: Dszquphsbqiz Day 5

Announcements:
 Assignment 1 due tomorrow in class.
Questions?
Roll Call
Today: Vigenere ciphers

Pronunciation?
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
Source

The recent development of various methods of


modulation such as PCM and PPM which exchange
bandwidth for signal-to-noise ratio has intensified the
interest in a general theory of communication. A basis
for such a theory is contained in the important papers
of Nyquist and Hartley on this subject. In the present
paper we will extend the theory to include a number
of new factors, in particular the effect of noise in the
channel, and the savings possible due to the
statistical structure of the original message and due to
the nature of the final destination of the information.

(Claude Shannon’s A Mathematical Theory Of


Communication)
Security
The vector isn’t known
It’s length isn’t even known!
With shift cipher, most frequent cipher letter is
probably e.
 But here, e maps to H, I, L, … (spread out!)
Consider 4 attacks:
 Known plaintext?
 Chosen plaintext?
 Chosen ciphertext?
 Ciphertext only?
Cryptanalysis
What would you do to simplify the
problem?
You can even assume that you know how
long the key is…
3-4 min with a partner
English letter frequencies
A 0.082 H 0.061 O 0.075 U 0.028
B 0.015 I 0.070 P 0.019 V 0.010
C 0.028 J 0.002 Q 0.001 W 0.023
D 0.043 K 0.008 R 0.060 X 0.001
E 0.127 L 0.040 S 0.063 Y 0.020
F 0.022 M 0.024 T 0.091 Z 0.001
G 0.020 N 0.067 0.14

0.12

0.1

Graph:
0.08

0.06

0.04

0.02

0
0 5 10 15 20 25 30
Exceptions
Consider Gadsby by Ernest Vincent
Wright, February 1939:
 http://www.spinelessbooks.com/gadsby/01.html

What do you notice about it?


Cryptanalysis
Assume we know the key length, L, …
 We’ll see how to find it shortly
Method 1:
 Parse out the characters at positions p = 1 (mod L)
These have all been shifted the same amount
Do a frequency analysis to find shift
 The most frequent letter should be e, given enough text. Can
verify to see how shift affects other letters.
 This gives the first letter of the key
 Repeat for positions p = 2, p = 3, … p = L
 Problem: involves some trial and error.
 For brute force to work, would need to brute force all
letters of key simultaneously: _____ possibilities
Dot products
A  B  A. * B   Ai Bi
i
Consider A = (0.0820 0.0150 0.0280 0.0430 0.1270 0.0220 0.0200
0.0610 0.0700 0.0020 0.0080 0.0400 0.0240 0.0670 0.0750 0.0190 0.0010
0.0600 0.0630 0.0910 0.0280 0.0100 0.0230 0.0010 0.0200 0.0010)

Ai = A displaced i positions to the right


A0 .* A0 = ?
A0 .* A1 = ? 0.14

Ai .* Aj depends on _____ only.


0.12

0.1

0.08

0.06

0.04

Max occurs when _____. 0.02

0
0
0.14

0.12
5 10 15 20 25 30

3 reasons why: 0.08

0.06
0.1

0.04

0.02

0
0 5 10 15 20 25 30
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) 5 matches
Key length: an example
Take any random pair in the ciphertext:
The letter in the top row is shifted by i (say 0)
The letter in the bottom row is shifted by j (say 2)

Prob(both ‘A’) = P(‘a’)*P(‘y’) = 0.082 * 0.020


Prob they are the same (any letter) is ______
When i=j, get max # of coincidences
Occurs when we shift by the correct key length

Demo
Another method
Method 1
 Parse out the characters at positions p = 1
(mod L)
These have all been shifted the same amount
Do a frequency analysis to find shift
 The most frequent letter should be e, given enough text.
Can verify to see how shift affects other letters.

 This gives the first letter of the key


 Repeat for positions p = 2, p = 3, … p = L
Another method
Method 2
 Parse out the characters at positions p = 1
(mod L)
These have all been shifted the same amount
Get the whole freq. distribution W = (0.05, 0.002, …)
 W approximates A. Calculate W  Ai for 0  i  25
 Max occurs when we got the shift correct.
 Note we use the distribution of all 26 letters…more
robust than just using 1 (‘e’).
 This gives the first letter of the key
 Repeat for positions p = 2, p = 3, … p = L
Summary of both methods
Method 1
 Pros?

Method 2
 Pros?
Demo
Of my code…
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?
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?

You might also like