You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current api design makes the assumption that you can provide initial key material to expand, on that you have a prk that is able to create a new hmac instance.
However, if we don't have access to the key bytes directly (pkcs11, tpm), it would be good to be able to initialise a hkdf from an existing hmac instance provided that trait needed traits are satifised.
For example
let tpm_hmac = ...... ; // impls the needed Mac traits, output size user, etc.
let hkdf = Hkdf::from<tpm_hmac>(tpm_hmac);
Being able to do HKDF with an HSM-backed HMAC (#155) is something I've wanted, but I'm not sure it actually addresses @Firstyear's issue.
If you want to plug in a fully HSM-provided HKDF as a replacement for the software version, I'm not sure how else to solve that besides KDF traits ala: RustCrypto/traits#1879
That said, I also think it's still reasonable to do the extract step with an HSM-backed HKDF to obtain a PRK, then do the expand step on the host, which I think #155 will also enable.
Activity
tarcieri commentedon Oct 11, 2025
If you’re able to get the PRK out of the HSM/TPM you can do
Hkdf::from_prkBut it seems like what you actually want is to be able to use different implementations of HKDF for
HkdfExtractandHkdfYou could also instantiate
HkdfExtractwith whatever HSM/TPM adapter you have, use it to extract the PRK, then callHkdf::from_prk.Firstyear commentedon Oct 13, 2025
Part of the point of a HSM/TPM is that you can't extract the PRK though. You'd be doing a "HMAC to derive the PRK, then making a HKDF from that PRK"
Where what I would like is to skip that step, and just be able to HKDF using the TPM/HSM hmac impl without the PRK dance in between.
newpavlov commentedon Oct 13, 2025
I guess we could unseal the
HmacImpltrait. It requires only 3 methods +Clone, which should be easy to implement on top of HSMs.tarcieri commentedon Oct 13, 2025
Being able to do HKDF with an HSM-backed HMAC (#155) is something I've wanted, but I'm not sure it actually addresses @Firstyear's issue.
If you want to plug in a fully HSM-provided HKDF as a replacement for the software version, I'm not sure how else to solve that besides KDF traits ala: RustCrypto/traits#1879
That said, I also think it's still reasonable to do the extract step with an HSM-backed HKDF to obtain a PRK, then do the expand step on the host, which I think #155 will also enable.
Firstyear commentedon Oct 14, 2025
Thank you @newpavlov !