From 50aa85dc9bf47c7fad280aba40401a14c81a1aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Fri, 24 Aug 2018 10:37:45 +0200 Subject: [PATCH] crypto: deprecate _toBuf PR-URL: https://github.com/nodejs/node/pull/22501 Fixes: https://github.com/nodejs/node/issues/22425 Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Benjamin Gruenbaum Reviewed-By: Anna Henningsen Reviewed-By: Denys Otrishko --- doc/api/deprecations.md | 8 ++++++++ lib/crypto.js | 2 +- test/parallel/test-crypto.js | 12 ++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 56935574e6186c..7aa8ac01ba6bd4 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -1031,6 +1031,14 @@ With the current crypto API, having `Cipher.setAuthTag()` and when called. They have never been documented and will be removed in a future release. + +### DEP0114: crypto._toBuf() + +Type: Runtime + +The `crypto._toBuf()` function was not designed to be used by modules outside +of Node.js core and will be removed in the future. + [`--pending-deprecation`]: cli.html#cli_pending_deprecation [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size [`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array diff --git a/lib/crypto.js b/lib/crypto.js index bced9f040a6b4d..c2d3eb38cff0dd 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -137,7 +137,7 @@ function createVerify(algorithm, options) { module.exports = exports = { // Methods - _toBuf: toBuf, + _toBuf: deprecate(toBuf, 'crypto._toBuf is deprecated.', 'DEP0114'), createCipheriv, createDecipheriv, createDiffieHellman, diff --git a/test/parallel/test-crypto.js b/test/parallel/test-crypto.js index 88d49167100fbe..1f02c07b02eb2f 100644 --- a/test/parallel/test-crypto.js +++ b/test/parallel/test-crypto.js @@ -25,6 +25,13 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +common.expectWarning({ + DeprecationWarning: [ + ['crypto.createCipher is deprecated.', 'DEP0106'], + ['crypto._toBuf is deprecated.', 'DEP0114'] + ] +}); + const assert = require('assert'); const crypto = require('crypto'); const tls = require('tls'); @@ -294,3 +301,8 @@ testEncoding({ testEncoding({ defaultEncoding: 'latin1' }, assertionHashLatin1); + +{ + // Test that the exported _toBuf function is deprecated. + crypto._toBuf(Buffer.alloc(0)); +}