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

KDF interface returns truncated output if the algorithm doesn't support requested length #2347

Closed
guidovranken opened this issue May 5, 2020 · 5 comments
Labels

Comments

@guidovranken
Copy link

Eg. HKDF + MD5 with a key size > 4080 returns 4080 bytes.

4080 is 255 * 16 (MD5 output size).

The spec says key sizes larger than (255 * digest size) are illegal: https://tools.ietf.org/html/rfc5869#section-2.3 and most libraries I've tested simply return an error/throw an exception in those cases.

This is how I am invoking Botan's HKDF: https://github.com/guidovranken/cryptofuzz/blob/690e0d3199d6bd51f13957d31d8c89dca8cd91f0/modules/botan/module.cpp#L363-L382

Is Botan's behavior intentional?

@randombit
Copy link
Owner

Not intentional, this is a bug, we just let the counter overflow :( Thanks for reporting.

@randombit
Copy link
Owner

Apologies, actually this is intended behavior of the KDF interface. If the output requested is too large for the KDF to support we return a truncated amount. I'm not sure if this is good behavior - in fact it seems almost certainly not good - but it is how the KDF interface currently works and I'm not sure if we can in the immediate term change it without breaking compat. I've now officially deprecated this behavior so we can fix it in 3.0, but in the meantime you'll probably have to skip this test for Botan in cryptofuzz.

@guidovranken
Copy link
Author

Ok thanks, workaround in Cryptofuzz has been implemented, you may close this report when you want.

@randombit randombit changed the title HKDF clamps output to 255 * requested keysize. Feature or bug? KDF interface returns truncated output if the algorithm doesn't support requested length May 7, 2020
randombit added a commit that referenced this issue Nov 28, 2020
randombit added a commit that referenced this issue Nov 28, 2020
randombit added a commit that referenced this issue Nov 28, 2020
@randombit
Copy link
Owner

@guidovranken The KDF truncation behavior has been removed on master so you should be able to enable KDF testing in cryptofuzz again.

@guidovranken
Copy link
Author

@randombit Great. I've removed the workaround for this bug in Cryptofuzz.

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

No branches or pull requests

2 participants