Skip to content

[Breaking change]: HKDF on Windows uses Windows CNG implementation #55875

Description

@vcsjones

Description

Starting in .NET 11, the HKDF class uses Windows' built-in HKDF implementation. The Windows implementation may be more restrictive on inputs than the previous implementation, causing inputs that worked in previous versions of .NET to no longer work in .NET 11.


This breaking change was introduced in .NET 11 preview 1.

Version

Other (please put exact version in description textbox)

Previous behavior

For Windows, HKDF.DeriveKey and HKDF.Expand accepted inputs of arbitrary size, so long as the inputs were permitted by the HKDF specification.

New behavior

For Windows, HKDF.DeriveKey and HKDF.Expand have limits on the maximum input length for keying material or pseudorandom key. Exceeding these limits will produce a CryptographicException. Both limits are currently 2048 bytes.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

On Windows, .NET 11 changed from using a managed implementation to the implementation provided by Windows CNG. Using the platform implementation of a cryptographic algorithm is the preferred means for .NET to provide cryptographic functionality.

Recommended action

Typical uses of HKDF should not face these limits. Consider using smaller inputs when the limits are reached.

Feature area

Cryptography

Affected APIs

  • System.Security.Cryptography.HKDF.DeriveKey (all overloads)
  • System.Security.Cryptography.HKDF.Expand (all overloads)

Associated WorkItem - 630671

Activity

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

Metadata

Metadata

Assignees

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.breaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions