Skip to content

Commit ba0b4e4

Browse files
MaleDongtniessen
authored andcommitted
lib,doc: remove unused parameter, improve docs
1) Remove 'callback' in 'check' function, because we don't check or use that directly. 2) Make 'digest' clearer in the documentation. PR-URL: #22858 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 8989c76 commit ba0b4e4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

doc/api/crypto.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,9 @@ otherwise `err` will be `null`. By default, the successfully generated
17861786
`derivedKey` will be passed to the callback as a [`Buffer`][]. An error will be
17871787
thrown if any of the input arguments specify invalid values or types.
17881788

1789+
If `digest` is `null`, `'sha1'` will be used. This behavior will be deprecated
1790+
in a future version of Node.js.
1791+
17891792
The `iterations` argument must be a number set as high as possible. The
17901793
higher the number of iterations, the more secure the derived key will be,
17911794
but will take a longer amount of time to complete.
@@ -1849,6 +1852,9 @@ applied to derive a key of the requested byte length (`keylen`) from the
18491852
If an error occurs an `Error` will be thrown, otherwise the derived key will be
18501853
returned as a [`Buffer`][].
18511854

1855+
If `digest` is `null`, `'sha1'` will be used. This behavior will be deprecated
1856+
in a future version of Node.js.
1857+
18521858
The `iterations` argument must be a number set as high as possible. The
18531859
higher the number of iterations, the more secure the derived key will be,
18541860
but will take a longer amount of time to complete.

lib/internal/crypto/pbkdf2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function pbkdf2(password, salt, iterations, keylen, digest, callback) {
2323
}
2424

2525
({ password, salt, iterations, keylen, digest } =
26-
check(password, salt, iterations, keylen, digest, callback));
26+
check(password, salt, iterations, keylen, digest));
2727

2828
if (typeof callback !== 'function')
2929
throw new ERR_INVALID_CALLBACK();
@@ -43,15 +43,15 @@ function pbkdf2(password, salt, iterations, keylen, digest, callback) {
4343

4444
function pbkdf2Sync(password, salt, iterations, keylen, digest) {
4545
({ password, salt, iterations, keylen, digest } =
46-
check(password, salt, iterations, keylen, digest, pbkdf2Sync));
46+
check(password, salt, iterations, keylen, digest));
4747
const keybuf = Buffer.alloc(keylen);
4848
handleError(keybuf, password, salt, iterations, digest);
4949
const encoding = getDefaultEncoding();
5050
if (encoding === 'buffer') return keybuf;
5151
return keybuf.toString(encoding);
5252
}
5353

54-
function check(password, salt, iterations, keylen, digest, callback) {
54+
function check(password, salt, iterations, keylen, digest) {
5555
if (typeof digest !== 'string') {
5656
if (digest !== null)
5757
throw new ERR_INVALID_ARG_TYPE('digest', ['string', 'null'], digest);

0 commit comments

Comments
 (0)