CNS Assignment 2 Ans PDF
CNS Assignment 2 Ans PDF
2.2
Cayptography &Network Securi
3 Public and Private Kevs :
Decryption Algorithm:
This algorithm accepts the cipher tevt and the
keys to produce the original plain text.
Encryption:
The essential steps are
Each user generates a pair of keys to be used for encryption and decryption of message
2 Each user places one of the two keys in a public register which is accessible to all. This
the public key. The other key is the private key.
B's B's
User
Public key l Private key
User
A
Plain CT
Text
Encryption Decryption ’PT
Algorithm Algorithm
Figure: 2.1
The above figure shows that each user maintains the public key of others, which is th
model for security.
3. Awants to transmit a confidential message to B, Aencrypt's the message with B's public ke
4. When B receives the message, decrypts the message with it's own private key.
The above method works well, when all the participants have access to public keys, an
private keys which is generated by itself and kept securely. Hence there is no need of key exchang
Encryption Decryption X
Message
Message algorithm algorithm
PU, PR,
Key
pair
The crypt analyst can act in between to determine the estimate of the key PR (or) the
estimate of the message &.
Crypt
A analyst >PR,
Message
SOurce
EA Y
DA
X Message
TDestination
PR, PU,
Key
Source
pair A Figure 2.4
The crypt analyst can act in between to determine the estimate of the key PR, (or) the
|MessageEA EA DA DAMessage
source Designaion
Key
SOurce
pair B
Key
sOurce
pair A
Figure 2.4
Z =E(PU, E(PR, X)
X = D(PU, DPR, Z)
In the above figure we can ensure security and authentication. The message is encrypted
using senders private key, providing digital signatures. Next the second encryption is done using
the receivers public key. Hence the final cipher text can be decrypted only by the intended
receiver who alone has the private key. Thus confidentiality is provided.
The Disadvantage of this method is that:
The sender signs the message with its private key. Signing is achieved by an algorithm
applied to the message or to the block of data.
3 Key Exchange:
The public key cryptography is used to exchange session key. The famous algorithms are
RSA, ECC, Diffie Hellman, DSS.
2.5 REQUIREMENT FOR PUBLIC KEY CRYPTOGRAPHY
It should be computationally easy for party B to generate a pair of key.
2 It should be computationally easy for sender A to generate the cipher text M, knowing the
public key of B.
C=E (PU,, M)
It should be computationally easy for the receiver to decrypt the message using the private
key to recover the original message.
M = D(PR, C)
= D[PR,, E (PU,, M))
4 It should be computationally infeasible to determine the private key given the public key.
5. It should be computationally infeasible to determine the plain text given the CT, public key.
6. The two keys can be applied in any order. In M =D [PU,, E (PR,, M)] = D [PR,, E (PU,, M)].
Crypt Analysis:
Attack Type 1:
Puon
C- E (PU, M)
3. It should be computationally easy for the receiver to decrypt the message using the private
key to recover the original message.
M = D(PR,, C)
- D[PR, E (PU,, M)]
4. It should be computationally infeasible to determine the private key given the public key.
5. It should be computationally infeasible to determine the plain text given the CT, public key.
6. The two keys can be applied in any order. In M=D[PU, E(PR,, M)] =D[PR,, E(PU,, M)].
Attack is of other types (i.e.) given the algorithm and the public key deduce private key.
This method has not been successful till date.
Atack Type 3:
Probable message attack.
When a confidential message is to be transmitted using DES, the attacker will find all 2%
possible keys using the public key and discover the encrypted key by matching the generated
cipher text and the actual cipher.
This attack can be avoided by appending some random bits to the message.
2.6 RSA
This is a block cipher, in which plain text and cipher text are integers between 0ton-1 for
some 'n'. Size of n can be 1024 bits. M< 21024,
Plain text is encrypted in blocks. The block has some binary value, less than some
numbern.
M = c mod n
- (m) mod n.
- me mod n.
Algorithm
This attack can be avoided by appending some random bits to the message.
2.6 RSA
A ’ Aldeman.
This is a block cipher, in which plain text and cipher text are integers between 0 to n-1 for
some 'n'. Size of n can be 1024 bits, M< 21024
Encryption is denoted by E.
Decryption is denoted by D.
M Cd mod n.
(m°) mod n.
= me mod n.
Both the sender and the receiver must know n.
Algorithm
(private, chosen)
p, q are the two prime numbers
(public, calculated)
n = p
(public, chosen)
e is chosen s.t. gcd( (n), e) = 1; 1<e<o (n)
(private calculated).
d=e'mod (n)
Step 1: Select two prime numbers.
Step 2: Calculate n = pg
SUMMARY:
Key Generation:
Select p, 4
calculate n =p X4
calculate d
Example:
1. p=17,q= 11
2. n =p x q= 17 x 1| = 187
(n) =(p-l)Xq-1)=16x10=160
4. Select e =7
C = m'mod n
= ((88 mod 187) x (88 mod 187) x (88' mod 187)] mod 187
(88 x 77 x 132) mod 187
Decryption:
m =c mod n
1|2 mod 187 =[(1|' mod 187) x (112 mod 187) x (11 mod 187)
Encryption:
C = m modn
C = 88 mnod 187
- [(88* mod 187) x(88² mod 187) x (88' mod187)] mod 187
= (88 x 77 x 132) mod 187
= ||
Decryption:
m =c mod n
m=1123 mod 187
1|P mod l87 = [(11' mod 187) x (I1' mod 187) x (11' mod 187)
(11 mod 187) (119 mod 187)] mod 187
= 88
" p:
Steps:
1. Calculate n:
on=p*q=7*11= 77
2. calculate (n):
o n) = (p-1) * (q-1) =6 *10 =60
4. Encryption:
oC= M^e mod n
oC=8^17 mod 77 = 45
5. Decryption:
M= C^d mod n
o M=45^23 mod 77 = 8
Conclusion:
github.com
github.com
,