You are on page 1of 54

" A cryptogram

is a piece of writing to which a meaning exists but is not immediately


perceptible; its intelligibility is concealed, hence mysterious or
occult, and thus supernatural. Therefore anyone practicing the art
is of necessity the associate of forces governing supernatural phenomena.
The mental portrait the average layman has even today of the professional
cryptographer is that of a long haired, thick bespectacled recluse;
a cross between a venerable savant and a necromancer who must therefore
commune daily with dark spirits in order to accomplish his feats of
mental jiu-jitsu."

in an article of
William Friedman
(Office of the Chief Signal Officer
War dept. Washington, D.C.)
on Edgar Allan Poe written in
"American Literature" V 8, Nov 1936 pp 265-280

next

http://www.math.ucsd.edu/~alina/187/

next

CRYPTOGRAPHY
Cryptography: from greek kryptos ( ),
which may be translated into hidden or secret;
and graphen ( ), for writing.

Secret Writing
next

My name is Alina Bucur (call me Alina)



I am the instructor.

The TAs are

Quang Bach; Geoffrey Ganzberger; Zonglin Jiang.
The course was created by Prof. Adriano Garsia,
who taught it for over 30 years.
This is my first time teaching this course at UCSD. And no, I am not
happy about 8am either.

Until recently the UCSD Math Dept was unique in teaching

Cryptography to undergraduates at this level of

mathematical sophistication.
You will be exposed to some very beautiful mathematics

in a setting that is very relevant to the present needs for
protecting information.
next

EXAMS AND GRADES


There will be 7 or 8 weekly quizzes on Tuesdays

starting Tuesday April 5.
A sample quiz will be posted on Thursdays preceding each
quiz.
The lowest quiz score will be automatically dropped.
If you have to miss a quiz this will count as

your lowest score. No make-up quizzes will be given.
All tests are open book and notes.
You will not need a computer but in some tests it might help to
have a calculator.
There will be 3 computer assignments on codebreaking

using applets from the course website.
The Final (not cumulative) will count as 2 quizzes.

The 3 applet assignments will count as one quiz.
next

TEXTBOOKS?
There is no single textbook that contains all the
material that is presented in this class.
All classroom presentations will be posted in
the web in pdf form the day after the class.
There will also be lecture notes.
To access this material you will need a password.
For a historical view (with sensationalist elements) of cryptography you
may want to read:
The Codebreakers: The Comprehensive History of

Secret Communication from Ancient Times to the Internet

by David Kahn

Revised ed. New York: Scribner, 1996.
next

THE JARGON OF CRYPTOGRAPHY


Cryptography:
The art of secret writing.
Plaintext:
Text to be encoded for secrecy.
Ciphertext:
Encoded text.
(Short ciphertext is sometimes called a "cryptogram")

Cipher:
A method of secret writing.
next

CIPHER

OR CYPHER

?
cypher is British

cipher is American
next

THE JARGON OF CRYPTOGRAPHY


n-gram:
A string of n-letters.

Encipherment, Encryption:
The process of encoding plaintext into ciphertext.

Decipherment, Decryption:
The process of decoding ciphertext back into plaintext.

Encrypt, Decrypt:
These are the corresponding verbs.

next

THE JARGON OF CRYPTOGRAPHY


Sender:
The person that is to send the encrypted

message.

Receiver:
The person which is to receive and decrypt

the message.

Opponent:
The person or organization which intercepts the message and

attempts the unauthorized decipherment.
next

THE JARGON OF CRYPTOGRAPHY


Sender:
Receiver:

ALICE

BOB

BOB

ALICE
from Wikipedia:

These names were invented by Ron


Rivest for the 1978 communication of
the ACM article presenting the RSA

Cryptosystem

Opponent:
EVE

from Bruce Sniders book Applied


Cryptography

next

THE JARGON OF CRYPTOGRAPHY


Cryptographic system, Encipherment scheme:
A family of ciphers

(transformations of plaintext into ciphertext to be used for encryption
and decryption).

Each member of the family is determined by a particular key.

Key:
The information, usually a sequence of digits or symbols,

used to determine the algorithm by which plaintext is to be

transformed into ciphertext.
next

THE JARGON OF CRYPTOGRAPHY


Message space:
The collection of all messages that may occur in a particular

cryptographic transaction.

Key space:
The collection of all keys that may occur in a given

cryptographic system.

next

THE JARGON OF CRYPTOGRAPHY


Cryptanalysis:
The process by which the opponent attempts to recover the

original plaintext from the intercepted ciphertext.

Code breaking:
The process by which a cryptographic system is made

vulnerable to cryptanalysis.

