Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

L. J.

POLYTECHNIC
L. J. Campus, Between Sarkhej-Sanand Circle & Kataria Motors,

S.G. Road, Ahmedabad-382210.

Ph. 079-29096539.

Notes
Of
Computer
And
Network Security
DEPARTMENT OF COMPUTER ENGINEERING

SEMESTER – 5
Computer and Network Security [3350704] Notes Unit 3

CNS UNIT 3

1. Explain symmetric encryption in detail.


Symmetric encryption is a means of protecting data using a secret key to
encrypt (lock) and decrypt (unlock) it. The sender and recipient share the key
or password to gain access to the information.

The key can be a word; a phrase; or a nonsensical or random string of letters,


numbers, and symbols. Many organizations use symmetric encryption because
it is relatively inexpensive. But it does come with some flaws. A key in
symmetric encryption can be used forever, and that sometimes leads
organizations to forget to change them. As a result, even users who may no
longer be part of the company can intercept and read encrypted data.

Symmetric encryption works the same way as locking the door to a family’s
home to which only the husband and the wife hold the key. Even when
neighbors or their in-laws try to open the door, they can’t do so unless they use
any of the couple’s keys. When other people take the key from the husband or
wife, they can open the door even without the knowledge or presence of the
couple.

In symmetric encryption, the key that encrypts a message or file is the same
key that can decrypt them. The sender of the data uses the symmetric key
algorithm to encrypt the original data and turn it into cipher text. The encrypted
message is then sent to the receiver who uses the same symmetric key to
decrypt or open the cipher text or turn it back into readable form.

If somebody other than the intended recipient gets access to the symmetric key,
he/she can also decrypt the message. For this reason, symmetric encryption is
considered less secure compared to asymmetric encryption. Needless to say,
careful and secure handling of the key is necessary to protect data and its
owners.

2
Computer and Network Security [3350704] Notes Unit 3

2. Explain asymmetric encryption in detail.


Asymmetric cryptography, also known as public-key cryptography, is a
process that uses a pair of related keys -- one public key and one private key --
to encrypt and decrypt a message and protect it from unauthorized access or
use.

A public key is a cryptographic key that can be used by any person to encrypt a
message so that it can only be decrypted by the intended recipient with their
private key. A private key -- also known as a secret key -- is shared only with
key's initiator.

When someone wants to send an encrypted message, they can pull the intended
recipient's public key from a public directory and use it to encrypt the message
before sending it. The recipient of the message can then decrypt the message
using their related private key.

If the sender encrypts the message using their private key, the message can be
decrypted only using that sender's public key, thus authenticating the sender.
These encryption and decryption processes happen automatically; users do not
need to physically lock and unlock the message.

The encryption process is also used in software programs that need to establish
a secure connection over an insecure network, such as browsers over the
internet, or that need to validate a digital signature.

Increased data security is the primary benefit of asymmetric cryptography. It is


the most secure encryption process because users are never required to reveal
or share their private keys, thus decreasing the chances of a cybercriminal
discovering a user's private key during transmission.
3
Computer and Network Security [3350704] Notes Unit 3

The two participants in the asymmetric encryption workflow are the sender and
the receiver. Each has its own pair of public and private keys. First, the sender
obtains the receiver's public key. Next, the plaintext message is encrypted by
the sender using the receiver's public key. This creates cipher text. The cipher
text is sent to the receiver, who decrypts it with their private key, returning it to
legible plaintext.

Because of the one-way nature of the encryption function, one sender is unable
to read the messages of another sender, even though each has the public key of
the receiver.

3. List out limitations of symmetric encryption


• Symmetric cryptosystems have a problem of key transportation.
• The secret key is to be transmitted to the receiving system before the actual
message is to be transmitted.
• Every means of electronic communication is insecure as it is impossible to
guarantee that no one will be able to tap communication channels. So the
only secure way of exchanging keys would be exchanging them personally.
• Cannot provide digital signatures.

4
Computer and Network Security [3350704] Notes Unit 3

4. Difference between symmetric and asymmetric encryption


Characteristics Symmetric Key Asymmetric Key
Key used for Same key is used One key is used for
encryption and for encryption and encryption and
decryption decryption another, different
key is used for
decryption
Speed of Very fast Slower
encryption/
decryption
Size of resulting Usually same as or More than the
encrypted text less than the original clear text
original clear text size
size
Key agreement or A big problem No problem at all
exchange
Number of keys Scalability is an Keys are same as
required as issue because keys the number of
compared to the are equal to square participants, so
number of of the number of scales up quite
participants in the participants well
message exchange
Usage Mainly for Can be used for
encryption and encryption and
decryption decryption as well
as digital signature
5. Explain Caesar cipher with example
A B C D E F G
0 1 2 3 4 5 6

