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

generateKeyPair('ec') should not support NODE-ED* and NODE-X* #37055

Closed
tniessen opened this issue Jan 24, 2021 · 1 comment
Closed

generateKeyPair('ec') should not support NODE-ED* and NODE-X* #37055

tniessen opened this issue Jan 24, 2021 · 1 comment
Labels
crypto Issues and PRs related to the crypto subsystem.

Comments

@tniessen
Copy link
Member

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.

Node.js already supported these special algorithms through their own key types (thanks to #26554, #26774, and #31178):

  • crypto.generateKeyPairSync('ed25519').publicKey.asymmetricKeyType === 'ed25519'
  • crypto.generateKeyPairSync('ed448').publicKey.asymmetricKeyType === 'ed448'
  • crypto.generateKeyPairSync('x25519').publicKey.asymmetricKeyType === 'x25519'
  • crypto.generateKeyPairSync('x448').publicKey.asymmetricKeyType === 'x448'

With #36879, we now also have this:

  • crypto.generateKeyPairSync('ec', { namedCurve: 'NODE-ED25519' }).publicKey.asymmetricKeyType === 'ed25519'
  • crypto.generateKeyPairSync('ec', { namedCurve: 'NODE-ED448' }).publicKey.asymmetricKeyType === 'ed448'
  • crypto.generateKeyPairSync('ec', { namedCurve: 'NODE-X25519' }).publicKey.asymmetricKeyType === 'x25519'
  • crypto.generateKeyPairSync('ec', { namedCurve: 'NODE-X448' }).publicKey.asymmetricKeyType === 'x448'

This also means that two keys, both generated through some call to crypto.generateKeyPairSync('ec', { namedCurve }) result in different ASN.1 representations, which is also highly unusual and counter-intuitive.

#36879 technically also landed without full approval.

@tniessen tniessen added the crypto Issues and PRs related to the crypto subsystem. label Jan 24, 2021
@panva
Copy link
Member

panva commented Jan 25, 2021

likely culrpit cc @jasnell

@panva panva closed this as completed in 8b65004 Jan 27, 2021
targos pushed a commit that referenced this issue 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants