summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Bevenius <daniel.bevenius@gmail.com>2019-06-20 08:09:17 +0200
committerMichaël Zasso <targos@protonmail.com>2019-07-02 09:07:53 +0200
commitdef96ae278bcf0437c5fb345a234f8c1a1076b5b (patch)
tree962d2068e760a03cd49237e9851d096adad92c8c /lib
parented8cee6b1a240a86d6495145fd180db679c88be6 (diff)
downloadandroid-node-v8-def96ae278bcf0437c5fb345a234f8c1a1076b5b.tar.gz
android-node-v8-def96ae278bcf0437c5fb345a234f8c1a1076b5b.tar.bz2
android-node-v8-def96ae278bcf0437c5fb345a234f8c1a1076b5b.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')
-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;