Multiple diffieHellman.generateKeys calls don't update the public key #56990
Copy link
Copy link
Closed
Labels
cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Description
Activity
- addeddocIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.
on Feb 10, 2025 - addedcryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.
on Feb 10, 2025 Not a bug but maybe a case of unclear documentation. See commit 4a82c8f for why that paragraph was added.
Public key generation is a deterministic process. You don't change any parameters so of course the public key stays the same. If you called
dh.setPublicKey(some_other_pubkey)and then call generateKeys again, you get the old public key again.Reacted by Tobias Nießen- added a commit that references this issue
on Mar 11, 2026 github-actions commented
on Apr 21, 2026 on Apr 21, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Apr 21, 2026 - added a commit that references this issue
on Apr 21, 2026 - added 2 commits that reference this issue
on May 5, 2026 - added a commit that references this issue
on Jul 29, 2026
Metadata
Metadata
Assignees
Labels
cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Affected URL(s)
https://nodejs.org/docs/latest-v22.x/api/crypto.html#diffiehellmangeneratekeysencoding
Description of the problem
The documentation regarding diffieHellman.generateKeys([encoding]) in
cryptomodule states as follows:I have not been able to observe in any way that calling
generateKeysmultiple times results in different public keys.NodeJS docs state that it is a thin wrapper around OpenSSL's
DH_generate_key. The OpenSSL page onDH_generate_keystates that as follows in their docs:Is it possible this is the result of such deprecation?