H I J K L M N
7 8 9 10 11 12 13

O P Q R S T U
14 15 16 17 18 19 20

V W X Y Z
21 22 23 24 25

5
Computer and Network Security [3350704] Notes Unit 3

The Caesar Cipher technique is one of the earliest and simplest method of
encryption technique. It’s simply a type of substitution cipher, i.e., each
letter of a given text is replaced by a letter some fixed number of positions
down the alphabet. For example with a shift of 1, A would be replaced by B,
B would become C, and so on.

Thus to cipher a given text we need an integer value, known as shift which
indicates the number of position each letter of the text has been moved down.
The encryption can be represented using modular arithmetic by first
transforming the letters into numbers, according to the scheme, A = 0, B = 1…
Z = 25. Encryption of a letter by a shift n/Key K can be described
mathematically as:
For Encryption CT = (PT + K) mod 26
For Decryption PT = (CT – K) mod 26

A Caesar cipher involves replacing each letter in the message by a letter that
is some fixed number (here 3) of positions further along in the alphabet.
Working:
1. Convert the plain text into the number that matches its order in the
alphabets starting from 0. (A = 0,B = 1.., Z = 25)
2. Calculate : CT = (PT + K) mod 26
3. Covert CT

Plain Text : ABCDEFGHIJKLMNOPQRSTUVWXYZ


Key: 3
Cipher Text: DEFGHIJKLMNOPQRSTUVWXYZABC

P A T T A C K A T O N C E
T
K 3
E
Y
C D W W D F N D W R Q F H
T

Example: Plain Text: ATTACK AT ONCE


Shift/ Key: 3
Cipher Text: DWWDFNDWRQFH

6
Computer and Network Security [3350704] Notes Unit 3

Question: Convert the PT = ATTACK IS HAPPENING into cipher text using


Caesar cipher.
Caesar cipher decryption:
Working:
1. Convert the cipher text into the number that matches its order in the
alphabets starting from 0. (A = 0,B = 1.., Z = 25)
2. Calculate : PT = (CT - K) mod 26
3. Covert PT

Example: Cipher Text: DWWDFNDWRQFH


Shift/ Key: 3
Plain Text: ATTACK AT ONCE

6. Explain playfair cipher with example


One of the way to improve security is to encrypt two letters of plain text at a
time.
Playfair cipher provides this advantage.
Playfair cipher uses a 5x5 matrix (25 cells, 5 row and 5 column) for the
encryption and decryption process.
The Keyword is placed in the matrix cells.

Rules for creating the matrix:


1. Place the letters of the keyword in the matrix from left to right
A-Z = 26 alphabets
2. Do not enter the duplicate letters in the matrix which are repeated in keyword
3. The letters I and J are always placed in the same cell because we have only 25
cells and there are 26 alphabets so we need to combine two letters.
4. Fill the remaining empty cells with the remaining alphabets from A to Z

PT = COMPUTERS
Keyword = SECURITY

7
Computer and Network Security [3350704] Notes Unit 3

S E C U R
I/J T Y

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

Rules for encryption:


1. Each letter is replaced by the letter in the same row and in the column of the
other letter of the pair
2. Pair cannot be made with same letter. Break the letter in single and add a bogus
letter (X or Z) to the previous letter.
3. If the letter is standing alone in the process of pairing, then add an extra bogus
letter (X or Z) with the alone letter
4. If both the letters are in the same column: Take the letter below each one
(going back to the top if at the bottom).
5. If both the letters are in the same row: Take the letter to the right of each one
(going back to the leftmost if at the rightmost position).
6. 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.
7. If a pair is a repeated letter, insert filler like 'X’ between two repeating letters.

Plain text pairs to be encrypted:

1. CO
2. MP
3. UT
4. ER
5. SX

8
Computer and Network Security [3350704] Notes Unit 3

1. PT = CO
S E C U R
I/J T Y A B
D F G H K
L M N O P
Q V W X Z
As C and O are in different row and columns, according to rule when the
characters of PT pairs are in different row and columns, the cipher text will be
the character in the same row of the first character and same column of the
second character of the pair so we have,
CT = UN for PT = CO

2. PT = MP
S E C U R
I/J T Y A B
D F G H K
L M N O P
Q V W X Z
As the characters M and P are in same row, according to the rule take the letter
to the right of each one (going back to the leftmost if at the rightmost position)
as its cipher text.
CT = NL for PT = MP

