You are on page 1of 24

Cryptography

Kevin O’Bryant Math 187


kobryant@ucsd.edu MWF 4:00 – 4:50 pm
www.math.ucsd.edu/~kobryant www.math.ucsd.edu/~crypto

04/03/29 1
Definitions
 Plaintext
• The message that Alice wants Bob to read
 Ciphertext
• The message that Alice sends Bob
 Cryptosystem
• The algorithm that Alice uses to turn plaintext
into ciphertext.
 Key
• Something Bob and Alice agree on beforehand
that customizes the cryptosystem

04/03/29 2
Cryptosystems
 Two basic types:
• Substitution (replace letters)
• Transposition (rearrange letters)
 Caeser Cipher
• Shift each letter by the same amount
• Key: how much to shift
 Monoalphabetic Substitution
• Replace each letter with some other letter in a one-to-
one manner
• Key: the bottom line of
Plaintext: abcdefghijklmnopqrstuvwxyz
Ciphertext: QWERTYUIOPASDFGHJKLZXCVBNM

04/03/29 3
Caeser Cipher
GZO PN OCZMZAJMZ WMVXZ JPMNZGQZN OJ JPM
YPOT, VIY NJ WZVM JPMNZGQZN, OCVO DA OCZ
WMDODNC ZHKDMZ VIY DON XJHHJIRZVGOC GVNO
AJM V OCJPNVIY TZVMN, HZI RDGG NODGG NVT,
'OCDN RVN OCZDM ADIZNO CJPM.‘
Caeser Cipher
• Strengths
 Very Fast
 Easy to remember

04/03/29 4
Cipher Wheels

04/03/29 5
Caeser Cipher
GZO PN OCZMZAJMZ WMVXZ JPMNZGQZN OJ JPM YPOT, VIY NJ WZVM
JPMNZGQZN, OCVO DA OCZ WMDODNC ZHKDMZ VIY DON XJHHJIRZVGOC GVNO
AJM V OCJPNVIY TZVMN, HZI RDGG NODGG NVT, 'OCDN RVN OCZDM
ADIZNO CJPM.‘

Caeser Cipher
• Strengths
 Very Fast
 Easy to remember
• Weaknesses
 Formatting gives away the house
 Small number of keys: 26 (and one is weak)
 Frequency analysis

04/03/29 6
Strengthening Caeser
 Fixing the Formatting Weakness
• Strip out punctuation, and put letters in
blocks of the same length.
GZO PN OCZMZAJMZ WMVXZ JPMNZGQZN OJ JPM YPOT, VIY NJ
WZVM JPMNZGQZN, OCVO DA OCZ WMDODNC ZHKDMZ VIY DON
XJHHJIRZVGOC GVNO AJM V OCJPNVIY TZVMN, HZI RDGG
NODGG NVT, 'OCDN RVN OCZDM ADIZNO CJPM.‘
becomes
GZOP NOCZ MZAJ MZWM VXZJ PMNZ GQZN OJJP MYPO TVIY
NJWZ VMJP MNZG QZNO CVOD AOCZ WMDO DNCZ HKDM ZVIY
DONX JHHJ IRZV GOCG VNOA JMVO CJPN VIYT ZVMN HZIR
DGGN ODGG NVTO CDNR VNOC ZDMA DIZN OCJP M

04/03/29 7
Strengthening Caeser
 Key weakness is fixed by monoalphabetic
substitution
• Strengths
 403,291,461,126,605,635,584,000,000 keys
 Fast
• Weaknesses
 How many keys are easy to remember?
 Frequency analysis
We saw the frequencies of individual letters, but it is also possible---
and reasonable---to look at pairs of letters, and triples, etc. More
on this in three weeks.

04/03/29 8
Strengthening Caeser
 Fixing Frequency analysis
• Many ways to make frequency analysis
harder:
 send “e” to 3 letters (do you really need z
and x?)
 spell poorly (do you really need all those

silent letters?)
 send short messages

 use several different keys in one message

04/03/29 9
Vigenère’s Cryptosystem
 Let’s encrypt the plaintext
“prince is my favorite musician”
with the keyword “GUITAR”.
 Step 1: strip formatting:
“prince ismyfa vorite musici an”
using blocks the same length as our keyword.
 Step 2: encrypt the first letter of each block with the
Caeser-cipher that sends “a” to “G”, the second with that
C-c that sends “a” to “U”, the third with that C-c that sends
“a” to “I”, the fourth by sending “a” to “T”, fifth by sending
“a” to “A”, the sixth by sending “a” to “R”.
VLQGCV OMURFR BIZBTV SOABCZ GH
 Step 3: reformat into a (possibly) different block length.
VLQG CVOM URFR BIZB TVSO ABCZ GH

04/03/29 10
Vigenère’s Cryptosystem
 Strengths
• Infinite number of keywords
• Scrambles frequencies
• Easy to remember key
• Considered unbreakable in Black chambers for
200 years
 Weaknesses
• Can perform frequency analysis if we know-or
guess-the length of the keyword

04/03/29 11
Vigenère’s Cryptosystem
 History
