From ef175d014c5b050d05d61d3067845573da7eeb24 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Thu, 16 Jan 2025 20:47:40 +0000 Subject: [PATCH] Fix test:kdf --- .github/workflows/test-slow.yml | 4 ++-- package.json | 2 +- test/slow-kdf.test.js | 11 ++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-slow.yml b/.github/workflows/test-slow.yml index 891ea4e..d99e42c 100644 --- a/.github/workflows/test-slow.yml +++ b/.github/workflows/test-slow.yml @@ -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: @@ -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 diff --git a/package.json b/package.json index fc8977a..d09f89b 100644 --- a/package.json +++ b/package.json @@ -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)", diff --git a/test/slow-kdf.test.js b/test/slow-kdf.test.js index fa25740..10d78ee 100644 --- a/test/slow-kdf.test.js +++ b/test/slow-kdf.test.js @@ -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), @@ -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, {