I've seen an application recently that used the Diffie Hellman algorithm. It is not a Ephemeral Diffie-Hellman implementation, but rather a Diffie Hellman one. After the secret keys have been calculated, the client then sends a SHA-512 hash of the key to the server when the server asks for it. The only reason I can think of is, the server computes a SHA-512 hash of its secret key and requests the clients hash to detect MITM attacks. Is this wise? safe? What other reason would the application need to do this for?

  • can you clarify what you mean with "Diffie Hellmann one"?
    – user10008
    Commented Aug 24, 2014 at 0:56
  • I just mean it's a standard Diffie Hellman implementation.
    – npn_or_pnp
    Commented Aug 24, 2014 at 1:01
  • 1
    Are you sure they're not hashing more data than just the key? Using DH it seems pointless to send the SHA512 hash of it since it's not transmitted. If there is more data involved in the handshake then it would make a little bit more sense.
    – RoraΖ
    Commented Aug 24, 2014 at 13:19
  • Why doesn't it make sense? Sending the hash of the DH secret key (assuming the DH key is signed using a digital signature) will allow the server to determine if the DH secret keys are the same and not tampered with by an active MITM attack. Once the key is validated by hash, the server uses military strength AES encryption to encrypt all data moving forward(while renegotiating new DH keys every 5 minutes)
    – npn_or_pnp
    Commented Aug 25, 2014 at 16:50

1 Answer 1


By sending a SHA-512 hash of it, you don't expose more useful information about the key, than the attacker had from the Diffie-Hellman messages. However, it is completely insecure to rely on that hash. The man in the middle could give every side its needed hash, and still could intercept the traffic. For Diffie-Hellman to provide any security, either the messages must be signed with a public key cryptosystem, or the negotiated key. Note that when a signature gets transmitted, no more information leaks about the signed content than a hash.

  • The negotiated secret key is provided by DH without being transmitted to the server(only the hash). The client never receives a hash from the server. Can you provide URL references for how a "signed public key" and "signed negotiated key" work?
    – npn_or_pnp
    Commented Aug 24, 2014 at 12:55
  • Does this help?
    – user10008
    Commented Aug 24, 2014 at 16:10
  • so to make this less confusing for others, if the program were to sign the SHA-512 hash with a digital signature, this would provide adequate security to make sure the hash was not tampered with?
    – npn_or_pnp
    Commented Aug 24, 2014 at 19:02
  • If the signature is done with a key the application trusts, yes.
    – user10008
    Commented Aug 24, 2014 at 19:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .