0% found this document useful (0 votes)
2 views

02. Symmetric Cipher

The document provides a comprehensive overview of cryptography, covering its history, definitions, and various models, including symmetric and asymmetric ciphers. It details classical ciphers like the Caesar and Playfair ciphers, as well as modern symmetric ciphers such as DES and AES, explaining key concepts like encryption, decryption, and cryptanalysis. Additionally, it discusses the principles of block and stream ciphers, emphasizing the importance of secure key management and the evolution of cryptographic techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

02. Symmetric Cipher

The document provides a comprehensive overview of cryptography, covering its history, definitions, and various models, including symmetric and asymmetric ciphers. It details classical ciphers like the Caesar and Playfair ciphers, as well as modern symmetric ciphers such as DES and AES, explaining key concepts like encryption, decryption, and cryptanalysis. Additionally, it discusses the principles of block and stream ciphers, emphasizing the importance of secure key management and the evolution of cryptographic techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 72

Review

• What is security: history and definition •


Security policy, mechanisms and services •
Security models

Outline
• Overview of Cryptography •
Classical Symmetric Cipher •
Modern Symmetric Ciphers (DES)

Basic Terminology
• plaintext - the original message
• ciphertext - the coded message
• cipher - algorithm for transforming plaintext to ciphertext
• key - info used in cipher known only to sender/receiver •
encipher (encrypt) - converting plaintext to ciphertext •
decipher (decrypt) - recovering ciphertext from plaintext •
cryptography - study of encryption principles/methods
• cryptanalysis (codebreaking) - the study of principles/
methods of deciphering ciphertext without knowing key
• cryptology - the field of both cryptography and cryptanalysis
Unconditional vs. Computational
Security • Unconditional security
– No matter how much computer power is available, the
cipher cannot be broken
– The ciphertext provides insufficient information to
uniquely determine the corresponding plaintext
– Only one-time pad scheme qualifies, E.g., OTP
• Computational security
– The cost of breaking the cipher exceeds the value of the
encrypted info
– The time required to break the cipher exceeds the useful
lifetime of the info
– E.g., AES, DES, etc
Brute Force Search
• Always possible to simply try every key •
Most basic attack, proportional to key size
Alternative Keys Time required at 106
Time required at 1 decryptions/µs
decryption/µs
Key Size (bits) Number of
32 232 = 4.3 × 109 231 µs = 35.8 minutes 2.15 milliseconds 56 256 = 7.2 × 1016 255 µs =
1142 years 10.01 hours
128 2128 = 3.4 × 1038 2127 µs = 5.4 × 1024 years
years 5.4 × 1018 years 5.9 × 1030 years

168 2168 = 3.7 × 1050 2167 µs = 5.9 × 1036


26 characters 26! = 4 × 1026 2 × 1026 µs = 6.4 × 106 years
(permutation) 6.4 × 1012 years

Outline
• Overview of Cryptography •
Classical Symmetric Cipher –
Substitution Cipher
– Transposition Cipher

• Modern Symmetric Ciphers (DES)


Symmetric Cipher Model
Requirements
• Two requirements for secure use of symmetric
encryption:
– a strong encryption algorithm
– a secret key known only to sender / receiver
Y = EK(X)
X = DK(Y)
• Assume encryption algorithm is known •
Implies a secure channel to distribute key

Classical Substitution Ciphers


• Letters of plaintext are replaced by other
letters or by numbers or symbols
• Plaintext is viewed as a sequence of bits,
then substitution replaces plaintext bit
patterns with ciphertext bit patterns
Caesar Cipher
• Earliest known substitution cipher •
Replaces each letter by 3rd letter on •
Example:
meet me after the toga
party PHHW PH DIWHU WKH
WRJD SDUWB

Caesar Cipher
• Define transformation as:
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

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 •
Mathematically give each letter a number a
b c d e f g h i j k l m
0 1 2 3 4 5 6 7 8 9 10 11 12

n o p q r s t u v w x y Z

13 14 15 16 17 18 19 20 21 22 23 24 25

• Then have Caesar cipher as:


C = E(p) = (p + k) mod (26)
p = D(C) = (C – k) mod (26)
Cryptanalysis of Caesar Cipher
• Only have 25 possible ciphers
– A maps to B,..Z
• Given ciphertext, just try all shifts of letters
• Do need to recognize when have plaintext
• E.g., break ciphertext "GCUA VQ DTGCM"

Monoalphabetic Cipher
• Rather than just shifting the alphabet •
Could shuffle (jumble) the letters arbitrarily
• Each plaintext letter maps to a different random
ciphertext letter
utjSeUq_c&t=12s
• Key is 26 letters long
https://www.youtube.com/watch?v=J

