@blamejs/pki 0.8.61 → 0.9.0
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 +24 -0
- package/README.md +7 -0
- package/index.js +55 -26
- package/lib/acme.js +5 -5
- package/lib/asn1-der.js +1 -1
- package/lib/attrcert-sign.js +2 -2
- package/lib/cbor-det.js +4 -1
- package/lib/cmc-build.js +1 -1
- package/lib/cmp-build.js +5 -5
- package/lib/cmp-session.js +6 -3
- package/lib/cmp-verify.js +1 -1
- package/lib/cms-compress.js +5 -2
- package/lib/cms-decrypt.js +2 -2
- package/lib/cms-encrypt.js +2 -2
- package/lib/cms-sign.js +2 -2
- package/lib/crl-sign.js +3 -3
- package/lib/crmf-sign.js +1 -1
- package/lib/csr-sign.js +1 -1
- package/lib/ct.js +14 -13
- package/lib/est.js +12 -12
- package/lib/framework-error.js +1 -1
- package/lib/guard-bytes.js +1 -1
- package/lib/guard-limits.js +3 -2
- package/lib/hpke.js +2 -2
- package/lib/http-retry-after.js +4 -1
- package/lib/http-transport.js +6 -6
- package/lib/inspect.js +9 -4
- package/lib/jose.js +3 -3
- package/lib/merkle.js +4 -4
- package/lib/ocsp.js +2 -2
- package/lib/path-validate.js +3 -3
- package/lib/pbes2.js +8 -4
- package/lib/pkcs12-build.js +5 -5
- package/lib/scep.js +1 -1
- package/lib/schema-engine.js +12 -12
- package/lib/schema-pkix.js +12 -12
- package/lib/sign-scheme.js +2 -2
- package/lib/sigstore.js +1 -1
- package/lib/smime.js +11 -7
- package/lib/tlog.js +2 -2
- package/lib/tls-cert-compress.js +3 -3
- package/lib/tsp-sign.js +6 -6
- package/lib/tuf.js +3 -3
- package/lib/webauthn-mds.js +1 -1
- package/lib/webauthn.js +1 -1
- package/lib/x509-sign.js +3 -3
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/lib/est.js
CHANGED
|
@@ -533,7 +533,7 @@ function _partMediaType(contentType) {
|
|
|
533
533
|
}
|
|
534
534
|
|
|
535
535
|
function parseServerKeygenResponse(body, contentType, opts) {
|
|
536
|
-
opts = opts ||
|
|
536
|
+
opts = opts || intrinsic.create(null);
|
|
537
537
|
opts = _knownOpts(opts, PARSE_SERVERKEYGEN_OPTS, "parseServerKeygenResponse");
|
|
538
538
|
var parts = splitMultipartMixed(body, contentType);
|
|
539
539
|
if (parts.length !== 2) throw E("est/bad-multipart", "a serverkeygen response must have exactly two parts (RFC 7030 sec. 4.4.2)");
|
|
@@ -617,7 +617,7 @@ function classifyResponse(status, headers, body, opts) {
|
|
|
617
617
|
}
|
|
618
618
|
|
|
619
619
|
function _classifyResponse(status, headers, body, opts) {
|
|
620
|
-
opts = opts ||
|
|
620
|
+
opts = opts || intrinsic.create(null);
|
|
621
621
|
opts = _knownOpts(opts, CLASSIFY_OPTS, "classifyResponse");
|
|
622
622
|
var op = opts.op;
|
|
623
623
|
if (op !== undefined && op !== null && CLASSIFIABLE_OPS.indexOf(op) === -1) throw E("est/unsupported-operation", "unrecognized EST operation " + guard.text.showValue(op));
|
|
@@ -689,7 +689,7 @@ function _classifyResponse(status, headers, body, opts) {
|
|
|
689
689
|
* // -> "https://ca.example/.well-known/est/cacerts"
|
|
690
690
|
*/
|
|
691
691
|
function paths(baseUrl, opts) {
|
|
692
|
-
opts = opts ||
|
|
692
|
+
opts = opts || intrinsic.create(null);
|
|
693
693
|
opts = _knownOpts(opts, PATHS_OPTS, "paths");
|
|
694
694
|
var base = String(baseUrl);
|
|
695
695
|
var prefix = base.slice(0, _stripTrailingSlashEnd(base)) + "/.well-known/est";
|
|
@@ -957,7 +957,7 @@ function _drive(method, url, body, headers, opts, transport, budgets) {
|
|
|
957
957
|
function step() {
|
|
958
958
|
var hopBody = (typeof body === "function" && budgets.onAttempt) ? budgets.onAttempt() : body;
|
|
959
959
|
return guard.async.invoked(transport, [{ method: method, url: _urlHref(url), headers: _headersFor(url), body: hopBody, tls: _tlsFor(url), proxy: budgets.proxy, timeout: budgets.timeout, maxResponseBytes: budgets.maxResponseBytes }], E, "est/bad-input", "opts.transport").then(function (res) {
|
|
960
|
-
res = res ||
|
|
960
|
+
res = res || intrinsic.create(null);
|
|
961
961
|
var blen = _bodyLen(res);
|
|
962
962
|
if (blen > budgets.maxResponseBytes) throw E("est/response-too-large", "the response body (" + blen + " bytes) exceeds the " + budgets.maxResponseBytes + "-byte cap (RFC 7030 sec. 6)");
|
|
963
963
|
var h = intrinsic.assign(intrinsic.create(null), {
|
|
@@ -1159,7 +1159,7 @@ function _certsResult(op, res, opts, csrSpki) {
|
|
|
1159
1159
|
* r.retry && r.retryAfterSeconds; // 60
|
|
1160
1160
|
*/
|
|
1161
1161
|
function fullcmc(baseUrl, request, opts) {
|
|
1162
|
-
opts = opts ||
|
|
1162
|
+
opts = opts || intrinsic.create(null);
|
|
1163
1163
|
var der, wanted, sent;
|
|
1164
1164
|
try {
|
|
1165
1165
|
if (typeof opts !== "object" || Buffer.isBuffer(opts)) throw E("est/bad-input", "pki.est.fullcmc options must be an object");
|
|
@@ -1588,7 +1588,7 @@ function _enroll(op, baseUrl, csrInput, opts, proxySnap) {
|
|
|
1588
1588
|
* r.certificates; // -> [Buffer, ...] raw, unordered
|
|
1589
1589
|
*/
|
|
1590
1590
|
function cacerts(baseUrl, opts) {
|
|
1591
|
-
opts = opts ||
|
|
1591
|
+
opts = opts || intrinsic.create(null);
|
|
1592
1592
|
var proxySnap; try { proxySnap = _snapProxy(opts); } catch (_pe) { return _rej(E("est/bad-input", "the options object could not be read", _pe)); }
|
|
1593
1593
|
return _promiseResolve(_Promise, undefined).then(function () {
|
|
1594
1594
|
opts = _knownOpts(opts, CACERTS_OPTS, "cacerts");
|
|
@@ -1654,7 +1654,7 @@ function cacerts(baseUrl, opts) {
|
|
|
1654
1654
|
* bound.retry; // true
|
|
1655
1655
|
*/
|
|
1656
1656
|
function simpleenroll(baseUrl, csrInput, opts) {
|
|
1657
|
-
opts = opts ||
|
|
1657
|
+
opts = opts || intrinsic.create(null);
|
|
1658
1658
|
var proxySnap; try { proxySnap = _snapProxy(opts); } catch (_pe) { return _rej(E("est/bad-input", "the options object could not be read", _pe)); }
|
|
1659
1659
|
return _promiseResolve(_Promise, undefined).then(function () {
|
|
1660
1660
|
opts = _knownOpts(opts, SIMPLEENROLL_OPTS, "simpleenroll");
|
|
@@ -1694,7 +1694,7 @@ function simpleenroll(baseUrl, csrInput, opts) {
|
|
|
1694
1694
|
* r.retry; // true
|
|
1695
1695
|
*/
|
|
1696
1696
|
function simplereenroll(baseUrl, csrInput, opts) {
|
|
1697
|
-
opts = opts ||
|
|
1697
|
+
opts = opts || intrinsic.create(null);
|
|
1698
1698
|
var proxySnap; try { proxySnap = _snapProxy(opts); } catch (_pe) { return _rej(E("est/bad-input", "the options object could not be read", _pe)); }
|
|
1699
1699
|
return _promiseResolve(_Promise, undefined).then(function () {
|
|
1700
1700
|
opts = _knownOpts(opts, SIMPLEREENROLL_OPTS, "simplereenroll");
|
|
@@ -1751,7 +1751,7 @@ function _assertConfidentialCipher(res) {
|
|
|
1751
1751
|
}
|
|
1752
1752
|
|
|
1753
1753
|
function _ciHeaderList(headers, name) {
|
|
1754
|
-
headers = headers ||
|
|
1754
|
+
headers = headers || intrinsic.create(null);
|
|
1755
1755
|
/** @internal The header NAME a value is selected under is folded through the captured conversion on
|
|
1756
1756
|
* both sides of the comparison: the match decides which header this response is read from. */
|
|
1757
1757
|
var lname = _toLowerCase(name), keys = guard.identifier.optionNames(headers), parts = [];
|
|
@@ -1765,7 +1765,7 @@ function _ciHeaderList(headers, name) {
|
|
|
1765
1765
|
}
|
|
1766
1766
|
|
|
1767
1767
|
function _ciHeader(headers, name) {
|
|
1768
|
-
headers = headers ||
|
|
1768
|
+
headers = headers || intrinsic.create(null);
|
|
1769
1769
|
var lname = _toLowerCase(name), keys = guard.identifier.optionNames(headers), found = null, n = 0;
|
|
1770
1770
|
for (var i = 0; i < keys.length; i++) {
|
|
1771
1771
|
if (_toLowerCase(keys[i]) !== lname) continue;
|
|
@@ -1854,7 +1854,7 @@ async function _serverkeygenResult(res, opts, derived) {
|
|
|
1854
1854
|
* r.retry; // true -- a 202 is surfaced, never slept
|
|
1855
1855
|
*/
|
|
1856
1856
|
function serverkeygen(baseUrl, csrInput, opts) {
|
|
1857
|
-
opts = opts ||
|
|
1857
|
+
opts = opts || intrinsic.create(null);
|
|
1858
1858
|
var proxySnap; try { proxySnap = _snapProxy(opts); } catch (_pe) { return _rej(E("est/bad-input", "the options object could not be read", _pe)); }
|
|
1859
1859
|
return _promiseResolve(_Promise, undefined).then(function () {
|
|
1860
1860
|
opts = _knownOpts(opts, SERVERKEYGEN_OPTS, "serverkeygen");
|
|
@@ -1916,7 +1916,7 @@ function _csrattrsResult(res, opts) {
|
|
|
1916
1916
|
* r.available; // false -- a 404 is "no CSR-attributes policy available"
|
|
1917
1917
|
*/
|
|
1918
1918
|
function csrattrs(baseUrl, opts) {
|
|
1919
|
-
opts = opts ||
|
|
1919
|
+
opts = opts || intrinsic.create(null);
|
|
1920
1920
|
var proxySnap; try { proxySnap = _snapProxy(opts); } catch (_pe) { return _rej(E("est/bad-input", "the options object could not be read", _pe)); }
|
|
1921
1921
|
return _promiseResolve(_Promise, undefined).then(function () {
|
|
1922
1922
|
opts = _knownOpts(opts, CSRATTRS_OPTS, "csrattrs");
|
package/lib/framework-error.js
CHANGED
|
@@ -122,7 +122,7 @@ function defineClass(name, opts) {
|
|
|
122
122
|
if (typeof name !== "string" || name.length === 0) {
|
|
123
123
|
throw new TypeError("defineClass: name must be a non-empty string");
|
|
124
124
|
}
|
|
125
|
-
opts = opts ||
|
|
125
|
+
opts = opts || intrinsic.create(null);
|
|
126
126
|
var withCause = !!opts.withCause;
|
|
127
127
|
var flagKey = "is" + name;
|
|
128
128
|
|
package/lib/guard-bytes.js
CHANGED
|
@@ -281,7 +281,7 @@ function snapshotSource(input, ErrorClass, code, label) {
|
|
|
281
281
|
* the budget rather than the shape of the input. The figure is far above any real caller value: an
|
|
282
282
|
* options bag or a JWK is tens of nodes, and a certificate chain passed as an anchor list is thousands. */
|
|
283
283
|
function snapshotDeep(value, ErrorClass, code, label, opts) {
|
|
284
|
-
var o = opts ||
|
|
284
|
+
var o = opts || _create(null);
|
|
285
285
|
var cap = o.maxDepth == null ? 64 : o.maxDepth;
|
|
286
286
|
var maxNodes = o.maxNodes == null ? constants.LIMITS.DEEP_COPY_MAX_NODES : o.maxNodes;
|
|
287
287
|
return _deep(value, ErrorClass, code, label, cap, 0, o.collect || null, { n: 0, max: maxNodes });
|
package/lib/guard-limits.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// @internal
|
|
5
5
|
|
|
6
6
|
var constants = require("./constants");
|
|
7
|
+
var _create = require("./guard-intrinsic").create;
|
|
7
8
|
var _isInteger = require("./guard-intrinsic").isInteger;
|
|
8
9
|
var _freeze = require("./guard-intrinsic").freeze;
|
|
9
10
|
var _sizeOf = require("./guard-intrinsic").sizeOf;
|
|
@@ -15,7 +16,7 @@ function _monotonicNow() { return _Number(_hrtimeBigint() / 1000000n); }
|
|
|
15
16
|
// @enforced-by behavioral -- a config-time cap validator has no rename-proof code
|
|
16
17
|
function cap(value, key, dflt, opts) {
|
|
17
18
|
if (value === undefined) return dflt;
|
|
18
|
-
opts = opts ||
|
|
19
|
+
opts = opts || _create(null);
|
|
19
20
|
/** @internal Each bound is read ONCE, into the value the integer check and the comparison share.
|
|
20
21
|
* Read twice, the check saw one bound and the comparison another, so an `opts` answering a valid
|
|
21
22
|
* small integer to the check and a large one to the comparison configured a cap that admitted a
|
|
@@ -141,7 +142,7 @@ function budget(limits) {
|
|
|
141
142
|
*/
|
|
142
143
|
// @enforced-by behavioral -- an elapsed-time comparison has no rename-proof shape that separates a deadline from any other subtraction; the vectors driving a checker to its bound are the guard
|
|
143
144
|
function deadline(totalMs, opts) {
|
|
144
|
-
opts = opts ||
|
|
145
|
+
opts = opts || _create(null);
|
|
145
146
|
var rawNow = opts.now;
|
|
146
147
|
var now = typeof rawNow === "function" ? rawNow : _monotonicNow;
|
|
147
148
|
if (!_isInteger(totalMs) || totalMs < 0) {
|
package/lib/hpke.js
CHANGED
|
@@ -923,7 +923,7 @@ function _setupS(ids, pkR, opts) {
|
|
|
923
923
|
* the subject being the key rather than the ciphertext. `_suite(ids)` stays above both, by necessity:
|
|
924
924
|
* which KEM this is decides the width the key is held to. */
|
|
925
925
|
var r = _recipPublic(suite, pkR);
|
|
926
|
-
opts = _options(opts ||
|
|
926
|
+
opts = _options(opts || intrinsic.create(null), _SETUP_S_KEYS, "sender setup");
|
|
927
927
|
var mode = opts.mode;
|
|
928
928
|
var kem = suite.kem, k;
|
|
929
929
|
if (mode === MODE_AUTH || mode === MODE_AUTH_PSK) {
|
|
@@ -978,7 +978,7 @@ function _setupR(ids, enc, skR, opts) {
|
|
|
978
978
|
* size of whatever was supplied: a 64 MiB value handed where a 32-byte encapsulation belongs was
|
|
979
979
|
* copied in full and only then refused. */
|
|
980
980
|
var sealed = _rawKey(enc, _encWidth(suite.kem));
|
|
981
|
-
opts = _options(opts ||
|
|
981
|
+
opts = _options(opts || intrinsic.create(null), _SETUP_R_KEYS, "recipient setup");
|
|
982
982
|
var mode = opts.mode;
|
|
983
983
|
var r = _recipPrivate(suite, skR);
|
|
984
984
|
var kem = suite.kem, ss;
|
package/lib/http-retry-after.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
"use strict";
|
|
4
4
|
// @internal
|
|
5
5
|
|
|
6
|
+
/** @internal The record constructor, captured at load, for the reason the same capture in
|
|
7
|
+
* `lib/inspect.js` gives: arming this module counts 48 live runtime reads. */
|
|
8
|
+
var _create = Object.create;
|
|
6
9
|
var constants = require("./constants");
|
|
7
10
|
var guard = require("./guard-all");
|
|
8
11
|
|
|
@@ -100,7 +103,7 @@ function httpDateMs(s, refMs) {
|
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
function parse(value, opts) {
|
|
103
|
-
opts = opts ||
|
|
106
|
+
opts = opts || _create(null);
|
|
104
107
|
var raStr = String(value).trim();
|
|
105
108
|
var out = { retryAfterSeconds: null, retryAfterDate: null };
|
|
106
109
|
if (_isAllDigits(raStr)) {
|
package/lib/http-transport.js
CHANGED
|
@@ -339,7 +339,7 @@ function _blockedAddrErr(hostname, address) {
|
|
|
339
339
|
}
|
|
340
340
|
function _makeGuardedLookup(lookupFn) {
|
|
341
341
|
return function guardedLookup(hostname, options, callback) {
|
|
342
|
-
lookupFn(hostname, options ||
|
|
342
|
+
lookupFn(hostname, options || intrinsic.create(null), function (err, address, family) {
|
|
343
343
|
if (err) return callback(err);
|
|
344
344
|
/** @internal Each address is read ONCE, the read is what gets classified, and the SNAPSHOT is
|
|
345
345
|
* what the socket layer is handed. Forwarding the list the resolver returned let the entry be
|
|
@@ -633,7 +633,7 @@ function _proxyErrorClass(e, C) {
|
|
|
633
633
|
* res.status; // 200
|
|
634
634
|
*/
|
|
635
635
|
function httpsTransport(defaults) {
|
|
636
|
-
defaults = defaults ||
|
|
636
|
+
defaults = defaults || intrinsic.create(null);
|
|
637
637
|
/** @internal Each of these is read ONCE, into the value both the test and the use see, and the
|
|
638
638
|
* error factory a refusal is built from is one of them. */
|
|
639
639
|
var rawE = defaults.E;
|
|
@@ -789,7 +789,7 @@ function httpsTransport(defaults) {
|
|
|
789
789
|
}
|
|
790
790
|
|
|
791
791
|
var _transportFn = function transport(request) {
|
|
792
|
-
request = request ||
|
|
792
|
+
request = request || intrinsic.create(null);
|
|
793
793
|
var prep;
|
|
794
794
|
try { prep = _prepare(request); }
|
|
795
795
|
catch (e) { return _promiseReject(_Promise, e); }
|
|
@@ -848,7 +848,7 @@ function httpsTransport(defaults) {
|
|
|
848
848
|
/** @internal Captured for consistency with the rest of the file, not because this gates
|
|
849
849
|
* anything: an understated `content-length` only skips this EARLY refusal, and the cap is
|
|
850
850
|
* enforced below on the bytes actually counted as they arrive. */
|
|
851
|
-
var declared = intrinsic.parseInt((res.headers ||
|
|
851
|
+
var declared = intrinsic.parseInt((res.headers || intrinsic.create(null))["content-length"], 10);
|
|
852
852
|
if (intrinsic.numberIsFinite(declared) && declared > prep.maxBytes) { fail(C("response-too-large"), "the declared content-length " + declared + " exceeds the " + prep.maxBytes + "-byte cap (RFC 7030 sec. 6)"); return; }
|
|
853
853
|
var buf = _bufferAllocUnsafe(0);
|
|
854
854
|
var len = 0;
|
|
@@ -1039,7 +1039,7 @@ function httpsTransport(defaults) {
|
|
|
1039
1039
|
* connecting directly while a proxy is configured would reach an origin the caller asked not to
|
|
1040
1040
|
* reach directly. */
|
|
1041
1041
|
_transportFn.peerChain = function peerChain(request) {
|
|
1042
|
-
request = request ||
|
|
1042
|
+
request = request || intrinsic.create(null);
|
|
1043
1043
|
var prep;
|
|
1044
1044
|
try { prep = _prepare({
|
|
1045
1045
|
url: request.url,
|
|
@@ -1149,6 +1149,6 @@ function httpsTransport(defaults) {
|
|
|
1149
1149
|
* pki.schema.x509.parse(channel.peerChain[0]).subject.dn; // the leaf's subject
|
|
1150
1150
|
* channel.peerCertificate; // the one certificate the endpoint sent
|
|
1151
1151
|
*/
|
|
1152
|
-
function peerChain(request, defaults) { return httpsTransport(defaults ||
|
|
1152
|
+
function peerChain(request, defaults) { return httpsTransport(defaults || intrinsic.create(null)).peerChain(request); }
|
|
1153
1153
|
|
|
1154
1154
|
module.exports = { https: httpsTransport, peerChain: peerChain, isBlockedIp: _isBlockedIp, _makeGuardedLookup: _makeGuardedLookup, MAX_TIMEOUT: MAX_TIMEOUT, snapshotProxy: snapshotProxy };
|
package/lib/inspect.js
CHANGED
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
* @card Read a certificate like `openssl x509 -text`, in pure JS.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
/** @internal The record constructor, captured at load. A default record written as `{}` has
|
|
27
|
+
* `Object.prototype`, so every field the caller omitted is read off the prototype chain. This module
|
|
28
|
+
* does not take the guard-intrinsic captures, and requiring them arms it whole: measured, that counts
|
|
29
|
+
* 662 live runtime reads here, which is a migration of its own rather than a line in this change. */
|
|
30
|
+
var _create = Object.create;
|
|
26
31
|
var frameworkError = require("./framework-error");
|
|
27
32
|
var constants = require("./constants");
|
|
28
33
|
var asn1 = require("./asn1-der");
|
|
@@ -56,7 +61,7 @@ var OID_UNOTICE = oid.byName("unotice");
|
|
|
56
61
|
|
|
57
62
|
var HEX = "0123456789abcdef";
|
|
58
63
|
function _hexColon(buf, opts) {
|
|
59
|
-
opts = opts ||
|
|
64
|
+
opts = opts || _create(null);
|
|
60
65
|
var hex = [];
|
|
61
66
|
for (var i = 0; i < buf.length; i++) {
|
|
62
67
|
var b = buf[i], s = HEX[(b >> 4) & 0xf] + HEX[b & 0xf];
|
|
@@ -346,7 +351,7 @@ var EXT_RENDERERS = Object.assign(Object.create(null), {
|
|
|
346
351
|
return (decoded || []).map(function (ad) {
|
|
347
352
|
var m = null;
|
|
348
353
|
try { m = oid.name(ad.accessMethod); } catch (_e) { /* allow:swallow-unverified display best-effort: an unregistered accessMethod OID falls back to the raw dotted OID below (inspection is best-effort, never a verdict) */ }
|
|
349
|
-
var loc = ad.accessLocation ||
|
|
354
|
+
var loc = ad.accessLocation || _create(null), lv;
|
|
350
355
|
if (loc.tag === 6) lv = "URI:" + loc.value;
|
|
351
356
|
else if (loc.tag === 2) lv = "DNS:" + loc.value;
|
|
352
357
|
else if (loc.tag === 1) lv = "email:" + loc.value;
|
|
@@ -1368,7 +1373,7 @@ function pkcs12Report(input) {
|
|
|
1368
1373
|
* structure, and the outer MacData fields then describe nothing: read from there, a store with 2048
|
|
1369
1374
|
* PBKDF2 iterations reported one iteration, an empty salt, and "pbmac1" as its digest. */
|
|
1370
1375
|
if (p.mac.pbmac1) {
|
|
1371
|
-
var kdf = p.mac.pbmac1.kdf ||
|
|
1376
|
+
var kdf = p.mac.pbmac1.kdf || _create(null);
|
|
1372
1377
|
_optLine(L, " ", "Digest", p.mac.pbmac1.schemeName || p.mac.pbmac1.schemeOid);
|
|
1373
1378
|
_optLine(L, " ", "Key Derivation", kdf.prfName || kdf.prfOid);
|
|
1374
1379
|
_optLine(L, " ", "Iterations", kdf.iterationCount);
|
|
@@ -2363,7 +2368,7 @@ var KNOWN_DUMP_OPTS = Object.assign(Object.create(null),
|
|
|
2363
2368
|
* // Incomplete: the walk could not read the value at offset 5: content length 3 overruns the 0 bytes that remain.
|
|
2364
2369
|
*/
|
|
2365
2370
|
function asn1Dump(input, opts) {
|
|
2366
|
-
if (opts === undefined || opts === null) opts =
|
|
2371
|
+
if (opts === undefined || opts === null) opts = _create(null);
|
|
2367
2372
|
if (typeof opts !== "object" || Array.isArray(opts)) {
|
|
2368
2373
|
throw _err("inspect/bad-input", "pki.inspect.asn1 options must be an object");
|
|
2369
2374
|
}
|
package/lib/jose.js
CHANGED
|
@@ -325,7 +325,7 @@ function assertPublicJwk(jwk) {
|
|
|
325
325
|
*/
|
|
326
326
|
var _VERIFY_KEYS = intrinsic.assign(intrinsic.create(null), { key: 1, profile: 1 });
|
|
327
327
|
async function verify(jws, opts) {
|
|
328
|
-
opts = opts ||
|
|
328
|
+
opts = opts || intrinsic.create(null);
|
|
329
329
|
guard.identifier.assertKnownKeys(opts, _VERIFY_KEYS, E, "jose/bad-input", "unknown pki.jose.verify option ");
|
|
330
330
|
/** @internal opts.key is examined several times: the type gate, the RFC 7638 thumbprint comparison
|
|
331
331
|
* against the embedded jwk, and the key the signature is verified under. An option reached through
|
|
@@ -456,7 +456,7 @@ function _fixedPayload(supplied) {
|
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
async function sign(opts) {
|
|
459
|
-
opts = opts ||
|
|
459
|
+
opts = opts || intrinsic.create(null);
|
|
460
460
|
guard.identifier.assertKnownKeys(opts, _SIGN_KEYS, E, "jose/bad-input", "unknown pki.jose.sign option ");
|
|
461
461
|
var fixedPayload = _fixedPayload(opts.payload);
|
|
462
462
|
var headerJson;
|
|
@@ -496,7 +496,7 @@ async function sign(opts) {
|
|
|
496
496
|
var protectedB64 = b64uEncode(headerBytes);
|
|
497
497
|
var payloadB64 = payload.length === 0 ? "" : b64uEncode(payload);
|
|
498
498
|
var signingInput = _bufferFrom(protectedB64 + "." + payloadB64, "ascii");
|
|
499
|
-
var jwk = header.jwk || opts.jwk ||
|
|
499
|
+
var jwk = header.jwk || opts.jwk || intrinsic.create(null);
|
|
500
500
|
/** @internal `suppliedKey` is the reading taken at the top, so the key adopted for signing, the key the
|
|
501
501
|
* hash-to-algorithm check approved and the key the expected signature width is computed from are all
|
|
502
502
|
* one key. */
|
package/lib/merkle.js
CHANGED
|
@@ -274,7 +274,7 @@ function emptyRootHash() {
|
|
|
274
274
|
*/
|
|
275
275
|
var _INCLUSION_KEYS = _assign(_create(null), { leafIndex: 1, treeSize: 1, leafHash: 1, rootHash: 1, proof: 1 });
|
|
276
276
|
function verifyInclusion(opts) {
|
|
277
|
-
opts = opts ||
|
|
277
|
+
opts = opts || _create(null);
|
|
278
278
|
guard.identifier.assertKnownKeys(opts, _INCLUSION_KEYS, function (c, m) { return new MerkleError(c, m); },
|
|
279
279
|
"merkle/bad-input", "unknown verifyInclusion option ");
|
|
280
280
|
var leafIndex = _coerceCoord(opts.leafIndex, "leafIndex");
|
|
@@ -346,7 +346,7 @@ function verifyInclusion(opts) {
|
|
|
346
346
|
*/
|
|
347
347
|
var _CONSISTENCY_KEYS = _assign(_create(null), { oldSize: 1, newSize: 1, oldRoot: 1, newRoot: 1, proof: 1 });
|
|
348
348
|
function verifyConsistency(opts) {
|
|
349
|
-
opts = opts ||
|
|
349
|
+
opts = opts || _create(null);
|
|
350
350
|
guard.identifier.assertKnownKeys(opts, _CONSISTENCY_KEYS, function (c, m) { return new MerkleError(c, m); },
|
|
351
351
|
"merkle/bad-input", "unknown verifyConsistency option ");
|
|
352
352
|
var oldSize = _coerceCoord(opts.oldSize, "oldSize");
|
|
@@ -456,7 +456,7 @@ function root(leafHashes) {
|
|
|
456
456
|
*/
|
|
457
457
|
var _INCLUSION_PROOF_KEYS = _assign(_create(null), { leafHashes: 1, leafIndex: 1 });
|
|
458
458
|
function inclusionProof(opts) {
|
|
459
|
-
opts = opts ||
|
|
459
|
+
opts = opts || _create(null);
|
|
460
460
|
guard.identifier.assertKnownKeys(opts, _INCLUSION_PROOF_KEYS, _merkleErr,
|
|
461
461
|
"merkle/bad-input", "unknown inclusionProof option ");
|
|
462
462
|
var leaves = _leafArray(opts.leafHashes, "leafHashes");
|
|
@@ -498,7 +498,7 @@ function inclusionProof(opts) {
|
|
|
498
498
|
*/
|
|
499
499
|
var _CONSISTENCY_PROOF_KEYS = _assign(_create(null), { leafHashes: 1, oldSize: 1 });
|
|
500
500
|
function consistencyProof(opts) {
|
|
501
|
-
opts = opts ||
|
|
501
|
+
opts = opts || _create(null);
|
|
502
502
|
guard.identifier.assertKnownKeys(opts, _CONSISTENCY_PROOF_KEYS, _merkleErr,
|
|
503
503
|
"merkle/bad-input", "unknown consistencyProof option ");
|
|
504
504
|
var leaves = _leafArray(opts.leafHashes, "leafHashes");
|
package/lib/ocsp.js
CHANGED
|
@@ -350,7 +350,7 @@ function _sign(responseData, responder, opts) {
|
|
|
350
350
|
opts = guard.identifier.optionsObject(opts, _err, "ocsp/bad-input", "pki.ocsp.sign options");
|
|
351
351
|
guard.identifier.assertKnownKeys(opts, _SIGN_OPTS, _err, "ocsp/bad-input",
|
|
352
352
|
"pki.ocsp.sign has an unknown option (the nonce to echo back is `nonce`): ");
|
|
353
|
-
responseData = responseData ||
|
|
353
|
+
responseData = responseData || _ocspIntrinsic.create(null);
|
|
354
354
|
if (typeof responseData !== "object") throw _err("ocsp/bad-input", "the responseData must be an object { responderID, responses, producedAt? }");
|
|
355
355
|
guard.identifier.assertKnownKeys(responseData, _RESPONSE_DATA_KEYS, _err, "ocsp/bad-input", "unknown responseData field (accepted: responderID, responses, producedAt): ");
|
|
356
356
|
if (!responder || typeof responder !== "object") throw _err("ocsp/bad-input", "a responder must be { cert, key }");
|
|
@@ -449,7 +449,7 @@ function _responderID(rid, respCert) {
|
|
|
449
449
|
throw _err("ocsp/bad-input", "responderID must be \"byName\" or \"byKey\"");
|
|
450
450
|
}
|
|
451
451
|
function _buildSingleResponse(r, opts) {
|
|
452
|
-
r = r ||
|
|
452
|
+
r = r || _ocspIntrinsic.create(null);
|
|
453
453
|
var certIdP;
|
|
454
454
|
if (typeof r !== "object") return _promiseReject(_Promise, _err("ocsp/bad-input", "each response entry must be an object"));
|
|
455
455
|
try { guard.identifier.assertKnownKeys(r, _SINGLE_RESPONSE_KEYS, _err, "ocsp/bad-input", "unknown response entry field (accepted: cert, issuer, certID, hashAlgorithm, status, thisUpdate, nextUpdate, singleExtensions): "); }
|
package/lib/path-validate.js
CHANGED
|
@@ -1867,7 +1867,7 @@ async function _validate(path, opts, run, scope) {
|
|
|
1867
1867
|
}
|
|
1868
1868
|
|
|
1869
1869
|
if (opts.ctLogList != null) {
|
|
1870
|
-
var ctCheck = await ctGateCheck(certs[n - 1], certs, anchor, opts.ctLogList, opts.ctPolicy ||
|
|
1870
|
+
var ctCheck = await ctGateCheck(certs[n - 1], certs, anchor, opts.ctLogList, opts.ctPolicy || intrinsic.create(null), n, opts.time);
|
|
1871
1871
|
var target = null;
|
|
1872
1872
|
for (var tr = 0; tr < state.results.length; tr++) { if (state.results[tr].index === n - 1) { target = state.results[tr]; break; } }
|
|
1873
1873
|
if (target) guard.list.append(target.checks, ctCheck);
|
|
@@ -2599,7 +2599,7 @@ function _ocspFromBytes(response) {
|
|
|
2599
2599
|
}
|
|
2600
2600
|
|
|
2601
2601
|
function _verifyOcspParsed(parsedResponse, cert, issuerCert, time, opts) {
|
|
2602
|
-
opts = opts ||
|
|
2602
|
+
opts = opts || intrinsic.create(null);
|
|
2603
2603
|
/** @internal The captured finite test rather than a live `isNaN`: a valid Date's instant is always
|
|
2604
2604
|
* finite and an invalid one's is not, so the two answer the same question, and the instant is read
|
|
2605
2605
|
* ONCE into the value the test decides on. */
|
|
@@ -3356,7 +3356,7 @@ async function _aiaFetchOne(uri, aia) {
|
|
|
3356
3356
|
var res = await guard.async.invoked(aia.transport,
|
|
3357
3357
|
[{ method: "GET", url: uri, tls: aia.tls, timeout: aia.timeout, maxResponseBytes: aia.maxResponseBytes, blockPrivateAddresses: true }],
|
|
3358
3358
|
E, "path/bad-input", "opts.transport");
|
|
3359
|
-
res = res ||
|
|
3359
|
+
res = res || intrinsic.create(null);
|
|
3360
3360
|
if (res.status !== 200) throw E("path/aia-status", "an AIA fetch returned HTTP " + res.status + " (only 200 is a cert source; no redirect following)");
|
|
3361
3361
|
var body = guard.bytes.isByteSource(res.body)
|
|
3362
3362
|
? guard.bytes.source(res.body, PathError, "path/aia-bad-body", "the AIA response body")
|
package/lib/pbes2.js
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
// @internal
|
|
5
5
|
|
|
6
6
|
var asn1 = require("./asn1-der");
|
|
7
|
+
/** @internal The record constructor, captured at load, for the reason the same capture in
|
|
8
|
+
* `lib/inspect.js` gives: arming this module counts 25 live runtime reads. */
|
|
9
|
+
var _create = Object.create;
|
|
7
10
|
var oid = require("./oid");
|
|
8
11
|
var webcrypto = require("./webcrypto");
|
|
9
12
|
var guard = require("./guard-all");
|
|
@@ -110,7 +113,7 @@ function cbcDecrypt(key, iv, ct, keyBits, E, code) {
|
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
function pbes2Encrypt(pwBytes, plaintext, opts, E, prefix) {
|
|
113
|
-
opts = opts ||
|
|
116
|
+
opts = opts || _create(null);
|
|
114
117
|
var cipherName = opts.cipher || "aes256-CBC";
|
|
115
118
|
var keyBits = CONTENT_KEYBITS[O(cipherName)];
|
|
116
119
|
if (!keyBits || cipherName.indexOf("CBC") === -1) throw E(prefix + "/bad-input", "unsupported PBES2 cipher " + cipherName + " (AES-CBC only)");
|
|
@@ -168,9 +171,10 @@ function pbmac1AlgId(desc) {
|
|
|
168
171
|
|
|
169
172
|
function pbmac1(pwBytes, salt, iterationCount, keyLength, prfHash, macHash, message) {
|
|
170
173
|
var subtle = webcrypto.webcrypto.subtle;
|
|
171
|
-
/** @internal Every step is continued through the capture, and the wipe is attached on
|
|
172
|
-
*
|
|
173
|
-
* a PBMAC1 integrity tag is computed under, so a replacement
|
|
174
|
+
/** @internal Every step is continued through the capture, and the wipe is attached on the success
|
|
175
|
+
* outcome and the failure outcome separately, not through `finally`, which calls the receiver's own
|
|
176
|
+
* `then`. These steps derive the key a PBMAC1 integrity tag is computed under, so a replacement
|
|
177
|
+
* settling one hands back a tag computed
|
|
174
178
|
* under bytes nobody derived, and skips the wipe that keeps the derived key from outliving it. */
|
|
175
179
|
var base = guard.async.chain(subtle.importKey("raw", pwBytes, { name: "PBKDF2" }, false, ["deriveBits"]),
|
|
176
180
|
function (baseKey) {
|
package/lib/pkcs12-build.js
CHANGED
|
@@ -237,7 +237,7 @@ function _buildBag(bag, opts, depth) {
|
|
|
237
237
|
case "shroudedKey": {
|
|
238
238
|
var kDer = _coerceDer(bag.key, "shroudedKey key");
|
|
239
239
|
try { pkcs8.parse(kDer); } catch (e2) { throw _err("pkcs12/bad-input", "shroudedKey key is not a well-formed PKCS#8 PrivateKeyInfo", e2); }
|
|
240
|
-
var enc = bag.encrypt ||
|
|
240
|
+
var enc = bag.encrypt || intrinsic.create(null);
|
|
241
241
|
var bagPbe = _pbeOpts(enc);
|
|
242
242
|
var pw = _pbePasswordOwned(enc.password != null ? enc.password : opts.password);
|
|
243
243
|
var r;
|
|
@@ -552,7 +552,7 @@ function build(spec, opts) {
|
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
async function _build(spec, opts) {
|
|
555
|
-
opts = opts ||
|
|
555
|
+
opts = opts || intrinsic.create(null);
|
|
556
556
|
var form = _specForm(spec);
|
|
557
557
|
if (form.isObject) {
|
|
558
558
|
guard.identifier.assertKnownKeys(spec, form.full ? _BUILD_SPEC_FULL_KEYS : _BUILD_SPEC_SHORTHAND_KEYS,
|
|
@@ -621,7 +621,7 @@ async function _build(spec, opts) {
|
|
|
621
621
|
: "");
|
|
622
622
|
});
|
|
623
623
|
}
|
|
624
|
-
if (opts.mac !== false) _push(pfxChildren,await _buildMacData(opts.mac ||
|
|
624
|
+
if (opts.mac !== false) _push(pfxChildren,await _buildMacData(opts.mac || intrinsic.create(null), opts.password, authSafeDer));
|
|
625
625
|
pfx = b.sequence(pfxChildren);
|
|
626
626
|
}
|
|
627
627
|
|
|
@@ -676,7 +676,7 @@ async function verifyMac(pfx, password, opts) {
|
|
|
676
676
|
}
|
|
677
677
|
|
|
678
678
|
async function _verifyMacOfStore(m, password, opts) {
|
|
679
|
-
opts = opts ||
|
|
679
|
+
opts = opts || intrinsic.create(null);
|
|
680
680
|
if (m.integrityMode !== "password" || !m.mac) throw _err("pkcs12/bad-input", "the store carries no password MAC (integrityMode " + m.integrityMode + ")");
|
|
681
681
|
var expected = m.mac.macValue;
|
|
682
682
|
var computed;
|
|
@@ -767,7 +767,7 @@ function _capWork(iterations, salt, opts, keyLength, hardCap) {
|
|
|
767
767
|
* var keyDer = store.keys[0].pkcs8, certDer = store.certs[0].cert;
|
|
768
768
|
*/
|
|
769
769
|
async function open(pfx, password, opts) {
|
|
770
|
-
opts = opts ||
|
|
770
|
+
opts = opts || intrinsic.create(null);
|
|
771
771
|
guard.identifier.assertKnownKeys(opts, _OPEN_OPTS, _err, "pkcs12/bad-input", "pki.pkcs12.open has an unknown option ");
|
|
772
772
|
/** @internal Every option is taken once, here, and everything below reads the snapshot. A store
|
|
773
773
|
* is opened in many passes, the MAC and then each bag, so an option left on the caller's object is
|
package/lib/scep.js
CHANGED
|
@@ -745,7 +745,7 @@ function _drive(method, url, body, headers, opts, transport, budgets) {
|
|
|
745
745
|
if (proxySnap != null) req.proxy = proxySnap;
|
|
746
746
|
if (curBody != null) req.body = curBody;
|
|
747
747
|
return guard.async.invoked(transport, [req], _err, "scep/bad-input", "opts.transport").then(function (res) {
|
|
748
|
-
res = res ||
|
|
748
|
+
res = res || intrinsic.create(null);
|
|
749
749
|
var blen = _responseLen(res.body);
|
|
750
750
|
if (blen > budgets.maxResponseBytes) throw _err("scep/response-too-large", "the response body (" + blen + " bytes) exceeds the " + budgets.maxResponseBytes + "-byte cap");
|
|
751
751
|
var status = res.status;
|
package/lib/schema-engine.js
CHANGED
|
@@ -169,7 +169,7 @@ function time(ns) {
|
|
|
169
169
|
|
|
170
170
|
function field(name, schema) { return { fkind: "required", name: name, schema: schema }; }
|
|
171
171
|
function optional(name, schema, opts) {
|
|
172
|
-
opts = opts ||
|
|
172
|
+
opts = opts || intrinsic.create(null);
|
|
173
173
|
var match = opts.whenAny
|
|
174
174
|
? function () { return true; }
|
|
175
175
|
: opts.whenUniversal
|
|
@@ -182,51 +182,51 @@ function optional(name, schema, opts) {
|
|
|
182
182
|
defaultCode: opts.defaultCode };
|
|
183
183
|
}
|
|
184
184
|
function trailing(members, opts) {
|
|
185
|
-
opts = opts ||
|
|
185
|
+
opts = opts || intrinsic.create(null);
|
|
186
186
|
return { fkind: "trailing", members: members, minTag: opts.minTag, maxTag: opts.maxTag,
|
|
187
187
|
unexpectedCode: opts.unexpectedCode, orderCode: opts.orderCode };
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
|
|
191
191
|
function seq(fields, opts) {
|
|
192
|
-
opts = opts ||
|
|
192
|
+
opts = opts || intrinsic.create(null);
|
|
193
193
|
return { kind: "seq", fields: fields, assert: opts.assert || "sequence", implicitTag: opts.implicitTag, arity: opts.arity,
|
|
194
194
|
code: opts.code, what: opts.what, build: opts.build, checks: opts.checks || [] };
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
function explicit(tag, schema, opts) {
|
|
198
|
-
opts = opts ||
|
|
198
|
+
opts = opts || intrinsic.create(null);
|
|
199
199
|
return { kind: "explicit", tag: tag, schema: schema, emptyCode: opts.emptyCode, code: opts.code, what: opts.what };
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
function choice(alts, opts) {
|
|
203
|
-
opts = opts ||
|
|
203
|
+
opts = opts || intrinsic.create(null);
|
|
204
204
|
return { kind: "choice", alts: alts, code: opts.code, what: opts.what };
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
function seqOf(item, opts) {
|
|
208
|
-
opts = opts ||
|
|
208
|
+
opts = opts || intrinsic.create(null);
|
|
209
209
|
return { kind: "repeat", item: item, assert: opts.assert || "sequence", code: opts.code, what: opts.what,
|
|
210
210
|
min: opts.min, max: opts.max, maxCode: opts.maxCode,
|
|
211
211
|
unique: opts.unique, dupCode: opts.dupCode, build: opts.build };
|
|
212
212
|
}
|
|
213
213
|
function setOf(item, opts) {
|
|
214
|
-
opts = opts ||
|
|
214
|
+
opts = opts || intrinsic.create(null);
|
|
215
215
|
return { kind: "repeat", item: item, assert: opts.assert || "set", derSetOrder: true, code: opts.code, what: opts.what,
|
|
216
216
|
min: opts.min, max: opts.max, maxCode: opts.maxCode,
|
|
217
217
|
unique: opts.unique, dupCode: opts.dupCode, build: opts.build };
|
|
218
218
|
}
|
|
219
219
|
function setOfUnique(item, keyFn, opts) {
|
|
220
|
-
return setOf(item, Object.assign({ unique: keyFn }, opts ||
|
|
220
|
+
return setOf(item, Object.assign({ unique: keyFn }, opts || intrinsic.create(null)));
|
|
221
221
|
}
|
|
222
222
|
function implicitSetOf(tag, item, opts) {
|
|
223
|
-
opts = opts ||
|
|
223
|
+
opts = opts || intrinsic.create(null);
|
|
224
224
|
return { kind: "repeat", item: item, assert: "implicit", implicitTag: tag, derSetOrder: true, code: opts.code, what: opts.what,
|
|
225
225
|
min: opts.min, max: opts.max, maxCode: opts.maxCode,
|
|
226
226
|
unique: opts.unique, dupCode: opts.dupCode, build: opts.build };
|
|
227
227
|
}
|
|
228
228
|
function implicitSeqOf(tag, item, opts) {
|
|
229
|
-
opts = opts ||
|
|
229
|
+
opts = opts || intrinsic.create(null);
|
|
230
230
|
return { kind: "repeat", item: item, assert: "implicit", implicitTag: tag, code: opts.code, what: opts.what,
|
|
231
231
|
min: opts.min, max: opts.max, maxCode: opts.maxCode,
|
|
232
232
|
unique: opts.unique, dupCode: opts.dupCode, build: opts.build };
|
|
@@ -471,7 +471,7 @@ function _wrapConstructed(schema, parts) {
|
|
|
471
471
|
function _present(v) { return v !== undefined && v !== null; }
|
|
472
472
|
|
|
473
473
|
function _encodeSeq(schema, value, ctx) {
|
|
474
|
-
value = value ||
|
|
474
|
+
value = value || intrinsic.create(null);
|
|
475
475
|
var parts = [];
|
|
476
476
|
for (var f = 0; f < schema.fields.length; f++) {
|
|
477
477
|
var fld = schema.fields[f];
|
|
@@ -578,7 +578,7 @@ function _encodeChoice(schema, value, ctx) {
|
|
|
578
578
|
* { code: "app/bad-der", what: "the embedded structure" });
|
|
579
579
|
*/
|
|
580
580
|
function embeddedDer(schema, bytes, ctx, opts) {
|
|
581
|
-
opts = opts ||
|
|
581
|
+
opts = opts || intrinsic.create(null);
|
|
582
582
|
if (opts.budget) {
|
|
583
583
|
if (!(opts.budget.remaining > 0)) {
|
|
584
584
|
throw ctx.E(opts.budgetCode || opts.code, (opts.what || "embedded DER") +
|