Uh oh!
There was an error while loading. Please reload this page.
Conversation
1dd9bad to
7d87e21Comparetarcieri
commented
May 31, 2025
I opened this up for discussion primarily, and also reserved the I think we probably need a lot more traits than this, particularly ones for representing the "expand" and "extract" steps in proper KDFs like HKDF. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Another important question: output size limits and fallibility. Should we have a How about a trait with an associated constant or typenum type that defines the maximum output size? |
daxpedda
commented
Jun 2, 2025
I am assuming that "key stretching functions", e.g. Argon2, Scrypt and such, don't fall under this trait? |
tarcieri
commented
Jun 2, 2025
@daxpedda I think it would be good to eventually support password-based KDFs. I think they wind up having a very similar API to other KDFs, to the point it might just be a marker trait and some usage guidelines. That said, it would probably be good to focus on traits for what's in https://github.com/rustcrypto/kdfs for now |
daxpedda
commented
Jun 2, 2025
FWIW: I don't have much feedback for this kind of interface, but for OPAQUE we would like to have a trait for key stretching functions. |
tarcieri
commented
Jan 14, 2026
I thought I'd collect the individual functions we're trying to abstract over: KDFs
|
tarcieri
commented
Jan 14, 2026
It seems like a one-shot API which accepts IKM/password and salt, and can access pubtraitKdf{fnderive_key(&self,secret:&[u8],salt:&[u8],out:&mut[u8]) -> Result<()>;}As for PBKDFs, perhaps a marker trait for where it's acceptable to use a password as pubtraitPbkdf:Kdf{}Notably having a trait that wraps the low-level KDF APIs for PBKDFs (as opposed to the high-level password hash string APIs in |
Sounds good to me! Is it correct to interpret What about the |
These are all good questions. The "other information" parameter of One-Step KDF seems to have fairly open-ended usage, per my interpretation of NIST SP 800-56C. It's described as:
I think it would be fine to pass Re: errors, I'll need to look at the error types in the various KDF crates to see if they're actually useful, and if not we can just have a common error type, which is probably where I'll start anyway as that's simpler. |
newpavlov
commented
Jan 14, 2026
Maybe it's better to use something like |
Traits which provide an API for interacting with Key Derivation Functions. We have several of these located at https://github.com/rustcrypto/kdfs and password-based KDFs at https://github.com/RustCrypto/password-hashes but the APIs for using these are typically just free functions, whereas traits could provide a common API.
Just pushed up my suggested new changes and removed draft.
HKDF still calls it a salt, and I think "salt" is still an exceedingly common term for it. It's also the parameter that gets passed as a salt in PBKDFs. I think it would probably be more confusing to call it something else other than salt. |
But I don't think it's correct to call customization strings (
HKDF explicitly distinguishes between |
tarcieri
commented
Jan 14, 2026
Well, that's why I want to pass the salt parameter to salt in HKDF. I think most HKDF usages use a salt, whereas they may or may not use info and if they do, this trait isn't going to be expressive enough to cover that case. For One-Shot KDF I think it's fine to pass
Can you show me an HKDF use case which uses info but does not use salt? Because that's the only such use case where such a trait impl would be useful. I think it's much more common to configure salt but leave info unspecified. |
newpavlov
commented
Jan 14, 2026
For example, in QUIC salt is fixed (so it could've been omitted) and then initialized value is used with different On Wiki "salt" is defined as:
|
I guess it does not really matter. The trait method accepts If we are to keep |
Uh oh!
There was an error while loading. Please reload this page.
tarcieri
commented
Jan 14, 2026
Thanks for the approval. I think it's good to have something landed to iterate on. I'll note that while in some applications like password hash strings (including the At the end of the day, KDFs have a secret and non-secret input, and it's just a bikeshed debate about what to call the non-secret input (we could consider simply calling the other input Your comment did get me thinking though that your suggestion of using the non-secret HKDF input as info rather than salt is actually probably better, because then the trait can (almost) be impl'd on |
Traits which provide an API for interacting with Key Derivation Functions.
We have several of these located at https://github.com/rustcrypto/kdfs and password-based KDFs at https://github.com/RustCrypto/password-hashes but the APIs for using these are typically just free functions, whereas traits could provide a common API.