Cryptography Techniques

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 71

Cryptography Techniques

• There are 2 primary ways in which a plain text message can be


codified to obtain the corresponding cipher text.
• - Substitution Techniques – In substitution cipher technique, the
character of a plain text message are replaced by other characters,
numbers or symbols
• - Transposition Techniques – These also perform some permutation
over the plain text.
• - When these 2 approaches are used together we call the technique
as product cipher.
SUBSTITUTION TECHNIQUES
Caesar Cipher
• Each alphabet in a message is replaced by an alphabet three places
down the line.
• HELLO ATUL
• KHOOR DWXO
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

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
• Very weak scheme of hiding plain text message

• Algorithm to break Caesar cipher


• 1. Read each alphabet in the cipher text message, and search for it in
the second row of the replacement table.
• 2. When a match is found, replace that alphabet in the cipher text
message with the corresponding alphabet in the same column but the
first row of the table
• Repeat the process for all alphabets in the cipher text message
K H O O R K R Z D U H B R X Cipher Text

H E L L O H O W A R E Y O U Plain Text
Modified Version of Caesar Cipher
• Complicate Caesar Cipher to make attacker’s life difficult
• Cipher text alphabets corresponding to original plain text alphabets may
not necessarily be three places down the order, but instead can be any
places down the order.
• Once the replacement scheme is decided it would be constant and will be
used for all other alphabets in the messgae
• This complicate matters a bit
• Alphabet A can be replaced by any other alphabet in English alphabet set
(B-Z), B can be replaced by any other alphabet in English alphabet (A, C-Z).
• Thus for each alphabet we have 25 possibilities of replacement.
• Algorithm to break modified Caesar Cipher
• 1. Let k be a number equal to 1
• 2. Read the complete cipher text message
• 3. Replace each alphabet in the cipher text message with an alphabet
that is k positions down the order.
• 4. Increment k by 1
• 5. The original text message corresponding to the cipher text message
is one of the 25 possibilities produced by above steps.
Cipher Text K W U M P M Z M

Attempte no (k)
1 L X V N Q N A N
2 M Y W O R O B O
3 N Z X P S P C P
4 O A Y Q T Q D Q
5 P B Z R U R E R
6 Q C A S V S F S

18 C O M E H E R E

25 J V T L O L Y L
• A mechanism of encoding messages so that they can be sent securely
is Cryptography.
• An attack on a cipher text message wherein the attacker attempts to
use all possible permutations and combinations is called as Brute
Force Attack.
• The process of trying to break any cipher text message to obtain the
original plain text message itself is called as Cryptanalysis and the
person attempting a cryptanalysis is called as Cryptanalyst.
• Cryptanalyst is a person who attempts to break a Caesar cipher
message to obtain the original plain text message. The process itself is
called as cryptanalysis.
• A Cryptanalyst attempting a brute force attack tries all possibilities to
derive the original plain text message from a given cipher text
message.
• For modified Caesar Cipher following points are to be known to break
a cipher text message using brute force attack
• - Substitution technique was used to derive the cipher text from the
original plain text
• - There are only 25 possibilities to try out
• - The language of the plain text was English.
Mono-alphabetic Cipher
• Rather than using a uniform scheme of replacement for all the
alphabets in a given plain text message we decide to use random
substitution
• Thus A can be replaced by any random alphabet (B-Z), B can be
replaced by any other random alphabet (A, C-Z)
• There is no relation between the replacement of B and A
• That is if we decide to replace A with D, we need not replace B with E-
we can replace each B with any other character.
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
D E A B C U W V F Y Z X G T H S R I J Q P K L O N M

• HELLO SIR , SATYENDR


• VCXXH JFI , JDQNCTBI
• The number of permutations and combinations now will be very high
and the cipher text is extremely difficult to crack
• Mono-alphabetic cipher pose a difficult problem for cryptanalyst
because it can be very difficult to crack thanks to the high number of
possible permutations and combinations.
• Attacks can be planned based on knowledge of English language, like
some letters occur more frequently in English, if a single alphabet is
found in cipher text the probability that it is P is 13.33%, After P
comes Z which is likely to occur 11.67%, probability the alphabet is
C,K,L,N, or R is almost the lowest.
• Patters of alphabets in cipher text, repeated patters of words, for eg.
Two alphabet cipher patterns since the word to occur very frequency
in English, repeating three alphabet patterns and replace them with
the word the and so on.
Homophonic Substitution Cipher
• The Homophonic Substitution Cipher is very similar to Mono-
alphabetic Cipher.
• Like a plain substitution cipher technique, we replace one alphabet
with another in this scheme.
• The replacement alphabet set in case of simple substitution technique
is fixed (i.e. A replaces with D, B with F etc.)
• Here, one plain text alphabet can map to more than one cipher text
alphabet. For e.g. A can be replaced by {D, H, P, R, B} , B can be
replaced by {E, I, Q, S}
• Homophonic Substitution Cipher also involves substitution of one
plain text character with a cipher text character at a time, however
the cipher text character can be any of the chosen set.
Polygram Substitution Cipher
• In Polygram substitution Cipher, rather than replacing one plain text
alphabet with one cipher text alphabet at a time, a block of alphabets
is replaced with another block.

