-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Methods Expand and DeriveKey of the System.Security.Cryptography.HKDF class throw invalid exceptions when the argument outputLength has negative value.
In this example Expand throws ArgumentOutOfRangeException with the message Output keying material length can be at most 8160 bytes (255 * hash length).:
HKDF.Expand(HashAlgorithmName.SHA256, prk: new byte[32], outputLength: -1);Instead the exception message should say that outputLength can't be negative (or that it must be positive - depends on whether 0 is considered a valid input).
Here DeriveKey throws OverflowException with the message Arithmetic operation resulted in an overflow.:
HKDF.DeriveKey(HashAlgorithmName.SHA256, ikm: new byte[32], outputLength: -1);Instead the type of exception should be ArgumentOutOfRangeException and the message should say that the outputLength can't be negative (or that it must be positive - depends on whether 0 is considered a valid input).
Windows 10 x64 Pro, dotnet 5.0.0-preview.8.