@blamejs/pki 0.5.3 → 0.5.5
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 +43 -1
- package/MIGRATING.md +31 -0
- package/README.md +3 -3
- package/lib/attrcert-sign.js +11 -7
- package/lib/cmp-session.js +23 -10
- package/lib/cmp-verify.js +12 -4
- package/lib/cms-decrypt.js +71 -30
- package/lib/cms-encrypt.js +7 -11
- package/lib/crl-sign.js +170 -24
- package/lib/est.js +77 -1
- package/lib/guard-all.js +6 -0
- package/lib/guard-encoding.js +35 -6
- package/lib/guard-identifier.js +27 -1
- package/lib/guard-json.js +44 -8
- package/lib/guard-name.js +31 -8
- package/lib/guard-parsed.js +443 -0
- package/lib/hpke.js +36 -3
- package/lib/jose.js +8 -0
- package/lib/lint.js +20 -4
- package/lib/merkle.js +9 -0
- package/lib/ocsp.js +38 -8
- package/lib/path-validate.js +201 -72
- package/lib/pkcs12-build.js +34 -7
- package/lib/pki-build.js +12 -1
- package/lib/schema-crl.js +7 -1
- package/lib/schema-ocsp.js +6 -1
- package/lib/schema-pkcs12.js +7 -2
- package/lib/schema-pkix.js +76 -0
- package/lib/schema-x509.js +14 -1
- package/lib/sign-scheme.js +22 -5
- package/lib/smime.js +47 -0
- package/lib/trust.js +121 -10
- package/lib/tsp-sign.js +40 -19
- package/lib/validator-cose.js +86 -1
- package/lib/validator-tpm.js +8 -3
- package/lib/webauthn-mds.js +19 -29
- package/lib/webauthn.js +40 -18
- package/lib/x509-sign.js +6 -2
- package/package.json +5 -1
- package/sbom.cdx.json +6 -6
package/lib/validator-cose.js
CHANGED
|
@@ -156,6 +156,90 @@ function credentialKey(node, E, code, unsupportedCode) {
|
|
|
156
156
|
// CANONICAL CTAP2 COSE_Key: exactly the type's parameters, nothing more.
|
|
157
157
|
var expectedParams = kty === 2n ? 5 : 4;
|
|
158
158
|
if (node.children.length !== expectedParams) throw bad("the COSE_Key carries parameters beyond the canonical set for its key type (WebAuthn sec. 6.5.1)");
|
|
159
|
+
return assertKeyMaterial(key, E, code, unsupportedCode);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// assertKeyMaterial(key, E, code, unsupportedCode) -> key | throws
|
|
163
|
+
//
|
|
164
|
+
// The rules about the KEY, split from the rules about its CBOR encoding, because the
|
|
165
|
+
// toolkit accepts a stored credential key in two forms and both reach a signature
|
|
166
|
+
// verification. `pki.webauthn.verifyAssertion` takes the COSE bytes or the object
|
|
167
|
+
// `pki.webauthn.verify` returned; the bytes went through every check below and the
|
|
168
|
+
// object went through none, so the same 1-byte modulus was refused as a credential key
|
|
169
|
+
// in one form and imported for verification in the other. A caller stores whichever
|
|
170
|
+
// form their datastore round-trips, which is not a choice about how carefully their
|
|
171
|
+
// credential is checked.
|
|
172
|
+
//
|
|
173
|
+
// Everything above this line is about the ENCODING -- a CBOR map, integer labels, byte
|
|
174
|
+
// strings, the canonical parameter count -- and can only be asked of bytes. Everything
|
|
175
|
+
// here is about the key, and is asked of both.
|
|
176
|
+
//
|
|
177
|
+
// @enforced-by behavioral -- key-material rules have no rename-proof code shape distinct
|
|
178
|
+
// from ordinary length and byte comparisons; the RED vectors that drive BOTH accepted
|
|
179
|
+
// forms of a stored credential key (the COSE bytes and the object) through
|
|
180
|
+
// pki.webauthn.verifyAssertion with an undersized modulus, e = 1, a curve/length
|
|
181
|
+
// mismatch and a short OKP x are the guard.
|
|
182
|
+
function assertKeyMaterial(key, E, code, unsupportedCode) {
|
|
183
|
+
function bad(msg, cause) { return new E(code, msg, cause); }
|
|
184
|
+
if (!key || typeof key !== "object") throw bad("a credential key must be a decoded COSE_Key object");
|
|
185
|
+
// ONE read of each field, into a plain object, before anything is checked or used.
|
|
186
|
+
//
|
|
187
|
+
// The object form comes from the caller, so any of these can be an accessor. One that THROWS
|
|
188
|
+
// turns a validation into a raw fault -- the thing this function exists to prevent -- and one
|
|
189
|
+
// that returns DIFFERENT values on successive reads makes the field that was checked and the
|
|
190
|
+
// field that is used two different values, which is the check defeated rather than merely
|
|
191
|
+
// reported badly. Reading each exactly once settles both, and settles them for every field
|
|
192
|
+
// rather than for the ones a particular branch happens to reach.
|
|
193
|
+
try {
|
|
194
|
+
key = { kty: key.kty, alg: key.alg, crv: key.crv, x: key.x, y: key.y, n: key.n, e: key.e };
|
|
195
|
+
} catch (e) { throw bad("a credential key field could not be read", e); }
|
|
196
|
+
// Then the TYPE and the VALUE. BigInt() throws a raw TypeError on a Symbol and on undefined, and
|
|
197
|
+
// a raw RangeError on a fractional or non-finite number, so "it is a number" is not the check --
|
|
198
|
+
// "it is an integer" is. EVERY integer label the branches below read, not the two the dispatch
|
|
199
|
+
// happens to need first:
|
|
200
|
+
// crv indexes a lookup table, and a Symbol thrown at a property read is the same raw fault as a
|
|
201
|
+
// Symbol thrown at BigInt(). The decoded form gets these from the CBOR reader, which has already
|
|
202
|
+
// established them; the object form gets them from the caller, so this is where they are settled.
|
|
203
|
+
// A BigInt is bounded too. COSE labels are small registry integers, and an unbounded one converts
|
|
204
|
+
// to Infinity, which then throws a raw RangeError at the next conversion -- the same defeat as a
|
|
205
|
+
// fractional number, reached by a value that IS an integer. "It is an integer" is not the whole
|
|
206
|
+
// check either; "it is an integer this code can carry" is.
|
|
207
|
+
var MAX = BigInt(Number.MAX_SAFE_INTEGER);
|
|
208
|
+
function _isInt(v) {
|
|
209
|
+
if (typeof v === "bigint") return v <= MAX && v >= -MAX;
|
|
210
|
+
return typeof v === "number" && Number.isSafeInteger(v);
|
|
211
|
+
}
|
|
212
|
+
if (!_isInt(key.kty)) throw bad("a COSE_Key kty (label 1) must be an integer");
|
|
213
|
+
if (!_isInt(key.alg)) throw bad("a COSE_Key alg (label 3) must be an integer");
|
|
214
|
+
if (key.crv !== undefined && key.crv !== null && !_isInt(key.crv)) throw bad("a COSE_Key crv (label -1) must be an integer");
|
|
215
|
+
// ONE representation from here down. A label may arrive as a Number or a BigInt -- a CBOR reader
|
|
216
|
+
// hands out BigInt, an object built in JavaScript is likelier to hold Number -- and everything
|
|
217
|
+
// below compares with === against the Number-keyed profile table and the curve tables. Accepting
|
|
218
|
+
// both forms at the gate and then comparing only one is a check that answers by how the caller
|
|
219
|
+
// happened to spell the value; the decoded arm normalizes here too, for the same reason.
|
|
220
|
+
key.kty = Number(key.kty);
|
|
221
|
+
key.alg = Number(key.alg);
|
|
222
|
+
if (key.crv !== undefined && key.crv !== null) key.crv = Number(key.crv);
|
|
223
|
+
var kty = BigInt(key.kty);
|
|
224
|
+
if (kty === 2n) {
|
|
225
|
+
var el2 = EC2_CRV_LEN[key.crv];
|
|
226
|
+
if (!Buffer.isBuffer(key.x) || !Buffer.isBuffer(key.y)) throw bad("an EC2 COSE_Key must carry crv (-1), x (-2), and y (-3)");
|
|
227
|
+
if (!el2 || key.x.length !== el2 || key.y.length !== el2) throw bad("an EC2 COSE_Key x/y length is inconsistent with its curve");
|
|
228
|
+
} else if (kty === 1n) {
|
|
229
|
+
var okp2 = OKP_CRV[key.crv];
|
|
230
|
+
if (!okp2 || !Buffer.isBuffer(key.x) || key.x.length !== okp2.len) throw bad("an OKP COSE_Key must be Ed25519 (crv 6) or Ed448 (crv 7) with a matching-length x (-2)");
|
|
231
|
+
} else if (kty === 3n) {
|
|
232
|
+
if (!Buffer.isBuffer(key.n) || !key.n.length || !Buffer.isBuffer(key.e) || !key.e.length) throw bad("an RSA COSE_Key must carry n (-1) and e (-2)");
|
|
233
|
+
if (key.n[0] === 0) throw bad("an RSA COSE_Key modulus (-1) must be minimally encoded, with no leading zero byte (RFC 8230 sec. 4)");
|
|
234
|
+
if (key.e[0] === 0) throw bad("an RSA COSE_Key exponent (-2) must be minimally encoded, with no leading zero byte (RFC 8230 sec. 4)");
|
|
235
|
+
var bits = _modulusBits(key.n);
|
|
236
|
+
if (bits < RSA_MIN_MODULUS_BITS) throw bad("an RSA COSE_Key modulus (-1) is " + bits + " bits, below the " + RSA_MIN_MODULUS_BITS + "-bit minimum");
|
|
237
|
+
if (key.e.length > RSA_MAX_EXPONENT_BYTES) throw bad("an RSA COSE_Key exponent (-2) is longer than " + RSA_MAX_EXPONENT_BYTES + " bytes");
|
|
238
|
+
if ((key.e[key.e.length - 1] & 1) === 0) throw bad("an RSA COSE_Key exponent (-2) must be odd");
|
|
239
|
+
if (key.e.length === 1 && key.e[0] <= 1) throw bad("an RSA COSE_Key exponent (-2) must be greater than 1 -- e = 1 makes RSA the identity function");
|
|
240
|
+
} else {
|
|
241
|
+
throw bad("unsupported COSE_Key kty " + Number(key.kty));
|
|
242
|
+
}
|
|
159
243
|
// PROFILE: the declared alg must match the key type (and, for EC2, the curve).
|
|
160
244
|
var prof = ALG_PROFILE[String(key.alg)];
|
|
161
245
|
// An algorithm this verifier does not implement is NOT a malformed key. The key can be perfectly
|
|
@@ -173,7 +257,7 @@ function credentialKey(node, E, code, unsupportedCode) {
|
|
|
173
257
|
// OpenSSL does NOT validate an OKP (Ed25519/Ed448) point on import -- an all-zeroes key
|
|
174
258
|
// parses, and even verifies a trivial signature -- so an OKP point needs an explicit
|
|
175
259
|
// on-curve + full-order (non-low-order) check (RFC 8032 decode + the cofactor check).
|
|
176
|
-
if (kty ===
|
|
260
|
+
if (Number(key.kty) === 1 && !edwardsPoint.validate(key.x, key.crv)) throw bad("the OKP credential public key is not a valid, full-order Edwards point");
|
|
177
261
|
return key;
|
|
178
262
|
}
|
|
179
263
|
|
|
@@ -216,6 +300,7 @@ function toSpki(key, E, code) {
|
|
|
216
300
|
|
|
217
301
|
module.exports = {
|
|
218
302
|
credentialKey: credentialKey,
|
|
303
|
+
assertKeyMaterial: assertKeyMaterial,
|
|
219
304
|
toSpki: toSpki,
|
|
220
305
|
EC2_CRV_LEN: EC2_CRV_LEN,
|
|
221
306
|
EC2_CRV_OID: EC2_CRV_OID,
|
package/lib/validator-tpm.js
CHANGED
|
@@ -221,12 +221,17 @@ function normalizeObjectAttributePolicy(policy, E, code) {
|
|
|
221
221
|
// either of which could match a key this policy was written to exclude, including the
|
|
222
222
|
// Empty Policy. An entry that is not a Buffer or a canonical even-length hex string is a
|
|
223
223
|
// caller error, and it fails here rather than becoming a digest nobody intended.
|
|
224
|
+
// Through guard.encoding.hex, which owns the alphabet, the even-length rule and the
|
|
225
|
+
// canonical round-trip -- the same three checks written here by hand, and now written
|
|
226
|
+
// once. It also decodes, so the hex path cannot validate one string and decode another.
|
|
224
227
|
allow = ap.allow.map(function (entry, i) {
|
|
225
228
|
if (Buffer.isBuffer(entry)) return entry;
|
|
226
|
-
|
|
227
|
-
|
|
229
|
+
var label = "opts.tpmPolicy.authPolicy.allow[" + i + "]";
|
|
230
|
+
if (typeof entry !== "string" || entry.length === 0) {
|
|
231
|
+
throw new E(code, label + " must be a Buffer or an even-length hex string");
|
|
228
232
|
}
|
|
229
|
-
return
|
|
233
|
+
return guard.encoding.hex(entry, null, function (c, m) { return new E(c, m); }, code,
|
|
234
|
+
label + " must be a Buffer or an even-length hex string --");
|
|
230
235
|
});
|
|
231
236
|
}
|
|
232
237
|
}
|
package/lib/webauthn-mds.js
CHANGED
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
// FIDO Metadata Service v3.0 sec. 3.1 / sec. 3.2, RFC 7515 (JWS).
|
|
21
21
|
|
|
22
22
|
var frameworkError = require("./framework-error");
|
|
23
|
-
var asn1 = require("./asn1-der");
|
|
24
23
|
var x509 = require("./schema-x509");
|
|
25
24
|
var guard = require("./guard-all");
|
|
26
25
|
var jose = require("./jose");
|
|
@@ -32,7 +31,10 @@ var edwardsPoint = require("./edwards-point");
|
|
|
32
31
|
var webcrypto = require("./webcrypto");
|
|
33
32
|
var nodeCrypto = require("crypto");
|
|
34
33
|
|
|
34
|
+
var oid = require("./oid");
|
|
35
|
+
var pkix = require("./schema-pkix");
|
|
35
36
|
var WebauthnError = frameworkError.WebauthnError;
|
|
37
|
+
var _KU_NS = pkix.makeNS("webauthn", WebauthnError, oid);
|
|
36
38
|
function _err(code, message, cause) { return new WebauthnError(code, message, cause); }
|
|
37
39
|
var C = constants.LIMITS;
|
|
38
40
|
|
|
@@ -183,17 +185,13 @@ var UNDERSTOOD_HEADER = Object.assign(Object.create(null), {
|
|
|
183
185
|
|
|
184
186
|
// The BLOB's signing certificate must be allowed to sign. RFC 5280 sec. 4.2.1.3 numbers
|
|
185
187
|
// digitalSignature bit 0 of the keyUsage BIT STRING; an absent extension places no restriction.
|
|
188
|
+
// Through the shared reader, which applies the NamedBitList rules a local bit test does not: DER
|
|
189
|
+
// drops trailing zero bits (X.690 sec. 11.2.2) and sec. 4.2.1.3 requires at least one bit set, so
|
|
190
|
+
// reading the bits here would let a certificate the rest of the toolkit calls malformed sign a BLOB.
|
|
186
191
|
function _assertLeafSigns(leaf) {
|
|
187
|
-
var
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
var ku;
|
|
191
|
-
try { ku = asn1.read.bitString(asn1.decode(exts[i].value)); }
|
|
192
|
-
catch (e) { throw _err("webauthn/bad-att-cert", "the metadata BLOB x5c leaf keyUsage extension is malformed", e); }
|
|
193
|
-
if (!ku.bytes.length || (ku.bytes[0] & 0x80) === 0) {
|
|
194
|
-
throw _err("webauthn/bad-att-cert", "the metadata BLOB x5c leaf keyUsage does not assert digitalSignature, so it may not sign the BLOB (RFC 5280 sec. 4.2.1.3)");
|
|
195
|
-
}
|
|
196
|
-
return;
|
|
192
|
+
var ku = pkix.keyUsageOf(_KU_NS, leaf, _err, "webauthn/bad-att-cert", "metadata BLOB x5c leaf");
|
|
193
|
+
if (ku && ku.digitalSignature !== true) {
|
|
194
|
+
throw _err("webauthn/bad-att-cert", "the metadata BLOB x5c leaf keyUsage does not assert digitalSignature, so it may not sign the BLOB (RFC 5280 sec. 4.2.1.3)");
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
197
|
|
|
@@ -214,24 +212,16 @@ function _isAnchorItself(cert, anchor) {
|
|
|
214
212
|
// a hand-built object literal satisfies it too and then raises a raw TypeError from deep inside the
|
|
215
213
|
// path validator, which is an untyped throw escaping a public verb.
|
|
216
214
|
function _asCert(v, label) {
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
//
|
|
220
|
-
//
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
// `validity` is what separates a certificate from the other signed structures that carry a
|
|
228
|
-
// subject, a public key and a signature algorithm: a parsed certification request has all
|
|
229
|
-
// three and would otherwise be installed as a trust anchor.
|
|
230
|
-
v.validity && v.validity.notBefore !== undefined) {
|
|
231
|
-
return v;
|
|
232
|
-
}
|
|
233
|
-
try { return x509.parse(v); }
|
|
234
|
-
catch (e) { throw _err("webauthn/bad-input", label + " is not a decodable certificate", e); }
|
|
215
|
+
// Through the shared certificate door: these become the anchors a metadata BLOB's signer chain is
|
|
216
|
+
// judged against, and an anchor's identity is its subject and its key. A caller-assembled object
|
|
217
|
+
// could carry a real root's subject beside a substituted key -- every field well-formed, nothing
|
|
218
|
+
// for a shape test to catch -- so the object is re-derived from the bytes its parser read instead.
|
|
219
|
+
// Bytes in any form (a Buffer, a typed-array view, a DataView, an ArrayBuffer) are parsed here;
|
|
220
|
+
// refusing one of those would make the accepted set depend on how the caller received the file.
|
|
221
|
+
return guard.parsed.acceptDerived(v, "certificate", function (bytes) {
|
|
222
|
+
try { return x509.parse(bytes); }
|
|
223
|
+
catch (e) { throw _err("webauthn/bad-input", label + " is not a decodable certificate", e); }
|
|
224
|
+
}, _err, "webauthn/bad-input", label);
|
|
235
225
|
}
|
|
236
226
|
|
|
237
227
|
// Verify a FIDO Metadata Service BLOB and return its entries indexed for lookup. `blob` is the
|
package/lib/webauthn.js
CHANGED
|
@@ -572,8 +572,13 @@ function _snapshotRoots(supplied) {
|
|
|
572
572
|
if (_isBufferSource(root)) {
|
|
573
573
|
return guard.bytes.snapshotSource(root, WebauthnError, "webauthn/bad-input", "opts.rootCertificates[]");
|
|
574
574
|
}
|
|
575
|
-
|
|
576
|
-
|
|
575
|
+
// A PARSED certificate is kept AS IT IS, not deep-copied. The copy was this function's way of
|
|
576
|
+
// stopping a caller mutating a root after it was accepted, and it solved that by making a
|
|
577
|
+
// detached twin -- which loses the parser's record, so the door below could no longer re-derive
|
|
578
|
+
// the anchor from the bytes it was read from. The record is the stronger form of the same
|
|
579
|
+
// protection: the anchor is re-parsed from those bytes, so an edit made afterwards, at any depth,
|
|
580
|
+
// is discarded rather than copied. Cloning would trade that for a snapshot of a mutable object.
|
|
581
|
+
return root; // a PEM string is immutable; a parsed certificate carries its own provenance
|
|
577
582
|
});
|
|
578
583
|
}
|
|
579
584
|
|
|
@@ -592,13 +597,16 @@ function _applyCallerRoots(res, supplied, vopts, onlyPaths) {
|
|
|
592
597
|
// would fault on a field it does not have rather than naming the caller's mistake.
|
|
593
598
|
// The same three forms opts.safetyNetRoots takes, since it is the same question.
|
|
594
599
|
var roots = supplied.map(function (root, i) {
|
|
595
|
-
var
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
600
|
+
var label = "opts.rootCertificates[" + i + "]";
|
|
601
|
+
// These BECOME trust anchors, which is the sharpest form of the rule: the anchor's key is what
|
|
602
|
+
// the whole attestation chain is judged against, so a caller-assembled certificate carrying a
|
|
603
|
+
// real root's name beside a substituted key would anchor an attacker's chain. Re-derived from
|
|
604
|
+
// the bytes its parser read, exactly as at every other certificate door.
|
|
605
|
+
return guard.parsed.acceptDerived(root, "certificate", function (bytes) {
|
|
606
|
+
try {
|
|
607
|
+
return x509.parse(_isBufferSource(bytes) ? guard.bytes.source(bytes, WebauthnError, "webauthn/bad-input", label) : bytes);
|
|
608
|
+
} catch (e) { throw _err("webauthn/bad-input", label + " is not a decodable certificate", e); }
|
|
609
|
+
}, _err, "webauthn/bad-input", label);
|
|
602
610
|
});
|
|
603
611
|
// Same rule the metadata route applies: a compound element carrying no
|
|
604
612
|
// certificates makes no claim there is anything to anchor, so it is not a reason to
|
|
@@ -1174,14 +1182,15 @@ function _safetyNetHostnameOk(leaf) {
|
|
|
1174
1182
|
function _safetyNetChainTrusted(chain, roots, time) {
|
|
1175
1183
|
var anchors;
|
|
1176
1184
|
try {
|
|
1185
|
+
// The same door opts.rootCertificates goes through, for the same reason: these become trust
|
|
1186
|
+
// anchors, and an anchor's key is what the chain is judged against.
|
|
1177
1187
|
anchors = roots.map(function (root, i) {
|
|
1178
|
-
var
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
throw _err("webauthn/bad-input",
|
|
1183
|
-
}
|
|
1184
|
-
return anchorCert;
|
|
1188
|
+
var label = "opts.safetyNetRoots[" + i + "]";
|
|
1189
|
+
return guard.parsed.acceptDerived(root, "certificate", function (bytes) {
|
|
1190
|
+
try {
|
|
1191
|
+
return x509.parse(_isBufferSource(bytes) ? guard.bytes.source(bytes, WebauthnError, "webauthn/bad-input", label) : bytes);
|
|
1192
|
+
} catch (e) { throw _err("webauthn/bad-input", label + " is not a decodable certificate", e); }
|
|
1193
|
+
}, _err, "webauthn/bad-input", label);
|
|
1185
1194
|
});
|
|
1186
1195
|
} catch (e) { return Promise.reject(e); }
|
|
1187
1196
|
return mds.chainToAnchor(chain, anchors, time === undefined ? new Date() : time,
|
|
@@ -2228,7 +2237,13 @@ function _snapshotAssertion(input) {
|
|
|
2228
2237
|
var key = {}, kk;
|
|
2229
2238
|
for (kk in out.credentialPublicKey) {
|
|
2230
2239
|
if (!Object.prototype.hasOwnProperty.call(out.credentialPublicKey, kk)) continue;
|
|
2231
|
-
|
|
2240
|
+
// The read itself can fault: a stored key is a caller-supplied object, so a field may be an
|
|
2241
|
+
// accessor, and one that THROWS would escape as a raw error from the very copy whose job is
|
|
2242
|
+
// to make the descriptor stop being the caller's. The copy is the boundary, so the fault is
|
|
2243
|
+
// named here rather than surfacing from wherever the field was later used.
|
|
2244
|
+
var v;
|
|
2245
|
+
try { v = out.credentialPublicKey[kk]; }
|
|
2246
|
+
catch (e) { throw _err("webauthn/bad-cose-key", "credentialPublicKey." + kk + " could not be read", e); }
|
|
2232
2247
|
key[kk] = _isBufferSource(v) ? guard.bytes.snapshotSource(v, WebauthnError, "webauthn/bad-input", "credentialPublicKey." + kk) : v;
|
|
2233
2248
|
}
|
|
2234
2249
|
out.credentialPublicKey = key;
|
|
@@ -2295,7 +2310,14 @@ function verifyAssertion(input) {
|
|
|
2295
2310
|
var coseKey = input.credentialPublicKey;
|
|
2296
2311
|
if (Buffer.isBuffer(coseKey) || ArrayBuffer.isView(coseKey) || coseKey instanceof ArrayBuffer) {
|
|
2297
2312
|
coseKey = parseCoseKey(coseKey);
|
|
2298
|
-
} else if (
|
|
2313
|
+
} else if (_isPlainObject(coseKey)) {
|
|
2314
|
+
// The OBJECT form is held to the same rules about the KEY as the bytes form. The bytes went
|
|
2315
|
+
// through the curve/length, RSA modulus-floor and exponent checks; the object went through
|
|
2316
|
+
// none, so one stored credential was refused in one form and imported for signature
|
|
2317
|
+
// verification in the other. Which form a relying party stores is a question about what their
|
|
2318
|
+
// datastore round-trips, not about how carefully their credential is checked.
|
|
2319
|
+
coseKey = validator.cose.assertKeyMaterial(coseKey, WebauthnError, "webauthn/bad-cose-key", "webauthn/unsupported-algorithm");
|
|
2320
|
+
} else {
|
|
2299
2321
|
throw _err("webauthn/bad-input", "credentialPublicKey must be the stored COSE key -- the object pki.webauthn.verify returned, or its COSE bytes");
|
|
2300
2322
|
}
|
|
2301
2323
|
var bindingChecked = _applyBindings(authData, coseKey, input);
|
package/lib/x509-sign.js
CHANGED
|
@@ -286,8 +286,12 @@ function _sign(spec, issuer, opts) {
|
|
|
286
286
|
issuerDer = subjectDer;
|
|
287
287
|
issuerSpki = spki;
|
|
288
288
|
} else if (issuer.cert != null) {
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
// The CA-ness gate, the issuer name and the signing key are all read off this object, so a
|
|
290
|
+
// partial one decides them on fields that are not there.
|
|
291
|
+
// Re-derived from the bytes its parser read. The issuer certificate's subject and key identifier
|
|
292
|
+
// are copied into the certificate being signed, so they are a claim about who issued it -- an
|
|
293
|
+
// assembled object could name an issuer whose bytes the signer never saw.
|
|
294
|
+
issuerCert = guard.parsed.acceptDerived(issuer.cert, "certificate", x509.parse, _err, "x509/bad-input", "issuer.cert");
|
|
291
295
|
issuerPathLen = _assertIssuerIsCa(issuerCert);
|
|
292
296
|
issuerDer = pkiBuild.tbsNameField(issuerCert, "subject");
|
|
293
297
|
issuerSpki = issuerCert.subjectPublicKeyInfo.bytes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blamejs/pki",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
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",
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"url": "https://github.com/blamejs/pki/issues"
|
|
14
14
|
},
|
|
15
15
|
"main": "index.js",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": "./index.js",
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
16
20
|
"bin": {
|
|
17
21
|
"pki": "bin/pki.js"
|
|
18
22
|
},
|
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:e4afed62-75b0-4b79-b65c-4d16c17ee70b",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-08-
|
|
8
|
+
"timestamp": "2026-08-15T23:54:15.184Z",
|
|
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.5.
|
|
22
|
+
"bom-ref": "@blamejs/pki@0.5.5",
|
|
23
23
|
"type": "application",
|
|
24
24
|
"name": "pki",
|
|
25
|
-
"version": "0.5.
|
|
25
|
+
"version": "0.5.5",
|
|
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.5.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/pki@0.5.5",
|
|
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.5.
|
|
57
|
+
"ref": "@blamejs/pki@0.5.5",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|