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

Need more Flexibility in KDFs SP.800-56C and SP.800-108 #4449

Open
reneme opened this issue Nov 27, 2024 · 2 comments
Open

Need more Flexibility in KDFs SP.800-56C and SP.800-108 #4449

reneme opened this issue Nov 27, 2024 · 2 comments
Assignees
Labels
enhancement Enhancement or new feature
Milestone

Comments

@reneme
Copy link
Collaborator

reneme commented Nov 27, 2024

Currently, there are some hard-coded assumptions. Let's take,

auto kdf = KDF::create("SP800-56C(SHA-256)");

... that will currently create a KDF that uses HMAC(SHA-256) for the extraction (which is fine) and hard-codes SP800-108-Feedback for the expansion. As far as I can see, there's no way to customize the expansion step (especially now that the concrete KDF-headers are internal). Or am I missing something?

Also, SP800-108 currently hard-codes the bitlengths for the counter and the encoding of the requested key lengths to 32 bits.

As it stands, customization of the mentioned hard-coded decisions should probably all be encodable using the algo-spec. Also, I believe, this can be done in a backward-compatilbe way using the existing bits as defaults. Albeit I foresee this to become somewhat cumbersome. Maybe #3275 would be useful here.

The fully-customized algo spec would probably look like this:

SP800-56C(SHA-256,SP800-108-Counter(SHA-256,8,16))

... with 8 and 16 being the bitlengths for the counter (aka r) and the key length L respectively.

@reneme reneme added the enhancement Enhancement or new feature label Nov 27, 2024
@reneme reneme added this to the Botan 3.7.0 milestone Nov 27, 2024
@reneme reneme self-assigned this Nov 27, 2024
@randombit
Copy link
Owner

😭 why could NIST not just standardize HKDF and be done with it

[Fine to extend this to handle these cases if you need them, I just greatly dislike how NIST keeps coming with new KDFs - we already implement 8 KDFs from various NIST SPs and they all have a zillion options]

@reneme
Copy link
Collaborator Author

reneme commented Nov 27, 2024

Yep. Try adding BSI to the mix. 😏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or new feature
Projects
None yet
Development

No branches or pull requests

2 participants