Edit

HKDF on Windows uses CNG implementation

Starting in .NET 11, HKDF on Windows uses Windows' built-in Cryptography API: Next Generation (CNG) implementation. The Windows implementation restricts some input sizes more than the previous .NET implementation, so some inputs that worked in earlier .NET versions now throw CryptographicException.

Version introduced

.NET 11 Preview 1

Previous behavior

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

New behavior

Starting in .NET 11, on Windows, DeriveKey and Expand limit the maximum input length for input keying material and pseudorandom keys. If the input keying material passed to DeriveKey or the pseudorandom key passed to Expand exceeds the limit, the method throws CryptographicException.

Both limits are currently 2,048 bytes.

Type of breaking change

This change is a behavioral change.

Reason for change

On Windows, .NET 11 changed from a managed HKDF implementation to the implementation provided by Windows CNG. The .NET cryptography libraries prefer platform implementations for cryptographic algorithms.

Typical uses of HKDF shouldn't reach these limits. If your application passes input keying material or pseudorandom keys larger than 2,048 bytes on Windows, consider smaller inputs.

Affected APIs