Skip to content

Commit

Permalink
crypto: remove default encoding from pbkdf2
Browse files Browse the repository at this point in the history
Refs: #47182
PR-URL: #47869
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
tniessen authored and targos committed May 12, 2023
1 parent 93f1aa2 commit e9c6ee7
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/internal/crypto/pbkdf2.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const {

const {
getArrayBufferOrView,
getDefaultEncoding,
normalizeHashName,
kKeyObject,
} = require('internal/crypto/util');
Expand Down Expand Up @@ -49,14 +48,11 @@ function pbkdf2(password, salt, iterations, keylen, digest, callback) {
keylen,
digest);

const encoding = getDefaultEncoding();
job.ondone = (err, result) => {
if (err !== undefined)
return FunctionPrototypeCall(callback, job, err);
const buf = Buffer.from(result);
if (encoding === 'buffer')
return FunctionPrototypeCall(callback, job, null, buf);
FunctionPrototypeCall(callback, job, null, buf.toString(encoding));
return FunctionPrototypeCall(callback, job, null, buf);
};

job.run();
Expand All @@ -78,9 +74,7 @@ function pbkdf2Sync(password, salt, iterations, keylen, digest) {
if (err !== undefined)
throw err;

const buf = Buffer.from(result);
const encoding = getDefaultEncoding();
return encoding === 'buffer' ? buf : buf.toString(encoding);
return Buffer.from(result);
}

function check(password, salt, iterations, keylen, digest) {
Expand Down

0 comments on commit e9c6ee7

Please sign in to comment.