-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
crypto: modernize DH/ECDH/ECDH-ES #31178
Conversation
e394dd5
to
6261781
Compare
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.
LGTM in principle, some comments on the WIP.
I can confirm the missing ECDH-ES JWA algorithm support for x25519 and x448 keys is solved with this (closes #26626). @tniessen would it be possible to split the change to
Reason I ask is i'd like to see 1) backported to lts/erbium and in order to do that It would likely be easier if the change was as simple as possible. |
@panva Since either the whole PR, or a subset, are semver-minor, there isn't anything blocking backporting to LTS. |
Great. |
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.
Overall direction seems okay to me.
6261781
to
0dfa9c5
Compare
Thank you for the initial round of reviews, I'll try to finish up within the next few days.
I would happily accept alternative directions! This is the best I came up with so far :) |
27d73df
to
78043cc
Compare
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.
Few nits regarding error handling.
78043cc
to
eb347a5
Compare
eb347a5
to
bc309fb
Compare
e98c950
to
4378c9d
Compare
@nodejs/crypto PTAL. |
4378c9d
to
70dc715
Compare
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.
The JS code is LGTM
62197f1
to
a962a3d
Compare
Refs: #31178 Refs: #31445 PR-URL: #31873 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
The new key type 'dh' corresponds to EVP_PKEY_DH. PR-URL: nodejs#31178 Reviewed-By: Sam Roberts <[email protected]>
PR-URL: nodejs#31178 Reviewed-By: Sam Roberts <[email protected]>
This allows using the generateKeyPair API for DH instead of the old stateful DH APIs. PR-URL: nodejs#31178 Reviewed-By: Sam Roberts <[email protected]>
Currently, Node.js has separate (stateful) APIs for DH/ECDH, and no support for ECDH-ES. This commit adds a single stateless function to compute the DH/ECDH/ECDH-ES secret based on two KeyObjects. PR-URL: nodejs#31178 Reviewed-By: Sam Roberts <[email protected]>
test-crypto-keygen and test-crypto-dh-stateless are currently flaky on ARM CI systems due to their slow CPUs. PR-URL: nodejs#31178 Reviewed-By: Sam Roberts <[email protected]>
The new key type 'dh' corresponds to EVP_PKEY_DH. PR-URL: #31178 Reviewed-By: Sam Roberts <[email protected]>
PR-URL: #31178 Reviewed-By: Sam Roberts <[email protected]>
This allows using the generateKeyPair API for DH instead of the old stateful DH APIs. PR-URL: #31178 Reviewed-By: Sam Roberts <[email protected]>
Currently, Node.js has separate (stateful) APIs for DH/ECDH, and no support for ECDH-ES. This commit adds a single stateless function to compute the DH/ECDH/ECDH-ES secret based on two KeyObjects. PR-URL: #31178 Reviewed-By: Sam Roberts <[email protected]>
test-crypto-keygen and test-crypto-dh-stateless are currently flaky on ARM CI systems due to their slow CPUs. PR-URL: #31178 Reviewed-By: Sam Roberts <[email protected]>
@tniessen I noticed some test excludes in the parallel tests:
Since this PR is closed I'm wondering if they are still needed and/or there is an open issue that should be listed instead of this one as to why they are excluded? |
@mhdawson These tests were disabled because they kept timing out. I "temporarily disabled" them more than two years ago, see #31178 (comment) 😄 |
This adds support for DH/ECDH/ECDH-ES via the
KeyObject
API, and should fix #26626. I also added DH support togenerateKeyPair
, which is a partial solution to #28404. There are still lots of things I need to figure out, but I would like to see if people are okay with this approach.(Note that the current API does not support "raw" DH keys, only SPKI/PKCS#8 keys are supported as of now. That will likely change via the previously discussed
.params
/.fields
APIs.)cc @nodejs/crypto @nodejs/security
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes