Skip to content

Commit 25220f0

Browse files
MaleDongtargos
MaleDong
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 5660759 commit 25220f0

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

doc/api/crypto.md

+6
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,9 @@ otherwise `err` will be `null`. By default, the successfully generated
18081808
`derivedKey` will be passed to the callback as a [`Buffer`][]. An error will be
18091809
thrown if any of the input arguments specify invalid values or types.
18101810

1811+
If `digest` is `null`, `'sha1'` will be used. This behavior will be deprecated
1812+
in a future version of Node.js.
1813+
18111814
The `iterations` argument must be a number set as high as possible. The
18121815
higher the number of iterations, the more secure the derived key will be,
18131816
but will take a longer amount of time to complete.
@@ -1871,6 +1874,9 @@ applied to derive a key of the requested byte length (`keylen`) from the
18711874
If an error occurs an `Error` will be thrown, otherwise the derived key will be
18721875
returned as a [`Buffer`][].
18731876

1877+
If `digest` is `null`, `'sha1'` will be used. This behavior will be deprecated
1878+
in a future version of Node.js.
1879+
18741880
The `iterations` argument must be a number set as high as possible. The
18751881
higher the number of iterations, the more secure the derived key will be,
18761882
but will take a longer amount of time to complete.

lib/internal/crypto/pbkdf2.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function pbkdf2(password, salt, iterations, keylen, digest, callback) {
2222
}
2323

2424
({ password, salt, iterations, keylen, digest } =
25-
check(password, salt, iterations, keylen, digest, callback));
25+
check(password, salt, iterations, keylen, digest));
2626

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

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

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

0 commit comments

Comments
 (0)