crypto: remove legacy native handles
PR-URL: https://github.com/nodejs/node/pull/27011 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
73bca57988
commit
2f1ed5c063
@ -2239,18 +2239,21 @@ use the [WHATWG URL API][] instead.
|
|||||||
### DEP0117: Native crypto handles
|
### DEP0117: Native crypto handles
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
changes:
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/27011
|
||||||
|
description: End-of-Life.
|
||||||
- version: v11.0.0
|
- version: v11.0.0
|
||||||
pr-url: https://github.com/nodejs/node/pull/22747
|
pr-url: https://github.com/nodejs/node/pull/22747
|
||||||
description: Runtime deprecation.
|
description: Runtime deprecation.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
Type: Runtime
|
Type: End-of-Life
|
||||||
|
|
||||||
Previous versions of Node.js exposed handles to internal native objects through
|
Previous versions of Node.js exposed handles to internal native objects through
|
||||||
the `_handle` property of the `Cipher`, `Decipher`, `DiffieHellman`,
|
the `_handle` property of the `Cipher`, `Decipher`, `DiffieHellman`,
|
||||||
`DiffieHellmanGroup`, `ECDH`, `Hash`, `Hmac`, `Sign`, and `Verify` classes.
|
`DiffieHellmanGroup`, `ECDH`, `Hash`, `Hmac`, `Sign`, and `Verify` classes.
|
||||||
Using the `_handle` property to access the native object is deprecated because
|
The `_handle` property has been removed because improper use of the native
|
||||||
improper use of the native object can lead to crashing the application.
|
object can lead to crashing the application.
|
||||||
|
|
||||||
<a id="DEP0118"></a>
|
<a id="DEP0118"></a>
|
||||||
### DEP0118: dns.lookup() support for a falsy hostname
|
### DEP0118: dns.lookup() support for a falsy hostname
|
||||||
|
@ -20,7 +20,6 @@ const {
|
|||||||
const {
|
const {
|
||||||
getDefaultEncoding,
|
getDefaultEncoding,
|
||||||
kHandle,
|
kHandle,
|
||||||
legacyNativeHandle,
|
|
||||||
toBuf
|
toBuf
|
||||||
} = require('internal/crypto/util');
|
} = require('internal/crypto/util');
|
||||||
|
|
||||||
@ -219,8 +218,6 @@ Cipher.prototype.setAAD = function setAAD(aadbuf, options) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
legacyNativeHandle(Cipher);
|
|
||||||
|
|
||||||
function Cipheriv(cipher, key, iv, options) {
|
function Cipheriv(cipher, key, iv, options) {
|
||||||
if (!(this instanceof Cipheriv))
|
if (!(this instanceof Cipheriv))
|
||||||
return new Cipheriv(cipher, key, iv, options);
|
return new Cipheriv(cipher, key, iv, options);
|
||||||
@ -245,7 +242,6 @@ function addCipherPrototypeFunctions(constructor) {
|
|||||||
Object.setPrototypeOf(Cipheriv.prototype, LazyTransform.prototype);
|
Object.setPrototypeOf(Cipheriv.prototype, LazyTransform.prototype);
|
||||||
Object.setPrototypeOf(Cipheriv, LazyTransform);
|
Object.setPrototypeOf(Cipheriv, LazyTransform);
|
||||||
addCipherPrototypeFunctions(Cipheriv);
|
addCipherPrototypeFunctions(Cipheriv);
|
||||||
legacyNativeHandle(Cipheriv);
|
|
||||||
|
|
||||||
function Decipher(cipher, password, options) {
|
function Decipher(cipher, password, options) {
|
||||||
if (!(this instanceof Decipher))
|
if (!(this instanceof Decipher))
|
||||||
@ -257,7 +253,6 @@ function Decipher(cipher, password, options) {
|
|||||||
Object.setPrototypeOf(Decipher.prototype, LazyTransform.prototype);
|
Object.setPrototypeOf(Decipher.prototype, LazyTransform.prototype);
|
||||||
Object.setPrototypeOf(Decipher, LazyTransform);
|
Object.setPrototypeOf(Decipher, LazyTransform);
|
||||||
addCipherPrototypeFunctions(Decipher);
|
addCipherPrototypeFunctions(Decipher);
|
||||||
legacyNativeHandle(Decipher);
|
|
||||||
|
|
||||||
|
|
||||||
function Decipheriv(cipher, key, iv, options) {
|
function Decipheriv(cipher, key, iv, options) {
|
||||||
@ -270,7 +265,6 @@ function Decipheriv(cipher, key, iv, options) {
|
|||||||
Object.setPrototypeOf(Decipheriv.prototype, LazyTransform.prototype);
|
Object.setPrototypeOf(Decipheriv.prototype, LazyTransform.prototype);
|
||||||
Object.setPrototypeOf(Decipheriv, LazyTransform);
|
Object.setPrototypeOf(Decipheriv, LazyTransform);
|
||||||
addCipherPrototypeFunctions(Decipheriv);
|
addCipherPrototypeFunctions(Decipheriv);
|
||||||
legacyNativeHandle(Decipheriv);
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Cipher,
|
Cipher,
|
||||||
|
@ -11,7 +11,6 @@ const { isArrayBufferView } = require('internal/util/types');
|
|||||||
const {
|
const {
|
||||||
getDefaultEncoding,
|
getDefaultEncoding,
|
||||||
kHandle,
|
kHandle,
|
||||||
legacyNativeHandle,
|
|
||||||
toBuf
|
toBuf
|
||||||
} = require('internal/crypto/util');
|
} = require('internal/crypto/util');
|
||||||
const {
|
const {
|
||||||
@ -165,9 +164,6 @@ DiffieHellman.prototype.setPrivateKey = function setPrivateKey(key, encoding) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
legacyNativeHandle(DiffieHellman);
|
|
||||||
legacyNativeHandle(DiffieHellmanGroup);
|
|
||||||
|
|
||||||
|
|
||||||
function ECDH(curve) {
|
function ECDH(curve) {
|
||||||
if (!(this instanceof ECDH))
|
if (!(this instanceof ECDH))
|
||||||
@ -195,8 +191,6 @@ ECDH.prototype.getPublicKey = function getPublicKey(encoding, format) {
|
|||||||
return encode(key, encoding);
|
return encode(key, encoding);
|
||||||
};
|
};
|
||||||
|
|
||||||
legacyNativeHandle(ECDH);
|
|
||||||
|
|
||||||
ECDH.convertKey = function convertKey(key, curve, inEnc, outEnc, format) {
|
ECDH.convertKey = function convertKey(key, curve, inEnc, outEnc, format) {
|
||||||
if (typeof key !== 'string' && !isArrayBufferView(key)) {
|
if (typeof key !== 'string' && !isArrayBufferView(key)) {
|
||||||
throw new ERR_INVALID_ARG_TYPE(
|
throw new ERR_INVALID_ARG_TYPE(
|
||||||
|
@ -8,7 +8,6 @@ const {
|
|||||||
const {
|
const {
|
||||||
getDefaultEncoding,
|
getDefaultEncoding,
|
||||||
kHandle,
|
kHandle,
|
||||||
legacyNativeHandle,
|
|
||||||
toBuf
|
toBuf
|
||||||
} = require('internal/crypto/util');
|
} = require('internal/crypto/util');
|
||||||
|
|
||||||
@ -89,8 +88,6 @@ Hash.prototype.digest = function digest(outputEncoding) {
|
|||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
legacyNativeHandle(Hash);
|
|
||||||
|
|
||||||
|
|
||||||
function Hmac(hmac, key, options) {
|
function Hmac(hmac, key, options) {
|
||||||
if (!(this instanceof Hmac))
|
if (!(this instanceof Hmac))
|
||||||
@ -130,8 +127,6 @@ Hmac.prototype.digest = function digest(outputEncoding) {
|
|||||||
Hmac.prototype._flush = Hash.prototype._flush;
|
Hmac.prototype._flush = Hash.prototype._flush;
|
||||||
Hmac.prototype._transform = Hash.prototype._transform;
|
Hmac.prototype._transform = Hash.prototype._transform;
|
||||||
|
|
||||||
legacyNativeHandle(Hmac);
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Hash,
|
Hash,
|
||||||
Hmac
|
Hmac
|
||||||
|
@ -19,7 +19,6 @@ const {
|
|||||||
const {
|
const {
|
||||||
getDefaultEncoding,
|
getDefaultEncoding,
|
||||||
kHandle,
|
kHandle,
|
||||||
legacyNativeHandle,
|
|
||||||
toBuf,
|
toBuf,
|
||||||
validateArrayBufferView,
|
validateArrayBufferView,
|
||||||
} = require('internal/crypto/util');
|
} = require('internal/crypto/util');
|
||||||
@ -56,8 +55,6 @@ Sign.prototype.update = function update(data, encoding) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
legacyNativeHandle(Sign);
|
|
||||||
|
|
||||||
function getPadding(options) {
|
function getPadding(options) {
|
||||||
return getIntOption('padding', RSA_PKCS1_PADDING, options);
|
return getIntOption('padding', RSA_PKCS1_PADDING, options);
|
||||||
}
|
}
|
||||||
@ -166,8 +163,6 @@ Verify.prototype.verify = function verify(options, signature, sigEncoding) {
|
|||||||
rsaPadding, pssSaltLength);
|
rsaPadding, pssSaltLength);
|
||||||
};
|
};
|
||||||
|
|
||||||
legacyNativeHandle(Verify);
|
|
||||||
|
|
||||||
function verifyOneShot(algorithm, data, key, signature) {
|
function verifyOneShot(algorithm, data, key, signature) {
|
||||||
if (algorithm != null)
|
if (algorithm != null)
|
||||||
validateString(algorithm, 'algorithm');
|
validateString(algorithm, 'algorithm');
|
||||||
|
@ -21,7 +21,6 @@ const { validateString } = require('internal/validators');
|
|||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
const {
|
const {
|
||||||
cachedResult,
|
cachedResult,
|
||||||
deprecate,
|
|
||||||
filterDuplicateStrings
|
filterDuplicateStrings
|
||||||
} = require('internal/util');
|
} = require('internal/util');
|
||||||
const {
|
const {
|
||||||
@ -30,18 +29,6 @@ const {
|
|||||||
|
|
||||||
const kHandle = Symbol('kHandle');
|
const kHandle = Symbol('kHandle');
|
||||||
|
|
||||||
function legacyNativeHandle(clazz) {
|
|
||||||
Object.defineProperty(clazz.prototype, '_handle', {
|
|
||||||
get: deprecate(function() { return this[kHandle]; },
|
|
||||||
`${clazz.name}._handle is deprecated. Use the public API ` +
|
|
||||||
'instead.', 'DEP0117'),
|
|
||||||
set: deprecate(function(h) { this[kHandle] = h; },
|
|
||||||
`${clazz.name}._handle is deprecated. Use the public API ` +
|
|
||||||
'instead.', 'DEP0117'),
|
|
||||||
enumerable: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var defaultEncoding = 'buffer';
|
var defaultEncoding = 'buffer';
|
||||||
|
|
||||||
function setDefaultEncoding(val) {
|
function setDefaultEncoding(val) {
|
||||||
@ -116,7 +103,6 @@ module.exports = {
|
|||||||
getDefaultEncoding,
|
getDefaultEncoding,
|
||||||
getHashes,
|
getHashes,
|
||||||
kHandle,
|
kHandle,
|
||||||
legacyNativeHandle,
|
|
||||||
setDefaultEncoding,
|
setDefaultEncoding,
|
||||||
setEngine,
|
setEngine,
|
||||||
timingSafeEqual,
|
timingSafeEqual,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user