2
$\begingroup$

Actually, I am working on a project to combine symmetric and asymmetric cryptographic algorithms.

The shared secret key for AES will be generated through the Elliptic Curve Diffie Hellman Key Exchange (ECDH) Method. I have one question that ECDH will generate a shared secret key of 256 bit or more length key. For AES-128 I need a secret key of 128 bit but ECDH is not generating the 128-bit key.

So how can I convert the variable-length key into 128 bit?

$\endgroup$
1
  • $\begingroup$ In SO, if the answer is useful, one usually upvotes, and if you are the asker, if the answer satisfies you, you can accept the answer. Have fun. $\endgroup$
    – kelalaka
    Oct 19, 2021 at 14:44

1 Answer 1

3
$\begingroup$

There is already good scheme for this, Elliptic Curve Integrated Encryption Scheme (ECIES);

Once you exchanged the keys with ECDH, then you can use a KDF to derive any key length, HKDF is fine.

ECIES also authenticates the ciphertext as Encrypted-then-MAC. In order to use MAC, you need another key. You can use HKDF to derive many keys by providing different info parameters for each required key. Since your key is random you don't need the extract part of the HKDF, if available, just use expand part.

As an advice, use AES-256, it is only %40 times slower than AES-128, however, it is secure against Quantum and Multi-target attacks.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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