How can I use HKDF with ECDiffieHellmanCng and AesCng RRS feed

  • Question

  • 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.
    Tuesday, March 5, 2019 6:20 PM

All replies

  • If I were to set the KeyDerivationFunction to Hmac and the HashAlgorithm to Sha256 and then call the DeriveKeyFromHmac method, the output of that method would be consistent with the "Extract" step of the HKDF function, correct?  I could then write a method to do the expand step and get my symmetric key.  
    Tuesday, March 5, 2019 7:05 PM
  • Hi Sam,

    Thank you for posting here.

    According your post, your question is more relevant to the HKDF, please post in the following forum.


    The Visual C# forum discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    Note: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you.

    Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.

    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 6, 2019 6:30 AM
  • Hi Jack.  You seem to misunderstand.  My question is about the MS implementation of the ECDiffieHellmanCng class, not about HKDF itself.
    Wednesday, March 6, 2019 3:45 PM