Information Security (1030106508)

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

INFORMATION SECURITY (1030106508)

PRACTICAL: 11

AIM:- Implement Play Fair Substitution on Encryption &


Decryption.
Introduction:
 The Playfair Cipher was first described by Charles Wheatstone in 1854, and it was the
first example of a Digraph Substitution Cipher. It is named after Lord Playfair, who
heavily promoted the use of the cipher to the military.

 When it was first put to the British Foreign Office as a cipher, it was rejected due to
its perceived complexity. However, it was later adopted as a military cipher due to it
being reasonably fast to use, and it requires no special equipment, whilst also
providing a stronger cipher than a Monoalphabetic Substitution Cipher.

Encryption:
 In order to encrypt using the Playfair Cipher, we must first draw up a Polybius Square
(but without the need for the number headings). This is usually done using a keyword,
and either combining "i" and "j" or omitting "q" from the square.

 We must now split the plaintext up into digraphs. On each digraph we perform the
following encryption steps:

Step 1: If the digraph consists of the same letter twice then insert the letter "X"
between the same letters, and then continue with the rest of the steps.

Step 2: If the two letters appear on the same row in the square, then replace each letter
by the letter immediately to the right of it in the square.

Step 3: If the two letters appear in the same column in the square, then replace each
letter by the letter immediately below it in the square.

Step 4: Form the rectangle for which the two plaintext letters are two opposite corners.
Then replace each plaintext letter with the letter that forms the other corner of the
rectangle that lies on the same row as that plaintext letter.
Example:

 We encrypt the plaintext "hide the gold in the tree stump". We do this by setting out a
5x5 grid, and filling it with the alphabet, starting with the letters of the key phrase,
and ignoring any letters we already have in the square. We are also going to combine
"I" and "J" in the square.

DHRUV SOJITRA
(20270106160) Page 1
INFORMATION SECURITY (1030106508)

 Plaintext = hide the gold in the tree stump.


 Key = Playfair Example

[5 x 5 Matrix]

We must now split the plaintext into digraphs. At this point it is a good idea to apply Rule 1,
and split up any double letter digraphs by inserting an "x" between them.

[split the plaintext and put ‘x’ when same characters are match]

We now take each digraph in turn and apply rule 2, 3 or 4 as necessary. If pair of plaintext
are in same row of matrix then:

If pair of plaintext are in same column of matrix then:

DHRUV SOJITRA
(20270106160) Page 2
INFORMATION SECURITY (1030106508)

If pair of plaintext are in random place of matrix then:

Ciphertext = UA ARBED EXAPO PR QNX AXANR

DHRUV SOJITRA
(20270106160) Page 3
INFORMATION SECURITY (1030106508)

Decryption:

 Reverse process to Encryption.


 When you are convert Ciphertext to Plaintext then fully reverse process of
Encryption

Ciphertext = UA ARBED EXAPO PR QNX AXANR


Key = Example

[5 x 5 Matrix]

 Plaintext = hide the gold in the tree stump.

DHRUV SOJITRA
(20270106160) Page 4
INFORMATION SECURITY (1030106508)

PRACTICAL: 12

AIM:- Implement Vigenere Substitution on Encryption &


Decryption.

Introduction:

 Vignere Cipher First described by Giovan Battista Bellaso in 1553, the


cipher is easy to understand and implement. Many people have tried to
implement encryption schemes that are essentially Vignere ciphers. In
1863, Friedrich Kasiski was the first to publish a general method of
deciphering Vignere ciphers. In the 19th century the scheme was
misattributed to Blaise de Vignere, and so acquired its present name.

 Vignere Cipher is a method of encrypting alphabetic text. It uses a simple


form of polyalphabetic substitution. A polyalphabetic cipher is any cipher
based on substitution, using multiple substitution alphabets.

 The encryption of the original text is done using the Vignere table.

 Above is the picture of Blaise de Vignere who invented Vignere Cipher


technique.

DHRUV SOJITRA
(20270106160) Page 5
INFORMATION SECURITY (1030106508)

 Encryption:

 To encrypt a message using the Vignere Cipher you first need to


choose a keyword. You then repeat this keyword over and over
until it is the same length as the plaintext. This is called the
keystream.
 Now for each plaintext letter, you find the letter down the left hand
side of the Vignere table. You also take the corresponding letter
from the keystream, and find this across the top of the Vignere
table. Where these two lines cross in the table is the ciphertext letter
you use.

DHRUV SOJITRA
(20270106160) Page 6
INFORMATION SECURITY (1030106508)

 As an example, we shall encrypt the plaintext "a simple example"


using the keyword battista. First we must generate the keystream,
by repeating the letters of the keyword until it is the same length as
the plaintext.

Message:- HELLO I AM DHRUV.


Key:- APPLE.

Plaintext: H E L L O I A M D H R U V.
KEY: A P P L E A P P L E A P P

Ciphertext:- HPAWS I PB OLRJK

 Decryption:

 To decrypt a ciphertext with the keyword, we first have to generate


the keystream by repeating the keyword until we have a keystream
the same length as the ciphertext. Then you find the column with
the letter of the keystream at the top, and go down this column until
you find the ciphertext letter. Now read across to the far left of the
table to reveal the plaintext letter.

 As an example we shall decipher the ciphertext -


"ZPSPNOXMOFAORMQDPUKZ" which has been encoded using
the keyword giovan. We start by generating the keystream.

Ciphertext:- HPAWS I PB OLRJK


Key:- APPLE.

Ciphertext:- HPAWS I PB OLRJK


KEY: APPLE A PP LEAP P

Plaintext: HELLO I AM DHRUV.

DHRUV SOJITRA
(20270106160) Page 7
INFORMATION SECURITY (1030106508)

PRACTICAL: 13

