diff options
author | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-04-25 09:11:37 +0200 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-04-26 07:48:56 +0200 |
commit | 20612486d9c56b4e1f3c8f28b9edd827ceaa0500 (patch) | |
tree | 267dc9701e5a597b4de30fa4cc03e19fc876fdf2 /lib | |
parent | fe70af90726b8105b10e172996561685133e4662 (diff) | |
download | android-node-v8-20612486d9c56b4e1f3c8f28b9edd827ceaa0500.tar.gz android-node-v8-20612486d9c56b4e1f3c8f28b9edd827ceaa0500.tar.bz2 android-node-v8-20612486d9c56b4e1f3c8f28b9edd827ceaa0500.zip |
crypto: make pbkdf2 use checkIsArrayBufferView
This commit updates pbkdf2 to use checkIsArrayBufferView from
internal/crypto/util.
PR-URL: https://github.com/nodejs/node/pull/20251
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/crypto/pbkdf2.js | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/lib/internal/crypto/pbkdf2.js b/lib/internal/crypto/pbkdf2.js index 4a7f26b509..82ea9feb85 100644 --- a/lib/internal/crypto/pbkdf2.js +++ b/lib/internal/crypto/pbkdf2.js @@ -7,10 +7,10 @@ const { ERR_OUT_OF_RANGE } = require('internal/errors').codes; const { + checkIsArrayBufferView, getDefaultEncoding, toBuf } = require('internal/crypto/util'); -const { isArrayBufferView } = require('internal/util/types'); const { PBKDF2 } = process.binding('crypto'); @@ -39,19 +39,8 @@ function _pbkdf2(password, salt, iterations, keylen, digest, callback) { if (digest !== null && typeof digest !== 'string') throw new ERR_INVALID_ARG_TYPE('digest', ['string', 'null'], digest); - password = toBuf(password); - salt = toBuf(salt); - - if (!isArrayBufferView(password)) { - throw new ERR_INVALID_ARG_TYPE('password', - ['string', 'Buffer', 'TypedArray'], - password); - } - - if (!isArrayBufferView(salt)) { - throw new ERR_INVALID_ARG_TYPE('salt', - ['string', 'Buffer', 'TypedArray'], salt); - } + password = checkIsArrayBufferView('password', toBuf(password)); + salt = checkIsArrayBufferView('salt', toBuf(salt)); if (typeof iterations !== 'number') throw new ERR_INVALID_ARG_TYPE('iterations', 'number', iterations); |