1. Cryptography and
Cryptography and
Network Security
Network Security
Chapter 2
Chapter 2
Fourth Edition
Fourth Edition
by William Stallings
by William Stallings
Lecture slides by Lawrie Brown
Lecture slides by Lawrie Brown
2. Chapter 2 –
Chapter 2 – Classical Encryption
Classical Encryption
Techniques
Techniques
Many savages at the present day regard their
Many savages at the present day regard their
names as vital parts of themselves, and
names as vital parts of themselves, and
therefore take great pains to conceal their real
therefore take great pains to conceal their real
names, lest these should give to evil-disposed
names, lest these should give to evil-disposed
persons a handle by which to injure their
persons a handle by which to injure their
owners.
owners.
—
—The Golden Bough,
The Golden Bough, Sir James George Frazer
Sir James George Frazer
3. Symmetric Encryption
Symmetric Encryption
or conventional /
or conventional / private-key
private-key / single-key
/ single-key
sender and recipient share a common key
sender and recipient share a common key
all classical encryption algorithms are
all classical encryption algorithms are
private-key
private-key
was only type prior to invention of public-
was only type prior to invention of public-
key in 1970’s
key in 1970’s
and by far most widely used
and by far most widely used
4. Some Basic Terminology
Some Basic Terminology
plaintext
plaintext - original message
- original message
ciphertext
ciphertext - coded message
- coded message
cipher
cipher - algorithm for transforming plaintext to ciphertext
- algorithm for transforming plaintext to ciphertext
key
key - info used in cipher known only to sender/receiver
- info used in cipher known only to sender/receiver
encipher (encrypt)
encipher (encrypt) - converting plaintext to ciphertext
- converting plaintext to ciphertext
decipher (decrypt)
decipher (decrypt) - recovering ciphertext from plaintext
- recovering ciphertext from plaintext
cryptography
cryptography - study of encryption principles/methods
- study of encryption principles/methods
cryptanalysis (codebreaking)
cryptanalysis (codebreaking) - study of principles/
- study of principles/
methods of deciphering ciphertext
methods of deciphering ciphertext without
without knowing key
knowing key
cryptology
cryptology - field of both cryptography and cryptanalysis
- field of both cryptography and cryptanalysis
6. Requirements
Requirements
two requirements for secure use of
two requirements for secure use of
symmetric encryption:
symmetric encryption:
a strong encryption algorithm
a strong encryption algorithm
a secret key known only to sender / receiver
a secret key known only to sender / receiver
mathematically have:
mathematically have:
Y
Y = E
= EK
K(
(X
X)
)
X
X = D
= DK
K(
(Y
Y)
)
assume encryption algorithm is known
assume encryption algorithm is known
implies a secure channel to distribute key
implies a secure channel to distribute key
7. Cryptography
Cryptography
characterize cryptographic system by:
characterize cryptographic system by:
type of encryption operations used
type of encryption operations used
• substitution / transposition / product
substitution / transposition / product
number of keys used
number of keys used
• single-key or private / two-key or public
single-key or private / two-key or public
way in which plaintext is processed
way in which plaintext is processed
• block / stream
block / stream
8. Cryptanalysis
Cryptanalysis
objective to recover key not just message
objective to recover key not just message
general approaches:
general approaches:
cryptanalytic attack
cryptanalytic attack
brute-force attack
brute-force attack
9. Cryptanalytic Attacks
Cryptanalytic Attacks
ciphertext only
ciphertext only
only know algorithm & ciphertext, is statistical,
only know algorithm & ciphertext, is statistical,
know or can identify plaintext
know or can identify plaintext
known plaintext
known plaintext
know/suspect plaintext & ciphertext
know/suspect plaintext & ciphertext
chosen plaintext
chosen plaintext
select plaintext and obtain ciphertext
select plaintext and obtain ciphertext
chosen ciphertext
chosen ciphertext
select ciphertext and obtain plaintext
select ciphertext and obtain plaintext
chosen text
chosen text
select plaintext or ciphertext to en/decrypt
select plaintext or ciphertext to en/decrypt
10. More Definitions
More Definitions
unconditional security
unconditional security
no matter how much computer power or time
no matter how much computer power or time
is available, the cipher cannot be broken
is available, the cipher cannot be broken
since the ciphertext provides insufficient
since the ciphertext provides insufficient
information to uniquely determine the
information to uniquely determine the
corresponding plaintext
corresponding plaintext
computational security
computational security
given limited computing resources (eg time
given limited computing resources (eg time
needed for calculations is greater than age of
needed for calculations is greater than age of
universe), the cipher cannot be broken
universe), the cipher cannot be broken
11. Brute Force Search
Brute Force Search
always possible to simply try every key
always possible to simply try every key
most basic attack, proportional to key size
most basic attack, proportional to key size
assume either know / recognise plaintext
assume either know / recognise plaintext
Key Size (bits) Number of Alternative
Keys
Time required at 1
decryption/µs
Time required at 106
decryptions/µs
32 232
= 4.3 109
231
µs = 35.8 minutes 2.15 milliseconds
56 256
= 7.2 1016
255
µs = 1142 years 10.01 hours
128 2128
= 3.4 1038
2127
µs = 5.4 1024
years 5.4 1018
years
168 2168
= 3.7 1050
2167
µs = 5.9 1036
years 5.9 1030
years
26 characters
(permutation)
26! = 4 1026
2 1026
µs = 6.4 1012
years 6.4 106
years
12. Classical Substitution
Classical Substitution
Ciphers
Ciphers
where
where letters of plaintext are replaced by
letters of plaintext are replaced by
other letters or by numbers or symbols
other letters or by numbers or symbols
or if plaintext is
or if plaintext is viewed as a sequence of
viewed as a sequence of
bits, then substitution involves replacing
bits, then substitution involves replacing
plaintext bit patterns with ciphertext bit
plaintext bit patterns with ciphertext bit
patterns
patterns
13. Caesar Cipher
Caesar Cipher
earliest known substitution cipher
earliest known substitution cipher
by Julius Caesar
by Julius Caesar
first attested use in military affairs
first attested use in military affairs
replaces each letter by 3rd letter on
replaces each letter by 3rd letter on
example:
example:
meet me after the toga party
meet me after the toga party
PHHW PH DIWHU WKH WRJD SDUWB
PHHW PH DIWHU WKH WRJD SDUWB
14. Caesar Cipher
Caesar Cipher
can define transformation as:
can define transformation as:
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
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 F G H I J K L M N O P Q R S T U V W X Y Z A B C
mathematically give each letter a number
mathematically give each letter a number
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
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
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
then have Caesar cipher as:
then have Caesar cipher as:
c
c = E(
= E(p
p) = (
) = (p
p +
+ k
k) mod (26)
) mod (26)
p
p = D(c) = (c –
= D(c) = (c – k
k) mod (26)
) mod (26)
15. Cryptanalysis of Caesar
Cryptanalysis of Caesar
Cipher
Cipher
only have 26 possible ciphers
only have 26 possible ciphers
A maps to A,B,..Z
A maps to A,B,..Z
could simply try each in turn
could simply try each in turn
a
a brute force search
brute force search
given ciphertext, just try all shifts of letters
given ciphertext, just try all shifts of letters
do need to recognize when have plaintext
do need to recognize when have plaintext
eg. break ciphertext "GCUA VQ DTGCM"
eg. break ciphertext "GCUA VQ DTGCM"
16. Monoalphabetic Cipher
Monoalphabetic Cipher
rather than just shifting the alphabet
rather than just shifting the alphabet
could shuffle (jumble) the letters arbitrarily
could shuffle (jumble) the letters arbitrarily
each plaintext letter maps to a different random
each plaintext letter maps to a different random
ciphertext letter
ciphertext letter
hence key is 26 letters long
hence key is 26 letters long
Plain: abcdefghijklmnopqrstuvwxyz
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: ifwewishtoreplaceletters
Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
17. Monoalphabetic Cipher
Monoalphabetic Cipher
Security
Security
now have a total of 26! = 4 x 1026 keys
now have a total of 26! = 4 x 1026 keys
with so many keys, might think is secure
with so many keys, might think is secure
but would be
but would be !!!WRONG!!!
!!!WRONG!!!
problem is language characteristics
problem is language characteristics
18. Language Redundancy and
Language Redundancy and
Cryptanalysis
Cryptanalysis
human languages are
human languages are redundant
redundant
eg "th lrd s m shphrd shll nt wnt"
eg "th lrd s m shphrd shll nt wnt"
letters are not equally commonly used
letters are not equally commonly used
in English E is by far the most common letter
in English E is by far the most common letter
followed by T,R,N,I,O,A,S
followed by T,R,N,I,O,A,S
other letters like Z,J,K,Q,X are fairly rare
other letters like Z,J,K,Q,X are fairly rare
have tables of single, double & triple letter
have tables of single, double & triple letter
frequencies for various languages
frequencies for various languages
20. Use in Cryptanalysis
Use in Cryptanalysis
key concept - monoalphabetic substitution
key concept - monoalphabetic substitution
ciphers do not change relative letter frequencies
ciphers do not change relative letter frequencies
discovered by Arabian scientists in 9
discovered by Arabian scientists in 9th
th
century
century
calculate letter frequencies for ciphertext
calculate letter frequencies for ciphertext
compare counts/plots against known values
compare counts/plots against known values
if caesar cipher look for common peaks/troughs
if caesar cipher look for common peaks/troughs
peaks at: A-E-I triple, NO pair, RST triple
peaks at: A-E-I triple, NO pair, RST triple
troughs at: JK, X-Z
troughs at: JK, X-Z
for
for monoalphabetic must identify each letter
monoalphabetic must identify each letter
tables of common double/triple letters help
tables of common double/triple letters help
21. Example Cryptanalysis
Example Cryptanalysis
given ciphertext:
given ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
count relative letter frequencies (see text)
count relative letter frequencies (see text)
guess P & Z are e and t
guess P & Z are e and t
guess ZW is th and hence ZWP is the
guess ZW is th and hence ZWP is the
proceeding with trial and error finally get:
proceeding with trial and error finally get:
it was disclosed yesterday that several informal but
it was disclosed yesterday that several informal but
direct contacts have been made with political
direct contacts have been made with political
representatives of the viet cong in moscow
representatives of the viet cong in moscow
22. Playfair Cipher
Playfair Cipher
not even the large number of keys in a
not even the large number of keys in a
monoalphabetic cipher provides security
monoalphabetic cipher provides security
one approach to improving security was to
one approach to improving security was to
encrypt multiple letters
encrypt multiple letters
the
the Playfair Cipher
Playfair Cipher is an example
is an example
invented by Charles Wheatstone in 1854,
invented by Charles Wheatstone in 1854,
but named after his friend Baron Playfair
but named after his friend Baron Playfair
23. Playfair Key Matrix
Playfair Key Matrix
a 5X5 matrix of letters based on a keyword
a 5X5 matrix of letters based on a keyword
fill in letters of keyword (sans duplicates)
fill in letters of keyword (sans duplicates)
fill rest of matrix with other letters
fill rest of matrix with other letters
eg. using the keyword MONARCHY
eg. using the keyword MONARCHY
M
M O
O N
N A
A R
R
C
C H
H Y
Y B
B D
D
E
E F
F G
G I/J
I/J K
K
L
L P
P Q
Q S
S T
T
U
U V
V W
W X
X Z
Z
24. Encrypting and Decrypting
Encrypting and Decrypting
plaintext is encrypted two letters at a time
plaintext is encrypted two letters at a time
1.
1. if a pair is a repeated letter, insert filler like 'X’
if a pair is a repeated letter, insert filler like 'X’
2.
2. if both letters fall in the same row, replace
if both letters fall in the same row, replace
each with letter to right
each with letter to right (wrapping back to start
(wrapping back to start
from end)
from end)
3.
3. if both letters fall in the same column, replace
if both letters fall in the same column, replace
each with the letter below it (again wrapping to
each with the letter below it (again wrapping to
top from bottom)
top from bottom)
4.
4. otherwise each letter is replaced by the letter
otherwise each letter is replaced by the letter
in the same row and in the column of the other
in the same row and in the column of the other
letter of the pair
letter of the pair
25. Security of Playfair Cipher
Security of Playfair Cipher
security much improved over monoalphabetic
security much improved over monoalphabetic
since have 26 x 26 = 676 digrams
since have 26 x 26 = 676 digrams
would need a 676 entry frequency table to
would need a 676 entry frequency table to
analyse (verses 26 for a monoalphabetic)
analyse (verses 26 for a monoalphabetic)
and correspondingly more ciphertext
and correspondingly more ciphertext
was widely used for many years
was widely used for many years
eg. by US & British military in WW1
eg. by US & British military in WW1
it
it can
can be broken, given a few hundred letters
be broken, given a few hundred letters
since still has much of plaintext structure
since still has much of plaintext structure
26. Polyalphabetic Ciphers
Polyalphabetic Ciphers
polyalphabetic substitution ciphers
polyalphabetic substitution ciphers
improve security using multiple cipher alphabets
improve security using multiple cipher alphabets
make cryptanalysis harder with more alphabets
make cryptanalysis harder with more alphabets
to guess and flatter frequency distribution
to guess and flatter frequency distribution
use a key to select which alphabet is used for
use a key to select which alphabet is used for
each letter of the message
each letter of the message
use each alphabet in turn
use each alphabet in turn
repeat from start after end of key is reached
repeat from start after end of key is reached
27. Vigenère Cipher
Vigenère Cipher
simplest polyalphabetic substitution cipher
simplest polyalphabetic substitution cipher
effectively multiple caesar ciphers
effectively multiple caesar ciphers
key is multiple letters long K = k
key is multiple letters long K = k1
1 k
k2
2 ... k
... kd
d
i
ith
th
letter specifies i
letter specifies ith
th
alphabet to use
alphabet to use
use each alphabet in turn
use each alphabet in turn
repeat from start after d letters in message
repeat from start after d letters in message
decryption simply works in reverse
decryption simply works in reverse
28. Example of
Example of Vigenère Cipher
Vigenère Cipher
write the plaintext out
write the plaintext out
write the keyword repeated above it
write the keyword repeated above it
use each key letter as a caesar cipher key
use each key letter as a caesar cipher key
encrypt the corresponding plaintext letter
encrypt the corresponding plaintext letter
eg using keyword
eg using keyword deceptive
deceptive
key: deceptivedeceptivedeceptive
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
plaintext: wearediscoveredsaveyourself
ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMGJ
ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMGJ
29. Aids
Aids
simple aids can assist with en/decryption
simple aids can assist with en/decryption
a
a Saint-Cyr Slide
Saint-Cyr Slide is a simple manual aid
is a simple manual aid
a slide with repeated alphabet
a slide with repeated alphabet
line up plaintext 'A' with key letter, eg 'C'
line up plaintext 'A' with key letter, eg 'C'
then read off any mapping for key letter
then read off any mapping for key letter
can bend round into a
can bend round into a cipher disk
cipher disk
or expand into a
or expand into a Vigenère Tableau
Vigenère Tableau
30. Security of
Security of Vigenère Ciphers
Vigenère Ciphers
have multiple ciphertext letters for each
have multiple ciphertext letters for each
plaintext letter
plaintext letter
hence letter frequencies are obscured
hence letter frequencies are obscured
but not totally lost
but not totally lost
start with letter frequencies
start with letter frequencies
see if look monoalphabetic or not
see if look monoalphabetic or not
if not, then need to determine number of
if not, then need to determine number of
alphabets, since then can attach each
alphabets, since then can attach each
31. Kasiski Method
Kasiski Method
method developed by Babbage / Kasiski
method developed by Babbage / Kasiski
repetitions in ciphertext give clues to period
repetitions in ciphertext give clues to period
so find same plaintext an exact period apart
so find same plaintext an exact period apart
which results in the same ciphertext
which results in the same ciphertext
of course, could also be random fluke
of course, could also be random fluke
eg repeated “VTW” in previous example
eg repeated “VTW” in previous example
suggests size of 3 or 9
suggests size of 3 or 9
then attack each monoalphabetic cipher
then attack each monoalphabetic cipher
individually using same techniques as before
individually using same techniques as before
32. Autokey Cipher
Autokey Cipher
ideally want a key as long as the message
ideally want a key as long as the message
Vigenère proposed the
Vigenère proposed the autokey
autokey cipher
cipher
with keyword is prefixed to message as key
with keyword is prefixed to message as key
knowing keyword can recover the first few letters
knowing keyword can recover the first few letters
use these in turn on the rest of the message
use these in turn on the rest of the message
but still have frequency characteristics to attack
but still have frequency characteristics to attack
eg. given key
eg. given key deceptive
deceptive
key: deceptivewearediscoveredsav
key: deceptivewearediscoveredsav
plaintext: wearediscoveredsaveyourself
plaintext: wearediscoveredsaveyourself
ciphertext:ZICVTWQNGKZEIIGASXSTSLVVWLA
ciphertext:ZICVTWQNGKZEIIGASXSTSLVVWLA
33. One-Time Pad
One-Time Pad
if a truly random key as long as the message is
if a truly random key as long as the message is
used, the cipher will be secure
used, the cipher will be secure
called a One-Time pad
called a One-Time pad
is unbreakable since ciphertext bears no
is unbreakable since ciphertext bears no
statistical relationship to the plaintext
statistical relationship to the plaintext
since for
since for any plaintext
any plaintext &
& any ciphertext
any ciphertext there
there
exists a key mapping one to other
exists a key mapping one to other
can only use the key
can only use the key once
once though
though
problems in generation & safe distribution of key
problems in generation & safe distribution of key
34. Transposition Ciphers
Transposition Ciphers
now consider classical
now consider classical transposition
transposition or
or
permutation
permutation ciphers
ciphers
these hide the message by rearranging
these hide the message by rearranging
the letter order
the letter order
without altering the actual letters used
without altering the actual letters used
can recognise these since have the same
can recognise these since have the same
frequency distribution as the original text
frequency distribution as the original text
35. Rail Fence cipher
Rail Fence cipher
write message letters out diagonally over a
write message letters out diagonally over a
number of rows
number of rows
then read off cipher row by row
then read off cipher row by row
eg. write message out as:
eg. write message out as:
m e m a t r h t g p r y
m e m a t r h t g p r y
e t e f e t e o a a t
e t e f e t e o a a t
giving ciphertext
giving ciphertext
MEMATRHTGPRYETEFETEOAAT
MEMATRHTGPRYETEFETEOAAT
36. Row Transposition Ciphers
Row Transposition Ciphers
a more complex transposition
a more complex transposition
write letters of message out in rows over a
write letters of message out in rows over a
specified number of columns
specified number of columns
then reorder the columns according to
then reorder the columns according to
some key before reading off the rows
some key before reading off the rows
Key: 3 4 2 1 5 6 7
Key: 3 4 2 1 5 6 7
Plaintext: a t t a c k p
Plaintext: a t t a c k p
o s t p o n e
o s t p o n e
d u n t i l t
d u n t i l t
w o a m x y z
w o a m x y z
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
37. Product Ciphers
Product Ciphers
ciphers using substitutions or transpositions are
ciphers using substitutions or transpositions are
not secure because of language characteristics
not secure because of language characteristics
hence consider using several ciphers in
hence consider using several ciphers in
succession to make harder, but:
succession to make harder, but:
two substitutions make a more complex substitution
two substitutions make a more complex substitution
two transpositions make more complex transposition
two transpositions make more complex transposition
but a substitution followed by a transposition makes a
but a substitution followed by a transposition makes a
new much harder cipher
new much harder cipher
this is bridge from classical to modern ciphers
this is bridge from classical to modern ciphers
38. Rotor Machines
Rotor Machines
before modern ciphers, rotor machines were
before modern ciphers, rotor machines were
most common complex ciphers in use
most common complex ciphers in use
widely used in WW2
widely used in WW2
German Enigma, Allied Hagelin, Japanese Purple
German Enigma, Allied Hagelin, Japanese Purple
implemented a very complex, varying
implemented a very complex, varying
substitution cipher
substitution cipher
used a series of cylinders, each giving one
used a series of cylinders, each giving one
substitution, which rotated and changed after
substitution, which rotated and changed after
each letter was encrypted
each letter was encrypted
with 3 cylinders have 26
with 3 cylinders have 263
3
=17576 alphabets
=17576 alphabets
40. Steganography
Steganography
an alternative to encryption
an alternative to encryption
hides existence of message
hides existence of message
using only a subset of letters/words in a
using only a subset of letters/words in a
longer message marked in some way
longer message marked in some way
using invisible ink
using invisible ink
hiding in LSB in graphic image or sound file
hiding in LSB in graphic image or sound file
has drawbacks
has drawbacks
high overhead to hide relatively few info bits
high overhead to hide relatively few info bits
41. Summary
Summary
have considered:
have considered:
classical cipher techniques and terminology
classical cipher techniques and terminology
monoalphabetic substitution ciphers
monoalphabetic substitution ciphers
cryptanalysis using letter frequencies
cryptanalysis using letter frequencies
Playfair cipher
Playfair cipher
polyalphabetic ciphers
polyalphabetic ciphers
transposition ciphers
transposition ciphers
product ciphers and rotor machines
product ciphers and rotor machines
stenography
stenography
Editor's Notes
#1:Lecture slides by Lawrie Brown for “Cryptography and Network Security”, 4/e, by William Stallings, Chapter 2 – “Classical Encryption Techniques”.
#3:Symmetric encryption, also referred to as conventional encryption or single-key encryption, was the only type of encryption in use prior to the development of public-key encryption in the 1970s. It remains by far the most widely used of the two types of encryption. All traditional schemes are symmetric / single key / private-key encryption algorithms, with a single key, used for both encryption and decryption. Since both sender and receiver are equivalent, either can encrypt or decrypt messages using that common key.
#4:Briefly review some terminology used throughout the course.
#5:Detail the five ingredients of the symmetric cipher model, shown in Stallings Figure 2.1:
plaintext - original message
encryption algorithm – performs substitutions/transformations on plaintext
secret key – control exact substitutions/transformations used in encryption algorithm
ciphertext - scrambled message
decryption algorithm – inverse of encryption algorithm
#6:We assume that it is impractical to decrypt a message on the basis of the cipher- text plus knowledge of the encryption/decryption algorithm, and do not need to keep the algorithm secret; rather we only need to keep the key secret. This feature of symmetric encryption is what makes it feasible for widespread use. It allows easy distribution of s/w and h/w implementations.
Can take a closer look at the essential elements of a symmetric encryption scheme: mathematically it can be considered a pair of functions with: plaintext X, ciphertext Y, key K, encryption algorithm EK, decryption algorithm DK.
#7:Cryptographic systems can be characterized along these three independent dimensions.
#8:Typically objective is to recover the key in use rather then simply to recover the plaintext of a single ciphertext.
There are two general approaches:
Cryptanalytic attacks rely on the nature of the algorithm plus perhaps some knowledge of the general characteristics of the plaintext or even some sample plaintext-ciphertext pairs.
Brute-force attacks try every possible key on a piece of ciphertext until an intelligible translation into plaintext is obtained. On average,half of all possible keys must be tried to achieve success.
#9:Stallings Table 2.1 summarizes the various types of cryptanalytic attacks, based on the amount of information known to the cryptanalyst, from least to most. The most difficult problem is presented when all that is available is the ciphertext only. In some cases, not even the encryption algorithm is known, but in general we can assume that the opponent does know the algorithm used for encryption. Then with increasing information have the other attacks. Generally, an encryption algorithm is designed to withstand a known-plaintext attack.
#10:Two more definitions are worthy of note. An encryption scheme is unconditionally secure if the ciphertext generated by the scheme does not contain enough information to determine uniquely the corresponding plaintext, no matter how much ciphertext is available. An encryption scheme is said to be computationally secure if either the cost of breaking the cipher exceeds the value of the encrypted information, or the time required to break the cipher exceeds the useful lifetime of the information. Unconditional security would be nice, but the only known such cipher is the one-time pad (later).
For all reasonable encryption algorithms, we have to assume computational security where it either takes too long, or is too expensive, to bother breaking the cipher.
#11:A brute-force attack involves trying every possible key until an intelligible translation of the ciphertext into plaintext is obtained. On average, half of all possible keys must be tried to achieve success. Stallings Table 2.2 shows how much time is required to conduct a brute-force attack, for various common key sizes (DES is 56, AES is 128, Triple-DES is 168, plus general mono-alphabetic cipher), where either a single system or a million parallel systems, are used.
#12:In this section and the next, we examine a sampling of what might be called classical encryption techniques. A study of these techniques enables us to illustrate the basic approaches to symmetric encryption used today and the types of cryptanalytic attacks that must be anticipated. The two basic building blocks of all encryption technique are substitution and transposition. We examine these in the next two sections. Finally, we discuss a system that combine both substitution and transposition.
#13:Substitution ciphers form the first of the fundamental building blocks. The core idea is to replace one basic unit (letter/byte) with another. Whilst the early Greeks described several substitution ciphers, the first attested use in military affairs of one was by Julius Caesar, described by him in Gallic Wars (cf. Kahn pp83-84). Still call any cipher using a simple letter shift a caesar cipher, not just those with shift 3.
#14:This mathematical description uses modulo (clock) arithmetic. Here, when you reach Z you go back to A and start again. Mod 26 implies that when you reach 26, you use 0 instead (ie the letter after Z, or 25 + 1 goes to A or 0).
Example: howdy (7,14,22,3,24) encrypted using key f (ie a shift of 5) is MTBID
#15:With a caesar cipher, there are only 26 possible keys, of which only 25 are of any use, since mapping A to A etc doesn't really obscure the message! Note this basic rule of cryptanalysis "check to ensure the cipher operator hasn't goofed and sent a plaintext message by mistake"!
Can try each of the keys (shifts) in turn, until can recognise the original message. See Stallings Fig 2.3 for example of search.
Note: as mentioned before, do need to be able to recognise when have an original message (ie is it English or whatever). Usually easy for humans, hard for computers. Though if using say compressed data could be much harder.
Example "GCUA VQ DTGCM" when broken gives "easy to break", with a shift of 2 (key C).
#16:With only 25 possible keys, the Caesar cipher is far from secure. A dramatic increase in the key space can be achieved by allowing an arbitrary substitution, where the translation alphabet can be any permutation of the 26 alphabetic characters.
See example translation alphabet, and an encrypted message using it.
#17:Note that even given the very large number of keys, being 10 orders of magnitude greater than the key space for DES, the monoalphabetic substitution cipher is not secure, because it does not sufficiently obscure the underlying language characteristics.
#18:As the example shows, we don't actually need all the letters in order to understand written English text. Here vowels were removed, but they're not the only redundancy. cf written Hebrew has no vowels for same reason. Are usually familiar with "party conversations", can hear one person speaking out of hubbub of many, again because of redundancy in aural language also. This redundancy is also the reason we can compress text files, the computer can derive a more compact encoding without losing any information. Basic idea is to count the relative frequencies of letters, and note the resulting pattern.
#19:Note that all human languages have varying letter frequencies, though the number of letters and their frequencies varies. Stallings Figure 2.5 shows English letter frequencies. Seberry & Pieprzyk, "Cryptography - An Introduction to Computer Security", Prentice-Hall 1989, Appendix A has letter frequency graphs for 20 languages (most European & Japanese & Malay).
#20:The simplicity and strength of the monoalphabetic substitution cipher meant it dominated cryptographic use for the first millenium AD. It was broken by Arabic scientists. The earliest known description is in Abu al-Kindi's "A Manuscript on Deciphering Cryptographic Messages", published in the 9th century but only rediscovered in 1987 in Istanbul, but other later works also attest to their knowledge of the field. Monoalphabetic ciphers are easy to break because they reflect the frequency data of the original alphabet. The cryptanalyst looks for a mapping between the observed pattern in the ciphertext, and the known source language letter frequencies. If English, look for peaks at: A-E-I triple, NO pair, RST triple, and troughs at: JK, X-Z.
#21:Illustrate the process with this example from the text in Stallings section 2.2.
#22:Consider ways to reduce the "spikyness" of natural language text, since if just map one letter always to another, the frequency distribution is just shuffled. One approach is to encrypt more than one letter at once. The Playfair cipher is an example of doing this.
#23:The best-known multiple-letter encryption cipher is the Playfair, which treats digrams in the plaintext as single units and translates these units into ciphertext digrams. The Playfair algorithm is based on the use of a 5x5 matrix of letters constructed using a keyword. The rules for filling in this 5x5 matrix are: L to R, top to bottom, first with keyword after duplicate letters have been removed, and then with the remain letters, with I/J used as a single letter. This example comes from Dorothy Sayer's book "Have His Carcase", in which Lord Peter Wimsey solves it, and describes the use of a probably word attack.
#24:Plaintext is encrypted two letters at a time,according to the rules as shown. Note how you wrap from right side back to left, or from bottom back to top.
if a pair is a repeated letter, insert a filler like 'X', eg. "balloon" encrypts as "ba lx lo on"
if both letters fall in the same row, replace each with letter to right (wrapping back to start from end), eg. “ar" encrypts as "RM"
if both letters fall in the same column, replace each with the letter below it (again wrapping to top from bottom), eg. “mu" encrypts to "CM"
otherwise each letter is replaced by the one in its row in the column of the other letter of the pair, eg. “hs" encrypts to "BP", and “ea" to "IM" or "JM" (as desired)
Decrypting of course works exactly in reverse. Can see this by working the example pairs shown, backwards.
#25:The Playfair cipher is a great advance over simple monoalphabetic ciphers, since there are 26*26=676 digrams (vs 26 letters), so that identification of individual digrams is more difficult. Also,the relative frequencies of individual letters exhibit a much greater range than that of digrams, making frequency analysis much more difficult. The Playfair cipher was for a long time considered unbreakable. It was used as the standard field system by the British Army in World War I and still enjoyed considerable use by the U.S.Army and other Allied forces during World War II. Despite this level of confidence in its security,the Playfair cipher is relatively easy to break because it still leaves much of the structure of the plaintext language intact
#26:One approach to reducing the "spikyness" of natural language text is used the Playfair cipher which encrypts more than one letter at once. We now consider the other alternative, using multiple cipher alphabets in turn. This gives the attacker more work, since many alphabets need to be guessed, and because the frequency distribution is more complex, since the same plaintext letter could be replaced by several ciphertext letters, depending on which alphabet is used. The general name for this approach is a polyalphabetic substitution cipher. All these techniques have the following features in common:
A set of related monoalphabetic substitution rules is used.
2. A key determines which particular rule is chosen for a given transformation.
#27:The best known, and one of the simplest, such algorithms is referred to as the Vigenère cipher, where the set of related monoalphabetic substitution rules consists of the 26 Caesar ciphers, with shifts of 0 through 25. Each cipher is denoted by a key letter, which is the ciphertext letter that substitutes for the plaintext letter ‘a’, and which are each used in turn, as shown next.
#28:Discuss this simple example from text Stallings section 2.2.
#29:Implementing polyalphabetic ciphers by hand can be very tedious. Various aids were devised to assist the process.
The "Saint-Cyr Slide" was popularised and named by Jean Kerckhoffs, who published a famous early text "La Cryptographie Militaire" (Miltary Cryptography) in 1883. He named the slide after the French National Military Academy where the methods were taught. He also noted that any slide can be expanded into a tableau, or bent round into a cipher disk.
The Vigenère Tableau (given in the text as Stallings Table 2.3) is a complete set of forward shifted alphabet mappings.
#30:The Vigenère & related polyalphabetic ciphers still do not completely obscure the underlying language characteristics.
The key to breaking them was to identify the number of translation alphabets, and then attack each separately.
#31:For some centuries the Vigenère cipher was le chiffre indéchiffrable (the unbreakable cipher). As a result of a challenge, it was broken by Charles Babbage (the inventor of the computer) in 1854 but kept secret (possibly because of the Crimean War - not the first time governments have kept advances to themselves!). The method was independently reinvented by a Prussian, Friedrich Kasiski, who published the attack now named after him in 1863. However lack of major advances meant that various polyalphabetic substitution ciphers were used into the 20C. One very famous incident was the breaking of the Zimmermann telegram in WW1 which resulted in the USA entering the war.
In general the approach is to find a number of duplicated sequences, collect all their distances apart, look for common factors, remembering that some will be random flukes and need to be discarded. Now have a series of monoalphabetic ciphers, each with original language letter frequency characteristics. Can attack these in turn to break the cipher.
#32:Taking the polyalphabetic idea to the extreme, want as many different translation alphabets as letters in the message being sent. One way of doing this with a smallish key, is to use the Autokey cipher.
The example uses the keyword "DECEPTIVE" prefixed to as much of the message "WEAREDISCOVEREDSAV" as is needed. When deciphering, recover the first 9 letters using the keyword "DECEPTIVE". Then instead of repeating the keyword, start using the recovered letters from the message "WEAREDISC". As recover more letters, have more of key to recover later letters.
Problem is that the same language characteristics are used by the key as the message. ie. a key of 'E' will be used more often than a 'T' etc hence an 'E' encrypted with a key of 'E' occurs with probability (0.1275)2 = 0.01663, about twice as often as a 'T' encrypted with a key of 'T' have to use a larger frequency table, but it exists given sufficient ciphertext this can be broken.
#33:The One-Time Pad is an evolution of the Vernham cipher, which was invented by Gilbert Vernham in 1918, and used a long tape of random letters to encrypt the message. An Army Signal Corp officer, Joseph Mauborgne, proposed an improvement using a random key that was truly as long as the message, with no repetitions, which thus totally obscures the original message. It produces random output that bears no statistical relationship to the plaintext. Because the ciphertext contains no information whatsoever about the plaintext, there is simply no way to break the code, since any plaintext can be mapped to any ciphertext given some key.
The one-time pad offers complete security but, in practice, has two fundamental difficulties:
There is the practical problem of making large quantities of random keys.
2. And the problem of key distribution and protection, where for every message to be sent, a key of equal length is needed by both sender and receiver.
Because of these difficulties, the one-time pad is of limited utility, and is useful primarily for low-bandwidth channels requiring very high security.
#34:All the techniques examined so far involve the substitution of a ciphertext symbol for a plaintext symbol. A very different kind of mapping is achieved by performing some sort of permutation on the plaintext letters. This technique is referred to as a transposition cipher, and form the second basic building block of ciphers. The core idea is to rearrange the order of basic units (letters/bytes/bits) without altering their actual values.
#35:The simplest such cipher is the rail fence technique, in which the plaintext is written down as a sequence of diagonals and then read off as a sequence of rows.
The example message is: "meet me after the toga party" with a rail fence of depth 2.
This sort of thing would be trivial to cryptanalyze.
#36:A more complex transposition cipher is to write the message in a rectangle, row by row, and read the message off shuffling the order of the columns in each row.
A pure transposition cipher is easily recognized because it has the same letter frequencies as the original plaintext. For the type of columnar transposition just shown, cryptanalysis is fairly straightforward and involves laying out the ciphertext in a matrix and playing around with column positions. Digram and trigram frequency tables can be useful.
#37:Have seen that ciphers based on just substitutions or transpositions are not secure, and can be attacked because they do not sufficient obscure the underlying language structure
So consider using several ciphers in succession to make harder.
A substitution followed by a transposition is known as a Product Cipher, and makes a new much more secure cipher, and forms the bridge to modern ciphers.
#38:The next major advance in ciphers required use of mechanical cipher machines which enabled to use of complex varying substitutions.
A rotor machine consists of a set of independently rotating cylinders through which electrical pulses can flow. Each cylinder has 26 input pins and 26 output pins, with internal wiring that connects each input pin to a unique output pin. If we associate each input and output pin with a letter of the alphabet, then a single cylinder defines a monoalphabetic substitution. After each input key is depressed, the cylinder rotates one position, so that the internal connections are shifted accordingly. The power of the rotor machine is in the use of multiple cylinders, in which the output pins of one cylinder are connected to the input pins of the next, and with the cylinders rotating like an “odometer”, leading to a very large number of substitution alphabets being used, eg with 3 cylinders have 263=17576 alphabets used.
They were extensively used in world war 2, and the history of their use and analysis is one of the great stories from WW2.
#39:This photo of an Allied Hagelin machine was taken by Lawrie Brown at Eurocrypt'93 in Norway. Note pen for scale, and the rotating cipher wheels near the front.
#40:Steganography is an alternative to encryption which hides the very existence of a message by some means. There are a large range of techniques for doing this.
Steganography has a number of drawbacks when compared to encryption. It requires a lot of overhead to hide a relatively few bits of information.
Also, once the system is discovered, it becomes virtually worthless, although a message can be first encrypted and then hidden using steganography.