UNIT-2
Classical Cryptography & Symmetric
Key Cryptography
Prepared By: Prof. Hina Tandel
Information Security RNGPIT
Contents
• Classical Cryptography
• Symmetric cipher model,
• Substitution techniques,
• Transposition techniques,
• Steganography
• Symmetric Key Cryptography
• Block cipher principles,
• Substitution-Permutation networks,
• Data Encryption Standard (DES),
• Block cipher modes of operation.
Symmetric Cipher Model (Conventional Encryption)
Secret key shared by Secret key shared by
sender and recipient sender and recipient
K
K
Transmitted
cipher text
Y = E(K, X)
X X
Plaintext Encryption Algorithm Decryption Algorithm Plaintext
input (e.g. AES) (reverse of encryption output
algorithm)
▪ Plaintext
The secretiskey
Decryption
Ciphertext
An original isthe isoriginal
the
message also
algorithm isisintelligible
input
scrambled to the
essentially
message
known message
asencryption
the
the oralgorithm.
data
encryption
produced that the
is fed
algorithm
as while
plaintext, output. into
run
codedin
▪ the
The algorithm
key isison
reverse.
It depends
message aas
the
called input.
value independent
plaintext
the of thekey.
and the secret
ciphertext. plaintext and of the
▪ Encryption
algorithm.
It
Thetakes
ciphertext
process algorithm
the ciphertext
of andperforms
the secret
is an apparently
converting from randomvarious
key
plaintext and
stream substitutions
produces isthe
of data
to ciphertext and
original
and,
known asasit
▪ transformations
The algorithm
plaintext.
stands, on
orwill
is unintelligible.
enciphering the plaintext.
produce
encryption; a restoring
different output depending
the plaintext fromon the
the
specific
ciphertextkeyisbeing used at or
deciphering thedecryption.
time.
Cryptology
▪ Cryptology has two parts namely, Cryptography which focuses on creating secret codes
and Cryptanalysis which is the study of the cryptographic algorithm and the breaking of those secret
codes.
▪ Cryptanalyst :The person practicing Cryptanalysis is called a Cryptanalyst.
▪ It helps us to better understand the cryptosystems and also helps us improve the system by finding any
weak point and thus work on the algorithm to create a more secure secret code.
▪ For example, a Cryptanalyst might try to decipher a ciphertext to derive the plaintext. It can help us to
deduce the plaintext or the encryption key.
Cryptanalysis and Brute-Force Attack
• Cryptanalysis: Cryptanalytic attacks rely on the nature of the algorithm and some
knowledge of the general characteristics of the plaintext or even some sample
plaintext–ciphertext pairs.
• This type of attack exploits the characteristics of the algorithm to attempt to derive a
specific plaintext or to derive the key being used.
• Cryptanalysis is the process of studying cryptographic systems to look for weaknesses or
leaks of information.
• Brute-force attack: The attacker tries every possible key on a piece of ciphertext until an
intelligible translation into plaintext is obtained.
• On average, half of all possible keys must be tried to achieve success.
Attacks on Encrypted Messages
Type of Attack Known to cryptanalyst
Ciphertext Only Encryption algorithm, Ciphertext
Attacks on Encrypted Messages
Type of Attack Known to cryptanalyst
Known Encryption algorithm, Ciphertext, One or more
Plaintext plaintext-cipher text pairs formed with the secret key
Attacks on Encrypted Messages
Type of Attack Known to cryptanalyst
Chosen Encryption algorithm, Ciphertext, Plaintext message chosen by
Plaintext cryptanalyst
Attacks on Encrypted Messages
Type of Attack Known to cryptanalyst
Chosen Encryption algorithm, Ciphertext, Ciphertext chosen by
Ciphertext cryptanalyst, with its corresponding decrypted plaintext
generated with the secret key
Attacks on Encrypted Messages
Type of Attack Known to cryptanalyst
Chosen text Encryption algorithm, Ciphertext, Plaintext chosen by
cryptanalyst, with its corresponding ciphertext generated with
the secret key , Ciphertext chosen by cryptanalyst, with its
corresponding decrypted plaintext generated with the secret
key
Substitution Techniques
• A substitution technique is one in which the letters of plaintext are replaced
by other letters or by numbers or symbols.
1) Caesar Cipher
2) Monoalphabetic Cipher
3) Playfair Cipher
4) Hill Cipher
5) Polyalphabetic Ciphers
6) One-Time Pad
1) Caesar Cipher
▪ The Caesar cipher involves replacing each letter of the alphabet with the letter
standing three places further down the alphabet.
▪ In encryption each plaintext letter P, substitute the ciphertext letter C:
C = E(k, P) = (P + k) mod 26
C = E(3, P) = (P + 3) mod 26
▪ For decryption algorithm is:
P = D(k, C) = (C - k) mod 26
Caesar Cipher (Cont…)
▪ Let us assign a numerical equivalent to each letter
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
C = E(3, P) = (P + 3) mod 26
plain: 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
cipher: 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
Example:
Plaintext: THE QUICK BROWN FOX
Ciphertext: WKH TXLFN EURZQ IRA
Brute force attack on Caesar Cipher
• The encryption and decryption algorithms are known.
• There are only 25 keys to try.
• The language of the plaintext is known and easily recognizable.
Brute force attack on Caesar Cipher
Ciphertext: ZNK WAOIQ HXUCT LUD
Key Transformed text Key Transformed text
1 YMJ VZNHP GWTBS KTC 14 LZW IMAUC TJGOF XGP
2 XLI UYMGO FVSAR JSB 15 KYV HLZTB SIFNE WFO
3 WKH TXLFN EURZQ IRA 16 JXU GKYSA RHEMD VEN
4 VJG SWKEM DTQYP HQZ 17 IWT FJXRZ QGDLC UDM
5 UIF RVJDL CSPXOGPY
18 HVS EIWQY PFCKB TCL
6 THE QUICK BROWN FOX
19 GUR DHVPX OEBJA SBK
7 SGD PTHBJ AQNVM ENW
8 RFC OSGAI ZPMUL DMV 20 FTQ CGUOW NDAIZ RAJ
9 QEB NRFZH YOLTK CLU 21 ESP BFTNV MCZHY QZI
10 PDA MQEYG XNKSJ BKT 22 DRO AESMU LBYGX PYH
11 OCZ LPDXF WMJRI AJS 23 CQN ZDRLT KAXFW OXG
12 NBY KOCWE VLIQH ZIR 24 BPM YCQKS JZWEV NWF
13 MAX JNBVD UKHPG YHQ 25 AOL XBPJR IYVDU MVE
Substitution Techniques
1) Caesar Cipher
2) Monoalphabetic Cipher
3) Playfair Cipher
4) Hill Cipher
5) Polyalphabetic Ciphers
6) One-Time Pad
2) Monoalphabetic Cipher (Simple substitution)
• It is an improvement to the Caesar Cipher.
• Instead of shifting the alphabets by some number, this scheme uses some
permutation of the letters in alphabet.
• The sender and the receiver decide on a randomly selected permutation of the
letters of the alphabet.
• With 26 letters in alphabet, the possible permutations are 26! which is equal to
4x1026.
plain: 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
cipher: y n l k x b s h m i w d p j r o q v f e a u g t z c
Attack on Monoalphabetic Cipher
• The relative frequencies of the letters in the ciphertext (in percentages) are
Ciphertext:
uzqsovuohxmopvgpozpevsgzwszopfpesxudbmetsxaizvuephzhmdzshzowsfpappdtsvpquz
wymxuzuhsxepyepopdzszufpombzwpfupzhmdjudtmohmq
▪ In our ciphertext, the most common digram is ZW, which appears three times. So equate Z with t, W
with h and P with e.
▪ Now notice that the sequence ZWP appears in the ciphertext, and we can translate that sequence as
“the.”
Attack on Monoalphabetic Cipher (Cont…)
▪ If the cryptanalyst knows the nature of the plaintext, then the analyst can
exploit the regularities of the language.
▪ The relative frequency of the letters can be determined and compared to a
standard frequency distribution for English.
▪ If the message were long enough, this technique alone might be sufficient,
but because this is a relatively short message, we cannot expect an exact
match.
Substitution Techniques
1) Caesar Cipher
2) Monoalphabetic Cipher
3) Playfair Cipher
4) Hill Cipher
5) Polyalphabetic Ciphers
6) One-Time Pad
3) Playfair Cipher
• The Playfair algorithm is based on a 5 × 5 matrix (key) of letters.
• The matrix is constructed by filling in the letters of the keyword (minus
duplicates) from left to right and from top to bottom, and then filling in the
remainder of the matrix with the remaining letters in alphabetic order. The
letters I and J count as one letter.
O C U R E
Example: N A B D F
Keyword= OCCURRENCE G H I/J K L
Plaintext= TALL TREES M P Q S T
V W X Y Z
Playfair Cipher - Encrypt Plaintext
• Playfair, treats digrams (two letters) in the plaintext as single units and
translates these units into ciphertext diagrams.
• Make Pairs of letters add filler letter “X” if same letter appears in a pair.
Plaintext= TALL TREES
Plaintext= TA LX LT RE ES
• If there is an odd number of letters, then add uncommon letter to complete
diagram, a X/Z may be added to the last letter.
Playfair Cipher - Encrypt Plaintext
• Map each pair in key matrix
O C U R E
Plaintext= TA LX LT RE ES
Ciphertext= PF IZ TZ EO RT N A B D F
G H I/J K L
M P Q S T
V W X Y Z
▪ If the
theletters
lettersare
letters on different
appear
appear ononthe rows
thesame
sameand columns,
column,
row, replace
replace
replace themthem
them withwith
with the
the letters
letters on other
toimmediately
their corner
immediate of the
below,
right same row.
wrapping
respectively,
around
wrapping
to thearound
top to
if
▪ The
the order
necessary.
left sideisofimportant - the first letter of the pair should be
the row if necessary.
▪ replaced
For example,first. using the table above, the letter pair
pair RE
LT would be
▪ For example,
encoded TZ.using the table above, the letter pair TA would be
as EO.
encoded as PF.
Playfair Cipher Examples
1. Key= “ engineering ” Plaintext=” test this process ”
2. Key= “ keyword ” Plaintext=” come to the window ”
3. Key= “ moonmission ” Plaintext=” greet ”
E N G I R Encrypted K E Y W O Encrypted
A B C D F Message: R D A B C Message:
H K L M O pi tu pm gt ue lf gp F G H I L lc nk zk vf yo gq ce
P Q S T U xg M N P Q S bw
V W X Y Z T U V X Z
M O N I S Encrypted
A B C D E Message:
F G H K L hq cz du
P Q R T U
V W X Y Z
Example
• Example of Playfair Cipher
• Suppose, the plaintext is COMMUNICATION and the key that we will use
to encipher the plaintext is COMPUTER. The key can be any word or
phrase. Let's encipher the message COMMUNICATION.
• 1. First, split the plaintext into digraph (by rule 2) i.e. CO MX MU NI CA
TE.
• 2. Construct a 5*5 key-matrix (by rule 3). In our case, the key
is COMPUTER.
Limitations
• The limitations of the Playfair cipher are as follows:
• Only 25 alphabets are supported.
• It does not support numeric characters.
• Only either upper cases or lower cases are supported.
• The use of special characters (such as blank space, newline, punctuations, etc.) is
prohibited.
• It does not support other languages, except English.
• Encryption of media files is also not supported.
Substitution Techniques
1) Caesar Cipher
2) Monoalphabetic Cipher
3) Playfair Cipher
4) Hill Cipher
5) Polyalphabetic Ciphers
6) One-Time Pad
4) Hill Cipher
▪ Hill cipher is based on linear algebra
▪ Each letter is represented by numbers from 0 to 25 and calculations are
done modulo 26.
▪ Encryption and decryption can be given by the following formula:
Encryption:
C=PK mod 26
Decryption: P=CK-1 mod 26
Hill Cipher Encryption
▪ To encrypt a message using the Hill Cipher we must first turn our keyword and
plaintext into a matrix (a 2 x 2 matrix or a 3 x 3 matrix, etc).
Example: Key = “HILL”, Plaintext = “EXAM”
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
Hill Cipher Encryption (Cont…)
C=PK mod 26
Ciphertext = “ELSC”
Hill Cipher Decryption
P=CK-1 mod 26
Step:1 Find Inverse of key matrix
Step:2 Multiply the Multiplicative Inverse of the Determinant by the Adjoin
Matrix
Step:3 Multiply inverse key matrix with ciphertext matrix to obtain plaintext
matrix
Step: 1 Inverse of key matrix
2 X 2 inverse of matrix
3 X 3 inverse of matrix
Step: 1 Inverse of key matrix
▪ -11 mod 26 = 15
▪ Because, modulo for negative
number is = N- (B%N)
= 26 – (11%26)
Step: 2 Modular (Multiplicative) inverse
▪ The inverse of a number A is 1/A since A * 1/A = 1
e.g. the inverse of 5 is 1/5
▪ In modular arithmetic we do not have a division operation.
▪ The modular inverse of A (mod C) is A-1
▪ (A * A-1) ≡ 1 (mod C)
Example:
▪ The modular inverse of A mod C is the A-1 value that makes
A * A-1 mod C = 1
A = 3, C = 11
Since (3*4) mod 11 = 1, 4 is modulo inverse of 3
A = 10, C = 17 , A-1 = ?
12
Step 2: Modular (Multiplicative) inverse
Determinants’ multiplicative inverse Modulo 26
Determinant 1 3 5 7 9 11 15 17 19 21 23 25
Inverse Modulo 26 1 9 21 15 3 19 7 23 11 5 17 25
Step 2: Multiply with adjoin of matrix
Hill Cipher Encryption (Cont…)
P=CK-1 mod 26
Plaintext = “EXAM”
Substitution Techniques
1) Caesar Cipher
2) Monoalphabetic Cipher
3) Playfair Cipher
4) Hill Cipher
5) Polyalphabetic Ciphers
6) One-Time Pad
5) Polyalphabetic Cipher
▪ Monoalphabetic cipher encoded using only one fixed alphabet
▪ Polyalphabetic cipher is a substitution cipher in which the cipher
alphabet for the plain alphabet may be different at different places
during the encryption process.
1. Vigenere cipher
2. Vernam cipher
Plaintext
K
e
y
PT = HELLO
KEY = GMGMG
CT = NQRXU
Vigenere Cipher
Keyword : DECEPTIVE
Key : DECEPTIVEDECEPTIVEDECEPTIVE
Plaintext : WEAREDISCOVEREDSAVEYOURSELF
Ciphertext : ZICVTWQNGRZGVTWAVZHCQYGLMGJ
An analyst looking at only the ciphertext would detect the repeated
sequences VTW at a displacement of 9 and make the assumption that the
keyword is either three or nine letters in length.
This system is
Keyword : DECEPTIVE referred as
Key : DECEPTIVEWEAREDISCOVEREDSAV an autokey
Plaintext : WEAREDISCOVEREDSAVEYOURSELF system
Vernam Cipher
• The ciphertext is generated by applying the logical XOR operation to the
individual bits of plaintext and the key stream.
Substitution Techniques
1) Caesar Cipher
2) Monoalphabetic Cipher
3) Playfair Cipher
4) Hill Cipher
5) Polyalphabetic Ciphers
6) One-Time Pad
One time pad cipher
Encryption process
Decryption process
Decryption process
Decryption process
One time pad
• The one-time pad, which is a provably secure cryptosystem,
was developed by Gilbert Vernam in 1918.
• The message is represented as a binary string (a sequence of 0’s and 1’s using a coding
mechanism such as ASCII coding.
• The key is a truly random sequence of 0’s and 1’s of the same length as the message.
▪ message =‘IF’
▪ then its ASCII code =(1001001 1000110)
▪ key = (1010110 0110001)
▪ Encryption:
• 1001001 1000110 plaintext
• 1010110 0110001 key
• 0011111 1110110 ciphertext
Transposition Techniques
• A transposition cipher does not substitute one symbol for another, instead
it changes the location of the symbols.
• The simplest such cipher is the rail fence technique, in which the plaintext
is written down as a sequence of diagonals and then read off as a sequence
of rows.
• For example, to send the message “Meet me at the park” to Bob, Alice
writes
▪ She then creates the ciphertext “MEMATEAKETETHPR”.
Columner technique
• A more complex scheme is to write the message in a rectangle, row by row, and
read the message off, column by column, but permute the order of the columns.
• The order of the columns then becomes the key to the algorithm.
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