# CSIS 5857: Encoding and Encryption

Document Sample

```					History and Background

CSIS 5857: Encoding and Encryption
Why is History Important?
• Most modern encryption algorithms based on
concepts hundreds/thousands of years old

• Most attacks on encryption also very old
– Exhaustive search
– Cryptographic analysis
Substitution Algorithms
Mapping of plaintext to ciphertext

• Can be single character mapping (historical)
A  G

• Can map entire blocks of plaintext
(modern block ciphers)
1001011001111100  0110101011100011
Side Point   Substitution Algorithms
Mapping must be unique for decryption to
work!

Encryption:      A  G
B  G

Decryption:      G  A or B ?
Substitution Algorithms
• Mapping often involves translating
Side Point

characters to numeric values
• Encryption/decryption functions in
terms of mathematical functions
Caesar Cipher
• Key k: number between 1 and 25

• Example:    k = 3, p = RUNAWAY
E(RUNAWAY)  UXQDZDB
D(UXQDZDB)  RUNAWAY
Exhaustive Key Search
Testing all possible keys
Algorithm:
• Given ciphertext c
• For all keys ki
– Compute pi = D(c, ki )
– If pi is recognizable plaintext, then ki is correct

Time proportional to number of possible
keys ki
Caesar Cipher and Exhaustive Search

Only 26 possible keys to test!
Ciphertext: UXQDZDB
Key:      Resulting Plaintext:
1       TWPCYCA
2       SVOBXBZ
3       RUNAWAY  recognizable plaintext
4       QTMZVZX
Not computationally secure!
This requires plaintext to be recognizable!
Side Point

Ciphertext: NMIXE
Key:         Resulting Plaintext:
1           ONJYF
2           POKZG
3           QPLAH  plaintext in Klingon!

Examples:
• Navajo “windtalkers” (WW2)
• Compressed text
• Text in form of image…

Can still defeat with chosen plaintext attack
• Encrypt known plaintext
Monoalphabetic Substitution
• Each plaintext character has corresponding
ciphertext character
• No pattern (unlike Caesar cipher)

Example:

“runaway”  “HJGNPNS”
Monoalphabetic Substitution
• Key = substitution table itself

• Number of possible keys = 26!
 400,000,000,000,000,000,000,000,000

• Computationally secure to exhaustive search
(at least without a computer)
Cryptanalysis Attacks
• Based on knowledge
– Properties of the encryption algorithm
– Properties of the likely plaintext

• Often combined with exhaustive search
– Knowledge eliminates most possible keys
– Search now feasible for few remaining keys

All possible keys                 Eliminated by
cryptanalysis
Remaining keys               Search feasible
Frequency-based Analysis
Some letters much more common than others
Frequency-based Analysis
Example ciphertext:
“PCRGFNICRAYJHVRYICJQNGRSRGIV”
Letter frequencies:
A   1    H   1   O   0   V   2
B   0    I   3   P   1   W 0
C   3    J   2   Q   1   X   0
D   0    K   0   R   5   Y   2   Hypothesis:
E   0    L   0   S   1   Z   0   “e”  “R”
F   1    M   0   T   0
G   3    N   2   U   0
Frequency-based Analysis
• Some combinations of letters much more
common than others
Example: “e” often followed by “n”

Example ciphertext (after “e” substituted for “R”):
“PCeGFNICeAYJHVeYICJQNGeSeGIV”
• “G” second most common letter
• Follows “e” twice
Hypothesis: “n”  “G”
“PCenFNICeAYJHVeYICJQNneSenIV”
Frequency-based Analysis
• Knowing part of key in monoalphabetic
Side Point

substitution makes it easier to guess the
rest of the key
• Very bad property of an encryption
algorithm!

“I can only see part of
the key, but it is easy
to guess the rest!”
Frequency-based Analysis
• Success of frequency-based analysis
Side Point

increases with more text
– Single long ciphertext
– Multiple ciphertexts encoded with same key

ciphertexts

• General property of cryptanalysis
• Should change key as often as possible!
Polyalphabetic Substitution
• Single plaintext character may map to
multiple possible ciphertext characters
• Frequency analysis attacks much harder

Example: Vigenére cipher
• Key = some word or phrase of length n
• ci = (pi + ki mod n) mod 26
Vigenére cipher
Vigenére cipher
Example:
• Key: “python”
• Plaintext: “rabbitwithbigpointyteeth”
Ciphertext:

r a b b i t w i t h b i g p o i n t y t e e t h
p y t h o n p y t h o n p y t h o n p y t h o n
G Y U I V G L G M Y M V V N H P B G N R P L H U
Polyalphabetic Substitution
• Vigenére cipher still vulnerable to frequency-
based cryptanalysis
– Guess key size n
– Treat like n different monoalphabetic substitutions

• General principle:
Larger n  more secure

(that is, number of
characters before repetition)
Enigma
• Developed by Germany in
WW2
• Arguably most complex pre-
computer substitution cipher

Flash simulation at
http://enigmaco.de/enigma/enigma.html
Enigma
Enigma
• Consists of 3 to 5 rotors
– Each rotor is a monoalphabetic mapping of a plaintext
character to a ciphertext character
– Output of one rotor fed into input of next rotor so final
output the result of 3 to 5 monoalphabetic substitutions
• Rotors turn after each character!
– Fast rotor: every character
– Middle rotor: every 26 characters
– Slow rotor: every 26 x 26 = 676 characters
Enigma
Enigma
• “C” typed as first character:
–   “C” connected to 26 on fast rotor 
–   26 connected to 7 on middle rotor 
–   7 connected to 20 on slow rotor 
–   20 connected to “E” (then reflected back through)

• “C” typed as second character (after fast rotator
turns one character):
–   “C” connected to 25 on fast rotor 
–   25 connected to 23 on middle rotor 
–   23 connected to 9 on slow rotor 
–   9 connected to “O” (then reflected back through)
Enigma
• 26 x 26 x 26 = 17,576 characters entered
before repetition
• Essentially invulnerable to frequency-based
cryptanalysis
(particularly if rotors changed at regular intervals)

• Required Alan Turing’s Bletchley Group to crack
– Captured machines to understand patterns
– Large numbers of known plaintexts
– Exhaustive searches using primitive computers
• Idea: Make key as long as the message
itself!
(Joseph Mauborgne)

• Unconditionally secure
since inherently ambiguous for attacker
Example:
• Ciphertext: NZAKBMK
• Possible Vigenére keys: wtnkxmm   and   nlvwker
Ciphertext:    NZAKBMK        NZAKBMK
Possible keys: nlvwker        wtnkxmm
Plaintext:     goforit        runaway

• Which key is correct?                      ???
We have no way of knowing
since both are plausible plaintext!
Only get to use a key for one message
• Unlikely that different possible keys would still both result in
plausible plaintext for more than one message
• Adversary could find correct key by process of elimination
Ciphertext:        WMGKZX                WMGKZX
Possible keys:     nlvwke                wtnkxm
Plaintext:         jblopt                attack

• Would need to securely distribute
“This is the
a new key for each message!                         one!”
Transposition Cipher
• Ciphertext = Permutation of plaintext
• Simple example:
runaway         r     n    w     y

u  a         a
 rnwyuaa
• Key = permutation order
Above example: 1357246
Column Transposition Ciphers
• Common approach: columns
• Example:
Plaintext: longlongagoinagalaxyfaraway
Key: 5241763 (size n of key = 7 columns)

5241763
longlon              Break plaintext into
gagoina              rows of size n of key
galaxyf
arawayx        Insert extra chars to fill columns
Column Transposition Ciphers
5   2   4   1   7   6   3
• For column with label i:    l   o   n   g   l   o   n
– Append contents of       g   a   g   o   i   n   a
column i to ciphertext   g   a   l   a   x   y   f
a   r   a   w   a   y   x

• Resulting ciphertext:               This column first
goaw oaar nafx ngla
This column second,
lgga onyy lixa                      and so on
Column Transposition Ciphers
• Decryption:
– Divide ciphertext into n strings
– Arrange strings into columns, with order of
columns determined by key
goawoaarnafxnglalggaonyylixa
5   2   4   1   7   6   3
l   o   n   g   l   o   n
g   a   g   o   i   n   a
g   a   l   a   x   y   f
a   r   a   w   a   y   x
Attacks on Transposition Ciphers
• Brute force: Trying all possible permutations
– Key of size n  n! possible keys
– Solution: Choose key such that n! tests is
computationally secure
• Cryptographic attacks:
– Eliminate column pairs with
i   a
x   f
a   x
Attacks on Transposition Ciphers
• Can apply transposition multiple times with
same key to defeat cryptographic attacks
• Example:
Ciphertext after first permutation:
goawoaarnafxngla
lggaonyylixa                    5     2   4   1   7   6   3
g     o   a   w   o   a   a
Ciphertext after second         r     n   a   f   x   n   g
permutation:                    l     a   l   g   g   a   o
wfglonayagoaaaly
n     y   y   l   i   x   a
grnlanaxoxgi
Using Multiple Keys
• Important question:
Does using multiple keys always make
encryption more secure?
– Brute force attacks
– Cryptographic attacks

• Mathematically:
C = E(E(p, k1), k2)

Is this more secure than C = E(p, k1)?
Using Multiple Keys
Only if:
• Using multiple keys greatly increases the
number of possible ciphertexts
Possible ciphertexts         After applying K1 and K2

Possible ciphertexts     After applying K1

• Applying multiple keys is not equivalent to
applying a single key
No k3 such that E(E(p, k1), k2) = E(p, k3)
Using Multiple Keys
• Example: Caesar cipher with 2 keys
K1 = 3       K2 = 8
– Equivalent to single key K3 = 11
– Still only 26 possible mappings from P to C

• Example: Transposition cipher with 2 keys
K1 = 5241763 K2 = 7325641
– Equivalent to single key K3 = 6357142
– Still only 7! possible mappings from P to C

No more secure in either case!
Avalanche Effect
Small change in key 
Large change in ciphertext

• Desirable property of cipher
Knowing some of key  rest of key still hard to find

• Not a property of substitution ciphers
• Property of transposition ciphers
(particularly if applied multiple times)
Avalanche Effect
Example: two similar keys applied twice
• plaintext = longlongagoinagalaxyfaraway
• k1 = 5241763
ciphertext =
wfglonayagoaaalygrnlanaxoxgi
• k2 = 5421763
ciphertext =
wfglaalylaoaonrygaangoaxnxgi

• Already different in 14 of 28 characters
Substitution and Transposition
• Most modern ciphers combine substitution
and transposition
– Substitution gives large number of possible
keys to defeat brute force attacks
– Transposition gives avalanche effect to defeat
cryptographic attacks

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 7 posted: 6/23/2012 language: pages: 42
How are you planning on using Docstoc?