@blamejs/pki 0.6.38 → 0.6.40

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/CHANGELOG.md CHANGED
@@ -4,6 +4,43 @@ All notable changes to `@blamejs/pki` are documented here. The format
4
4
  follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this
5
5
  project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## v0.6.40 — 2026-09-05
8
+
9
+ Every verify verdict now reaches its caller as the object the verb built, and a list the toolkit assembles carries the entries the toolkit put in it.
10
+
11
+ ### Fixed
12
+
13
+ - The verdicts of pki.attrcert.verify, pki.crl.verify, pki.csr.verify, pki.ct.verifySctWithLogList, pki.ct.verifySctList, pki.path.validate, pki.path.build, pki.pkcs12.verifyMac, pki.pkcs12.open, pki.webauthn.verify, pki.webauthn.verifyAssertion, pki.cmp.verify, pki.tsp.verify, pki.ocsp.verifyRequest and pki.sigstore.verifyBundle end the prototype lookup for then on themselves. An accessor installed there while a verification was pending could otherwise run with the verdict as its receiver and change what the caller reads.
14
+ - A list a verdict reports is appended to by defining the entry rather than assigning it, so a setter at the appended index cannot take the value and answer the read with something else. This covers the keys, certificates, CRLs and secrets pki.pkcs12.open returns from an authenticated store, the signers pki.cms.verify reports and the countersignatures under them, the per-SCT results and the distinct operators pki.ct.verifySctList counts its policy against, the per-certificate results pki.path.validate reports and the checks under each of them that name which gate refused, the elements of a compound attestation pki.webauthn.verify returns along with the routes its anchoredTo names, the certificate chain and transcript a pki.cmp session returns, and the signer identities pki.smime.verify reports. The arrays a pki.schema parser fills are not covered: a verify verb re-derives its answer from the bytes and refuses a parse result whose fields were rebuilt, so a substituted entry there decides nothing.
15
+ - pki.webauthn.verify builds the fields it learns after the attestation itself is checked into the verdict rather than writing them onto it. bindingChecked, which tells a relying party which of its expectations were enforced, could otherwise be taken by an inherited setter and reported by its getter as a check that never ran. anchoredTo, anchoredElements, metadata, clientData, safetyNet, tpm and compound are built the same way.
16
+ - The results of pki.path.crlChecker(...).check and pki.path.ocspChecker(...).check, the build-only result pki.path.build returns under validate:false, and the results of pki.ct.signSct and pki.ct.fetchLogList carry the same protection. Each is handed to a caller, so each ends the prototype lookup for then on itself.
17
+ - Path validation, CMS verification, timestamp verification, CMP protection verification and Sigstore bundle verification append to every one of their own lists the same way. Each reads its answer back out of those lists, so the name forms a name-constraint check compares, the CRLs a revocation decision scans, the policy-tree nodes that produce the user-constrained set, the candidate certificates a signer identifier selects, the chains a timestamp is trusted through and the path a Fulcio leaf is anchored by are all written where an indexed setter cannot reach them.
18
+
19
+ ## v0.6.39 — 2026-09-05
20
+
21
+ A verdict field is created with the verdict rather than written onto it afterward, so a value left on Object.prototype can no longer answer a question the verification never asked.
22
+
23
+ ### Added
24
+
25
+ - The pki.ocsp.verify and pki.path.verifyOcspResponse verdicts carry valid, true only when status is good. Every failure these verbs detect already reports status unknown, so the boolean covers exactly the checks they run.
26
+ - The pki.cmc.verify verdict carries valid, true only for the issued outcome. Every other outcome, pending included, reads as false, with outcome, failInfo and pendToken unchanged.
27
+
28
+ ### Changed
29
+
30
+ - The pki.ocsp.verify and pki.path.verifyOcspResponse verdicts report thisUpdate and nextUpdate as null, not undefined, when no response covered the certificate. Every path now reports both, so a reader gets the same shape whatever the verdict. Code testing them with === undefined should test == null.
31
+ - The container release workflow takes docker/setup-qemu-action v4.3.0.
32
+
33
+ ### Fixed
34
+
35
+ - A verdict field is now created with the verdict rather than assigned onto it afterward, so a value left on Object.prototype cannot answer a read the verification never wrote. Three verdicts could report an affirmative that had not been established: an OCSP response whose signature does not verify, or that no authorized responder signs, contributed a good status through pki.ocsp.verify, pki.path.verifyOcspResponse and pki.path.ocspChecker, so pki.path.validate accepted a certificate whose revocation status was never determined; pki.cms.verify reported a signer as trusted when it had been given no trust anchors to chain to; and pki.crmf.verifyPop reported verified for a request carrying no proof of possession at all. pki.cmc.verify, pki.smime.verify and the pki.cmp session results carried the same construction and are fixed with them.
36
+ - A verdict also ends the prototype lookup for then, so an accessor installed there cannot rewrite it between the verification and the caller.
37
+ - A pki.cmp session transcript no longer reports a protection result on a request leg. A request records no verdict, and the snapshot read the field without asking whether the entry carried one, so a value left on Object.prototype was copied in and read back as a result the session never reached.
38
+ - The tables that decide how a signature is verified answer from their own entries alone. pki.cms.verify looked its signature scheme up in a table that inherits from Object.prototype, so a message could name an algorithm the toolkit does not implement and have the verification proceed under a descriptor left there. The dispatch tables in pki.cms.verify, pki.path.validate and the composite-signature resolver are fixed.
39
+
40
+ ### Internal
41
+
42
+ - The test covering the implicit-rejection substitute content key chooses a ciphertext whose outcome it can predict. OpenSSL answers an RSA PKCS#1 v1.5 decode fault with a synthetic key whose length is drawn from the private key and the ciphertext, and a draw equal to the content-key length took the substitute out of the path, so the test failed about once in every few hundred runs.
43
+
7
44
  ## v0.6.38 — 2026-09-05
