How to use HKDF with ECDiffieHellmanCng

435 views Asked by At

I am attempting to use the ECDiffieHellmanCng class to perform key exchange operations between a desktop and a device connected over BLE. The specs of the system require that HKDF be used to derive the key. That doesn't appear to be an option for the hash functions in the ECDiffieHellmanCng class. Is there a way to do this? I would then need to take the resulting key and pass it into a AesCng object.

1

There are 1 answers

4
Emil On BEST ANSWER

The ECDiffieHellmanCng sucks since it forces you to use one of three pre-defined post processing key derivation functions (Hash, Hmac or Tls). If none of these match your protocol you are out of luck.

You might be able to use the Hmac variant however since that is the first internal operation for HKDF ("extract"). Just set the HmacKey property to the salt in HKDF. Then manually perform the second Hmac operation yourself ("expand") to get the final HKDF result.