NSM Notes - Unit 2
NSM Notes - Unit 2
UNIT-2
CRYPTOGRAPHY IN NETWORK
2.1 INTRODUCTION TO SYMMETRIC ENCRYPTION & ASYMMETRIC ENCRYPTION
2.1.1 Symmetric Encryption
Symmetric Encryption is a type of encryption where only one key (a secret key) is used to encrypt and decrypt
electronic data. The entities communicating via symmetric encryption must exchange the key so that it can be
used in the decryption process.
By using symmetric encryption algorithms, data is "scrambled" so that it can't be understood by anyone who
does not possess the secret key to decrypt it. Once the intended recipient who possesses the key has the
message, the algorithm reverses its action so that the message is returned to its original readable form. The
secret key that the sender and recipient both use could be a specific password/code or it can be a random string
of letters or numbers that have been generated by a secure Random Number Generator (RNG).
Advantages:
1) Enhanced Security: Asymmetric encryption provides a higher level of security compared to symmetric
encryption where only one key is used for both encryption and decryption with asymmetric encryption a
different key is used for each process and the private key is used for decryption is kept secret by the
receiver making, it harder for an attacker to intercept and decrypt the data.
2) Authentication: Asymmetric encryption can be used for authentication purposes which means that the
receiver can verify the sender’s identity.
3) Non-repudiation: Asymmetric encryption also provides non-repudiation which means that the sender
cannot deny sending a message or altering its contents this is because the message is encrypted with the
sender’s private key and only their public key can decrypt it. Therefore, the receiver can be sure that the
message was sent by the sender and has not been tampered with.
4) Key Distribution: Asymmetric encryption eliminates the need for a secure key distribution system that
is required in symmetric encryption with symmetric encryption, the same key is used for both encryption
and decryption and the key needs to be securely shared between the sender and the receiver asymmetric
NETWORK SECURITY & MANAGEMENT
encryption, on the other hand, allows the public key to be shared openly and the private key is kept secret
by the receiver.
5) Versatility: Asymmetric encryption can be used for a wide range of applications including secure email
communication online banking transactions and e-commerce it is also used to secure SSL/TSL
connections which are commonly used to secure internet traffic.
It uses a single shared key (secret key) to It uses two different keys for encryption
Keys used
encrypt and decrypt the message. and decryption.
The size of ciphertext in symmetric The size of ciphertext in asymmetric
Size encryption could be the same or smaller encryption could be the same or larger than
than the plain text. the plain 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
EXAMPLE:
Plain Text: SECURITY, Key: 3
ENCRYPTION:
Encryption
Plain Text Cipher Text
CT = (PT+3) Mod 26
S (18) (18 + 3) mod 26 = 21 mod 26 = 21 V
E (04) (04 + 3) mod 26 = 07 mod 26 = 07 H
C (02) (02 + 3) mod 26 = 05 mod 26 = 05 F
U (20) (20 + 3) mod 26 = 23 mod 26 = 23 X
R (17) (17 + 3) mod 26 = 20 mod 26 = 20 U
I (08) (08 + 3) mod 26 = 11 mod 26 = 11 L
T (19) (19 + 3) mod 26 = 22 mod 26 = 22 W
Y (24) (24 + 3) mod 26 = 27 mod 26 = 01 B
Cipher Text: VHFXULWB
DECRYPTION:
Decryption
Cipher Text Plain Text
PT = (CT-3) Mod 26
V (21) (21 - 3) mod 26 = 18 mod 26 = 18 S
H (07) (07 - 3) mod 26 = 04 mod 26 = 04 E
F (05) (05 - 3) mod 26 = 02 mod 26 = 02 C
X (23) (23 - 3) mod 26 = 20 mod 26 = 20 U
U (20) (20 - 3) mod 26 = 17 mod 26 = 17 R
L (11) (11 - 3) mod 26 = 08 mod 26 = 08 I
W (22) (22 - 3) mod 26 = 19 mod 26 = 19 T
B (01) (01 - 3) mod 26 = 24 mod 26 = 24 Y
Plain Text: SECURITY
Features:
1) Ease of Implementation
2) Speed
3) Symmetric Encryption
4) Weak Security
5) Limited Applicability
EXAMPLE:
1) Plain Text: COMPUTER, Key: NETWORK
N E T W O
R K A B C
D F G H I/J
L M P Q S
U V X Y Z
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
NETWORK SECURITY & MANAGEMENT
Features:
1) Digraphic Substitution
2) Polygraphic Nature
3) Key-Based Encryption
4) Key Table
5) Handling of Odd Letters
6) Letter Pairs
7) Handling Repeated Letters
8) Security
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
EXAMPLE:
1)Plain Text: HELLO
Key: 6
ENCRYPTION:
Encryption
Plain Text Cipher Text
CT = (PT+3) Mod 26
H (07) (07 + 06) mod 26 = 13 mod 26 = 13 N
E (04) (04 + 06) mod 26 = 10 mod 26 = 10 K
L (11) (11 + 06) mod 26 = 17 mod 26 = 17 R
L (11) (11 + 06) mod 26 = 17 mod 26 = 17 R
O (14) (14 + 06) mod 26 = 20 mod 26 = 20 U
Cipher Text: NKRRU
DECRYPTION:
Decryption
Cipher Text Plain Text
PT = (CT-3) Mod 26
N (13) (13 - 06) mod 26 = 07 mod 26 = 07 H
K (10) (10 - 06) mod 26 = 04 mod 26 = 04 E
R (17) (17 - 06) mod 26 = 11 mod 26 = 11 L
R (17) (17 - 06) mod 26 = 11 mod 26 = 11 L
U (20) (20 - 06) mod 26 = 14 mod 26 = 14 O
Plain Text: HELLO
NETWORK SECURITY & MANAGEMENT
ENCRYPTION:
Encryption
Plain Text Cipher Text
CT = (PT+3) Mod 26
L (11) (11 + 15) mod 26 = 26 mod 26 = 00 A
A (0) (00 + 15) mod 26 = 15 mod 26 = 15 P
Y (24) (24 + 15) mod 26 = 39 mod 26 = 13 N
O (14) (14 + 15) mod 26 = 29 mod 26 = 03 C
U (20) (20 + 15) mod 26 = 35 mod 26 = 09 J
T (19) (19 + 15) mod 26 = 34 mod 26 = 08 I
Cipher Text: APNCJI
DECRYPTION:
Decryption
Cipher Text Plain Text
PT = (CT-3) Mod 26
A (0) (00 - 15) mod 26 = 18 mod 26 = 11 L
P (15) (15 - 15) mod 26 = 04 mod 26 = 00 A
N (13) (13 - 15) mod 26 = 02 mod 26 = 24 Y
C (03) (03 - 15) mod 26 = 20 mod 26 = 14 O
J (09) (09 - 15) mod 26 = 17 mod 26 = 20 U
I (08) (08 - 15) mod 26 = 08 mod 26 = 19 T
Plain Text: LAYOUT
Method 1:
When the Vigenere table is given, the encryption and decryption are done using the Vigenere table (26 * 26
matrix) in this method.
For generating the key, the given keyword is repeated circularly until it matches the length of
the plain text.
EXAMPLE: The plaintext is "CYBERSECURITY", and the key is "BEST".
C Y B E R S E C U R I T Y
B E S T B E S T B E S T B
ENCRYPTION:
The first letter of the plaintext is combined with the first letter of the key. The column of plain text "C" and
the row of key "B" intersects the alphabet of "D" in the Vigenere table, so the first letter of ciphertext is "D".
NETWORK SECURITY & MANAGEMENT
Similarly, the second letter of the plaintext is combined with the second letter of the key. The column of plain
text "Y" and the row of key "E" intersect the alphabet of "C" in the Vigenere table, so the second letter of
ciphertext is "C".
This process continues continuously until the plaintext is finished.
Ciphertext = D C T X S W W V V V A M Z
DECRYPTION:
Decryption is done by the row of keys in the Vigenere table. First, select the row of the key letter, find the
ciphertext letter's position in that row, and then select the column label of the corresponding ciphertext as the
plaintext.
D C T X S W W V V V A M Z
B E S T B E S T B E S T B
For example, in the row of the key is "B" and the ciphertext is "D" and this ciphertext letter appears in the
column "C", which means the first plaintext letter is "C".
Next, in the row of the key is "E" and the ciphertext is "C" and this ciphertext letter appears in the column
"Y", which means the second plaintext letter is "Y".
This process continues continuously until the ciphertext is finished.
Plaintext = CYBER SECURITY
Method 2:
When the Vigenere table is not given, the encryption and decryption are done by the algebraic formula in this
method (convert the letters (A-Z) into the numbers (0-25)).
*If any case (Di) value becomes negative (-ve), in this case, we will add 26 to the negative value.
Where,
E denotes the encryption, D denotes the decryption, P denotes the plaintext, K denotes the key.
Note: "i" denotes the offset of the ith number of the letters, as shown in the table below.
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
NETWORK SECURITY & MANAGEMENT
EXAMPLE:
Plaintext: CYBER SECURITY
Key: BEST
ENCRYPTION:
Ei = (Pi + Ki) mod 26
Plaintext C Y B E R S E C U R I T Y
Key B E S T B E S T B E S T B
Ciphertext D C T X S W W V V V A M Z
Cipher Text: D C T X S W W V V V A M Z
DECRYPTION:
Di = (Ei - Ki) mod 26
If any case (Di) value becomes negative (-ve), in this case, we will add 26 to the negative value.
Like, the second letter of the ciphertext;
C = 02 and E = 04
D1 = (02 - 04) mod 26 = -2 mod 26 = (-2 + 26) mod 26 = 24 mod 26 = 24
Ciphertext D C T X S W W V V V A M Z
Key B E S T B E S T B E S T B
Plaintext C Y B E R S E C U R I T Y
ENCRYPTION:
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 Key/ OTP. Add each number corresponding to the plain text character to the
corresponding character of the key. If the produced cipher text is greater than 25; then subtract 26 from it.
Convert each number of the cipher text into corresponding alphabet characters.
EXAMPLE:
Plaintext: COMPUTER
Key: SECURITY
Plain C O M P U T E R
Text (02) (14) (12) (15) (20) (19) (04) (17)
Key/ S E C U R I T Y
OTP (18) (04) (02) (20) (17) (08) (19) (24)
PT + 35 37 27 41
20 18 14 23
Key 35-26=09 37-26=11 27-26=01 41-26=15
Cipher U S O J L B X P
Text (20) (18) (14) (09) (11) (01) (23) (15)
Cipher Text: USOJLBXP
DECRYPTION:
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 key/ OTP. Subtract each number corresponding to the cipher text character to
the corresponding key character number. If the produced cipher text is a negative number; then add 26 to it.
Convert each number of the plain text into the corresponding alphabet character.
NETWORK SECURITY & MANAGEMENT
Cipher U S O J L B X P
Text (20) (18) (14) (09) (11) (01) (23) (15)
Key/ S E C U R I T Y
OTP (18) (04) (02) (20) (17) (08) (19) (24)
-11 -06 -07 -09
CT - Key 02 14 12 -11+26 -06+26 -07+26 04 -09+26
= 15 = 20 =19 =17
Plain
C O M P U T E R
Text
Plain Text: COMPUTER
ENCRYPTION:
To encrypt the text using a hill cipher, we need to perform the following operation.
E (K, P) = (K * P) mod 26
Where K is the key matrix and P is plain text in vector form. Matrix multiplication of K and P generates the
encrypted ciphertext.
Step 1: Convert the key using a substitution scheme into a n * n key matrix.
Step 2: Now, we will convert our plain text into vector form. Since the key matrix is n * n, the vector must be
n * 1 for matrix multiplication. (Suppose the key matrix is 2x2, a vector will be a 2x1 matrix.)
Step 3: Multiply the key matrix with each n * 1 plain text vector, and take the modulo of the result by 26.
DECRYPTION:
To encrypt the text using a hill cipher, we need to perform the following operation.
D (K, C) = (K-1 * C) mod 26
Where K is the key matrix and C is the ciphertext in vector form. Matrix multiplication of the inverse of key
matrix K and ciphertext C generates the decrypted plain text.
NETWORK SECURITY & MANAGEMENT
Step 1: Calculate the inverse of the key matrix. First, we need to find the determinant of the key matrix (must
be between 0-25). Here the Extended Euclidean algorithm is used to get the modulo multiplicative inverse of
the key matrix determinant
Step 2: Now, we multiply the n * 1 blocks of ciphertext and the inverse of the key matrix. The resultant block
after concatenation is the plain text that we have encrypted.
EXAMPLE:
1) Plain Text: HI
Key: BEAT
Solution (Encryption):
Convert key into 2*2 matrix and then convert it into numeric form (A = 0, B = 1 ……. Z = 25)
𝐵 𝐸 1 4
[ ]=[ ]
𝐴 𝑇 0 19
𝐻 7
Convert plain text into a 2*1 matrix and then convert it into numeric form. P = [ ] = [ ]
𝐼 8
E = KP mod 26
1 4 7
=[ ] [ ] mod 26
0 19 8
1∗7+4∗8
=[ ] mod 26
0 ∗ 7 + 19 ∗ 8
7 + 32
=[ ] mod 26
0 + 152
39
=[ ] mod 26
152
13
=[ ]
22
𝑁
=[ ]
𝑊
Cipher Text = NW
𝑃 15
P2 = [ ] = [ ]
𝐻 7
𝐸 4
P3 = [ ] = [ ]
𝑅 17
E = E1 + E2 + E3
= K P1 mod 26 + K P2 mod 26 + K P3 mod 26
7 8 2 7 8 15 7 8 4
=[ ] [ ] mod 26 + [ ] [ ] mod 26 + [ ] [ ] mod 26
11 11 8 11 11 7 11 11 17
78 161 164
=[ ] mod 26 + [ ] mod 26 + [ ] mod 26
110 242 231
0 5 8
=[ ]+[ ]+[ ]
6 8 23
𝐴 𝐹 𝐼
=[ ]+[ ]+[ ]
𝐺 𝐼 𝑋
Cipher Text = AGFIIX
Features:
1) Matrix-Based Encryption
2) Key Matrix
3) Modular Arithmetic
4) Block Processing
5) Key Generation
6) Padding
ENCRYPTION:
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.
For example, if the message is THIS IS SECRET MESSAGE” and the number of rails (key) = 3 then the
cipher is prepared as:
T I C M A
H S S E R T E S G
I S E S E
Its encryption will be done row-wise. Therefore, the cipher text will be: TICMAHSSERTESGISESE
DECRYPTION:
Let cipher-text = “TICMAHSSERTESGISESE”, and Key = 3
Number of columns in matrix = length of cipher-text = 13
Number of rows = key = 3
Hence original matrix will be of 3*19, now marking places with text as ‘*’ or any other symbol ( - ).
The decryption process for the Rail Fence Cipher involves reconstructing the diagonal grid used to encrypt
the message. We start writing the message, but leaving a dash in place of the spaces yet to be occupied.
Gradually, you can replace all the dashes with the corresponding letters and read off the plaintext from the
table.
We start by making a grid with as many rows as the key is and as many columns as the length of the ciphertext.
We then place the first letter in the top left square and dash diagonally downwards where the letters will be.
When we get back to the top row, we place the next letter in the ciphertext. Continue like this across the row,
and start the next row when you reach the end
Here the ciphertext received is " TICMAHSSERTESGISESE ", encrypted with a key of 3, you start by placing
the "T" in the first square. You then dash the diagonal down spaces until you get back to the top row and place
the "I" here.
- - - - -
- - - - - - - - -
- - - - -
NETWORK SECURITY & MANAGEMENT
T I C M A
- - - - - - - - -
- - - - -
T I C M A
H S S E R T E S G
I S E S E
To be the most effective, the digital signature must be part of the application data so that it is generated at the
time the message is created.
Then, the signature is verified at the time the message is received and processed.
You can choose to sign the entire message or sign parts of the message (even overlapping parts of a message
can be signed).
You can choose to sign only parts of a message if a part of the message must be modified before it reaches the
consumer.
In this scenario, if the entire message was signed, the whole signature is invalidated if even one part of the
message is modified.
NETWORK SECURITY & MANAGEMENT
A digital signature for an electronic message is created by using a form of cryptography and is equivalent to a
personal signature on a written document. A digital certificate owner combines the data to be signed with their
private key and then transforms the data with an algorithm. The recipient of the message uses the
corresponding certificate public key to decrypt the signature. The public key decryption also verifies the
integrity of the signed message and verifies the sender as the source. Only the organization with the private
key can create the digital signature. However, anyone who has access to the corresponding public key can
verify the digital signature.
When a content creator digitally signs a message, the signature must meet the following criteria to be
valid:
1) The certificate that is associated with the digital signature is current (not expired).
2) The certificate that is associated with the digital signature is issued to the signing publisher by a
reputable certificate authority (CA). The CA signs certificates that it issues. The signature consists of
a data string that is encrypted with the private key of the CA. Any user can then verify the signature
on the certificate by using the CA public key to decrypt the signature.
3) The publisher (the signing organization), is trusted.
NETWORK SECURITY & MANAGEMENT