Onetime pad/ephemeral key


A key to be used only once.
next

ONE TIME PAD

The Key is a long list of



numbers as long as the

message itself
Photo from

Otto von Guericke
University

Magdeburg Germany
next

THE SET UP
In a typical cryptographic transaction the sender and receiver

choose a cryptographic system and, at some time before the message

is to be sent, the sender chooses the key. This determines

which transformation of the system will be used to

encrypt the message.

The key is then sent to the receiver by some



safe path (inaccessible to the opponent). Upon obtaining the key

the receiver determines which transformation of the system is to be

used to decrypt the message.

next

ASSUMPTIONS
Safe paths between sender and receiver do exist

though generally they maybe impractical to use

for the message itself
(for instance the path may require hand carrying by

an especially trusted messenger).
By necessity the path taken by the message itself

may have to be "unsafe".

The security of the



message is not usually expected to be achieved through the opponent's

ignorance of the encryption system but rather from lack of

knowledge as to which particular key has

been used in the encryption.
next

ASSUMPTIONS

(classical Cryptography)
If the opponent's task consists

of reconstructing the key from an analysis of the

ciphertext,

then security is achieved by assuring that the key space

is too large for an exhaustive trial and error attack to be

practical.

However the basic goal of the opponent is to recover the



original plaintext.

This may not necessarily involve reconstructing the key.
next

Methods of Encryption
Substitution:
When individual letters or n-grams of plaintext are replaced
by letters or n-grams of ciphertext

Transposition:
When the characters or words of the original message are rearranged
according to some particular pattern.

Most known modern methods are a


mixture of both.
next

SUBSTITUTION

C H U R C H Y A R D
next

ENCRYPTION

BY SUBSTITUTION

Plaintext
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

P V J W D C H T S K Z F N Q E Y O R I G A U M L X B

Ciphertext

next

TRANSPOSITION
THE PAST IS A PEBBLE IN

MY SHOE

THE PEBBLE IS PAST MY SHOE IN A

next

Encryption by

transposition
1

T T L I N
TTIBAGLN

next

Cryptographic transactions
may be viewed as two-person games
between the sender-receiver on one side
and the opponent on the other side.

ALICE

BOB

EVE
This game may be played under different sets of rules.
next

The most commonly used rules


Ciphertext only attack:
The opponent is to recover plaintext only through

knowledge of ciphertext.

Known plaintext attack:


The opponent may have access to some information

concerning the original plaintext. This may include

the knowledge of portions of the plaintext.

Chosen plaintext attack:


The opponent is in a position to acquire ciphertext

corresponding to plaintext of his selection.
next

Classical Cryptography:
A cryptographic transaction where the opponent

is allowed ciphertext-only or known-plaintext attacks.

Modern Cryptography:
Usually this refers to the game in which the opponent has access

to an unlimited amount of corresponding

plaintext-ciphertext pairs.
That is, the opponent is capable of chosen-plaintext attack.
This is achieved by the opponent having access

to all the encrypting transformations of the system.
Security is to be achieved through

secrecy of all the decrypting transformations.

next

COURSE OBJECTIVES
The analysis and decryption of cryptograms is more an art than a
science
which is very much like playing chess.

This is not our goal here.


Our objective here is to learn how encrypted data, in reasonably large
amounts, can be made vulnerable to computer attack.
Before we can understand cryptoanalysis we must

begin by understanding encryption.

We will start with the classical



methods of encryption.
next

COURSE OVERVIEW
FIRST STAGE
Early ciphers:

Caesar shift

Vigenre

Rectangular transposition

Monoalphabetic substitution

Playfair

ADFGVX

Vernams two tape system

Affine ciphers

Hill Cipher

next

SECOND STAGE
Elements of probability and statistics

Probabilities and conditional probabilities

Expectation and conditional expectation

Dependence and independence

Statistical models of English text

Random number generators

The chi-square test

next

THIRD STAGE
Codebreaking

Breaking Vigenre

Breaking rectangular transposition

Breaking homophonic

Breaking affine

Breaking Hill

Breaking monoalphabetic substitution

Breaking ADFGVX

next

FOURTH STAGE
Information theory

Basics on the concept of information

Entropy and information

Fundamental identities

Redundancy and compression of text

Entropy of English text

File and text compression

The Huffman code

Perfect secrecy systems

next

FINAL STAGE
Modern cryptography

Euclidean algorithm

Chinese remainder theoorem

Residue systems

The Euler phi function

Primitive roots

Quadratic residues

Quadratic reciprocity law

The Jacobi symbol

Primality testing

The RSA scheme

Knapsack

Factoring large integers

The quadratic sieve

Public key systems