3. PT = UT
S E C U R
I/J T Y A B
D F G H K
L M N O P
Q V W X Z
As U and T are in different row and columns, according to rule when the
characters of PT pairs are in different row and columns, the cipher text will be
the character in the same row of the first character and same column of the
second character of the pair so we have,
CT = EA for PT = EA

9
Computer and Network Security [3350704] Notes Unit 3

4. PT = ER
S E C U R
I/J T Y A B
D F G H K
L M N O P
Q V W X Z
As the characters E and R are in same row, according to the rule take the letter
to the right of each one (going back to the leftmost if at the rightmost position)
as its cipher text.
CT = CS for PT = ER

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

As S and X are in different row and columns, according to rule when the
characters of PT pairs are in different row and columns, the cipher text will be
the character in the same row of the first character and same column of the
second character of the pair so we have,
CT = UQ for PT = SX
So for PT = COMPUTERS, CT is UNNLEACSU

The Playfair Cipher Decryption Algorithm:


The algorithm consists of 2 steps:

Generate the key matrix (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.

10
Computer and Network Security [3350704] Notes Unit 3

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 cipher text: The cipher text is split into pairs of two
letters

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.

Cipher text pairs to be decrypted:

• UN
• NL
• EA
• CS
• UQ
1. CT = UN
S E C U R
I/J T Y A B
D F G H K
L M N O P
Q V W X Z
As U and N are in different row and columns, according to rule when the
characters of CT pairs are in different row and columns, the plain text will be
the character in the same row of the first character and same column of the
second character of the pair so we have,
CT = UN and PT = CO

11
Computer and Network Security [3350704] Notes Unit 3

2. CT = NL
S E C U R
I/J T Y A B
D F G H K
L M N O P
Q V W X Z
As the characters N and L are in same row, according to the rule take the letter
to the right of each one (going back to the leftmost if at the rightmost position)
as its cipher text.
CT = NL and PT = MP

3. CT = EA
S E C U R
I/J T Y A B
D F G H K
L M N O P
Q V W X Z
As E and A are in different row and columns, according to rule when the
characters of PT pairs are in different row and columns, the cipher text will be
the character in the same row of the first character and same column of the
second character of the pair so we have,
CT = EA and PT = UT

4. CT = CS
S E C U R
I/J T Y A B
D F G H K
L M N O P
Q V W X Z
As the characters C and S are in same row, according to the rule take the letter
to the right of each one (going back to the leftmost if at the rightmost position)
as its cipher text.
CT = CS and PT = ER

12
Computer and Network Security [3350704] Notes Unit 3

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

As U and Q are in different row and columns, according to rule when the
characters of CT pairs are in different row and columns, the cipher text will be
the character in the same row of the first character and same column of the
second character of the pair so we have,
CT = UQ and PT = SX

So for CT = UNNLEACSUQ, PT is COMPUTERS

7. Explain hill cipher with example


Hill cipher is a polygraphic substitution cipher based on linear algebra.
Each letter is represented by a number modulo 26.

Often the simple scheme A = 0, B = 1, …, Z = 25 is used, but this is not an


essential feature of the cipher.

To encrypt a message, each block of n letters (considered as an n-component


vector) is multiplied by an invertible n × n matrix, against modulus 26.

To decrypt the message, each block is multiplied by the inverse of the matrix
used for encryption.

The matrix used for encryption is the cipher key, and it should be chosen
randomly from the set of invertible n × n matrices (modulo 26).
Example:
Plaintext = hi
Key = beat
CT = K . PT mod 26

13
Computer and Network Security [3350704] Notes Unit 3

Step 1:

CT = mod 26
Step 2:

CT = mod 26

Step 3:

CT = mod 26

Step 4:

CT = mod 26
Step 5:

CT = mod 26

14
Computer and Network Security [3350704] Notes Unit 3

Step 6:

CT =

Step 7:

CT =
Step 8:

CT =
So for PT = HI, cipher text CT = NW

8. Explain vernam cipher with example


Vernam Cipher is a method of encrypting alphabetic text. It is one of the
Substitution techniques for converting plain text into cipher text. In this
mechanism we assign a number to each character of the Plain-Text, like (a = 0,
b = 1, c = 2, … z = 25).
Method to take key/ OTP: In the Vernam cipher algorithm, we take a key to
encrypt the plain text whose length should be equal to the length of the plain
text.
Encryption Algorithm:
Treat each plaintext character as a number in an increasing sequence from a =
0, b= 1 … z = 25.
Do the same for each character of the input cipher text/ OTP.
Add each number corresponding to the plain text character to the
corresponding input cipher text character number.

15
Computer and Network Security [3350704] Notes Unit 3

If the produced cipher text is greater than 25; then subtract 26 from it.
Convert each number of the cipher text into corresponding alphabet character.

PT= C O M P U T E R
2 14 12 15 20 19 4 17
OTP= S E C U R I T Y
18 4 2 20 17 8 19 24
+
CT= 20 18 14 35 37 27 23 41

PT= C O M P U T E R
2 14 12 15 20 19 4 17
OTP= S E C U R I T Y
18 4 2 20 17 8 19 24
+
CT= 20 18 14 35 37 27 23 41
- 26 - 26 -26 -26
=9 = 11 =1 15
CT = U S O J L B X P

Decryption Algorithm:
Treat each cipher text character as a number in an increasing sequence from a
= 0, b= 1 … z = 25.
Do the same for each character of the input cipher text/ OTP.
Subtract each number corresponding to the cipher text character to the
corresponding OTP character number.

16
Computer and Network Security [3350704] Notes Unit 3

If the produced cipher text is greater than 25; then subtract 26 from it.
Convert each number of the plain text into corresponding alphabet character.

CT= U S O J L B X P
20 18 14 9 11 1 23 15
OTP= S E C U R I T Y
18 4 2 20 17 8 19 24
-
PT= 2 14 12 -11 -6 -7 4 -9

CT= U S O J L B X P
20 18 14 9 11 1 23 15
OTP= S E C U R I T Y
18 4 2 20 17 8 19 24
-
PT= 2 14 12 -11+26 -6+26 -7+26 4 -9+26
=15 =20 =19 =17
PT = C O M P U T E R

9. Explain rail fence cipher with example


Given a plain-text message and a numeric key, cipher/de-cipher the given text
using Rail Fence algorithm.
The rail fence cipher (also called a zigzag cipher) is a form of transposition
cipher. It derives its name from the way in which it is encoded.

17
Computer and Network Security [3350704] Notes Unit 3

Encryption
In a transposition cipher, the order of the alphabets is re-arranged to obtain the
cipher-text.

• In the rail fence cipher, the plain-text is written downwards and


diagonally on successive rails of an imaginary fence.
• When we reach the bottom rail, we traverse upwards moving diagonally,
after reaching the top rail, the direction is changed again. Thus the
alphabets of the message are written in a zig-zag manner.
• After each alphabet has been written, the individual rows are combined
to obtain the cipher-text.
Example:
Plain text = Secret message
Key = 4
Key = Number of rows

S M E
E T E G
C E S A
R S

Cipher text = SMEETEGCESARS

10.Write short note on steganography


• Steganography is the art of concealing/embedding a file, message, image, or
video within another file, message, image, or video.
• The word steganography comes from Greek steganographia, which combines
the words steganós, meaning "covered or concealed", and -graphia meaning
"writing".
• The first recorded use of the term was in 1499 by Johannes Trithemius in his
Steganographia, a treatise (paper work or essay) on cryptography and
steganography, disguised as a book on magic.

18
Computer and Network Security [3350704] Notes Unit 3

• Generally, the hidden messages appear to be something else: images, articles,


shopping lists, or some other cover text.

• For example, the hidden message may be in invisible ink between the visible
lines of a private letter.
• The advantage of steganography over cryptography alone is that the intended
secret message does not attract attention to itself as an object of
scrutiny/scanning.
• Whereas cryptography is the practice of protecting the contents of a message
alone, steganography is concerned both with concealing the fact that a secret
message is being sent and its contents.
• For example, the hidden message may be in invisible ink between the visible
lines of a private letter.
• The advantage of steganography over cryptography alone is that the intended
secret message does not attract attention to itself as an object of
scrutiny/scanning.
• Whereas cryptography is the practice of protecting the contents of a message
alone, steganography is concerned both with concealing the fact that a secret
message is being sent and its contents.

Steganography techniques:
1. Character Marking: Selected letters are overwritten in pencil. The marks are
ordinarily not visible unless the paper is held at an angle to bright light. ...
2. Invisible Ink: A number of substances can be used for writing but secure trace
until some other chemical is applied to the paper.

19
Computer and Network Security [3350704] Notes Unit 3

3. Pin Punctures: Small pin punctures on the pictures are ordinarily not visible
unless the paper is held up in front of a light.
4. Typewriter correction ribbon: Used between lines typed with a black ribbon,
the results of typing with the correction tape are visible only under a strong
light.

Advantages:

• It is used for hiding the password to reach to the receiver and not the actual
information.
• Messages do not attract attention to themselves; so it is difficult to detect that
the file is using steganography
• It can be applied differently in digital images, audio and video file.

Disadvantages/ Drawbacks compared to Encryption:

• It requires a lot of overhead to hide a relatively few bits of information.


• Once the system is discovered it becomes totally useless.

20

You might also like