@blamejs/pki 0.7.38 → 0.7.39

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,15 @@ 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.7.39 — 2026-09-12
8
+
9
+ An OCSP CertID's issuer hashes are held to the length of the digest they name.
10
+
11
+ ### Changed
12
+
13
+ - pki.schema.ocsp.parseRequest and parseResponse refuse a CertID whose issuerNameHash or issuerKeyHash is not the length of the digest its hashAlgorithm names (ocsp/bad-cert-id, RFC 6960 sec. 4.1.1), for SHA-1, SHA-256, SHA-384, SHA-512, SHA3-256 and SHA3-512; a CertID under a digest this build does not know is read as given. pki.ocsp.verify and pki.ocsp.verifyRequest, which parse first, report such a request or response as malformed instead of comparing a hash that could never match.
14
+ - The digest output lengths live in pki.constants.NAMES.DIGEST_OCTETS, read by the OCSP parser and by pki.tsp.sign and pki.tsp.verify for the messageImprint length check they already made.
15
+
7
16
  ## v0.7.38 — 2026-09-12
8
17
 
9
18
  pki.lint.certificate grades six RFC 5280 rules its parser read past, and the parser surfaces the unique identifiers.
package/lib/constants.js CHANGED
@@ -238,6 +238,11 @@ var NAMES = Object.assign(Object.create(null), {
238
238
  "SLH-DSA-SHA2-128s": "SLH-DSA-SHA2-128s", "SLH-DSA-SHA2-128f": "SLH-DSA-SHA2-128f",
239
239
  "SLH-DSA-SHA2-192s": "SLH-DSA-SHA2-192s", "SLH-DSA-SHA2-256s": "SLH-DSA-SHA2-256s",
240
240
  },
241
+ /** @internal The output length in octets of each fixed-length digest, by the OID registry's name
242
+ * (FIPS 180-4, FIPS 202). A structure that carries "the hash of X under algorithm A" is held to
243
+ * this length: an OCSP CertID's issuer hashes, a timestamp's messageImprint. The XOFs (SHAKE) have
244
+ * no single length and are absent. */
245
+ DIGEST_OCTETS: { sha1: 20, sha256: 32, sha384: 48, sha512: 64, "sha3-256": 32, "sha3-512": 64 },
241
246
  });
242
247
 
243
248
  /** @internal Each inner table is looked up by a name a certificate supplies, so it answers from
@@ -183,9 +183,19 @@ var CERT_ID = schema.seq([
183
183
  schema.field("serialNumber", schema.integerLeaf()),
184
184
  ], {
185
185
  assert: "sequence", arity: { exact: 4 }, code: "ocsp/bad-cert-id", what: "CertID",
186
+ /** @internal RFC 6960 sec. 4.1.1: issuerNameHash and issuerKeyHash are the hashes of the issuer's
187
+ * name and key "using the hash algorithm specified in hashAlgorithm", so each is that digest's
188
+ * length; a hash of any other length names no certificate. A digest this build does not know is
189
+ * read as given, since its length is not known here. */
186
190
  build: function (m) {
191
+ var hashAlgorithm = m.fields.hashAlgorithm.value.result;
192
+ var want = constants.NAMES.DIGEST_OCTETS[hashAlgorithm.name];
193
+ if (want !== undefined) {
194
+ if (m.fields.issuerNameHash.value.length !== want) throw NS.E("ocsp/bad-cert-id", "CertID issuerNameHash is " + m.fields.issuerNameHash.value.length + " octets, not the " + want + " a " + hashAlgorithm.name + " digest is (RFC 6960 sec. 4.1.1)");
195
+ if (m.fields.issuerKeyHash.value.length !== want) throw NS.E("ocsp/bad-cert-id", "CertID issuerKeyHash is " + m.fields.issuerKeyHash.value.length + " octets, not the " + want + " a " + hashAlgorithm.name + " digest is (RFC 6960 sec. 4.1.1)");
196
+ }
187
197
  return {
188
- hashAlgorithm: m.fields.hashAlgorithm.value.result,
198
+ hashAlgorithm: hashAlgorithm,
189
199
  issuerNameHash: m.fields.issuerNameHash.value,
190
200
  issuerKeyHash: m.fields.issuerKeyHash.value,
191
201
  serialNumber: m.fields.serialNumber.value,
package/lib/tsp-sign.js CHANGED
@@ -31,6 +31,7 @@ var frameworkError = require("./framework-error");
31
31
 
32
32
  var pkix = require("./schema-pkix");
33
33
  var pkiBuild = require("./pki-build");
34
+ var constants = require("./constants");
34
35
  var TspError = frameworkError.TspError;
35
36
  var _NS = pkix.makeNS("tsp", TspError, oid);
36
37
  var b = asn1.build;
@@ -48,7 +49,7 @@ var _b = pkiBuild.makeBuilder({
48
49
  });
49
50
 
50
51
  var NODE_DIGEST = intrinsic.assign(intrinsic.create(null), { sha256: "sha256", sha384: "sha384", sha512: "sha512" });
51
- var HASH_LEN = intrinsic.assign(intrinsic.create(null), { sha256: 32, sha384: 48, sha512: 64 });
52
+ var HASH_LEN = constants.NAMES.DIGEST_OCTETS;
52
53
 
53
54
  var _REVOCATION_RANK = intrinsic.assign(intrinsic.create(null), { "false": 0, "undetermined": 1, "waived": 2, "determined": 3 });
54
55
  function _rankRevocation(v) {
@@ -422,7 +423,7 @@ function parseResponse(input) { return schemaTsp.parse(input); }
422
423
 
423
424
 
424
425
  var _VERIFY_DIGEST = intrinsic.assign(intrinsic.create(null), { sha256: "sha256", sha384: "sha384", sha512: "sha512", sha1: "sha1" });
425
- var _VERIFY_DIGEST_LEN = intrinsic.assign(intrinsic.create(null), { sha1: 20, sha256: 32, sha384: 48, sha512: 64 });
426
+ var _VERIFY_DIGEST_LEN = constants.NAMES.DIGEST_OCTETS;
426
427
  var _BIND_DIGEST = intrinsic.assign(intrinsic.create(null), { sha256: "sha256", sha384: "sha384", sha512: "sha512" });
427
428
 
428
429
  function _imprintMatches(mi, data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blamejs/pki",
3
- "version": "0.7.38",
3
+ "version": "0.7.39",
4
4
  "description": "Pure-JavaScript PKI toolkit that owns its stack — X.509, ASN.1/DER, CMS, PQC-first.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "blamejs contributors",
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:c822cb0e-bdf1-4b76-ba2a-51824bba609d",
5
+ "serialNumber": "urn:uuid:5b3f8b70-36de-4855-8e1e-c6d22b99d982",
6
6
  "version": 1,
7
7
  "metadata": {
8
- "timestamp": "2026-09-12T14:08:23.734Z",
8
+ "timestamp": "2026-09-12T14:40:25.102Z",
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.7.38",
22
+ "bom-ref": "@blamejs/pki@0.7.39",
23
23
  "type": "application",
24
24
  "name": "pki",
25
- "version": "0.7.38",
25
+ "version": "0.7.39",
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.7.38",
29
+ "purl": "pkg:npm/%40blamejs/pki@0.7.39",
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.7.38",
57
+ "ref": "@blamejs/pki@0.7.39",
58
58
  "dependsOn": []
59
59
  }
60
60
  ]