Professional Documents
Culture Documents
Css Exp 4 PDF
Css Exp 4 PDF
Experiment No 4
Theory:
Introduction:
Diffie-Hellman key exchange is a method of digital encryption that securely exchanges
cryptographic keys between two parties over a public channel without their conversation being
transmitted over the internet. The two parties use symmetric cryptography to encrypt and decrypt
their messages. Published in 1976 by Whitfield Diffie and Martin Hellman, it was one of the first
practical examples of public key cryptography.
Diffie-Hellman key exchange raises numbers to a selected power to produce decryption keys.
The components of the keys are never directly transmitted, making the task of a would-be code
breaker mathematically overwhelming. The method doesn't share information during the key
exchange. The two parties have no prior knowledge of each other, but the two parties create a
key together.
Diffie-Hellman key exchange is commonly found in security protocols, such as Transport Layer
Security (TLS), Secure Shell (SSH) and IP Security (IPsec). For example, in IPsec, the
encryption method is used for key generation and key rotation.
Even though Diffie-Hellman key exchange can be used for establishing both public and private
keys, the Rivest-Shamir-Adleman algorithm, or RSA algorithm, can also be used, since it's able
to sign public key certificates.
Vidya Vikas Education Trust’s
Universal College of Engineering, Kaman Road, Vasai-401208
Accredited by B+ Grade by NAAC
Algorithm:
R=q^a mod p
S=q^b mod p
Rk = S^a mod p
Sk = R^b mod p
Program:
if __name__ == '__main__':
P = 23
G=9
a=4
x = int(pow(G,a,P))
b=3
y = int(pow(G,b,P))
ka = int(pow(y,a,P))
kb = int(pow(x,b,P))
Output:
Conclusion:
Hence we have successfully implemented the Diffie Hellman Key Exchange algorithm.