diff options
Diffstat (limited to 'node_modules/pbkdf2/lib/precondition.js')
-rw-r--r-- | node_modules/pbkdf2/lib/precondition.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/node_modules/pbkdf2/lib/precondition.js b/node_modules/pbkdf2/lib/precondition.js index 1519b0092..683db5630 100644 --- a/node_modules/pbkdf2/lib/precondition.js +++ b/node_modules/pbkdf2/lib/precondition.js @@ -1,5 +1,15 @@ var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs -module.exports = function (iterations, keylen) { + +function checkBuffer (buf, name) { + if (typeof buf !== 'string' && !Buffer.isBuffer(buf)) { + throw new TypeError(name + ' must be a buffer or string') + } +} + +module.exports = function (password, salt, iterations, keylen) { + checkBuffer(password, 'Password') + checkBuffer(salt, 'Salt') + if (typeof iterations !== 'number') { throw new TypeError('Iterations not a number') } |