2 Classical Ciphers
2 Classical Ciphers
Cryptography
Hina Binte Haq
Secret Writing: Hieroglyphics (
)
Secret Writing
●Cryptography kryptos graphein
○ Scrambled writing
44 23 15
13 11 44
43 11 44
34 33
44 23 15
32 11 44
Rosicrucian Cipher
Monoalphabetic: Caesar Cipher - I
Monoalphabetic: Caesar Cipher-I
• plain: hello
• key +3
• cipher: khoor
Activity
C = (m + k) mod 26
m = (C - k) mod 26
Monoalphabetic: Caesar Cipher - II
Jefferson Wheel implementation of
Caesar Cipher
● Caesar Shift Cipher
○ Each letter substituted by shifting n=3 places
■ E XAM PLE
■ HAD P SO H
● Jefferson wheel implementation
○ Set the message across the wheels
○ Select another line (in random) as cipher
Cryptanalysis
• SDUWB
An adversary wishes to break the Cryptosystem.
Exhaustive / Brute force search
Cipher text
3.19
Ciphertext-Only Attack
3.20
Known-Plaintext Attack
3.21
Chosen-Plaintext Attack
Attacker chooses some plaintexts and somehow gets its
ciphertexts. Then compares/analyzes plaintext/ciphertexts to
get the key
3.22
Chosen-Ciphertext Attack
Attacker chooses some ciphertexts and somehow gets its
plaintexts. Then compares/analyzes plaintext/ciphertexts to get
the key
3.23
Cryptanalysis
• The credit for breaking Caesar cipher goes primarily to the renowned
Arab polymath Al-Kindi (801–873 CE).
• Caesar cipher which stood for almost a thousand years was broken by
Cryptanalysis
Attacking the Cipher
• Statistical analysis
Cipher text
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUD
BMETSXAIZVUEPHZHMDZSHZOWSFPAPPDTSVPQUZ
WYMXUZUHSXEPYEPOPDZSZUFPOMBZWPFUPZHM
DJUDTMOHMQ
Attacking the Cipher
Cipher text
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUD
BMETSXAIZVUEPHZHMDZSHZOWSFPAPPDTSVPQUZ
WYMXUZUHSXEPYEPOPDZSZUFPOMBZWPFUPZHM
DJUDTMOHMQ
Attacking the Cipher
Cipher text
Relative Frequency = RF
P Appears = 16
M 6.67
Attacking the Cipher
P 13.33 H 5.83 F 3.33 B 1.67 C 0.00
M 6.67
P Z
Attacking the Cipher
P 13.33 H 5.83 F 3.33 B 1.67 C 0.00
Z 11.67 D 5.00 W 3.33 G 1.67 K 0.00 S, U, O, M, and H are all of relatively high
S 8.33 E 5.00 Q 2.50 Y 1.67 L 0.00 frequency and probably correspond to plain
letters from the set {a, h, i, n, o, r, s}.
U 8.33 V 4.17 T 2.50 I 0.83 N 0.00
M 6.67
P Z
Attacking the Cipher
P 13.33 H 5.83 F 3.33 B 1.67 C 0.00
Z 11.67 D 5.00 W 3.33 G 1.67 K 0.00 S, U, O, M, and H are all of relatively high
S 8.33 E 5.00 Q 2.50 Y 1.67 L 0.00 frequency and probably correspond to plain
letters from the set {a, h, i, n, o, r, s}.
U 8.33 V 4.17 T 2.50 I 0.83 N 0.00
M 6.67
P Z
S
Attacking the Cipher
P Z
S
Most common 2 gram and 3gram Frequencies
36
Attacking the Cipher
digram.
• In our ciphertext, the most common digram is ZW, which appears three times.
Attacking the Cipher
• Now notice the sequence ZWSZ in the first line.
• We do not know that these four letters form a complete word TH_T.
• If S A then it will become THAT
Attacking Caesar Cipher
key VIGVIGVIGVIGVIGV
plain THEBOYHASTHEBALL
Cipher OPKWWECIYOPKWIRG
Key
Plain Text
Key : VIGVIGVIGVIGVIGV
Plain : THEBOYHASTHEBALL
Cipher : OPKWWECIYOPKWIRG
Vigenere Cipher
• Vigènere cipher has key letters on top, plaintext letters on the left
Polyalphabetic:
– (X goes to A, Y to B, Z to C)
– KHO
– ORZ
– RUO
– GXX
Modern History
● 19th century and onwards
Attacking Vigenere Cipher
Approach
• Break message into n parts, each part being enciphered using the
52
Babbage breaks Vigenere Cipher
● Babbage broke Vigenere’s Cipher (1854, Crimean war)
○ Stage 1: Discover key length
■ Look for repeated sequences, and measure their distance
■ The key length is a factor of these distances
53
Babbage breaks Vigenere Cipher
● Given this ciphertext
● Assuming that the keyword is indeed five letters long, the next step is to work out the actual letters of the keyword. For
the time being, let us call the keyword L1-L2-L3-L4-L5, such that L1 represents the first letter of the keyword, and
so on.
● The letter L1 defines one row of the Vigenère square and effectively provides a
monoalphabetic substitution cipher alphabet for the first letter of the plaintext.
● L2, second L3, third, L4 fourth, L5 fifth and L6 once again 1 st so that is it just use frequency analysis.
54
Babbage breaks Vigenere Cipher
● What if key was large???
● What if key size was as large as message???
● What if keys are only used once???
55
One-Time Pad
The one-time pad offers complete security but, in practice, has two fundamental difficulties:
• Key Generation
– Any heavily used system might require millions of random characters on a regular basis.
• Key Distribution
– For every message to be sent, a key of equal length is needed by both sender and receiver
3
9
One-Time Pad
● Why It's Unbreakable:
An attacker has no information about the plaintext because every
possible plaintext message of the same length can produce the same
ciphertext (given an appropriate key).
58
One-Time Pad
ciphertext:
ANKYODKYUREPFJBYOJDSPLREYIUNOFDOIUERFPLUYTS
key: pxlmvmsydofuyrvzwc tnlebnecvgdupahfzzlmnyih
plaintext: mr mustard with the candlestick in the hall
ciphertext:
ANKYODKYUREPFJBYOJDSPLREYIUNOFDOIUERFPLUYTS
key: pftgpmiydgaxgoufhklllmhsqdqogtewbqfgyovuhwt
plaintext: miss scarlet with the knife in the library 3
9
Book Cipher: an
approximation of the
One Time Pad
• Approximate one-time pad with book text
• Each letter is given by a row, column pair as it is found in an agreed upon text.
upon text.
• Note all such ciphers would have an even number of numbers in them,
64
Enigma - Rotor Machines
– Key press passes through all rotors and back through a reflector
rotor
– Rotors advance after each key press changing the substitution.
● Performing substitutions
○ Letter-pairs are switched
○ Pulse goes through scramblers
○ Hits reflector and goes back
67
68
Poles Crack the Enigma
● Polish obtained an Enigma from a German spy (1933)
○ Hans-Thilo Schmidt sold to French intelligence
● Obtained information on its usage
○ daily code book indicated rotors and orientation
○ a different orientation key for each message (swapped keys)
69
Poles Crack the Enigma
● Rejewski’s algorithm to discover the day key
○ First, use catalog to identify the scrambler setting and orientation
○ Then, run the ciphertext through an Enigma and look at the text to identify
swapped letter pairs using frequency analysis
● Bombe machines were constructed to mechanize the search
70
Online Crypto Tools
● https://www.cryptool.org/en/cto/caesar/
● https://www.cryptool.org/en/cto/atbash/
● https://legacy.cryptool.org/en/cto/frequency-analysis
● https://www.boxentriq.com/code-breaking/cipher-identifier
● https://www.cryptool.org/en/cto/monoalpha/
● https://www.cryptool.org/en/cto/railfence/
● https://www.101computing.net/category/cryptography/
71