-
Notifications
You must be signed in to change notification settings - Fork 17
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
TLS 1.3 HKDF-Extract with empty salt fails when using the KeyPair FIPS Provider #253
Comments
Thanks for reporting and for the detailed reproducer.
Our HKDF test suite contains at least on test that checks In fact, OpenSSL TLS 1.3 implementation behavior is similar to ours, it only sets the salt if it is not nil: https://github.com/openssl/openssl/blob/3240427a8530f5aa6070f135e954e20e591fa132/ssl/tls13_enc.c#L206-L208 On the other hand, the OpenSSL HKDF documentation says the following, contradicting the implemented behavior:
Having said this, I would prefer not to force an allocation on every OpenSSL user just because one provider is not compatible (unless I'm wrong) with the OpenSSL behavior. Let me push back a bit on this. Wouldn't it make more sense for the Keypair FIPS provider to follow suite with OpenSSL built-in providers? @simo5 @derekparker you are more involved with the OpenSSL project. What do you think? |
If you decide this issue if worth fixing, then I can open PRs. I believe the performance concerns can be handled with taking a slice from a preallocated buffer instead of allocating a new buffer per call. |
My gut feeling is that the Keypair FIPS provider should accept empty salts regardless of what we do here, if it wants to be compatible with the rest of the OpenSSL ecosystem. On the other hand, the OpenSSL HKDF docs do mention that the salt is mandatory even when that is not enforced, so we better comply with what it says on the tin. @samiponkanenssh please send that PR 😄. |
@qmuntal The PR I just opened fixes the nil salt issue, which I am seeing with microsoft/go TLS 1.3. I noticed that there is a slightly different yet similar problem in the hkdf_test.go. A few test vectors use There is also a separate problem in hkdf_test.go as it uses test vectors with SHA1 hash. Would you prefer me changing the PR to handle also the |
Better treat |
As instructed by @qmuntal I am opening this issue here in golang-fips/openssl.
The issue is that TLS 1.3 does not work in binaries built with microsoft/go and
-tags goexperiment.opensslcrypto
when using the KeyPair FIPS Provider for OpenSSL 3 (https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/4724).I have been in contact with Keypair and the root cause is that Keypair FIPS provider enforces a minimum HMAC key length of 112 bits. However, when crypto/tls calls HKDF Extract() it sometimes does this with nil salt and consequently when that salt is used as the HMAC key, the FIPS provider's enforcement kicks in and triggers a panic.
The issue can be reproduced with this simple app:
The panic looks following on microsoft/go1.23.6-20250211.6:
Similar panic is triggered in microsoft/go1.24.0-20250212.5:
According to RFC 5869 Section 2.2, the salt "if not provided, it is set to a string of HashLen zeros.".
Patching the OpenSSL HKDF bindings in the golang-fips/openssl/v2/hkdf.go to convert nil salt to zeroed buffer does fix the issue.
For microsoft/go1.23.6-20250211.6 the patch looks like following:
For microsoft/go1.24.0-20250212.5 the patch looks like following, though I have not done very extensive testing on go1.24:
The text was updated successfully, but these errors were encountered: