Skip to content

Fix node:crypto diffieHellman with an imported public key - #8393

Merged
jasnell merged 1 commit into
mainfrom
littledivy/2026-11-12-x25519-imported-dh
Nov 12, 2026
Merged

jasnell merged 1 commit into
mainfrom
littledivy/2026-11-12-x25519-imported-dh

Conversation

@littledivy

Copy link
Copy Markdown
Member

statelessDH passed the keys to ncrypto's DHPointer::stateless(ourKey, theirKey) in the wrong order, so diffieHellman() threw for public keys imported from SPKI/JWK (X25519) and for all EC keys.

In this patch the private key goes first, and diffieHellman is added to the node:crypto default export. Fixes #7743.

`statelessDH` passed the keys to ncrypto's `DHPointer::stateless(ourKey,
theirKey)` in the wrong order, so `diffieHellman()` threw for public keys
imported from SPKI/JWK (X25519) and for all EC keys.

In this patch the private key goes first, and `diffieHellman` is added to
the `node:crypto` default export. Fixes #7743.
@littledivy
littledivy requested review from a team as code owners November 12, 2026 12:39

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — This is a small, correct fix to the argument order in statelessDH, with tests for the affected paths. No issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

statelessDH now passes the private key and then the public key, which is the order DHPointer::stateless(ourKey, theirKey) expects. The new tests cover X25519 public keys imported from SPKI and JWK, and EC keys.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: b29f3756

@jasnell
jasnell merged commit 6c56137 into main Nov 12, 2026
23 of 24 checks passed
@jasnell
jasnell deleted the littledivy/2026-11-12-x25519-imported-dh branch November 12, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug Report — Runtime APIs: node:crypto diffieHellman fails for an imported X25519 public key

2 participants