HELLO YUQQW

HELL TEUI

• The replacement of plain text happens block by block rather than


character by character.
• Polygram substitution Cipher technique replaces one block of plain
text with a block of cipher text- it does not work on a character by
character basis.
Polyalphabetic Substitution Cipher
• Invented by Leon Battista in 1568.
• Examples, Vigenère Cipher and Beaufort Cipher
• This cipher uses multiple one character keys. Each of the key encrypts
one plain text character.
Playfair Cipher
• Playfair Cipher also called Playfair square is a cryptographic technique,
used for manual encryption of data.
• Invented by Charles Wheatstone in 1854.
• It was used in British Army in World War I and by Australians in World
War II.
• Playfair is quite fast to use and does not require any special equipment
to be used.
• It was used to protect important but not very critical information, so
that by the time the cryptanalyst could break it the value of information
was nullified anyway.
• The Playfair encryption scheme uses two main processes:

Playfair Cipher

Step 1: Creation and Population of matrix

Step 2: Encryption Process


• Step 1: Creation and Population of matrix
• The Playfair Cipher makes use of a 5 X 5 matrix, which is used to store
a keyword or phrase that becomes a key for encryption and
decryption.
• The way this is entered into 5 X 5 matrix is based on some simple rules

• 1. Enter the keyword in the matrix row wise : left to right and then top
to bottom.
• 2. Drop Duplicate letters
• 3.Fill the remaining spaces in the matrix with the rest of the English
alphabets (A-Z) that were not a part of our keyword. While doing so,
combine I and J in the same cell of the table. If I or J is a part of a
keyword, disregard both I and J while filling the remaining slots.
• Suppose that our keyword is PLAYFAIR EXAMPLE. The 5 X 5 matrix
containing our keyword will be as follows:
P L A Y F

I R E X M

B C D G H

K N O Q S

T U V W Z
• The first row of the matrix is shown below
P L A Y F

• This is simply the first 5 letters of keyword (PLAYFAIR EXAMPLE)


• We write them as rule #1
• The second row of the matrix is as shown below
• Y
• F
I R E X M

• The first 4 cells are just the continuation of keyword (PLAYFAIR


EXAMPLE).
• We have repetition of Alphabet A. Therefore we disregard the
repeating A as per rule #2 and choose the next alphabet.
• The third row of the matrix is as shown below:

B C D G H

• In first 2 row PLAYF IREXM


• PLAYFAIR EXAMPLE
• As all our keyword alphabets are covered now, there is nothing left to
populate in our matrix from the third row onwards. Hence, we would
now consider rule # 3.
• This rule suggests that we should fill the remaining part of matrix with
alphabets A-Z that are yet unused. Based on this criterion we see the
third row as
B C D G H

• Fourth row as
K N O Q S

• Fifth row as
T U V W Z
• Step 2: Encryption Process
• 1. Before executing these steps the plaintext message that we want to
encrypt needs to be broken down into groups of tow alphabets. For
example if our message is
• MY NAME IS ATUL, it become
• MY NA ME IS AT UL
• The encryption process works on this broken-down message.
• 2. If both alphabets are the same (or only one is left), add an X after
the first alphabet. Encrypt the new pair and continue.
• 3.If both the alphabets in the pair appear in the same row of our
matrix, replace them with alphabets to their immediate right
respectively. If the original pair is on the right side of the row, then
wrapping around to the left side of the row happens.
• 4. If both the alphabets in the pair appear in the same column of our
matrix , replace them with alphabets immediately below them
respectively. If the original pair is on the bottom side of the row, then
wrapping around to the top side of the row happens.
• 5. If the alphabets are not in the same row or column, replace them
with the alphabets in the same row respectively, but at the other pair
of corners of the rectangle defined by the original pair. The order is
quite significant here. The first encrypted alphabet of the pair is the
one that is present on the same row as the first plaintext alphabet.
• Our Keyword is PLAYFAIR EXAMPLE
• Original Text is MY NAME IS ATUL.

