@quantakrypto/sieve 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +227 -0
- package/dist/categories/correctness.d.ts +13 -0
- package/dist/categories/correctness.d.ts.map +1 -0
- package/dist/categories/correctness.js +78 -0
- package/dist/categories/correctness.js.map +1 -0
- package/dist/categories/determinism.d.ts +12 -0
- package/dist/categories/determinism.d.ts.map +1 -0
- package/dist/categories/determinism.js +78 -0
- package/dist/categories/determinism.js.map +1 -0
- package/dist/categories/dsa.d.ts +17 -0
- package/dist/categories/dsa.d.ts.map +1 -0
- package/dist/categories/dsa.js +17 -0
- package/dist/categories/dsa.js.map +1 -0
- package/dist/categories/helpers.d.ts +50 -0
- package/dist/categories/helpers.d.ts.map +1 -0
- package/dist/categories/helpers.js +127 -0
- package/dist/categories/helpers.js.map +1 -0
- package/dist/categories/implicit-rejection.d.ts +29 -0
- package/dist/categories/implicit-rejection.d.ts.map +1 -0
- package/dist/categories/implicit-rejection.js +126 -0
- package/dist/categories/implicit-rejection.js.map +1 -0
- package/dist/categories/index.d.ts +30 -0
- package/dist/categories/index.d.ts.map +1 -0
- package/dist/categories/index.js +33 -0
- package/dist/categories/index.js.map +1 -0
- package/dist/categories/kat.d.ts +21 -0
- package/dist/categories/kat.d.ts.map +1 -0
- package/dist/categories/kat.js +173 -0
- package/dist/categories/kat.js.map +1 -0
- package/dist/categories/robustness.d.ts +15 -0
- package/dist/categories/robustness.d.ts.map +1 -0
- package/dist/categories/robustness.js +98 -0
- package/dist/categories/robustness.js.map +1 -0
- package/dist/categories/signature.d.ts +29 -0
- package/dist/categories/signature.d.ts.map +1 -0
- package/dist/categories/signature.js +259 -0
- package/dist/categories/signature.js.map +1 -0
- package/dist/categories/sizes.d.ts +23 -0
- package/dist/categories/sizes.d.ts.map +1 -0
- package/dist/categories/sizes.js +150 -0
- package/dist/categories/sizes.js.map +1 -0
- package/dist/categories/slh-dsa.d.ts +23 -0
- package/dist/categories/slh-dsa.d.ts.map +1 -0
- package/dist/categories/slh-dsa.js +23 -0
- package/dist/categories/slh-dsa.js.map +1 -0
- package/dist/categories/timing.d.ts +16 -0
- package/dist/categories/timing.d.ts.map +1 -0
- package/dist/categories/timing.js +98 -0
- package/dist/categories/timing.js.map +1 -0
- package/dist/categories/types.d.ts +68 -0
- package/dist/categories/types.d.ts.map +1 -0
- package/dist/categories/types.js +31 -0
- package/dist/categories/types.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +181 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +169 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +115 -0
- package/dist/protocol.js.map +1 -0
- package/dist/report.d.ts +48 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +79 -0
- package/dist/report.js.map +1 -0
- package/dist/runner.d.ts +129 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +305 -0
- package/dist/runner.js.map +1 -0
- package/dist/sizes.d.ts +84 -0
- package/dist/sizes.d.ts.map +1 -0
- package/dist/sizes.js +214 -0
- package/dist/sizes.js.map +1 -0
- package/dist/vectors.d.ts +69 -0
- package/dist/vectors.d.ts.map +1 -0
- package/dist/vectors.js +198 -0
- package/dist/vectors.js.map +1 -0
- package/package.json +43 -0
- package/vectors/README.md +83 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../../src/categories/timing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAkD,IAAI,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,C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C,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC;QAC5B,CAAC,CAAC,CAAE,MAAM,CAAC,GAAG,GAAG,CAAC,CAAY,GAAI,MAAM,CAAC,GAAG,CAAY,CAAC,GAAG,CAAC;QAC7D,CAAC,CAAE,MAAM,CAAC,GAAG,CAAY,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared result types for test categories.
|
|
3
|
+
*
|
|
4
|
+
* Every category is an async function that drives a {@link Runner} and returns
|
|
5
|
+
* a {@link CategoryResult}. Categories never throw for *expected* SUT failures;
|
|
6
|
+
* they record them as failing checks. They only throw for harness-level faults
|
|
7
|
+
* (e.g. inability to spawn), which the report layer surfaces as an "error".
|
|
8
|
+
*/
|
|
9
|
+
import type { Runner } from "../runner.js";
|
|
10
|
+
import type { Sizes } from "../sizes.js";
|
|
11
|
+
/** Status of a single check or a whole category. */
|
|
12
|
+
export type Status = "pass" | "fail" | "skip";
|
|
13
|
+
/**
|
|
14
|
+
* A bug-class tag linking a category/check to quantakrypto's antiform taxonomy.
|
|
15
|
+
*
|
|
16
|
+
* - AF-02: implicit-rejection / Fujisaki-Okamoto reject-path mistakes.
|
|
17
|
+
* - AF-05: size/format confusion (wrong-length artifacts accepted/emitted).
|
|
18
|
+
*/
|
|
19
|
+
export type BugClass = "AF-02" | "AF-05" | undefined;
|
|
20
|
+
/** One atomic assertion within a category. */
|
|
21
|
+
export interface Check {
|
|
22
|
+
/** Short name, unique within its category. */
|
|
23
|
+
name: string;
|
|
24
|
+
status: Status;
|
|
25
|
+
/** Human-readable detail (why it passed/failed/was skipped). */
|
|
26
|
+
detail: string;
|
|
27
|
+
/** Optional bug-class tag. */
|
|
28
|
+
bugClass?: BugClass;
|
|
29
|
+
}
|
|
30
|
+
/** The aggregate outcome of running one category. */
|
|
31
|
+
export interface CategoryResult {
|
|
32
|
+
/** Category identifier, e.g. "correctness". */
|
|
33
|
+
category: string;
|
|
34
|
+
/** Rolled-up status: fail if any check failed, else pass; all-skip => skip. */
|
|
35
|
+
status: Status;
|
|
36
|
+
/** Bug class this category primarily exercises, if any. */
|
|
37
|
+
bugClass?: BugClass;
|
|
38
|
+
/** Individual checks. */
|
|
39
|
+
checks: Check[];
|
|
40
|
+
/** Free-form summary line. */
|
|
41
|
+
summary: string;
|
|
42
|
+
}
|
|
43
|
+
/** Context handed to every category. */
|
|
44
|
+
export interface CategoryContext {
|
|
45
|
+
runner: Runner;
|
|
46
|
+
sizes: Sizes;
|
|
47
|
+
/** Number of randomized iterations to perform (where applicable). */
|
|
48
|
+
iterations: number;
|
|
49
|
+
/**
|
|
50
|
+
* Max concurrent in-flight requests for categories that issue many
|
|
51
|
+
* INDEPENDENT requests (via {@link Runner.sendMany}). Default 16 when unset.
|
|
52
|
+
* Categories with dependent/ordered ops ignore this and use serial `send`.
|
|
53
|
+
*/
|
|
54
|
+
pipelineDepth?: number;
|
|
55
|
+
/** Optional directory of official ACVP/KAT vectors (kat category only). */
|
|
56
|
+
vectorsDir?: string;
|
|
57
|
+
}
|
|
58
|
+
/** A category is a named driver producing one {@link CategoryResult}. */
|
|
59
|
+
export type Category = (ctx: CategoryContext) => Promise<CategoryResult>;
|
|
60
|
+
/** Roll a list of checks up into a category-level status. */
|
|
61
|
+
export declare function rollUp(checks: readonly Check[]): Status;
|
|
62
|
+
/** Convenience constructor for a passing check. */
|
|
63
|
+
export declare function pass(name: string, detail: string, bugClass?: BugClass): Check;
|
|
64
|
+
/** Convenience constructor for a failing check. */
|
|
65
|
+
export declare function fail(name: string, detail: string, bugClass?: BugClass): Check;
|
|
66
|
+
/** Convenience constructor for a skipped check. */
|
|
67
|
+
export declare function skip(name: string, detail: string, bugClass?: BugClass): Check;
|
|
68
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/categories/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,oDAAoD;AACpD,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AAErD,8CAA8C;AAC9C,MAAM,WAAW,KAAK;IACpB,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,yBAAyB;IACzB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,yEAAyE;AACzE,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;AAEzE,6DAA6D;AAC7D,wBAAgB,MAAM,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,MAAM,CAKvD;AAED,mDAAmD;AACnD,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,CAE7E;AAED,mDAAmD;AACnD,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,CAE7E;AAED,mDAAmD;AACnD,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,CAE7E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared result types for test categories.
|
|
3
|
+
*
|
|
4
|
+
* Every category is an async function that drives a {@link Runner} and returns
|
|
5
|
+
* a {@link CategoryResult}. Categories never throw for *expected* SUT failures;
|
|
6
|
+
* they record them as failing checks. They only throw for harness-level faults
|
|
7
|
+
* (e.g. inability to spawn), which the report layer surfaces as an "error".
|
|
8
|
+
*/
|
|
9
|
+
/** Roll a list of checks up into a category-level status. */
|
|
10
|
+
export function rollUp(checks) {
|
|
11
|
+
if (checks.length === 0)
|
|
12
|
+
return "skip";
|
|
13
|
+
if (checks.some((c) => c.status === "fail"))
|
|
14
|
+
return "fail";
|
|
15
|
+
if (checks.every((c) => c.status === "skip"))
|
|
16
|
+
return "skip";
|
|
17
|
+
return "pass";
|
|
18
|
+
}
|
|
19
|
+
/** Convenience constructor for a passing check. */
|
|
20
|
+
export function pass(name, detail, bugClass) {
|
|
21
|
+
return { name, status: "pass", detail, bugClass };
|
|
22
|
+
}
|
|
23
|
+
/** Convenience constructor for a failing check. */
|
|
24
|
+
export function fail(name, detail, bugClass) {
|
|
25
|
+
return { name, status: "fail", detail, bugClass };
|
|
26
|
+
}
|
|
27
|
+
/** Convenience constructor for a skipped check. */
|
|
28
|
+
export function skip(name, detail, bugClass) {
|
|
29
|
+
return { name, status: "skip", detail, bugClass };
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/categories/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA4DH,6DAA6D;AAC7D,MAAM,UAAU,MAAM,CAAC,MAAwB;IAC7C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IACvC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC3D,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC5D,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,MAAc,EAAE,QAAmB;IACpE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpD,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,MAAc,EAAE,QAAmB;IACpE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpD,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,MAAc,EAAE,QAAmB;IACpE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpD,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `sieve` command-line interface.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* sieve --impl "<command...>" --param ml-kem-768 [--iterations N]
|
|
7
|
+
* [--vectors <dir>] [--timing] [--only a,b] [--timeout-ms N] [--json]
|
|
8
|
+
*
|
|
9
|
+
* Exit codes: 0 on overall PASS, 1 on overall FAIL, 2 on a usage error.
|
|
10
|
+
*
|
|
11
|
+
* Zero runtime dependencies — argument parsing is hand-rolled below.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `sieve` command-line interface.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* sieve --impl "<command...>" --param ml-kem-768 [--iterations N]
|
|
7
|
+
* [--vectors <dir>] [--timing] [--only a,b] [--timeout-ms N] [--json]
|
|
8
|
+
*
|
|
9
|
+
* Exit codes: 0 on overall PASS, 1 on overall FAIL, 2 on a usage error.
|
|
10
|
+
*
|
|
11
|
+
* Zero runtime dependencies — argument parsing is hand-rolled below.
|
|
12
|
+
*/
|
|
13
|
+
import { runSieve } from "./index.js";
|
|
14
|
+
import { formatHuman, formatJson } from "./report.js";
|
|
15
|
+
import { isParamSet, PARAM_SETS } from "./sizes.js";
|
|
16
|
+
const USAGE = `sieve — conformance battery for ML-KEM / ML-DSA implementations
|
|
17
|
+
|
|
18
|
+
USAGE:
|
|
19
|
+
sieve --impl "<command...>" --param <set> [options]
|
|
20
|
+
|
|
21
|
+
REQUIRED:
|
|
22
|
+
--impl "<cmd...>" Command Sieve spawns and drives over stdin/stdout JSON.
|
|
23
|
+
Quote the whole command, e.g. --impl "node ./impl.js".
|
|
24
|
+
--param <set> Parameter set. One of:
|
|
25
|
+
${PARAM_SETS.join(", ")}
|
|
26
|
+
|
|
27
|
+
OPTIONS:
|
|
28
|
+
--iterations <N> Randomized iterations for applicable categories (default 32).
|
|
29
|
+
--vectors <dir> Directory of OFFICIAL NIST ACVP vector files for the KAT
|
|
30
|
+
category. Sieve ships none and never fabricates them; see
|
|
31
|
+
vectors/README.md. Without this, KAT is SKIPPED.
|
|
32
|
+
--timing Include the advisory (non-verdict) decaps timing probe.
|
|
33
|
+
--only <a,b,...> Run only these categories (comma-separated).
|
|
34
|
+
--timeout-ms <N> Per-request timeout in ms (default 10000).
|
|
35
|
+
--pipeline-depth <N> Max concurrent in-flight requests for independent-iteration
|
|
36
|
+
categories (default 16). Use 1 for strictly serial.
|
|
37
|
+
--inherit-env Pass the FULL parent environment to the SUT. DANGEROUS:
|
|
38
|
+
the SUT is untrusted code; by default Sieve scrubs the env
|
|
39
|
+
to a minimal allow-list. Only for trusted local impls.
|
|
40
|
+
--json Emit the report as JSON instead of human-readable text.
|
|
41
|
+
-h, --help Show this help.
|
|
42
|
+
|
|
43
|
+
EXIT: 0 = PASS, 1 = FAIL, 2 = usage error.`;
|
|
44
|
+
class UsageError extends Error {
|
|
45
|
+
}
|
|
46
|
+
function parseArgs(argv) {
|
|
47
|
+
let impl;
|
|
48
|
+
let param;
|
|
49
|
+
let iterations = 32;
|
|
50
|
+
let vectorsDir;
|
|
51
|
+
let timing = false;
|
|
52
|
+
let only;
|
|
53
|
+
let timeoutMs;
|
|
54
|
+
let pipelineDepth;
|
|
55
|
+
let inheritEnv = false;
|
|
56
|
+
let json = false;
|
|
57
|
+
for (let i = 0; i < argv.length; i++) {
|
|
58
|
+
const arg = argv[i];
|
|
59
|
+
const eq = arg.indexOf("=");
|
|
60
|
+
const flag = eq >= 0 ? arg.slice(0, eq) : arg;
|
|
61
|
+
const inlineVal = eq >= 0 ? arg.slice(eq + 1) : undefined;
|
|
62
|
+
const next = () => {
|
|
63
|
+
if (inlineVal !== undefined)
|
|
64
|
+
return inlineVal;
|
|
65
|
+
const v = argv[++i];
|
|
66
|
+
if (v === undefined)
|
|
67
|
+
throw new UsageError(`flag ${flag} requires a value`);
|
|
68
|
+
return v;
|
|
69
|
+
};
|
|
70
|
+
switch (flag) {
|
|
71
|
+
case "--impl": {
|
|
72
|
+
const raw = next().trim();
|
|
73
|
+
impl = raw.split(/\s+/).filter((s) => s.length > 0);
|
|
74
|
+
if (impl.length === 0)
|
|
75
|
+
throw new UsageError("--impl command is empty");
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case "--param": {
|
|
79
|
+
const p = next();
|
|
80
|
+
if (!isParamSet(p)) {
|
|
81
|
+
throw new UsageError(`unknown --param "${p}"; expected one of ${PARAM_SETS.join(", ")}`);
|
|
82
|
+
}
|
|
83
|
+
param = p;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case "--iterations": {
|
|
87
|
+
const n = Number(next());
|
|
88
|
+
if (!Number.isInteger(n) || n < 1)
|
|
89
|
+
throw new UsageError("--iterations must be a positive integer");
|
|
90
|
+
iterations = n;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case "--vectors":
|
|
94
|
+
vectorsDir = next();
|
|
95
|
+
break;
|
|
96
|
+
case "--timing":
|
|
97
|
+
timing = true;
|
|
98
|
+
break;
|
|
99
|
+
case "--only":
|
|
100
|
+
only = next()
|
|
101
|
+
.split(",")
|
|
102
|
+
.map((s) => s.trim())
|
|
103
|
+
.filter((s) => s.length > 0);
|
|
104
|
+
break;
|
|
105
|
+
case "--timeout-ms": {
|
|
106
|
+
const n = Number(next());
|
|
107
|
+
if (!Number.isInteger(n) || n < 1)
|
|
108
|
+
throw new UsageError("--timeout-ms must be a positive integer");
|
|
109
|
+
timeoutMs = n;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case "--pipeline-depth": {
|
|
113
|
+
const n = Number(next());
|
|
114
|
+
if (!Number.isInteger(n) || n < 1)
|
|
115
|
+
throw new UsageError("--pipeline-depth must be a positive integer");
|
|
116
|
+
pipelineDepth = n;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
case "--inherit-env":
|
|
120
|
+
inheritEnv = true;
|
|
121
|
+
break;
|
|
122
|
+
case "--json":
|
|
123
|
+
json = true;
|
|
124
|
+
break;
|
|
125
|
+
case "-h":
|
|
126
|
+
case "--help":
|
|
127
|
+
process.stdout.write(USAGE + "\n");
|
|
128
|
+
process.exit(0);
|
|
129
|
+
break;
|
|
130
|
+
default:
|
|
131
|
+
throw new UsageError(`unknown flag: ${flag}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (!impl)
|
|
135
|
+
throw new UsageError("missing required --impl");
|
|
136
|
+
if (!param)
|
|
137
|
+
throw new UsageError("missing required --param");
|
|
138
|
+
return {
|
|
139
|
+
impl,
|
|
140
|
+
param,
|
|
141
|
+
iterations,
|
|
142
|
+
...(vectorsDir ? { vectorsDir } : {}),
|
|
143
|
+
timing,
|
|
144
|
+
...(only ? { only } : {}),
|
|
145
|
+
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
146
|
+
...(pipelineDepth !== undefined ? { pipelineDepth } : {}),
|
|
147
|
+
inheritEnv,
|
|
148
|
+
json,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async function main() {
|
|
152
|
+
let opts;
|
|
153
|
+
try {
|
|
154
|
+
opts = parseArgs(process.argv.slice(2));
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
if (err instanceof UsageError) {
|
|
158
|
+
process.stderr.write(`error: ${err.message}\n\n${USAGE}\n`);
|
|
159
|
+
return 2;
|
|
160
|
+
}
|
|
161
|
+
throw err;
|
|
162
|
+
}
|
|
163
|
+
const report = await runSieve({
|
|
164
|
+
command: opts.impl,
|
|
165
|
+
param: opts.param,
|
|
166
|
+
iterations: opts.iterations,
|
|
167
|
+
...(opts.vectorsDir ? { vectorsDir: opts.vectorsDir } : {}),
|
|
168
|
+
timing: opts.timing,
|
|
169
|
+
...(opts.only ? { only: opts.only } : {}),
|
|
170
|
+
...(opts.timeoutMs !== undefined ? { timeoutMs: opts.timeoutMs } : {}),
|
|
171
|
+
...(opts.pipelineDepth !== undefined ? { pipelineDepth: opts.pipelineDepth } : {}),
|
|
172
|
+
...(opts.inheritEnv ? { inheritEnv: true } : {}),
|
|
173
|
+
});
|
|
174
|
+
process.stdout.write((opts.json ? formatJson(report) : formatHuman(report)) + "\n");
|
|
175
|
+
return report.overall === "PASS" ? 0 : 1;
|
|
176
|
+
}
|
|
177
|
+
main().then((code) => process.exit(code), (err) => {
|
|
178
|
+
process.stderr.write(`sieve: fatal: ${err.stack ?? String(err)}\n`);
|
|
179
|
+
process.exit(2);
|
|
180
|
+
});
|
|
181
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAiB,MAAM,YAAY,CAAC;AAenE,MAAM,KAAK,GAAG;;;;;;;;;yBASW,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;2CAkBH,CAAC;AAE5C,MAAM,UAAW,SAAQ,KAAK;CAAG;AAEjC,SAAS,SAAS,CAAC,IAAuB;IACxC,IAAI,IAA0B,CAAC;IAC/B,IAAI,KAA2B,C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,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,GAAG,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClF,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjD,CAAC,CAAC;IAEH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACpF,OAAO,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,IAAI,EAAE,CAAC,IAAI,CACT,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAC5B,CAAC,GAAG,EAAE,EAAE;IACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAkB,GAAa,CAAC,KAAK,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @quantakrypto/sieve — programmatic API.
|
|
3
|
+
*
|
|
4
|
+
* Sieve is a conformance battery for ML-KEM (FIPS 203) and ML-DSA (FIPS 204)
|
|
5
|
+
* implementations. It TESTS other people's implementations; it implements no
|
|
6
|
+
* cryptography of its own and ships no Known-Answer-Test vectors. See README.md
|
|
7
|
+
* and PROTOCOL.md.
|
|
8
|
+
*
|
|
9
|
+
* Typical use:
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { runSieve } from "@quantakrypto/sieve";
|
|
12
|
+
* const report = await runSieve({ command: ["node", "./my-impl.js"], param: "ml-kem-768" });
|
|
13
|
+
* console.log(report.overall);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import { type SieveReport } from "./report.js";
|
|
17
|
+
import { type ParamSet } from "./sizes.js";
|
|
18
|
+
export type { SieveReport, CategoryCounts } from "./report.js";
|
|
19
|
+
export type { CategoryResult, Check, Status, BugClass } from "./categories/types.js";
|
|
20
|
+
export type { ParamSet, Family, Sizes, KemSizes, DsaSizes, SlhDsaSizes, SignatureSizes, } from "./sizes.js";
|
|
21
|
+
export type { Request, Response, SignatureFamily } from "./protocol.js";
|
|
22
|
+
export { PARAM_SETS, isParamSet, sizesFor, asKemSizes, asDsaSizes, asSlhDsaSizes, asSignatureSizes, } from "./sizes.js";
|
|
23
|
+
export { CATEGORIES, categoriesFor } from "./categories/index.js";
|
|
24
|
+
export { buildReport, formatHuman, formatJson, overallVerdict } from "./report.js";
|
|
25
|
+
export { encodeRequest, decodeResponse, ProtocolError, PROTOCOL_VERSION, toB64, fromB64, } from "./protocol.js";
|
|
26
|
+
export { Runner, TimeoutError, SutCrashError, buildSutEnv, DEFAULT_ENV_ALLOWLIST, } from "./runner.js";
|
|
27
|
+
export type { RunnerOptions } from "./runner.js";
|
|
28
|
+
export { loadVectors } from "./vectors.js";
|
|
29
|
+
export type { Vector, VectorSet } from "./vectors.js";
|
|
30
|
+
/** Options for {@link runSieve}. */
|
|
31
|
+
export interface RunSieveOptions {
|
|
32
|
+
/** Argv of the SUT, e.g. ["node", "./impl.js"]. */
|
|
33
|
+
command: readonly string[];
|
|
34
|
+
/** Parameter set to test, e.g. "ml-kem-768". */
|
|
35
|
+
param: ParamSet;
|
|
36
|
+
/** Randomized iterations for applicable categories (default 32). */
|
|
37
|
+
iterations?: number;
|
|
38
|
+
/** Per-request timeout in milliseconds (default 10000). */
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
/** Directory of official ACVP vectors for the kat category (optional). */
|
|
41
|
+
vectorsDir?: string;
|
|
42
|
+
/** Include the advisory timing category (default false). */
|
|
43
|
+
timing?: boolean;
|
|
44
|
+
/** Working directory for the SUT. */
|
|
45
|
+
cwd?: string;
|
|
46
|
+
/** Extra env for the SUT (layered over the scrubbed minimal env). */
|
|
47
|
+
env?: Record<string, string>;
|
|
48
|
+
/**
|
|
49
|
+
* Inherit the full parent environment instead of the scrubbed minimal env.
|
|
50
|
+
* Default `false` — the SUT is untrusted code. See security.md Q-17.
|
|
51
|
+
*/
|
|
52
|
+
inheritEnv?: boolean;
|
|
53
|
+
/** Extra env variable names to copy from the parent env into the SUT's env. */
|
|
54
|
+
envAllowlist?: readonly string[];
|
|
55
|
+
/**
|
|
56
|
+
* Max concurrent in-flight requests per SUT process for categories that issue
|
|
57
|
+
* many INDEPENDENT requests (correctness/determinism iterations). Default 16.
|
|
58
|
+
* Set to 1 for strictly serial behavior. The id-correlated protocol keeps
|
|
59
|
+
* dependent ops ordered; see docs/audits/performance.md §7.1.
|
|
60
|
+
*/
|
|
61
|
+
pipelineDepth?: number;
|
|
62
|
+
/** Restrict to these category names (default: all applicable). */
|
|
63
|
+
only?: readonly string[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Spawn the SUT, run the applicable categories, and return an aggregated
|
|
67
|
+
* report. The SUT process is always torn down before returning, even on error.
|
|
68
|
+
*/
|
|
69
|
+
export declare function runSieve(opts: RunSieveOptions): Promise<SieveReport>;
|
|
70
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5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AAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+EAA+E;IAC/E,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CAkE1E"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @quantakrypto/sieve — programmatic API.
|
|
3
|
+
*
|
|
4
|
+
* Sieve is a conformance battery for ML-KEM (FIPS 203) and ML-DSA (FIPS 204)
|
|
5
|
+
* implementations. It TESTS other people's implementations; it implements no
|
|
6
|
+
* cryptography of its own and ships no Known-Answer-Test vectors. See README.md
|
|
7
|
+
* and PROTOCOL.md.
|
|
8
|
+
*
|
|
9
|
+
* Typical use:
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { runSieve } from "@quantakrypto/sieve";
|
|
12
|
+
* const report = await runSieve({ command: ["node", "./my-impl.js"], param: "ml-kem-768" });
|
|
13
|
+
* console.log(report.overall);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import { categoriesFor } from "./categories/index.js";
|
|
17
|
+
import { Runner } from "./runner.js";
|
|
18
|
+
import { buildReport } from "./report.js";
|
|
19
|
+
import { isParamSet, sizesFor } from "./sizes.js";
|
|
20
|
+
export { PARAM_SETS, isParamSet, sizesFor, asKemSizes, asDsaSizes, asSlhDsaSizes, asSignatureSizes, } from "./sizes.js";
|
|
21
|
+
export { CATEGORIES, categoriesFor } from "./categories/index.js";
|
|
22
|
+
export { buildReport, formatHuman, formatJson, overallVerdict } from "./report.js";
|
|
23
|
+
export { encodeRequest, decodeResponse, ProtocolError, PROTOCOL_VERSION, toB64, fromB64, } from "./protocol.js";
|
|
24
|
+
export { Runner, TimeoutError, SutCrashError, buildSutEnv, DEFAULT_ENV_ALLOWLIST, } from "./runner.js";
|
|
25
|
+
export { loadVectors } from "./vectors.js";
|
|
26
|
+
/**
|
|
27
|
+
* Spawn the SUT, run the applicable categories, and return an aggregated
|
|
28
|
+
* report. The SUT process is always torn down before returning, even on error.
|
|
29
|
+
*/
|
|
30
|
+
export async function runSieve(opts) {
|
|
31
|
+
if (!isParamSet(opts.param)) {
|
|
32
|
+
throw new RangeError(`unknown parameter set: ${opts.param}`);
|
|
33
|
+
}
|
|
34
|
+
const sizes = sizesFor(opts.param);
|
|
35
|
+
const iterations = opts.iterations ?? 32;
|
|
36
|
+
const startedAt = new Date();
|
|
37
|
+
const t0 = performance.now();
|
|
38
|
+
const runner = new Runner({
|
|
39
|
+
command: opts.command,
|
|
40
|
+
...(opts.timeoutMs !== undefined ? { timeoutMs: opts.timeoutMs } : {}),
|
|
41
|
+
...(opts.cwd ? { cwd: opts.cwd } : {}),
|
|
42
|
+
...(opts.env ? { env: opts.env } : {}),
|
|
43
|
+
...(opts.inheritEnv !== undefined ? { inheritEnv: opts.inheritEnv } : {}),
|
|
44
|
+
...(opts.envAllowlist ? { envAllowlist: opts.envAllowlist } : {}),
|
|
45
|
+
});
|
|
46
|
+
const pipelineDepth = opts.pipelineDepth ?? 16;
|
|
47
|
+
const results = [];
|
|
48
|
+
try {
|
|
49
|
+
let cats = categoriesFor(sizes.family, opts.timing ?? false);
|
|
50
|
+
if (opts.only && opts.only.length > 0) {
|
|
51
|
+
const want = new Set(opts.only);
|
|
52
|
+
cats = cats.filter((c) => want.has(c.name));
|
|
53
|
+
}
|
|
54
|
+
for (const cat of cats) {
|
|
55
|
+
try {
|
|
56
|
+
const res = await cat.run({
|
|
57
|
+
runner,
|
|
58
|
+
sizes,
|
|
59
|
+
iterations,
|
|
60
|
+
pipelineDepth,
|
|
61
|
+
...(opts.vectorsDir ? { vectorsDir: opts.vectorsDir } : {}),
|
|
62
|
+
});
|
|
63
|
+
results.push(res);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
// A category that throws (rather than recording a fail) is a harness
|
|
67
|
+
// fault; surface it as a failing category so the report is complete.
|
|
68
|
+
results.push({
|
|
69
|
+
category: cat.name,
|
|
70
|
+
status: "fail",
|
|
71
|
+
checks: [
|
|
72
|
+
{
|
|
73
|
+
name: "category-error",
|
|
74
|
+
status: "fail",
|
|
75
|
+
detail: `category threw: ${err.message}`,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
summary: "category aborted with an error",
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
await runner.close();
|
|
85
|
+
}
|
|
86
|
+
return buildReport({
|
|
87
|
+
param: opts.param,
|
|
88
|
+
impl: [...opts.command],
|
|
89
|
+
iterations,
|
|
90
|
+
...(opts.vectorsDir ? { vectorsDir: opts.vectorsDir } : {}),
|
|
91
|
+
startedAt,
|
|
92
|
+
durationMs: Math.round(performance.now() - t0),
|
|
93
|
+
categories: results,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC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