Skip to content

Commit 3ee2951

Browse files
committed
test: overlap SLH-DSA signature checks
Start each asynchronous signature before the synchronous checks for the same algorithm. Keep every sign, verify, and invalid-digest assertion, with only one asynchronous signature outstanding. This reduces elapsed time when CPU capacity is available without reducing coverage. Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: #65980 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name>
1 parent 78e9d47 commit 3ee2951

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

test/pummel/test-crypto-pqc-sign-verify-slh-dsa.mjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import { promisify } from 'node:util';
1313
import { randomBytes, sign, verify } from 'node:crypto';
1414
import fixtures from '../common/fixtures.js';
1515

16+
const pSign = promisify(sign);
17+
const pVerify = promisify(verify);
18+
1619
function getKeyFileName(type, suffix) {
1720
return `${type.replaceAll('-', '_')}_${suffix}.pem`;
1821
}
@@ -37,6 +40,8 @@ for (const [asymmetricKeyType, sigLen] of [
3740
};
3841

3942
const data = randomBytes(32);
43+
// Start the async signature before the sync work to overlap the two.
44+
const signaturePromise = pSign(undefined, data, keys.private);
4045

4146
// sync
4247
{
@@ -48,9 +53,7 @@ for (const [asymmetricKeyType, sigLen] of [
4853

4954
// async
5055
{
51-
const pSign = promisify(sign);
52-
const pVerify = promisify(verify);
53-
const signature = await pSign(undefined, data, keys.private);
56+
const signature = await signaturePromise;
5457
assert.strictEqual(signature.byteLength, sigLen);
5558
assert.strictEqual(await pVerify(undefined, randomBytes(32), keys.public, signature), false);
5659
assert.strictEqual(await pVerify(undefined, data, keys.public, signature), true);

0 commit comments

Comments
 (0)