• Matrix for the keyword (PLAYFAIR EXAMPLE) is


Encryption Process
• First we break the original text into pairs of two alphabets each.
• MY NAME IS ATUL

• MY NA ME IS AT UL
• Now we apply our Playfair cipher algorithm to this text. The first pair
of alphabet is MY. Looking at the matrix the alphabets M and Y do not
occur in the same row or column. Therefore we need to apply step
#5. This means we need to replace this text with the text diagonally
opposite to it. In this case the text is XF which is our first cipher text
block.
P L A Y F

I R E X M

B C D G H

K N O Q S

T U V W Z
• Next text block to be encrypted is NA. Again step 5 will apply. Second
block of cipher if OL.

P L A Y F

I R E X M

B C D G H

K N O Q S

T U V W Z
• The third block of plain text is ME. We see that the alphabets ME are
in the same row. Based on logic of step #3 the cipher text block will be
IX.

P L A Y F

I R E X M

B C D G H

K N O Q S

T U V W Z
• Forth block of plaintext is IS. We need to apply the logic of step #5 to
get the diagonal alphabets. Based on this the cipher text block will be
MK.

P L A Y F

I R E X M

B C D G H

K N O Q S

T U V W Z
• Now we look at the fifth block of plain text, which is AT. We can see
that we need to apply logic of step # 5. Based on this the cipher text
block is PV.

P L A Y F

I R E X M

B C D G H

K N O Q S

T U V W Z
• Now we look at the last block of plain text, which is UL. We can see
that the 2 alphabets U and L are in the same column. Therefore, we
need to apply the logic of step # 4. We get the cipher text alphabet as
LR.

P L A Y F

I R E X M

B C D G H

K N O Q S

T U V W Z
• Thus our Plain Text Block
• MY NA ME IS AT UL becomes
• XF OL IX MK PV LR
• The Decryption process works in exactly the opposite steps.
Hill Cipher
• Works on multiple letters at the same time.
• It is a type of polygraphic substitution cipher
• Lester Hill invented this in 1929
• Based on matrix theory
• Treat every letter in the plain text message as a number, so that
• A =0, B=1, C= 2 and Z = 25.
• The plain text message is organized as a message of numbers, based
on the above conversion. For example if our plain text is CAT. Based
on the above steps we know that C = 2, A = 0 and T = 19. There our
plain text matrix will look as follows:

19
• Now, our plain text matrix is multiplied by a matrix of randomly
chosen keys. The key matrix consists of size nXn, where n is the
number of rows in our plain text matrix. For example we take the
following key matrix.
6 24 1

13 16 10

20 17 15
• Now multiply the 2 matrix as shown below

6 24 1 2 31

13 16 10 0 216
X =
20 17 15 19 325
• Now compute mod 26 value of the above matrix

31 5

216 8

mod 26 =
325 13
• Now translating the numbers to alphabets
• 5 = F, 8 = I and 13 = N.
• Therefore our cipher text is FIN.
• For decryption take the cipher text message and multiply it with the
inverse of our original key matrix.
• The inverse of our original key matrix is

8 5 10

21 8 21

21 12 8
• For decryption, take the cipher text matrix and multiply it by the
inverse of our original key matrix.

8 5 10 5 210

• 21 8 21 X 8 = 442

21 12 8 13 305
• Now we need to take modulo 26 on this matrix

210 2

442 0
• mod 26 =
305 19
• Thus our plain text message contains 2,0,19. which corresponds to
• 2 = C, 0 = A and 19 = T
• This gives us original plain text message CAT.
TRANSPOSITION TECHNIQUES
Rail fence Technique
• The Rail fence technique is an example of transposition. It uses a
simple algorithm
• 1. Write down the plain text message as a sequence of diagonals
• 2. Read the plain text written in step 1 as a sequence of rows.
• Plain Text : come home tomorrow

•c m h m t m r o
• o e o e o o r w

• Read the text row by row and write it sequentially