• Idea of entertwining two keys came
from Leon Battista Alberti around 1465
in Florence
• Developed by
 Johannes Trithemius
 Giovanni Porta

 Blaise de Vigenère

04/03/29 12
The Alpha and the Omega of
Vigenère’s cryptosystem

04/03/29 13
Vigenère’s Cryptosystem
 History
• Idea of entertwining two keys came
from Leon Battista Alberti around 1465
in Florence
• Developed by
 Johannes Trithemius
 Giovanni Porta

 Blaise de Vigenère

• Broken by Charles Babbage


• Publicly broken by Friedrich Kasiski

04/03/29 14
The Vision of Sin
Sit thee down, and have no shame,
Cheek by jowl, and knee by knee:
What car I for any name?
What for order or degree?

Let me screw thee up a peg:


Let me loose thy tongue with wine:
Callest thou that thing a leg?
Which is thinnest? Thine or mine?

Thou shalt not be saved by works:


Thou has been a sinner too:
Ruined trunks on withered forks,
Empty scarecrows, I and you!

Fill the cup, and fill the can:


Have a rouse before the morn:
Every moment dies a man, Alfred Tennyson
Every moment one is born.

Image taken from


http://charon.sfsu.edu/TENNYSON/tennyson.html

04/03/29 15
Babbage to Tennyson
[suggested correction to “otherwise
beautiful” poem]

It must be manifest that if this were true,


the population of the world would be at a
standstill . . . I would suggest that in the
next edition of your poem you have it read
– “Every moment dies a man, Every
moment 1 1/16 is born.” The actual figure is
so long I cannot get it onto a line, but I
believe the figure 1 1/16 will be sufficiently
accurate for poetry.
04/03/29 16
Transpositions
Part of an actual telegram from Union Army General Halleck to General Buell
(quoted from Battle Cry of Freedom: The Civil War Era)
YOU MARCHED THE IS THE ELSEWHERE MOVE OF SURPRISING TWO
TIMES HALLECK AS SLOWLY ARMY IN HAS DISTANCE HAVE FOUR LAST
MOST IMMOBILITY YOU HERE TOO YOUR BRAGG MONTHS THE

HERE AS ELSEWHERE YOU MOVE


TOO SLOWLY THE IMMOBILITY OF
YOUR ARMY IS MOST SURPRISING
BRAGG IN THE LAST TWO
MONTHS HAS MARCHED FOUR TIMES
THE DISTANCE YOU HAVE HALLECK

04/03/29 17
From Lincoln
1863 WOULD RELIEVED
MEADE SINCE HAVE THE
WITHOUT ME WAS WHO THE
SATURDAY HEVY A WAR
FIGHTING CORPS KNOW
PLEASE THE TO OF AND
IMPRESSION TO CAMERON 15
I BE THAT ALL GETTYSBURG
GET RIVER TELL WHO
COMMANDER IN ON LINCOLN
SIGNED OF FOR ONE YOU
FIGHT OVER ONLY BATTLE
SMITH THE MUCH SIMON
WASHINGTON FOR GIVE OF
COUCH THE STRIVEN ENEMY
ANOTHER IF THE WAS
COUNCIL NIGHT

Image from
http://www.picturehistory.com/

04/03/29 18
Rectangular Transposition
 Let’s encrypt
“Out of life’s school of war: What does
not destroy me, makes me
stronger.”
with keyword Nietzsche
 The lexicographically first letter in

our keyword is c, followed by e, e, h,


i, n, s, t, z:
652897143
04/03/29 19
Rectangular Transposition
 Step 2: Write the plaintext under the
permutation rowwise
6 5 2 8 9 7 1 4 3
o u t o f l i f e
s s c h o o l o f
w a r w h a t d o
e s n o t d e s t
r o y m e m a k e
s m e s t r o n g
e r q j x z u v r

04/03/29 20
Rectangular Transposition
6 5 2 8 9 7 1 4 3
o u t o f l i f e
s s c h o o l o f
w a r w h a t d o
e s n o t d e s t
r o y m e m a k e
s m e s t r o n g
e r q j x z u v r

•Step 3: Write down the columns according to the numbers at the top:
ILTEAOU TCRNYEQ EFOTEGR FODSKNV USASOMR
OSWERSE LOADMRZ OHWOMSJ FOHTETX

04/03/29 21
Rectangular Transposition
 Step 4: Break into grams of a
different length:
ILTEAOU TCRNYEQ EFOTEGR FODSKNV USASOMR
OSWERSE LOADMRZ OHWOMSJ FOHTETX
becomes
ILTEA OUTCR NYEQE FOTEG RFODS KNVUS
ASOMR OSWER SELOA DMRZO HWOMS JFOHT ETX

04/03/29 22
Grades
 6 out of 7 quizzes (60%)
 Computer Homework (20%)

 Final Exam (or project) (20%)

04/03/29 23
Summary
 Caeser Sucks
 Monoalphabetic substitution is better

 Vigenère is good

 Transposition is a nice idea, and

deserves to be looked at more


 The End

04/03/29 24

You might also like