Vous êtes sur la page 1sur 44

Classical Encryption Techniques

1
Introduction
Cryptography Area within the field of
cryptology.

Cryptology cryptos (hidden) + logos (science)

Cryptology Science of concealing.

Cryptology comprises the methods for encrypting
messages as well as methods for decrypting
messages.



2
Cryptology can be divided into two areas:
Cryptography
Cryptanalysis

Cryptography Art of secret writing.

Plaintext Message to be transformed.

Ciphertext Transformed message.
3
Encryption Plaintext Ciphertext

Decryption Ciphertext Plaintext

Encryption & decryption are done using keys.

Cryptanalysis Techniques for deciphering the
encrypted data without prior knowledge of which
key has been used.





4
Cryptanalytic attacks are of four types:

o Ciphertext only attack

o Known plaintext attack

o Chosen plaintext attack

o Chosen ciphertext attack






5
Ciphertext only attack

Attacker has access to a set of ciphertexts.

Attack is successful if the corresponding plaintexts
and key can be deduced.





6
Known plaintext attack

Attacker has samples of both the plaintext and the
corresponding ciphertext.

Aim is to deduce the key using this information.





7
Chosen plaintext attack

Attacker is able to define his own plaintext, feed it
into the cipher & analyze the resulting ciphertext.

This attack requires the attacker to be able to send
data to the encryption device & view the output
from the device.

Impossible to attempt in most cases.





8
Chosen ciphertext attack

- Attacker chooses his own ciphertext
- Obtains the plaintext from the deciphering
engine.

9
Two Types of Cryptography
Symmetric Cryptography
o Same key is used for encryption & decryption.
o Also termed as Private Key Cryptography.

Asymmetric Cryptography
o Two different keys are used for encryption &
decryption.
o Also termed as Public Key Cryptography.



10
Classical cipher systems

Two types:
o Substitution Ciphers Letters of plaintext are
replaced by other letters.

o Transposition Ciphers Letters of plaintext are
rearranged.
11
Classical cipher systems

Can also be classified as:
o Stream Ciphers Converts one symbol of
plaintext immediately into a symbol of
ciphertext.

o Block Ciphers Converts a block of plaintext
symbols to blocks of ciphertext.
12
Substitution Ciphers
Caesar Cipher
o Used by Julius Caesar.
o Shift Cipher Each letter is replaced by a letter
standing at a fixed number of places after it in
the alphabet.
o Used a shift of 3.
o C
i
= P
i
+ 3.
o Plaintext: A B C D E X Y Z
o Ciphertext: D E F G H.A B C
13
Encrypt the following user Caesar
Cipher
MEET ME AFTER THE PARTY
14
PHHW PH DIWHU WKH SDUWB
Substitution Ciphers (contd.)
Substitution alphabets are derived based on
a key.
First the alphabets are written.
Key is written below it & remaining letters
of the alphabet are filled after the key.
Eg: Key: WORD
A B C D E F G H I J K-------X Y Z
W O R D A B C E F G ------- X Y Z
15
Substitution Ciphers (contd.)

Duplicate letters in a keyword will be dropped.

Eg: Key: TEST
A B C D E F G H ------------X Y Z
T E S A B C D F -------------X Y Z
16
Encrypt the following
COME BACK EARLY
Key: INDIA
17
DOLB NIDJ BIRKY
Substitution Ciphers (contd.)
Playfair cipher
o Based on the use of a 5X5 matrix of letters
constructed using a keyword.
o The matrix is constructed by filling in the letters of
the keyword from left to right & from top to
bottom.
o Then fill the remainder of the matrix with the
remaining letters in alphabetic order.
o Letters I & J are counted as one letter.


18
Substitution Ciphers (contd.)
o Plaintext is encrypted two letters at a time as
follows:

If a pair is a repeated letter, insert filler like
X.

If both letters fall in the same row, replace
each with letter to right (wrapping back to
start from end) .


19
Substitution Ciphers (contd.)

If both letters fall in the same column,
replace each with the letter below it
(wrapping to top from bottom)

Else, each letter is replaced by the letter in
the same row and in the column of the other
letter of the pair.





20
Substitution Ciphers (contd.)
Ex:- Keyword is MONARCHY




21
Substitution Ciphers (contd.)
Ex:- Keyword is MONARCHY

AR is encrypted as RM.
MU is encrypted as CM.
HS is encrypted as BP.
EA is encrypted as IM or JM.





22
Encrypt the following
WE LIVE IN A WORLD FULL OF
BEAUTY.
Key - ANOTHER.

A N O T H
E R B C D
F G I/J K L
M P Q S U
V W X Y Z

23
Digrams are WE LI VE IN AW OR LD FU
LX LO FB EA UT YZ

Ciphertext is VRFK AFGO NVNB ULLM
IZIH IEFE SH ZV



24
Substitution Ciphers (contd.)
Hill cipher
o Uses matrix multiplication to generate the
ciphertext.

o Encryption is done as, C = KP mod 26, where
K is an nXn matrix representing the encryption
key & C and P are column vectors of length n.

