0% found this document useful (0 votes)
20 views73 pages

BCSE309L - MODULE2 - Symmetric Cipher

The document covers fundamental concepts in cryptography and network security, focusing on symmetric encryption, including definitions of plaintext, ciphertext, and keys. It explains various substitution techniques, such as the Caesar cipher and Playfair cipher, along with the Hill cipher, detailing their encryption and decryption processes. Additionally, it emphasizes the importance of a secure key distribution method and the mathematical principles underlying these cryptographic systems.

Uploaded by

pspinjanispam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views73 pages

BCSE309L - MODULE2 - Symmetric Cipher

The document covers fundamental concepts in cryptography and network security, focusing on symmetric encryption, including definitions of plaintext, ciphertext, and keys. It explains various substitution techniques, such as the Caesar cipher and Playfair cipher, along with the Hill cipher, detailing their encryption and decryption processes. Additionally, it emphasizes the importance of a secure key distribution method and the mathematical principles underlying these cryptographic systems.

Uploaded by

pspinjanispam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 73

BCSE309L – Cryptography and Network

Security
M ODULE - 2

2
Some Basic Terminology
• Plaintext - Original message
• Ciphertext - 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 plaintext from ciphertext
• Cryptography - Study of encryption principles/methods
• Cryptanalysis (codebreaking) - Study of principles / methods of
deciphering ciphertext without knowing key
• Cryptology - Field of both cryptography and cryptanalysis

3
Symmetric Encryption

4
Symmetric Encryption
• It is a form of cryptosystem in which encryption and
decryption are performed using the same key
• Also known as conventional / private-key / single-key
encryption
• Sender and recipient share a common key
• All classical encryption algorithms use private-key
• Was only type prior to invention of public-key in 1970’s

5
Symmetric Encryption

Symmetric Encryption Scheme: 5 ingredients


1. Plaintext
2. Encryption Algorithm
3. Secret Key
4. Cipher Text
5. Decryption Algorithm

6
Simplified Model of Symmetric Encryption

K K
X=D[K,Y]

Y=E(K,X
)

7
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

8
Model of Symmetric Cryptosystem

9
Cryptography

• Characterize cryptographic system by:


– Type of operations used for transforming plaintext to
ciphertext (encryption algorithms) used
• Substitution / Transposition
– Number of keys used
• Single-key or private (symmetric/conventional encryption)/
• Two-key or public(asymmetric/public key encryption)
– Way in which plaintext is processed
• Block cipher/ Stream cipher

10
Substitution Techniques
Substitution Techniques
Substitution Techniques
Caesar Cipher
Vigenere Cipher

14
Substitution Techniques
Vigenere Cipher
Substitution Techniques
Substitution Techniques
Playfair Cipher

18
Substitution Techniques
Relative Frequency of Letters in English Text

As a first step, the relative frequency of the letters can be determined and
compared to a standard frequency distribution for English as shown in Figure
Substitution Techniques
Substitution Techniques
Playfair Cipher

It's not a monoalphabetic cipher.


It's a digraph cipher. A digraph cipher changes two letters into two other letters.
Substitution Techniques
Playfair Cipher
Substitution Techniques
Playfair Cipher
Algorithm:
Substitution Techniques
Playfair Cipher
Substitution Techniques

• GREET
• MANGO

25
Substitution Techniques

• GREET - For plaintext GREET, the digraph will be GR EX ET,


• MANGO - MANGO plaintext - MANGOZ by adding the letter Z at the end

26
Substitution Techniques
Playfair Cipher
Substitution Techniques
Playfair Cipher
Substitution Techniques
Playfair Cipher
Substitution Techniques

Playfair Cipher

Key : MONARCHY

Plaintext : INSTRUMENTSZ

Ciphertext : ?
Substitution Techniques
Playfair Cipher
Substitution Techniques
Playfair Cipher

Decryption
• Decrypting the Playfair cipher is as simple as doing the
same process in reverse.
• The receiver has the same key and can create the same
key table, and then decrypt any messages made using
that key.

Key : MONARCHY

Ciphertext : gatlmzclrqtx

Plaintext : ?
32
Substitution Techniques
Playfair Cipher

• Generate the key Square(5×5) at the receiver’s end:


– The key square is a 5×5 grid of alphabets that acts as the key for encrypting
the plaintext.
– Each of the 25 alphabets must be unique and one letter of the alphabet
(usually J) is omitted from the table (as the table can hold only 25 alphabets).
If the plaintext contains J, then it is replaced by I.
– The initial alphabets in the key square are the unique alphabets of the key in
the order in which they appear followed by the remaining letters of the
alphabet in order
• Algorithm to decrypt the ciphertext:
– The ciphertext is split into pairs of two letters (digraphs)

Note: The ciphertext always have even number of characters.


33
Substitution Techniques
Playfair Cipher

Rules for Decryption:


• If both the letters are in the same column: Take the letter above
each one (going back to the bottom if at the top).
• If both the letters are in the same row: Take the letter to the left
of each one (going back to the rightmost if at the leftmost
position).
• If neither of the above rules is true: Form a rectangle with the
two letters and take the letters on the horizontal opposite corner of
the rectangle.

34
Substitution Techniques
Playfair Cipher
Decryption

CipherText: "gatlmzclrqtx"
After Split: 'ga' 'tl' 'mz' 'cl' 'rq' 'tx'

35
Hill Cipher

