Skip to content

Commit

Permalink
Fix test generator for kdf
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Oct 3, 2024
1 parent 5da947e commit 8a468a5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ function executeKDFTests(limit = true) {
should('PBKDF2(sha256) generator', async () => {
const cases = genl({
c: integer(1, 1024),
dkLen: integer(0, 1024),
dkLen: integer(1, 1024),
pwd: bytes(0, 1024),
salt: bytes(0, 1024),
});
for (let c of cases) {
// console.log('T', c);
if (c.dkLen === 0) continue;
// if (c.dkLen === 0) continue;
const exp = Uint8Array.from(crypto.pbkdf2Sync(c.pwd, c.salt, c.c, c.dkLen, 'sha256'));
const opt = { c: c.c, dkLen: c.dkLen };
assert.deepStrictEqual(pbkdf2(sha256, c.pwd, c.salt, opt), exp, `pbkdf2(sha256, ${opt})`);
Expand All @@ -105,11 +105,12 @@ function executeKDFTests(limit = true) {
should('PBKDF2(sha512) generator', async () => {
const cases = genl({
c: integer(1, 1024),
dkLen: integer(0, 1024),
dkLen: integer(1, 1024),
pwd: bytes(0, 1024),
salt: bytes(0, 1024),
});
for (let c of cases) {
// if (c.dkLen === 0) continue;
const exp = Uint8Array.from(crypto.pbkdf2Sync(c.pwd, c.salt, c.c, c.dkLen, 'sha512'));
const opt = { c: c.c, dkLen: c.dkLen };
assert.deepStrictEqual(pbkdf2(sha512, c.pwd, c.salt, opt), exp, `pbkdf2(sha512, ${opt})`);
Expand All @@ -124,7 +125,7 @@ function executeKDFTests(limit = true) {
should('PBKDF2(sha3_256) generator', async () => {
const cases = genl({
c: integer(1, 1024),
dkLen: integer(0, 1024),
dkLen: integer(1, 1024),
pwd: bytes(0, 1024),
salt: bytes(0, 1024),
});
Expand All @@ -143,7 +144,7 @@ function executeKDFTests(limit = true) {
should('PBKDF2(sha3_512) generator', async () => {
const cases = genl({
c: integer(1, 1024),
dkLen: integer(0, 1024),
dkLen: integer(1, 1024),
pwd: bytes(0, 1024),
salt: bytes(0, 1024),
});
Expand Down Expand Up @@ -186,7 +187,7 @@ function executeKDFTests(limit = true) {
should('PBKDF2(blake2s) generator', async () => {
const cases = genl({
c: integer(1, 1024),
dkLen: integer(0, 1024),
dkLen: integer(1, 1024),
pwd: bytes(0, 1024),
salt: bytes(0, 1024),
});
Expand All @@ -205,7 +206,7 @@ function executeKDFTests(limit = true) {
should('PBKDF2(blake2b) generator', async () => {
const cases = genl({
c: integer(1, 1024),
dkLen: integer(0, 1024),
dkLen: integer(1, 1024),
pwd: bytes(0, 1024),
salt: bytes(0, 1024),
});
Expand Down

0 comments on commit 8a468a5

Please sign in to comment.