Skip to content

Commit 2f1ed5c

Browse files
committed
crypto: remove legacy native handles
PR-URL: #27011 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 73bca57 commit 2f1ed5c

File tree

6 files changed

+6
-39
lines changed

6 files changed

+6
-39
lines changed

doc/api/deprecations.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -2239,18 +2239,21 @@ use the [WHATWG URL API][] instead.
22392239
### DEP0117: Native crypto handles
22402240
<!-- YAML
22412241
changes:
2242+
- version: REPLACEME
2243+
pr-url: https://github.com/nodejs/node/pull/27011
2244+
description: End-of-Life.
22422245
- version: v11.0.0
22432246
pr-url: https://github.com/nodejs/node/pull/22747
22442247
description: Runtime deprecation.
22452248
-->
22462249
2247-
Type: Runtime
2250+
Type: End-of-Life
22482251
22492252
Previous versions of Node.js exposed handles to internal native objects through
22502253
the `_handle` property of the `Cipher`, `Decipher`, `DiffieHellman`,
22512254
`DiffieHellmanGroup`, `ECDH`, `Hash`, `Hmac`, `Sign`, and `Verify` classes.
2252-
Using the `_handle` property to access the native object is deprecated because
2253-
improper use of the native object can lead to crashing the application.
2255+
The `_handle` property has been removed because improper use of the native
2256+
object can lead to crashing the application.
22542257
22552258
<a id="DEP0118"></a>
22562259
### DEP0118: dns.lookup() support for a falsy hostname

lib/internal/crypto/cipher.js

-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const {
2020
const {
2121
getDefaultEncoding,
2222
kHandle,
23-
legacyNativeHandle,
2423
toBuf
2524
} = require('internal/crypto/util');
2625

@@ -219,8 +218,6 @@ Cipher.prototype.setAAD = function setAAD(aadbuf, options) {
219218
return this;
220219
};
221220

222-
legacyNativeHandle(Cipher);
223-
224221
function Cipheriv(cipher, key, iv, options) {
225222
if (!(this instanceof Cipheriv))
226223
return new Cipheriv(cipher, key, iv, options);
@@ -245,7 +242,6 @@ function addCipherPrototypeFunctions(constructor) {
245242
Object.setPrototypeOf(Cipheriv.prototype, LazyTransform.prototype);
246243
Object.setPrototypeOf(Cipheriv, LazyTransform);
247244
addCipherPrototypeFunctions(Cipheriv);
248-
legacyNativeHandle(Cipheriv);
249245

250246
function Decipher(cipher, password, options) {
251247
if (!(this instanceof Decipher))
@@ -257,7 +253,6 @@ function Decipher(cipher, password, options) {
257253
Object.setPrototypeOf(Decipher.prototype, LazyTransform.prototype);
258254
Object.setPrototypeOf(Decipher, LazyTransform);
259255
addCipherPrototypeFunctions(Decipher);
260-
legacyNativeHandle(Decipher);
261256

262257

263258
function Decipheriv(cipher, key, iv, options) {
@@ -270,7 +265,6 @@ function Decipheriv(cipher, key, iv, options) {
270265
Object.setPrototypeOf(Decipheriv.prototype, LazyTransform.prototype);
271266
Object.setPrototypeOf(Decipheriv, LazyTransform);
272267
addCipherPrototypeFunctions(Decipheriv);
273-
legacyNativeHandle(Decipheriv);
274268

275269
module.exports = {
276270
Cipher,

lib/internal/crypto/diffiehellman.js

-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const { isArrayBufferView } = require('internal/util/types');
1111
const {
1212
getDefaultEncoding,
1313
kHandle,
14-
legacyNativeHandle,
1514
toBuf
1615
} = require('internal/crypto/util');
1716
const {
@@ -165,9 +164,6 @@ DiffieHellman.prototype.setPrivateKey = function setPrivateKey(key, encoding) {
165164
return this;
166165
};
167166

168-
legacyNativeHandle(DiffieHellman);
169-
legacyNativeHandle(DiffieHellmanGroup);
170-
171167

172168
function ECDH(curve) {
173169
if (!(this instanceof ECDH))
@@ -195,8 +191,6 @@ ECDH.prototype.getPublicKey = function getPublicKey(encoding, format) {
195191
return encode(key, encoding);
196192
};
197193

198-
legacyNativeHandle(ECDH);
199-
200194
ECDH.convertKey = function convertKey(key, curve, inEnc, outEnc, format) {
201195
if (typeof key !== 'string' && !isArrayBufferView(key)) {
202196
throw new ERR_INVALID_ARG_TYPE(

lib/internal/crypto/hash.js

-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const {
88
const {
99
getDefaultEncoding,
1010
kHandle,
11-
legacyNativeHandle,
1211
toBuf
1312
} = require('internal/crypto/util');
1413

@@ -89,8 +88,6 @@ Hash.prototype.digest = function digest(outputEncoding) {
8988
return ret;
9089
};
9190

92-
legacyNativeHandle(Hash);
93-
9491

9592
function Hmac(hmac, key, options) {
9693
if (!(this instanceof Hmac))
@@ -130,8 +127,6 @@ Hmac.prototype.digest = function digest(outputEncoding) {
130127
Hmac.prototype._flush = Hash.prototype._flush;
131128
Hmac.prototype._transform = Hash.prototype._transform;
132129

133-
legacyNativeHandle(Hmac);
134-
135130
module.exports = {
136131
Hash,
137132
Hmac

lib/internal/crypto/sig.js

-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const {
1919
const {
2020
getDefaultEncoding,
2121
kHandle,
22-
legacyNativeHandle,
2322
toBuf,
2423
validateArrayBufferView,
2524
} = require('internal/crypto/util');
@@ -56,8 +55,6 @@ Sign.prototype.update = function update(data, encoding) {
5655
return this;
5756
};
5857

59-
legacyNativeHandle(Sign);
60-
6158
function getPadding(options) {
6259
return getIntOption('padding', RSA_PKCS1_PADDING, options);
6360
}
@@ -166,8 +163,6 @@ Verify.prototype.verify = function verify(options, signature, sigEncoding) {
166163
rsaPadding, pssSaltLength);
167164
};
168165

169-
legacyNativeHandle(Verify);
170-
171166
function verifyOneShot(algorithm, data, key, signature) {
172167
if (algorithm != null)
173168
validateString(algorithm, 'algorithm');

lib/internal/crypto/util.js

-14
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const { validateString } = require('internal/validators');
2121
const { Buffer } = require('buffer');
2222
const {
2323
cachedResult,
24-
deprecate,
2524
filterDuplicateStrings
2625
} = require('internal/util');
2726
const {
@@ -30,18 +29,6 @@ const {
3029

3130
const kHandle = Symbol('kHandle');
3231

33-
function legacyNativeHandle(clazz) {
34-
Object.defineProperty(clazz.prototype, '_handle', {
35-
get: deprecate(function() { return this[kHandle]; },
36-
`${clazz.name}._handle is deprecated. Use the public API ` +
37-
'instead.', 'DEP0117'),
38-
set: deprecate(function(h) { this[kHandle] = h; },
39-
`${clazz.name}._handle is deprecated. Use the public API ` +
40-
'instead.', 'DEP0117'),
41-
enumerable: false
42-
});
43-
}
44-
4532
var defaultEncoding = 'buffer';
4633

4734
function setDefaultEncoding(val) {
@@ -116,7 +103,6 @@ module.exports = {
116103
getDefaultEncoding,
117104
getHashes,
118105
kHandle,
119-
legacyNativeHandle,
120106
setDefaultEncoding,
121107
setEngine,
122108
timingSafeEqual,

0 commit comments

Comments
 (0)