Plain: abcdefghijklmnopqrstuvwxyz
Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
Plaintext: ifwewishtoreplaceletters
Ciphertext:
WIRFRWAJUHYFTSDVFSFUUFYA

Monoalphabetic Cipher Security


26
• Now have a total of 26! = 4 x 10 keys
• Is that secure?
• Problem is language characteristics
– Human languages are redundant
– Letters are not equally commonly used
English Letter Frequencies
Note that all human languages have varying letter frequencies, though the
number of letters and their frequencies varies.

Example
Cryptanalysis • Given ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ

VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX

EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ

• Count relative letter frequencies (see text)


• Guess P & Z are e and t
• Guess ZW is th and hence ZWP is the •
Proceeding with trial and error finally get: it was

disclosed yesterday that several informal but direct


contacts have been made with political representatives
of the viet cong in moscow

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
Playfair Cipher
• a 5X5 matrix of letters based on a keyword
• fill in letters of keyword (sans duplicates) •
fill rest of matrix with other letters • Eg. Using
the keyword Abhi or AAAbhiiii
A B H I/J C
DEFGK
LMNOP
QRSTU
VWXYZ

Playfair Cipher: Encryption


plaintext is encrypted two letters at a time
1. Create 5×5 matrix that is called grid of letters
2. The matrix is made by inserting the value of key and
remaining alphabets into the matrix (row wise from
left to right) where, letter I and J will be combined
together
3. Convert the text into pairs of alphabets
e.g., Heya → He ya
a. Pairs cannot be made with same letters. Break the letters
into single and add ‘X’ to the previous letter
E.g. Hello → He lx lo
Helloe → He lx lo ez
a. By the letter is standing alone in the process of pairing, then
add ‘z’ with the letter.

Playfair Cipher:
Encryption 4. Code will be formed using
3 rules:
i. if both letters fall in the same row, replace each with
letter to right (wrapping back to start from end)
ii. if both letters fall in the same column, replace each
with the letter below it (again wrapping to top from
bottom)
iii. Otherwise, each letter is replaced by the letter in the
same row and in the column of the other letter of the
pair
Playfair Cipher
A B H I/J C D E F G K L M N O P Q R S T U
VWXYZ

Plain Text Ciphertext BM → ER


RW → WB
FG → GK [Same ROW]
UQ → QR [Same ROW]
QW → RV [Horizontal]
Playfair Cipher: Security
• security much improved over monoalphabetic
• since have 26 x 26 = 676 diagrams
• would need a 676 entry frequency table to
analyse (verses 26 for a monoalphabetic)
• and correspondingly more ciphertext
• was widely used for many years
– eg. by US & British military in WW1
• it can be broken, given a few hundred letters
• since still has much of plaintext structure

Hill Cipher: Encryption


1. This encryption algorithm takes m successive
plaintext letters and substitutes for them m
ciphertext letters.
2. The substitution is determined by m linear
equations in which each character is assigned
a numerical value (a = 0, b = 1, c=2 , z = 25).
Hill Cipher: Encryption/Decryption
Hill Cipher: Example
Hill Cipher: Example
Hill Cipher: Example
Hill Cipher: Example
Hill Cipher: Example
Hill Cipher: Example
Hill Cipher: Example
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

Example of Vigenère Cipher


• write the plaintext out
• write the keyword repeated above it • use
each key letter as a caesar cipher key •
encrypt the corresponding plaintext letter •
e.g. using keyword deceptive
key: deceptivedeceptivedeceptive
plaintext:
wearediscoveredsaveyourself
ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMG
J

Example of Vigenère Cipher


Security of Vigenère Cipher
• have multiple ciphertext letters for each plaintext
letter
• hence letter frequencies are obscured
• but not totally lost
• start with letter frequencies
– see if look monoalphabetic or not

• if not, then need to determine number of


alphabets, since then can attach each
Vernam Cipher
Vernam Cipher: Algorithm (1/4)

• Assign a number to each character of the plain


text and the key according to alphabetical
order.

https://www.geeksforgeeks.org/vernam-cipher-in-cryptography/

Vernam Cipher: Algorithm


(2/4)
Vernam Cipher: Algorithm (3/4)
Vernam Cipher: Algorithm (4/4)

• Subtract the number from 26 if the resulting


number is greater than or equal to 26, if it isn’t
then leave it.
Vernan Cipher:

