crypto: pbkdf2 throws when no callback provided
This commit is contained in:
parent
f3621359f4
commit
d7da20c812
@ -458,6 +458,19 @@ DiffieHellman.prototype.setPrivateKey = function(key, encoding) {
|
||||
|
||||
|
||||
exports.pbkdf2 = function(password, salt, iterations, keylen, callback) {
|
||||
if (typeof callback !== 'function')
|
||||
throw new Error('No callback provided to pbkdf2');
|
||||
|
||||
return pbkdf2(password, salt, iterations, keylen, callback);
|
||||
};
|
||||
|
||||
|
||||
exports.pbkdf2Sync = function(password, salt, iterations, keylen) {
|
||||
return pbkdf2(password, salt, iterations, keylen);
|
||||
};
|
||||
|
||||
|
||||
function pbkdf2(password, salt, iterations, keylen, callback) {
|
||||
password = toBuf(password);
|
||||
salt = toBuf(salt);
|
||||
|
||||
@ -476,11 +489,8 @@ exports.pbkdf2 = function(password, salt, iterations, keylen, callback) {
|
||||
var ret = binding.PBKDF2(password, salt, iterations, keylen);
|
||||
return ret.toString(encoding);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.pbkdf2Sync = function(password, salt, iterations, keylen) {
|
||||
return exports.pbkdf2(password, salt, iterations, keylen);
|
||||
};
|
||||
|
||||
|
||||
exports.randomBytes = randomBytes;
|
||||
|
@ -657,7 +657,7 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
|
||||
// Test PBKDF2 with RFC 6070 test vectors (except #4)
|
||||
//
|
||||
function testPBKDF2(password, salt, iterations, keylen, expected) {
|
||||
var actual = crypto.pbkdf2(password, salt, iterations, keylen);
|
||||
var actual = crypto.pbkdf2Sync(password, salt, iterations, keylen);
|
||||
assert.equal(actual, expected);
|
||||
|
||||
crypto.pbkdf2(password, salt, iterations, keylen, function(err, actual) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user