@ai-ecoverse/slicc-kernel 1.125.8 → 1.125.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -426,7 +426,7 @@ The module's default export (or its `main` export) is called with a context and
426
426
  - With `rejectUnauthorized: false`, `chainError` says what is wrong with the chain apart from the name, with Node's names, and is absent when the chain is fine:
427
427
  - a self-signed leaf alone is `DEPTH_ZERO_SELF_SIGNED_CERT`;
428
428
  - an untrusted chain ending in a self-signed root is `SELF_SIGNED_CERT_IN_CHAIN`;
429
- - self-signed means the certificate's own key verifies its signature (RSA PKCS#1 v1.5, ECDSA P-256/384/521 or Ed25519), not just that its issuer and subject names match, so a self-issued certificate signed by another key, such as a CA rollover certificate, is not self-signed, as in Node ([#1059](https://github.com/ai-ecoverse/slicc-kernel/issues/1059));
429
+ - self-signed means the certificate's own key verifies its signature (RSA PKCS#1 v1.5, RSA-PSS, ECDSA P-256/384/521 or Ed25519; a signature the kernel can't verify is not self-signed), not just that its issuer and subject names match, so a self-issued certificate signed by another key, such as a CA rollover certificate, is not self-signed, as in Node ([#1059](https://github.com/ai-ecoverse/slicc-kernel/issues/1059));
430
430
  - a lone leaf whose issuer is unknown is `UNABLE_TO_VERIFY_LEAF_SIGNATURE`;
431
431
  - an untrusted longer chain is `UNABLE_TO_GET_ISSUER_CERT_LOCALLY`;
432
432
  - otherwise it's the reason's code, such as `CERT_HAS_EXPIRED`.
@@ -6632,7 +6632,7 @@ function satisfies(version, range2) {
6632
6632
  }
6633
6633
 
6634
6634
  // src/version.ts
6635
- var KERNEL_VERSION = true ? "1.125.8" : "0.0.0-dev";
6635
+ var KERNEL_VERSION = true ? "1.125.9" : "0.0.0-dev";
6636
6636
  var OS_RELEASE = "6.0.0-slicc";
6637
6637
  function procVersion() {
6638
6638
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -17313,8 +17313,32 @@ var HASHES = {
17313
17313
  "2a8648ce3d040302": ["ECDSA", "SHA-256"],
17314
17314
  "2a8648ce3d040303": ["ECDSA", "SHA-384"],
17315
17315
  "2a8648ce3d040304": ["ECDSA", "SHA-512"],
17316
- "2b6570": ["Ed25519", ""]
17316
+ "2b6570": ["Ed25519", ""],
17317
+ "2a864886f70d01010a": ["RSA-PSS", "SHA-1"]
17317
17318
  };
17319
+ var PSS_HASHES = {
17320
+ "2b0e03021a": "SHA-1",
17321
+ "608648016503040201": "SHA-256",
17322
+ "608648016503040202": "SHA-384",
17323
+ "608648016503040203": "SHA-512"
17324
+ };
17325
+ function pssOf(der, algorithm) {
17326
+ const params = children2(der, algorithm, 2)?.[1];
17327
+ let hash = "SHA-1";
17328
+ let salt = 20;
17329
+ for (const field4 of params && der[params.start] === 48 ? children2(der, params, 3) ?? [] : []) {
17330
+ const inner = tlv2(der, field4.body);
17331
+ if (!inner) return void 0;
17332
+ if (der[field4.start] === 160) {
17333
+ const known = PSS_HASHES[oidOf(der, inner) ?? ""];
17334
+ if (!known) return void 0;
17335
+ hash = known;
17336
+ } else if (der[field4.start] === 162) {
17337
+ salt = der.subarray(inner.body, inner.end).reduce((n, b) => n * 256 + b, 0);
17338
+ }
17339
+ }
17340
+ return { hash, salt };
17341
+ }
17318
17342
  var CURVES = {
17319
17343
  "2a8648ce3d030107": ["P-256", 32],
17320
17344
  "2b81040022": ["P-384", 48],
@@ -17349,10 +17373,13 @@ function signedOf(der) {
17349
17373
  const spki = parts2?.tbs[5];
17350
17374
  if (!tbs || !algorithm || !value2 || !spki || der[value2.start] !== 3) return void 0;
17351
17375
  const known = HASHES[oidOf(der, algorithm) ?? ""];
17352
- if (!known) return "unknown";
17353
- const [scheme, hash] = known;
17376
+ if (!known) return void 0;
17377
+ const [scheme] = known;
17378
+ const pss = scheme === "RSA-PSS" ? pssOf(der, algorithm) : void 0;
17379
+ if (scheme === "RSA-PSS" && !pss) return void 0;
17380
+ const hash = pss?.hash ?? known[1];
17354
17381
  const curve = scheme === "ECDSA" ? curveOf(der, spki) : void 0;
17355
- if (scheme === "ECDSA" && !curve) return "unknown";
17382
+ if (scheme === "ECDSA" && !curve) return void 0;
17356
17383
  const signature = der.subarray(value2.body + 1, value2.end);
17357
17384
  return {
17358
17385
  tbs: raw(der, tbs),
@@ -17360,7 +17387,8 @@ function signedOf(der) {
17360
17387
  signature,
17361
17388
  scheme,
17362
17389
  hash,
17363
- ...curve ? { curve } : {}
17390
+ ...curve ? { curve } : {},
17391
+ ...pss ? { salt: pss.salt } : {}
17364
17392
  };
17365
17393
  }
17366
17394
  async function verifiesItself(s) {
@@ -17371,13 +17399,12 @@ async function verifiesItself(s) {
17371
17399
  ]);
17372
17400
  const signature = s.curve ? fixedEcdsa(s.signature, s.curve[1]) : s.signature;
17373
17401
  if (!signature) return false;
17374
- const params = s.scheme === "ECDSA" ? { name: "ECDSA", hash: s.hash } : { name: s.scheme };
17402
+ const params = s.scheme === "ECDSA" ? { name: "ECDSA", hash: s.hash } : s.salt === void 0 ? { name: s.scheme } : { name: s.scheme, saltLength: s.salt };
17375
17403
  return crypto.subtle.verify(params, key, new Uint8Array(signature), new Uint8Array(s.tbs));
17376
17404
  }
17377
17405
  async function selfSigned(der) {
17378
17406
  if (!selfIssued(der)) return false;
17379
17407
  const signed = signedOf(der);
17380
- if (signed === "unknown") return true;
17381
17408
  if (!signed) return false;
17382
17409
  return verifiesItself(signed).catch(() => false);
17383
17410
  }