36
Hill Cipher
• Hill cipher was developed by the
mathematician Lester Hill in 1929.
• The encryption algorithm takes m successive
plaintext letters and substitutes for them m
ciphertext letters.
Hill Cipher
• Step 1 – Select a Message to Encrypt
sathish
• Step 2 – Select a Key
– If we encrypt 2 letters at a time then key size is 2 x 2
matrix
– If we encrypt 3 letters at a time then the key should be 3
x 3 matrix
Ex: sa th is h
sa th is ha

Key Selected is dbgf


Hill Cipher
• STEP 3
Let us assign a numerical equivalent to each letter:
Hill Cipher
• STEP 4
Convert the key dbgf to a 2X2 Matrix

d b

g f =

Key K is Done
Hill Cipher

• Step 5 – Convert the message sathisha to a n component


vector (here n=2)
• Message - sa th is ha
Plain Text P
Hill Cipher Encryption

STEP 5
• Ciphertext (C) = P * K mod 26
• Plaintext (P) = K-1 C mod 26
= K-1 * K * P mod 26
= K-1 * K * P mod 26
Hill Cipher Encryption
Ciphertext (C) = P * K mod 26
Plaintext (P) = C K-1 mod 26
= K * P * K-1 mod 26
= K-1 * K * P mod 26

43
Hill Cipher Encryption
Ciphertext (C) = K * P mod 26

Key 

Plaintext 
Hill Cipher Encryption
Ciphertext (C) = K * P mod 26

Key 

Plaintext 
Hill Cipher Encryption

54= 2 x 26 + 2
108= 4 x 26 + 4
Hill Cipher Encryption

* mod 26
Hill Cipher Encryption
Hill Cipher Encryption

* mod 26
Hill Cipher Encryption
Hill Cipher Encryption

*
mod 26
Hill Cipher Encryption
Hill Cipher Encryption

Cipher text = cemtqivq


Hill Cipher Encryption

• Plaintext = sathisha
• Ciphertext = cemtqivq

54
Hill Cipher Decryption
Hill Cipher Decryption

Ciphertext = K * P mod 26

• Plain Text = K-1 C mod 26

K -1 = 1 / |K| * adj(K)

determinant ‘k’ adjoint ‘k’


Hill Cipher Decryption
+ - +
Determinant a1 b1 c1
• 2*2 matrix a2 b2 c2  a1(b2c3-c2b3)
a3 b3 c3
a b
X= a1 b1 c1
c d
a2 b2 c2  b1(a2c3-c2a3)
|X| = ad-bc a3 b3 c3
• 3*3 matrix a1 b1 c1
a1 b1 c1 a2 b2 c2  c1(a2b3-b2a3)
a3 b3 b3
X = a2 b2 c2
a3 b3 c3 |X| = a1(b2c3-c2b3) - b1(a2c3-c2a3) +
c1(a2b3-b2a3)
57
Hill Cipher Decryption

Determinant
+ - + -
a1 b1 c1 d1 b2 c2 d2
• 4*4 matrix a2 b2 c2 d2  a1 * b3 c3 d3
a3 b3 c3 d3 b4 c4 d4
a1 b1 c1 d1 a4 b4 c4 d4  a1 * (b2 (c3d4-d3c4))

a2 b2 c2 d2
X=
a3 b3 c3 d3 .
a4 b4 c4 d4 .
.
|X| = a1(b2 (c3d4-d3c4))-b1(a2(c3d4-d3c4))+c1(a2(b3d4-d3b4))-d1(a2(b3c4-c3b4))

58
Compute 1 / |K|

K= Find | K |

|K| Should not be ZERO


Compute 1 / |K|
1 / |K| = 1 / 9
= 9 -1 mod 26 (Find Multiplicative inverse)
= 3 (By using EEA)
Find the adjoint of a matrix
2*2 matrix adj(k)
• Interchange the elements of the principal diagonal.
• Just change (but do NOT interchange) the signs of the elements of
the other diagonal
a11
a b a11 a12 a13
X= b11 b12 b13  b12*c13 – b13*c12
c d
c11 c12 c13
d -b
Adj(X) =
-c a
a12
3*3 matrix a11 a12 a13
a11 a12 a13 b11 b12 b13  b11*c13 – b13*c11
c11 c12 c13
X = b11 b12 b13
c11 c12 c13 Find similarly for others – a13,b11,b12,b13,c11,c12,c13
Arrange in the matrix form
+ - + Apply sign
- + - Find transpose  found adj(X)
61
+ - +
Compute adj(k)

Here ‘K’ is a 2*2 matrix

K=
K-1 = (1 / |K|) * adj(K)
We have 1 / |K| = 3
and adj(k)

*3 =

K-1 = mod 26
Plain Text = K-1 C mod 26
Plain Text = K-1 C mod 26 Decryption
Ciphertext = cemtqivq
= ce mt qi vq

K -1 =

2 12 16 21

4 19 8 16 Cipher text
C

c m q v

e t i q
Hill Cipher Decryption

Plain Text = K -1 C mod 26

2
* mod 26
4
Hill Cipher Decryption
Hill Cipher Decryption

• Plain Text = K -1 C mod 26

12
* mod 26
19
Hill Cipher Decryption
Hill Cipher Decryption

16
mod 26
*
8
Hill Cipher Decryption
Hill Cipher Decryption

21
* mod 26
16
Hill Cipher Decryption

You might also like