summaryrefslogtreecommitdiff
path: root/lib/internal/crypto
diff options
context:
space:
mode:
authorDaniel Bevenius <daniel.bevenius@gmail.com>2019-06-20 08:09:17 +0200
committerDaniel Bevenius <daniel.bevenius@gmail.com>2019-06-24 05:36:40 +0200
commit882e8fea669911a008ccdddd889b92414ca68949 (patch)
tree6619e7c489761fe17fccf2e08933c2040bdb1889 /lib/internal/crypto
parent7fad0afd2c02496185a5aa5fab750b9d5cbab3bc (diff)
downloadandroid-node-v8-882e8fea669911a008ccdddd889b92414ca68949.tar.gz
android-node-v8-882e8fea669911a008ccdddd889b92414ca68949.tar.bz2
android-node-v8-882e8fea669911a008ccdddd889b92414ca68949.zip
crypto: move _scrypt call out of handleError funct
This commit moves the _scrypt function call out of the handleError function, which now only takes in an error object as its parameter. The motivation for this is to hopefully improve readability as it was not clear to me the first time I stepped through the code where the actual call to _scrypt was. PR-URL: https://github.com/nodejs/node/pull/28318 Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/crypto')
-rw-r--r--lib/internal/crypto/scrypt.js8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/internal/crypto/scrypt.js b/lib/internal/crypto/scrypt.js
index 0ed4140c9c..50a2bbc153 100644
--- a/lib/internal/crypto/scrypt.js
+++ b/lib/internal/crypto/scrypt.js
@@ -44,7 +44,7 @@ function scrypt(password, salt, keylen, options, callback = defaults) {
callback.call(wrap, null, keybuf.toString(encoding));
};
- handleError(keybuf, password, salt, N, r, p, maxmem, wrap);
+ handleError(_scrypt(keybuf, password, salt, N, r, p, maxmem, wrap));
}
function scryptSync(password, salt, keylen, options = defaults) {
@@ -52,15 +52,13 @@ function scryptSync(password, salt, keylen, options = defaults) {
const { N, r, p, maxmem } = options;
({ password, salt, keylen } = options);
const keybuf = Buffer.alloc(keylen);
- handleError(keybuf, password, salt, N, r, p, maxmem);
+ handleError(_scrypt(keybuf, password, salt, N, r, p, maxmem));
const encoding = getDefaultEncoding();
if (encoding === 'buffer') return keybuf;
return keybuf.toString(encoding);
}
-function handleError(keybuf, password, salt, N, r, p, maxmem, wrap) {
- const ex = _scrypt(keybuf, password, salt, N, r, p, maxmem, wrap);
-
+function handleError(ex) {
if (ex === undefined)
return;