crypto: runtime deprecate ECDH.setPublicKey()

It's been "pending" deprecation since 6.12.0.
I think that's long enough.

PR-URL: https://github.com/nodejs/node/pull/58620
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
James M Snell 2025-06-09 08:53:10 -07:00 committed by GitHub
parent 308b6bc6de
commit 66632648ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 4 deletions

View File

@ -718,6 +718,9 @@ The `SlowBuffer` class has been removed. Please use
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/58620
description: Runtime deprecation.
- version: v6.12.0
pr-url: https://github.com/nodejs/node/pull/10116
description: A deprecation code has been assigned.
@ -726,10 +729,10 @@ changes:
description: Documentation-only deprecation.
-->
Type: Documentation-only
Type: Runtime
The [`ecdh.setPublicKey()`][] method is now deprecated as its inclusion in the
API is not useful.
The [`ecdh.setPublicKey()`][] method is now deprecated as its inclusion in
the API is not useful.
### DEP0032: `node:domain` module

View File

@ -46,6 +46,7 @@ const {
} = require('internal/util/types');
const {
deprecate,
lazyDOMException,
} = require('internal/util');
@ -228,7 +229,9 @@ function ECDH(curve) {
ECDH.prototype.computeSecret = DiffieHellman.prototype.computeSecret;
ECDH.prototype.setPrivateKey = DiffieHellman.prototype.setPrivateKey;
ECDH.prototype.setPublicKey = DiffieHellman.prototype.setPublicKey;
ECDH.prototype.setPublicKey = deprecate(DiffieHellman.prototype.setPublicKey,
'ecdh.setPublicKey() is deprecated.',
'DEP0031');
ECDH.prototype.getPrivateKey = DiffieHellman.prototype.getPrivateKey;
ECDH.prototype.generateKeys = function generateKeys(encoding, format) {

View File

@ -0,0 +1,24 @@
// Flags: --no-warnings
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
}
const crypto = require('crypto');
common.expectWarning(
'DeprecationWarning',
'ecdh.setPublicKey() is deprecated.', 'DEP0031');
const ec = crypto.createECDH('secp256k1');
try {
// This will throw but we don't care about the error,
// we just want to verify that the deprecation warning
// is emitted.
ec.setPublicKey(Buffer.from([123]));
} catch {
// Intentionally ignore the error
}