Skip to content

Commit

Permalink
crypto: deprecate _toBuf
Browse files Browse the repository at this point in the history
PR-URL: #22501
Fixes: #22425
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
  • Loading branch information
tniessen committed Aug 27, 2018
1 parent fa3d6be commit 50aa85d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
<a id="DEP0114"></a>
### 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
Expand Down
2 changes: 1 addition & 1 deletion lib/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions test/parallel/test-crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -294,3 +301,8 @@ testEncoding({
testEncoding({
defaultEncoding: 'latin1'
}, assertionHashLatin1);

{
// Test that the exported _toBuf function is deprecated.
crypto._toBuf(Buffer.alloc(0));
}

0 comments on commit 50aa85d

Please sign in to comment.