Example
Vernan Cipher: Example
Vernan Cipher: Example
Vernam Cipher: Cryptoanalysis
• The system worked with a very long but repeating
keyword.
• This technique can be broken with sufficient
ciphertext, the use of known or probable plaintext
sequences, or both.
One time pad
• The two requirements for the One-Time pad are
– The key should be randomly generated as long as
the size of the message.
– The key is to be used to encrypt and decrypt a
single message, and then it is discarded.
One time pad
• So encrypting every new message requires a
new key of the same length as the new message
in one-time pad.
• The ciphertext generated by the One-Time pad
is random, so it does not have any statistical
relation with the plain text.
One time pad
One time pad
One Time Pad
• If a truly random key as long as the message is
used, the cipher will be secure – One Time Pad
– E.g., a random sequence of 0’s and 1’s XORed to
plaintext, no repetition of keys

• Unbreakable since ciphertext bears no


statistical relationship to the
plaintext
• For any plaintext, it needs a random key of the
same length
– Hard to generate large amount of keys

• Have problem of safe distribution of key


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?
Rail fence cipher
▪ The rail fence cipher (also called a zigzag
cipher) is a form of transposition cipher.
▪ It derives its name from the way in which it is
encoded.
Rail fence cipher
▪ For example, if the message is “GeeksforGeeks”
and the number of rails = 3 then cipher is
prepared as:

▪ Ciphertext: GSGSEKFREKEOE
Rail fence cipher
Rail Fence Cipher
• Write message letters out diagonally over a
number of rows
• Then read off cipher row by row
• E.g., write message out as:
m e m a t r h t g p r y
e t e f e t e o a a t

• Giving ciphertext
MEMATRHTGPRYETEFETEOAAT

Row coloumn transposition


• A more cmplex scheme
• Rectangle
• Write: row by row
• Read: Column by column
• Key: Order of the column
Row coloumn transposition

Plaintext: “Kill Corona Virus at twelve am tomorrow”


Row coloumn transposition

Plaintext: “Kill Corona Virus at twelve am tomorrow”


Row Coloumn Transposition
Row Coloumn Transposition
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 another substitution
– Two transpositions make a more complex transposition
– But a substitution followed by a transposition makes a new
much harder cipher
• This is bridge from classical to modern ciphers
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
Outline
• Overview of Cryptography •
Classical Symmetric Cipher •
Modern Symmetric Ciphers (DES)

Block vs Stream Ciphers


• Block ciphers process messages in into blocks,
each of which is then en/decrypted
• Like a substitution on very big characters
– 64-bits or more
• Stream ciphers process messages a bit or byte at
a time when en/decrypting
• Many current ciphers are block ciphers, one of the
most widely used types of cryptographic
algorithms
Block Cipher Principles
• Most symmetric block ciphers are based on a
Feistel Cipher Structure
• Block ciphers look like an extremely large
substitution
• Would need table of 264 entries for a 64-bit block
• Instead create from smaller building blocks •
Using idea of a product cipher

https://www.geeksforgeeks.org/block-cipher-design-principles/
https://engineering.purdue.edu/kak/compsec/NewLectures/Lecture3.pdf

Ideal Block Cipher


Feistel Cipher Structure
Feistel Cipher is not a specific scheme of block cipher.
It is a design model from which many different block
ciphers are derived. DES is just one example of a Feistel
Cipher.
A cryptographic system based on Feistel cipher structure
uses the same algorithm for both encryption and
decryption.
https://www.tutorialspoint.com/cryptography/feistel_block_c
i pher.htm
Feistel Cipher Structure
• Feistel cipher implements Shannon’s S-P network
concept
– based on invertible product cipher

• Process through multiple rounds which


– partitions input block into two halves
– perform a substitution on left data half
– based on round function of right half & subkey
– then have permutation swapping halves

Feistel
Cipher
Structur
e
Feistel Cipher
Decryption
Electronic Code
Book-Encryption
https://www.youtube.com/watch?v=-j80aA8q_IQ&t=1001s

Cipher Block Chaining Mode


https://www.youtube.com/watch?v=-j80aA8q_IQ&t=1001s

DES (Data Encryption Standard)


• Published in 1977, standardized in 1979,
developed by IBM
• Key: 64 bit quantity=8-bit parity+56-bit key
– Every 8th bit is a parity bit.

• 64 bit input, 64 bit output.


64 bit M 64 bit C
DES
Encryption

56 bits
Overview of DES Algorithm
Per-Round Key
Generation Initial Permutation of DES
key

C i-1 D i-1
28 bits 28 bits

Circular Left Shift Circular Left Shift


One
round with Discard Round 1,2,9,16: single
shift
Others: two bits
48 bits Ki
C iD i
Permutation
28 bits 28 bits
DES: Generating 16 sub keys
• Key in Hexadecimal= 133457799BBCDFF1
• K= 00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001

DES: Generating 16 sub keys


DES: Generating 16 sub keys
DES: Generating 16 sub keys
DES: Generating 16 sub keys

You might also like