@blamejs/pki 0.2.28 → 0.2.29
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 +8 -0
- package/README.md +1 -1
- package/lib/cms-verify.js +3 -1
- package/lib/ct.js +63 -3
- package/lib/lint.js +3 -0
- package/lib/ocsp-verify.js +1 -0
- package/lib/path-validate.js +1 -0
- package/lib/validator-sig.js +6 -2
- package/lib/webauthn.js +4 -4
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ 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.2.29 — 2026-07-16
|
|
8
|
+
|
|
9
|
+
Certificate Transparency log-list signature verification arrives as pki.ct.verifyLogListSignature: verify the detached signature published alongside the CT log list against a caller-pinned signer key, completing the offline log-list trust chain.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- pki.ct.verifyLogListSignature(json, signature, publicKey) verifies the detached signature over the Certificate Transparency log list (log_list.sig over log_list.json). The message is the raw json bytes, verified byte-for-byte with no canonicalization; publicKey is the caller-pinned signer SubjectPublicKeyInfo (there is no embedded key). The scheme is RSASSA-PKCS1-v1.5 with SHA-256 (an EC P-256 arm is accepted for future-proofing). It resolves true or false (a cryptographic verdict) and throws a typed CtError on a forgeable or unsupported key (an RSA exponent below 3, a sub-2048-bit RSA key, an unsupported key type or curve, a non-conformant ECDSA DER signature). Its verdict is cross-checked against OpenSSL's dgst -verify. Paired with pki.ct.parseLogList, this completes the offline CT log-list trust chain.
|
|
14
|
+
|
|
7
15
|
## v0.2.28 — 2026-07-16
|
|
8
16
|
|
|
9
17
|
The Certificate Transparency log-list trust surface arrives as pki.ct.parseLogList and pki.ct.verifySctWithLogList: resolve a trusted CT log's key from an SCT's log id and verify it in one step, ingesting the CT log-list JSON into state- and temporal-interval-constrained trusted logs.
|
package/README.md
CHANGED
|
@@ -225,7 +225,7 @@ is callable today; nothing below is a stub.
|
|
|
225
225
|
| `pki.smime` | RFC 8551 S/MIME message assembly, verification, encryption, and compression over the CMS layer — `sign(content, signers, opts)` wraps a MIME entity as a signed S/MIME message in either form: `multipart/signed` (clear-signed — the content stays readable in any MUA, a detached CMS SignedData rides alongside as `application/pkcs7-signature` with a matching `micalg`) or `application/pkcs7-mime; smime-type=signed-data` (opaque — the whole entity is a base64 CMS SignedData). The signed bytes are the entity's RFC 8551 §3.1.1 canonical form (CRLF line endings); `verify(message, opts)` unwraps both forms and recomputes over the same canonicalizer, so a transport that re-wraps line endings still verifies and a tampered part fails. `encrypt(content, recipients, opts)` envelopes a MIME entity as an opaque `application/pkcs7-mime` message and `decrypt(message, keyMaterial, opts)` opens one — `smime-type=authEnveloped-data` (AES-GCM, confidentiality and integrity, the default) or `smime-type=enveloped-data` (AES-CBC, confidentiality only, so `decrypt` reports `authenticated: false`, the §3.3 no-integrity caveat); the `smime-type` is derived from the CMS body, not the header, and decryption is fail-closed and oracle-free. The crypto is entirely `pki.cms.sign` / `verify` / `encrypt` / `decrypt` — any RSA / RSASSA-PSS / ECDSA / EdDSA / ML-DSA / SLH-DSA signer and any RSA-OAEP / ECDH / X25519 / X448 / AES-KW / PBKDF2 / ML-KEM recipient carries through (algorithm-agnostic). Like `cms.verify`, `verify` returns the per-signer cryptographic verdict plus the recovered content; chaining a signer to a trust anchor is the caller's `pki.path.validate` step. `compress(content, opts)` / `decompress(message, opts)` add the opaque `application/pkcs7-mime; smime-type=compressed-data; name=smime.p7z` frame (RFC 8551 §3.6, RFC 3274) — a size transform with no integrity/confidentiality (§2.4.5), decompress bounded against a bomb; the recovered content, which may itself be signed or enveloped, is returned for the caller to re-verify. Bidirectionally interoperable with `openssl smime` / `openssl cms`. Fail-closed with typed `smime/*` errors — `sign`, `verify`, `encrypt`, `decrypt`, `compress`, `decompress` |
|
|
226
226
|
| `pki.tsp` | RFC 3161 Time-Stamp Protocol — `sign(messageImprint, tsa, opts)` produces a TimeStampToken: a CMS SignedData (over `pki.cms.sign`) whose content is a `TSTInfo` carrying the timestamped message imprint, the TSA policy, a serial number, and `genTime` (with optional accuracy / nonce / ordering), plus the RFC 3161 §2.4.2 signing-certificate attribute binding the token to the TSA certificate (SHA-2 imprints, any `pki.cms.sign` TSA key). `request` / `parseRequest` build and parse the TimeStampReq a client sends (imprint, requested policy, nonce, certReq), `response` / `parseResponse` the TimeStampResp a TSA returns — a granted status wrapping a token, or a rejection with PKIStatus and failure info, the §2.4.2 status↔token coupling enforced in both directions. `verify(token, data, opts)` verifies a token fail-closed: the CMS signature over the exact signed bytes, the message imprint recomputed from the data, the TSTInfo content type, the ESSCertID(V2) binding to the TSA certificate, the §2.3 critical timeStamping-only extendedKeyUsage, the request nonce when used, and — with a trust anchor supplied — full certification-path validation of the TSA certificate at the token's `genTime`, returning `{ valid, genTime, serialNumber, tstInfo, … }` — `sign`, `request`, `parseRequest`, `response`, `parseResponse`, `verify` |
|
|
227
227
|
| `pki.ocsp` | RFC 6960 Online Certificate Status Protocol — the responder and relying-party surface. `buildRequest(query, opts)` builds an OCSPRequest for one or more `{ cert, issuer }` pairs (CertID hashed under SHA-1 by default per the RFC 5019 lightweight profile, or SHA-2; optional RFC 9654 nonce, optional requestor signature). `sign(responseData, responder, opts)` produces a signed BasicOCSPResponse over the exact `ResponseData` DER — the issuing CA directly or a delegated responder, any `pki.cms.sign` key including the post-quantum ML-DSA / SLH-DSA sets, with `good` / `revoked` (reason + time) / `unknown` per-certificate status, and `buildErrorResponse(status)` the unsigned §2.3 error (`tryLater` / `unauthorized` / …). `verify(response, opts)` verifies a response fail-closed against the same hardened gates `pki.path.ocspChecker` runs: the CertID binding, responder authorization (the issuing CA or a CA-issued delegate bearing id-kp-OCSPSigning **and** id-pkix-ocsp-nocheck, passing the full out-of-path certificate gates), the signature over `tbsResponseDataBytes`, currency (`thisUpdate`/`nextUpdate`), and the request-nonce echo — returning `{ status: "good" / "revoked" / "unknown", … }`, never a silent accept. Transport-free — `buildRequest`, `sign`, `buildErrorResponse`, `verify` |
|
|
228
|
-
| `pki.ct` | RFC 6962 Certificate Transparency SCTs — `parseSctList` decodes the `SignedCertificateTimestampList` a certificate or OCSP response carries in the SCT extension (a TLS-presentation-language payload inside the §3.3 double DER wrap) into per-SCT log id, exact `timestamp` (BigInt), named signature algorithm, and raw signature; `reconstructSignedData` rebuilds the exact `digitally-signed` preimage; `verifySct` verifies an SCT signature against a log's public key by reconstructing the signed data, routing an ECDSA signature through the strict DER-conformance gate, and verifying through the crypto engine — resolving true or false, and throwing a typed error on a structural fault. The producing side: `encodeSctList` builds the extension value byte-for-byte (the exact inverse of `parseSctList`) and `signSct` performs a log's signing step (rebuilding the same signed-data preimage the verifier hashes and signing it with the log's ECDSA-P-256 / RSA key). The trust surface: `parseLogList` ingests the CT log-list JSON into constraint-carrying trusted logs — recomputing each log's id as SHA-256 of its key and refusing a disagreeing id (a swapped key, §3.2), decoding the state + temporal-interval constraints — and `verifySctWithLogList` resolves the log key from an SCT's log id, enforces the state (usable/qualified/readonly trusted; retired only before retirement; pending/rejected refused) and the temporal-interval window, then delegates the signature check to `verifySct`. Structure decoded, crypto fail-closed — `parseSctList`, `reconstructSignedData`, `verifySct`, `encodeSctList`, `signSct`, `parseLogList`, `verifySctWithLogList` |
|
|
228
|
+
| `pki.ct` | RFC 6962 Certificate Transparency SCTs — `parseSctList` decodes the `SignedCertificateTimestampList` a certificate or OCSP response carries in the SCT extension (a TLS-presentation-language payload inside the §3.3 double DER wrap) into per-SCT log id, exact `timestamp` (BigInt), named signature algorithm, and raw signature; `reconstructSignedData` rebuilds the exact `digitally-signed` preimage; `verifySct` verifies an SCT signature against a log's public key by reconstructing the signed data, routing an ECDSA signature through the strict DER-conformance gate, and verifying through the crypto engine — resolving true or false, and throwing a typed error on a structural fault. The producing side: `encodeSctList` builds the extension value byte-for-byte (the exact inverse of `parseSctList`) and `signSct` performs a log's signing step (rebuilding the same signed-data preimage the verifier hashes and signing it with the log's ECDSA-P-256 / RSA key). The trust surface: `parseLogList` ingests the CT log-list JSON into constraint-carrying trusted logs — recomputing each log's id as SHA-256 of its key and refusing a disagreeing id (a swapped key, §3.2), decoding the state + temporal-interval constraints — and `verifySctWithLogList` resolves the log key from an SCT's log id, enforces the state (usable/qualified/readonly trusted; retired only before retirement; pending/rejected refused) and the temporal-interval window, then delegates the signature check to `verifySct`. `verifyLogListSignature(json, signature, publicKey)` verifies the detached `log_list.sig` over the raw log-list bytes against a caller-pinned signer key (RSASSA-PKCS1-v1.5/SHA-256, EC P-256 arm; forgeable-key defenses fail closed) — cross-checked against `openssl dgst`, completing the offline log-list trust chain. Structure decoded, crypto fail-closed — `parseSctList`, `reconstructSignedData`, `verifySct`, `encodeSctList`, `signSct`, `parseLogList`, `verifySctWithLogList`, `verifyLogListSignature` |
|
|
229
229
|
| `pki.merkle` | RFC 6962 / RFC 9162 Merkle-tree proof verification — `leafHash` / `nodeHash` / `emptyRootHash` build the domain-separated (0x00 leaf / 0x01 node) SHA-256 tree hashes; `verifyInclusion` folds an audit proof back to a root and `verifyConsistency` reconstructs both the old and new root (the append-only guarantee), each constant-time-compared to a trusted checkpoint root. Fail-closed on bad geometry, sync hashing, transport-free — `leafHash`, `nodeHash`, `emptyRootHash`, `verifyInclusion`, `verifyConsistency` |
|
|
230
230
|
| `pki.trust` | Mozilla / CCADB trust-store ingestion — `parseCertdata` reads the NSS `certdata.txt` object stream and `parseCcadbCsv` the CCADB CSV export into one identical constraint-carrying anchor shape: the per-purpose trust bits (only `CKT_NSS_TRUSTED_DELEGATOR` grants) and the per-purpose distrust-after dates the bare root list omits. Certificate and trust objects pair by byte-exact issuer + serial (never adjacency) and are cross-checked against the parsed DER, so metadata can never attach to the wrong root; `anchor()` hands an entry to `pki.path.validate({ trustAnchor, checkPurpose })`. Offline, fail-closed, bounded — `parseCertdata`, `parseCcadbCsv`, `anchor` |
|
|
231
231
|
| `pki.shbs` | Stateful hash-based signature **verification** — HSS/LMS (RFC 8554), carried in X.509 by RFC 9802 and CMS by RFC 9708, profiled by NIST SP 800-208 (CNSA 2.0 firmware signing). `verify` checks an HSS signature (every level must pass) and `verifyLms` a single-tree LMS, over the raw public-key / signature blobs the parsers already surface. Pure public-input SHA-256 / SHAKE256 hashing, a data-driven typecode registry, bounds-before-slice reads; a malformed blob throws a typed `ShbsError`, a well-formed-but-wrong signature returns `false`. **Verify only by design** — stateful signing needs atomic one-time-key state that belongs in an HSM — `verify`, `verifyLms` |
|
package/lib/cms-verify.js
CHANGED
|
@@ -253,7 +253,9 @@ function _verifySignature(scheme, hashName, sigBytes, spki, signedBytes, curveOi
|
|
|
253
253
|
if (scheme.kind === "ec") {
|
|
254
254
|
var ec = EC_CURVE[curveOid];
|
|
255
255
|
if (!ec) throw _err("cms/unsupported-algorithm", "the signer key is on an unsupported EC curve");
|
|
256
|
-
|
|
256
|
+
// The ORDER-AWARE gate: r,s in [1, n-1] per FIPS 186-5 sec. 6.4.2 (rejecting an out-of-range r/s >= the
|
|
257
|
+
// curve order n, not only the r=s=0 forgery) -- a verifier that knows the curve MUST use it.
|
|
258
|
+
var raw = validator.sig.ecdsaDerToP1363(sigBytes, ec.curve, CmsError, "cms/bad-signature");
|
|
257
259
|
return subtle.importKey("spki", spki, { name: "ECDSA", namedCurve: ec.curve }, false, ["verify"])
|
|
258
260
|
.then(function (k) { return subtle.verify({ name: "ECDSA", hash: hashName }, k, raw, signedBytes); });
|
|
259
261
|
}
|
package/lib/ct.js
CHANGED
|
@@ -396,9 +396,10 @@ async function verifySct(entry, sct, logPublicKey) {
|
|
|
396
396
|
if (!ec) throw new CtError("ct/unsupported-algorithm", "unsupported SCT log EC curve (RFC 6962 sec. 2.1.4 mandates NIST P-256)");
|
|
397
397
|
imp = { name: "ECDSA", namedCurve: ec.curve };
|
|
398
398
|
ver = { name: "ECDSA", hash: hashName };
|
|
399
|
-
// The SCT signature is a DER ECDSA-Sig-Value; route it through the
|
|
400
|
-
//
|
|
401
|
-
|
|
399
|
+
// The SCT signature is a DER ECDSA-Sig-Value; route it through the ORDER-AWARE conformance gate
|
|
400
|
+
// (primitive, minimal, and r,s in [1, n-1] per FIPS 186-5 sec. 6.4.2 -- rejecting an out-of-range
|
|
401
|
+
// r/s >= the curve order n, not only the r=s=0 shape) before converting to raw r||s.
|
|
402
|
+
sig = validator.sig.ecdsaDerToP1363(sig, ec.curve, CtError, "ct/bad-signature");
|
|
402
403
|
} else if (sigInfo.signatureName === "rsa") {
|
|
403
404
|
if (alg.algOid !== oid.byName("rsaEncryption")) throw new CtError("ct/bad-input", "the SCT declares an RSA signature but the log key is not an RSA key");
|
|
404
405
|
if (!(alg.rsaBits >= 2048)) throw new CtError("ct/unsupported-algorithm", "the SCT log RSA key is below the RFC 6962 sec. 2.1.4 minimum of 2048 bits");
|
|
@@ -622,6 +623,7 @@ function _parseTemporalInterval(ti) {
|
|
|
622
623
|
if (typeof ti !== "object") throw _ctErr("ct/bad-log-list", "a CT log temporal_interval must be an object");
|
|
623
624
|
var start = rfc3339.parse(ti.start_inclusive, _ctErr, "ct/bad-date", "temporal_interval.start_inclusive");
|
|
624
625
|
var end = rfc3339.parse(ti.end_exclusive, _ctErr, "ct/bad-date", "temporal_interval.end_exclusive");
|
|
626
|
+
// allow:nan-date-comparison-unguarded -- start/end are rfc3339.parse results, guaranteed non-NaN (rfc3339.isValid rejects a NaN date).
|
|
625
627
|
if (start.getTime() >= end.getTime()) throw _ctErr("ct/bad-log-list", "a CT log temporal_interval start_inclusive must be strictly before end_exclusive");
|
|
626
628
|
return { startInclusive: start, endExclusive: end };
|
|
627
629
|
}
|
|
@@ -787,6 +789,63 @@ async function verifySctWithLogList(entry, sct, logList, opts) {
|
|
|
787
789
|
return verifySct(entry, sct, log.key); // the shipped crypto verdict (re-checks the logId binding)
|
|
788
790
|
}
|
|
789
791
|
|
|
792
|
+
/**
|
|
793
|
+
* @primitive pki.ct.verifyLogListSignature
|
|
794
|
+
* @signature pki.ct.verifyLogListSignature(json, signature, publicKey) -> Promise<boolean>
|
|
795
|
+
* @since 0.2.29
|
|
796
|
+
* @status experimental
|
|
797
|
+
* @spec RFC 6962, RFC 8017
|
|
798
|
+
* @related pki.ct.parseLogList, pki.ct.verifySct
|
|
799
|
+
*
|
|
800
|
+
* Verify the detached signature published alongside the Certificate Transparency log list (the
|
|
801
|
+
* `log_list.sig` over `log_list.json`). `json` is the RAW log-list bytes (a Buffer, or the fetched text
|
|
802
|
+
* as a string -- verified byte-for-byte, never re-serialized), `signature` is the detached signature, and
|
|
803
|
+
* `publicKey` is the caller-PINNED signer SubjectPublicKeyInfo (DER; there is no baked-in key). The scheme
|
|
804
|
+
* is RSASSA-PKCS1-v1.5 with SHA-256 over an RSA key (the deployed scheme; an EC P-256 / ECDSA-SHA-256 arm
|
|
805
|
+
* is accepted for future-proofing). Resolves `true` for a valid signature, `false` on a cryptographic
|
|
806
|
+
* mismatch (a verdict). Fail-closed forgery defenses throw before any verify: an RSA public exponent below
|
|
807
|
+
* 3 or even (`ct/bad-input`), a sub-2048-bit RSA key or an unsupported key type / curve
|
|
808
|
+
* (`ct/unsupported-algorithm`), a non-conformant ECDSA DER Sig-Value (`ct/bad-signature`); a structural
|
|
809
|
+
* evaluation failure is `ct/verify-error`. Offline: the caller fetches and pins; the toolkit only verifies.
|
|
810
|
+
*
|
|
811
|
+
* @example
|
|
812
|
+
* var ok = await pki.ct.verifyLogListSignature(logListJsonBytes, logListSig, googleSignerSpki);
|
|
813
|
+
*/
|
|
814
|
+
async function verifyLogListSignature(json, signature, publicKey) {
|
|
815
|
+
var message = typeof json === "string" ? Buffer.from(json) : _toBuffer(json, "the CT log list JSON");
|
|
816
|
+
// Bound the signed message before the digest/verify (the same cap parseLogList enforces) so a hostile
|
|
817
|
+
// caller cannot force unbounded hashing work on an oversized input (CWE-400).
|
|
818
|
+
if (message.length > C.LIMITS.CT_LOG_LIST_MAX_BYTES) throw new CtError("ct/too-large", "the CT log list exceeds the " + C.LIMITS.CT_LOG_LIST_MAX_BYTES + "-byte cap");
|
|
819
|
+
var sig = _toBuffer(signature, "the CT log list signature");
|
|
820
|
+
var spki = _toBuffer(publicKey, "the CT log list signer public key (SPKI)");
|
|
821
|
+
var alg = _spkiAlg(spki); // fail-closed: a non-SPKI key or a forgeable RSA e < 3 throws ct/bad-input
|
|
822
|
+
var imp, ver;
|
|
823
|
+
if (alg.algOid === oid.byName("rsaEncryption")) {
|
|
824
|
+
if (!(alg.rsaBits >= 2048)) throw new CtError("ct/unsupported-algorithm", "the CT log-list signer RSA key is below the 2048-bit minimum");
|
|
825
|
+
imp = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" };
|
|
826
|
+
ver = { name: "RSASSA-PKCS1-v1_5" };
|
|
827
|
+
} else if (alg.algOid === oid.byName("ecPublicKey")) {
|
|
828
|
+
var ec = CT_EC_CURVE[alg.curveOid];
|
|
829
|
+
if (!ec) throw new CtError("ct/unsupported-algorithm", "unsupported CT log-list signer EC curve (only NIST P-256)");
|
|
830
|
+
imp = { name: "ECDSA", namedCurve: ec.curve };
|
|
831
|
+
ver = { name: "ECDSA", hash: "SHA-256" };
|
|
832
|
+
// A DER ECDSA-Sig-Value: route through the ORDER-AWARE conformance gate (primitive, minimal, and
|
|
833
|
+
// r,s in [1, n-1] per FIPS 186-5 sec. 6.4.2 -- defeating the CVE-2022-21449 r=s=0 forgery AND an
|
|
834
|
+
// out-of-range r/s >= the curve order n) before the raw r||s conversion.
|
|
835
|
+
sig = validator.sig.ecdsaDerToP1363(sig, ec.curve, CtError, "ct/bad-signature");
|
|
836
|
+
} else {
|
|
837
|
+
throw new CtError("ct/unsupported-algorithm", "unsupported CT log-list signer key algorithm (only rsaEncryption / ecPublicKey P-256)");
|
|
838
|
+
}
|
|
839
|
+
// A wrong signature resolves false from subtle.verify (a verdict); a structural failure -- an
|
|
840
|
+
// unimportable key -- is re-thrown fail-closed.
|
|
841
|
+
try {
|
|
842
|
+
var key = await subtle.importKey("spki", spki, imp, false, ["verify"]);
|
|
843
|
+
return await subtle.verify(ver, key, sig, message);
|
|
844
|
+
} catch (e) {
|
|
845
|
+
throw new CtError("ct/verify-error", "the CT log-list signature could not be evaluated", e);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
790
849
|
module.exports = {
|
|
791
850
|
parseSctList: parseSctList,
|
|
792
851
|
reconstructSignedData: reconstructSignedData,
|
|
@@ -795,6 +854,7 @@ module.exports = {
|
|
|
795
854
|
signSct: signSct,
|
|
796
855
|
parseLogList: parseLogList,
|
|
797
856
|
verifySctWithLogList: verifySctWithLogList,
|
|
857
|
+
verifyLogListSignature: verifyLogListSignature,
|
|
798
858
|
HASH_ALGORITHMS: HASH_ALGORITHMS,
|
|
799
859
|
SIGNATURE_ALGORITHMS: SIGNATURE_ALGORITHMS,
|
|
800
860
|
};
|
package/lib/lint.js
CHANGED
|
@@ -156,6 +156,7 @@ function _makeCtx(cert, profile) {
|
|
|
156
156
|
function _effective(rule, cert) {
|
|
157
157
|
if (!rule.effectiveDate) return true;
|
|
158
158
|
var nb = cert.validity && cert.validity.notBefore;
|
|
159
|
+
// allow:nan-date-comparison-unguarded -- nb is a codec-parsed cert notBefore (asn1 readTime rejects a NaN instant); effectiveDate is a Date literal.
|
|
159
160
|
return (nb instanceof Date) && nb.getTime() >= rule.effectiveDate.getTime();
|
|
160
161
|
}
|
|
161
162
|
|
|
@@ -296,6 +297,7 @@ var RFC5280_RULES = [
|
|
|
296
297
|
message: "the certificate notBefore must not be later than notAfter",
|
|
297
298
|
check: function (cert) {
|
|
298
299
|
var v = cert.validity;
|
|
300
|
+
// allow:nan-date-comparison-unguarded -- notBefore/notAfter are codec-parsed cert dates (asn1 readTime rejects a NaN instant).
|
|
299
301
|
return (v.notBefore instanceof Date && v.notAfter instanceof Date && v.notBefore.getTime() > v.notAfter.getTime()) ? true : null;
|
|
300
302
|
},
|
|
301
303
|
},
|
|
@@ -375,6 +377,7 @@ var VALIDITY_SCHEDULE = [
|
|
|
375
377
|
var VALIDITY_SCHEDULE_START = VALIDITY_SCHEDULE[VALIDITY_SCHEDULE.length - 1].from;
|
|
376
378
|
function _validityCeilingDays(notBefore) {
|
|
377
379
|
for (var i = 0; i < VALIDITY_SCHEDULE.length; i++) {
|
|
380
|
+
// allow:nan-date-comparison-unguarded -- notBefore is a codec-parsed cert date (NaN-rejected); the schedule bounds are Date literals.
|
|
378
381
|
if (notBefore.getTime() >= VALIDITY_SCHEDULE[i].from.getTime()) return VALIDITY_SCHEDULE[i].maxDays;
|
|
379
382
|
}
|
|
380
383
|
// Unreachable: the rule's effectiveDate (VALIDITY_SCHEDULE_START) reports NE for any cert
|
package/lib/ocsp-verify.js
CHANGED
|
@@ -206,6 +206,7 @@ function makeOcspVerify(deps) {
|
|
|
206
206
|
if (st.type === "revoked") {
|
|
207
207
|
// Present-time validation revokes regardless of a future revocationTime (skew/post-dating);
|
|
208
208
|
// only explicit historical validation defers a strictly-future revocation (reports good).
|
|
209
|
+
// allow:nan-date-comparison-unguarded -- revocationTime is codec-parsed (NaN-rejected); a NaN check time makes this FAIL CLOSED (sawGood stays unset -> not treated good), and `time` is validated at the pki.ocsp.verify / path.verifyOcspResponse entry points.
|
|
209
210
|
if (historical && st.revocationTime instanceof Date && st.revocationTime.getTime() > time.getTime()) { out.sawGood = true; }
|
|
210
211
|
else if (!out.revoked) { out.revoked = { revocationReason: st.revocationReason || null, reason: "certificate reported revoked by an authorized OCSP responder" + (st.revocationReason ? " (" + st.revocationReason + ")" : "") }; }
|
|
211
212
|
} else if (st.type === "good") { out.sawGood = true; }
|
package/lib/path-validate.js
CHANGED
|
@@ -1766,6 +1766,7 @@ function crlChecker(crls) {
|
|
|
1766
1766
|
// validation (opts.historicalMode) -- validating as of a past instant,
|
|
1767
1767
|
// e.g. a timestamped signature -- does an entry dated AFTER the
|
|
1768
1768
|
// validation time not yet apply.
|
|
1769
|
+
// allow:nan-date-comparison-unguarded -- revocationDate is codec-parsed (NaN-rejected); a NaN check time makes this FAIL CLOSED (the skip is not taken -> the entry is treated as revoked), and `time` is validated at the path.validate / crlChecker entry points.
|
|
1769
1770
|
if (historical && entry.revocationDate instanceof Date && entry.revocationDate.getTime() > time.getTime()) continue;
|
|
1770
1771
|
// Record the revocation but keep scanning: a delta removeFromCRL for the
|
|
1771
1772
|
// same serial (in another CRL) overrides it (base/delta not merged).
|
package/lib/validator-sig.js
CHANGED
|
@@ -98,8 +98,12 @@ function ecdsaDerToP1363(der, curve, E, code) {
|
|
|
98
98
|
if (n.tagClass !== "universal" || n.tagNumber !== asn1.TAGS.SEQUENCE || !n.children || n.children.length !== 2) {
|
|
99
99
|
throw new E(code, "ECDSA signature must be a SEQUENCE of exactly two INTEGERs");
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
// Wrap the strict DER integer reads (they enforce PRIMITIVE + MINIMAL encoding) so a non-minimal /
|
|
102
|
+
// constructed / empty INTEGER surfaces the CALLER's typed code, not a raw asn1/* -- the same behavior
|
|
103
|
+
// as ecdsaSigToRaw, so this gate is a strict superset (DER conformance + the order bound below).
|
|
104
|
+
var r, s;
|
|
105
|
+
try { r = asn1.read.integer(n.children[0]); } catch (e) { throw new E(code, "ECDSA signature r is not a minimally-encoded DER INTEGER", e); }
|
|
106
|
+
try { s = asn1.read.integer(n.children[1]); } catch (e) { throw new E(code, "ECDSA signature s is not a minimally-encoded DER INTEGER", e); }
|
|
103
107
|
if (r < 1n || s < 1n || r >= order || s >= order) {
|
|
104
108
|
throw new E(code, "ECDSA signature component out of range [1, n-1] (CVE-2022-21449)");
|
|
105
109
|
}
|
package/lib/webauthn.js
CHANGED
|
@@ -169,9 +169,9 @@ var COSE_ALG = {
|
|
|
169
169
|
};
|
|
170
170
|
|
|
171
171
|
// DER ECDSA-Sig-Value { r, s } -> raw r||s (the ieee-p1363 form WebCrypto verify expects).
|
|
172
|
-
// validator-sig owns the complete strict-DER conformance
|
|
173
|
-
//
|
|
174
|
-
function _derEcdsaToRaw(der,
|
|
172
|
+
// validator-sig owns the complete strict-DER conformance PLUS the FIPS 186-5 sec. 6.4.2 order bound
|
|
173
|
+
// (r,s in [1, n-1] -- the order-aware gate a curve-aware verifier MUST use), composed here.
|
|
174
|
+
function _derEcdsaToRaw(der, curve) { return validator.sig.ecdsaDerToP1363(der, curve, WebauthnError, "webauthn/bad-signature"); }
|
|
175
175
|
|
|
176
176
|
// Verify `sig` over `message` with the SPKI public key `spkiBytes` under COSE `alg`.
|
|
177
177
|
// A wrong signature resolves `false` from subtle.verify without throwing (a false
|
|
@@ -189,7 +189,7 @@ function _verifySig(alg, sig, spkiBytes, message, E) {
|
|
|
189
189
|
// point before verify. This covers EVERY key that signs a WebAuthn statement: the x5c
|
|
190
190
|
// attestation-certificate key (packed/tpm/apple) AND the self-attestation credential key.
|
|
191
191
|
if (imp.name === "Ed25519" || imp.name === "Ed448") _requireValidEdPoint(spkiBytes, imp.name, E);
|
|
192
|
-
var s = d.ecdsa ? _derEcdsaToRaw(sig, d.
|
|
192
|
+
var s = d.ecdsa ? _derEcdsaToRaw(sig, d.imp.namedCurve) : sig;
|
|
193
193
|
return subtle.importKey("spki", spkiBytes, imp, false, ["verify"])
|
|
194
194
|
.then(function (key) { return subtle.verify(ver, key, s, message); })
|
|
195
195
|
.catch(function (e) { throw _err("webauthn/verify-error", "the attestation signature could not be evaluated", e); });
|
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:2699d42b-0d6d-4b83-a3b9-1e8816b4e49a",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-07-
|
|
8
|
+
"timestamp": "2026-07-16T15:08:05.156Z",
|
|
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.2.
|
|
22
|
+
"bom-ref": "@blamejs/pki@0.2.29",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "pki",
|
|
25
|
-
"version": "0.2.
|
|
25
|
+
"version": "0.2.29",
|
|
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.2.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/pki@0.2.29",
|
|
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.2.
|
|
57
|
+
"ref": "@blamejs/pki@0.2.29",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|