Aim: To Implement Diffiehellman Key Exchange Protocol. Theory: Diffiehellman Key Exchange Is A Cryptographic Protocol That Allows Two
Aim: To Implement Diffiehellman Key Exchange Protocol. Theory: Diffiehellman Key Exchange Is A Cryptographic Protocol That Allows Two
Aim: To Implement Diffiehellman Key Exchange Protocol. Theory: Diffiehellman Key Exchange Is A Cryptographic Protocol That Allows Two
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.