Unit 3-Solution
Unit 3-Solution
Unit 3-Solution
POLYTECHNIC
L. J. Campus, Between Sarkhej-Sanand Circle & Kataria Motors,
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
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
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.
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.
4
Computer and Network Security [3350704] Notes Unit 3
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
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
6
Computer and Network Security [3350704] Notes Unit 3
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
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 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
• 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
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
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
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.
S M E
E T E G
C E S A
R S
18
Computer and Network Security [3350704] Notes Unit 3
• 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.
20