Skip to content

Commit 7ecdaa2

Browse files
committed
use test vectors for pbkdf2
1 parent e03a512 commit 7ecdaa2

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

test/pbkdf2.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11

22
var tape = require('tape')
3-
var pbkdf2 = require('../').pbkdf2
4-
var crypto = require('crypto')
3+
var pbkdf2Sync = require('../').pbkdf2Sync
4+
5+
var vectors = require('hash-test-vectors/pbkdf2')
56

67
tape('pbkdf2', function (t) {
7-
pbkdf2('hello', 'salt', 1000, 20, function (err, key) {
8-
if(err) throw err
9-
t.deepEqual(key.toString('hex'), crypto.pbkdf2Sync('hello', 'salt', 1000, 20).toString('hex'))
10-
t.end()
8+
vectors.forEach(function (input) {
9+
var key = pbkdf2Sync(input.password, input.salt, input.iterations, input.length)
10+
11+
if(key.toString('hex') !== input.sha1)
12+
console.log(input)
13+
14+
t.equal(key.toString('hex'), input.sha1)
15+
16+
1117
})
18+
19+
t.end()
1220
})

0 commit comments

Comments
 (0)