-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
HKDF: Expand and DeriveKey throw invalid exceptions when outputLength is negative #42229
Comments
Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq, @jeffhandley |
It's not blocking release but I think we should fix at least fix OverflowException to correctly throw ArgumentOutOfRangeException for 5.0 (the call if it will be included in 5.0 doesn't belong to me but will make a patch and see what happens) |
Zero doesn't really make sense, I'm fine with making it throw AOORE. |
I did a preemptive bar check on this and determined it won't meet the bar for 5.0.0 (since there are workarounds); moving to 6.0.0. Thanks for reporting this, @andreimilto! |
You're welcome, @jeffhandley! |
Note to anyone picking this up: it probably makes sense to fix #42230 in the same pull request. |
Hi, I am a first-time contributor and I would love to take a shot at this. |
@tonycimaglia Excellent! Have a look at the Workflow Guide for instructions about getting dotnet/runtime building and running locally, the OS table has a link to building requirements. If everything is set up correctly, you should be able to do If you plan to develop and test in Visual Studio, see the Visual Studio Workflow for some info on getting tests running. Also, take a look at the Building Libraries for more info about building and testing libraries from the Command Line. The HKDF implementation is here: Lines 49 to 51 in a1f9226
and the tests are here:
Before you start making changes it'd be a good idea to make sure that all of the tests in 'System.Security.Cryptography.Algorithms' are green. |
@vcsjones do you mind assigning these issues to me so no one else picks them up? |
Here's an example of another method checking that a parameter is positive: Lines 143 to 144 in 1b491f6
For testing ArgumentExceptions and derived exceptions, we have a custom assertion helper that should be used that also asserts the Lines 315 to 317 in 0ed3f33
It's new-ish so it isn't used consistently in all of the unit tests, but it should be used going forward. |
Hey @tonycimaglia - wanted to check in with you and see you were still willing to submit pull requests for these. If not, no worries. Let me know if you're running in to any issues. |
Since there hasn't been a response in 8 months I'd be interested in picking this up since I just finished one. |
Go for it, @ADustyOldMuffin 😄 |
@ADustyOldMuffin Just in case you missed the in the scroll, fixing #42230 will likely address this one at the same time (but we should make sure tests cover both cases). |
Methods
Expand
andDeriveKey
of theSystem.Security.Cryptography.HKDF
class throw invalid exceptions when the argumentoutputLength
has negative value.In this example
Expand
throwsArgumentOutOfRangeException
with the messageOutput keying material length can be at most 8160 bytes (255 * hash length).
:Instead the exception message should say that
outputLength
can't be negative (or that it must be positive - depends on whether0
is considered a valid input).Here
DeriveKey
throwsOverflowException
with the messageArithmetic operation resulted in an overflow.
:Instead the type of exception should be
ArgumentOutOfRangeException
and the message should say that theoutputLength
can't be negative (or that it must be positive - depends on whether0
is considered a valid input).Windows 10 x64 Pro, dotnet 5.0.0-preview.8.
The text was updated successfully, but these errors were encountered: