Skip to content

Commit

Permalink
Fix test:kdf
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Jan 16, 2025
1 parent 572952a commit ef175d0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-slow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- run: npm install
- run: npm run build --if-present
- run: npm run test:big
slowkdf:
kdf:
name: Test slow KDFs
runs-on: ubuntu-latest
env:
Expand All @@ -51,4 +51,4 @@ jobs:
cache: npm
- run: npm install
- run: npm run build --if-present
- run: npm run test:slowkdf
- run: npm run test:kdf
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"test": "node --import ./test/esm-register.js test/index.js",
"test:dos": "node --import ./test/esm-register.js test/slow-dos.test.js",
"test:big": "node --import ./test/esm-register.js test/slow-big.test.js",
"test:slowkdf": "node --import ./test/esm-register.js test/slow-kdf.test.js",
"test:kdf": "node --import ./test/esm-register.js test/slow-kdf.test.js",
"test:coverage": "c8 npm test"
},
"author": "Paul Miller (https://paulmillr.com)",
Expand Down
11 changes: 10 additions & 1 deletion test/slow-kdf.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ import { describe, should } from 'micro-should';
import { bytes, integer, gen, serializeCase } from './generator.js';
import { scrypt, scryptAsync } from '../esm/scrypt.js';
import { argon2i, argon2d, argon2id } from '../esm/argon2.js';
import { argon2iAsync, argon2dAsync, argon2idAsync } from '../esm/argon2.js';
import { bytesToHex } from '../esm/utils.js';
import { json, pattern } from './utils.js';

const argon2_vectors = json('./vectors/argon2.json');

// Some vectors are very slow and are ran in slow-big.test.js.

const asyncMap = new Map([
[argon2i, argon2iAsync],
[argon2d, argon2dAsync],
[argon2id, argon2idAsync],
]);

// Takes 10h
const SCRYPT_CASES = gen({
N: integer(1, 10),
Expand Down Expand Up @@ -83,7 +92,7 @@ for (let i = 0; i < verySlowArgon.length; i++) {
const v = verySlowArgon[i];
const ver = v.version || 0x13;
const str = `m=${v.m}, t=${v.t}, p=${v.p}`;
const title = `${v.fn.name}/v${ver} ${str} (#${i})`;
const title = `argon #${i} ${v.fn.name}/v${ver} ${str}`;
should(title, () => {
const res = bytesToHex(
v.fn(v.password, v.salt, {
Expand Down

0 comments on commit ef175d0

Please sign in to comment.