Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: updated to const and strictEqual
Upadted all var to const/let and updated assert.equal to
assert.strictEqual
  • Loading branch information
ghvaldez committed Dec 1, 2016
commit f3e3d79027bd4638d9756502f3b31e234ab28b7e
21 changes: 11 additions & 10 deletions test/parallel/test-crypto-pbkdf2.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
'use strict';
var common = require('../common');
var assert = require('assert');
const common = require('../common');
const assert = require('assert');

if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
var crypto = require('crypto');
const crypto = require('crypto');

//
// Test PBKDF2 with RFC 6070 test vectors (except #4)
//
function testPBKDF2(password, salt, iterations, keylen, expected) {
var actual = crypto.pbkdf2Sync(password, salt, iterations, keylen, 'sha256');
assert.equal(actual.toString('latin1'), expected);
const actual =
crypto.pbkdf2Sync(password, salt, iterations, keylen, 'sha256');
assert.strictEqual(actual.toString('latin1'), expected);

crypto.pbkdf2(password, salt, iterations, keylen, 'sha256', (err, actual) => {
assert.equal(actual.toString('latin1'), expected);
assert.strictEqual(actual.toString('latin1'), expected);
});
}

Expand Down Expand Up @@ -44,15 +45,15 @@ testPBKDF2('pass\0word', 'sa\0lt', 4096, 16,
'\x89\xb6\x9d\x05\x16\xf8\x29\x89\x3c\x69\x62\x26\x65' +
'\x0a\x86\x87');

var expected =
const expected =
'64c486c55d30d4c5a079b8823b7d7cb37ff0556f537da8410233bcec330ed956';
var key = crypto.pbkdf2Sync('password', 'salt', 32, 32, 'sha256');
assert.equal(key.toString('hex'), expected);
const key = crypto.pbkdf2Sync('password', 'salt', 32, 32, 'sha256');
assert.strictEqual(key.toString('hex'), expected);

crypto.pbkdf2('password', 'salt', 32, 32, 'sha256', common.mustCall(ondone));
function ondone(err, key) {
if (err) throw err;
assert.equal(key.toString('hex'), expected);
assert.strictEqual(key.toString('hex'), expected);
}

// Error path should not leak memory (check with valgrind).
Expand Down