• cmhmtmrooeoeoorw (cipher text)
• Rail fence technique involves writing plain text as sequence of
diagonals and then reading it row-by-row to produce cipher text.
Simple columnar transposition
technique(Basic technique)
• Variations of the basic transposition technique such as Rail fence
technique exist.
• We call it as Simple Columnar Transposition Technique
• Algorithm used
• 1. Write the plain text message row-by-row in a rectangle of a pre-
defined size.
• 2. Read the message column-by-column. However, it need not be in the
order of columns 1,2,3 etc. It can be any random order such as 2,3,1 etc.
• 3. The message obtained is the cipher text message.
• Original Plain Text : COME HOME TOMORROW
• Let us consider a rectangle of six columns. Therefore when we write
the message in the rectangle row-by-row (suppressing spaces), it
would look as follows:

Column 1 Column 2 Column 3 Column 4 Column 5 Column 6

C O M E H O

M E T O M O

R R O W
• Now, let us decide the order of the columns as some random order,
say 4,6,1,2,5,3
• Then read the text in the order of these columns.
• The cipher text obtained would be
• EOWOOCMROERHMMTO
• The simple Columnar Transposition Technique simple arranges the
plain text as a sequence of rows of a rectangle that are read in
columns randomly.
• Quite simple to break into
• Trying out few permutations and combinations of column orders to
get hold of the original plain text.
• We can modify simple columnar transposition technique to add
another twist : perform more than one rounds of transposition using
the same technique
Simple Columnar Transposition Technique
with multiple rounds
• The idea here is to use the same basic procedure as used by the Simple
Columnar Transposition Technique but do it more than once.
• That adds more complexity to the cryptanalyst.
• Algorithm used
• 1. Write the plain text message row-by-row in a rectangle of a pre-defined
size.
• 2. Read the message column-by-column. However it need not be in the
order of columns 1,2,3, etc. . It can be any random order such as 2,3,1, etc.
• 3. The message thus obtained is the cipher text message of round 1.
• 4. Repeat steps 1 to 3 as many times as desired.
• Original Plain Text : COME HOME TOMORROW
• Let us consider a rectangle of six columns. Therefore when we write
the message in the rectangle row-by-row (suppressing spaces), it
would look as follows:

Column 1 Column 2 Column 3 Column 4 Column 5 Column 6

C O M E H O

M E T O M O

R R O W
• Now let us decide the order of columns as some random order, say
4,6,1,2,5,3. Then read the text in the order of these columns.
• The cipher text thus obtained is EOWOOCMROERHMMTO in round 1.
• The tabular representation of the cipher text after round 1 is as
follows:
Column 1 Column 2 Column 3 Column 4 Column 5 Column 6

E O W O O C

M R O E R H

M M T O
• Now let us use the same order of columns as before that is 4,6,1,2,5,
and 3. Then read the text in the order of these columns
• The cipher text thus obtained would be OEOCHEMMORMORWOT in
round 2.
• Continue like this if more number of iterations is desired, otherwise
stop.
• More the number of iterations more complex is the cipher text
produced.
• Cipher text produced by the Simple Columnar Transposition
Technique with multiple rounds is much more complex to crack as
compared to the basic technique.
Vernam Cipher (One-time pad)
• Vernam Cipher whose specific subset is called as One-Time Pad is
implemented using a random set of non-repeating characters as the
input cipher text.
• Once an input cipher text for transposition is used, it is never used
again for any other message (hence the name one-time). The length
of the input cipher text is equal to the length of the original plain text.
• Algorithm
• 1. Treat each plain text alphabet as a number in an increasing
sequence i.e. A=0, B=1, C=2, ……Z=25
• 2.Do the same for each character of the input cipher text.
• 3.Add each number corresponding to the plain text alphabet to the
corresponding input cipher text alphabet number
• 4. If the sum thus produced is greater than 26, subtract 26 from it.
• 5. Translate each number to the sum back to the corresponding
alphabet. This gives the output cipher text.
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

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
• Plain Text Message : HOW ARE YOU
• One-time pad : NCBTZQARX
(input cipher text)
• Cipher text Message: UQXTRUYFR
H O W A R E Y O U
Plain txt 7 14 22 0 17 4 24 14 20
+
One time 13 2 1 19 25 16 0 17 23
pad
N C B T Z Q A R X
Initial 20 16 23 19 42 20 24 31 43
Total
Subtract 20 16 23 19 17 20 24 5 17
26, if >
25
Cipher U Q X T R U Y F R
text
• Vernam Cipher uses a one-time pad which is discarded after a single
use and therefore is suitable only for short messages.
Book Cipher/Running Key Cipher
• The idea used here is similar in principle to the Vernam Cipher
• For producing cipher text, some portion of text from a book is used,
which serves the purpose of one-time pad.
• They are added to the input plain text message similar to the way a
one-time pad works.

You might also like