Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing KDFs #75

Open
tarcieri opened this issue Oct 11, 2022 · 5 comments
Open

Missing KDFs #75

tarcieri opened this issue Oct 11, 2022 · 5 comments

Comments

@tarcieri
Copy link
Member

This is a tracking issue for KDF algorithms we should potentially implement.

Please leave a comment with your requests!

@tarcieri tarcieri pinned this issue Oct 11, 2022
@touilleMan
Copy link

Hi,

It seems the kdf algo from libsodium is missing.

It would be pretty trivial to add it given it's basically a bit of cooking on top of blake2b:

    pub fn kdf_blake2b_derive_from_key::<OutSize>(subkey_id: u64, context: &[u8;8], key: &GenericArray<u8, U32>) -> [u8;OutSize] {
        let mut personal: [u8;16] = [0u8;16];
        personal[..8].copy_from_slice(context);

        let mut salt: [u8;16] = [0u8;16];
        salt[..8].copy_from_slice(&subkey_id.to_le_bytes());

        Blake2bMac<OutSize>::new_with_salt_and_personal(&key, &salt, &personal)
          .expect("subkey has always a valid size")
          .finalize().into()
}

@nemynm
Copy link
Contributor

nemynm commented Oct 4, 2024

Hello,
I would propose ANSI-X9.63-KDF. I have opened a dedicated issue #101.

@TheBestTvarynka
Copy link

KBKDF from NIST SP 800-108 is missing. It would be nice to have it implemented. This KDF is used in Microsoft protocols for key derivation. For example, https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-gkdi/5d373568-dd68-499b-bd06-a3ce16ca7117:

KDF(HashAlg, KI, Label, Context, L) — denotes an execution of the [SP800-108] KDF in counter mode ([SP800-108] section 5.1) by using the Hash Message Authentication Code (HMAC) specified in [FIPS198-1].

I found #87, but it's a draft and hasn't had any updates for the last year.

Do you accept external contributions? Maybe I'll consider implementing it in the future.

@tarcieri
Copy link
Member Author

cc @baloo

@baloo
Copy link
Member

baloo commented Oct 29, 2024

@TheBestTvarynka Feel free to take over or redo the PR :)

This is something I hoped to get back to, but I haven't got time to yet. My use-case for it was for TPM activate credential with RSA keys.
I think the implementation is correct, but I wanted to get tests going.

I got bogged down by the CAVS test vectors. I implemented them as a procmacro that will generate rust test code, but that ended being the wrong approach, it's too slow to iterate.

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

No branches or pull requests

5 participants