Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Aim: To Implement Diffiehellman Key Exchange Protocol. Theory: Diffiehellman Key Exchange Is A Cryptographic Protocol That Allows Two

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Lab 2

Aim: To implement DiffieHellman key exchange protocol.


Theory: DiffieHellman key exchange is a cryptographic protocol that allows two
parties that have no prior knowledge of each other to jointly establish a shared
secret key over an insecure communications channel. This key can then be used to
encrypt subsequent communications using a symmetric keycipher.
The simplest, and original, implementation of the protocol uses the Multiplicative
group of integers modulo p, where p is prime and g is primitive root mod p. Here is
an example of the protocol:
1. Alice and Bob agree to use a prime number p=23 and base g=5.
2. Alice chooses a secret integer Xa=6, then sends Bob
(g^XA) mod p o 56 mod 23 = 8.
3. BobXBchooses a secret
integer Xb=15, then sends Alice
(g^ ) mod p. o 515 mod 23 = 19.
4.
5.

Alice computes YA = (g^XA) mod p


6
o 19 mod 23 = 2.
Bob computes YB = (g^XB) mod p.

815 mod 23 = 2.

In the original description, the DiffieHellman exchange by itself does not provide
authentication of the communicating parties and is thus vulnerable to a maninthemiddle
attack. A person in the middle may establish two distinct DiffieHellman key exchanges, one
with Alice and the other with Bob, effectively masquerading as Alice to Bob, and vice versa,
allowing the attacker to decrypt (and read or store) then reencrypt the messages passed
between them. A method to authenticate the communicating parties to each other is
generally needed to prevent this type of attack.

Algorithm:
Alice and Bob, two users who wish to establish secure communications. We can
assume that Alice and Bob know nothing about each other but are in contact.
1. Communicating in the clear, Alice and Bob agree on two large positive
integers, p and g, where p is a prime number and g is a primitive root mod p.
2. Alice randomly chooses another large positive integer, XA, which is smaller
than p. XA will serve as Alice's private key.
3. Bob similarly chooses his own private key, XB.
4. Alice computes her public key, YA, using the formula YA = (g^XA) mod p.
5. Bob similarly computes his public key, YB, using the formula YB = (g^XB) mod p.
6. Alice and Bob exchange public keys over the insecure circuit.
7. Alice computes the shared secret key, k, using the formula k = (YB ^XA) mod p.
8. Bob computes the same shared secret key, k, using the formula k = (YA ^

XB

) mod p.

9. Alice and Bob communicate using the symmetric algorithm of their choice and
the shared secret key, k, which was never transmitted over the insecure circuit.

Conclusion: DiffieHellman is a mathematical algorithm that allows two computers


to generate an identical shared secret on both systems, even though those
systems may never have communicated with each other before. That shared secret
can then be used to securely exchange a cryptographic encryption key. That key
then encrypts traffic between the two systems.

You might also like