Skip to content

Conversation

@tarcieri
Copy link
Member

Due to the &self requirement in the Kdf trait, this seems like the only existing type that a Kdf impl makes sense for, since derive_key needs to be able to input IKM.

The "salt" parameter of Kdf::derive_key has been mapped to the HKDF info parameter, as what HKDF calls the "salt" (the non-secret value that goes into the extract step) has already been (potentially) configured via &self, whereas the "info" parameter (the non-secret value that goes into the expand step) is the one we can actually configure through this API.

Due to the `&self` requirement in the `Kdf` trait, this seems like the
only existing type that a `Kdf` impl makes sense for, since `derive_key`
needs to be able to input IKM.

The "salt" parameter of `Kdf::derive_key` has been mapped to the HKDF
`info` parameter, as what HKDF calls the "salt" (the non-secret value
that goes into the extract step) has already been (potentially)
configured via `&self`, whereas the "info" parameter (the non-secret
value that goes into the expand step) is the one we can actually
configure through this API.
@tarcieri tarcieri requested a review from newpavlov January 14, 2026 21:46

#[cfg(feature = "kdf")]
impl<H: HmacImpl> Kdf for GenericHkdfExtract<H> {
fn derive_key(&self, secret: &[u8], info: &[u8], out: &mut [u8]) -> kdf::Result<()> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@newpavlov per your point on RustCrypto/traits#1879 it does seem like the non-secret argument to derive_key is a better fit for HKDF info and maybe we can consider renaming it in the trait.

For now I have used the info name in the impl.

@tarcieri
Copy link
Member Author

I can't tell if being able to input IKM before invoking derive_key is a feature or a bug

@tarcieri tarcieri merged commit cd6df6d into master Jan 15, 2026
35 checks passed
@tarcieri tarcieri deleted the hkdf/impl-kdf-trait branch January 15, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants