Skip to content

Commit 50aa85d

Browse files
committed
crypto: deprecate _toBuf
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>
1 parent fa3d6be commit 50aa85d

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

doc/api/deprecations.md

+8
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,14 @@ With the current crypto API, having `Cipher.setAuthTag()` and
10311031
when called. They have never been documented and will be removed in a future
10321032
release.
10331033
1034+
<a id="DEP0114"></a>
1035+
### DEP0114: crypto._toBuf()
1036+
1037+
Type: Runtime
1038+
1039+
The `crypto._toBuf()` function was not designed to be used by modules outside
1040+
of Node.js core and will be removed in the future.
1041+
10341042
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
10351043
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
10361044
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array

lib/crypto.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function createVerify(algorithm, options) {
137137

138138
module.exports = exports = {
139139
// Methods
140-
_toBuf: toBuf,
140+
_toBuf: deprecate(toBuf, 'crypto._toBuf is deprecated.', 'DEP0114'),
141141
createCipheriv,
142142
createDecipheriv,
143143
createDiffieHellman,

test/parallel/test-crypto.js

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ const common = require('../common');
2525
if (!common.hasCrypto)
2626
common.skip('missing crypto');
2727

28+
common.expectWarning({
29+
DeprecationWarning: [
30+
['crypto.createCipher is deprecated.', 'DEP0106'],
31+
['crypto._toBuf is deprecated.', 'DEP0114']
32+
]
33+
});
34+
2835
const assert = require('assert');
2936
const crypto = require('crypto');
3037
const tls = require('tls');
@@ -294,3 +301,8 @@ testEncoding({
294301
testEncoding({
295302
defaultEncoding: 'latin1'
296303
}, assertionHashLatin1);
304+
305+
{
306+
// Test that the exported _toBuf function is deprecated.
307+
crypto._toBuf(Buffer.alloc(0));
308+
}

0 commit comments

Comments
 (0)