Hello Bharath
Specifically the Diffie-Hellman key exchange method allows two parties that have no prior knowledge of each other to jointly establish a shared secret key over an insecure channel. This key can then be used to encrypt subsequent communications using a symmetric key cipher.
The following elements are used for the DH process:
- The communicating devices agree in the open on a specific key (you can call it the public key) that they will initially use to start the DH process. This can be known to anyone.
- Both parties randomly choose a secret key (you can call this a private key) which will obviously be different from each other.
- Each party computes a value with the public and private key using an agreed upon algorithm. The result (let’s call it an intermediate value) is then sent to the other party, again openly.
* The important thing here is that it is extremely difficult to obtain the public and private key just by obtaining the intermediate value. - So, both parties now have
* the public key (which is the same for both)
* the private key (which is different for each party)
* the intermediate value received from the other party
* the intermediate value computed by itself
- Using these values, party A computes a value (the shared secret key) using
* the intermediate value received from the other party
* its own private key - The result, which is the shared secret key, should be the same for both devices.
An excellent explanation using colours can be found at this link which should clarify any questions you may have.
I hope this has been helpful!
Laz