25
Substitution Ciphers (contd.)
Eg:-Plaintext: PAY MORE MONEY
Key matrix: 17 17 5
21 18 21
2 2 19
15 375 11
K 0 = 819 mod 26 = 13 = LNS
24 486 18
Finally, ciphertext will be LNS HDL EWM
TRW
26
Encrypt the following
Eg:-Plaintext: ACT
Key matrix: 6 24 1
13 16 10
20 17 15
0 67 15
K 2 = 222 mod 26 = 14 = POH
19 319 7
27
Substitution Ciphers (contd.)
Vigenere Cipher
o Polyalphabetic cipher - Different substitution alphabets
are used for the same alphabet in plaintext based on a
key value.
o Encryption is done with the help of Vigenere table as
follows:
Locate the plaintext letter on the top row.
Locate the key letter on the side column.
Encrypt the letter using the letter at the intersection
of the row & column.
Shift cipher with C
i
= P
i
+ K
i
.

28






Vigenere Table
29






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
A 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
B 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 A
C C 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
D 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
E 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 D
F F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
G G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
H H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
I I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
J J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
K K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
L L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
M M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
N N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
O O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
P P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
Q Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
R R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
S S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
T T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
U U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
V V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
W W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
X X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
Y Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
Z Z 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






Substitution Ciphers (contd.)

Eg: Key: DECEPTIVE
Plaintext: WE ARE DISCOVERED

WE ARE DISCOVERED
DE CEP TIVEDECEPT

Ciphertext is ZI CVT WQNGRZGVTW
30






Encrypt the following user Vigenere
Cipher
COMPUTING GIVES INSIGHT
Key: LUCKY
31
NIOZSECPQ ETPGC GYMKQFE
Substitution Ciphers (contd.)
Vernam Cipher
o Convert letters to their numeric equivalents.

o Generate random numbers to be added with the
letter codes.

o Calculate the sum mod 26 of each coded letter
with corresponding random number.

o Cipher text is the base 26 representation of the
resulting letter.

32
Substitution Ciphers (contd.)
Eg:
Plaintext: V E R N A M C I P H E R
Numeric Eq: 21 4 17 13 0 12 2 8 15 7 4 17
Random No: 76 48 16 82 44 3 58 11 60 5 48 88
Sum: 97 52 33 95 44 15 6019 75 12 52 105
Sum mod 26: 19 0 7 17 18 15 8 19 23 12 0 1
Ciphertext: T A H R S P I T X M A B
33
Encrypt the following user Vernam
Cipher
I AM HERE
Random nos: 11 44 3 5 48 88 10
34
T SP MABO
Transposition (Permutation) Ciphers
Rail fence technique

o Arrange the plaintext charatcters as a sequence
of diagonals.

o Read off as a sequence of rows.


35
Transposition Ciphers (contd.)
Eg:-
Plaintext : MEET ME HERE

M E M H R
E T E E E

Ciphertext: MEMHR ETEEE

36
Encrypt the following
COME HOME TOMORROW

CMHM TMRO OEOE OORW
37
Transposition Ciphers (contd.)
Columnar Transposition
o Rearrangement of the characters of the plaintext
into columns. The no.of columns represents the
key.
o Write the characters of plaintext in rows.
o Form the ciphertext by reading down the
column.
o If the message length is not a multiple of the
chosen no, a special character is used to fill in
any short column.

38
Transposition Ciphers (contd.)
Eg:
o Plaintext: THIS IS A SAMPLE MESSAGE
o Choose key to be 5.
T H I S I
S A S A M
P L E M E
S S A G E
o Ciphertext: TSPS HALS ISEA SAMG IMEE

39
Encrypt the following
COME HOME TOMORROW
Choose key to be 4.
C O M E
H O M E
T O M O
R R O W

CHTR OOOR MMMO EEOW

40
Transposition Ciphers (contd.)
Write the message row wise.
Read the message column wise, but permute the
order of the columns based on a key value.
Eg:
o Plaintext: WE ARE DISCOVERED
o Key: Z E B R A S (6 3 2 4 1 5)
W E A R E D
I S C O V E
R E D $ $ $
o Ciphertext: EV$ ACD ESE RO$ DE$ WIR
41
Encrypt the following

COME HOME TOMORROW
Key is 4, 6, 1, 2, 5, 3
4 6 1 2 5 3
C O M E H O
M E T O M O
R R O W $ $

MTO EOW OO$ CMR HM$ OER

42
Transposition Ciphers (contd.)
Transposition based on the key value can be done
in the following way too.
Eg:
o Plaintext: WE ARE DISCOVERED
o Key: Z E B R A S (6 3 2 4 1 5)
1 2 3 4 5 6
W E A R E D
I S C O V E
R E D $ $ $
o Ciphertext: DE$ ACD ESE RO$ WIR EV$
43
Encrypt the following

COME HOME TOMORROW
Key is 4, 6, 1, 2, 5, 3
1 2 3 4 5 6
C O M E H O
M E T O M O
R R O W $ $

EOW OO$ CMR OER HM$ MTO

44

Vous aimerez peut-être aussi