Classical Cryptography
Classical Cryptography
Introduction to Cryptography
cryptography is the study of
form the basis of many technological solutions to computer and communications security problems
W Diffie, M E Hellman, "Privacy and Authentication: An Introduction to Cryptography", in Proc. IEEE, Vol
67(3) Mar 1979, pp 397-427
Basic Concepts
cryptography
the art or science encompassing the principles and methods of transforming an intelligible message into one
that is unintelligible, and then retransforming that message back to its original form
plaintext
the original intelligible message
ciphertext
the transformed message
cipher
an algorithm for transforming an intelligible message into one that is unintelligible by transposition and/or
substitution methods
key
1/20
some critical information used by the cipher, known only to the sender & receiver
encipher (encode)
the process of converting plaintext to ciphertext using a cipher and a key
decipher (decode)
the process of converting ciphertext back into plaintext using a cipher and a key
cryptanalysis
the study of principles and methods of transforming an unintelligible message back into an intelligible
message without knowledge of the key. Also called codebreaking
cryptology
both cryptography and cryptanalysis
code
an algorithm for transforming an intelligible message into an unintelligible one using a code-book
Concepts
Encryption C = E_(K)(P)
Decryption P = E_(K)^(-1)(C)
The parameter that selects the individual transformation is called the key K, selected from a keyspace K
E_(K) ; K in K : P -> C
Usually assume the cryptographic system is public, and only the key is secret information
a private-key (or secret-key, or single-key) encryption algorithm is one where the sender and the recipient
share a common, or closely related, key
2/20
Classical Cryptography
Cryptanalytic Attacks
have several different types of attacks
ciphertext only
known plaintext
chosen plaintext
chosen plaintext-ciphertext
can select plaintext and obtain corresponding ciphertext, or select ciphertext and obtain plaintext
allows further knowledge of algorithm structure to be used
unconditional security
- no matter how much computer power is available, the cipher cannot be broken
computational security
- given limited computing resources (eg time needed for calculations is greater than age of universe),
the cipher cannot be broken
3/20
A Brief History of Cryptography
Ancient Ciphers
have a history of at least 4000 years
ancient Egyptians enciphered some of their hieroglyphic writing on monuments
Machine Ciphers
Jefferson cylinder, developed in 1790s, comprised 36 disks, each with a random alphabet, order of
disks was key, message was set, then another row became cipher
Wheatstone disc, originally invented by Wadsworth in 1817, but developed by Wheatstone in 1860's,
comprised two concentric wheels used to generate a polyalphabetic cipher
4/20
Enigma Rotor machine, one of a very important class of cipher machines, heavily used during 2nd world
war, comprised a series of rotor wheels with internal cross-connections, providing a substitution using a
continuosly changing alphabet
5/20
Classical Cryptographic Techniques
have two basic components of classical ciphers: substitution and transposition
in substitution ciphers letters are replaced by other letters
in transposition ciphers the letters are arranged in a different order
these ciphers may be:
monoalphabetic - only one substitution/ transposition is used, or
polyalphabetic - where several substitutions/ transpositions are used
several such ciphers may be concatentated together to form a product cipher
replace each letter of message by a letter a fixed distance away eg use the 3rd letter on
reputedly used by Julius Caesar
eg.
L FDPH L VDZ L FRQTXHUHG
I CAME I SAW I CONQUERED
6/20
9/1/2010 Classical Cryptography
ie mapping is
ABCDEFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMNOPQRSTUVWXYZABC
GDUCUGQFRMPCNJYACJCRRCPQ
HEVDVHRGSNQDOKZBDKDSSDQR
Plain - IFWEWISHTOREPLACELETTERS
JGXFXJTIUPSFQMBDFMFUUFST
KHYGYKUJVQTGRNCEGNGVVGTU
Cipher - LIZHZLVKWRUHSODFHOHWWHUV
MJAIAMWLXSVITPEGIPIXXIVW
Character Frequencies
7/20
use these tables to compare with letter frequencies in ciphertext, since a monoalphabetic substitution does
not change relative letter frequencies
[1]
more generally could use a more complex equation to calculate the ciphertext letter for each plaintext letter
Cryptanalysis:
8/20
Mixed Alphabets
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: IFWEWISHTOREPLACELETTERS
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
!!!WRONG!!!
(ie can get key nearly right, and nearly get message)
Cryptanalysis
General Monoalphabetic
STARW
BCDEF
GHIJK
LMNOP
QUVXY
Z
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: SBGLQZTCHMUADINVREJOXWFKPY
9/20
Classical Cryptography
Vigenère Cipher
Plaintext THISPROCESSCANALSOBEEXPRESSED
Keyword CIPHERCIPHERCIPHERCIPHERCIPHE
Plaintext VPXZTIQKTZWTCVPSWFDMTETIGAHLH
ABCDEFGHIJKLMNOPQRSTUVWXYZ
A ABCDEFGHIJKLMNOPQRSTUVWXYZ
B BCDEFGHIJKLMNOPQRSTUVWXYZA
C CDEFGHIJKLMNOPQRSTUVWXYZAB
D DEFGHIJKLMNOPQRSTUVWXYZABC
E EFGHIJKLMNOPQRSTUVWXYZABCD
F FGHIJKLMNOPQRSTUVWXYZABCDE
G GHIJKLMNOPQRSTUVWXYZABCDEF
H HIJKLMNOPQRSTUVWXYZABCDEFG
I IJKLMNOPQRSTUVWXYZABCDEFGH
J JKLMNOPQRSTUVWXYZABCDEFGHI
K KLMNOPQRSTUVWXYZABCDEFGHIJ
L LMNOPQRSTUVWXYZABCDEFGHIJK
M MNOPQRSTUVWXYZABCDEFGHIJKL
N NOPQRSTUVWXYZABCDEFGHIJKLM
O OPQRSTUVWXYZABCDEFGHIJKLMN
P PQRSTUVWXYZABCDEFGHIJKLMNO
Q QRSTUVWXYZABCDEFGHIJKLMNOP
R RSTUVWXYZABCDEFGHIJKLMNOPQ
S STUVWXYZABCDEFGHIJKLMNOPQR
T TUVWXYZABCDEFGHIJKLMNOPQRS
10/20
Classical Cryptography
V
U VWXYZABCDEFGHIJKLMNOPQRSTU
UVWXYZABCDEFGHIJKLMNOPQRST
W WXYZABCDEFGHIJKLMNOPQRSTUV
X XYZABCDEFGHIJKLMNOPQRSTUVW
Y YZABCDEFGHIJKLMNOPQRSTUVWX
Z ZABCDEFGHIJKLMNOPQRSTUVWXY
Beauford Cipher
Key = d
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: DCBAZYXWVUTSRQPONMLKJIHGFE
Variant-Beauford Cipher
D = F(H(M),k)
N = F(H(K),D)
for polyalphabetic substitution ciphers, if have s possible keys for each simple subs, and d keys used, then
hence need 1.5 times the number of separate substitutions used letters to break the cipher
but first need to determine just how many alphabets were used
Kasiski method
index of coincidence
Kasiski Method
use repetitions in ciphertext to give clues as to period, looking for same plaintext an exact period apart,
leading to same ciphertext
Plaintext: TOBEORNOTTOBE
Key: NOWNOWNOWNOWN
Ciphertext: GCXRCNACPGCXR
Index of Coincidence
d IC
1 0.0660
2 0.0520
3 0.0473
4 0.0450
5 0.0436
6 0.0427
7 0.0420
8 0.0415
9 0.0411
10 0.0408
11 0.0405
12 0.0403
13 0.0402
14 0.0400
15 0.0399
... ...
Inf 0.0380
first define a measure of roughness (MR) giving variation of frequencies of individual characters relative
to a uniform distribution
MR = Isu(i=o,n-1,(p_(i) - F(1,n))^(2))
where p_(i) is probability an arbitrary character in ciphertext is the ith character a_(i) in the alphabet
Isu(i=o,n-1,p_(i)) = 1
MR = Isu(i=o,n-1,p_(i)^(2)) - 0.038
or
MR + 0.038 = Isu(i=o,n-1,p_(i)^(2))
13/20
can also compute MR for a flat distribution as 0
since probabilities and period are unknown, cannot compute MR, however can estimate from ciphertext
now the number of pairs of letters that can be chosen from ciphertext of length N is
if F_(i) is the freq of the ith letter of English in the ciphertext, then the number of pairs containing just the
ith letter is
now define the Index of Coincidence (IC) as the prob that two letters at random from the ciphertext are
indeed the same
IC = Isu(i=o,n-1,F(F_(i)(F_(i)-1),N(N-1)))
Krypto program
krypto [file]
Command Meaning
? this message.
! execute a shell command.
14/20
f [<seqlen> [n]] print [the n most] frequent strings of length seqlen.
g [<d> <p>] print the frequency distribution graph of letters.
i [<p>] calculate the index of coincidence of the text.
l [<b> <B>] list only the modified string. [b=blklength, B=blks/line]
p print current code.
q exit.
s <ch1> <ch2> substitute ch2 for ch1.
S [-] -[gvbB] {keys} Perform the substitution specified by the key.
T [-] <perm>|key Transpose text by perm or keyword. e.g. T 4,5,2,3,1
t <n> [/regexp] look for transpositions of period n; [print only /regexp].
B [-] <perm>|key apply the specifed rectangular encryption to the text.
b <n> [/regexp] look for block decryptions of size n; [print only
/regexp].
u undo previous modification.
z reset the code to its initial state.
r <file> enter code from file.
w <file> write code to file.
e edit code.
Transposition Ciphers
transposition or permutation ciphers hide the message contents by rearranging the order of the letters
Scytale cipher
A. Sinkov "Elementary Cryptanalysis", New Mathematical Library, Random House, 1968* other simple
transposition ciphers include:
Reverse cipher
15/20
Plain: I CAME I SAW I CONQUERED
Cipher: DEREU QNOCI WASIE MACI
Plain: I A E S W C N U R D
C M I A I O Q E E
Cipher: IAESW CNURD CMIAI OQEE
Geometric Figure
write message following one pattern and read out with another
in general write message in a number of columns and then use some rule to read off from these columns
key could be a series of number being the order to: read off the cipher; or write in the plaintext
Plain: THESIMPLESTPOSSIBLETRANSPOSITIONSXX
Key (R): 2 5 4 1 3
Key (W): 4 1 5 3 2
T H E S I S T I E H
M P L E S E M S L P
T P O S S S T S O P
I B L E T E I T L B
R A N S P S R P N A
O S I T I T O I I S
O N S X X X O X S N
Cipher: STIEH EMSLP STSOP EITLB SRPNA TOIIS XOXSN
or can use a word, with letter order giving sequence: to write in the plaintext; or read off the cipher
Plain: ACONVENIENTWAYTOEXPRESSTHEPERMUTATION
Key (W): C O M P U T E R
Key (W): 1 4 3 5 8 7 2 6
16/20
A N O V I N C E
E W T A O T N Y
H E P R T U E M
A O I N Z Z T Z
key idea for row transposition ciphers is that message is in groups that have the letters reordered in each
Exercise using key sorcery (to read out) encipher:
gives
erasb lecam snabd umole atoed ctamo ryrre elntl iicee ntgha dnria oesav w
to determine the complexity of this cipher, we can calculate its unicity distance
given blocks of period d, there are d! keys, hence
another group of ciphers are block (columnar) transposition ciphers where the message is written in
rows, but read off by columns in order given by key (use B command in krypto)
for ease of recovery may insist matrix is filled
17/20
Key(R): s o r c e r y s o r c e r y
Key(R): 6 3 4 1 2 5 7 6 3 4 1 2 5 7
l a s e r b e l a s e r b e
a m s c a n b a m s c a n b
e m o d u l a e m o d u l a
t e d t o c a t e d t o c a
r r y m o r e r r y m o r e
i n t e l l i i n t e l l i
g e n c e t h g e n c e t h
a n r a d i o a n r a d i o
w a v e s w a v e s q r
ecdtm ecaer auool edsam merne nasso dytnr vbnlc rltiq laetr igawe baaei hor
Sinkov p148
Nihilist ciphers
a more complex transposition cipher using both row and column transpositions is the nihilist cipher
write message in rows in order controlled by the key (as for a row cipher)
then read off by rows, but in order controlled by the key, this time written down the side
uses a period of size the square of the key length
Plaintext: NOWISTHETIMEFORALLGOODMEN
Key (W): L E M O N
2 1 3 5 4
L 2 O N W S I
E 1 H T E I T
18/20
Classical Cryptography
M 3 E M F R O
0 5 L A L O G
N 4 D O M N E
attacking this cipher depends on column and row rearrangement, with much trial and error
for more complexity can vary readout algorithm
diagonal cipher reads out on fwd diag (/) in alternate directions (up diag, down diag etc), ie a zig-
zag read out
Product ciphers
can see that in general ciphers based on just substitutions or just transpositions are not secure
what about using several ciphers in order
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 ciphers consist substitution-transposition combinations chained together
in general are far too hard to do by hand, however one famous product cipher, the 'ADFGVX' cipher was
used in WW1 (see Kahn pp339-350)
instead there use had to wait for the invention of the cipher machine, particularly the rotor machines (eg
Enigma, Hagalin) mentioned briefly earlier
Substitution Table
\\ A D F G V X
A K Z W R 1 F
D 9 B 6 C L 5
F Q 7 J P G X
G E V Y 3 A N
V 8 O D H 0 2
X U 4 I S T M
Plaintext: PRODUCTCIPHERS
19/20
Intermediate Text:
FG AG VD VF XA DG XV
DG XF FG VG GA AG XG
D E U T S C H Key
2 3 7 6 5 1 4 Sorted Order
F G A G V D V
F X A D G X V
D G X F F G V
G G A A G X G
williamstallings.com/…/classical.html 20/20