Skip to content

Conversation

vcsjones
Copy link
Member

@vcsjones vcsjones commented Apr 21, 2025

OpenSSL 3.x has introduced a change that stops allowing HKDF's salt to be set to NULL in openssl/openssl#27305.

This breaks our HKDF implementation which sets a NULL salt and info, depending on the mode.

This broke plenty of existing tests with failures like:

Error Message:
   Interop+Crypto+OpenSslCryptographicException : error:078C0102:common libcrypto routines::passed a null parameter
  Stack Trace:
     at Interop.Crypto.HkdfExpand(SafeEvpKdfHandle kdf, ReadOnlySpan`1 prk, String algorithm, ReadOnlySpan`1 info, Span`1 destination) in /__w/runtime-ci/runtime-ci/runtime/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Kdf.cs:line 113
   at System.Security.Cryptography.HKDF.Expand(HashAlgorithmName hashAlgorithmName, Int32 hashLength, ReadOnlySpan`1 prk, Span`1 output, ReadOnlySpan`1 info) in /__w/runtime-ci/runtime-ci/runtime/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/HKDF.OpenSsl.cs:line 44

In this case, we no longer set the info or salt if they are NULL, and tests are green again.

This was found in a nightly run against OpenSSL 3.5. https://github.com/vcsjones/runtime-ci/actions/runs/14574054040/job/40876380622

Fixes vcsjones/runtime-ci#5

@Copilot Copilot AI review requested due to automatic review settings April 21, 2025 14:39
@ghost ghost added the area-System.Security label Apr 21, 2025
@vcsjones vcsjones requested a review from bartonjs April 21, 2025 14:40
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the HKDF implementation to no longer set a NULL salt or info parameter in order to comply with OpenSSL 3.x behavior.

  • Conditionally includes the salt and info parameters only when they are non-null and have a non-zero length.
  • Updates the construction of the OSSL_PARAM array accordingly.

@vcsjones vcsjones added this to the 10.0.0 milestone Apr 21, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

@vcsjones
Copy link
Member Author

@vcsjones vcsjones merged commit fd33f03 into dotnet:main Apr 21, 2025
92 of 98 checks passed
@vcsjones vcsjones deleted the hkdf-no-set-null branch April 21, 2025 21:40
@vcsjones
Copy link
Member Author

/backport to release/9.0-staging

Copy link
Contributor

Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/14581934220

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build Failure for run 14574054040

2 participants