Cryptography 2
Cryptography 2
Chapter 2 Classical
Encryption
网络视频: http://wlkt.ustc.edu.cn/video/detail_3363_0.htm
Outlines
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 2/52
2.1 Evolution of contemporary
cryptology
1918, William Friedman (Sept. 24,1891 –Nov. 12, 1969)
,
◦ US military specialist in cryptology, Cracking Japanese PURPLE
machine.
Claude Shannon (Apr. 30, 1916 – Feb. 24, 2001)
◦ American Electronic engineer and mathematician
◦ The Communication Theory of Secrecy System (1948)-foundation of
modern cryptography, The father of information theory
1949-1967 age of silence
1971: IBM’s Luciffer Cipher
◦ 128 bits block encryption by Horst Feistel (Jan.30, 1915–Nov.14,
1990)
◦ Foundation of Data Encryption Standard (DES)
1976-1977 , NIST published DES
1975, Whitfield Diffie & Matin Hellman,
◦ A New Direction in Cryptography: epoch-making Idea of public key
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 3/52
2.1 Evolution of contemporary
cryptology
1977 - 1978: Ronald Rivest, Adi Shamir, Len Adleman- RSA
public key system
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 5/52
2.2 Symmetric Cipher
Model
A symmetric encryption scheme has five ingredients (Figure
3.1):
■ Plaintext: original intelligible message or data that is fed into the
algorithm as input.
■ Encryption algorithm: The encryption algorithm performs various
substitutions and transformations on the plaintext.
■ Secret key: The secret key is also input to the encryption algorithm. The
key is a value independent of the plaintext and of the algorithm. The
algorithm will produce a different output depending on the specific key being
used at the time. The exact substitutions and transformations performed by
the algorithm depend on the key.
■ Ciphertext: the scrambled message produced as output. It depends on
the plaintext and the secret key. For a given message, two different keys will
produce two different ciphertexts. The ciphertext is an apparently random
stream of data and, as it stands, is unintelligible.
■ Decryption algorithm: This is essentially the encryption algorithm run in
reverse. It takes the ciphertext and the secret key and produces the original
plaintext.
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 6/52
2.2 Symmetric Cipher
Model
Plaintext: X
Cyphertext: Y
Encryption algorithm: E
Secret Key : K
Decryption
algorithm :D
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 7/52
Some terms
Cryptography : the area of study of encryption;
Cryptographic system/cipher: encryption schemes;
Cryptanalysis : the area of techniques used for deciphering a
message without any knowledge of the enciphering details.
Cryptology: cryptography+ cryptanalysis
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 8/52
Brute-force attack
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 9/52
cryptanalytic attacks
Various types of cryptanalytic attacks based on the amount
of information known to the cryptanalyst.
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 10/52
More terms
unconditionally secure:
◦ the ciphertext generated by the scheme does not contain
enough information to determine uniquely the corresponding plaintext, no matter
how much ciphertext is available;
computationally secure:
◦ The cost of breaking the cipher exceeds the value of the encrypted information.
◦ The time required to break the cipher exceeds the useful lifetime of the
information.
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 11/52
2.3 Substitution
techniques
the letters of plaintext are replaced by other letters or by numbers
or symbols.
Caesar Cipher
Monoalphabetic Ciphers
Polyalphabetic Ciphers
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 12/52
Caesar Cipher
Example:
◦ plain: meet me after the toga party
◦ cipher: PHHW PH DIWHU WKH WRJD SDUWB
Encryption 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
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
26! or greater than 4 * 1026 possible keys.
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 15/52
How to Crack Monoalphabetic
Substitution Ciphers
Example of ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
Frequency Analysis:
◦ 9th Century, Prosperity of Muslim civilization
◦ Theologians scrutinized the revelations of Muhammad in
Koran, daily utterances authentic statement by etymology of
words, structure of sentences individual letter analysis: a ,l
---j breakthrough in cryptanalysis
◦ al-Kindi, philosopher of the Arabs, author of 290 books, A
Manuscript on Deciphering Cryptographic Message ,
1987,Istanbul
School of Computer
(Finding the characteristic
Science&Technology, USTC of Information Source)
mfy@ustc.edu.
cn 现代密码学理论与实践 16/52
How to Crack Monoalphabetic
Substitution Ciphers
School of Computer
Science&Technology,
al-Kindi’ manuscript about
mfy@ustc.edu.
frequency analysis
USTC
cn 现代密码学理论与实践 17/52
How to Crack Monoalphabetic Substitution
Ciphers
the relative frequency of the letters can be determined (see the
table)and compared to a standard frequency distribution for
English (Figure 2.5).
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 18/52
Playfair Cipher
Encryption:
2-letter encryption 1. Repeating plaintext letters that are in
the same pair are separated with a filler
cipher letter, such as x, so that balloon would
◦ Using 5 * 5 matrix of be treated as ba lx lo on.
letters constructed using 2. Two plaintext letters that fall in the same
a keyword row of the matrix are each replaced by the
letter to the right, with the first element of
Example the row circularly following
the last. For example, ar is encrypted as RM.
keyword – monarchy
3. Two plaintext letters that fall in the same
column are each replaced by the letter
beneath, with the top element of the
column circularly following the last.
For example, mu is encrypted as CM.
or
C = PK mod 26S
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 20/52
Hill Cipher
Example
Plaintext: paymoremoney Encryption Key:
pay={15,0,24}
KK-1 = =I
School
K-1 of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 21/52
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 22/52
Polyalphabetic Cipher
1. A set of related monoalphabetic substitution rules is used.
2. A key determines which particular rule is chosen for a given
transformation.
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ
Expressed numerically
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 23/52
key: deceptivedeceptivedeceptive
School of Computer
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 24/52
How to Crack
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 25/52
Autokey Cipher
Key: deceptive
key: deceptivewearediscoveredsav
plaintext: wearediscoveredsaveyourself
ciphertext:ZICVTWQNGKZEIIGASXSTSLVVWLA
Ciphertext still keep some of the structure
of the plaintext
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 26/52
An example of breaking
Vigenère
Key : ? ? ? ? ? ? ? ? ??? ? ?? ? ? ? ? ? ??
Plaintext: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Ciphertext: V H R M H E U Z N FQ D E Z R W X F I D K
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 27/52
An example of breaking
Vigenère
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 28/52
One-Time Pad
(The first military cryptographic device, used by Sparta in the war against Persia,404
B.C. )
2D - Graph Transposition
D Ciphertext
T A N
N D E R S
C A N Y O U U Ciphertext : dnsuaruteodynnac
Plaintext Plaintext : can you understand
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 31/52
Rail Fence cipher
The plaintext is written down as a sequence of diagonals and then
read off as a sequence of rows.
Example 1:
Plaintext: “meet me after the toga party” with a rail fence of depth 2,
mematrhtgpry
etefeteoaat
Ciphertext:
mematrhtgpryetefeteoaat
Example 2:
Key: 4 3 1 2 5 6 7
Plaintext: a t t a c k p
ostpone
duntilt
woamxyz
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 32/52
Product Cipher
Pure Substitution Cipher / Transposition
Cipher--Not secure
Product Cipher-Mixes of Substitution Cipher
Cipher
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 33/52
2.5 Rotor Machine-Enigma
Polyalphabetic Cipher popular in WWII
◦ German Enigma, Japanese Purple,
Allied Hagelin
1923(Churchill <<World
Crisis>>1914.9)
Hitler
produced 30000 machines
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 34/52
2.5 Rotor Machine-Enigma
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 35/52
2.5 Rotor Machine-Enigma
Keyboard
Lampboard
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 36/52
2.5 Rotor Machine-Enigma
Scramblers: a polyalphabetic cipher each
position
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 37/52
2.5 Rotor Machine-Enigma
Scramblers
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 38/52
2.5 Rotor Machine-Enigma
Rotor Machine: an
implementation of
monoalphabetic substitution
cipher;
Use 3 independent
Scramblers; each scrambler has
26 inputs and 26 outputs; each
input links to an output; each
scrambler defines a
monoalphabetic cipher;
The scrambler move one
position and change the wire
connection after a key stroke,
and defines a different
monoalphabetic cipher. After 26
letters, the scrambler come back
to the original position-
School of Computer polyalphabetic cipher with a
period of 26 letters.
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 39/52
2.5 Rotor Machine-Enigma
Scrambler
Rotor Machine with 3 scramblers:
monoalphabetic ciphers
3 scramblers-6 permutations
5 scramblers-60 permutations
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 40/52
2.5 Rotor Machine-Enigma
Plugboard
◦ Swap a pair of letters;
◦ Allow 6 pairs of 26
letters;
◦ Total combinations
100,391,791,500
2 2 2 2 2 2
(C 26 C 24 C 22 C 20 C18C16 ) / 6!
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 41/52
2.5 Rotor Machine-Enigma
Reflector:
◦ reflect scrambled
results to scrambler
◦ Guarantee the
invertibility between
plaintext and
ciphertext under
any state.
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 42/52
2.5 Rotor Machine-Enigma
Operation procedure
◦ Encryption
Arrange 3 scramblers (6)
Set initial position of each scrambler 263=17576
2 2 2 2 2 2
Plugboard links: (C26C24C22C20C18C16 ) / 6!
Input plaintext-write down Ciphertext from
lampboard-send out ciphertext
◦ Decryption
Set the same state as encryption
Receive ciphertext-Input ciphertext-write down
plaintext from lampboard
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 43/52
2.5 Rotor Machine-Enigma
Enigma Security
◦ 3 parts
3 scramblers—6 permutations
Total Initial positions: 263=17576
Links of plugboard: 100391791500
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 44/52
2.6 Cracking the Enigma
Situation after WWI
◦ Allies lacked of fear and adversity
◦ Poland
otherwise lived in threats
Set up “Biuro Szyfrow”
1919-1920 war at Russia intercept
>400 msgs until 1926 Enigma
Commercial Enigma to Military
Enigma ???
Belgium, Nov. 8, 1931, Schmidt -->
Rex. French secret agent for 10000
marks ( or today’s $30000)
(handbook without arrangement of
School of Computer
internal wires)
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 45/52
2.6 Cracking the Enigma
Work by Poland
◦ German Usage
◦ Daily setup:
plugboard links:
A/L-P/R-T/D-B/W-L/F-O/Y
Scrambler permutation:2-3-1
Initial positions:Q-C-W (day
key)
◦ Each message is encrypted
with message key(MK)
◦ Each MK is encrypted twice
with day key (DK)
School of Computer
e.g. PGHPGHKIVBJE
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 46/52
2.6 Cracking the Enigma
Work by Poland
School of Computer
Ring of letters from the above table
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 47/52
2.6 Cracking the Enigma
Work by Poland
The mode of ring of letters is irrelative with
plugboard
Set up the database of all rings of letters which
characterize each DK (17576 DKs).
Rings of letters of length 3,9,7,7 from 1st and 4th letters
Rings of letters of length 2,3,9,12 from 2nd and 5th letters
Rings of letters of length 5,5,5,3,8 from 3st and 6th letters
plugboard
The same as Rejewski’s
tewwerwetter w/t
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 51/52
2.6 Cracking the Enigma
Work by
Britain
◦ British Bombe
◦ Bletchley Park
“ The geese who
laid golden eggs
and never
cackled .”
--Churchill in
Sept 6,1941
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 52/52
Enigma : A monument in cryptology
Monument in cryptology -- Enigma
◦ Design of Enigma --- cryptography
German Arthur Scherbius ;
(http://www.techcn.com.cn/index.php?doc-view-131925)
◦ Breaking Enigma ---cryptology
Poland (Marian Rejewski) ; British (Alan Turing)
Bletchley Park
The place where Enigma
is cracked
School of Computer
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 53/52
Review Questions and
Problems
3.4 The following ciphertext was generated using a simple substitution algorithm.
hzsrnqc klyy wqc flo mflwf ol zqdn nsoznj wskn lj xzsrbjnf,wzsxz gqv zqhhnf ol ozn glco zlfnco
hnlhrn; nsoznj jnrqosdnc lj fnqj kjsnfbc, wzsxz sc xnjoqsfrv gljn efeceqr. zn rsdnb qrlfn sf zsc
zlecn sf cqdsrrn jlw, wzsoznj flfn hnfnojqonb. q csfyrn blgncosx cekksxnb ol cnjdn zsg. zn
pjnqmkqconb qfb bsfnb qo ozn xrep, qo zlejc gqozngqosxqrrv ksanb, sf ozn cqgn jllg, qo ozn
cqgn oqprn, fndnj oqmsfy zsc gnqrc wsoz loznj gngpnjc, gexz rncc pjsfysfy q yenco wsoz zsg;
qfb wnfo zlgn qo naqxorv gsbfsyzo, lfrv ol jnosjn qo lfxn ol pnb. zn fndnj ecnb ozn xlcv
xzqgpnjc wzsxz ozn jnkljg hjldsbnc klj soc kqdlejnb gngpnjc. zn hqccnb onf zlejc leo lk ozn
ownfov-klej sf cqdsrrn jlw, nsoznj sf crnnhsfy lj gqmsfy zsc olsrno.
Decrypt this message.
Hints:
1. As you know, the most frequently occurring letter in English is e. Therefore, the first or
second (or perhaps third?) most common character in the message is likely to stand for e.
Also, e is often seen in pairs (e.g., meet, fleet, speed, seen, been, agree, etc.). Try to find a
character in the ciphertext that decodes to e.
2. The most common word in English is “the.” Use this fact to guess the characters that
stand for t and h.
3. Decipher the rest of the message by deducing additional words.
Warning: The resulting message is in English but may not make much sense on a first
School of Computer
reading.
Science&Technology, USTC
mfy@ustc.edu.
cn 现代密码学理论与实践 54/52
Review Questions and
Problems
3.9 When the PT-109 American patrol boat, under the command of Lieutenant John F.
Kennedy, was sunk by a Japanese destroyer, a message was received at an
Australian wireless station in Playfair code:
KXJEY UREBE ZWEHE WRYTU HEYFS
KREHE GOYFI WTTTU OLKSY CAJPO
BOTEI ZONTX BYBNT GONEY CUZWR
GDSON SXBOU YWRHE BAAHY USEDQ
The key used was royal new zealand navy. Decrypt the message. Translate TT into
tt.