@blamejs/pki 0.5.39 → 0.6.1
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 +23 -1
- package/README.md +7 -6
- package/lib/acme.js +23 -23
- package/lib/cmc-verify.js +2 -2
- package/lib/cmp-build.js +2 -2
- package/lib/cmp-session.js +1 -1
- package/lib/ct.js +279 -22
- package/lib/est.js +11 -11
- package/lib/hpke.js +4 -4
- package/lib/http-transport.js +1 -1
- package/lib/lint.js +3 -3
- package/lib/ocsp-request-verify.js +28 -0
- package/lib/ocsp.js +156 -0
- package/lib/path-validate.js +76 -5
- package/lib/schema-c509.js +2 -2
- package/lib/schema-cmc.js +3 -3
- package/lib/sigstore.js +3 -3
- package/lib/webauthn.js +3 -3
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/lib/ocsp.js
CHANGED
|
@@ -32,6 +32,7 @@ var ocspSchema = require("./schema-ocsp");
|
|
|
32
32
|
var pathValidate = require("./path-validate");
|
|
33
33
|
var signScheme = require("./sign-scheme");
|
|
34
34
|
var ocspVerify = require("./ocsp-verify");
|
|
35
|
+
var ocspRequestVerify = require("./ocsp-request-verify"); // path-validate (required above) injects its signature engine into this seam at load
|
|
35
36
|
var webcrypto = require("./webcrypto");
|
|
36
37
|
var subtle = webcrypto.webcrypto.subtle;
|
|
37
38
|
var guard = require("./guard-all");
|
|
@@ -579,9 +580,164 @@ function _responseNonce(parsed) {
|
|
|
579
580
|
return null;
|
|
580
581
|
}
|
|
581
582
|
|
|
583
|
+
var _VERIFY_REQUEST_OPTS = { certs: 1 };
|
|
584
|
+
// Parsed from BYTES so the signature, the algorithm that verifies it and the tbsRequest it covers
|
|
585
|
+
// are bound to one byte string, the same discipline pki.ocsp.verify follows for a response. A
|
|
586
|
+
// BufferSource is SNAPSHOT first: parseRequest surfaces tbsRequest / signature / embedded certs as
|
|
587
|
+
// views into it, and the signature check awaits, so without a copy a caller could mutate the buffer
|
|
588
|
+
// mid-verification and be judged on bytes other than the parser read. A PEM string decodes to a
|
|
589
|
+
// fresh buffer already; parseRequest owns that decode and a non-bytes input is its typed refusal.
|
|
590
|
+
function _requestFromBytes(request) {
|
|
591
|
+
if (guard.bytes.isByteSource(request)) request = guard.bytes.snapshotSource(request, OcspError, "ocsp/bad-input", "the OCSP request");
|
|
592
|
+
return ocspSchema.parseRequest(request);
|
|
593
|
+
}
|
|
594
|
+
function _reqVerdict(parsed, extra) {
|
|
595
|
+
return {
|
|
596
|
+
signed: extra.signed, signatureValid: extra.signatureValid,
|
|
597
|
+
signerCert: extra.signerCert != null ? extra.signerCert : null,
|
|
598
|
+
signerCerts: extra.signerCerts != null ? extra.signerCerts : [],
|
|
599
|
+
certs: extra.certs != null ? extra.certs : [],
|
|
600
|
+
signerSubject: extra.signerSubject != null ? extra.signerSubject : null,
|
|
601
|
+
requestorName: parsed.requestorName, requestList: parsed.requestList,
|
|
602
|
+
requestExtensions: parsed.requestExtensions, version: parsed.version,
|
|
603
|
+
reason: extra.reason != null ? extra.reason : null,
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
// Collect EVERY candidate certificate whose key verified the request signature. RFC 6960 sec. 4.1.1
|
|
607
|
+
// certs is an unordered SEQUENCE OF Certificate, and several may share the signing key (an expired
|
|
608
|
+
// certificate carried beside its renewal), so all matches are surfaced rather than one
|
|
609
|
+
// position-dependent pick: the responder builds a trusted path to one of them to select a usable
|
|
610
|
+
// one, and no valid match is hidden behind an unusable one that happened to appear first. `strict` separates the
|
|
611
|
+
// responder's own opts.certs (a malformed entry is its config error, a typed throw) from the
|
|
612
|
+
// request's untrusted embedded certs (a malformed one is skipped, never fatal).
|
|
613
|
+
async function _findRequestSigners(candidates, strict, parsed, sig, sigBits) {
|
|
614
|
+
var parsedList = [];
|
|
615
|
+
for (var i = 0; i < candidates.length; i++) {
|
|
616
|
+
try { parsedList.push({ der: candidates[i], cert: x509.parse(candidates[i]) }); }
|
|
617
|
+
catch (e) { if (strict) throw _err("ocsp/bad-signer-cert", "an opts.certs entry does not parse as an X.509 certificate", e); }
|
|
618
|
+
}
|
|
619
|
+
// The certs surfaced for path building are the PARSEABLE ones: a malformed embedded entry (skipped
|
|
620
|
+
// above rather than fatal) is excluded so it is never handed to pki.path.build as a candidate.
|
|
621
|
+
var parseable = parsedList.map(function (p) { return p.der; });
|
|
622
|
+
// signerCerts is every candidate whose key VERIFIES the request signature, identified by the
|
|
623
|
+
// verification itself rather than by comparing encoded key bytes. A request carries one signature
|
|
624
|
+
// under one key, but that key can appear across several certificates in the unordered certs field
|
|
625
|
+
// (an expired certificate beside its renewal), and the one key can be encoded differently between
|
|
626
|
+
// them -- rsaEncryption with NULL versus absent parameters, an EC point compressed versus
|
|
627
|
+
// uncompressed -- so a byte comparison would drop a genuine match, while a coincidental byte match
|
|
628
|
+
// under a different algorithm would be a false one. Verifying each candidate answers both exactly,
|
|
629
|
+
// through the algorithm-confusion gate (RFC 9814 sec. 4) in the shared engine. The work is bounded:
|
|
630
|
+
// the parser already caps the certificate count at OCSP_MAX_CERTS, and the engine returns false
|
|
631
|
+
// (never throws) for a candidate whose key does not match the signature, so a non-signer is skipped
|
|
632
|
+
// rather than aborting the verdict.
|
|
633
|
+
var matches = [];
|
|
634
|
+
for (var j = 0; j < parsedList.length; j++) {
|
|
635
|
+
if (await ocspRequestVerify.verifyRequestSignature(sig.signatureAlgorithm, sigBits, parsedList[j].cert.subjectPublicKeyInfo.bytes, parsed.tbsRequestBytes)) {
|
|
636
|
+
matches.push({ der: parsedList[j].der, subject: parsedList[j].cert.subject });
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return { matches: matches, parseable: parseable };
|
|
640
|
+
}
|
|
641
|
+
// The verdict from `_findRequestSigners`: signerCerts is every match (so the caller's trust decision
|
|
642
|
+
// does not depend on ordering), signerCert / signerSubject the first for the common single-signer
|
|
643
|
+
// case. `certs` is every PARSEABLE certificate the request carried (or opts.certs supplied), so the
|
|
644
|
+
// responder has the intermediates it needs to chain a signer to an anchor -- those do not sign the
|
|
645
|
+
// request, so they never appear in signerCerts. No match is signatureValid:false with the reason.
|
|
646
|
+
function _signerVerdict(parsed, found, failReason) {
|
|
647
|
+
if (!found.matches.length) return _reqVerdict(parsed, { signed: true, signatureValid: false, certs: found.parseable, reason: failReason });
|
|
648
|
+
return _reqVerdict(parsed, {
|
|
649
|
+
signed: true, signatureValid: true, signerCert: found.matches[0].der,
|
|
650
|
+
signerCerts: found.matches.map(function (m) { return m.der; }), certs: found.parseable,
|
|
651
|
+
signerSubject: { dn: found.matches[0].subject.dn, rdns: found.matches[0].subject.rdns }, reason: null,
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* @primitive pki.ocsp.verifyRequest
|
|
657
|
+
* @signature pki.ocsp.verifyRequest(request, opts?) -> Promise<{ signed, signatureValid, signerCert, signerCerts, certs, signerSubject, requestorName, requestList, requestExtensions, version, reason }>
|
|
658
|
+
* @since 0.6.0
|
|
659
|
+
* @status stable
|
|
660
|
+
* @spec RFC 6960
|
|
661
|
+
* @related pki.ocsp.buildRequest, pki.ocsp.verify, pki.schema.ocsp.parseRequest, pki.csr.verify
|
|
662
|
+
*
|
|
663
|
+
* The responder-side counterpart to `pki.ocsp.buildRequest`: verify a client's signed OCSP request
|
|
664
|
+
* (RFC 6960 sec. 4.1.1). Signing a request is OPTIONAL, so an unsigned request is not an error; it is
|
|
665
|
+
* reported with `signed: false` and authenticates no requestor. For a signed request the requestor's
|
|
666
|
+
* signature over the exact `tbsRequest` is checked under the public key of the requestor certificate
|
|
667
|
+
* the request carries, through the same certification-path signature engine `pki.ocsp.verify` uses
|
|
668
|
+
* for a response (with its EdDSA low-order-point and algorithm-confusion gates). `request` is DER
|
|
669
|
+
* `Buffer` / `Uint8Array` or a PEM `OCSP REQUEST` string, parsed from bytes so the signature, its
|
|
670
|
+
* algorithm and the covered `tbsRequest` are one byte string and cannot be split.
|
|
671
|
+
*
|
|
672
|
+
* `signatureValid` means only that a certificate's key made this signature over this request. It
|
|
673
|
+
* says nothing about whether that certificate is trusted: `signerCerts` is every certificate the
|
|
674
|
+
* request carries whose key verified the signature (RFC 6960 sec. 4.1.1 certs is unordered, and a
|
|
675
|
+
* key may appear under an expired certificate beside its renewal), so the responder builds a trusted
|
|
676
|
+
* path to one of them rather than depend on ordering. `signerCert` and the decoded `signerSubject`
|
|
677
|
+
* are the first of those, the common single-signer case. `certs` is every parseable certificate the
|
|
678
|
+
* request carried (or opts.certs supplied), including intermediates that do not sign and so are absent
|
|
679
|
+
* from `signerCerts`: the responder passes it as the `opts.candidates` pool to `pki.path.build`, which
|
|
680
|
+
* discovers and validates the ordered path from a `signerCerts` entry (leaf) up to a trust anchor.
|
|
681
|
+
* The responder then confirms that certificate is authorized to sign the request -- its `keyUsage`,
|
|
682
|
+
* where present, must assert `digitalSignature` (RFC 5280 sec. 4.2.1.3, since the certificate signed
|
|
683
|
+
* the request) -- and compares its subject to the `requestorName` it expects. The decoded
|
|
684
|
+
* `requestList`, `requestExtensions` and `version` are
|
|
685
|
+
* returned so the CertIDs being asked about need no re-parse.
|
|
686
|
+
*
|
|
687
|
+
* @opts
|
|
688
|
+
* - `certs` An array of certificates (DER `Buffer` / `Uint8Array` or PEM strings) supplying the
|
|
689
|
+
* requestor certificate when the request omits its own `certs` (RFC 6960 lets them
|
|
690
|
+
* travel out of band); every entry whose key verifies is surfaced in `signerCerts`,
|
|
691
|
+
* and is ignored when the request embeds its own certificates.
|
|
692
|
+
*
|
|
693
|
+
* @example
|
|
694
|
+
* var pair = await pki.key.generate("Ed25519");
|
|
695
|
+
* var key = await pki.key.export(pair.privateKey), spki = await pki.key.export(pair.publicKey);
|
|
696
|
+
* var caDer = await pki.x509.sign({ subject: "OCSP CA", subjectPublicKey: spki,
|
|
697
|
+
* notBefore: new Date("2026-01-01T00:00:00Z"), notAfter: new Date("2027-01-01T00:00:00Z") }, { key: key });
|
|
698
|
+
* var request = await pki.ocsp.buildRequest({ cert: caDer, issuer: caDer },
|
|
699
|
+
* { signer: { cert: caDer, key: key }, requestorName: pki.schema.x509.parse(caDer).subject.bytes });
|
|
700
|
+
* var v = await pki.ocsp.verifyRequest(request);
|
|
701
|
+
* // v.signed && v.signatureValid -> for a signerCerts entry, pki.path.build(entry, { candidates:
|
|
702
|
+
* // v.certs, trustAnchors, time }) discovers and validates the path (several signerCerts may share
|
|
703
|
+
* // the key, e.g. an expired one beside its renewal); confirm that entry's keyUsage asserts
|
|
704
|
+
* // digitalSignature, then bind its subject to the requestor you expect before honoring v.requestList.
|
|
705
|
+
*/
|
|
706
|
+
async function verifyRequest(request, opts) {
|
|
707
|
+
opts = guard.identifier.optionsObject(opts, _err, "ocsp/bad-input", "pki.ocsp.verifyRequest options");
|
|
708
|
+
guard.identifier.assertKnownKeys(opts, _VERIFY_REQUEST_OPTS, _err, "ocsp/bad-input",
|
|
709
|
+
"pki.ocsp.verifyRequest has an unknown option (out-of-band requestor certificates are `certs`): ");
|
|
710
|
+
var parsed = _requestFromBytes(request);
|
|
711
|
+
var sig = parsed.optionalSignature;
|
|
712
|
+
if (sig == null) {
|
|
713
|
+
return _reqVerdict(parsed, { signed: false, signatureValid: false,
|
|
714
|
+
reason: "the OCSP request is unsigned (RFC 6960 sec. 4.1.1 makes optionalSignature OPTIONAL); no requestor is authenticated" });
|
|
715
|
+
}
|
|
716
|
+
// sig.signature is the raw signature the parser already refused unless octet-aligned; the seam
|
|
717
|
+
// re-checks alignment, so it is handed the BIT STRING shape the seam verifies.
|
|
718
|
+
var sigBits = { unusedBits: 0, bytes: sig.signature };
|
|
719
|
+
// Prefer the certificates the request carries; fall back to opts.certs only when it carries none.
|
|
720
|
+
if (sig.certs.length) {
|
|
721
|
+
return _signerVerdict(parsed, await _findRequestSigners(sig.certs, false, parsed, sig, sigBits),
|
|
722
|
+
"the OCSP request signature does not verify over tbsRequest under any certificate the request carries (RFC 6960 sec. 4.1.1)");
|
|
723
|
+
}
|
|
724
|
+
var suppliedCerts = [];
|
|
725
|
+
if (opts.certs != null) {
|
|
726
|
+
var list = pkiBuild.reqDenseArray(opts.certs, "opts.certs", _err, "ocsp/bad-input");
|
|
727
|
+
for (var i = 0; i < list.length; i++) suppliedCerts.push(_normCertDer(list[i], "an opts.certs entry"));
|
|
728
|
+
}
|
|
729
|
+
if (!suppliedCerts.length) {
|
|
730
|
+
return _reqVerdict(parsed, { signed: true, signatureValid: false,
|
|
731
|
+
reason: "the signed OCSP request carries no certificate and opts.certs was not supplied, so its signature cannot be verified" });
|
|
732
|
+
}
|
|
733
|
+
return _signerVerdict(parsed, await _findRequestSigners(suppliedCerts, true, parsed, sig, sigBits),
|
|
734
|
+
"the OCSP request signature does not verify over tbsRequest under any opts.certs entry");
|
|
735
|
+
}
|
|
736
|
+
|
|
582
737
|
module.exports = {
|
|
583
738
|
buildRequest: buildRequest,
|
|
584
739
|
sign: sign,
|
|
585
740
|
buildErrorResponse: buildErrorResponse,
|
|
586
741
|
verify: verify,
|
|
742
|
+
verifyRequest: verifyRequest,
|
|
587
743
|
};
|
package/lib/path-validate.js
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
var webcrypto = require("./webcrypto");
|
|
34
34
|
var pkix = require("./schema-pkix");
|
|
35
35
|
var oid = require("./oid");
|
|
36
|
+
var ct = require("./ct");
|
|
36
37
|
var errors = require("./framework-error");
|
|
37
38
|
var asn1 = require("./asn1-der");
|
|
38
39
|
var schema = require("./schema-engine");
|
|
@@ -44,6 +45,7 @@ var crlVerify = require("./crl-verify");
|
|
|
44
45
|
var csrVerify = require("./csr-verify");
|
|
45
46
|
var crmfVerify = require("./crmf-verify");
|
|
46
47
|
var attrcertVerify = require("./attrcert-verify");
|
|
48
|
+
var ocspRequestVerify = require("./ocsp-request-verify");
|
|
47
49
|
var cmpVerify = require("./cmp-verify");
|
|
48
50
|
var cmsVerify = require("./cms-verify");
|
|
49
51
|
var cmpSession = require("./cmp-session");
|
|
@@ -1277,17 +1279,73 @@ function validateCriticalExtensionStructure(cert) {
|
|
|
1277
1279
|
// inputs appear together. A grep of one function would have shipped a list missing four real
|
|
1278
1280
|
// options and rejected callers that work today.
|
|
1279
1281
|
var _VALIDATE_OPTS = {
|
|
1280
|
-
checkPurpose: 1,
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1282
|
+
checkPurpose: 1, ctLogList: 1, ctPolicy: 1, historicalMode: 1, initialAnyPolicyInhibit: 1,
|
|
1283
|
+
initialExcludedSubtrees: 1, initialExplicitPolicy: 1, initialPermittedSubtrees: 1,
|
|
1284
|
+
initialPolicyMappingInhibit: 1, maxPathCerts: 1, maxPolicyNodes: 1, requireRevocation: 1,
|
|
1285
|
+
requiredEku: 1, revocationChecker: 1, softFail: 1, time: 1, trustAnchor: 1,
|
|
1286
|
+
userInitialPolicySet: 1, verifier: 1
|
|
1284
1287
|
};
|
|
1285
1288
|
|
|
1289
|
+
// The opt-in Certificate Transparency gate (RFC 6962). When opts.ctLogList is supplied, the target's
|
|
1290
|
+
// embedded SCTs are verified against the trusted log-list and the caller's CT policy, and the verdict is
|
|
1291
|
+
// recorded on the target's checks. Fail-closed: a target that declares a CT policy but carries no
|
|
1292
|
+
// SCT-list extension is refused. Reached only through opts.ctLogList, so every existing caller is
|
|
1293
|
+
// unaffected. The SCT-list extension OID is looked up through the shared registry, never a literal.
|
|
1294
|
+
var OID_SCT_LIST = oid.byName("signedCertificateTimestampList");
|
|
1295
|
+
async function ctGateCheck(leaf, certs, anchor, ctLogList, ctPolicy, n, at) {
|
|
1296
|
+
var exts = leaf.extensions || [], sctExt = null;
|
|
1297
|
+
for (var i = 0; i < exts.length; i++) {
|
|
1298
|
+
if (exts[i] && (exts[i].oid === OID_SCT_LIST || exts[i].name === "signedCertificateTimestampList")) { sctExt = exts[i]; break; }
|
|
1299
|
+
}
|
|
1300
|
+
if (sctExt == null) return { name: "ct", ok: false, code: "path/ct-required" };
|
|
1301
|
+
// The leaf's issuer contributes issuerKeyHash: the certificate that signed it (certs[n-2] in the
|
|
1302
|
+
// anchor->target order), or the anchor itself when the target is validated directly beneath it.
|
|
1303
|
+
var issuer = n >= 2 ? certs[n - 2] : { subjectPublicKeyInfo: { bytes: anchor.publicKey } };
|
|
1304
|
+
var entry, list;
|
|
1305
|
+
try {
|
|
1306
|
+
entry = ct.x509CertEntry(leaf, issuer);
|
|
1307
|
+
list = ct.parseSctList(sctExt.value);
|
|
1308
|
+
} catch (e) {
|
|
1309
|
+
return { name: "ct", ok: false, code: pathCode(e, "path/ct-required") };
|
|
1310
|
+
}
|
|
1311
|
+
// verifySctList throws only for a mis-shaped caller configuration (a bad ctPolicy threshold value, a
|
|
1312
|
+
// ctLogList that is not a parseLogList result): that is the caller's error, surfaced at the path
|
|
1313
|
+
// boundary as path/bad-input rather than leaking the ct/* domain code of a layer they did not call.
|
|
1314
|
+
// verifySctList throws only for a mis-shaped caller configuration (a bad ctPolicy threshold value, a
|
|
1315
|
+
// ctLogList that is not a parseLogList result): that is the caller's error, surfaced at the path
|
|
1316
|
+
// boundary as path/bad-input rather than leaking the ct/* domain code of a layer they did not call.
|
|
1317
|
+
var verdict;
|
|
1318
|
+
try {
|
|
1319
|
+
verdict = await ct.verifySctList(entry, list, ctLogList,
|
|
1320
|
+
{ minScts: ctPolicy.minScts, minOperators: ctPolicy.minOperators, certNotAfter: leaf.validity.notAfter, at: at });
|
|
1321
|
+
} catch (e) {
|
|
1322
|
+
if (e && e.isPkiError) throw E("path/bad-input", "validate: the CT policy or log-list is invalid (" + (e.code || "ct/bad-input") + "): " + e.message);
|
|
1323
|
+
throw e;
|
|
1324
|
+
}
|
|
1325
|
+
return { name: "ct", ok: verdict.policyOk === true, code: verdict.policyOk ? undefined : "path/ct-policy-not-met" };
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1286
1328
|
async function validate(path, opts) {
|
|
1287
1329
|
opts = guard.identifier.optionsObject(opts, E, "path/bad-input", "validate: opts");
|
|
1288
1330
|
guard.identifier.assertKnownKeys(opts, _VALIDATE_OPTS, E, "path/bad-input",
|
|
1289
1331
|
"pki.path.validate has an unknown option. The anchor here is `trustAnchor`, singular; " +
|
|
1290
1332
|
"pki.path.build takes `trustAnchors`. The unknown option was: ");
|
|
1333
|
+
// A CT policy without a log-list cannot be enforced -- refuse it at entry rather than silently
|
|
1334
|
+
// skipping the CT gate and returning a valid path the caller believes was CT-checked (fail-closed).
|
|
1335
|
+
if (opts.ctPolicy != null && opts.ctLogList == null) throw E("path/bad-input", "validate: opts.ctPolicy requires opts.ctLogList (the trusted CT log-list to verify the certificate's SCTs against)");
|
|
1336
|
+
// Validate the CT policy's KEYS at entry: a misspelled key (e.g. `minSCTs`) would otherwise read as
|
|
1337
|
+
// undefined and silently default to the RFC floor of 1, applying a weaker policy than the caller asked
|
|
1338
|
+
// for. The values are validated by verifySctList when the gate runs.
|
|
1339
|
+
// Validate the whole CT configuration at entry, independent of whether the target carries an SCT
|
|
1340
|
+
// extension, so a malformed policy or log-list is always path/bad-input -- never masked as a
|
|
1341
|
+
// per-certificate path/ct-required just because the target happens to lack SCTs.
|
|
1342
|
+
if (opts.ctLogList != null) {
|
|
1343
|
+
if (typeof opts.ctLogList !== "object" || opts.ctLogList.byLogId == null) throw E("path/bad-input", "validate: opts.ctLogList must be a pki.ct.parseLogList result");
|
|
1344
|
+
var ctp = guard.identifier.optionsObject(opts.ctPolicy, E, "path/bad-input", "validate: opts.ctPolicy");
|
|
1345
|
+
guard.identifier.assertKnownKeys(ctp, { minScts: 1, minOperators: 1 }, E, "path/bad-input", "validate: opts.ctPolicy has an unknown key (the CT policy keys are minScts / minOperators): ");
|
|
1346
|
+
if (ctp.minScts != null && (typeof ctp.minScts !== "number" || !intrinsic.isInteger(ctp.minScts) || ctp.minScts < 1)) throw E("path/bad-input", "validate: opts.ctPolicy.minScts must be a positive integer");
|
|
1347
|
+
if (ctp.minOperators != null && (typeof ctp.minOperators !== "number" || !intrinsic.isInteger(ctp.minOperators) || ctp.minOperators < 1)) throw E("path/bad-input", "validate: opts.ctPolicy.minOperators must be a positive integer");
|
|
1348
|
+
}
|
|
1291
1349
|
if (!intrinsic.isArray(path)) throw E("path/bad-input", "validate: path must be an array of certificates");
|
|
1292
1350
|
// Bound the per-cert asymmetric-verify work BEFORE parsing an untrusted bundle
|
|
1293
1351
|
// (the policy-tree cap guards CVE-2023-0464-style blow-up; this guards linear
|
|
@@ -1606,6 +1664,15 @@ async function validate(path, opts) {
|
|
|
1606
1664
|
failed = true;
|
|
1607
1665
|
}
|
|
1608
1666
|
|
|
1667
|
+
// Opt-in CT gate: verify the target's embedded SCTs and record the verdict on its checks (RFC 6962).
|
|
1668
|
+
if (opts.ctLogList != null) {
|
|
1669
|
+
var ctCheck = await ctGateCheck(certs[n - 1], certs, anchor, opts.ctLogList, opts.ctPolicy || {}, n, opts.time);
|
|
1670
|
+
var target = null;
|
|
1671
|
+
for (var tr = 0; tr < state.results.length; tr++) { if (state.results[tr].index === n - 1) { target = state.results[tr]; break; } }
|
|
1672
|
+
if (target) intrinsic.push(target.checks, ctCheck);
|
|
1673
|
+
if (!ctCheck.ok) failed = true;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1609
1676
|
return {
|
|
1610
1677
|
valid: !failed,
|
|
1611
1678
|
// What the revocation rule and the anchor's own trust metadata actually decided. `valid` alone
|
|
@@ -2369,6 +2436,10 @@ crmfVerify.setEngine(_verifyWithSpki);
|
|
|
2369
2436
|
// same way.
|
|
2370
2437
|
attrcertVerify.setEngine(_verifyWithSpki);
|
|
2371
2438
|
|
|
2439
|
+
// And for a signed OCSPRequest (RFC 6960 sec. 4.1.1), so pki.ocsp.verifyRequest checks a requestor's
|
|
2440
|
+
// signature through the same one engine that verifies a response, never a second, weaker request path.
|
|
2441
|
+
ocspRequestVerify.setEngine(_verifyWithSpki);
|
|
2442
|
+
|
|
2372
2443
|
// ---- the OCSP revocation checker (RFC 6960) -------------------------------
|
|
2373
2444
|
|
|
2374
2445
|
// The OCSP response-verification core (responder authorization + CertID binding + currency +
|
|
@@ -3346,7 +3417,7 @@ async function _fetchAiaIssuers(current, aia) {
|
|
|
3346
3417
|
* @primitive pki.path.build
|
|
3347
3418
|
* @signature pki.path.build(leaf, opts) -> Promise<{ valid, path, trustAnchor, result, candidatesConsidered, aiaFetches }>
|
|
3348
3419
|
* @since 0.3.7
|
|
3349
|
-
* @status
|
|
3420
|
+
* @status stable
|
|
3350
3421
|
* @spec RFC 4158, RFC 5280
|
|
3351
3422
|
* @related pki.path.validate, pki.schema.x509.parse, pki.trust.parseCertdata
|
|
3352
3423
|
*
|
package/lib/schema-c509.js
CHANGED
|
@@ -2014,7 +2014,7 @@ function _reconstructDer(r, sigNode) {
|
|
|
2014
2014
|
* @primitive pki.schema.c509.parse
|
|
2015
2015
|
* @signature pki.schema.c509.parse(bytes) -> { certificateType, serialNumber, serialNumberHex, ... }
|
|
2016
2016
|
* @since 0.2.30
|
|
2017
|
-
* @status
|
|
2017
|
+
* @status stable
|
|
2018
2018
|
* @spec draft-ietf-cose-cbor-encoded-cert, RFC 8949, RFC 9090, RFC 5280
|
|
2019
2019
|
*
|
|
2020
2020
|
* Decode a C509 certificate (draft-ietf-cose-cbor-encoded-cert) from its deterministic-CBOR bytes.
|
|
@@ -2274,7 +2274,7 @@ function _encodeC509Array(r) {
|
|
|
2274
2274
|
* @primitive pki.schema.c509.encode
|
|
2275
2275
|
* @signature pki.schema.c509.encode(input[, opts]) -> Buffer
|
|
2276
2276
|
* @since 0.3.4
|
|
2277
|
-
* @status
|
|
2277
|
+
* @status stable
|
|
2278
2278
|
* @spec draft-ietf-cose-cbor-encoded-cert, RFC 8949, RFC 9090
|
|
2279
2279
|
* @related pki.schema.c509.parse
|
|
2280
2280
|
*
|
package/lib/schema-cmc.js
CHANGED
|
@@ -667,7 +667,7 @@ function _finishBody(body, where) {
|
|
|
667
667
|
* @primitive pki.schema.cmc.parsePkiData
|
|
668
668
|
* @signature pki.schema.cmc.parsePkiData(der) -> parsed
|
|
669
669
|
* @since 0.4.16
|
|
670
|
-
* @status
|
|
670
|
+
* @status stable
|
|
671
671
|
* @spec RFC 5272 sec. 3.2.1
|
|
672
672
|
* @related pki.schema.cmc.parse, pki.schema.cmc.parsePkiResponse
|
|
673
673
|
*
|
|
@@ -695,7 +695,7 @@ function parsePkiData(input) {
|
|
|
695
695
|
* @primitive pki.schema.cmc.parsePkiResponse
|
|
696
696
|
* @signature pki.schema.cmc.parsePkiResponse(der) -> parsed
|
|
697
697
|
* @since 0.4.16
|
|
698
|
-
* @status
|
|
698
|
+
* @status stable
|
|
699
699
|
* @spec RFC 5272 sec. 4.2.1
|
|
700
700
|
* @related pki.schema.cmc.parse, pki.schema.cmc.parsePkiData
|
|
701
701
|
*
|
|
@@ -721,7 +721,7 @@ function parsePkiResponse(input) {
|
|
|
721
721
|
* @primitive pki.schema.cmc.parse
|
|
722
722
|
* @signature pki.schema.cmc.parse(input) -> parsed
|
|
723
723
|
* @since 0.4.16
|
|
724
|
-
* @status
|
|
724
|
+
* @status stable
|
|
725
725
|
* @spec RFC 5272, RFC 6402
|
|
726
726
|
* @defends cmc-status-confusion (CWE-20)
|
|
727
727
|
* @related pki.schema.cmc.parsePkiData, pki.schema.cmc.parsePkiResponse, pki.cms.verify
|
package/lib/sigstore.js
CHANGED
|
@@ -104,7 +104,7 @@ function _jsonParse(input, code, label) {
|
|
|
104
104
|
* @primitive pki.sigstore.pae
|
|
105
105
|
* @signature pki.sigstore.pae(payloadType, payloadBytes) -> Buffer
|
|
106
106
|
* @since 0.2.3
|
|
107
|
-
* @status
|
|
107
|
+
* @status stable
|
|
108
108
|
* @spec DSSE
|
|
109
109
|
* @related pki.sigstore.verifyBundle
|
|
110
110
|
*
|
|
@@ -150,7 +150,7 @@ function _b64(s, label) {
|
|
|
150
150
|
* @primitive pki.sigstore.parseBundle
|
|
151
151
|
* @signature pki.sigstore.parseBundle(input) -> bundle
|
|
152
152
|
* @since 0.2.3
|
|
153
|
-
* @status
|
|
153
|
+
* @status stable
|
|
154
154
|
* @spec Sigstore bundle v0.3
|
|
155
155
|
* @related pki.sigstore.verifyBundle
|
|
156
156
|
*
|
|
@@ -637,7 +637,7 @@ function _statement(payload, payloadType, expectedPredicate) {
|
|
|
637
637
|
* @primitive pki.sigstore.verifyBundle
|
|
638
638
|
* @signature pki.sigstore.verifyBundle(bundle, opts) -> Promise<result>
|
|
639
639
|
* @since 0.2.3
|
|
640
|
-
* @status
|
|
640
|
+
* @status stable
|
|
641
641
|
* @spec DSSE, Sigstore bundle v0.3, RFC 9162, SLSA provenance v1
|
|
642
642
|
* @related pki.sigstore.parseBundle, pki.sigstore.pae
|
|
643
643
|
*
|
package/lib/webauthn.js
CHANGED
|
@@ -1939,7 +1939,7 @@ var CLIENT_DATA_TYPE = Object.assign(Object.create(null), { "webauthn.create": 1
|
|
|
1939
1939
|
* @primitive pki.webauthn.parseClientData
|
|
1940
1940
|
* @signature pki.webauthn.parseClientData(bytes, opts?) -> { type, challenge, origin, crossOrigin, topOrigin, checked }
|
|
1941
1941
|
* @since 0.5.0
|
|
1942
|
-
* @status
|
|
1942
|
+
* @status stable
|
|
1943
1943
|
* @spec W3C WebAuthn Level 3 sec. 5.8.1 / 7.1 / 7.2
|
|
1944
1944
|
* @defends webauthn-ceremony-confusion (CWE-345)
|
|
1945
1945
|
* @related pki.webauthn.verify, pki.webauthn.verifyAssertion
|
|
@@ -2126,7 +2126,7 @@ var _CLIENT_DATA_OPTS = Object.assign(Object.create(null), {
|
|
|
2126
2126
|
* @primitive pki.webauthn.parseAuthenticatorData
|
|
2127
2127
|
* @signature pki.webauthn.parseAuthenticatorData(bytes) -> { rpIdHash, flags, signCount, aaguid, credentialId, credentialPublicKey, credentialPublicKeyBytes, extensions }
|
|
2128
2128
|
* @since 0.5.0
|
|
2129
|
-
* @status
|
|
2129
|
+
* @status stable
|
|
2130
2130
|
* @spec W3C WebAuthn Level 3 sec. 6.1
|
|
2131
2131
|
* @related pki.webauthn.verifyAssertion, pki.webauthn.parseAttestationObject
|
|
2132
2132
|
*
|
|
@@ -2164,7 +2164,7 @@ var _ASSERT_OPTS = Object.assign(Object.create(null), {
|
|
|
2164
2164
|
* @primitive pki.webauthn.verifyAssertion
|
|
2165
2165
|
* @signature pki.webauthn.verifyAssertion(input) -> Promise<{ signatureVerified, signCount, signCountChecked, flags, rpIdHash, extensions, bindingChecked, clientData }>
|
|
2166
2166
|
* @since 0.5.0
|
|
2167
|
-
* @status
|
|
2167
|
+
* @status stable
|
|
2168
2168
|
* @spec W3C WebAuthn Level 3 sec. 7.2
|
|
2169
2169
|
* @defends webauthn-assertion-forgery (CWE-347)
|
|
2170
2170
|
* @related pki.webauthn.parseAuthenticatorData, pki.webauthn.verify
|
package/package.json
CHANGED
package/sbom.cdx.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
|
|
3
3
|
"bomFormat": "CycloneDX",
|
|
4
4
|
"specVersion": "1.5",
|
|
5
|
-
"serialNumber": "urn:uuid:
|
|
5
|
+
"serialNumber": "urn:uuid:1d7ac08a-caae-46f2-b074-9a7c370ea22f",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-08-
|
|
8
|
+
"timestamp": "2026-08-30T12:52:47.496Z",
|
|
9
9
|
"lifecycles": [
|
|
10
10
|
{
|
|
11
11
|
"phase": "build"
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
"component": {
|
|
22
|
-
"bom-ref": "@blamejs/pki@0.
|
|
22
|
+
"bom-ref": "@blamejs/pki@0.6.1",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "pki",
|
|
25
|
-
"version": "0.
|
|
25
|
+
"version": "0.6.1",
|
|
26
26
|
"scope": "required",
|
|
27
27
|
"author": "blamejs contributors",
|
|
28
28
|
"description": "Pure-JavaScript PKI toolkit that owns its stack — X.509, ASN.1/DER, CMS, PQC-first.",
|
|
29
|
-
"purl": "pkg:npm/%40blamejs/pki@0.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/pki@0.6.1",
|
|
30
30
|
"properties": [],
|
|
31
31
|
"externalReferences": [
|
|
32
32
|
{
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"components": [],
|
|
55
55
|
"dependencies": [
|
|
56
56
|
{
|
|
57
|
-
"ref": "@blamejs/pki@0.
|
|
57
|
+
"ref": "@blamejs/pki@0.6.1",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|