Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

Let's say, I have a friend far from me and I want to send some secret messages to him. I have to say, I'm pretty newbie in security. That's why I'm wondering, does the Diffie–Hellman key exchange protocol allow me make a secure communication with him by sending a public key to him and them after all necessary computations, get a secret key (which will be the same for us both, of course) and use it for encrypting/decrypting the messages from and to each other? And our communication will be secure, correct?

share|improve this question
3  
As always the problem is how to exchange the public key without having a MitM replace it by their own public key. –  CodesInChaos Nov 7 '13 at 14:13
    
@CodesInChaos if we forget about MitM, everything else is ok, correct? –  Alex Nov 8 '13 at 3:25
add comment

1 Answer

up vote 4 down vote accepted

Diffie-Hellman allows two parties to generate a secret key which cannot be recovered by someone snooping on the communication. This secret key can be used to set up a secure channel between the two parties that ran the DH protocol.

The secret key is established between the two parties that exchanged the initial messages. If you send out one message and receive a response, you have no way to know that this message comes from your friend. It could come from a man-in-the-middle instead. A MitM can reply to your message and send a message to your friend, and thus set up one secret key to communicate with you and one to communicate with your friend. Form that point, both you and your friend have a secure channel with the MitM, who can choose to relay messages and snoop on them, or modify them, or withhold them, or inject messages as he wishes.

There is no way to set up a secure channel without authentication. If you want to be sure that you're communicating with your friend, then you need to know something about your friend before the protocol starts, so that you can tell your friend from an attacker. For example, you might have your friend's public key. Your friend faces the same problem.

Once each party knows the other's public key, DH is a possible way of establishing a secure channel. The DH setup messages are signed by the public key, so the receiving party can check their authenticity.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.