AIM:- Implement One Time Pad(OTP) Substitution on Encryption


& Decryption.
One-Time Pad:
 if a truly random key as long as the message is used, the cipher will be
secure called a One-Time pad.
 is unbreakable since ciphertext bears no statistical relationship to the
plaintext, since for any plaintext & any cipher text there exists a key
mapping one to other can only use the key once though.
 have problem of safe distribution of key The One-Time Pad is an
evolution of the Vernham cipher, which was invented by Gilbert Vern
ham in 1918, and used a long tape of random letters to encrypt the
message. An Army Signal Corp officer, Joseph Mauborgne, proposed an
improvement using a random key that was truly as long as the message,
with no repetitions, which thus totally obscures the original message.
Since any plaintext can be mapped to any ciphertext given some key,
there is simply no way to determine which plaintext corresponds to a
specific instance of ciphertext.

Encryption:
 In this mechanism we assign a number to each character of the Plain-
Text, like (a = 0, b = 1, c = 2, … z = 25).
 Step 1: Assign a number to each character of the plain-text and the key
according to alphabetical order.
 Step 2: Add both the number (Corresponding plain-text character number
and Key character number).
 Step 3: Subtract the number from 26 if the added number is greater than
26, if it isn’t then leave it.
Example:
Plain text — H E L L O → 7 4 11 11 14
Key — M O N E Y → 12 14 13 4 24
Plain text + key → 19 18 24 15 38 → 19 18 24 15 12 (= 38 – 26)
Cipher Text → T S Y P M

DHRUV SOJITRA
(20270106160) Page 8
INFORMATION SECURITY (1030106508)

Decryption:
 For Decryption, Apply the same rules and steps are mentioned in Encryption
Technique. In short, We can say that Decryption is the Reverse process of
Encryption.

Example:
Cipher Text — T S Y P M → 19 18 24 15 12
Key — M O N E Y → 12 14 13 4 24
Cipher text - key → 7 4 11 11 -12 → 7 4 11 11 14(= 38 – 26)
Cipher Text → H E L L O

DHRUV SOJITRA
(20270106160) Page 9
INFORMATION SECURITY (1030106508)

PRACTICAL: 14
AIM:- Prepare a report on block cipher modes of operation.

DHRUV SOJITRA
(20270106160) Page 10
INFORMATION SECURITY (1030106508)

PRACTICAL: 15
AIM:- Prepare a report on DES.

 THE DATA ENCYPTION STANDARD.


 SDES encrypts 64-bit blocks using a 56-bit key and produces a 64-bit ciphertext.
 Same steps, with the same k y, are used to reverse the encryption with the order of the keys
reversed.
 The DES is widely used.

DES Encryption

The DES encryption is shown in the figure below:

DHRUV SOJITRA
(20270106160) Page 11
INFORMATION SECURITY (1030106508)

 Encryption function has two inputs: the plaintext to be encrypted and the key.
 The processing of the plaintext proceeds in three phases.
 The 64-bit plaintext passes through an initial permutation (IP) that rearranges the
bits to produce the permuted input.
 The permuted output is then passed through sixteen rounds of the same function,
which involves both permutation and substitution functions. The left and right
halves from the last round are swapped to produce preoutput.
 The preoutput is passed through a permutation that is the inverse of the
initial permutation function, to produce the 64-bit cipher text.
 The right-hand portion of the figure shows the way in which the 56-bit key is used.
 Initially, the key is passed through a permutation function.
 Then, a sub key (k;) is produces for each of the sixteen rounds by the combination of a
left circular shift and a permutation.
 The permutation function is the same for each round, but a different sub key is
produced because of the repeated shifts of the key bits.
 The initial permutation and its inverse are defined by tables.
 The tables are to be interpreted as follows.
 The input to a table consists of 64 bits numbered from 1 to 64.
 The 64 entries in the permutation table contain a permutation of the numbers from
1 to 64.
 Each entry in the permutation table indicates the position of a input bit in the
output.
 Inverse permutation table nullifies the effect of initial permutation.

Figure shows the internal structure of a single round.

DHRUV SOJITRA
(20270106160) Page 12
INFORMATION SECURITY (1030106508)

The left and right halves are treated as separate 32-bit quantities, labeled L (left) and R
(right).
The overall processing at each round can be summarized as:

Expansion (E)
o The 32-bit input is first expanded to 48 bits.
o Bits of input are split into groups of 4 bits.

Substitution (S-Box)
 This 48-bit result is input to S-Boxes that perform a substitution on
input and produces a 32-bit output.
 It is easy to understand S-Box by following figure.
 DES consists of a set of eight S-boxes.
 Each S-Box takes 6 bits as input and produces 4 bits as output.
 The first and last bits of the input to box form a 2-bit binary number
which gives the binary value of row number.
 The decimal value in the cell selected by the row and column is then
converted to its 4-bit binary number to produce the output.
 For example, in S1, for input 101110, the row is 10 (row 2) and the
column is 0111(column 7).The value in row 2, column 7 is 11, so the output
is 1011.

Key Generation
 A 64-bit key is used as input to the algorithm while only 56 bits are actually
used. Every eighth bit is ignored. Sub-keys at each round are generated as given
below:
 The key is first permuted using a table named Permuted Choice One.
 The resulting 56-bit key is divided into two 28-bit quantities, and D . At
each round, C;- and D,- are separately subjected to a circular left shift of 1 or 2
bits, as governed by a table.
 These shifted values are forwarded to the next round. They are also input to a
permutation table- Permuted Choice Two.
 The table produces a 48-bit output that serves as the round key k;.

DES Decryption
 Decryption in DES is same as encryption, except that the sub keys are used in
reverse order.

DHRUV SOJITRA
(20270106160) Page 13

You might also like