-
Notifications
You must be signed in to change notification settings - Fork 30.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
src: refactor SubtleCrypto algorithm and length validations #57273
src: refactor SubtleCrypto algorithm and length validations #57273
Conversation
Review requested:
|
cc @nodejs/web-standards |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #57273 +/- ##
==========================================
+ Coverage 90.24% 90.26% +0.02%
==========================================
Files 630 630
Lines 184908 184921 +13
Branches 36181 36196 +15
==========================================
+ Hits 166874 166923 +49
+ Misses 11061 11026 -35
+ Partials 6973 6972 -1
|
18888dc
to
9b119b2
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
9b119b2
to
37988fa
Compare
This comment was marked as outdated.
This comment was marked as outdated.
37988fa
to
a1aa1be
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
} | ||
|
||
function eddsaSignVerify(key, data, algorithm, signature) { | ||
validateEdDSASignVerifyAlgorithm(algorithm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the order of the checks. Previously, we first checked (key.type !== type)
and then checked (name === 'Ed448' && context?.byteLength)
. Now, it's the other way around.
It seems like we're not really following the strict order from the specification for other algorithms either. So I guess this is fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the (name === 'Ed448' && context?.byteLength)
check is our own because we don't support non-empty contexts. From the (early draft warning) supports method proposal this falls under
If the specified operation or algorithm (or one of its parameter values) is expected to fail (for any key and/or data) for an implementation-specific reason (e.g. known nonconformance to the specification), return false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a draft PR for the supports method in #57270 that I will further refactor this PR's validations structures in when it lands.
Landed in 6fdd4e6 |
PR-URL: #57273 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com> Reviewed-By: Mattias Buelens <mattias@buelens.com>
PR-URL: #57273 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com> Reviewed-By: Mattias Buelens <mattias@buelens.com>
This PR refactors the algorithm operation validations of the normalized algorithm and length (where applicable) that can be performed without accessing parameters such as key, data, ciphertext, etc.
This will allow #57270 to invoke these sync validations as part of the
SubtleCrypto.supports()
steps without repeating them in its own implementation.This code is well tested throught WebCryptoAPI WPTs and I've also covered some previously missed lines in our own test suite.