I am using Diffie-Helman key exchange to generate the shared secret. But how will can a message be encrypted using this shared key?

  • $\begingroup$ Why did you tag this with PQ-crypto? Diffie-Hellman is not PQ secure, neither on finite fields, not on elliptic curves. $\endgroup$ Apr 3, 2015 at 10:05

1 Answer 1


You can't encrypt a message with ECDH alone, because all it gives you is a shared secret that you can't really control. Rather, you use that secret in a symmetric scheme like AES (generally after passing it through a KBKDF to convert from an ECDH result to a proper-length and less-structured symmetric key, which you then use as the key for symmetric crypto).

  • $\begingroup$ my shared secret is a point(x,y) which is not 256 or 32 bits long. how can i use AES in such a scenario? $\endgroup$
    – rahul
    Apr 1, 2015 at 20:52
  • $\begingroup$ @rahul That's where the KBKDF comes in. For instance, with TLS, the premaster secret is the x-coordinate of the point. You then pass this to a KBKDF like HKDF to get the actual key. $\endgroup$
    – cpast
    Apr 1, 2015 at 21:01
  • 1
    $\begingroup$ Note that you need to provide for integrity/authenticity if you want to send the ciphertext over an insecure channel. You could for instance use the resulting AES key in GCM mode of operation. $\endgroup$
    – Maarten Bodewes
    Apr 1, 2015 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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