Module 2(Part 1)
Module 2(Part 1)
MODULE 2
Prepared by
Dr. L. Mary Shamala
Assistant Professor
SCOPE / VIT
MODULE 2: SYMMETRIC ENCRYPTION ALGORITHMS
VIT/SCOPE/BCSE309-CNS/MODULE 2 2
BASIC TERMINOLOGY
VIT/SCOPE/BCSE309-CNS/MODULE 2 4
CRYPTOLOGY…
VIT/SCOPE/BCSE309-CNS/MODULE 2 5
CRYPTOGRAPHY
The many schemes used for encryption constitute the area of study
called Cryptography
It is a branch of mathematics that deals with the transformation of data.
Increasingly used to protect information.
Can ensure confidentiality
Integrity and Authenticity too
VIT/SCOPE/BCSE309-CNS/MODULE 2 6
CRYPTOGRAPHY - HISTORY
Symmetric
Same key for encryption and decryption
Key distribution problem
Examples: DES, AES, IDEA, Blowfish, RC4, RC5
Asymmetric
Mathematically related key pairs for encryption and decryption
Public and private keys
RSA, ECC, Diffie-Hellman, ElGamal
VIT/SCOPE/BCSE309-CNS/MODULE 2 9
BLOCK VS STREAM CIPHERS
VIT/SCOPE/BCSE309-CNS/MODULE 2 11
STREAM VS BLOCK CIPHER
Stream Cipher Block Cipher
Advantages Speed of High diffusion
transformation
Low error Immunity to insertion of
propagation symbol
Limitations Low diffusion Slowness of encryption
Susceptibility to Padding
malicious insertions
and modifications
Error propagation 12
VIT/SCOPE/BCSE309-CNS/MODULE 2
CLASSICAL CIPHERS
CLASSICAL ENCRYPTION TECHNIQUES
VIT/SCOPE/BCSE309-CNS/MODULE 2 14
SUBSTITUTION CIPHERS
Monoalphabetic Cipher
Uses one alphabet
Equal symbols of plaintext are always substituted with the same symbol
Susceptible to frequency analysis
Polyalphabetic Cipher
Uses multiple alphabets
Equal symbols of plaintext are substituted with different symbols, depending on
the key
VIT/SCOPE/BCSE309-CNS/MODULE 2 15
CLASSICAL SUBSTITUTION CIPHERS
VIT/SCOPE/BCSE309-CNS/MODULE 2 17
CAESAR CIPHER
VIT/SCOPE/BCSE309-CNS/MODULE 2 18
EXAMPLE
Plaintext
meet me after the toga party
Ciphertext
PHHW PH DIWHU WKH WRJD SDUWB
VIT/SCOPE/BCSE309-CNS/MODULE 2 19
EXAMPLE 2
VIT/SCOPE/BCSE309-CNS/MODULE 2 20
PLAYFAIR CIPHER
VIT/SCOPE/BCSE309-CNS/MODULE 2 21
PLAYFAIR KEY MATRIX
M O N A R
Uses a 5x5 matrix of letters
called Playfair C H Y B D
square or Wheatston-square,
based on keyword. E F G I/J K
Fill in the letters of the keyword L P Q S T
Fill the rest of the matrix with
other letters U V W X Z
Example: using the keyword
MONARCHY
VIT/SCOPE/BCSE309-CNS/MODULE 2 22
ENCRYPTING AND DECRYPTING
VIT/SCOPE/BCSE309-CNS/MODULE 2 24
EXAMPLE 2
VIT/SCOPE/BCSE309-CNS/MODULE 2 25
HILL CIPHER
VIT/SCOPE/BCSE309-CNS/MODULE 2 26
HILL CIPHER…
C = KP mod 26
C and P are column vectors of length 3, representing the plaintext and ciphertext,
K is a 3 x3 matrix, representing the encryption key.
Operations are performed mod 26.
VIT/SCOPE/BCSE309-CNS/MODULE 2 27
HILL CIPHER…
Encryption
Convert the keyword into a matrix
Form plaintext into di-grams (or tri-grams) and each of these into column
vectors
Perform matrix multiplication (modulo 26) on each column vector with the
key matrix
These vectors are then converted back into letters to produce the ciphertext
VIT/SCOPE/BCSE309-CNS/MODULE 2 28
EXAMPLE
Encrypt the plaintext message “short example” using the keyword hill
VIT/SCOPE/BCSE309-CNS/MODULE 2 29
EXAMPLE…
VIT/SCOPE/BCSE309-CNS/MODULE 2 30
VIT/SCOPE/BCSE309-CNS/MODULE 2 31
VIT/SCOPE/BCSE309-CNS/MODULE 2 32
VIT/SCOPE/BCSE309-CNS/MODULE 2 33
VIT/SCOPE/BCSE309-CNS/MODULE 2 34
Final Ciphertext: “APADJTFTWLFJ”
VIT/SCOPE/BCSE309-CNS/MODULE 2 35
EXAMPLE 2
VIT/SCOPE/BCSE309-CNS/MODULE 2 36
HILL CIPHER…
where I is the matrix that is all zeros except for ones along the main
diagonal from upper left to lower right.
VIT/SCOPE/BCSE309-CNS/MODULE 2 37
HILL CIPHER…
VIT/SCOPE/BCSE309-CNS/MODULE 2 38
POLYALPHABETIC CIPHERS
VIT/SCOPE/BCSE309-CNS/MODULE 2 39
VIGENÈRE CIPHER
Assume a sequence of plaintext letters P= p0, p1, p2 ,…, pn-1 and key
K= k0, k1, k2 ,…, km-1 where m<n
Ciphertext letters C= C0, C1, C2 ,…, Cn-1 is calculated as:
(p0 + k0) mod 26, (p1 + k1) mod 26,…, (pm-1 + km-1) mod 26,
(pm + km) mod 26, (pm+1 + k1) mod 26,…, (p2m-1 + km-1) mod 26,…
A general equation of the encryption process
Ci = (pi + kimodm) mod 26
Decryption
pi = (Ci – kimodm) mod 26
VIT/SCOPE/BCSE309-CNS/MODULE 2 41
Vigenere Tableau
VIT/SCOPE/BCSE309-CNS/MODULE 2 42
EXAMPLE OF VIGENÈRE CIPHER
VIT/SCOPE/BCSE309-CNS/MODULE 2 44
AUTOKEY CIPHER
To eliminate the periodic nature of keyword, ideally want a key as long as the
message.
Vigenère proposed the autokey cipher
Keyword is prefixed to message to provide a running key.
Example: The key is deceptive
key: deceptivewearediscoveredsav
plaintext: wearediscoveredsaveyourself
ciphertext:ZICVTWQNGKZEIIGASXSTSLVVWLA
Vulnerable to cryptanalysis as it has frequency characteristics
VIT/SCOPE/BCSE309-CNS/MODULE 2 45
TRANSPOSITION CIPHERS
VIT/SCOPE/BCSE309-CNS/MODULE 2 47
ROW TRANSPOSITION CIPHERS
A more complex transposition
Write the message in a rectangle, row by row, and read the message off,
column by column
Then reorder the columns according to some key before reading off the rows
Key: 4 3 1 2 5 6 7
Plaintext: a t t a c k p
o s t p o n e
d u n t i l t
w o a m x y z
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
48
ROW TRANSPOSITION CIPHERS…
VIT/SCOPE/BCSE309-CNS/MODULE 2 50
SYMMETRIC ENCRYPTION
VIT/SCOPE/BCSE309-CNS/MODULE 2 52
REQUIREMENTS
Cryptanalysis
rely on nature of the algorithm
plus some knowledge of plaintext characteristics
even some sample plaintext-ciphertext pairs
exploits characteristics of algorithm to deduce specific plaintext or key
Brute-force attack
try all possible keys on some ciphertext until get an intelligible translation into
plaintext
VIT/SCOPE/BCSE309-CNS/MODULE 2 54
CRYPTANALYSIS
VIT/SCOPE/BCSE309-CNS/MODULE 2 55
CRYPTANALYTIC ATTACKS
56
BRUTE FORCE SEARCH
Always possible to simply try every key
Most basic attack, proportional to key size
Assume either know / recognise plaintext
Average Time Required for Exhaustive Key Search
57
VIT/SCOPE/BCSE309-CNS/MODULE 2
Exhaustive Key Search
VIT/SCOPE/BCSE309-CNS/MODULE 2 58
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
VIT/SCOPE/BCSE309-CNS/MODULE 2 59
BLOCK CIPHERS
BLOCK CIPHER
A block of
BLOCK CIPHER plaintext is
treated as a whole Typically a block
and used to size of 64 or 128
produce a bits is used
ciphertext block
of equal length
The majority of
network-based
The two users symmetric
share a symmetric cryptographic
encryption key applications make
use of block
ciphers
VIT/SCOPE/BCSE309-CNS/MODULE 2 61
BLOCK CIPHER
VIT/SCOPE/BCSE309-CNS/MODULE 2 62
BLOCK CIPHERS...
VIT/SCOPE/BCSE309-CNS/MODULE 2 63
BLOCK CIPHER PRINCIPLES…
Shannon’s idea in introducing the product cipher was to enable the block
ciphers to have two important properties:
Diffusion
• Dissipates statistical structure of plaintext over the bulk of
ciphertext
• This is achieved by having each plaintext digit affect the value of
many ciphertext digits
Confusion
• Makes the relationship between ciphertext and key as complex as 65
possible
FEISTEL CIPHER
VIT/SCOPE/BCSE309-CNS/MODULE 2 67
Feistel Cipher Structure
VIT/SCOPE/BCSE309-CNS/MODULE 2 68
A ROUND IN FEISTEL CIPHER
VIT/SCOPE/BCSE309-CNS/MODULE 2 69
FEISTEL CIPHER DESIGN PRINCIPLES
Number of
Block size Key size
rounds
Ease of
analysis
VIT/SCOPE/BCSE309-CNS/MODULE 2 70
FEISTEL DECRYPTION ALGORITHM
VIT/SCOPE/BCSE309-CNS/MODULE 2 72
SIMPLIFIED DES (S-DES)
VIT/SCOPE/BCSE309-CNS/MODULE 2 73
GENERAL STRUCTURE OF S-DES ENCRYPTION
VIT/SCOPE/BCSE309-CNS/MODULE 2 74
KEY GENERATION FOR S-DES
VIT/SCOPE/BCSE309-CNS/MODULE 2 75
KEY GENERATION FOR S-DES …
VIT/SCOPE/BCSE309-CNS/MODULE 2
S-DES ENCRYPTION
Plaintext:11110011
Permuted output: 10111101
VIT/SCOPE/BCSE309-CNS/MODULE 2 77
S-DES ENCRYPTION
Rounds
S-DES uses two rounds.
Each round of S-DES is a
Feistel cipher
VIT/SCOPE/BCSE309-CNS/MODULE 2 78
S-DES ENCRYPTION
S-DES Function
VIT/SCOPE/BCSE309-CNS/MODULE 2 79
S-DES ENCRYPTION
Expansion P-box
Example: R= 1101
E/P output = 11101011
VIT/SCOPE/BCSE309-CNS/MODULE 2 80
S-DES ENCRYPTION
S-boxes
Straight P-Box
VIT/SCOPE/BCSE309-CNS/MODULE 2 82
SIMPLIFIED
DES
83
DATA ENCRYPTION STANDARD (DES)
VIT/SCOPE/BCSE309-CNS/MODULE 2 84
DATA ENCRYPTION STANDARD (DES)
The Data Encryption Standard (DES) is a symmetric-key block cipher published by
the National Institute of Standards and Technology (NIST).
Issued in 1977 by the National Bureau of Standards (now NIST) as Federal
Information Processing Standard 46
Most widely used block cipher in world
Algorithm itself is referred to as the Data Encryption Algorithm (DEA)
Data are encrypted in 64-bit blocks using a 56-bit key
The algorithm transforms 64-bit input in a series of steps into a 64-bit output
The same steps, with the same key, are used to reverse the encryption 85
VIT/SCOPE/BCSE309-CNS/MODULE 2
DES HISTORY
VIT/SCOPE/BCSE309-CNS/MODULE 2 88
Key Generation
89
VIT/SCOPE/BCSE309-CNS/MODULE 2 89
VIT/SCOPE/BCSE309-CNS/MODULE 2 90
KEY GENERATION
COMPRESSION PERMUTATION 1
91
VIT/SCOPE/BCSE309-CNS/MODULE 2
KEY GENERATION
SHIFT LEFT
VIT/SCOPE/BCSE309-CNS/MODULE 2 92
KEY GENERATION
COMPRESSION PERMUTATION 2
VIT/SCOPE/BCSE309-CNS/MODULE 2 93
DES ENCRYPTION
INITIAL AND FINAL PERMUTATIONS
VIT/SCOPE/BCSE309-CNS/MODULE 2 94
INITIAL AND FINAL PERMUTATIONS …
= (ffb2194d 004df6fb)
DES ROUNDS
VIT/SCOPE/BCSE309-CNS/MODULE 2 96
DES FUNCTION
The heart of DES is the DES function.
The DES function applies a 48-bit key to the rightmost 32 bits (Ri–1) to
produce a 32-bit output.
This function is made up of four sections:
an expansion P-box,
a whitener (that adds key)
a group of S-boxes
a straight P-box
VIT/SCOPE/BCSE309-CNS/MODULE 2 97
DES
FUNCTION…
VIT/SCOPE/BCSE309-CNS/MODULE 2 98
EXPANSION PERMUTATION
VIT/SCOPE/BCSE309-CNS/MODULE 2 99
SUBSTITUTION BOXES
VIT/SCOPE/BCSE309-CNS/MODULE 2 100
S-BOXES…
S-box rule
Example:
S(18 09 12 3d 11 17 38 39) = 5fd25e03
VIT/SCOPE/BCSE309-CNS/MODULE 2 101
S-box 1
S-box 2
S-box 3
102
S-box 4
S-box 5
S-box 6
103
S-box 7
S-box 8
VIT/SCOPE/BCSE309-CNS/MODULE 2 105
GENERAL
DEPICTION OF
DES ENCRYPTION
106
SINGLE ROUND
OF DES
107
DES DECRYPTION
VIT/SCOPE/BCSE309-CNS/MODULE 2 108
DES EXAMPLE
Plaintext:
02468ACEECA86420
Key:
0F1571C947D9E859
Ciphertext:
DA02CE3A89ECAC3B
VIT/SCOPE/BCSE309-CNS/MODULE 2 109
AVALANCHE EFFECT
Encrypt two plaintext blocks (with the same key) that differ only in one bit
and observe the differences in the number of bits in each round.
Plaintext: 0000000000000000 Key: 22234512987ABB23
CipherText: 4789FD476E82A5F1
Plaintext: 0000000000000001 Key: 22234512987ABB23
Ciphertext: 0A4ED5C15A63FEA3
Number of bit differences
111
AVALANCHE
EFFECT IN DES:
CHANGE IN
PLAINTEXT
VIT/SCOPE/BCSE309-CNS/MODULE 2 112
AVALANCHE
EFFECT IN DES:
CHANGE IN KEY
VIT/SCOPE/BCSE309-CNS/MODULE 2 113
STRENGTH OF DES – KEY SIZE
VIT/SCOPE/BCSE309-CNS/MODULE 2 114
STRENGTH OF DES – TIMING ATTACKS
VIT/SCOPE/BCSE309-CNS/MODULE 2 115
STRENGTH OF DES – ANALYTIC ATTACKS
VIT/SCOPE/BCSE309-CNS/MODULE 2 117
MULTIPLE DES
VIT/SCOPE/BCSE309-CNS/MODULE 2 122
TRIPLE DES
VIT/SCOPE/BCSE309-CNS/MODULE 2 123