1
$\begingroup$

I just read about Diffie–Hellman key exchange and was wondering how the value created from that can be used for any encryption method. Here is a link of where I read it from.

$\endgroup$
1
  • 1
    $\begingroup$ You could hash the value into an AES key $\endgroup$ – SamG101 Jan 16 '20 at 13:33
2
$\begingroup$

As the output of the DH key exchange is a number, it has to be converted into big-endian bytes before running it through a hash - say SHA (SHA2 or SHA3) for example, can convert it into a key of the correct length.

If you need variable-length keys, then you can use XOFs, which provide variable length outputs. This cannot increase the entropy of the result of the DH exchange.

If you need multiple keys, HKDF is an option. The DH output is already of enough entropy, so you can skip the HKDF-Extract step, and use the HKDF-Expand to create multiple keys that cannot be derived from each other.

$\endgroup$
0
1
$\begingroup$

To remain at the introductory level used in the question's reference¹, a simple (and not necessarily perfect) method: if the modulus used is large (hundreds of decimal digits) and significantly larger than the text to encrypt, the right part of the shared secret can be used as a key for a Vigenère cipher. With Vigenère, it is essential for confidentiality that the shared key material is not reused.

If the shared secret is expressed in base 10 (decimal), two digits can be used for each character encrypted taken from an alphabet of 100 characters (and that 2-to-1 correspondence used when comparing sizes of shared secret and text to encrypt). There is no such complication when base and alphabet size are identical (e.g. binary).


¹ This poster has a nicely low error/information ratio. The only thing I dislike is the part using "encrypt" and "decrypt" for sign and verify, as in "The encryption key is private, but the decryption key is made public". But at least, that's done consistently, and probably is due to old age (2008, which also makes information on RSA modulus size seriously obsolete).

$\endgroup$

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.