Discrete logarithms

Diffie-Hellman key exchange

The ElGamal public key cryptosystem

Elliptic curve cryptography

Zero-knowledge techniques

The DES (Data Encryption Standard)

next

EARLY CIPHERS
next

The scytale (circa -400)

Described by
the greek
Historian
Plutarch
46-127

next

The Caesar code


A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
KHUH LV DQ HADPSOH
HERE IS AN EXAMPLE

next

The code of the


XII century
Templars

next

next

Albertis wheels (1446)

next

The front page of Johannes


Trithemius

Polygraphiae

(1518) shows the author
presenting his book to the
emperor

Maximilian I

The first printed book on



Cryptography
next

One of the greatest feats of code


breaking
hieroglyphic, demotic and
The Rosetta
Stone
hieroglyphs,
Found in Egypt
in 1799

Demotic script,

it permitted
Jean-Franois
Champollion,
in 1822
to decode
hieroglyphics.
next

(ancient Egyptian script)

Ancient Greek.

The E Caesar Shift


A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

D E F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
HERE IS AN EXAMPLE
LIVI MW ER IBEQTPI
next

RAGZP

QZFYO

PYEXN

OXDWM

NWCVL

MVBUK

LUATJ

KTZSI

JSYRH

IRXQG

HQWPF

GPVOE

FOUND

ENTMC

DMSLB

CLRKA

BKQJZ

AJPIY

ZIOHX

YHNGW

K
P

XGMFV

SBHAQ

WFLEU

M
R

VEKDT

UDJCS

TCIBR

RAGZP

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
next

A cipher deemed

``unbreakable

Blaise de Vigenre

(1523-1596)
A poly-alphabetic substitution

next

The Caesar circular shifts for the key



GOLF
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
next

Since spaces are a giveaway,


they are eliminated
and the cipher is then
broken up into k-grams
For k=4
SEND FOOD SEND AMMU NITI ON
next

The Vigenre Cipher


A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
g
o
l
f

h
p
m
g

i
q
n
h

j
r
o
i

k
s
p
j

l
t
q
k

m
u
r
l

n
v
s
m

o
w
t
n

p
x
u
o

q
y
v
p

r
z
w
q

s
a
x
r

t
b
y
s

u
c
z
t

v
d
a
u

w
e
b
v

x
f
c
w

y
g
d
x

z
h
e
y

a
i
f
z

b
j
g
a

c
k
h
b

d
l
i
c

e
m
j
d

f
n
k
e

SEND FOOD SEND AMMUNITION


golf golf golf golf golf golf
SEND FOOD SEND AMMU NITI ONRU(bbish)
ys y i lczi ysyi gaxz twen ubcz
Then regroup and cut in another manner to hide the
length of the key.

next

Supposed to fool letter frequency


analysis, the Vigenre cipher
survived for three centuries.
There are 456,976 keys of length 4.
More generally : 26 length of key
The Scientific American in 1917 called it impossible of translation.

Yet it was broken in 1863 by the


mathematician

Charles Babbage.
next

The difference engine No.1 of


Babbage (1827)

Charles Babbage (1791-1871)


next

RECTANGULAR TRANSPOSITION
(ROW VERSION)

THE BABOONS ARE COMING FOR YOU


3

T H
BO
AR
MI
OR

E B
ON
E C
NG
YO

EATBH

A
S
O
F
U

EA
OS
EO
NF
YU

OSBNO EOACR

NFMGI

T
B
A
M
O

B
N
C
G
O

H
O
R
I
R

YUOOR

next break it up into 3-grams to hide the period

eat

bho

sbn

oeo

acr nfm

giy

uoo r
next

The Affine Cipher


encryption function
decryption function

e(x) = ax + b (mod p)
-1

d(y) = a (y-b) (mod p)

For p=37 the letter-to-code conversion table is


A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1

3 4

5 6

7 8

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

0 1 2 3 4 5 6 7 8 9 =
27 28 29 30 31 32 33 34 35 36 37

1. plaintext letters are converted to plaintext codes


2. plaintext codes are encrypted into ciphertext codes
3. ciphertext codes are converted back to letters
next

Modular Arithmetic
A=Bq+r
quotient

y = x (mod p)
-1

y = a

0r<B
remainder

y = p q + x 0x<p
ya=1

(mod p)

1. For small p inverses are obtained from the multiplication


modulo p table
2. For large p we use the euclidean algorithm
next

The addition table modulo 37

next

The multiplication table modulo 26

Since 2 and 13 are the prime factors of 26, then 13 and all even
next
numbers have no inverse mod 26

The multiplication table modulo 29


21

18

next

You might also like