Hi @Sourabh ,
Thanks for reaching out.
It looks like the NCryptSetProperty failure with 0x80090026 may be happening because HKDF is implemented at the BCrypt layer, not fully in NCrypt. While NCryptDeriveKey supports the "HKDF" KDF string, the HKDF-specific properties, like BCRYPT_HKDF_HASH_ALGORITHM and BCRYPT_HKDF_SALT_AND_FINALIZE, are generally expected to be set using BCryptSetProperty on the secret handle. NCrypt may not recognize these properties, which could explain the invalid parameter error.
https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptkeyderivation#hkdf
A couple of approaches that might help are:
- Using BCrypt entirely for HKDF: create the secret agreement with
BCryptSecretAgreement, configure hash and salt withBCryptSetProperty, then derive keys withBCryptDeriveKey. - A hybrid approach: use
NCryptSecretAgreementto create the secret, export the raw secret, then import it into BCrypt to perform HKDF.
The main point is that configuring HKDF properties via NCryptSetProperty may not be supported. Trying one of the approaches above could potentially work in your scenario.
Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.