Skip to content
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: generateKeyPair('ec') should not support NODE-ED* and NODE-X* #37063

Closed
wants to merge 4 commits into from

Conversation

panva
Copy link
Member

@panva panva commented Jan 25, 2021

The following "curves" were added to the 'ec' key type in #36879.

  • NODE-ED25519
  • NODE-ED448
  • NODE-X25519
  • NODE-X448

However, none of these are pure EC curves, for example, Curve25519 does not work with ECDSA, which is one of the reasons why crypto.getCurves() does not include Curve25519. This PR makes these "curves" only recognized from the Web Cryptography API experimental interface.

Fixes #37055

cc @jasnell @tniessen

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. labels Jan 25, 2021
@nodejs-github-bot
Copy link
Collaborator

lib/internal/crypto/ec.js Outdated Show resolved Hide resolved
Copy link
Member

@tniessen tniessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the only public API change (outside of WebCrypto) from the referenced PR, but I'm not 100% sure. It definitely fixes the problem with generateKeyPair.

lib/internal/crypto/ec.js Outdated Show resolved Hide resolved
@panva
Copy link
Member Author

panva commented Jan 25, 2021

I still have to manage to change KeyObjectHandle::InitEDRaw to accomodate for the revert in GetCurveFromName

@@ -443,7 +447,7 @@ Maybe<bool> ECDHBitsTraits::AdditionalConfig(
return Nothing<bool>();
}

params->id_ = GetCurveFromName(*name);
params->id_ = GetOKPCurveFromName(*name);
Copy link
Member Author

@panva panva Jan 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT id_ is only used to discern between X25519, X448 and then it throws everything else in the default bucket anyway, therefore returning the specific EC curve ids is not necessary and using GetOKPCurveFromName is ok.

@tniessen tniessen requested a review from jasnell January 25, 2021 15:43
@nodejs-github-bot
Copy link
Collaborator

@panva panva added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 25, 2021
panva added a commit that referenced this pull request Jan 27, 2021
Fixes #37055

PR-URL: #37063
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
@panva
Copy link
Member Author

panva commented Jan 27, 2021

Landed in 8b65004

@panva panva closed this Jan 27, 2021
targos pushed a commit that referenced this pull request Feb 2, 2021
Fixes #37055

PR-URL: #37063
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
@targos targos mentioned this pull request Feb 2, 2021
@panva panva deleted the fix-37055 branch October 13, 2022 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

generateKeyPair('ec') should not support NODE-ED* and NODE-X*
6 participants