Master Day02
Master Day02
LEARNING OBJECTIVES
• After studying this chapter, you should be able to:
• Present an overview of the main concepts of symmetric cryptography.
• Explain the difference between cryptanalysis and brute-force attack.
• Understand the operation of a monoalphabetic substitution cipher.
• Understand the operation of a polyalphabetic cipher.
• Present an overview of the Hill cipher.
• Describe the operation of a rotor machine
1
6/27/2022
Introduction
• Symmetric encryption, also referred to as conventional encryption or
single-key encryption, was the only type of encryption in use prior to
the development of public key encryption in the 1970s.
• It remains by far the most widely used of the two types of encryption.
• In lesson, we begin with a look at a general model for the symmetric
encryption process;
• This will enable us to understand the context within which the
algorithms are used.
• Next, we examine a variety of algorithms in use before the computer
era. Finally, we look briefly at a different approach known as
steganography.
Some terms
Plaintext • An original message
2
6/27/2022
3
6/27/2022
Requirements
• two requirements for secure use of symmetric encryption:
• a strong encryption algorithm
• a secret key known only to sender / receiver
• mathematically have:
Y = EK(X)
X = DK(Y)
• assume encryption algorithm is known
• implies a secure channel to distribute key
Cryptography
• characterize cryptographic system by: substitution
type of
encryption transposition
operations used
product
single-key
number of keys
used
private / two-key
or public
block
way in which
plaintext is
processed
stream
4
6/27/2022
Cryptanalysis
• objective to recover key not just message
• general approaches:
• cryptanalytic attack
• brute-force attack
5
6/27/2022
Cryptanalytic Attacks
• ciphertext only
• only know algorithm & ciphertext, is statistical, know or can identify plaintext
• known plaintext
• know/suspect plaintext & ciphertext
• chosen plaintext
• select plaintext and obtain ciphertext
• chosen ciphertext
• select ciphertext and obtain plaintext
• chosen text
• select plaintext or ciphertext to en/decrypt
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
6
6/27/2022
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)
7
6/27/2022
Caesar Cipher
• earliest known substitution cipher
• by Julius Caesar
• first attested use in military affairs
• replaces each letter by 3rd letter on
• example:
meet me after the toga party
PHHW PH DIWHU WKH WRJD SDUWB
Caesar Cipher
• Mathematically, give each letter a number
8
6/27/2022
Attacking Caesar
• Caesar can be broken if we only know one pair (plain letter, encrypted
letter)
• The difference between them is the key
• Caesar can be broken even if we only have the encrypted text and no
knowledge of the plaintext
• Brute-force attack is easy: there are only 25 keys possible
• Try all 25 keys and check to see which key gives an intelligible message
Attacking Caesar
9
6/27/2022
10
6/27/2022
Monoalphabetic Cipher
• rather than just shifting the alphabet
• could shuffle (jumble) the letters arbitrarily
• each plaintext letter maps to a different random ciphertext letter
• hence key is 26 letters long
Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: ifwewishtoreplaceletters
Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
11
6/27/2022
12
6/27/2022
Use in Cryptanalysis
• key concept - monoalphabetic substitution ciphers do not change
relative letter frequencies
• discovered by Arabian scientists in 9th century
• calculate letter frequencies for ciphertext
• compare counts/plots against known values
• if caesar cipher look for common peaks/troughs
• peaks at: A-E-I triple, NO pair, RST triple
• troughs at: JK, X-Z
• for monoalphabetic must identify each letter
• tables of common double/triple letters help
Example Cryptanalysis
• given ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
13
6/27/2022
Playfair Cipher
• The Playfair Cipher is an example of multiple-letter encryption
• Invented by Sir Charles Wheatstone in 1854, but named after his
friend Baron Playfair who championed the cipher at the British
foreign office
• Based on the use of a 5x5 matrix in which the letters of the alphabet
are written (I is considered the same as J)
• This is called key matrix
Playfair Cipher
• A 5X5 matrix of letters based on a keyword
• Fill in letters of keyword (no duplicates)
• Left to right, top to bottom
• Fill the rest of matrix with the other letters in alphabetic order
• E.g. using the keyword MONARCHY, we obtain the following matrix
14
6/27/2022
Vigenère Cipher
• Proposed by Giovan Batista Belaso (1553) and reinvented by Blaise de Vigenère
(1586), called “le chiffre indéchiffrable” for 300 years
• Effectively multiple Caesar ciphers
• Key is a word
• Encryption
• Read one letter t from the plaintext and one letter k from the key-word
• t is encrypted according to the Caesar cipher with key k
• for the next plain-letter, use the next letter from the key-word
• When the key word is finished, start the reading of the key from the beginning
• In other words: ci=(pi+ki mod m) mod 26
• Decryption works in reverse
• Example: key is “bcde”; “testing” is encrypted as “ugvxjpj”
• Note that the two ‘t’ are encrypted by different letters: ‘u’ and ‘x’
• The two ‘j’ in the cryptotext come from different plain letters: ‘i’ and ‘j’
15
6/27/2022
Playfair Cipher
• not even the large number of keys in a monoalphabetic cipher
provides security
• one approach to improving security was to encrypt multiple letters
• the Playfair Cipher is an example
• invented by Charles Wheatstone in 1854, but named after his friend
Baron Playfair
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
16
6/27/2022
17
6/27/2022
Polyalphabetic Ciphers
• polyalphabetic substitution ciphers
• improve security using multiple cipher alphabets
• make cryptanalysis harder with more alphabets to guess and flatter
frequency distribution
• use a key to select which alphabet is used for each letter of the
message
• use each alphabet in turn
• repeat from start after end of key is reached
Vigenère Cipher
• simplest polyalphabetic substitution cipher
• effectively multiple caesar ciphers
• key is multiple letters long K = k1 k2 ... kd
• ith letter specifies ith alphabet to use
• use each alphabet in turn
• repeat from start after d letters in message
• decryption simply works in reverse
18
6/27/2022
Vigenère Cipher
• Proposed by Giovan Batista Belaso (1553) and reinvented by Blaise de Vigenère
(1586), called “le chiffre indéchiffrable” for 300 years
• Effectively multiple Caesar ciphers
• Key is a word
• Encryption
• Read one letter t from the plaintext and one letter k from the key-word
• t is encrypted according to the Caesar cipher with key k
• for the next plain-letter, use the next letter from the key-word
• When the key word is finished, start the reading of the key from the beginning
• In other words: ci=(pi+ki mod m) mod 26
• Decryption works in reverse
• Example: key is “bcde”; “testing” is encrypted as “ugvxjpj”
• Note that the two ‘t’ are encrypted by different letters: ‘u’ and ‘x’
• The two ‘j’ in the cryptotext come from different plain letters: ‘i’ and ‘j’
19
6/27/2022
Vigenère Cipher
https://pages.mtu.edu/~shene/NSF-4/Tutorial/VIG/Vig-Base.html
Vigenère Cipher
https://pages.mtu.edu/~shene/NSF-4/Tutorial/VIG/Vig-Base.html
20
6/27/2022
Kasiski Method
• method developed by Babbage / Kasiski
• repetitions in ciphertext give clues to period
• so find same plaintext an exact period apart
• which results in the same ciphertext
• of course, could also be random fluke
• eg repeated “VTW” in previous example
• suggests size of 3 or 9
• then attack each monoalphabetic cipher individually using same
techniques as before
21
6/27/2022
Autokey Cipher
• ideally want a key as long as the message
• Vigenère proposed the autokey cipher
• with keyword is prefixed to message as key
• knowing keyword can recover the first few letters
• use these in turn on the rest of the message
• but still have frequency characteristics to attack
• eg. given key deceptive
key: deceptivewearediscoveredsav
plaintext: wearediscoveredsaveyourself
ciphertext:ZICVTWQNGKZEIIGASXSTSLVVWLA
One-Time Pad
• if a truly random key as long as the message is used, the cipher will be
secure
• called a One-Time pad
• is unbreakable since ciphertext bears no statistical relationship to the
plaintext
• since for any plaintext & any ciphertext there exists a key mapping
one to other
• can only use the key once though
• problems in generation & safe distribution of key
22
6/27/2022
Transposition Ciphers
• now consider classical transposition or permutation ciphers
• these hide the message by rearranging the letter order
• without altering the actual letters used
• can recognise these since have the same frequency distribution as the
original text
23
6/27/2022
Product Ciphers
• ciphers using substitutions or transpositions are not secure because
of language characteristics
• hence consider using several ciphers in succession to make harder,
but:
• two substitutions make a more complex substitution
• two transpositions make more complex transposition
• but a substitution followed by a transposition makes a new much harder
cipher
• this is bridge from classical to modern ciphers
24
6/27/2022
Rotor Machines
• before modern ciphers, rotor machines were most common complex
ciphers in use
• widely used in WW2
• German Enigma, Allied Hagelin, Japanese Purple
• implemented a very complex, varying substitution cipher
• used a series of cylinders, each giving one substitution, which rotated
and changed after each letter was encrypted
• with 3 cylinders have 263=17576 alphabets
25
6/27/2022
Steganography
• an alternative to encryption
• hides existence of message
• using only a subset of letters/words in a longer message marked in some way
• using invisible ink
• hiding in LSB in graphic image or sound file
• has drawbacks
• high overhead to hide relatively few info bits
Summary
• have considered:
• classical cipher techniques and terminology
• monoalphabetic substitution ciphers
• cryptanalysis using letter frequencies
• Playfair cipher
• polyalphabetic ciphers
• transposition ciphers
• product ciphers and rotor machines
• stenography
26
6/27/2022
53
27