Symmetric
Cryptography
Classical Cipher:
Substitution
Sang-Yoon Chang, Ph.D.
Module Objectives:
Classical Cipher: Substitution
Substitution Cipher
Modulo Operations
Caesar Cipher, Monoalphabetic Cipher,
Polyalphabetic Cipher, Vigenere Cipher
Module Objectives:
Classical Cipher: Substitution
Substitution Cipher
Modulo Operations
Caesar Cipher, Monoalphabetic Cipher,
Polyalphabetic Cipher, Vigenere Cipher
History of Cryptography
Long history of at least 4000 years
Alphabet (Merriam-Webster Dictionary)
1. “A set of letters or other characters
with which one or more languages are
written especially if arranged in a
customary order”
2. “A system of signs or signals that
serve as equivalents for letters”
Alphabet (in Cryptography)
Minimal unit for information coding
Can be letters, numbers, signs, etc.
Alphabet set depends on the
information coding scheme/system
Alphabet (in Cryptography)
English: {a, b, c, …, z}
Morse Code: {., -}
Computer Bits: {1,0}
Decimal: {0,1,2, …, 9}
Hexadecimal: {0,1,2, … F}
Alphabet (in Cryptography)
Alphabet Size
English: {a, b, c, …, z} 26
Morse Code: {., -} 2
Computer Bits: {1,0} 2
Decimal: {0,1,2, …, 9} 10
Hexadecimal: {0,1,2, … F} 16
Substitution Cipher
Each alphabet in the plaintext is
replaced by another alphabet to
generate ciphertext
Caesar Cipher
Earliest known substitution cipher
Replaces each alphabet with the
alphabet after shifting “x” times
to the right
The amount of shift (x) is the key
Caesar Cipher Example
x = 2 ß Key
AàC
BàD
CàE
…
Caesar Cipher Example
x = 2 ß Key
Plaintext:
AàC MEET ME LATER
BàD
Ciphertext:
CàE OGGV OG NCVGT
…
Caesar Cipher Example
x = 4 ß Key
Plaintext:
AàE MEET ME LATER
BàF
Ciphertext:
C à G QIIX QI PEXIV
…
Caesar Cipher Example
x = 26 ß Key
Plaintext:
A à A MEET ME LATER
B à B
Ciphertext:
C à C MEET ME LATER
…
Caesar Cipher Example
x = 26·i + 4 = 4, for any integer i
Plaintext:
A à E MEET ME LATER
B à F
Ciphertext:
C à G QIIX QI PEXIV
…
Caesar Cipher on English Plaintext
Possible keys are {0,1,…,25}
Key size is equal to the size of
the plaintext alphabet (26)
x = 26·i + a = a, where i is an integer
E.g., x = 25 = -1 = 51 = 77 = …
Caesar Cipher on English Plaintext
Possible keys are {0,1,…,25}
Key size is equal to the size of
the plaintext alphabet (26)
x = 26·i + a = a, where i is an integer
E.g., x = 25 = -1 = 51 = 77 = …
Modulo Operation Definitions
“a mod n” is the remainder when a is divided
by n (where n is positive and called modulus)
If a = q・n + r, for any integer q,
r = a mod n
If (a mod n) = (b mod n),
a and b are congruent modulo n
and a ≡ b (mod n)
Modulo Operation Definitions
12 mod 7 = 5
12 = 7・1 + 5 “a = q・n + r”
7 is modulus (positive)
Modulo Operation Definitions
-11 mod 7 = 3
-11 = 7・(-2) + 3 “a = q・n + r”
7 is modulus (positive)
Modulo Operation Definitions
… ≡ -9 ≡ -2 ≡ 5 ≡ 12 ≡ 19 ≡ ... (mod 7)
(mod n) operator maps all integers into
the set of integers between 0 and n-1
Zn = {0, 1, … , (n – 1)} is residue classes
Modulo Operation Definitions
Each integer in Zn represents residue class:
[r] = {a: a is an integer, a ≡ r (mod n) }
E.g., the residue classes (mod 7) are:
[0] = {..., -21, -14, -7, 0, 7, 14, 21, 28, ...}
[1] = {..., -20, -13, -6, 1, 8, 15, 22, 29, ...}
...
[6] = {..., -15, -8, -1, 6, 13, 20, 27, 34, ...}
Finding the smallest nonnegative r to which
a ≡ r (mod n) is called reducing a modulo n
Caesar Cipher Example
x = 4 ß Key
Plaintext:
A à E MEET ME LATER
B à F
Ciphertext:
C à G QIIX QI PEXIV
…
Coding Letters to Numbers
A à 0
B à 1
C à 2
…
Z à 25
Caesar Cipher Using English Letters
Encryption:
c = E(x, p) = (p + x) mod 26
Decryption:
p = D(x, c) = (c – x) mod 26
The keys are equivalent if they are
in the same residue class mod 26
Caesar Cipher Limitation
Key size is equal to the size of
the plaintext alphabet
(e.g., 26 for English letters)
Small key size
Vulnerable to brute force attack
Monoalphabetic Cipher
Each plaintext alphabet is assigned to
a different unique ciphertext alphabet
Key assigns the mapping for each alphabet
Key is a permutation of alphabet set
(n! permutations for n-element set)
Monoalphabetic Cipher Example
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Key: DKVQFIBJWPESCXHTMYAUOLRGZN
A à D
B à K
C à V
…
Monoalphabetic Cipher Example
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Key: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: MEETMELATER
Ciphertext: ?
Monoalphabetic Cipher Example
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Key: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: MEETMELATER
Ciphertext: CFFUCFSDUFY
Monoalphabetic Cipher Example
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Key: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: MEETMELATER
Ciphertext: CFFUCFSDUFY
Monoalphabetic Cipher
The possible number of keys is n!
where n is the plaintext alphabet size
E.g., n=26
Possible number of keys is 26! > 4·1026
Plaintext’s Natural Redundancy
Natural redundancy and biases
exist in plaintext
Such plaintext biases can be used
for cryptanalysis, e.g., against
monoalphabetic cipher
English Letter Frequency
English Letter Frequency
English Letter Frequency
Monoalphabetic Cipher Example
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Key: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: MEETMELATER
Ciphertext: CFFUCFSDUFY
Monoalphabetic Cipher Example
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Key: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: MEETMELATER
Ciphertext: CFFUCFSDUFY
Monoalphabetic Cipher Example
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Key: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: MEETMELATERAT…
Ciphertext: CFFUCFSDUFYDU…
Plaintext’s Natural Redundancy
The frequency bias can also occurs
in sequence of multiple alphabets
E.g., “TH” and “QU” in English
Uniform Distribution for Alphabets
No frequency biases, or uniform
distribution for alphabets, maximizes
the information entropy in alphabets
In uniform distribution, all alphabets
are equally likely and have equal
frequency
Polyalphabetic Cipher
Use multiple monoalphabetic cipher
substitutions
Use a key to define encryption
mappings per alphabet
Vigenere Cipher: Simple Polyalphabetic Cipher
Multiple Caesar Ciphers in parallel
Key: LEMON
Plaintext: MEET ME LATER
(Shift by:) LEMO NL EMONL
Ciphertext: XIQH ZP PMHRC
Vigenere Cipher: Simple Polyalphabetic Cipher
Encryption: Ci = (pi + ki mod m) mod 26
Key: LEMON m=5
Plaintext: MEET ME LATER
(Shift by:) LEMO NL EMONL
Ciphertext: XIQH ZP PMHRC
Vigenere Cipher: Simple Polyalphabetic Cipher
Decryption: pi = (Ci - ki mod m) mod 26
Key: LEMON m=5
Ciphertext: XIQH ZP PMHRC
(Left-Shift by:) LEMO NL EMONL
Plaintext: MEET ME LATER
Vigenere Cipher: Simple Polyalphabetic Cipher
Encryption: Ci = (pi + ki mod m) mod 26
Key: LEMON m=5 # Keys = nm
Plaintext: MEET ME LATER
(Shift by:) LEMO NL EMONL
Ciphertext: XIQH ZP PMHRC
Vigenere Cipher: Simple Polyalphabetic Cipher
Encryption: Ci = (pi + ki mod m) mod 26
Key: LEMON m=5
Plaintext: MEET ME LATER
(Shift by:) LEMO NL EMONL
Ciphertext: XIQH ZP PMHRC
Vigenere Cipher: One-Time Pad
One-time pad if m ≥ (plaintext size)
Key: LEMONISSOUR
m=11
Plaintext: MEET ME LATER
(Shift by:) LEMO NI SSOUR
Ciphertext: XIQH ZM DSHYI
Vigenere Cipher: One-Time Pad
One-time pad if m ≥ (plaintext size)
Key: LEMONISSOUR …
m needs to be as long as plaintext
Plaintext: MEET ME LATER …
(Shift by:) LEMO NI SSOUR …
Ciphertext: XIQH ZM DSHYI …