@blamejs/pki 0.7.29 → 0.7.31
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 +26 -0
- package/README.md +1 -1
- package/lib/guard-intrinsic.js +6 -0
- package/lib/hpke.js +192 -72
- package/lib/sigstore.js +136 -111
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,32 @@ 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.31 — 2026-09-12
|
|
8
|
+
|
|
9
|
+
HPKE encrypts to an ML-KEM public key.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- pki.hpke.suites.KEM.ML_KEM_512, ML_KEM_768 and ML_KEM_1024 (0x0040, 0x0041, 0x0042). The HPKE binding is FIPS 203 encapsulation and decapsulation with the 32-byte ML-KEM shared secret as the HPKE shared secret and the 64-byte seed as the private key. setupS and seal take the recipient's encapsulation key as raw bytes, as { pkm }, or as a node:crypto KeyObject; setupR and open take { skm } holding the seed, with pkm optional, or a KeyObject. The base and psk modes and every KDF and AEAD apply; the auth and auth-psk modes, which the ML-KEM KEMs do not define (draft-ietf-hpke-pq sec. 7.2), are refused with hpke/auth-unsupported at both ends. An encapsulation key that fails the FIPS 203 sec. 7.2 check (length or a coefficient at or above q) is refused at import, and an encapsulated key of the wrong length is refused before decapsulation, each as hpke/bad-key. The recipient side of the draft's A.1, A.2 and A.3 vectors (ML-KEM-512 and -768 with HKDF-SHA256, ML-KEM-1024 with HKDF-SHA384) is a full known answer: the vector's encapsulated key decapsulated under its seed, all ten decryptions and all five exports. The sender side is proven by round trip: node:crypto takes no encapsulation randomness, so a fixed ephemeral (opts.eph) is refused on an ML-KEM suite with hpke/bad-input rather than ignored.
|
|
14
|
+
- pki.hpke.suites.KDF.HKDF_SHA384 (0x0002), for any KEM. The draft-ietf-hpke-pq A.3 vector proves it in the key schedule. DHKEM(P-384) stays unoffered: no known-answer vector pairs it with an HKDF key schedule.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- A serialized HPKE private key, { skm, pkm } on setupR, open, opts.eph and opts.senderKey, passes one door for every suite. skm must be a Buffer of exactly the suite's private-key length, an EC scalar additionally in [1, n-1]; the public key is derived from it; and pkm, now optional, must equal that derivation when given. Before this a DHKEM recipient given { skm } alone escaped as a raw TypeError, and a pkm of the wrong length or of another key was fed into the KEM context unchecked, producing a context that could open nothing. A node:crypto KeyObject is checked against the suite's curve or ML-KEM parameter set, and a public KeyObject where a private one is due is refused rather than tried; each refusal is hpke/bad-key naming what was checked.
|
|
19
|
+
- opts.senderKey on setupS and opts.senderPublicKey on setupR are refused with hpke/bad-input in the base and psk modes, where they were previously left unused: a caller who supplied one without mode auth or auth-psk was not authenticating the exchange. A value of undefined or null is still absent. opts.eph is { skm, pkm } or absent (undefined or null); another value, such as 0 or an empty string, is refused with hpke/bad-input instead of being read as absent.
|
|
20
|
+
- pki.hpke.setupS and setupR read each option once, at entry, into a snapshot. mode was read at the default and again at the use, so an option supplied through an accessor could answer auth to the first read and base to the second and get an unauthenticated setup; senderKey was read at its presence check and again at import.
|
|
21
|
+
- The HKDF expand step wipes every block it computed when a later block's HMAC fails, as it already did on the succeeding path. A private KeyObject handed where a public key is due (the recipient key on setupS and seal, senderPublicKey on setupR) now has its public half taken before export, so no JWK carrying the private scalar is produced.
|
|
22
|
+
- The fuzz target for the HPKE recipient path decapsulates under an ML-KEM-768 seed as well as an X25519 key, and selects HKDF-SHA384 among the KDFs.
|
|
23
|
+
|
|
24
|
+
## v0.7.30 — 2026-09-12
|
|
25
|
+
|
|
26
|
+
The Sigstore bundle verifier decides with operations bound when the module loads.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- pki.sigstore.verifyBundle, parseBundle and pae read Buffer.prototype.equals, Buffer.prototype.toString, Buffer.prototype.subarray and Buffer.prototype.indexOf, Buffer.from and Buffer.concat, String.prototype.split, slice, indexOf, charAt and charCodeAt, Array.prototype.map, forEach, filter and slice, Object.assign, Object.create and Object.freeze, String, Number, BigInt, Date, Date.parse, Number.isNaN and JSON.stringify as bound at module load. Replacing Buffer.prototype.equals, String.prototype.split or indexOf, Array.prototype.filter or forEach, or Date.parse after load changes nothing this module decides: a valid bundle still verifies and a Rekor entry whose signature is not the bundle's is still refused. A replacement of Buffer.prototype.toString or subarray, Array.prototype.map, BigInt, Buffer.from or Buffer.concat still reaches the certificate parser and the chain builder's neighbors, which read those live; that residual is theirs and is stated here rather than implied covered.
|
|
31
|
+
- SECURITY.md names the key import and export verbs and the Sigstore bundle verifier among the surfaces that take what they decide with at load.
|
|
32
|
+
|
|
7
33
|
## v0.7.29 — 2026-09-12
|
|
8
34
|
|
|
9
35
|
Every decision pki.key makes is taken with operations bound when the module loads.
|
package/README.md
CHANGED
|
@@ -247,7 +247,7 @@ comment blocks, is at [pkijs.com](https://pkijs.com).
|
|
|
247
247
|
| `pki.merkle` | Merkle-tree proof verification (RFC 6962 / RFC 9162). `leafHash`, `nodeHash`, and `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, which is the append-only guarantee; each is constant-time-compared to a trusted checkpoint root. Fail-closed on bad geometry, sync hashing, transport-free — `leafHash`, `nodeHash`, `emptyRootHash`, `verifyInclusion`, `verifyConsistency` |
|
|
248
248
|
| `pki.trust` | Mozilla and CCADB trust-store ingestion. `parseCertdata` reads the NSS `certdata.txt` object stream and `parseCcadbCsv` the CCADB CSV export, both into one constraint-carrying anchor shape: the per-purpose trust bits, where 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 and serial rather than adjacency and are cross-checked against the parsed DER, so metadata cannot attach to the wrong root. `anchor()` hands an entry to `pki.path.validate({ trustAnchors, checkPurpose })`, and `anchor(entry, { nameConstraints })` attaches the namespace a root program trusts a root for when that is narrower than the root certificate states, a `{ permitted, excluded }` pair of `{ tag, base }` subtrees that `validate` seeds as the RFC 5280 §6.1.1(h)(i) initial value, intersecting with each certificate's own constraints. Offline, fail-closed, bounded — `parseCertdata`, `parseCcadbCsv`, `anchor` |
|
|
249
249
|
| `pki.shbs` | Stateful hash-based signature verification: HSS/LMS (RFC 8554), carried in X.509 by RFC 9802 and in CMS by RFC 9708, profiled by NIST SP 800-208 for CNSA 2.0 firmware signing. `verify` checks an HSS signature, where every level must pass, and `verifyLms` a single-tree LMS, over the raw public-key and signature blobs the parsers already surface. Pure public-input SHA-256 and SHAKE256 hashing, a data-driven typecode registry, and bounds-before-slice reads; a malformed blob throws a typed `ShbsError` while a well-formed but wrong signature returns `false`. Verification only by design, since stateful signing needs atomic one-time-key state that belongs in an HSM. `pki.path.validate` verifies an HSS-signed certificate on its own, so a chain reaching one needs no separate call: the signature covers the whole tbsCertificate rather than a digest of it (RFC 9802 §7.1), and a CertificateList naming the algorithm takes the same route. It is proven against the self-signed certificate RFC 9802 Appendix A publishes — `verify`, `verifyLms` |
|
|
250
|
-
| `pki.hpke` | Hybrid Public Key Encryption (RFC 9180), the encrypt-to-a-public-key primitive behind TLS ECH, MLS, and OHTTP. `setupS` and `setupR` establish a sender or recipient context (KEM encapsulation plus the HKDF key schedule); the context's `seal` and `open` AEAD-encrypt with a sequence-counter nonce, and `export` derives further secrets; the module-level `seal` and `open` are single-shot wrappers. DHKEM (P-256, P-521, X25519, X448)
|
|
250
|
+
| `pki.hpke` | Hybrid Public Key Encryption (RFC 9180), the encrypt-to-a-public-key primitive behind TLS ECH, MLS, and OHTTP. `setupS` and `setupR` establish a sender or recipient context (KEM encapsulation plus the HKDF key schedule); the context's `seal` and `open` AEAD-encrypt with a sequence-counter nonce, and `export` derives further secrets; the module-level `seal` and `open` are single-shot wrappers. DHKEM (P-256, P-521, X25519, X448) in all four modes, proven against the RFC 9180 Appendix A vectors, and the post-quantum ML-KEM-512/768/1024 KEMs (IANA 0x0040 to 0x0042) in the base and psk modes, proven against the draft-ietf-hpke-pq Appendix A vectors; HKDF-SHA256/SHA384/SHA512 by AES-GCM / ChaCha20Poly1305 / export-only. DHKEM(P-384) has no vector under an HKDF key schedule and fails closed. Pure composition over `node:crypto`; the PQ/T hybrid KEMs are a registry data-row extension once the CFRG combiner draft stabilizes — `suites`, `setupS`, `setupR`, `seal`, `open` |
|
|
251
251
|
| `pki.kem` | Composite ML-KEM key establishment (draft-ietf-lamps-pq-composite-kem), a post-quantum ML-KEM hybridized with a traditional RSA-OAEP, ECDH, X25519, or X448 so the established secret holds if either component is later broken. `encapsulate` turns a recipient's composite `SubjectPublicKeyInfo` into a 256-bit shared secret and a ciphertext; `decapsulate` recovers the same secret from the ciphertext and the composite PKCS#8 private key. Each component KEM runs independently and the two secrets are mixed through a SHA3-256 combiner that binds the traditional ciphertext, the traditional public key, and a per-algorithm label. The twelve algorithms pair ML-KEM-768 and ML-KEM-1024 with RSA-OAEP 2048/3072/4096, ECDH over P-256/P-384/P-521 and brainpoolP256r1/P384r1, X25519, and X448, each verified against the draft Appendix G known-answer vectors; a malformed key or ciphertext, an unsupported algorithm, or a component decapsulation failure throws a typed `KemError` — `encapsulate`, `decapsulate` |
|
|
252
252
|
| `pki.sigstore` | Offline verifier for a Sigstore bundle, the artifact `npm publish --provenance` produces and the registry serves. `verifyBundle` composes five fail-closed legs against caller-pinned trust (Fulcio CA roots and Rekor log keys, never trusted from the bundle): the DSSE signature over its PAE preimage under the Fulcio leaf key, the ephemeral Fulcio certificate chain validated as of the Rekor log time, the RFC 9162 inclusion proof folded to a Rekor-signed tree root, the log entry bound to this exact signature, and the in-toto SLSA subject digest the caller confirms against the published artifact. It reuses the X.509 parser, the RFC 5280 path validator, and the Merkle verifier; the net-new codecs are the DSSE PAE byte-builder and a fail-closed JSON reader. `verified: true` says the artifact was signed and logged, not that a party you trust signed it — Fulcio issues to anyone who completes an OIDC flow, so who signed is decided only by `opts.identity`, and `identityChecked` reports which of its fields were compared. An identity policy naming no field, or a field name that is not one of the three, is refused rather than satisfied — either would accept every signer while reading as a policy in force. A sixth leg is opt-in: pinning the certificate-transparency logs in `opts.ctLogs` checks the receipt Fulcio embeds in the certificate it issues (RFC 6962 §3.2), verified over the certificate as it stood before the receipt was added and under the key of the log that issued it, so the verdict says the signing certificate was public when it was issued rather than handed out quietly. At least one receipt must verify against a pinned log, the verdict reports `sctChecked` and `validScts`, and an empty log set is refused rather than read as a policy that checks nothing. Both content arms are read: a DSSE-wrapped in-toto attestation, and a message signature over an artifact's own bytes, which `cosign sign-blob` produces. For that arm `opts.artifact` supplies the bytes, and they are held to the hash the Rekor `hashedrekord` entry records before the signature is checked over them; the `messageDigest` the bundle carries is covered by no signature, so it is compared against the computed digest and never used in its place. `contentType` names the arm and the verdict has one shape for both — `pae`, `parseBundle`, `verifyBundle` |
|
|
253
253
|
| `pki.inspect` | Human-readable inspection, the pure-JS equivalent of `openssl x509/crl/req/cms -text`. `certificate(pem \| der \| parsed)` renders an OpenSSL-style report: version, serial, signature algorithm, issuer and subject distinguished names, validity, public-key details (curve or modulus size plus the raw point or modulus), every decoded extension with its critical flag, and the signature. `crl`, `csr`, and `cms` render the other formats the same way — a CRL like `openssl crl -text`, a CSR like `openssl req -text`, and a CMS message like `openssl cms -cmsout -print`, with a stable summary for a non-SignedData ContentInfo — and `any(input)` detects the format and routes to the right report. Built over the strict parsers and the two-way OID registry with one set of field renderers, it names extension and algorithm OIDs an OpenSSL build shows only as raw bytes. No OpenSSL dependency, and the format is stable and OpenSSL-familiar rather than pinned to one OpenSSL version. A certificate policy's user notice renders as text, both its explicit text and a notice reference with the notice numbers that identify it, rather than hex, and a malformed part falls back to a hex dump rather than throwing — `certificate`, `crl`, `csr`, `cms`, `any` |
|
package/lib/guard-intrinsic.js
CHANGED
|
@@ -28,6 +28,7 @@ var _keyEquals = uncurry(_nodeCrypto.KeyObject.prototype.equals);
|
|
|
28
28
|
var _isView = ArrayBuffer.isView;
|
|
29
29
|
var _isInteger = Number.isInteger;
|
|
30
30
|
var _isSafeInteger = Number.isSafeInteger;
|
|
31
|
+
var _numberIsFinite = Number.isFinite;
|
|
31
32
|
var _fromCharCode = String.fromCharCode;
|
|
32
33
|
var _objectCreate = Object.create;
|
|
33
34
|
var _getPrototypeOf = Object.getPrototypeOf;
|
|
@@ -85,6 +86,8 @@ var _Number = Number;
|
|
|
85
86
|
var _Boolean = Boolean;
|
|
86
87
|
var _BigInt = BigInt;
|
|
87
88
|
var _Date = Date;
|
|
89
|
+
var _dateParse = Date.parse;
|
|
90
|
+
var _numberIsNaN = Number.isNaN;
|
|
88
91
|
var _isFinite = globalThis.isFinite;
|
|
89
92
|
var _ArrayBuffer = ArrayBuffer;
|
|
90
93
|
var _Uint8Array = Uint8Array;
|
|
@@ -155,6 +158,7 @@ module.exports = Object.freeze({
|
|
|
155
158
|
isView: _isView,
|
|
156
159
|
isInteger: _isInteger,
|
|
157
160
|
isSafeInteger: _isSafeInteger,
|
|
161
|
+
numberIsFinite: _numberIsFinite,
|
|
158
162
|
fromCharCode: _fromCharCode,
|
|
159
163
|
create: _objectCreate,
|
|
160
164
|
getPrototypeOf: _getPrototypeOf,
|
|
@@ -202,6 +206,8 @@ module.exports = Object.freeze({
|
|
|
202
206
|
Boolean: _Boolean,
|
|
203
207
|
BigInt: _BigInt,
|
|
204
208
|
Date: _Date,
|
|
209
|
+
dateParse: _dateParse,
|
|
210
|
+
numberIsNaN: _numberIsNaN,
|
|
205
211
|
isFinite: _isFinite,
|
|
206
212
|
ArrayBuffer: _ArrayBuffer,
|
|
207
213
|
Uint8Array: _Uint8Array,
|
package/lib/hpke.js
CHANGED
|
@@ -8,16 +8,18 @@
|
|
|
8
8
|
* @fullname HPKE (Hybrid Public Key Encryption, RFC 9180)
|
|
9
9
|
* @intro Hybrid Public Key Encryption (RFC 9180): the standard construction
|
|
10
10
|
* behind TLS Encrypted Client Hello, MLS, and OHTTP that turns a recipient KEM
|
|
11
|
-
* public key into an encapsulated key plus an AEAD-encrypting context.
|
|
12
|
-
* the RFC 9180
|
|
13
|
-
* X448
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
11
|
+
* public key into an encapsulated key plus an AEAD-encrypting context. Two KEM
|
|
12
|
+
* families run the RFC 9180 key schedule: the DHKEM suites P-256, P-521, X25519,
|
|
13
|
+
* and X448 in all four modes (base / psk / auth / auth-psk), proven against the
|
|
14
|
+
* RFC 9180 Appendix A known-answer vectors, and the post-quantum ML-KEM-512 /
|
|
15
|
+
* -768 / -1024 KEMs (IANA code points 0x0040 to 0x0042, draft-ietf-hpke-pq) in
|
|
16
|
+
* the base and psk modes, proven against that draft's Appendix A vectors. The
|
|
17
|
+
* KDFs are HKDF-SHA256 / HKDF-SHA384 / HKDF-SHA512; the AEADs are AES-128-GCM,
|
|
18
|
+
* AES-256-GCM, ChaCha20Poly1305, and export-only. DHKEM(P-384) is RFC-registered
|
|
19
|
+
* but no known-answer vector pairs it with an HKDF key schedule, so a request
|
|
20
|
+
* for it fails closed. The PQ/T hybrid KEMs and the SHAKE-based KDFs of the HPKE
|
|
21
|
+
* revision are a data-row extension once their specifications stabilize. Pure
|
|
22
|
+
* composition over node:crypto: no ASN.1, no schema engine.
|
|
21
23
|
* The RFC 9180 sec. 7 registry code points live in pki.hpke.suites
|
|
22
24
|
* (KEM / KDF / AEAD / MODE), passed to the setup functions to select a suite.
|
|
23
25
|
* @spec RFC 9180
|
|
@@ -28,7 +30,11 @@ var nodeCrypto = require("crypto");
|
|
|
28
30
|
var frameworkError = require("./framework-error");
|
|
29
31
|
var guard = require("./guard-all");
|
|
30
32
|
var intrinsic = require("./guard-intrinsic");
|
|
33
|
+
var oid = require("./oid");
|
|
31
34
|
var _hasOwn = intrinsic.hasOwn;
|
|
35
|
+
var _isBuffer = intrinsic.isBuffer, _bufferFrom = intrinsic.bufferFrom, _bufferAlloc = intrinsic.bufferAlloc;
|
|
36
|
+
var _bufferConcat = intrinsic.bufferConcat, _bufferEquals = intrinsic.bufferEquals, _compare = intrinsic.compare;
|
|
37
|
+
var _subarray = intrinsic.subarray;
|
|
32
38
|
|
|
33
39
|
var HpkeError = frameworkError.HpkeError;
|
|
34
40
|
function _err(code, message, cause) { return new HpkeError(code, message, cause); }
|
|
@@ -49,6 +55,7 @@ function L(s) { return Buffer.from(s, "ascii"); }
|
|
|
49
55
|
|
|
50
56
|
var KDFS = intrinsic.assign(intrinsic.create(null), {
|
|
51
57
|
0x0001: { hash: "sha256", Nh: 32 },
|
|
58
|
+
0x0002: { hash: "sha384", Nh: 48 },
|
|
52
59
|
0x0003: { hash: "sha512", Nh: 64 },
|
|
53
60
|
});
|
|
54
61
|
var AEADS = intrinsic.assign(intrinsic.create(null), {
|
|
@@ -57,11 +64,18 @@ var AEADS = intrinsic.assign(intrinsic.create(null), {
|
|
|
57
64
|
0x0003: { cipher: "chacha20-poly1305", Nk: 32, Nn: 12, Nt: 16 },
|
|
58
65
|
0xFFFF: { exportOnly: true, Nn: 12 },
|
|
59
66
|
});
|
|
67
|
+
function _mlKemRow(name, oidName, node) {
|
|
68
|
+
var p = oid.kemParams(oidName);
|
|
69
|
+
return { kind: "mlkem", name: name, node: node, Nsecret: p.ss, Npub: p.ek, Nenc: p.ct, Nsk: 64 };
|
|
70
|
+
}
|
|
60
71
|
var KEMS = intrinsic.assign(intrinsic.create(null), {
|
|
61
|
-
0x0010: { kind: "ec", curve: "P-256", nodeCurve: "prime256v1", kdf: 0x0001, Nsecret: 32, Npub: 65 },
|
|
62
|
-
0x0012: { kind: "ec", curve: "P-521", nodeCurve: "secp521r1", kdf: 0x0003, Nsecret: 64, Npub: 133 },
|
|
63
|
-
0x0020: { kind: "okp",
|
|
64
|
-
0x0021: { kind: "okp",
|
|
72
|
+
0x0010: { kind: "ec", name: "P-256", curve: "P-256", nodeCurve: "prime256v1", kdf: 0x0001, Nsecret: 32, Npub: 65, Nsk: 32 },
|
|
73
|
+
0x0012: { kind: "ec", name: "P-521", curve: "P-521", nodeCurve: "secp521r1", kdf: 0x0003, Nsecret: 64, Npub: 133, Nsk: 66 },
|
|
74
|
+
0x0020: { kind: "okp", name: "X25519", curve: "X25519", kdf: 0x0001, Nsecret: 32, Npub: 32, Nsk: 32 },
|
|
75
|
+
0x0021: { kind: "okp", name: "X448", curve: "X448", kdf: 0x0003, Nsecret: 64, Npub: 56, Nsk: 56 },
|
|
76
|
+
0x0040: _mlKemRow("ML-KEM-512", "id-ml-kem-512", "ml-kem-512"),
|
|
77
|
+
0x0041: _mlKemRow("ML-KEM-768", "id-ml-kem-768", "ml-kem-768"),
|
|
78
|
+
0x0042: _mlKemRow("ML-KEM-1024", "id-ml-kem-1024", "ml-kem-1024"),
|
|
65
79
|
});
|
|
66
80
|
|
|
67
81
|
var MODE_BASE = 0x00, MODE_PSK = 0x01, MODE_AUTH = 0x02, MODE_AUTH_PSK = 0x03;
|
|
@@ -78,19 +92,24 @@ function _extract(hash, Nh, salt, ikm) {
|
|
|
78
92
|
}
|
|
79
93
|
function _expand(hash, Nh, prk, info, len) {
|
|
80
94
|
if (len > 255 * Nh) throw _err("hpke/export-length", "requested length " + len + " exceeds 255*Nh");
|
|
81
|
-
var out = [], t = Buffer.alloc(0), n = Math.ceil(len / Nh);
|
|
82
|
-
|
|
83
|
-
var
|
|
84
|
-
|
|
95
|
+
var out = [], t = Buffer.alloc(0), n = Math.ceil(len / Nh), fed = null, joined = null;
|
|
96
|
+
try {
|
|
97
|
+
for (var i = 1; i <= n; i++) {
|
|
98
|
+
fed = concat([t, info, Buffer.from([i])]);
|
|
99
|
+
t = nodeCrypto.createHmac(hash, prk).update(fed).digest();
|
|
100
|
+
guard.secret.zeroize(fed, HpkeError, "hpke/bad-input", "an expand feedback input");
|
|
101
|
+
fed = null;
|
|
102
|
+
out.push(t);
|
|
103
|
+
}
|
|
104
|
+
joined = concat(out);
|
|
105
|
+
var exact = Buffer.alloc(len);
|
|
106
|
+
joined.copy(exact, 0, 0, len);
|
|
107
|
+
return exact;
|
|
108
|
+
} finally {
|
|
85
109
|
guard.secret.zeroize(fed, HpkeError, "hpke/bad-input", "an expand feedback input");
|
|
86
|
-
|
|
110
|
+
guard.secret.zeroize(joined, HpkeError, "hpke/bad-input", "the KDF accumulator");
|
|
111
|
+
for (var oi = 0; oi < out.length; oi++) guard.secret.zeroize(out[oi], HpkeError, "hpke/bad-input", "a KDF block");
|
|
87
112
|
}
|
|
88
|
-
var joined = concat(out);
|
|
89
|
-
var exact = Buffer.alloc(len);
|
|
90
|
-
joined.copy(exact, 0, 0, len);
|
|
91
|
-
guard.secret.zeroize(joined, HpkeError, "hpke/bad-input", "the KDF accumulator");
|
|
92
|
-
for (var oi = 0; oi < out.length; oi++) guard.secret.zeroize(out[oi], HpkeError, "hpke/bad-input", "a KDF block");
|
|
93
|
-
return exact;
|
|
94
113
|
}
|
|
95
114
|
function _labeledExtract(kdf, suiteId, salt, label, ikm) {
|
|
96
115
|
var labeled = concat([HPKE_V1, suiteId, L(label), ikm]);
|
|
@@ -104,10 +123,27 @@ function _labeledExpand(kdf, suiteId, prk, label, info, len) {
|
|
|
104
123
|
|
|
105
124
|
var OKP_SPKI = intrinsic.assign(intrinsic.create(null), { X25519: "302a300506032b656e032100", X448: "3042300506032b656f033900" });
|
|
106
125
|
var OKP_PKCS8 = intrinsic.assign(intrinsic.create(null), { X25519: "302e020100300506032b656e04220420", X448: "3046020100300506032b656f043a0438" });
|
|
126
|
+
var EC_SEC1 = intrinsic.assign(intrinsic.create(null), {
|
|
127
|
+
"P-256": { head: "30310201010420", tail: "a00a06082a8648ce3d030107",
|
|
128
|
+
order: "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551" },
|
|
129
|
+
"P-521": { head: "30500201010442", tail: "a00706052b81040023",
|
|
130
|
+
order: "01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409" },
|
|
131
|
+
});
|
|
132
|
+
var ML_KEM_SPKI = intrinsic.assign(intrinsic.create(null), {
|
|
133
|
+
"ML-KEM-512": "30820332300b06096086480165030404010382032100",
|
|
134
|
+
"ML-KEM-768": "308204b2300b0609608648016503040402038204a100",
|
|
135
|
+
"ML-KEM-1024": "30820632300b06096086480165030404030382062100",
|
|
136
|
+
});
|
|
137
|
+
var ML_KEM_PKCS8 = intrinsic.assign(intrinsic.create(null), {
|
|
138
|
+
"ML-KEM-512": "3054020100300b060960864801650304040104428040",
|
|
139
|
+
"ML-KEM-768": "3054020100300b060960864801650304040204428040",
|
|
140
|
+
"ML-KEM-1024": "3054020100300b060960864801650304040304428040",
|
|
141
|
+
});
|
|
142
|
+
function _hex(h) { return _bufferFrom(h, "hex"); }
|
|
107
143
|
|
|
108
144
|
function _importPublic(kem, raw) {
|
|
109
|
-
if (!
|
|
110
|
-
throw _err("hpke/bad-key", kem.
|
|
145
|
+
if (!_isBuffer(raw) || raw.length !== kem.Npub) {
|
|
146
|
+
throw _err("hpke/bad-key", kem.name + " public key must be " + kem.Npub + " bytes");
|
|
111
147
|
}
|
|
112
148
|
try {
|
|
113
149
|
if (kem.kind === "ec") {
|
|
@@ -116,31 +152,62 @@ function _importPublic(kem, raw) {
|
|
|
116
152
|
var jwk = { kty: "EC", crv: kem.curve, x: raw.subarray(1, 1 + half).toString("base64url"), y: raw.subarray(1 + half).toString("base64url") };
|
|
117
153
|
return nodeCrypto.createPublicKey({ key: jwk, format: "jwk" });
|
|
118
154
|
}
|
|
119
|
-
|
|
155
|
+
var prefix = kem.kind === "mlkem" ? ML_KEM_SPKI[kem.name] : OKP_SPKI[kem.curve];
|
|
156
|
+
return nodeCrypto.createPublicKey({ key: _bufferConcat([_hex(prefix), raw]), format: "der", type: "spki" });
|
|
120
157
|
} catch (e) {
|
|
121
158
|
if (e instanceof HpkeError) throw e;
|
|
122
|
-
throw _err("hpke/bad-key", "invalid " + kem.
|
|
159
|
+
throw _err("hpke/bad-key", "invalid " + kem.name + " public key" +
|
|
160
|
+
(kem.kind === "mlkem" ? " (FIPS 203 sec. 7.2 encapsulation key check)" : ""), e);
|
|
123
161
|
}
|
|
124
162
|
}
|
|
125
163
|
function _exportPublic(kem, keyObject) {
|
|
126
|
-
var
|
|
164
|
+
var pub = keyObject.type === "public" ? keyObject : nodeCrypto.createPublicKey(keyObject);
|
|
165
|
+
if (kem.kind === "mlkem") {
|
|
166
|
+
var der = pub.export({ format: "der", type: "spki" }), prefix = _hex(ML_KEM_SPKI[kem.name]);
|
|
167
|
+
if (der.length !== prefix.length + kem.Npub || !_bufferEquals(_subarray(der, 0, prefix.length), prefix)) {
|
|
168
|
+
throw _err("hpke/bad-key", "the KeyObject is not an " + kem.name + " key");
|
|
169
|
+
}
|
|
170
|
+
return _subarray(der, prefix.length);
|
|
171
|
+
}
|
|
172
|
+
var jwk = pub.export({ format: "jwk" });
|
|
173
|
+
if (jwk.crv !== kem.curve) throw _err("hpke/bad-key", "the KeyObject is not a " + kem.name + " key");
|
|
127
174
|
if (kem.kind === "ec") return concat([Buffer.from([0x04]), _b64u(jwk.x), _b64u(jwk.y)]);
|
|
128
175
|
return _b64u(jwk.x);
|
|
129
176
|
}
|
|
130
177
|
function _b64u(s) { return guard.encoding.base64url(s, null, _err, "hpke/bad-key", "JWK coordinate"); }
|
|
131
178
|
|
|
132
|
-
function
|
|
179
|
+
function _scalarInRange(d, order) {
|
|
180
|
+
return _compare(d, _bufferAlloc(d.length)) > 0 && _compare(d, order) < 0;
|
|
181
|
+
}
|
|
182
|
+
function _importPrivate(kem, rawSk) {
|
|
183
|
+
if (!_isBuffer(rawSk) || rawSk.length !== kem.Nsk) {
|
|
184
|
+
throw _err("hpke/bad-key", kem.name + " private key must be " +
|
|
185
|
+
(kem.kind === "mlkem" ? "the 64-byte seed" : "the " + kem.Nsk + "-byte scalar") + " as a Buffer");
|
|
186
|
+
}
|
|
187
|
+
var der;
|
|
188
|
+
if (kem.kind === "ec") {
|
|
189
|
+
var sec1 = EC_SEC1[kem.curve];
|
|
190
|
+
if (!_scalarInRange(rawSk, _hex(sec1.order))) throw _err("hpke/bad-key", kem.name + " private scalar is outside [1, n-1]");
|
|
191
|
+
der = _bufferConcat([_hex(sec1.head), rawSk, _hex(sec1.tail)]);
|
|
192
|
+
} else {
|
|
193
|
+
der = _bufferConcat([_hex(kem.kind === "mlkem" ? ML_KEM_PKCS8[kem.name] : OKP_PKCS8[kem.curve]), rawSk]);
|
|
194
|
+
}
|
|
133
195
|
try {
|
|
134
|
-
|
|
135
|
-
var jwk = { kty: "EC", crv: kem.curve, d: rawSk.toString("base64url") };
|
|
136
|
-
if (rawPk) { jwk.x = rawPk.subarray(1, 1 + (rawPk.length - 1) / 2).toString("base64url"); jwk.y = rawPk.subarray(1 + (rawPk.length - 1) / 2).toString("base64url"); }
|
|
137
|
-
return nodeCrypto.createPrivateKey({ key: jwk, format: "jwk" });
|
|
138
|
-
}
|
|
139
|
-
return nodeCrypto.createPrivateKey({ key: Buffer.from(OKP_PKCS8[kem.curve] + rawSk.toString("hex"), "hex"), format: "der", type: "pkcs8" });
|
|
196
|
+
return nodeCrypto.createPrivateKey({ key: der, format: "der", type: kem.kind === "ec" ? "sec1" : "pkcs8" });
|
|
140
197
|
} catch (e) {
|
|
141
|
-
throw _err("hpke/bad-key", "invalid " + kem.
|
|
198
|
+
throw _err("hpke/bad-key", "invalid " + kem.name + " private key", e);
|
|
199
|
+
} finally {
|
|
200
|
+
guard.secret.zeroize(der, HpkeError, "hpke/bad-input", "the private key envelope");
|
|
142
201
|
}
|
|
143
202
|
}
|
|
203
|
+
function _boundPublic(kem, privateKey, pkm) {
|
|
204
|
+
var derived = _exportPublic(kem, nodeCrypto.createPublicKey(privateKey));
|
|
205
|
+
if (pkm === undefined) return derived;
|
|
206
|
+
if (!_isBuffer(pkm) || !_bufferEquals(derived, pkm)) {
|
|
207
|
+
throw _err("hpke/bad-key", "pkm is not the " + kem.name + " public key derived from skm");
|
|
208
|
+
}
|
|
209
|
+
return derived;
|
|
210
|
+
}
|
|
144
211
|
function _dh(privateKey, publicKey) {
|
|
145
212
|
try {
|
|
146
213
|
return nodeCrypto.diffieHellman({ privateKey: privateKey, publicKey: publicKey });
|
|
@@ -164,12 +231,33 @@ function _extractAndExpand(kem, dh, kemContext) {
|
|
|
164
231
|
function _kemId(kem) { for (var k in KEMS) if (KEMS[k] === kem) return Number(k); return 0; }
|
|
165
232
|
|
|
166
233
|
function _ephemeral(kem, eph) {
|
|
167
|
-
if (eph
|
|
234
|
+
if (eph != null) {
|
|
235
|
+
if (typeof eph !== "object") throw _err("hpke/bad-input", "eph must be { skm, pkm } (a fixed ephemeral key pair), got " + guard.text.showValue(eph));
|
|
236
|
+
var skE = _importPrivate(kem, eph.skm);
|
|
237
|
+
return { skE: skE, enc: _boundPublic(kem, skE, eph.pkm) };
|
|
238
|
+
}
|
|
168
239
|
var kp = _generate(kem);
|
|
169
240
|
return { skE: kp.privateKey, enc: _exportPublic(kem, kp.publicKey) };
|
|
170
241
|
}
|
|
171
242
|
function _wipeDh(dh) { guard.secret.zeroize(dh, HpkeError, "hpke/bad-input", "the KEM shared secret"); }
|
|
243
|
+
function _mlKemEncap(kem, pkR, eph) {
|
|
244
|
+
if (eph != null) {
|
|
245
|
+
throw _err("hpke/bad-input", "eph (a fixed ephemeral key pair) applies to a DHKEM suite; " + kem.name + " encapsulation takes its randomness from the runtime");
|
|
246
|
+
}
|
|
247
|
+
var r;
|
|
248
|
+
try { r = nodeCrypto.encapsulate(pkR); }
|
|
249
|
+
catch (e) { throw _err("hpke/bad-key", kem.name + " encapsulation failed", e); }
|
|
250
|
+
return { sharedSecret: r.sharedKey, enc: r.ciphertext };
|
|
251
|
+
}
|
|
252
|
+
function _mlKemDecap(kem, enc, skR) {
|
|
253
|
+
if (enc.length !== kem.Nenc) {
|
|
254
|
+
throw _err("hpke/bad-key", kem.name + " encapsulated key must be " + kem.Nenc + " bytes (FIPS 203 sec. 7.3 ciphertext check)");
|
|
255
|
+
}
|
|
256
|
+
try { return nodeCrypto.decapsulate(skR, enc); }
|
|
257
|
+
catch (e) { throw _err("hpke/bad-key", kem.name + " decapsulation failed", e); }
|
|
258
|
+
}
|
|
172
259
|
function _encap(kem, pkR, pkRm, eph) {
|
|
260
|
+
if (kem.kind === "mlkem") return _mlKemEncap(kem, pkR, eph);
|
|
173
261
|
var e = _ephemeral(kem, eph);
|
|
174
262
|
var dh = null;
|
|
175
263
|
try {
|
|
@@ -178,6 +266,7 @@ function _encap(kem, pkR, pkRm, eph) {
|
|
|
178
266
|
} finally { _wipeDh(dh); }
|
|
179
267
|
}
|
|
180
268
|
function _decap(kem, enc, skR, pkRm) {
|
|
269
|
+
if (kem.kind === "mlkem") return _mlKemDecap(kem, enc, skR);
|
|
181
270
|
var pkE = _importPublic(kem, enc);
|
|
182
271
|
var dh = null;
|
|
183
272
|
try {
|
|
@@ -307,14 +396,32 @@ function _recipPublic(suite, pk) {
|
|
|
307
396
|
}
|
|
308
397
|
}
|
|
309
398
|
function _recipPrivate(suite, sk) {
|
|
310
|
-
|
|
311
|
-
if (
|
|
399
|
+
var kem = suite.kem;
|
|
400
|
+
if (sk && sk.skm != null) {
|
|
401
|
+
var key = _importPrivate(kem, sk.skm);
|
|
402
|
+
return { key: key, pkm: _boundPublic(kem, key, sk.pkm) };
|
|
403
|
+
}
|
|
404
|
+
if (_isBuffer(sk)) {
|
|
405
|
+
throw _err("hpke/bad-key", "a serialized " + kem.name + " private key must be provided as { skm" +
|
|
406
|
+
(kem.kind === "mlkem" ? " } holding the 64-byte seed" : ", pkm } (the raw scalar, and optionally its public key)") + ", not a bare buffer");
|
|
407
|
+
}
|
|
312
408
|
try {
|
|
313
|
-
|
|
409
|
+
if (sk.type !== "private") throw _err("hpke/bad-key", "the private key must be a private KeyObject or { skm, pkm }, got a " + guard.text.showValue(sk.type) + " KeyObject");
|
|
410
|
+
var pkm = _exportPublic(kem, nodeCrypto.createPublicKey(sk));
|
|
314
411
|
return { key: sk, pkm: pkm };
|
|
315
412
|
} catch (e) {
|
|
316
413
|
if (e instanceof HpkeError) throw e;
|
|
317
|
-
throw _err("hpke/bad-key", "invalid
|
|
414
|
+
throw _err("hpke/bad-key", "invalid private key (expected a node KeyObject or { skm, pkm })", e);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function _requireAuthCapable(kem) {
|
|
418
|
+
if (kem.kind === "mlkem") {
|
|
419
|
+
throw _err("hpke/auth-unsupported", kem.name + " defines no AuthEncap / AuthDecap (draft-ietf-hpke-pq sec. 7.2); use the psk mode or a signature");
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function _refuseUnusedAuthKey(value, name, mode) {
|
|
423
|
+
if (value != null) {
|
|
424
|
+
throw _err("hpke/bad-input", name + " applies to the auth and auth-psk modes; mode " + mode + " would leave it unused, so the exchange it was meant to authenticate would not be");
|
|
318
425
|
}
|
|
319
426
|
}
|
|
320
427
|
|
|
@@ -332,7 +439,7 @@ var _SETUP_S_KEYS = _withCommon({
|
|
|
332
439
|
var _SETUP_R_KEYS = _withCommon({
|
|
333
440
|
senderPublicKey: 1,
|
|
334
441
|
});
|
|
335
|
-
function
|
|
442
|
+
function _options(opts, keys, who) {
|
|
336
443
|
guard.identifier.assertKnownKeys(opts, keys, _err, "hpke/bad-input", function (k) {
|
|
337
444
|
var other = (keys === _SETUP_S_KEYS ? _SETUP_R_KEYS : _SETUP_S_KEYS);
|
|
338
445
|
return "unknown HPKE " + who + " option " + JSON.stringify(k) +
|
|
@@ -340,17 +447,21 @@ function _mode(opts, keys, who) {
|
|
|
340
447
|
? " -- that option belongs to the other end of the exchange, where it would authenticate or seed; here it would do nothing"
|
|
341
448
|
: "") + " -- accepted: " + Object.keys(keys).sort().join(", ");
|
|
342
449
|
});
|
|
343
|
-
var
|
|
344
|
-
if (mode
|
|
345
|
-
|
|
450
|
+
var o = guard.identifier.snapshotOptions(opts, keys);
|
|
451
|
+
if (o.mode == null) o.mode = MODE_BASE;
|
|
452
|
+
if (o.mode !== MODE_BASE && o.mode !== MODE_PSK && o.mode !== MODE_AUTH && o.mode !== MODE_AUTH_PSK) {
|
|
453
|
+
throw _err("hpke/unknown-mode", "unsupported HPKE mode " + guard.text.showValue(o.mode) + " (RFC 9180 sec. 5.1 defines base / psk / auth / auth-psk)");
|
|
346
454
|
}
|
|
347
|
-
return
|
|
455
|
+
return o;
|
|
348
456
|
}
|
|
349
457
|
|
|
350
458
|
// @module @intro; a data registry, not a callable primitive).
|
|
351
459
|
var suites = intrinsic.assign(intrinsic.create(null), {
|
|
352
|
-
KEM: intrinsic.assign(intrinsic.create(null), {
|
|
353
|
-
|
|
460
|
+
KEM: intrinsic.assign(intrinsic.create(null), {
|
|
461
|
+
DHKEM_P256_HKDF_SHA256: 0x0010, DHKEM_P521_HKDF_SHA512: 0x0012, DHKEM_X25519_HKDF_SHA256: 0x0020, DHKEM_X448_HKDF_SHA512: 0x0021,
|
|
462
|
+
ML_KEM_512: 0x0040, ML_KEM_768: 0x0041, ML_KEM_1024: 0x0042,
|
|
463
|
+
}),
|
|
464
|
+
KDF: intrinsic.assign(intrinsic.create(null), { HKDF_SHA256: 0x0001, HKDF_SHA384: 0x0002, HKDF_SHA512: 0x0003 }),
|
|
354
465
|
AEAD: intrinsic.assign(intrinsic.create(null), { AES_128_GCM: 0x0001, AES_256_GCM: 0x0002, CHACHA20_POLY1305: 0x0003, EXPORT_ONLY: 0xFFFF }),
|
|
355
466
|
MODE: intrinsic.assign(intrinsic.create(null), { BASE: MODE_BASE, PSK: MODE_PSK, AUTH: MODE_AUTH, AUTH_PSK: MODE_AUTH_PSK }),
|
|
356
467
|
});
|
|
@@ -369,9 +480,13 @@ var suites = intrinsic.assign(intrinsic.create(null), {
|
|
|
369
480
|
* (send it to the recipient) and a `context` whose `.seal(aad, pt)` /
|
|
370
481
|
* `.export(ctx, L)` encrypt and derive further secrets. `suiteIds` is
|
|
371
482
|
* `{ kem, kdf, aead }` from `pki.hpke.suites`; `recipientPublicKey` is a node
|
|
372
|
-
* KeyObject or the serialized public key bytes
|
|
373
|
-
*
|
|
374
|
-
*
|
|
483
|
+
* KeyObject or the serialized public key bytes (the uncompressed point, the raw
|
|
484
|
+
* Montgomery coordinate, or the ML-KEM encapsulation key). `opts.mode` selects
|
|
485
|
+
* base / psk / auth / auth-psk (default base); `opts.info`, `opts.psk`/`opts.pskId`,
|
|
486
|
+
* and `opts.senderKey` (auth modes) supply the corresponding inputs; an option that
|
|
487
|
+
* belongs to another mode, such as `senderKey` in base mode, is refused with
|
|
488
|
+
* `hpke/bad-input` rather than left unused. The auth modes exist for the DHKEM
|
|
489
|
+
* suites only: an ML-KEM suite throws `hpke/auth-unsupported`.
|
|
375
490
|
*
|
|
376
491
|
* @example
|
|
377
492
|
* var s = pki.hpke.suites, ids = { kem: s.KEM.DHKEM_X25519_HKDF_SHA256, kdf: s.KDF.HKDF_SHA256, aead: s.AEAD.AES_128_GCM };
|
|
@@ -380,17 +495,18 @@ var suites = intrinsic.assign(intrinsic.create(null), {
|
|
|
380
495
|
* var ct = sender.context.seal(Buffer.from("aad"), Buffer.from("secret"));
|
|
381
496
|
*/
|
|
382
497
|
function _setupS(ids, pkR, opts) {
|
|
383
|
-
opts = opts || {};
|
|
384
498
|
var suite = _suite(ids);
|
|
385
|
-
|
|
499
|
+
opts = _options(opts || {}, _SETUP_S_KEYS, "sender setup");
|
|
500
|
+
var mode = opts.mode;
|
|
386
501
|
var r = _recipPublic(suite, pkR);
|
|
387
502
|
var kem = suite.kem, k;
|
|
388
503
|
if (mode === MODE_AUTH || mode === MODE_AUTH_PSK) {
|
|
389
|
-
|
|
504
|
+
_requireAuthCapable(kem);
|
|
390
505
|
if (opts.senderKey == null) throw _err("hpke/auth-key-required", "an authenticated mode requires opts.senderKey (the sender's KEM private key, RFC 9180 sec. 5.1.3)");
|
|
391
506
|
var s = _recipPrivate(suite, opts.senderKey);
|
|
392
507
|
k = _authEncap(kem, r.key, r.pkm, s.key, s.pkm, opts.eph);
|
|
393
508
|
} else {
|
|
509
|
+
_refuseUnusedAuthKey(opts.senderKey, "senderKey", mode);
|
|
394
510
|
k = _encap(kem, r.key, r.pkm, opts.eph);
|
|
395
511
|
}
|
|
396
512
|
var ctx = _keySchedule(suite, mode, k.sharedSecret, _buf(opts.info), _buf(opts.psk), _buf(opts.pskId), "S");
|
|
@@ -405,12 +521,14 @@ function _setupS(ids, pkR, opts) {
|
|
|
405
521
|
* @related pki.hpke.setupS, pki.hpke.open
|
|
406
522
|
*
|
|
407
523
|
* Establish the recipient HPKE context from the sender's encapsulated key `enc`
|
|
408
|
-
* and the recipient KEM private key
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
524
|
+
* and the recipient KEM private key, recovering the same shared secret and key
|
|
525
|
+
* schedule. The private key is a node KeyObject, or `{ skm, pkm }` where `skm` is
|
|
526
|
+
* the raw private scalar of a DHKEM suite or the 64-byte seed of an ML-KEM suite;
|
|
527
|
+
* `pkm` is optional, and when given it must be the public key derived from `skm`
|
|
528
|
+
* or the call throws `hpke/bad-key`. The returned `context` `.open(aad, ct)`
|
|
529
|
+
* decrypts and `.export(ctx, L)` derives secrets. `opts` mirrors `setupS` (mode /
|
|
530
|
+
* info / psk / pskId), with `opts.senderPublicKey` for the auth modes (DHKEM
|
|
531
|
+
* suites only). A ciphertext whose tag does not verify throws `hpke/open-failed`.
|
|
414
532
|
*
|
|
415
533
|
* @example
|
|
416
534
|
* var s = pki.hpke.suites, ids = { kem: s.KEM.DHKEM_X25519_HKDF_SHA256, kdf: s.KDF.HKDF_SHA256, aead: s.AEAD.AES_128_GCM };
|
|
@@ -421,16 +539,18 @@ function _setupS(ids, pkR, opts) {
|
|
|
421
539
|
* var pt = recipient.open(Buffer.alloc(0), sender.context.seal(Buffer.alloc(0), Buffer.from("hi")));
|
|
422
540
|
*/
|
|
423
541
|
function _setupR(ids, enc, skR, opts) {
|
|
424
|
-
opts = opts || {};
|
|
425
542
|
var suite = _suite(ids);
|
|
426
|
-
|
|
543
|
+
opts = _options(opts || {}, _SETUP_R_KEYS, "recipient setup");
|
|
544
|
+
var mode = opts.mode;
|
|
427
545
|
var r = _recipPrivate(suite, skR);
|
|
428
546
|
var kem = suite.kem, ss;
|
|
429
547
|
if (mode === MODE_AUTH || mode === MODE_AUTH_PSK) {
|
|
548
|
+
_requireAuthCapable(kem);
|
|
430
549
|
if (opts.senderPublicKey == null) throw _err("hpke/auth-key-required", "an authenticated mode requires opts.senderPublicKey (the sender's KEM public key, RFC 9180 sec. 5.1.3)");
|
|
431
550
|
var pkS = _recipPublic(suite, opts.senderPublicKey);
|
|
432
551
|
ss = _authDecap(kem, _buf(enc), r.key, r.pkm, pkS.key, pkS.pkm);
|
|
433
552
|
} else {
|
|
553
|
+
_refuseUnusedAuthKey(opts.senderPublicKey, "senderPublicKey", mode);
|
|
434
554
|
ss = _decap(kem, _buf(enc), r.key, r.pkm);
|
|
435
555
|
}
|
|
436
556
|
try { return _keySchedule(suite, mode, ss, _buf(opts.info), _buf(opts.psk), _buf(opts.pskId), "R"); }
|
|
@@ -451,9 +571,9 @@ function _setupR(ids, enc, skR, opts) {
|
|
|
451
571
|
* `setupS` options object (mode / info / psk / senderKey).
|
|
452
572
|
*
|
|
453
573
|
* @example
|
|
454
|
-
*
|
|
455
|
-
* var
|
|
456
|
-
* var out = pki.hpke.seal(ids,
|
|
574
|
+
* // requires: mlKemPkR -- the recipient's ML-KEM-768 encapsulation key (1184 bytes)
|
|
575
|
+
* var s = pki.hpke.suites, ids = { kem: s.KEM.ML_KEM_768, kdf: s.KDF.HKDF_SHA256, aead: s.AEAD.AES_256_GCM };
|
|
576
|
+
* var out = pki.hpke.seal(ids, mlKemPkR, {}, Buffer.from("aad"), Buffer.from("msg"));
|
|
457
577
|
*/
|
|
458
578
|
function seal(ids, pkR, opts, aad, pt) {
|
|
459
579
|
var s = null;
|
|
@@ -481,11 +601,11 @@ function seal(ids, pkR, opts, aad, pt) {
|
|
|
481
601
|
* verify throws `hpke/open-failed` and returns no plaintext.
|
|
482
602
|
*
|
|
483
603
|
* @example
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
* var
|
|
487
|
-
* var o = pki.hpke.seal(ids,
|
|
488
|
-
* var pt = pki.hpke.open(ids, o.enc,
|
|
604
|
+
* // requires: mlKemPkR -- the recipient's ML-KEM-768 encapsulation key (1184 bytes)
|
|
605
|
+
* // requires: mlKemSkR -- { skm } holding the recipient's 64-byte ML-KEM-768 seed
|
|
606
|
+
* var s = pki.hpke.suites, ids = { kem: s.KEM.ML_KEM_768, kdf: s.KDF.HKDF_SHA256, aead: s.AEAD.AES_256_GCM };
|
|
607
|
+
* var o = pki.hpke.seal(ids, mlKemPkR, {}, Buffer.alloc(0), Buffer.from("m"));
|
|
608
|
+
* var pt = pki.hpke.open(ids, o.enc, mlKemSkR, {}, Buffer.alloc(0), o.ct);
|
|
489
609
|
*/
|
|
490
610
|
function open(ids, enc, skR, opts, aad, ct) {
|
|
491
611
|
var ctx = _setupR(ids, enc, skR, opts);
|
package/lib/sigstore.js
CHANGED
|
@@ -33,6 +33,7 @@ var frameworkError = require("./framework-error");
|
|
|
33
33
|
var constants = require("./constants");
|
|
34
34
|
var asn1 = require("./asn1-der");
|
|
35
35
|
var guard = require("./guard-all");
|
|
36
|
+
var intrinsic = require("./guard-intrinsic");
|
|
36
37
|
var x509 = require("./schema-x509");
|
|
37
38
|
var pkix = require("./schema-pkix");
|
|
38
39
|
var pathValidate = require("./path-validate");
|
|
@@ -41,6 +42,59 @@ var oid = require("./oid");
|
|
|
41
42
|
var ct = require("./ct");
|
|
42
43
|
var edwardsPoint = require("./edwards-point");
|
|
43
44
|
|
|
45
|
+
/** @internal The operations this module decides with, taken at load. The bundle copy every later
|
|
46
|
+
* check runs on settles what is verified, so which function answers "what does this object own" and
|
|
47
|
+
* "what does it hold" is fixed before any caller code runs; one replaced after this module loads
|
|
48
|
+
* would otherwise be asked at the moment of the call. An emptied key list alone turns a bundle into
|
|
49
|
+
* one carrying no content arm. */
|
|
50
|
+
var _ownNames = intrinsic.getOwnPropertyNames;
|
|
51
|
+
var _ownDescriptor = intrinsic.getOwnPropertyDescriptor;
|
|
52
|
+
var _isArray = intrinsic.isArray;
|
|
53
|
+
var _create = intrinsic.create;
|
|
54
|
+
var _assign = intrinsic.assign;
|
|
55
|
+
var _freeze = intrinsic.freeze;
|
|
56
|
+
var _stringOf = intrinsic.String;
|
|
57
|
+
var _numberOf = intrinsic.Number;
|
|
58
|
+
var _bigIntOf = intrinsic.BigInt;
|
|
59
|
+
var _Date = intrinsic.Date;
|
|
60
|
+
var _dateParse = intrinsic.dateParse;
|
|
61
|
+
var _isNaN = intrinsic.numberIsNaN;
|
|
62
|
+
/** @internal Whether an object OWNS a name. The oneof rules are written on this question, so a
|
|
63
|
+
* replacement answering no for one arm hides it and a bundle setting two is read as setting one. */
|
|
64
|
+
var _hasOwn = intrinsic.hasOwn;
|
|
65
|
+
var _isFiniteNumber = intrinsic.numberIsFinite;
|
|
66
|
+
var _isSafeInt = intrinsic.isSafeInteger;
|
|
67
|
+
var _isBuffer = intrinsic.isBuffer;
|
|
68
|
+
var _bufferFrom = intrinsic.bufferFrom;
|
|
69
|
+
var _bufferConcat = intrinsic.bufferConcat;
|
|
70
|
+
var _bufToString = intrinsic.bufToString;
|
|
71
|
+
var _bufferEquals = intrinsic.bufferEquals;
|
|
72
|
+
var _subarray = intrinsic.subarray;
|
|
73
|
+
var _bufIndexOf = intrinsic.uncurry(Buffer.prototype.indexOf);
|
|
74
|
+
/** @internal The canonical form a Rekor signed entry timestamp is verified over. A replacement
|
|
75
|
+
* writing different bytes decides what that signature is checked against. */
|
|
76
|
+
var _jsonStringify = intrinsic.stringify;
|
|
77
|
+
/** @internal Every field the copy holds is DEFINED as its own, never assigned. An assignment consults
|
|
78
|
+
* the target's prototype for a setter, and something that installs one sees each field the copy
|
|
79
|
+
* writes and can hand back a different one, so a malformed value arrives valid and the checks read
|
|
80
|
+
* what the caller never sent. Defining reaches no prototype. */
|
|
81
|
+
var _defineProp = intrinsic.defineProperty;
|
|
82
|
+
var _isFiniteNum = intrinsic.isFinite;
|
|
83
|
+
/** @internal Uncurried, so the copy reads a character's code through the operation taken at load
|
|
84
|
+
* rather than through whatever the string it is walking offers under that name. What a character
|
|
85
|
+
* costs decides whether a bundle passes the size limit. */
|
|
86
|
+
var _charCodeAt = intrinsic.uncurry(String.prototype.charCodeAt);
|
|
87
|
+
var _charAt = intrinsic.uncurry(String.prototype.charAt);
|
|
88
|
+
var _strSlice = intrinsic.uncurry(String.prototype.slice);
|
|
89
|
+
var _strIndexOf = intrinsic.stringIndexOf;
|
|
90
|
+
var _split = intrinsic.uncurry(String.prototype.split);
|
|
91
|
+
var _join = intrinsic.join;
|
|
92
|
+
var _map = intrinsic.map;
|
|
93
|
+
var _forEach = intrinsic.forEach;
|
|
94
|
+
var _filter = intrinsic.filter;
|
|
95
|
+
var _arraySlice = intrinsic.arraySlice;
|
|
96
|
+
var _fromCharCode = intrinsic.fromCharCode;
|
|
97
|
+
|
|
44
98
|
var C = constants;
|
|
45
99
|
var SigstoreError = frameworkError.SigstoreError;
|
|
46
100
|
function _err(code, message, cause) { return new SigstoreError(code, message, cause); }
|
|
@@ -62,7 +116,7 @@ function _armPresent(obj, name) {
|
|
|
62
116
|
* records. A member this table does not carry is refused rather than mapped by guessing at its name,
|
|
63
117
|
* so a member added to the enum later cannot be read as one of these.
|
|
64
118
|
* HASH_ALGORITHM_UNSPECIFIED is absent for the reason it exists: it names no algorithm. */
|
|
65
|
-
var _HASH_BY_ENUM =
|
|
119
|
+
var _HASH_BY_ENUM = _freeze(_assign(_create(null), {
|
|
66
120
|
SHA2_256: { node: "sha256", bytes: 32 },
|
|
67
121
|
SHA2_384: { node: "sha384", bytes: 48 },
|
|
68
122
|
SHA2_512: { node: "sha512", bytes: 64 },
|
|
@@ -74,7 +128,7 @@ var _HASH_BY_ENUM = Object.freeze(Object.assign(Object.create(null), {
|
|
|
74
128
|
* a parser "accept[s] both enum names and integer values", so a bundle naming its digest algorithm as
|
|
75
129
|
* 1 is one a conforming producer may write and this reads it as the name it stands for. Zero is
|
|
76
130
|
* absent for the reason the name it belongs to is: HASH_ALGORITHM_UNSPECIFIED names no algorithm. */
|
|
77
|
-
var _HASH_BY_NUMBER =
|
|
131
|
+
var _HASH_BY_NUMBER = _freeze(_assign(_create(null), {
|
|
78
132
|
1: _HASH_BY_ENUM.SHA2_256,
|
|
79
133
|
2: _HASH_BY_ENUM.SHA2_384,
|
|
80
134
|
3: _HASH_BY_ENUM.SHA2_512,
|
|
@@ -96,7 +150,7 @@ function _hashOf(algorithm) {
|
|
|
96
150
|
/** @internal The same three algorithms keyed the way a hashedrekord names them. The entry is the
|
|
97
151
|
* authenticated statement of what was signed, so its algorithm is the one the artifact is digested
|
|
98
152
|
* under; the schema enumerates exactly these three. */
|
|
99
|
-
var _HASH_BY_REKOR =
|
|
153
|
+
var _HASH_BY_REKOR = _freeze(_assign(_create(null), {
|
|
100
154
|
sha256: { node: "sha256", bytes: 32 },
|
|
101
155
|
sha384: { node: "sha384", bytes: 48 },
|
|
102
156
|
sha512: { node: "sha512", bytes: 64 },
|
|
@@ -109,64 +163,35 @@ var JSON_MAX = C.LIMITS.JSON_MAX_BYTES;
|
|
|
109
163
|
* applied alone would admit it one way and refuse it the other. */
|
|
110
164
|
var BUNDLE_MAX_DEPTH = 64;
|
|
111
165
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* moment of the call. An emptied key list alone turns a bundle into one carrying no content arm. */
|
|
116
|
-
var _ownNames = Object.getOwnPropertyNames;
|
|
117
|
-
var _ownDescriptor = Object.getOwnPropertyDescriptor;
|
|
118
|
-
var _isArray = Array.isArray;
|
|
119
|
-
var _create = Object.create;
|
|
120
|
-
var _stringOf = String;
|
|
121
|
-
/** @internal Whether an object OWNS a name. The oneof rules are written on this question, so a
|
|
122
|
-
* replacement answering no for one arm hides it and a bundle setting two is read as setting one. */
|
|
123
|
-
var _hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
|
|
124
|
-
var _isFiniteNumber = Number.isFinite;
|
|
125
|
-
var _isSafeInt = Number.isSafeInteger;
|
|
126
|
-
var _isBuffer = Buffer.isBuffer;
|
|
127
|
-
var _bufferFrom = Buffer.from;
|
|
128
|
-
/** @internal The canonical form a Rekor signed entry timestamp is verified over. A replacement
|
|
129
|
-
* writing different bytes decides what that signature is checked against. */
|
|
130
|
-
var _jsonStringify = JSON.stringify;
|
|
131
|
-
/** @internal Every field the copy holds is DEFINED as its own, never assigned. An assignment consults
|
|
132
|
-
* the target's prototype for a setter, and something that installs one sees each field the copy
|
|
133
|
-
* writes and can hand back a different one, so a malformed value arrives valid and the checks read
|
|
134
|
-
* what the caller never sent. Defining reaches no prototype. */
|
|
135
|
-
var _defineProp = Object.defineProperty;
|
|
136
|
-
var _isFiniteNum = isFinite;
|
|
137
|
-
/** @internal Uncurried, so the copy reads a character's code through the operation taken at load
|
|
138
|
-
* rather than through whatever the string it is walking offers under that name. What a character
|
|
139
|
-
* costs decides whether a bundle passes the size limit. */
|
|
140
|
-
var _charCodeAt = Function.prototype.call.bind(String.prototype.charCodeAt);
|
|
141
|
-
var SP = Buffer.from(" ", "ascii");
|
|
142
|
-
var DSSEV1 = Buffer.from("DSSEv1", "ascii");
|
|
143
|
-
var _EM_DASH = String.fromCharCode(0x2014);
|
|
166
|
+
var SP = _bufferFrom(" ", "ascii");
|
|
167
|
+
var DSSEV1 = _bufferFrom("DSSEv1", "ascii");
|
|
168
|
+
var _EM_DASH = _fromCharCode(0x2014);
|
|
144
169
|
|
|
145
170
|
function _parseNoteSig(line) {
|
|
146
171
|
var prefix = _EM_DASH + " ";
|
|
147
|
-
if (line
|
|
172
|
+
if (_strSlice(line, 0, prefix.length) !== prefix) return null;
|
|
148
173
|
var p = prefix.length, n = line.length;
|
|
149
174
|
var t1s = p;
|
|
150
|
-
while (p < n && !pkix.isJsWhitespace(line
|
|
175
|
+
while (p < n && !pkix.isJsWhitespace(_charCodeAt(line, p))) p += 1;
|
|
151
176
|
if (p === t1s) return null;
|
|
152
|
-
var keyId = line
|
|
153
|
-
if (line
|
|
177
|
+
var keyId = _strSlice(line, t1s, p);
|
|
178
|
+
if (_charAt(line, p) !== " ") return null;
|
|
154
179
|
p += 1;
|
|
155
180
|
var t2s = p;
|
|
156
|
-
while (p < n && !pkix.isJsWhitespace(line
|
|
181
|
+
while (p < n && !pkix.isJsWhitespace(_charCodeAt(line, p))) p += 1;
|
|
157
182
|
if (p === t2s) return null;
|
|
158
|
-
var sig = line
|
|
183
|
+
var sig = _strSlice(line, t2s, p);
|
|
159
184
|
if (p !== n) return null;
|
|
160
185
|
return { keyId: keyId, sig: sig };
|
|
161
186
|
}
|
|
162
187
|
|
|
163
188
|
function _stripTrailingEquals(s) {
|
|
164
189
|
var i = s.length;
|
|
165
|
-
while (i > 0 && s
|
|
166
|
-
return s
|
|
190
|
+
while (i > 0 && _charAt(s, i - 1) === "=") i -= 1;
|
|
191
|
+
return _strSlice(s, 0, i);
|
|
167
192
|
}
|
|
168
193
|
|
|
169
|
-
var _BUNDLE_MEDIA_TYPES =
|
|
194
|
+
var _BUNDLE_MEDIA_TYPES = _assign(_create(null), {
|
|
170
195
|
"application/vnd.dev.sigstore.bundle.v0.1+json": 1,
|
|
171
196
|
"application/vnd.dev.sigstore.bundle.v0.2+json": 1,
|
|
172
197
|
"application/vnd.dev.sigstore.bundle.v0.3+json": 1,
|
|
@@ -206,22 +231,22 @@ function _jsonParse(input, code, label) {
|
|
|
206
231
|
*/
|
|
207
232
|
function pae(payloadType, payloadBytes) {
|
|
208
233
|
if (typeof payloadType !== "string") throw new TypeError("pae: payloadType must be a string");
|
|
209
|
-
var type =
|
|
234
|
+
var type = _bufferFrom(payloadType, "utf8");
|
|
210
235
|
var body = _isBuffer(payloadBytes) ? payloadBytes : _bufferFrom(payloadBytes || []);
|
|
211
|
-
return
|
|
236
|
+
return _bufferConcat([
|
|
212
237
|
DSSEV1, SP,
|
|
213
|
-
|
|
214
|
-
|
|
238
|
+
_bufferFrom(_stringOf(type.length), "ascii"), SP, type, SP,
|
|
239
|
+
_bufferFrom(_stringOf(body.length), "ascii"), SP, body,
|
|
215
240
|
]);
|
|
216
241
|
}
|
|
217
242
|
|
|
218
243
|
|
|
219
244
|
function _b64(s, label) {
|
|
220
245
|
if (typeof s !== "string") throw _err("sigstore/bad-bundle", label + " must be a base64 string");
|
|
221
|
-
var urlSafe = s
|
|
246
|
+
var urlSafe = _strIndexOf(s, "-") !== -1 || _strIndexOf(s, "_") !== -1;
|
|
222
247
|
var enc = urlSafe ? "base64url" : "base64";
|
|
223
|
-
var buf =
|
|
224
|
-
if (_stripTrailingEquals(buf
|
|
248
|
+
var buf = _bufferFrom(s, enc);
|
|
249
|
+
if (_stripTrailingEquals(_bufToString(buf, enc)) !== _stripTrailingEquals(s)) {
|
|
225
250
|
throw _err("sigstore/bad-bundle", label + " is not canonical base64");
|
|
226
251
|
}
|
|
227
252
|
return buf;
|
|
@@ -358,7 +383,7 @@ function _chargeString(budget, s) {
|
|
|
358
383
|
function _numOf(v) {
|
|
359
384
|
var t = typeof v;
|
|
360
385
|
if (t === "number") return v;
|
|
361
|
-
if (t === "string" || t === "boolean") return
|
|
386
|
+
if (t === "string" || t === "boolean") return _numberOf(v);
|
|
362
387
|
return NaN;
|
|
363
388
|
}
|
|
364
389
|
|
|
@@ -583,7 +608,7 @@ function _leafCertDer(vm) {
|
|
|
583
608
|
}
|
|
584
609
|
function _chainDers(vm) {
|
|
585
610
|
if (vm.x509CertificateChain && _isArray(vm.x509CertificateChain.certificates)) {
|
|
586
|
-
return vm.x509CertificateChain.certificates
|
|
611
|
+
return _map(vm.x509CertificateChain.certificates, function (c, i) { return _certBytes(c, "x509CertificateChain[" + i + "]"); });
|
|
587
612
|
}
|
|
588
613
|
return [_leafCertDer(vm)];
|
|
589
614
|
}
|
|
@@ -619,8 +644,8 @@ function _sha256(buf) { return nodeCrypto.createHash("sha256").update(buf).diges
|
|
|
619
644
|
function _toMs(x) {
|
|
620
645
|
if (x == null) return null;
|
|
621
646
|
if (typeof x === "number") return _isFiniteNumber(x) ? x : null;
|
|
622
|
-
if (guard.time.isDate(x)) { var d = guard.time.instantOf(x); return
|
|
623
|
-
if (typeof x === "string") { var t =
|
|
647
|
+
if (guard.time.isDate(x)) { var d = guard.time.instantOf(x); return _isNaN(d) ? null : d; }
|
|
648
|
+
if (typeof x === "string") { var t = _dateParse(x); return _isNaN(t) ? null : t; }
|
|
624
649
|
return null;
|
|
625
650
|
}
|
|
626
651
|
function _inWindow(timeMs, vf) {
|
|
@@ -632,29 +657,29 @@ function _inWindow(timeMs, vf) {
|
|
|
632
657
|
function _rekorKey(rekorKeys, keyIdBuf, hint, timeMs) {
|
|
633
658
|
for (var i = 0; i < rekorKeys.length; i++) {
|
|
634
659
|
var k = rekorKeys[i];
|
|
635
|
-
var match = (keyIdBuf && k.keyId && k.keyId
|
|
636
|
-
(hint && k.keyId && k.keyId.length >= 4 && k.keyId
|
|
660
|
+
var match = (keyIdBuf && k.keyId && _bufferEquals(k.keyId, keyIdBuf)) ||
|
|
661
|
+
(hint && k.keyId && k.keyId.length >= 4 && _bufferEquals(_subarray(k.keyId, 0, 4), hint));
|
|
637
662
|
if (match && _inWindow(timeMs, k.validFor)) return k;
|
|
638
663
|
}
|
|
639
664
|
return null;
|
|
640
665
|
}
|
|
641
666
|
|
|
642
667
|
function _verifyCheckpoint(envelope, ip, rekorKeys, timeMs) {
|
|
643
|
-
var buf =
|
|
644
|
-
var sep = buf
|
|
668
|
+
var buf = _bufferFrom(envelope, "utf8");
|
|
669
|
+
var sep = _bufIndexOf(buf, "\n\n");
|
|
645
670
|
if (sep < 0) throw _err("sigstore/bad-checkpoint", "the checkpoint has no note/signature separator");
|
|
646
|
-
var body = buf
|
|
647
|
-
var lines = body
|
|
648
|
-
if (_b64(lines[2], "checkpoint root")
|
|
671
|
+
var body = _subarray(buf, 0, sep + 1);
|
|
672
|
+
var lines = _split(_bufToString(body, "utf8"), "\n");
|
|
673
|
+
if (_bufToString(_b64(lines[2], "checkpoint root"), "hex") !== _bufToString(_b64(ip.rootHash, "inclusionProof.rootHash"), "hex")) {
|
|
649
674
|
throw _err("sigstore/inclusion-proof-mismatch", "the checkpoint root does not match the inclusion-proof root");
|
|
650
675
|
}
|
|
651
|
-
var sigBlock = buf
|
|
676
|
+
var sigBlock = _split(_bufToString(_subarray(buf, sep + 2), "utf8"), "\n");
|
|
652
677
|
for (var i = 0; i < sigBlock.length; i++) {
|
|
653
678
|
var note = _parseNoteSig(sigBlock[i]);
|
|
654
679
|
if (!note) continue;
|
|
655
680
|
var blob = _b64(note.sig, "checkpoint signature");
|
|
656
681
|
if (blob.length < 5) continue;
|
|
657
|
-
var hint = blob
|
|
682
|
+
var hint = _subarray(blob, 0, 4), derSig = _subarray(blob, 4);
|
|
658
683
|
var k = _rekorKey(rekorKeys, null, hint, timeMs);
|
|
659
684
|
if (!k) continue;
|
|
660
685
|
if (_rawVerify(_pubFromSpki(k.spki, "Rekor log"), body, derSig)) return true;
|
|
@@ -671,11 +696,11 @@ function _verifySet(te, rekorKeys, timeMs, canonBody) {
|
|
|
671
696
|
var canonical = _jsonStringify({
|
|
672
697
|
body: canonBody,
|
|
673
698
|
integratedTime: _numOf(te.integratedTime),
|
|
674
|
-
logID: keyId
|
|
699
|
+
logID: _bufToString(keyId, "hex"),
|
|
675
700
|
logIndex: _numOf(te.logIndex),
|
|
676
701
|
});
|
|
677
702
|
var sig = _b64(promise.signedEntryTimestamp, "signedEntryTimestamp");
|
|
678
|
-
return _rawVerify(_pubFromSpki(k.spki, "Rekor log"),
|
|
703
|
+
return _rawVerify(_pubFromSpki(k.spki, "Rekor log"), _bufferFrom(canonical, "utf8"), sig);
|
|
679
704
|
}
|
|
680
705
|
|
|
681
706
|
/** @internal The entry rows this build reads, keyed on the entry's OWN kind and apiVersion together.
|
|
@@ -684,7 +709,7 @@ function _verifySet(te, rekorKeys, timeMs, canonBody) {
|
|
|
684
709
|
* would read one shape's field names out of the other and report a mismatch rather than an
|
|
685
710
|
* unsupported entry. Each row states which content arm it may accompany, because an entry describing
|
|
686
711
|
* a DSSE envelope says nothing about a message signature and the two must agree. */
|
|
687
|
-
var _ENTRY_ROWS =
|
|
712
|
+
var _ENTRY_ROWS = _freeze(_assign(_create(null), {
|
|
688
713
|
"dsse@0.0.1": { content: "dsseEnvelope", bind: _bindDsseEntry },
|
|
689
714
|
"hashedrekord@0.0.1": { content: "messageSignature", bind: _bindHashedRekordEntry },
|
|
690
715
|
}));
|
|
@@ -723,18 +748,18 @@ function _bindDsseEntry(body, envelope, leafDer) {
|
|
|
723
748
|
}
|
|
724
749
|
var envSig = _b64(envelope.signatures[0].sig, "dsseEnvelope.signatures[0].sig");
|
|
725
750
|
var bodySig = _b64(spec.signatures[0].signature, "Rekor entry signature");
|
|
726
|
-
if (!envSig
|
|
751
|
+
if (!_bufferEquals(envSig, bodySig)) throw _err("sigstore/entry-mismatch", "the Rekor entry signature does not match the bundle signature");
|
|
727
752
|
var payload = _b64(envelope.payload, "dsseEnvelope.payload");
|
|
728
753
|
if (!spec.payloadHash || typeof spec.payloadHash.value !== "string") throw _err("sigstore/bad-tlog-entry", "the Rekor dsse entry is missing its payloadHash");
|
|
729
|
-
if (spec.payloadHash.value !== _sha256(payload)
|
|
754
|
+
if (spec.payloadHash.value !== _bufToString(_sha256(payload), "hex")) {
|
|
730
755
|
throw _err("sigstore/entry-mismatch", "the Rekor entry payloadHash does not match the bundle payload");
|
|
731
756
|
}
|
|
732
757
|
var vf = spec.signatures[0].verifier;
|
|
733
758
|
if (typeof vf !== "string") throw _err("sigstore/bad-tlog-entry", "the Rekor dsse entry is missing its verifier certificate");
|
|
734
759
|
var vDer;
|
|
735
|
-
try { vDer = x509.pemDecode(_b64(vf, "Rekor entry verifier")
|
|
760
|
+
try { vDer = x509.pemDecode(_bufToString(_b64(vf, "Rekor entry verifier"), "utf8"), "CERTIFICATE"); }
|
|
736
761
|
catch (e) { throw _err("sigstore/bad-tlog-entry", "the Rekor entry verifier is not a valid certificate", e); }
|
|
737
|
-
if (!vDer
|
|
762
|
+
if (!_bufferEquals(vDer, leafDer)) throw _err("sigstore/entry-mismatch", "the Rekor entry verifier certificate does not match the bundle leaf certificate");
|
|
738
763
|
}
|
|
739
764
|
|
|
740
765
|
/** @internal The entry's verifier, bound to the bundle's leaf. The Rekor field is "the public key
|
|
@@ -744,11 +769,11 @@ function _bindDsseEntry(body, envelope, leafDer) {
|
|
|
744
769
|
* about it, and the certificate's own identity is settled by the chain leg rather than here. Neither
|
|
745
770
|
* form is guessed at from the bytes: the armor names which one the entry wrote. */
|
|
746
771
|
function _bindVerifier(content, leafDer) {
|
|
747
|
-
var text = _b64(content, "Rekor entry verifier")
|
|
772
|
+
var text = _bufToString(_b64(content, "Rekor entry verifier"), "utf8");
|
|
748
773
|
var vDer;
|
|
749
774
|
try { vDer = x509.pemDecode(text, "CERTIFICATE"); } catch (_e) { vDer = null; } // allow:swallow-unverified the other armor is tried next and a value carrying neither is refused below
|
|
750
775
|
if (vDer !== null) {
|
|
751
|
-
if (!vDer
|
|
776
|
+
if (!_bufferEquals(vDer, leafDer)) {
|
|
752
777
|
throw _err("sigstore/entry-mismatch", "the Rekor entry verifier certificate does not match the bundle leaf certificate");
|
|
753
778
|
}
|
|
754
779
|
return;
|
|
@@ -757,7 +782,7 @@ function _bindVerifier(content, leafDer) {
|
|
|
757
782
|
try { spki = x509.pemDecode(text, "PUBLIC KEY"); }
|
|
758
783
|
catch (e) { throw _err("sigstore/bad-tlog-entry", "the Rekor entry verifier is neither a certificate nor a public key", e); }
|
|
759
784
|
var leafSpki = _parseCert(leafDer, "Fulcio leaf certificate").subjectPublicKeyInfo.bytes;
|
|
760
|
-
if (!spki
|
|
785
|
+
if (!_bufferEquals(spki, _bufferFrom(leafSpki))) {
|
|
761
786
|
throw _err("sigstore/entry-mismatch", "the Rekor entry verifier public key does not match the bundle leaf certificate's key");
|
|
762
787
|
}
|
|
763
788
|
}
|
|
@@ -769,7 +794,7 @@ function _bindVerifier(content, leafDer) {
|
|
|
769
794
|
* matched through a replaceable protocol. */
|
|
770
795
|
function _isLowerHex(s) {
|
|
771
796
|
for (var i = 0; i < s.length; i++) {
|
|
772
|
-
var c = s
|
|
797
|
+
var c = _charCodeAt(s, i);
|
|
773
798
|
if (!((c >= 0x30 && c <= 0x39) || (c >= 0x61 && c <= 0x66))) return false;
|
|
774
799
|
}
|
|
775
800
|
return s.length > 0;
|
|
@@ -792,7 +817,7 @@ function _bindHashedRekordEntry(body, ms, leafDer) {
|
|
|
792
817
|
}
|
|
793
818
|
var bodySig = _b64(spec.signature.content, "Rekor entry signature");
|
|
794
819
|
var armSig = _b64(ms.signature, "messageSignature.signature");
|
|
795
|
-
if (!armSig
|
|
820
|
+
if (!_bufferEquals(armSig, bodySig)) {
|
|
796
821
|
throw _err("sigstore/entry-mismatch", "the Rekor entry signature does not match the bundle signature");
|
|
797
822
|
}
|
|
798
823
|
var pk = spec.signature.publicKey;
|
|
@@ -855,10 +880,10 @@ function _verifyRekorEntry(te, rekorKeys, leafDer, contentType, bind) {
|
|
|
855
880
|
var included;
|
|
856
881
|
try {
|
|
857
882
|
included = merkle.verifyInclusion({
|
|
858
|
-
leafIndex:
|
|
859
|
-
treeSize:
|
|
883
|
+
leafIndex: _bigIntOf(ip.logIndex),
|
|
884
|
+
treeSize: _bigIntOf(ip.treeSize),
|
|
860
885
|
leafHash: merkle.leafHash(canonBytes),
|
|
861
|
-
proof: ip.hashes
|
|
886
|
+
proof: _map(ip.hashes, function (h, i) { return _b64(h, "inclusionProof.hashes[" + i + "]"); }),
|
|
862
887
|
rootHash: _b64(ip.rootHash, "inclusionProof.rootHash"),
|
|
863
888
|
});
|
|
864
889
|
} catch (e) {
|
|
@@ -874,7 +899,7 @@ function _verifyRekorEntry(te, rekorKeys, leafDer, contentType, bind) {
|
|
|
874
899
|
var li = _numOf(te.logIndex);
|
|
875
900
|
return {
|
|
876
901
|
integratedTime: t, logIndex: _isFiniteNumber(li) ? li : null,
|
|
877
|
-
logId: te.logId && te.logId.keyId ? _b64(te.logId.keyId, "logId.keyId")
|
|
902
|
+
logId: te.logId && te.logId.keyId ? _bufToString(_b64(te.logId.keyId, "logId.keyId"), "hex") : null,
|
|
878
903
|
artifactHash: artifactHash,
|
|
879
904
|
};
|
|
880
905
|
}
|
|
@@ -883,7 +908,7 @@ function _verifyRekorEntry(te, rekorKeys, leafDer, contentType, bind) {
|
|
|
883
908
|
function _dn(cert, which) { return cert[which] && cert[which].dn; }
|
|
884
909
|
|
|
885
910
|
function _normRoots(fulcioRoots) {
|
|
886
|
-
return fulcioRoots
|
|
911
|
+
return _map(fulcioRoots, function (r, i) {
|
|
887
912
|
var der = _isBuffer(r) ? r : (r && (r.der || r.rawBytes));
|
|
888
913
|
if (!_isBuffer(der)) throw _err("sigstore/bad-input", "fulcioRoots[" + i + "] must be a DER Buffer or { der, validFor }");
|
|
889
914
|
return { cert: _parseCert(der, "Fulcio CA root [" + i + "]"), validFor: (r && r.validFor) || null };
|
|
@@ -895,7 +920,7 @@ function _pathToAnchor(leaf, anchor, intBySubject) {
|
|
|
895
920
|
/** @internal Issuers are collected leaf-first and the path is assembled once, so no element is
|
|
896
921
|
* ever moved to a new index: an indexed setter has nothing to intercept and cannot replace the
|
|
897
922
|
* leaf the preceding signature checks authenticated. */
|
|
898
|
-
var above = [], cur = leaf, seen =
|
|
923
|
+
var above = [], cur = leaf, seen = _create(null), guardN = 0;
|
|
899
924
|
function assemble() {
|
|
900
925
|
var path = [];
|
|
901
926
|
for (var k = above.length - 1; k >= 0; k--) guard.list.append(path, above[k]);
|
|
@@ -927,7 +952,7 @@ var OID_SCT_LIST = oid.byName("signedCertificateTimestampList");
|
|
|
927
952
|
function _normCtLogs(ctLogs) {
|
|
928
953
|
if (!_isArray(ctLogs)) throw _err("sigstore/bad-input", "ctLogs must be an array of { keyId, spki, validFor? }");
|
|
929
954
|
if (ctLogs.length === 0) throw _err("sigstore/bad-input", "ctLogs is empty; omit the option to skip the certificate-transparency check rather than supplying no logs");
|
|
930
|
-
return ctLogs
|
|
955
|
+
return _map(ctLogs, function (l, i) {
|
|
931
956
|
if (l === null || typeof l !== "object") throw _err("sigstore/bad-input", "ctLogs[" + i + "] must be { keyId, spki, validFor? }");
|
|
932
957
|
if (!_isBuffer(l.keyId)) throw _err("sigstore/bad-input", "ctLogs[" + i + "].keyId must be the log id as a Buffer");
|
|
933
958
|
if (!_isBuffer(l.spki)) throw _err("sigstore/bad-input", "ctLogs[" + i + "].spki must be the log's SubjectPublicKeyInfo DER");
|
|
@@ -984,24 +1009,24 @@ function _sctVerifies(entry, sct, spki) {
|
|
|
984
1009
|
|
|
985
1010
|
/** @internal A receipt's own instant, in milliseconds. The parser's `timestampMs` is this same value
|
|
986
1011
|
* wherever it is representable, and above 2^53 there is no reachable instant either way. */
|
|
987
|
-
function _sctMs(sct) { return
|
|
1012
|
+
function _sctMs(sct) { return _numberOf(sct.timestamp || 0); }
|
|
988
1013
|
|
|
989
1014
|
function _ctLogFor(logs, logIdBytes, timeMs) {
|
|
990
|
-
var want = _isBuffer(logIdBytes) ? logIdBytes :
|
|
1015
|
+
var want = _isBuffer(logIdBytes) ? logIdBytes : _bufferFrom(logIdBytes || []);
|
|
991
1016
|
for (var i = 0; i < logs.length; i++) {
|
|
992
|
-
if (logs[i].keyId
|
|
1017
|
+
if (_bufferEquals(logs[i].keyId, want) && _inWindow(timeMs, logs[i].validFor)) return logs[i];
|
|
993
1018
|
}
|
|
994
1019
|
return null;
|
|
995
1020
|
}
|
|
996
1021
|
|
|
997
1022
|
async function _verifyChain(leaf, chainDers, fulcioRoots, timeMs) {
|
|
998
1023
|
var roots = _normRoots(fulcioRoots);
|
|
999
|
-
var bundleLinks = chainDers
|
|
1000
|
-
var intBySubject =
|
|
1024
|
+
var bundleLinks = _map(_arraySlice(chainDers, 1), function (d, i) { return _parseCert(d, "bundle intermediate [" + i + "]"); });
|
|
1025
|
+
var intBySubject = _create(null);
|
|
1001
1026
|
function addInt(c) { guard.list.append(intBySubject[_dn(c, "subject")] = intBySubject[_dn(c, "subject")] || [], c); }
|
|
1002
|
-
roots
|
|
1003
|
-
bundleLinks
|
|
1004
|
-
var candidates = roots
|
|
1027
|
+
_forEach(roots, function (r) { addInt(r.cert); });
|
|
1028
|
+
_forEach(bundleLinks, addInt);
|
|
1029
|
+
var candidates = _filter(roots, function (r) { return _inWindow(timeMs, r.validFor); });
|
|
1005
1030
|
var lastErr = _err("sigstore/chain-incomplete", "no caller-supplied Fulcio anchor (within its validity window) issues the chain");
|
|
1006
1031
|
for (var i = 0; i < candidates.length; i++) {
|
|
1007
1032
|
var anchor = candidates[i].cert;
|
|
@@ -1010,7 +1035,7 @@ async function _verifyChain(leaf, chainDers, fulcioRoots, timeMs) {
|
|
|
1010
1035
|
var spki = anchor.subjectPublicKeyInfo;
|
|
1011
1036
|
try {
|
|
1012
1037
|
var res = await pathValidate.validate(path, {
|
|
1013
|
-
time: new
|
|
1038
|
+
time: new _Date(timeMs),
|
|
1014
1039
|
historicalMode: true,
|
|
1015
1040
|
trustAnchors: { name: anchor.subject, publicKey: spki.bytes, algorithm: spki.algorithm.oid, parameters: spki.algorithm.parameters },
|
|
1016
1041
|
requiredEku: ["codeSigning"],
|
|
@@ -1030,14 +1055,14 @@ async function _verifyChain(leaf, chainDers, fulcioRoots, timeMs) {
|
|
|
1030
1055
|
|
|
1031
1056
|
|
|
1032
1057
|
var SAN_OID = oid.byName("subjectAltName");
|
|
1033
|
-
var FULCIO_PREFIX = oid.byName("otherName")
|
|
1058
|
+
var FULCIO_PREFIX = _join(_arraySlice(_split(oid.byName("otherName"), "."), 0, -1), ".") + ".";
|
|
1034
1059
|
function _identity(leaf) {
|
|
1035
|
-
var out = { san: null, extensions:
|
|
1060
|
+
var out = { san: null, extensions: _create(null) };
|
|
1036
1061
|
try {
|
|
1037
|
-
(leaf.extensions || []
|
|
1062
|
+
_forEach(leaf.extensions || [], function (ext) {
|
|
1038
1063
|
if (ext.oid === SAN_OID) { out.san = _sanValue(ext); return; }
|
|
1039
|
-
if (ext.oid
|
|
1040
|
-
out.extensions[ext.name || ext.oid] = _fulcioExtValue(ext,
|
|
1064
|
+
if (_strIndexOf(ext.oid, FULCIO_PREFIX) === 0) {
|
|
1065
|
+
out.extensions[ext.name || ext.oid] = _fulcioExtValue(ext, _numberOf(_strSlice(ext.oid, FULCIO_PREFIX.length)));
|
|
1041
1066
|
}
|
|
1042
1067
|
});
|
|
1043
1068
|
} catch (e) {
|
|
@@ -1046,7 +1071,7 @@ function _identity(leaf) {
|
|
|
1046
1071
|
}
|
|
1047
1072
|
return out;
|
|
1048
1073
|
}
|
|
1049
|
-
var GN_TYPE =
|
|
1074
|
+
var GN_TYPE = _assign(_create(null), { 1: "rfc822Name", 2: "dNSName", 6: "uri" });
|
|
1050
1075
|
function _sanValue(ext) {
|
|
1051
1076
|
var seq = asn1.decode(ext.value);
|
|
1052
1077
|
var names = [];
|
|
@@ -1055,7 +1080,7 @@ function _sanValue(ext) {
|
|
|
1055
1080
|
if (n.tagClass !== "context") continue;
|
|
1056
1081
|
var val = null;
|
|
1057
1082
|
if (!n.constructed && GN_TYPE[n.tagNumber]) {
|
|
1058
|
-
val = { type: GN_TYPE[n.tagNumber], value: asn1.read.octetStringImplicit(n, n.tagNumber)
|
|
1083
|
+
val = { type: GN_TYPE[n.tagNumber], value: _bufToString(asn1.read.octetStringImplicit(n, n.tagNumber), "utf8") };
|
|
1059
1084
|
} else if (n.constructed && n.tagNumber === 0 && (n.children || []).length >= 2) {
|
|
1060
1085
|
var inner = (n.children[1].children || [])[0] || n.children[1];
|
|
1061
1086
|
var v;
|
|
@@ -1073,13 +1098,13 @@ function _sanValue(ext) {
|
|
|
1073
1098
|
}
|
|
1074
1099
|
function _fulcioExtValue(ext, leafArc) {
|
|
1075
1100
|
if (!_isBuffer(ext.value)) throw _err("sigstore/bad-certificate", "Fulcio extension " + ext.oid + " has no value");
|
|
1076
|
-
if (leafArc >= 1 && leafArc <= 6) return ext.value
|
|
1101
|
+
if (leafArc >= 1 && leafArc <= 6) return _bufToString(ext.value, "utf8");
|
|
1077
1102
|
return asn1.read.string(asn1.decode(ext.value));
|
|
1078
1103
|
}
|
|
1079
1104
|
|
|
1080
1105
|
var IDENTITY_FIELDS = ["san", "issuer", "sourceRepositoryURI"];
|
|
1081
|
-
var IDENTITY_KEYS =
|
|
1082
|
-
var _VERIFY_BUNDLE_OPTS =
|
|
1106
|
+
var IDENTITY_KEYS = _assign(_create(null), { san: 1, issuer: 1, sourceRepositoryURI: 1 });
|
|
1107
|
+
var _VERIFY_BUNDLE_OPTS = _assign(_create(null), { fulcioRoots: 1, rekorKeys: 1, ctLogs: 1, identity: 1, predicateType: 1, time: 1, artifact: 1 });
|
|
1083
1108
|
|
|
1084
1109
|
/** @internal The bytes a message signature covers, taken once. There is no shape here in which a
|
|
1085
1110
|
* caller hands over a precomputed digest: the arm's own field comment forbids using one as a
|
|
@@ -1101,21 +1126,21 @@ function _checkIdentity(id, policy) {
|
|
|
1101
1126
|
var ran = { san: false, issuer: false, sourceRepositoryURI: false };
|
|
1102
1127
|
if (policy === undefined || policy === null) return ran;
|
|
1103
1128
|
if (typeof policy !== "object" || _isArray(policy)) {
|
|
1104
|
-
throw _err("sigstore/bad-input", "opts.identity must be an object naming the identity fields to pin (" + IDENTITY_FIELDS
|
|
1129
|
+
throw _err("sigstore/bad-input", "opts.identity must be an object naming the identity fields to pin (" + _join(IDENTITY_FIELDS, ", ") + ")");
|
|
1105
1130
|
}
|
|
1106
1131
|
guard.identifier.assertKnownKeys(policy, IDENTITY_KEYS, _err, "sigstore/bad-input", "opts.identity has an unknown key ");
|
|
1107
|
-
var asked = IDENTITY_FIELDS
|
|
1132
|
+
var asked = _filter(IDENTITY_FIELDS, function (f) { return policy[f] !== undefined; });
|
|
1108
1133
|
if (!asked.length) {
|
|
1109
|
-
throw _err("sigstore/bad-input", "opts.identity constrains nothing -- name at least one of " + IDENTITY_FIELDS
|
|
1134
|
+
throw _err("sigstore/bad-input", "opts.identity constrains nothing -- name at least one of " + _join(IDENTITY_FIELDS, ", ") + ", or omit it to state that the signer is not being checked");
|
|
1110
1135
|
}
|
|
1111
|
-
asked
|
|
1136
|
+
_forEach(asked, function (f) {
|
|
1112
1137
|
if (typeof policy[f] !== "string" || policy[f] === "") {
|
|
1113
1138
|
throw _err("sigstore/bad-input", "opts.identity." + f + " must be a non-empty string -- a value that cannot be compared would leave the signer unchecked under a policy that names it");
|
|
1114
1139
|
}
|
|
1115
1140
|
ran[f] = true;
|
|
1116
1141
|
});
|
|
1117
1142
|
var sanValue = id.san && id.san.value;
|
|
1118
|
-
if (policy.san && sanValue !== policy.san) throw _err("sigstore/identity-mismatch", "the certificate SAN " +
|
|
1143
|
+
if (policy.san && sanValue !== policy.san) throw _err("sigstore/identity-mismatch", "the certificate SAN " + _jsonStringify(sanValue) + " does not match the expected identity");
|
|
1119
1144
|
if (policy.issuer && policy.issuer !== id.extensions.issuer && policy.issuer !== id.extensions.issuerLegacy) throw _err("sigstore/identity-mismatch", "the certificate OIDC issuer does not match the expected issuer");
|
|
1120
1145
|
if (policy.sourceRepositoryURI && id.extensions.sourceRepositoryURI !== policy.sourceRepositoryURI) throw _err("sigstore/identity-mismatch", "the certificate source-repository URI does not match");
|
|
1121
1146
|
return ran;
|
|
@@ -1130,7 +1155,7 @@ function _statement(payload, payloadType, expectedPredicate) {
|
|
|
1130
1155
|
if (!st || typeof st !== "object" || st._type !== "https://in-toto.io/Statement/v1") throw _err("sigstore/bad-statement", "the payload is not an in-toto Statement v1");
|
|
1131
1156
|
if (!_isArray(st.subject) || !st.subject.length) throw _err("sigstore/bad-statement", "the in-toto statement has no subject");
|
|
1132
1157
|
if (expectedPredicate && st.predicateType !== expectedPredicate) {
|
|
1133
|
-
throw _err("sigstore/predicate-mismatch", "the statement predicateType " +
|
|
1158
|
+
throw _err("sigstore/predicate-mismatch", "the statement predicateType " + _jsonStringify(st.predicateType) + " does not match the expected " + _jsonStringify(expectedPredicate));
|
|
1134
1159
|
}
|
|
1135
1160
|
return st;
|
|
1136
1161
|
}
|
|
@@ -1305,9 +1330,9 @@ async function verifyBundle(bundle, opts) {
|
|
|
1305
1330
|
var candidateDigest = null;
|
|
1306
1331
|
if (isMsg) {
|
|
1307
1332
|
candidateDigest = nodeCrypto.createHash(candidate.artifactHash.node).update(artifact).digest();
|
|
1308
|
-
if (!guard.crypto.constantTimeEqual(candidateDigest,
|
|
1333
|
+
if (!guard.crypto.constantTimeEqual(candidateDigest, _bufferFrom(candidate.artifactHash.value, "hex"))) {
|
|
1309
1334
|
throw _err("sigstore/artifact-mismatch", "the artifact does not match the one the transparency-log entry records; its " +
|
|
1310
|
-
candidate.artifactHash.algorithm + " digest is " + candidateDigest
|
|
1335
|
+
candidate.artifactHash.algorithm + " digest is " + _bufToString(candidateDigest, "hex") + " and the entry names " + candidate.artifactHash.value);
|
|
1311
1336
|
}
|
|
1312
1337
|
}
|
|
1313
1338
|
var candidateTime = haveCallerTime ? callerTime : C.TIME.seconds(candidate.integratedTime);
|
|
@@ -1337,7 +1362,7 @@ async function verifyBundle(bundle, opts) {
|
|
|
1337
1362
|
if (isMsg) {
|
|
1338
1363
|
digestAlgorithm = rekor.artifactHash.algorithm;
|
|
1339
1364
|
var computed = artifactComputed;
|
|
1340
|
-
artifactDigest = computed
|
|
1365
|
+
artifactDigest = _bufToString(computed, "hex");
|
|
1341
1366
|
if (msParsed.digest !== null) {
|
|
1342
1367
|
var againstClaim = msParsed.digestAlg.node === rekor.artifactHash.node ? computed
|
|
1343
1368
|
: nodeCrypto.createHash(msParsed.digestAlg.node).update(artifact).digest();
|
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:12c7bd5e-a715-426d-b609-24c3b76f11be",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-09-
|
|
8
|
+
"timestamp": "2026-09-12T07:21:39.704Z",
|
|
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.
|
|
22
|
+
"bom-ref": "@blamejs/pki@0.7.31",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "pki",
|
|
25
|
-
"version": "0.7.
|
|
25
|
+
"version": "0.7.31",
|
|
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.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/pki@0.7.31",
|
|
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.
|
|
57
|
+
"ref": "@blamejs/pki@0.7.31",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|