You are on page 1of 19

# Chapter 4

Basics of Cryptography

## Prepared by: Mohan Gholap 1

• What is Cryptography?
- Plaintext

- Ciphertext

- Encryption: c = Ee(p)

- Decryption: p = Dd(c)

Kerckhoff’s Principle:
“The secrecy should be in the key used
for decryption, not in the decryption or
encryption algorithms”
Prepared by: Mohan Gholap 2
Types of Cryptography
1. Secret Key Cryptography:
- Both sender and receiver share a common
secret, ie. e = d
- Also called as “Symmetric key Cryptography”

## 2. Public Key Cryptography:

- Two distinct keys forming a key pair are used
- Encryption key/ Public key
- Decryption key/ Private key
Prepared by: Mohan Gholap 3
Example: If Alka wants to send confidential message
to Brijesh
Case 1: Secret Key Cryptography:
Both share a common key, k
Operation by Alka : c = Ek(p)
Opeartion by Brijech: p = Dk(c)

## Case 2: Public Key Cryptography:

Assuming Brijesh have key public-private key pair,
Operation by Alka : c = EB.pu(p)
Opeartion by Brijech: p = DB.pr(c)
Prepared by: Mohan Gholap 4
Types of Attacks
• Cryptographic algorithm is secure if a
cryptanalyst is unable to
a) Obtain plaintext from given ciphertext
b) Deduce the secret key or the private key

• Types:
 Known ciphertext attack
 Known plaintext attack
 Chosen plaintext attack
Prepared by: Mohan Gholap 5
Brute force attempt to obtain a key from known plaintext
Let (p1,c1), (p2,c2), … (pm,cm) be plaintext-ciphertext pairs
for(each potential key value in key space)
{
proceed = true;
i=1;
while(proceed == true && i <= m) {
if(ci != Ek(pi))
proceed = false;
i++;
}
if(i = m+1)
print (“Key value is k”);
}
Prepared by: Mohan Gholap 6
ELEMENTARY SUBSTITUTION CIPHERS
1. Monoalphabetic ciphers:
- most basic cipher is substitution cipher
- Let ∑ denote set of alphabets, {A,B, … ,Z}
- This approach defines the permutation of elements in ∑
- There are 26! Permutations.

## Ex: Simplest substitution cipher is one that replaces each

alphabet in a text by another alphabet k positions away.
[If k = 3]
D for A, E for B,…, A for X, B for Y,etc.

## - This scheme is called “Caeser cipher”

Prepared by: Mohan Gholap 7
Example Cont..d
Plaintext: WHAT IS THE POPULATION OF MARS

## Ciphertext: ZKDW LV WKH SRSXODWLRQ RI PDUV

NOTE:
Here, each letter is substituted by another unique
letter, hence such ciphers are called
“monoalphabetic”
Prepared by: Mohan Gholap 8
2. Polyalphabetic Ciphers
• Ciphertext corresponding to a particular
character is not fixed.

i. Vigenere Cipher:
- It uses a multi digit key k1,k2,….,km.
- Plaintext is split into number of blocks, each of
m consecutive characters
- 1st letter of each block replaced by letter k1
positions to its right, 2nd by a letter k2
positions to the right, and so on.
Prepared by: Mohan Gholap 9
Example:
P’text: W i s h i n g Y o u M u c h
Key : 04 19 03 22 07 12 05 11 04 19 03 22 07 12
C’text: A B V D P Y L J S N P Q J T

P’text: S u c c e s s
Key : 05 11 04 19 03 22 07
C’text: X F G V H O Z

## NOTE: Here, key length = 8.

ie. Key string repeats after 8 positions
Prepared by: Mohan Gholap 10
2. The Hill Cipher
• Plaintext is broken into blocks of size m.
• Here, Key is a m X m matrix of integers between 0 to 25.
• Let p1, p2, p3, …,pm be the numeric representation of
characters in plaintext.
• Let c1, c2, c3, …,cm represent corresponding characters in
ciphertext.
• To compute a ciphertext, we use the mapping,
A -> 0, B -> 1, . . . , Z -> 25

## Prepared by: Mohan Gholap 11

• Now,
c1 = p1 k11 + p2 k21 + . . . + pm km1 mod 26
c2 = p1 k12 + p2 k22 + . . . + pm km1 mod 26
...
cm = p1k1m + p2k2m+ . . . + pmkmm mod 26

In general, c=pK
where, i) c and p are row vectors of ciphertext & plaintext resp’ly,
ii) K is m X m matrix comprising the key

## At Receiver, plaintext can be recovered by,

p = c K-1
Prepared by: Mohan Gholap 12
Example:
Consider a Hill cipher using block size = 2 (m=2)
Let, K= 3 7
15 12
Let, a block of plaintext be (H I)
Numeric equivalent of this block is (7 8)
Wkt, c=pK
c = (7 8) * 3 7
15 12
= (11 15)
= (L P)
Prepared by: Mohan Gholap 13
ELEMENTARY TRANSPOSITION CIPHERS

## • A transposition cipher shuffles, rearranges or

permutes the bits in a block of plaintext.

## • Unlike a substitution cipher, the number of 0’s

and 1’s in a block doesn’t change after shuffling.

## Prepared by: Mohan Gholap 14

Example:
Plaintext: b e g i
Begin Operation at Noon n o p e
r a t i
o n a t
n o o n
Let us re-arrange the rows as follows,

Row 1 ->3, Row 2 -> 5, Row 3 ->2, Row 4 -> 1, Row 5 -> 4.
The resulting matrix is o n a t
r a t I
b e g i
n o o n
n o p e
Prepared by: Mohan Gholap 15
• We now re-arrange the columns as follows,
Column 1->4, Column 2->3, Column 3->1, Column 4 ->2

t i a r
g i e b
o n o n
p e o n

## Thus ciphertext generated is:

ATNOTIARGIEBONONPEON

Another example:

## • An attacker may use this approach as follows,

• C’text: 1 1 K C T A T A M M O C P M 5 1 C E N E

## Prepared by: Mohan Gholap 17

Other Cipher properties
• Confusion & Diffusion:
Confusion is the property of a cipher where it
doesn’t provide any description/clue regarding
the relationship between cipher-text and key.

## Diffusion is the property of a cipher-text,

where block of the Plain-text is irretrievably
scattered across the blocks of cipher-text.

## Prepared by: Mohan Gholap 18

• Block Ciphers & Stream Ciphers
 In Block Ciphers, plaintext is split into fixed size chunks
called blocks. Here, each block is encrypted separately
and usually same key is used for all blocks.
Example: DES, AES, RSA, ECC, etc.

##  Stream Ciphers operate on bits. Stream ciphers usually

generate a pseudo random key stream as a function of
fixed length key and a per message bit string.
Example: RC4 used in wireless LAN protocol.

## Stream ciphers are faster than block ciphers and are

less complicated.
Prepared by: Mohan Gholap 19