3 - Classical Encryption Schemes
3 - Classical Encryption Schemes
Encryption
Techniques
DR FAISAL BASHIR
Cryptography
Comes from Greek kryptós "hidden" and
gráfein "to write"
Key Size (bits) Number of Alternative Time required at 1 Time required at 106
Keys decryption/µs decryptions/µs
32 232 = 4.3 109 231 µs = 35.8 minutes 2.15 milliseconds
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 26! = 4 1026 2 1026 µs = 6.4 1012 years 6.4 106 years
(permutation)
Cryptanalytic Attacks
ciphertext only
only knows algorithm & ciphertext
known plaintext
know/suspect plaintext & ciphertext
chosen plaintext
select plaintext and obtain ciphertext
chosen ciphertext
select ciphertext and obtain plaintext
Example: chosen-plaintext attack
In 1942, US Navy cryptanalysts discovered
that Japan was planning an attack on “AF”.
They believed that “AF” means Midway
island.
Pentagon didn’t think so.
US forces in Midway sent a plain message
that their freshwater supplies were low.
Shortly, US intercepted a Japanese ciphertext
saying that “AF” was low on water.
This proved that “AF” is Midway.
More Definitions
unconditional security
no matter how much computer power or time is
available, the cipher cannot be broken since the
ciphertext provides insufficient information to uniquely
determine the corresponding plaintext
computational security
given limited computing resources (eg time needed
for calculations is greater than age of universe), the
cipher cannot be broken
Cryptography - recap
characterize cryptographic system by:
type of encryption operations used
substitution / transposition / product
number of keys used
single-key or private : symmetric
two-key or public : Asymmetric
way in which plaintext is processed
block / stream
Classical Substitution Ciphers
Letters/bitsof plaintext are replaced by
other letters/bits.
Categorized as:
Monoalphabetic Ciphers – Simple Cipher
Homophonic Ciphers
Polyalphabetic Ciphers
Polygram Ciphers
Mono-alphabetic cipher/ Simple
Substitution
Substitution of single letters separately
simple substitution—can be demonstrated by
writing out the alphabet in some order to
represent the substitution.
This is termed a substitution alphabet.
The cipher alphabet may be shifted or
reversed (creating the Caesar and Atbash
ciphers, respectively) or scrambled in a more
complex fashion, in which case it is called a
mixed alphabet or deranged alphabet.
Caesar Cipher
Earliestknown substitution cipher
Invented by Julius Caesar
Each letter is replaced by the letter three
positions further down the alphabet.
• Plain: 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
Cipher: 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
Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
Monoalphabetic Cipher - example
To attack, we
calculate
letter frequencies for ciphertext
compare this distribution against the known one
Example Cryptanalysis
Given ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
Count relative letter frequencies (next slide)
Guess {P, Z} = {e, t}
Of double letters, ZW has highest frequency,
so guess ZW = th and hence ZWP = the
Proceeding with trial and error finally get:
it was disclosed yesterday that several informal but
direct contacts have been made with political
representatives of the viet cong in moscow
Letter frequencies in ciphertext
d e c e p t i v e d e c e p t i v e d e c e p t i v e
K:
PT: w e a r e d i s c o v e r e d s a v e y o u r s e l f
w e a r e d i s c o v e r e d s a v e y o u r s e l
PT:
Z I C V T WQ N G R Z G V T WA V Z H C Q Y G L MG
CT:
1 2 3 4 5 6 7 8 9 10 11 12
58
Enigma Rotor Machine
59
60
German secret setting sheets
Date
Which rotors to use (there were 10 rotors)
Ring setting
Plugboard setting
61
Classical Substitution Ciphers
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
65
http://en.wikipedia.org/wiki/Playfair_ciphe
Example
Key: playfair example
Message: Hide the gold in the tree stump
Digraph: HI DE TH EG OL DI NT HE TR EX ES TU MP
Encrypted Message: BMODZBXDNABEKUDMUIXMMOUVIF
Encrypting and Decrypting
Plaintext is encrypted two letters at a time.
1. If a pair is a repeated letter, insert filler like 'X’.
2. If both letters fall in the same row, replace each with
the letter to its right (circularly).
3. If both letters fall in the same column, replace each
with the the letter below it (circularly).
4. Otherwise, each letter is replaced by the letter in the
same row but in the column of the other letter of the
pair.
70
Security of Playfair Cipher
Security
is much improved over the simple
monoalphabetic cipher.
Was widely used for many decades
eg. by US & British military in WW1 and early
WW2
Once thought to be unbreakable.
Actually,
it can be broken, because it still
leaves some structure of plaintext intact.
71
PlayFair - Example
Key: Black Cat
Plain Text: Attack at dawn while they are
sleeping
Cipher Text: ?
Classical Transposition Ciphers
Permutation of the plaintext letters.
Hide the message by rearranging the letter
order without altering the actual letters
used.
Rail Fence Cipher
Route cipher
Columnar Transposition Cipher
Grille
Rail Fence Cipher
Plaintext is written down as a sequence of
diagonals and read off as a sequence of
rows.
E.g. the PT: meet me after the party, is
written using a rail fence of depth 2 as:
m e m a t r h t g p r y
e t e f e t e o a a t
CT: MEMATRHTGPRYETEFETEOAAT
Rail Fence Cipher
Plain
Text: WE ARE DISCOVERED. FLEE AT
ONCE
http://en.wikipedia.org/wiki/Transposition_cipher
Route Cipher
In a route cipher, the plaintext is first written
out in a grid of given dimensions, then read
off in a pattern given in the key.
Route ciphers have many more keys than a
rail fence. In fact, for messages of reasonable
length, the number of possible keys is
potentially too great to be enumerated even
by modern machinery.
However, not all keys are equally good. Badly
chosen routes will leave excessive chunks of
plaintext, or text simply reversed, and this will
give cryptanalysts a clue as to the routes.
Route Cipher
http://en.wikipedia.org/wiki/Transposition_cipher
Columnar Transposition Cipher
In a columnar transposition, the message is
written out in rows of a fixed length, and then
read out again column by column, and the
columns are chosen in some scrambled order.
Both the width of the rows and the
permutation of the columns are usually
defined by a keyword.
For example, the word ZEBRAS is of length 6
(so the columns are of length 6), and the
permutation is defined by the alphabetical
order of the letters in the keyword. In this case,
the order would be "6 3 2 4 1 5"
Columnar Transposition Cipher
Write the message row-wise.
Read the message column-wise, in some specific
order.
For example:
Plaintext: Attack Postponed until two am
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
Key: 4312567 or DCABEFG
Column length is specified by first number in key.
4 3 1 2 5 6 7
a t t a c k p
o s t p o n e
d u n t i l t
w o a m x y z
Analysis of columnar transposition
Simple transposition can be easily detected
by doing a frequency count.
Can be attacked by anagramming
(rearranging).
Also keys very close to the correct key will reveal
long sections of legible plaintext interspersed by
gibberish.
Can be more secure if multiple stages of
transposition, using multiple keys, are
performed.
Double columnar transposition is more secure
and is similar to single columnar transposition,
but the process is repeated twice.
Grille
A grille usually consists of a square piece of
cardboard with cut-out apertures.
The grille is placed on a piece of paper, and the
corners of the grille are marked on the paper.
Then, the plaintext is written, letter by letter in the
apertures of the grille.
When the last aperture is reached, the grille is
turned 90 degrees, and the process continued. If
the apertures are properly placed on the grille,
turning the grille through all four positions (i.e. 0
degrees, 90 degrees, 180 degrees, and 270
degrees) will not result in any aperture appearing
in a position where a letter has already been
written on the paper.
PT:
We need more machine gun
Grille ammunition fast xx
http://hem.passagen.se/tan01/transpo.html
Classical Product Ciphers and
Fractioning Systems
Product Cipher
two substitutions are really only one more
complex substitution
two transpositions are really only one more
complex transposition
but a substitution followed by a transposition
makes a new much harder cipher (Product
Cipher)
Fractioning
Transposition is particularly effective when employed
with fractionation
In a fractionation system, a substitution is first made
from symbols in the plaintext to multiple symbols in the
ciphertext, which is then super encrypted by a
transposition.
For example, the plaintext alphabet could be written
out in a grid, then every letter in the message replaced
by its co-ordinates (Polybius square and Straddling
checkerboard).
When such a fractionated message is transposed, the
components of individual letters become widely
separated in the message.
Examples of ciphers that combine fractionation and
transposition include the bifid cipher, the trifid cipher,
the ADFGVX cipher and the VIC cipher.
Polybius Square
http://en.wikipedia.org/wiki/ADFGVX_cipher
ADFGVX Cipher - Example
Next, the fractionated message is subject to a
columnar transposition. We write out the message in
rows under a transposition key (here, "CARGO"):
Next, we sort the letters alphabetically in
the transposition key (changing CARGO
to ACGOR), rearranging the columns
beneath the letters along with the letters
themselves:
http://en.wikipedia.org/wiki/Bifid_cipher
Bifid Cipher - Exercise
Cipher Text: odstsn sdml tsqg ia apkd dhmod ybf
pdamdf fmot qfv nrywyvrg wyxerxz tbq noipxugobb
ni vwe Kuvle
Key: HolyBook
Plain Text: hearts rust just as iron rusts and indeed they are
polished through the recitation of the Quran
Bifid Cipher – Quiz (8A)
Cipher Text: Ei to tet ttgez do tbwtes
rpg ztpl tvu fap outkes
Plain Text: ?
Plain Text: ?
Substitution
key: the only one
Permutation key: trunckax
Decipher
the above mentioned text using
ADFGVX algorithm.