8
45
 
9
46
  A trust anchor can name the namespace its root is trusted for, and pki.path.validate enforces it as the initial name-constraint state.
@@ -717,7 +717,7 @@ function _verify(ac, issuer, opts) {
717
717
  var trust = _resolveIssuer(issuer);
718
718
 
719
719
  var acIssuer = _acIssuerName(parsed);
720
- var result = {
720
+ var result = guard.verdict.of({
721
721
  holder: parsed.holder,
722
722
  issuer: acIssuer,
723
723
  attributes: parsed.attributes,
@@ -735,7 +735,7 @@ function _verify(ac, issuer, opts) {
735
735
  valid: false,
736
736
  verified: false,
737
737
  reason: undefined,
738
- };
738
+ });
739
739
 
740
740
  return Promise.resolve(attrcertVerify.verifyAcSignature(parsed, trust.spki)).then(function (sigOk) {
741
741
  result.signatureValid = sigOk === true;
package/lib/cmc-verify.js CHANGED
@@ -89,12 +89,13 @@ function _assertBound(body, sent) {
89
89
  if (Buffer.isBuffer(v) || v instanceof Uint8Array) return v.length > 0; // allow:byte-source-narrow -- sent.senderNonce / dataReturn are already normalized to a Buffer by _snapshotSent; this is a length test on a settled value, not an input door
90
90
  return true;
91
91
  }
92
- var bound = {
92
+ var bound = guard.verdict.of({
93
93
  transactionId: _carries(sent.transactionId),
94
94
  senderNonce: _carries(sent.senderNonce),
95
95
  dataReturn: _carries(sent.dataReturn),
96
96
  bodyPartIDs: Array.isArray(sent.bodyPartIDs),
97
- };
97
+ boundToRequest: false,
98
+ });
98
99
  if (sent.transactionId != null) {
99
100
  var txControl = _findControl(body.controls, OID_TRANSACTION_ID, "Transaction Identifier");
100
101
  if (!txControl) {
@@ -197,6 +198,10 @@ function _governingStatus(statuses, outcome) {
197
198
  * @defends cmc-response-replay (CWE-294)
198
199
  * @related pki.schema.cmc.parse, pki.path.validate, pki.cms.verify
199
200
  *
201
+ * The verdict carries `valid`, the toolkit-wide alias the other verify verbs use, true only for the
202
+ * `issued` outcome. Every other outcome, including `pending`, is `valid: false`, and which one it
203
+ * was stays in `outcome` alongside `failInfo` and `pendToken`.
204
+ *
200
205
  * Interpret a Full PKI Response into one terminal verdict. `response` is the DER or a PEM `CMS`
201
206
  * block; an already-parsed message is interpreted too, but only under `allowUnverified: true`,
202
207
  * because both carriers authenticate over BYTES and a parsed object the caller still owns pins
@@ -419,7 +424,8 @@ function _shape(body, sent, signatureVerified, bound) {
419
424
  var confirm = _findControl(body.controls, OID_CONFIRM_CERT_ACCEPTANCE, "Confirm Certificate Acceptance");
420
425
  var serverNonce = _findControl(body.controls, OID_SENDER_NONCE, "Sender Nonce");
421
426
 
422
- return {
427
+ return guard.verdict.of({
428
+ valid: outcome === "issued",
423
429
  outcome: outcome,
424
430
  statuses: body.statuses,
425
431
  failInfo: governing ? governing.failInfoName : null,
@@ -448,7 +454,7 @@ function _shape(body, sent, signatureVerified, bound) {
448
454
  controls: body.controls,
449
455
  unhandled: body.unhandled,
450
456
  cms: body.cms,
451
- };
457
+ });
452
458
  }
453
459
 
454
460
  /**
@@ -507,7 +507,7 @@ function session(opts) {
507
507
  if (!Buffer.isBuffer(c)) return;
508
508
  var k = c.toString("base64");
509
509
  if (caPubsSeen[k]) {
510
- if (isGrantLeg) { for (var pi = 0; pi < caPubsAccum.length; pi++) { if (caPubsAccum[pi].toString("base64") === k) { caPubsAccum.push(caPubsAccum.splice(pi, 1)[0]); if (pi < caPubsWaitingCount) caPubsWaitingCount--; break; } } }
510
+ if (isGrantLeg) { for (var pi = 0; pi < caPubsAccum.length; pi++) { if (caPubsAccum[pi].toString("base64") === k) { guard.list.append(caPubsAccum, caPubsAccum.splice(pi, 1)[0]); if (pi < caPubsWaitingCount) caPubsWaitingCount--; break; } } }
511
511
  return;
512
512
  }
513
513
  try { x509.parse(c); } catch (e) { throw _err("cmp/bad-cert-response", "an authenticated caPubs entry is not a valid X.509 certificate", e); }
@@ -522,7 +522,7 @@ function session(opts) {
522
522
  if (caPubsAccum.length >= CAPUBS_MAX || caPubsBytes + c.length > caPubsByteBudget) return;
523
523
  caPubsSeen[k] = 1;
524
524
  caPubsBytes += c.length;
525
- caPubsAccum.push(Buffer.from(c));
525
+ guard.list.append(caPubsAccum, Buffer.from(c));
526
526
  if (!isGrantLeg) caPubsWaitingCount++;
527
527
  });
528
528
  if (isGrantLeg) return { state: "granted", resp: resp, code: code };
@@ -590,24 +590,23 @@ function session(opts) {
590
590
 
591
591
  function _recordTranscript(entry) {
592
592
  var len = Buffer.isBuffer(entry.bytes) ? entry.bytes.length : 0;
593
- if (transcriptBytes + len > transcriptCap) {
594
- entry.byteLength = len; entry.bytes = null; entry.truncated = true;
595
- } else {
596
- transcriptBytes += len;
597
- }
598
- transcript.push(entry);
593
+ var over = transcriptBytes + len > transcriptCap;
594
+ if (!over) transcriptBytes += len;
595
+ guard.list.append(transcript, over
596
+ ? guard.verdict.of(entry, { byteLength: len, bytes: null, truncated: true })
597
+ : guard.verdict.of(entry));
599
598
  }
600
599
 
601
600
  function _transcriptSnapshot() {
602
601
  return transcript.map(function (e) {
603
- var c = Object.assign({}, e);
602
+ var c = guard.verdict.of(e);
604
603
  if (Buffer.isBuffer(c.bytes)) c.bytes = Buffer.from(c.bytes);
605
- if (c.verdict) c.verdict = Object.assign({}, c.verdict);
604
+ if (guard.verdict.carries(c, "verdict") && c.verdict) c.verdict = guard.verdict.of(c.verdict);
606
605
  return c;
607
606
  });
608
607
  }
609
608
  function _terminal(outcome, extra) {
610
- return Object.assign({
609
+ return guard.verdict.of({
611
610
  outcome: outcome, certificate: null, chain: [], status: null, trusted: true,
612
611
  confirmed: false, implicitConfirm: false, transactionID: Buffer.from(transactionID),
613
612
  polls: 0, transcript: _transcriptSnapshot(),
@@ -704,7 +703,7 @@ function session(opts) {
704
703
  var k = _certIdentity(c);
705
704
  if (k != null && seenChain[k]) return;
706
705
  if (k != null) seenChain[k] = 1;
707
- chain.push(c);
706
+ guard.list.append(chain, c);
708
707
  });
709
708
  await _validateLeaf(leaf, caPubsAccum);
710
709
  var info = { status: PKI_STATUS_NAMES[granted.code] || granted.code, grantedWithMods: granted.code === 1 };
package/lib/cmp-verify.js CHANGED
@@ -77,7 +77,7 @@ var _engine = null;
77
77
  function setEngine(engine) { _engine = engine; }
78
78
 
79
79
  function _verdict(m, type, protectionAlg, valid, trusted, code, reason, signer) {
80
- var v = {
80
+ return guard.verdict.of({
81
81
  valid: valid,
82
82
  trusted: trusted,
83
83
  protectionType: type,
@@ -88,9 +88,7 @@ function _verdict(m, type, protectionAlg, valid, trusted, code, reason, signer)
88
88
  recipNonce: m.header.recipNonce || null,
89
89
  header: m.header,
90
90
  body: m.body,
91
- };
92
- if (code) { v.code = code; v.reason = reason; }
93
- return v;
91
+ }, code ? { code: code, reason: reason } : null);
94
92
  }
95
93
  function _ok(m, type, alg, trusted, signer) { return _verdict(m, type, alg, true, trusted, null, null, signer); }
96
94
  function _fail(m, type, alg, code, reason, signer) { return _verdict(m, type, alg, false, false, code, reason, signer || null); }
@@ -438,7 +436,7 @@ async function _verifySignature(m, protectedPart, protectionAlg, protection, opt
438
436
 
439
437
  if (opts.trustAnchors == null) return _ok(m, "signature", protectionAlg, false, signer);
440
438
  var trust = await _chainSigner(signer, m, opts, extra);
441
- if (trust.chain) signer.chain = trust.chain;
439
+ if (trust.chain) guard.verdict.set(signer, "chain", trust.chain);
442
440
  return _verdict(m, "signature", protectionAlg, true, trust.trusted, trust.trusted ? null : "cmp/untrusted-signer", trust.reason, signer);
443
441
  }
444
442
 
@@ -521,9 +519,7 @@ function _boundExtraCerts(extra) {
521
519
 
522
520
  var _defineOwn = Object.defineProperty;
523
521
  var _Date = Date;
524
- function _append(arr, v) {
525
- _defineOwn(arr, arr.length, { value: v, writable: true, enumerable: true, configurable: true });
526
- }
522
+ var _append = guard.list.append;
527
523
 
528
524
  function _certList(v) {
529
525
  if (v == null) return [];
package/lib/cms-verify.js CHANGED
@@ -51,22 +51,29 @@ var pkix = require("./schema-pkix");
51
51
  var CmsError = frameworkError.CmsError;
52
52
  function _err(code, message, cause) { return new CmsError(code, message, cause); }
53
53
  var _Promise = Promise, _promiseResolveRaw = Promise.resolve;
54
- function _pResolve(v) { return intrinsic.apply(_promiseResolveRaw, _Promise, [v]); }
54
+ /**
55
+ * @internal Every value resolved here is a signer row, and resolving a promise reads `then` off the
56
+ * value. Building the row through the verdict guard ends that lookup on the row itself, so an
57
+ * accessor installed while the signature check is pending cannot rewrite the `ok` the message
58
+ * verdict is derived from before it is read.
59
+ */
60
+ function _pResolve(v) { return intrinsic.apply(_promiseResolveRaw, _Promise, [_row(v)]); }
61
+ function _row(o) { return guard.verdict.of(o); }
55
62
 
56
63
  var OID_MESSAGE_DIGEST = oid.byName("messageDigest");
57
64
  var OID_CONTENT_TYPE = oid.byName("contentType");
58
65
  var OID_COUNTERSIGNATURE = oid.byName("countersignature");
59
66
 
60
- var DIGEST_HASH = {
67
+ var DIGEST_HASH = intrinsic.assign(intrinsic.create(null), {
61
68
  sha1: "SHA-1", sha256: "SHA-256", sha384: "SHA-384", sha512: "SHA-512",
62
69
  shake128: "SHAKE128", shake256: "SHAKE256",
63
- };
64
- var SIG_HASH = { sha1: "SHA-1", sha256: "SHA-256", sha384: "SHA-384", sha512: "SHA-512" };
70
+ });
71
+ var SIG_HASH = intrinsic.assign(intrinsic.create(null), { sha1: "SHA-1", sha256: "SHA-256", sha384: "SHA-384", sha512: "SHA-512" });
65
72
  function _supportedDigest(name) { return intrinsic.hasOwn(DIGEST_HASH, name) && !!DIGEST_HASH[name]; }
66
73
  async function _computeDigest(name, content) {
67
74
  return intrinsic.bufferFrom(await subtle.digest(DIGEST_HASH[name], content));
68
75
  }
69
- var SIG_SCHEME = {
76
+ var SIG_SCHEME = intrinsic.assign(intrinsic.create(null), {
70
77
  rsaEncryption: { kind: "rsa", params: "null" },
71
78
  rsassaPss: { kind: "rsapss" },
72
79
  ecPublicKey: { kind: "ec", params: "absent" },
@@ -83,13 +90,13 @@ var SIG_SCHEME = {
83
90
  ecdsaWithSHA256: { kind: "ec", hash: "SHA-256", params: "absent" },
84
91
  ecdsaWithSHA384: { kind: "ec", hash: "SHA-384", params: "absent" },
85
92
  ecdsaWithSHA512: { kind: "ec", hash: "SHA-512", params: "absent" },
86
- };
93
+ });
87
94
  ["sha2-128s", "sha2-128f", "sha2-192s", "sha2-192f", "sha2-256s", "sha2-256f",
88
95
  "shake-128s", "shake-128f", "shake-192s", "shake-192f", "shake-256s", "shake-256f"
89
96
  ].forEach(function (s) { SIG_SCHEME["id-slh-dsa-" + s] = { kind: "slhdsa", name: "SLH-DSA-" + s.toUpperCase(), params: "absent", sameKeyOid: true, digest: SLHDSA_BY_OID[oid.byName("id-slh-dsa-" + s)].digest }; });
90
97
  function _isDerNull(p) { return Buffer.isBuffer(p) && p.length === 2 && p[0] === 0x05 && p[1] === 0x00; }
91
98
  function _algParamsOk(shape, p) { return shape === "null" ? _isDerNull(p) : (p === null || p === undefined); }
92
- var EC_CURVE = {};
99
+ var EC_CURVE = intrinsic.create(null);
93
100
  EC_CURVE[oid.byName("prime256v1")] = { curve: "P-256", coordLen: 32 };
94
101
  EC_CURVE[oid.byName("secp384r1")] = { curve: "P-384", coordLen: 48 };
95
102
  EC_CURVE[oid.byName("secp521r1")] = { curve: "P-521", coordLen: 66 };
@@ -104,9 +111,9 @@ function _findSignerCerts(sid, parsedCerts) {
104
111
  for (var i = 0; i < parsedCerts.length; i++) {
105
112
  var c = parsedCerts[i];
106
113
  if (sid.subjectKeyIdentifier != null) {
107
- if (c.ski && intrinsic.bufferEquals(c.ski, _toBuf(sid.subjectKeyIdentifier, "sid.subjectKeyIdentifier"))) intrinsic.push(out, c);
114
+ if (c.ski && intrinsic.bufferEquals(c.ski, _toBuf(sid.subjectKeyIdentifier, "sid.subjectKeyIdentifier"))) guard.list.append(out, c);
108
115
  } else if (sid.issuer && sid.serialNumberHex != null) {
109
- if (c.cert.serialNumberHex === sid.serialNumberHex && guard.name.dnEqual(c.cert.issuer.rdns, sid.issuer.rdns, _err, "cms/bad-name", "the signer certificate issuer")) intrinsic.push(out, c);
116
+ if (c.cert.serialNumberHex === sid.serialNumberHex && guard.name.dnEqual(c.cert.issuer.rdns, sid.issuer.rdns, _err, "cms/bad-name", "the signer certificate issuer")) guard.list.append(out, c);
110
117
  }
111
118
  }
112
119
  return out;
@@ -122,13 +129,13 @@ async function _verifyAgainstCandidates(scheme, sigHash, sigBytes, signedBytes,
122
129
  }
123
130
  try {
124
131
  var ok = await _verifySignature(scheme, sigHash, sigBytes, c.cert.subjectPublicKeyInfo.bytes, signedBytes, _certCurveOid(c.cert), pssSalt);
125
- if (ok === true) return { ok: true, sid: sid, cert: c.der };
132
+ if (ok === true) return _row({ ok: true, sid: sid, cert: c.der });
126
133
  } catch (e) {
127
134
  lastErr = (e instanceof CmsError) ? e : _err("cms/verify-error", "the SignerInfo signature could not be evaluated", e);
128
135
  }
129
136
  }
130
- return lastErr ? { ok: false, code: lastErr.code, sid: sid, cert: candidates[0].der, message: lastErr.message }
131
- : { ok: false, sid: sid, cert: candidates[0].der };
137
+ return _row(lastErr ? { ok: false, code: lastErr.code, sid: sid, cert: candidates[0].der, message: lastErr.message }
138
+ : { ok: false, sid: sid, cert: candidates[0].der });
132
139
  }
133
140
 
134
141
  function _certSki(cert) {
@@ -262,7 +269,7 @@ async function _verifyOne(si, content, eContentType, parsedCerts, csTarget, dige
262
269
  var sigBytes = _toBuf(si.signature, "the SignerInfo signature");
263
270
 
264
271
  var signedBytes = await (csTarget != null ? _computeCountersigBytes(si, csTarget) : _computeSignedBytes(si, content, eContentType, digestByName));
265
- if (signedBytes && signedBytes.mismatch) return { ok: false, code: signedBytes.mismatch.code, sid: si.sid, cert: signers[0].der, message: signedBytes.mismatch.message };
272
+ if (signedBytes && signedBytes.mismatch) return _row({ ok: false, code: signedBytes.mismatch.code, sid: si.sid, cert: signers[0].der, message: signedBytes.mismatch.message });
266
273
  return _verifyAgainstCandidates(scheme, sigHash, sigBytes, signedBytes, si.sid, signers, pss ? pss.saltLength : 0, scheme.sameKeyOid ? oid.byName(si.signatureAlgorithm.name) : null);
267
274
  }
268
275
 
@@ -347,7 +354,7 @@ async function _verifyComposite(si, comp, content, eContentType, parsedCerts, cs
347
354
  if (!signers.length) return _pResolve({ ok: false, code: "cms/signer-cert-not-found", sid: si.sid, message: "no certificate matches this SignerInfo's signer identifier" });
348
355
  var sigBytes = _toBuf(si.signature, "the SignerInfo signature");
349
356
  var signedBytes = await (csTarget != null ? _computeCountersigBytes(si, csTarget) : _computeSignedBytes(si, content, eContentType, digestByName));
350
- if (signedBytes && signedBytes.mismatch) return { ok: false, code: signedBytes.mismatch.code, sid: si.sid, cert: signers[0].der, message: signedBytes.mismatch.message };
357
+ if (signedBytes && signedBytes.mismatch) return _row({ ok: false, code: signedBytes.mismatch.code, sid: si.sid, cert: signers[0].der, message: signedBytes.mismatch.message });
351
358
  return _verifyCompositeAgainstCandidates(comp, sigBytes, signedBytes, si.sid, signers, si.signatureAlgorithm.oid);
352
359
  }
353
360
 
@@ -360,11 +367,11 @@ async function _verifyCompositeAgainstCandidates(comp, sigBytes, signedBytes, si
360
367
  continue;
361
368
  }
362
369
  var r = await compositeSig.compositeVerify(c.cert.subjectPublicKeyInfo.bytes, sigBytes, signedBytes, comp, CmsError, "cms/unsupported-algorithm", "cms/bad-signature");
363
- if (r.ok === true) return { ok: true, sid: sid, cert: c.der };
370
+ if (r.ok === true) return _row({ ok: true, sid: sid, cert: c.der });
364
371
  if (r.code) lastErr = (r.error instanceof CmsError) ? r.error : _err(r.code, r.error && r.error.message ? r.error.message : "the composite signature could not be evaluated");
365
372
  }
366
- return lastErr ? { ok: false, code: lastErr.code, sid: sid, cert: candidates[0].der, message: lastErr.message }
367
- : { ok: false, sid: sid, cert: candidates[0].der };
373
+ return _row(lastErr ? { ok: false, code: lastErr.code, sid: sid, cert: candidates[0].der, message: lastErr.message }
374
+ : { ok: false, sid: sid, cert: candidates[0].der });
368
375
  }
369
376
 
370
377
  function _surfaceUnsignedAttrs(si) {
@@ -384,24 +391,23 @@ async function _verifyCountersignatures(si, parsedCerts) {
384
391
  var values = [];
385
392
  intrinsic.forEach(si.unsignedAttrs || [], function (a) {
386
393
  if (a.type !== OID_COUNTERSIGNATURE) return;
387
- intrinsic.forEach(a.values, function (v) { intrinsic.push(values, v && v.bytes ? v.bytes : v); });
394
+ intrinsic.forEach(a.values, function (v) { guard.list.append(values, v && v.bytes ? v.bytes : v); });
388
395
  });
389
396
  var out = [];
390
- for (var _cp = 0; _cp < values.length; _cp++) intrinsic.push(out, await _verifyOneCountersig(values[_cp], targetSig, parsedCerts));
397
+ for (var _cp = 0; _cp < values.length; _cp++) guard.list.append(out, await _verifyOneCountersig(values[_cp], targetSig, parsedCerts));
391
398
  return out;
392
399
  }
393
400
 
394
401
  async function _verifyOneCountersig(vDer, targetSig, parsedCerts) {
395
402
  var csSi;
396
403
  try { csSi = cms.walkCountersignature(asn1.decode(intrinsic.isBuffer(vDer) ? vDer : intrinsic.bufferFrom(vDer))); }
397
- catch (e) { return { ok: false, code: (e instanceof CmsError ? e.code : "cms/bad-countersignature"), message: e && e.message }; }
404
+ catch (e) { return _row({ ok: false, code: (e instanceof CmsError ? e.code : "cms/bad-countersignature"), message: e && e.message }); }
398
405
  var verdict = await _verifyOne(csSi, targetSig, null, parsedCerts, targetSig);
399
406
  var nested = await _verifyCountersignatures(csSi, parsedCerts);
400
- var node = { ok: verdict.ok, sid: verdict.sid, cert: verdict.cert, digestAlgorithm: csSi.digestAlgorithm.name };
401
- if (verdict.code) node.code = verdict.code;
402
- node.unsignedAttrs = _surfaceUnsignedAttrs(csSi);
403
- node.countersignatures = nested;
404
- return node;
407
+ var head = { ok: verdict.ok, sid: verdict.sid, cert: verdict.cert, digestAlgorithm: csSi.digestAlgorithm.name };
408
+ return guard.verdict.of(
409
+ verdict.code ? guard.verdict.of(head, { code: verdict.code }) : head,
410
+ { unsignedAttrs: _surfaceUnsignedAttrs(csSi), countersignatures: nested });
405
411
  }
406
412
 
407
413
  /**
@@ -489,7 +495,7 @@ async function _resolveContentDigests(parsed, streamSource) {
489
495
  var names = [], seen = {};
490
496
  intrinsic.forEach(parsed.signerInfos, function (si) {
491
497
  var dn = si.digestAlgorithm.name;
492
- if (si.signedAttrsBytes && _supportedDigest(dn) && !seen[dn]) { seen[dn] = 1; intrinsic.push(names, dn); }
498
+ if (si.signedAttrsBytes && _supportedDigest(dn) && !seen[dn]) { seen[dn] = 1; guard.list.append(names, dn); }
493
499
  });
494
500
  if (!names.length) return {};
495
501
  var ds;
@@ -539,19 +545,23 @@ async function _verify(input, opts) {
539
545
  for (var _sp = 0; _sp < parsed.signerInfos.length; _sp++) {
540
546
  var siOne = parsed.signerInfos[_sp];
541
547
  var verdict = await _verifyOne(siOne, content, eContentType, parsedCerts, null, digestByName);
542
- verdict.countersignatures = await _verifyCountersignatures(siOne, parsedCerts);
543
- verdict.unsignedAttrs = _surfaceUnsignedAttrs(siOne);
544
- verdict.signedAttributesPresent = !!siOne.signedAttrsBytes;
545
- verdict.signedAttributes = _surfaceSignedAttrs(siOne);
546
- verdict.digestAlgorithm = siOne.digestAlgorithm.name;
547
- intrinsic.push(signers, verdict);
548
+ var counters = await _verifyCountersignatures(siOne, parsedCerts);
549
+ guard.list.append(signers, guard.verdict.of(verdict, {
550
+ countersignatures: counters,
551
+ unsignedAttrs: _surfaceUnsignedAttrs(siOne),
552
+ signedAttributesPresent: !!siOne.signedAttrsBytes,
553
+ signedAttributes: _surfaceSignedAttrs(siOne),
554
+ digestAlgorithm: siOne.digestAlgorithm.name,
555
+ trusted: false,
556
+ }));
548
557
  }
549
- var res = {
558
+ var res = guard.verdict.of({
550
559
  valid: signers.length > 0 && guard.list.allMatch(signers, function (s) { return s.ok === true; }),
551
560
  eContentType: parsed.encapContentInfo.eContentType,
552
561
  eContent: parsed.encapContentInfo.eContent != null ? parsed.encapContentInfo.eContent : null,
553
562
  signers: signers,
554
- };
563
+ trusted: false,
564
+ });
555
565
  await _applyTrust(res, parsedCerts, trustCfg);
556
566
  return res;
557
567
  }
@@ -667,7 +677,7 @@ function _addCert(out, der) {
667
677
  try {
668
678
  cert = x509.parse(buf);
669
679
  } catch (_e2) { return; }
670
- out.push({ cert: cert, der: buf, ski: _certSki(cert) });
680
+ guard.list.append(out, { cert: cert, der: buf, ski: _certSki(cert) });
671
681
  }
672
682
 
673
683
  /**
@@ -24,7 +24,7 @@ var MLDSA_COMPONENT = {
24
24
  };
25
25
  var EC_CURVE_OID = { "P-256": "prime256v1", "P-384": "secp384r1", "P-521": "secp521r1" };
26
26
  var PH_CMS = { "SHA-256": "sha256", "SHA-512": "sha512", "SHAKE256": "shake256" };
27
- var COMPOSITE_ALGS = {};
27
+ var COMPOSITE_ALGS = Object.create(null);
28
28
  function _comp(name, mldsa, ph, label, trad) {
29
29
  var sz = MLDSA_COMPONENT[mldsa];
30
30
  COMPOSITE_ALGS[oid.byName(name)] = {
package/lib/crl-sign.js CHANGED
@@ -525,14 +525,14 @@ function _verify(crl, issuer) {
525
525
  return crlVerify.verifyCrlSignature(parsed, resolved.spki).then(function (sigOk) {
526
526
  var signatureValid = sigOk === true;
527
527
  var valid = issuerMaySign && signatureValid;
528
- var out = { valid: valid, issuerMaySign: issuerMaySign, signatureValid: signatureValid, issuer: parsed.issuer };
529
- if (!valid) {
530
- out.code = !issuerMaySign ? "crl/issuer-may-not-sign" : "crl/bad-signature";
531
- out.reason = !issuerMaySign
532
- ? "the issuer certificate is not this CRL's issuer, or its keyUsage does not assert cRLSign (RFC 5280 sec. 4.2.1.3)"
533
- : "the CRL signature did not verify under the issuer key";
534
- }
535
- return out;
528
+ return guard.verdict.of(
529
+ { valid: valid, issuerMaySign: issuerMaySign, signatureValid: signatureValid, issuer: parsed.issuer },
530
+ valid ? null : {
531
+ code: !issuerMaySign ? "crl/issuer-may-not-sign" : "crl/bad-signature",
532
+ reason: !issuerMaySign
533
+ ? "the issuer certificate is not this CRL's issuer, or its keyUsage does not assert cRLSign (RFC 5280 sec. 4.2.1.3)"
534
+ : "the CRL signature did not verify under the issuer key",
535
+ });
536
536
  });
537
537
  }
538
538
 
package/lib/crmf-sign.js CHANGED
@@ -478,7 +478,10 @@ function _verifyOne(msg) {
478
478
  subjectBound: false,
479
479
  publicKey: (t && t.publicKey && t.publicKey.bytes) || null,
480
480
  };
481
- function settle(extra) { var v = Object.assign({}, base, extra); v.valid = v.verified === true; return Promise.resolve(v); }
481
+ function settle(extra) {
482
+ var v = guard.verdict.of(base, extra);
483
+ return Promise.resolve(guard.verdict.of(v, { valid: v.verified === true }));
484
+ }
482
485
 
483
486
  var popo = msg.popo;
484
487
  if (popo == null) {
@@ -499,7 +502,7 @@ function _verifyOne(msg) {
499
502
  var spki = pin ? pin.publicKey : base.publicKey;
500
503
  var bound = !pin;
501
504
  return crmfVerify.verifyPopSignature(popo, spki, preimage).then(function (ok) {
502
- return Object.assign({}, base, {
505
+ return guard.verdict.of(base, {
503
506
  valid: ok === true, verified: ok === true, method: "signature", cryptographicallyVerified: ok === true,
504
507
  subject: bound ? base.subject : null,
505
508
  subjectBound: bound,
@@ -558,7 +561,7 @@ function _verifyPop(messages) {
558
561
  var parsed = _coerceMessages(messages);
559
562
  return Promise.all(parsed.messages.map(_verifyOne)).then(function (out) {
560
563
  var allVerified = out.length > 0 && out.every(function (m) { return m.verified === true; });
561
- return { valid: allVerified, verified: allVerified, messages: out };
564
+ return guard.verdict.of({ valid: allVerified, verified: allVerified, messages: out });
562
565
  });
563
566
  }
564
567
 
package/lib/csr-sign.js CHANGED
@@ -205,14 +205,14 @@ function verify(request) { return guard.async.deferred(function () { return _ver
205
205
  function _verify(request) {
206
206
  var parsed = _coerceCsr(request);
207
207
  return Promise.resolve(csrVerify.verifyCsrSignature(parsed)).then(function (ok) {
208
- return {
208
+ return guard.verdict.of({
209
209
  valid: ok === true,
210
210
  verified: ok === true,
211
211
  subject: parsed.subject,
212
212
  subjectPublicKeyInfo: parsed.subjectPublicKeyInfo,
213
213
  attributes: parsed.attributes,
214
214
  certificationRequestInfoBytes: parsed.certificationRequestInfoBytes,
215
- };
215
+ });
216
216
  });
217
217
  }
218
218
 
package/lib/ct.js CHANGED
@@ -551,7 +551,7 @@ async function signSct(entry, logKey, opts) {
551
551
  var priv = await subtle.importKey("pkcs8", mat.pkcs8, imp, false, ["sign"]);
552
552
  var sigRaw = Buffer.from(await subtle.sign(sign, priv, preimage));
553
553
  var signature = ecdsaDer ? validator.sig.rawToEcdsaDer(sigRaw, coordLen) : sigRaw;
554
- return {
554
+ return guard.verdict.of({
555
555
  version: 0,
556
556
  logId: logId, logIdHex: logId.toString("hex"),
557
557
  timestamp: timestamp,
@@ -559,7 +559,7 @@ async function signSct(entry, logKey, opts) {
559
559
  hashAlg: hashAlg, sigAlg: sigAlg,
560
560
  signatureAlgorithm: { hash: hashAlg, hashName: HASH_ALGORITHMS[hashAlg] || null, signature: sigAlg, signatureName: SIGNATURE_ALGORITHMS[sigAlg] || null },
561
561
  signature: signature,
562
- };
562
+ });
563
563
  }
564
564
 
565
565
 
@@ -766,14 +766,14 @@ async function verifySctWithLogList(entry, sct, logList, opts) {
766
766
  var c = _classifyLog(sct, logList, entry, opts);
767
767
  if (c.status !== "ok") throw _ctErr(c.code, c.message);
768
768
  var valid = await verifySct(entry, sct, c.log.key);
769
- return {
769
+ return guard.verdict.of({
770
770
  valid: valid,
771
771
  logId: c.log.logId,
772
772
  logIdHex: c.log.logIdHex,
773
773
  operator: c.log.operator,
774
774
  logState: c.log.state.name,
775
775
  timestamp: sct.timestamp,
776
- };
776
+ });
777
777
  }
778
778
 
779
779
  var _VERIFY_SCT_LIST_OPTS = { minScts: 1, minOperators: 1, certNotAfter: 1, at: 1 };
@@ -860,37 +860,37 @@ async function verifySctList(entry, list, logList, opts) {
860
860
  try { c = _classifyLog(sct, logList, entry, opts); }
861
861
  catch (e) {
862
862
  if (!(e && e.isPkiError)) throw e;
863
- row.code = e.code; row.reason = e.message; intrinsic.push(results, row); continue;
863
+ row.code = e.code; row.reason = e.message; guard.list.append(results, row); continue;
864
864
  }
865
865
  if (c.log) { row.operator = c.log.operator; row.logState = c.log.state.name; }
866
- if (c.status !== "ok") { row.code = c.code; row.reason = c.message; intrinsic.push(results, row); continue; }
866
+ if (c.status !== "ok") { row.code = c.code; row.reason = c.message; guard.list.append(results, row); continue; }
867
867
  var ok;
868
868
  try { ok = await verifySct(entry, sct, c.log.key); }
869
869
  catch (e) {
870
870
  if (!(e && e.isPkiError)) throw e;
871
- row.code = e.code; row.reason = e.message; intrinsic.push(results, row); continue;
871
+ row.code = e.code; row.reason = e.message; guard.list.append(results, row); continue;
872
872
  }
873
873
  if (ok === true && atMs != null && sct.timestamp > atMs) {
874
874
  row.code = "ct/future-timestamp"; row.reason = "the SCT timestamp is later than the validation time (RFC 6962 sec. 5.2)";
875
- intrinsic.push(results, row); continue;
875
+ guard.list.append(results, row); continue;
876
876
  }
877
877
  row.valid = ok === true;
878
878
  if (row.valid && !seenLogs[sct.logIdHex]) {
879
879
  seenLogs[sct.logIdHex] = true;
880
880
  validScts++;
881
- if (c.log.operator != null && !seenOps[c.log.operator]) { seenOps[c.log.operator] = true; intrinsic.push(operators, c.log.operator); }
881
+ if (c.log.operator != null && !seenOps[c.log.operator]) { seenOps[c.log.operator] = true; guard.list.append(operators, c.log.operator); }
882
882
  }
883
- intrinsic.push(results, row);
883
+ guard.list.append(results, row);
884
884
  }
885
885
  var operatorCount = operators.length;
886
886
  var policyOk = validScts >= minScts && operatorCount >= minOperators;
887
- return {
887
+ return guard.verdict.of({
888
888
  valid: policyOk,
889
889
  policyOk: policyOk, totalScts: scts.length + unknownScts, validScts: validScts, unknownScts: unknownScts,
890
890
  operatorCount: operatorCount, operators: operators, required: { minScts: minScts, minOperators: minOperators },
891
891
  results: results,
892
892
  reason: policyOk ? null : ("CT policy not met: " + validScts + " valid SCT(s) from " + operatorCount + " distinct operator(s); require at least " + minScts + " SCT(s) from at least " + minOperators + " operator(s)"),
893
- };
893
+ });
894
894
  }
895
895
 
896
896
  function _asParsedCert(v, field) {
@@ -1143,10 +1143,10 @@ async function fetchLogList(opts) {
1143
1143
  var ok = await verifyLogListSignature(jsonRes.body, sigRes.body, opts.signerKey);
1144
1144
  if (ok !== true) throw _ctErr("ct/log-list-untrusted", "the CT log-list detached signature did not verify against the pinned distributor key -- the fetched list is untrusted and was not parsed");
1145
1145
  var parsed = parseLogList(jsonRes.body);
1146
- return {
1146
+ return guard.verdict.of({
1147
1147
  logs: parsed.logs, byLogId: parsed.byLogId, version: parsed.version, timestamp: parsed.timestamp,
1148
1148
  raw: { json: jsonRes.body, sig: sigRes.body }, status: jsonRes.status, contentType: jsonRes.contentType, tls: jsonRes.tls,
1149
- };
1149
+ });
1150
1150
  }
1151
1151
 
1152
1152
  module.exports = {
package/lib/guard-all.js CHANGED
@@ -20,6 +20,7 @@ var header = require("./guard-header");
20
20
  var compress = require("./guard-compress");
21
21
  var secret = require("./guard-secret");
22
22
  var parsed = require("./guard-parsed");
23
+ var verdict = require("./guard-verdict");
23
24
  var async_ = require("./guard-async");
24
25
 
25
26
  module.exports = _freeze({
@@ -39,5 +40,6 @@ module.exports = _freeze({
39
40
  compress: compress,
40
41
  secret: secret,
41
42
  parsed: parsed,
43
+ verdict: verdict,
42
44
  async: async_,
43
45
  });
@@ -41,7 +41,7 @@ var _mapSet = intrinsic.mapSet;
41
41
  var _taSet = intrinsic.typedArraySet;
42
42
  var _Set = intrinsic.Set;
43
43
  var _Map = intrinsic.Map;
44
- function _append(arr, v) { _defineProperty(arr, arr.length, { value: v, writable: true, enumerable: true, configurable: true }); }
44
+ var _append = require("./guard-list").append;
45
45
 
46
46
  function _ownArrayIndices(v, n) {
47
47
  var keys = _ownKeys(v);
@@ -38,7 +38,7 @@ var _Number = intrinsic.Number;
38
38
  var _BigInt = intrinsic.BigInt;
39
39
  var _Object = intrinsic.Object;
40
40
  var _BufferProto = intrinsic.BufferProto;
41
- function _append(arr, v) { _defineProperty(arr, arr.length, { value: v, writable: true, enumerable: true, configurable: true }); }
41
+ var _append = require("./guard-list").append;
42
42
 
43
43
  function _isDottedDecimal(str) {
44
44
  if (str.length === 0) return false;
package/lib/guard-json.js CHANGED
@@ -12,7 +12,7 @@ var _hasOwn = require("./guard-intrinsic").hasOwn;
12
12
  var _Number = require("./guard-intrinsic").Number;
13
13
  var _isFinite = require("./guard-intrinsic").isFinite;
14
14
  var _stringify = require("./guard-intrinsic").stringify;
15
- function _append(arr, v) { _defineProperty(arr, arr.length, { value: v, writable: true, enumerable: true, configurable: true }); }
15
+ var _append = require("./guard-list").append;
16
16
  var limits = require("./guard-limits");
17
17
 
18
18
  function _hexVal(c) {