@blamejs/pki 0.1.2 → 0.1.3

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,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.1.3 — 2026-07-04
8
+
9
+ WebCrypto EC key import validates the curve against the key material.
10
+
11
+ ### Security
12
+
13
+ - pki.webcrypto.subtle.importKey now derives an imported EC key's named curve from the key material and enforces it across the spki, pkcs8 and jwk formats. Previously it trusted the caller-supplied namedCurve without checking it against the key, so a key on an unsupported curve (for example secp256k1) imported as an approved curve, and a key on one curve could be labelled as another — an algorithm-confusion vector in which the CryptoKey's algorithm disagreed with its key material. A curve the framework does not support is now rejected (NotSupportedError) and a namedCurve that does not match the key is rejected (DataError); generateKey already enforced this, and import now matches it. The raw-key format was already validated against its declared curve and is unchanged.
14
+
7
15
  ## v0.1.2 — 2026-07-04
8
16
 
9
17
  Fail-closed hardening across the DER codec, WebCrypto engine, and X.509 parser.
package/lib/webcrypto.js CHANGED
@@ -490,7 +490,23 @@ function _importRawPublic(name, alg, raw, extractable, usages) {
490
490
  }
491
491
 
492
492
  function _algFromImport(name, alg, keyObject) {
493
- if (name === "ECDSA" || name === "ECDH") return { name: name, namedCurve: alg.namedCurve || _curveFromKey(keyObject) };
493
+ if (name === "ECDSA" || name === "ECDH") {
494
+ // W3C WebCrypto EC import — the curve is a property of the KEY, not the
495
+ // caller's claim. Derive it from the imported key material; reject an
496
+ // unsupported curve (NotSupportedError, matching generateKey) and reject a
497
+ // requested namedCurve that disagrees with the key (DataError). Trusting
498
+ // alg.namedCurve would mislabel the CryptoKey (algorithm confusion) and let
499
+ // a non-approved curve import as an approved one.
500
+ var actualCurve = _curveFromKey(keyObject);
501
+ if (!actualCurve) {
502
+ throw new WebCryptoError("webcrypto/not-supported", name + ": imported key uses an unsupported EC curve");
503
+ }
504
+ if (alg.namedCurve && alg.namedCurve !== actualCurve) {
505
+ throw new WebCryptoError("webcrypto/data", name + ": importKey namedCurve " + JSON.stringify(alg.namedCurve) +
506
+ " does not match the imported key's curve " + JSON.stringify(actualCurve));
507
+ }
508
+ return { name: name, namedCurve: actualCurve };
509
+ }
494
510
  if (name === "RSASSA-PKCS1-V1_5" || name === "RSA-PSS" || name === "RSA-OAEP") return { name: name, hash: _hashObj(alg.hash) };
495
511
  if (name === "ED25519") return { name: "Ed25519" };
496
512
  if (name === "ED448") return { name: "Ed448" };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blamejs/pki",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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:61f60234-7f86-4857-9542-58817209d84d",
5
+ "serialNumber": "urn:uuid:2e1fe0ea-94e8-4271-ae62-9f7de0920674",
6
6
  "version": 1,
7
7
  "metadata": {
8
- "timestamp": "2026-07-04T19:11:06.976Z",
8
+ "timestamp": "2026-07-04T19:30:56.018Z",
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.1.2",
22
+ "bom-ref": "@blamejs/pki@0.1.3",
23
23
  "type": "application",
24
24
  "name": "pki",
25
- "version": "0.1.2",
25
+ "version": "0.1.3",
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.1.2",
29
+ "purl": "pkg:npm/%40blamejs/pki@0.1.3",
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.1.2",
57
+ "ref": "@blamejs/pki@0.1.3",
58
58
  "dependsOn": []
59
59
  }
60
60
  ]