@blamejs/core 0.18.50 → 0.18.53
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 +121 -0
- package/NOTICE +1 -1
- package/README.md +1 -1
- package/lib/ai-input.js +25 -3
- package/lib/db-query.js +32 -4
- package/lib/gate-contract.js +11 -2
- package/lib/guard-filename.js +32 -6
- package/lib/guard-jwt.js +2 -2
- package/lib/guard-yaml.js +157 -21
- package/lib/json-schema.js +130 -13
- package/lib/mail-bimi.js +279 -6
- package/lib/markup-tokenizer.js +88 -0
- package/lib/parsers/safe-yaml.js +24 -3
- package/lib/vendor/MANIFEST.json +12 -12
- package/lib/vendor/blamejs-pki.cjs +835 -41
- package/lib/yaml-lex.js +533 -0
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @blamejs/pki v0.5.
|
|
1
|
+
// @blamejs/pki v0.5.28 — vendored (Apache-2.0). Zero-dep pure CJS.
|
|
2
2
|
// https://github.com/blamejs/pki Exports: x509, crl, pkcs12, key, webcrypto, schema, csr, cms, ...
|
|
3
3
|
// Backs lib/mtls-engine-default.js (PQC-capable CA + PKCS#12 engine).
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -141,7 +141,7 @@ var require_package = __commonJS({
|
|
|
141
141
|
"node_modules/@blamejs/pki/package.json"(exports2, module2) {
|
|
142
142
|
module2.exports = {
|
|
143
143
|
name: "@blamejs/pki",
|
|
144
|
-
version: "0.5.
|
|
144
|
+
version: "0.5.28",
|
|
145
145
|
description: "Pure-JavaScript PKI toolkit that owns its stack \u2014 X.509, ASN.1/DER, CMS, PQC-first.",
|
|
146
146
|
license: "Apache-2.0",
|
|
147
147
|
author: "blamejs contributors",
|
|
@@ -1114,13 +1114,10 @@ var require_guard_identifier = __commonJS({
|
|
|
1114
1114
|
pair(DataView, _DATAVIEW_PROTO_MEMBERS);
|
|
1115
1115
|
pair(Buffer, _BUFFER_PROTO_MEMBERS);
|
|
1116
1116
|
_forEach(_getOwnPropertyNames(globalThis), function(n) {
|
|
1117
|
-
var
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
return;
|
|
1122
|
-
}
|
|
1123
|
-
if (typeof C !== "function" || typeof C.BYTES_PER_ELEMENT !== "number") return;
|
|
1117
|
+
var d = _getOwnPropertyDescriptor(globalThis, n);
|
|
1118
|
+
if (!d || typeof d.value !== "function") return;
|
|
1119
|
+
var C = d.value;
|
|
1120
|
+
if (typeof C.BYTES_PER_ELEMENT !== "number") return;
|
|
1124
1121
|
if (!C.prototype || _getPrototypeOf(C.prototype) !== _TYPED_ARRAY_PROTO) return;
|
|
1125
1122
|
_mapSet(m, C.prototype, _CONCRETE_TYPED_MEMBERS);
|
|
1126
1123
|
});
|
|
@@ -1236,6 +1233,16 @@ var require_guard_identifier = __commonJS({
|
|
|
1236
1233
|
if (util.types.isArgumentsObject(v)) return "an arguments object";
|
|
1237
1234
|
return null;
|
|
1238
1235
|
}
|
|
1236
|
+
function _isBuiltinExotic(v) {
|
|
1237
|
+
var t = util.types;
|
|
1238
|
+
return t.isDate(v) || t.isMap(v) || t.isSet(v) || t.isWeakMap(v) || t.isWeakSet(v) || t.isRegExp(v) || t.isPromise(v) || t.isArrayBuffer(v) || t.isSharedArrayBuffer(v) || t.isArrayBufferView(v) || t.isBoxedPrimitive(v) || t.isNativeError(v) || t.isArgumentsObject(v) || t.isGeneratorObject(v);
|
|
1239
|
+
}
|
|
1240
|
+
function assertPlainRecord(v, E, code, label) {
|
|
1241
|
+
_requireFactory(E);
|
|
1242
|
+
if (v === null || typeof v !== "object" || _isNodeBuffer(v) || _isArray(v)) throw E(code, label + " must be a plain object");
|
|
1243
|
+
_refuseUnenumerable(v, E, code, label);
|
|
1244
|
+
if (_isBuiltinExotic(v)) throw E(code, label + " must be a plain object (a built-in exotic such as a Date or Map is refused)");
|
|
1245
|
+
}
|
|
1239
1246
|
function optionsObject(opts, E, code, label) {
|
|
1240
1247
|
if (opts === null || opts === void 0) return _create(null);
|
|
1241
1248
|
if (typeof opts !== "object") throw E(code, label + " must be an object");
|
|
@@ -1286,6 +1293,7 @@ var require_guard_identifier = __commonJS({
|
|
|
1286
1293
|
module2.exports = intrinsic.freeze({
|
|
1287
1294
|
assertCanonicalOid,
|
|
1288
1295
|
assertKnownKeys,
|
|
1296
|
+
assertPlainRecord,
|
|
1289
1297
|
optionsObject,
|
|
1290
1298
|
refuseAccessorFields,
|
|
1291
1299
|
// Exported so a caller that forwards an options bag copies the same surface this module
|
|
@@ -1614,13 +1622,18 @@ var require_oid = __commonJS({
|
|
|
1614
1622
|
// id-pkip arc (id-pkix 5). id-regCtrl (id-pkip 1) names the control types a
|
|
1615
1623
|
// CertRequest carries; id-regInfo (id-pkip 2) names the registration-info types.
|
|
1616
1624
|
// The parser surfaces each control/info value raw, keyed by these names.
|
|
1625
|
+
// altCertTemplate (7) and the two keySpec controls algId (11) / rsaKeyLen (12) are the RFC 9480
|
|
1626
|
+
// sec. 2.16 additions; a CertReqTemplate response states its key requirements with the latter two.
|
|
1617
1627
|
regCtrl: { base: [1, 3, 6, 1, 5, 5, 7, 5, 1], of: {
|
|
1618
1628
|
regToken: 1,
|
|
1619
1629
|
authenticator: 2,
|
|
1620
1630
|
pkiPublicationInfo: 3,
|
|
1621
1631
|
pkiArchiveOptions: 4,
|
|
1622
1632
|
oldCertID: 5,
|
|
1623
|
-
protocolEncrKey: 6
|
|
1633
|
+
protocolEncrKey: 6,
|
|
1634
|
+
altCertTemplate: 7,
|
|
1635
|
+
algId: 11,
|
|
1636
|
+
rsaKeyLen: 12
|
|
1624
1637
|
} },
|
|
1625
1638
|
regInfo: { base: [1, 3, 6, 1, 5, 5, 7, 5, 2], of: { utf8Pairs: 1, certReq: 2 } },
|
|
1626
1639
|
// PKIX extended key purposes (id-kp, RFC 5280 sec. 4.2.1.12). timeStamping is required,
|
|
@@ -1840,6 +1853,10 @@ var require_oid = __commonJS({
|
|
|
1840
1853
|
// SignerInfo carries a MAC-based proof instead. Registered so a decoder can
|
|
1841
1854
|
// name it and refuse it deliberately.
|
|
1842
1855
|
"id-alg-noSignature": 2,
|
|
1856
|
+
// RSASSA-PSS with SHAKE (RFC 8692): RSA signature algorithms on the PKIX arc.
|
|
1857
|
+
// Registered so a consumer can name them -- e.g. the CMP keySpec RSA exclusion.
|
|
1858
|
+
"id-RSASSA-PSS-SHAKE128": 30,
|
|
1859
|
+
"id-RSASSA-PSS-SHAKE256": 31,
|
|
1843
1860
|
"id-alg-xmss-hashsig": 34,
|
|
1844
1861
|
"id-alg-xmssmt-hashsig": 35,
|
|
1845
1862
|
// Composite ML-DSA signature algorithms (draft-ietf-lamps-pq-composite-sigs
|
|
@@ -1916,7 +1933,57 @@ var require_oid = __commonJS({
|
|
|
1916
1933
|
edwards: { base: [1, 3, 101], of: { X25519: 110, X448: 111, Ed25519: 112, Ed448: 113 } },
|
|
1917
1934
|
// OIW Secsig SHA-1 (1.3.14.3.2.26) -- the most common OCSP CertID hashAlgorithm;
|
|
1918
1935
|
// nistHash covers only SHA-256 and above.
|
|
1919
|
-
|
|
1936
|
+
// OIW Secsig arc (1.3.14.3.2). id-SHA1 (.26) plus every RSA identifier the OIW SIG assigned under the
|
|
1937
|
+
// arc: md4WithRSA (.2), md5WithRSA (.3), md4WithRSAEncryption (.4), rsaSignature (.11, the ISO 9796 RSA
|
|
1938
|
+
// scheme), mdc2WithRSASignature (.14), shaWithRSAEncryption (.15), rsaKeyTransport (.22), and the
|
|
1939
|
+
// md2/md5/sha1-WithRSASignature set (.24/.25/.29) -- pre-PKCS#1 RSA algorithms still seen in old certs.
|
|
1940
|
+
// This is the arc's complete RSA membership per the OIW SIG assignments. Registered so a consumer can
|
|
1941
|
+
// name them -- e.g. the CMP keySpec RSA exclusion, which recognizes RSA wherever it is standardized.
|
|
1942
|
+
// The arc is shared with DES, DSA, DH, and the hashes, so no prefix isolates RSA; each is named.
|
|
1943
|
+
oiwSecsig: { base: [1, 3, 14, 3, 2], of: {
|
|
1944
|
+
sha1: 26,
|
|
1945
|
+
"md4WithRSA": 2,
|
|
1946
|
+
"md5WithRSA": 3,
|
|
1947
|
+
"md4WithRSAEncryption": 4,
|
|
1948
|
+
"rsaSignature": 11,
|
|
1949
|
+
"mdc2WithRSASignature": 14,
|
|
1950
|
+
"shaWithRSAEncryption": 15,
|
|
1951
|
+
"rsaKeyTransport": 22,
|
|
1952
|
+
"md2WithRSASignature": 24,
|
|
1953
|
+
"md5WithRSASignature": 25,
|
|
1954
|
+
"sha1WithRSASignature": 29
|
|
1955
|
+
} },
|
|
1956
|
+
// TeleTrusT (BSI) RSA signature arc (1.3.36.3.3.1) -- RSA signatures with SHA-1 and the RIPEMD family.
|
|
1957
|
+
// The arc is RSA-dedicated, so a consumer can classify the whole family by its prefix; one member is
|
|
1958
|
+
// registered here so that prefix can be derived from the registry rather than a dotted-decimal literal.
|
|
1959
|
+
teletrustRsaSig: { base: [1, 3, 36, 3, 3, 1], of: { "rsaSignatureWithripemd160": 2 } },
|
|
1960
|
+
// X.509 directory encryptionAlgorithm arc (2.5.8.1). id-ea-rsa (.1) is the X.509 `rsa` public-key
|
|
1961
|
+
// identifier, distinct from PKCS#1 rsaEncryption. Registered so a consumer can name it -- e.g. the
|
|
1962
|
+
// CMP keySpec RSA exclusion, which must recognize RSA wherever it is standardized.
|
|
1963
|
+
x509EncAlg: { base: [2, 5, 8, 1], of: { "rsa": 1 } },
|
|
1964
|
+
// X.500 directory signatureAlgorithm arc (2.5.8.3). Its RSA members are sqMod-nWithRSA (.1, the
|
|
1965
|
+
// ITU-T X.509 / ISO 9594-8 square-mod-n-with-RSA signature) and mdc2WithRSA (.100, MDC-2-with-RSA).
|
|
1966
|
+
// Registered so the CMP keySpec RSA exclusion can name them; the arc is not RSA-dedicated, so each
|
|
1967
|
+
// member is named individually rather than prefix-matched.
|
|
1968
|
+
x509SigAlg: { base: [2, 5, 8, 3], of: { "sqMod-nWithRSA": 1, "mdc2WithRSA": 100 } },
|
|
1969
|
+
// Chinese GM/T (SCA) SM algorithm arc (1.2.156.10197.1). Its one RSA member is sm3WithRSAEncryption
|
|
1970
|
+
// (.504, a PKCS#1 v1.5 RSA signature over an SM3 digest); sm2 (.301), sm3 (.401), and SM2-with-SM3
|
|
1971
|
+
// (.501) on the arc are not RSA. Registered so the CMP keySpec RSA exclusion can name it -- the arc is
|
|
1972
|
+
// mixed, so the RSA member is named individually rather than prefix-matched.
|
|
1973
|
+
smAlg: { base: [1, 2, 156, 10197, 1], of: { "sm3WithRSAEncryption": 504 } },
|
|
1974
|
+
// BSI TR-03110 EAC Terminal Authentication RSA arc (0.4.0.127.0.7.2.2.2.1, id-TA-RSA). Every child is an
|
|
1975
|
+
// RSA signature scheme -- PKCS#1 v1.5 or PSS over SHA-1/256/512 -- and the sibling id-TA-ECDSA arc
|
|
1976
|
+
// (0.4.0.127.0.7.2.2.2.2) is EC, so this arc is RSA-dedicated. The members are registered so a consumer
|
|
1977
|
+
// can derive the arc prefix from the registry rather than a dotted-decimal literal and classify the
|
|
1978
|
+
// whole family, including a variant BSI adds later, by that prefix.
|
|
1979
|
+
bsiTaRsa: { base: [0, 4, 0, 127, 0, 7, 2, 2, 2, 1], of: {
|
|
1980
|
+
"id-TA-RSA-v1-5-SHA-1": 1,
|
|
1981
|
+
"id-TA-RSA-v1-5-SHA-256": 2,
|
|
1982
|
+
"id-TA-RSA-PSS-SHA-1": 3,
|
|
1983
|
+
"id-TA-RSA-PSS-SHA-256": 4,
|
|
1984
|
+
"id-TA-RSA-v1-5-SHA-512": 5,
|
|
1985
|
+
"id-TA-RSA-PSS-SHA-512": 6
|
|
1986
|
+
} },
|
|
1920
1987
|
// NIST AES content-encryption algorithms (arc 2.16.840.1.101.3.4.1) -- the
|
|
1921
1988
|
// modern PBES2 / CMS content ciphers a PKCS#12 or EnvelopedData names.
|
|
1922
1989
|
nistAes: { base: [2, 16, 840, 1, 101, 3, 4, 1], of: {
|
|
@@ -1949,6 +2016,13 @@ var require_oid = __commonJS({
|
|
|
1949
2016
|
// sets .35-.46, each pairing a parameter set with its message-digest hash. The
|
|
1950
2017
|
// parameters MUST be absent for every one of them (enforced via paramsMustBeAbsent).
|
|
1951
2018
|
nistSig: { base: [2, 16, 840, 1, 101, 3, 4, 3], of: {
|
|
2019
|
+
// RSASSA-PKCS1-v1_5 with SHA-3 (NIST CSOR): RSA signature algorithms on the NIST
|
|
2020
|
+
// signature arc, alongside the ML-DSA / SLH-DSA sets. Registered so a consumer can
|
|
2021
|
+
// name them -- e.g. the CMP keySpec check that must recognize RSA to exclude it.
|
|
2022
|
+
"id-rsassa-pkcs1-v1_5-with-sha3-224": 13,
|
|
2023
|
+
"id-rsassa-pkcs1-v1_5-with-sha3-256": 14,
|
|
2024
|
+
"id-rsassa-pkcs1-v1_5-with-sha3-384": 15,
|
|
2025
|
+
"id-rsassa-pkcs1-v1_5-with-sha3-512": 16,
|
|
1952
2026
|
"id-ml-dsa-44": 17,
|
|
1953
2027
|
"id-ml-dsa-65": 18,
|
|
1954
2028
|
"id-ml-dsa-87": 19,
|
|
@@ -2363,7 +2437,13 @@ var require_webcrypto = __commonJS({
|
|
|
2363
2437
|
function CryptoKey(type, extractable, algorithm, usages, handle) {
|
|
2364
2438
|
this.type = type;
|
|
2365
2439
|
this.extractable = !!extractable;
|
|
2366
|
-
|
|
2440
|
+
var frozenAlg = algorithm;
|
|
2441
|
+
if (frozenAlg && typeof frozenAlg === "object") {
|
|
2442
|
+
frozenAlg = _assign({}, algorithm);
|
|
2443
|
+
if (frozenAlg.hash && typeof frozenAlg.hash === "object") frozenAlg.hash = intrinsic.freeze(_assign({}, frozenAlg.hash));
|
|
2444
|
+
frozenAlg = intrinsic.freeze(frozenAlg);
|
|
2445
|
+
}
|
|
2446
|
+
_defineProperty(this, "algorithm", { value: frozenAlg, enumerable: true });
|
|
2367
2447
|
if (usages != null && !_isArray(usages)) {
|
|
2368
2448
|
throw new WebCryptoError("webcrypto/syntax", "usages must be an array of key-usage strings");
|
|
2369
2449
|
}
|
|
@@ -4196,6 +4276,9 @@ var require_guard_name = __commonJS({
|
|
|
4196
4276
|
var _fromCharCode = String.fromCharCode;
|
|
4197
4277
|
var _String = String;
|
|
4198
4278
|
var _isArray = Array.isArray;
|
|
4279
|
+
var _isBuffer = intrinsic.isBuffer;
|
|
4280
|
+
var _bufferEquals = intrinsic.bufferEquals;
|
|
4281
|
+
var _getOwnPropertyDescriptor = intrinsic.getOwnPropertyDescriptor;
|
|
4199
4282
|
function assertNoControlBytes(str, E, code, label) {
|
|
4200
4283
|
for (var i = 0; i < str.length; i++) {
|
|
4201
4284
|
var c = _charCodeAt(str, i);
|
|
@@ -4272,6 +4355,47 @@ var require_guard_name = __commonJS({
|
|
|
4272
4355
|
}
|
|
4273
4356
|
return true;
|
|
4274
4357
|
}
|
|
4358
|
+
function dpnCorresponds(a, b, E, code, label) {
|
|
4359
|
+
var x = _reduceDpn(a, E, code, label), y = _reduceDpn(b, E, code, label);
|
|
4360
|
+
if (x.kind !== y.kind) return false;
|
|
4361
|
+
if (x.kind === "rdn") return _bufferEquals(x.bytes, y.bytes);
|
|
4362
|
+
for (var i = 0; i < x.names.length; i++) {
|
|
4363
|
+
for (var j = 0; j < y.names.length; j++) {
|
|
4364
|
+
if (_bufferEquals(x.names[i], y.names[j])) return true;
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
return false;
|
|
4368
|
+
}
|
|
4369
|
+
function _reduceDpn(d, E, code, label) {
|
|
4370
|
+
function refuse(why) {
|
|
4371
|
+
return E(code, "cannot compare " + label + ": " + why);
|
|
4372
|
+
}
|
|
4373
|
+
function ownValue(o, k) {
|
|
4374
|
+
var desc = _getOwnPropertyDescriptor(o, k);
|
|
4375
|
+
if (!desc || !_hasOwn(desc, "value")) throw refuse("a distribution-point comparison requires " + k + " to be the comparand's own value (RFC 5280 sec. 6.3.3 compares decoded names)");
|
|
4376
|
+
return desc.value;
|
|
4377
|
+
}
|
|
4378
|
+
if (!d || typeof d !== "object") {
|
|
4379
|
+
throw refuse("a distribution-point comparison requires the decoded DistributionPointName on both sides (kind fullName or rdn)");
|
|
4380
|
+
}
|
|
4381
|
+
var kind = ownValue(d, "kind");
|
|
4382
|
+
if (kind !== "fullName" && kind !== "rdn") throw refuse("a DistributionPointName is fullName or nameRelativeToCRLIssuer, and this is neither");
|
|
4383
|
+
if (kind === "rdn") {
|
|
4384
|
+
var bytes = ownValue(d, "bytes");
|
|
4385
|
+
if (!_isBuffer(bytes)) throw refuse("a nameRelativeToCRLIssuer distribution point must carry its encoded bytes");
|
|
4386
|
+
return { kind, bytes };
|
|
4387
|
+
}
|
|
4388
|
+
var names = ownValue(d, "names");
|
|
4389
|
+
if (!_isArray(names)) throw refuse("a fullName distribution point must carry a sequence of encoded GeneralNames");
|
|
4390
|
+
var len = names.length;
|
|
4391
|
+
var taken = [];
|
|
4392
|
+
for (var i = 0; i < len; i++) {
|
|
4393
|
+
var n = ownValue(names, i);
|
|
4394
|
+
if (!_isBuffer(n)) throw refuse("every fullName GeneralName must be its encoded bytes");
|
|
4395
|
+
taken[i] = n;
|
|
4396
|
+
}
|
|
4397
|
+
return { kind, names: taken };
|
|
4398
|
+
}
|
|
4275
4399
|
function escapeControlBytes(str) {
|
|
4276
4400
|
var s = _String(str), out = "";
|
|
4277
4401
|
for (var i = 0; i < s.length; i++) {
|
|
@@ -4322,6 +4446,7 @@ var require_guard_name = __commonJS({
|
|
|
4322
4446
|
dnEqual,
|
|
4323
4447
|
rdnEqual,
|
|
4324
4448
|
emailEqual,
|
|
4449
|
+
dpnCorresponds,
|
|
4325
4450
|
escapeControlBytes,
|
|
4326
4451
|
escapeDnValue,
|
|
4327
4452
|
lowerAscii
|
|
@@ -15631,6 +15756,88 @@ var require_schema_cmp = __commonJS({
|
|
|
15631
15756
|
};
|
|
15632
15757
|
}
|
|
15633
15758
|
});
|
|
15759
|
+
var CA_CERTS_VALUE = schema.seqOf(rawSequence("cmp/bad-info-value"), {
|
|
15760
|
+
min: 1,
|
|
15761
|
+
code: "cmp/bad-info-value",
|
|
15762
|
+
what: "CACertsValue",
|
|
15763
|
+
build: function(m) {
|
|
15764
|
+
return m.items.map(function(it) {
|
|
15765
|
+
return it.value;
|
|
15766
|
+
});
|
|
15767
|
+
}
|
|
15768
|
+
});
|
|
15769
|
+
var ROOT_CA_KEY_UPDATE = schema.seq([
|
|
15770
|
+
schema.field("newWithNew", rawSequence("cmp/bad-info-value")),
|
|
15771
|
+
schema.trailing([
|
|
15772
|
+
{ tag: 0, name: "newWithOld", schema: rawSequence("cmp/bad-info-value"), explicit: true, emptyCode: "cmp/bad-info-value" },
|
|
15773
|
+
{ tag: 1, name: "oldWithNew", schema: rawSequence("cmp/bad-info-value"), explicit: true, emptyCode: "cmp/bad-info-value" }
|
|
15774
|
+
], { minTag: 0, maxTag: 1, unexpectedCode: "cmp/bad-info-value", orderCode: "cmp/bad-info-value" })
|
|
15775
|
+
], {
|
|
15776
|
+
assert: "sequence",
|
|
15777
|
+
code: "cmp/bad-info-value",
|
|
15778
|
+
what: "RootCaKeyUpdateContent",
|
|
15779
|
+
build: function(m) {
|
|
15780
|
+
return {
|
|
15781
|
+
newWithNew: m.fields.newWithNew.value,
|
|
15782
|
+
newWithOld: m.fields.newWithOld.present ? m.fields.newWithOld.value : null,
|
|
15783
|
+
oldWithNew: m.fields.oldWithNew.present ? m.fields.oldWithNew.value : null
|
|
15784
|
+
};
|
|
15785
|
+
}
|
|
15786
|
+
});
|
|
15787
|
+
var ATTR_TYPE_AND_VALUE = schema.seq([
|
|
15788
|
+
schema.field("type", schema.oidLeaf()),
|
|
15789
|
+
schema.field("value", schema.any())
|
|
15790
|
+
], {
|
|
15791
|
+
assert: "sequence",
|
|
15792
|
+
code: "cmp/bad-info-value",
|
|
15793
|
+
what: "AttributeTypeAndValue",
|
|
15794
|
+
build: function(m, ctx) {
|
|
15795
|
+
var t = m.fields.type.value;
|
|
15796
|
+
return { type: t, name: ctx.oid.name(t) || null, value: m.fields.value.value.bytes };
|
|
15797
|
+
}
|
|
15798
|
+
});
|
|
15799
|
+
var CERT_REQ_TEMPLATE_VALUE = schema.seq([
|
|
15800
|
+
schema.field("certTemplate", CERT_TEMPLATE_LEAF),
|
|
15801
|
+
schema.optional("keySpec", schema.seqOf(ATTR_TYPE_AND_VALUE, {
|
|
15802
|
+
min: 1,
|
|
15803
|
+
code: "cmp/bad-info-value",
|
|
15804
|
+
what: "CertReqTemplate keySpec",
|
|
15805
|
+
build: function(m) {
|
|
15806
|
+
return m.items.map(function(it) {
|
|
15807
|
+
return it.value.result;
|
|
15808
|
+
});
|
|
15809
|
+
}
|
|
15810
|
+
}), { whenUniversal: [TAGS.SEQUENCE] })
|
|
15811
|
+
], {
|
|
15812
|
+
assert: "sequence",
|
|
15813
|
+
code: "cmp/bad-info-value",
|
|
15814
|
+
what: "CertReqTemplateValue",
|
|
15815
|
+
build: function(m) {
|
|
15816
|
+
return {
|
|
15817
|
+
certTemplate: m.fields.certTemplate.value,
|
|
15818
|
+
keySpec: m.fields.keySpec.present ? m.fields.keySpec.value.result : null
|
|
15819
|
+
};
|
|
15820
|
+
}
|
|
15821
|
+
});
|
|
15822
|
+
var CRLS_VALUE = schema.seqOf(rawSequence("cmp/bad-info-value"), {
|
|
15823
|
+
min: 1,
|
|
15824
|
+
code: "cmp/bad-info-value",
|
|
15825
|
+
what: "CRLsValue",
|
|
15826
|
+
build: function(m) {
|
|
15827
|
+
return m.items.map(function(it) {
|
|
15828
|
+
return it.value;
|
|
15829
|
+
});
|
|
15830
|
+
}
|
|
15831
|
+
});
|
|
15832
|
+
function _valueParser(what, topSchema) {
|
|
15833
|
+
return pkix.makeParser({ pemLabel: "CMP", PemError, ErrorClass: CmpError, prefix: "cmp", what, topSchema, ns: NS });
|
|
15834
|
+
}
|
|
15835
|
+
var readCaCerts = _valueParser("CACertsValue", CA_CERTS_VALUE);
|
|
15836
|
+
var readRootCaKeyUpdate = _valueParser("RootCaKeyUpdateContent", ROOT_CA_KEY_UPDATE);
|
|
15837
|
+
var readCertReqTemplate = _valueParser("CertReqTemplateValue", CERT_REQ_TEMPLATE_VALUE);
|
|
15838
|
+
var readCrls = _valueParser("CRLsValue", CRLS_VALUE);
|
|
15839
|
+
var readAlgorithmIdentifier = _valueParser("AlgorithmIdentifier", ALG_ID);
|
|
15840
|
+
var readName = _valueParser("Name", pkix.name(NS));
|
|
15634
15841
|
var parse = pkix.makeParser({
|
|
15635
15842
|
pemLabel: "CMP",
|
|
15636
15843
|
PemError,
|
|
@@ -15660,7 +15867,14 @@ var require_schema_cmp = __commonJS({
|
|
|
15660
15867
|
parse,
|
|
15661
15868
|
pemDecode,
|
|
15662
15869
|
pemEncode,
|
|
15663
|
-
matches
|
|
15870
|
+
matches,
|
|
15871
|
+
// @internal -- the RFC 9483 sec. 4.3 support-message values, read strictly from a genp.
|
|
15872
|
+
readCaCerts,
|
|
15873
|
+
readRootCaKeyUpdate,
|
|
15874
|
+
readCertReqTemplate,
|
|
15875
|
+
readCrls,
|
|
15876
|
+
readAlgorithmIdentifier,
|
|
15877
|
+
readName
|
|
15664
15878
|
};
|
|
15665
15879
|
}
|
|
15666
15880
|
});
|
|
@@ -20332,12 +20546,23 @@ var require_cmp_build = __commonJS({
|
|
|
20332
20546
|
"node_modules/@blamejs/pki/lib/cmp-build.js"(exports2, module2) {
|
|
20333
20547
|
"use strict";
|
|
20334
20548
|
var asn1 = require_asn1_der();
|
|
20549
|
+
var schema = require_schema_engine();
|
|
20335
20550
|
var oid = require_oid();
|
|
20336
20551
|
var cmp = require_schema_cmp();
|
|
20337
20552
|
var crmf = require_crmf_sign();
|
|
20338
20553
|
var schemaCrmf = require_schema_crmf();
|
|
20339
20554
|
var intrinsic = require_guard_intrinsic();
|
|
20340
20555
|
var _hasOwn = intrinsic.hasOwn;
|
|
20556
|
+
var _isArray = intrinsic.isArray;
|
|
20557
|
+
var _isBuffer = intrinsic.isBuffer;
|
|
20558
|
+
var _bufferConcat = intrinsic.bufferConcat;
|
|
20559
|
+
var _map = intrinsic.map;
|
|
20560
|
+
var _keys = intrinsic.keys;
|
|
20561
|
+
var _forEach = intrinsic.forEach;
|
|
20562
|
+
var _push = intrinsic.push;
|
|
20563
|
+
var _stringify = intrinsic.stringify;
|
|
20564
|
+
var _bigInt = intrinsic.BigInt;
|
|
20565
|
+
var _Date = intrinsic.Date;
|
|
20341
20566
|
var csr = require_schema_csr();
|
|
20342
20567
|
var crl = require_schema_crl();
|
|
20343
20568
|
var x509 = require_schema_x509();
|
|
@@ -20597,18 +20822,91 @@ var require_cmp_build = __commonJS({
|
|
|
20597
20822
|
}
|
|
20598
20823
|
function _encodeRevDetails(rd) {
|
|
20599
20824
|
if (!rd || typeof rd !== "object" || Buffer.isBuffer(rd)) throw _err("cmp/bad-rev-req", "each RevDetails must be an object { certDetails, crlEntryDetails? }");
|
|
20825
|
+
guard.identifier.assertKnownKeys(rd, KNOWN_REV_DETAILS_KEYS, _err, "cmp/bad-rev-req", "unknown RevDetails field ");
|
|
20600
20826
|
if (rd.certDetails == null) throw _err("cmp/bad-rev-req", "RevDetails.certDetails (a CertTemplate) is required");
|
|
20601
20827
|
var certDetails;
|
|
20602
|
-
if (
|
|
20603
|
-
certDetails = b.raw(
|
|
20828
|
+
if (guard.bytes.isByteSource(rd.certDetails)) {
|
|
20829
|
+
certDetails = b.raw(guard.bytes.snapshotSource(rd.certDetails, CmpError, "cmp/bad-rev-req", "RevDetails.certDetails (a pre-encoded CertTemplate DER)"));
|
|
20604
20830
|
} else {
|
|
20605
20831
|
if (rd.certDetails.issuer == null || rd.certDetails.serialNumber == null) throw _err("cmp/bad-rev-req", "a revocation certDetails must identify the certificate by issuer and serialNumber");
|
|
20606
20832
|
certDetails = b.raw(crmf.buildCertTemplate(rd.certDetails));
|
|
20607
20833
|
}
|
|
20608
20834
|
var children = [certDetails];
|
|
20609
|
-
if (rd.crlEntryDetails != null) children.push(b.raw(
|
|
20835
|
+
if (rd.crlEntryDetails != null) children.push(b.raw(_encodeCrlEntryDetails(rd.crlEntryDetails)));
|
|
20610
20836
|
return b.sequence(children);
|
|
20611
20837
|
}
|
|
20838
|
+
var KNOWN_REV_DETAILS_KEYS = { certDetails: 1, crlEntryDetails: 1 };
|
|
20839
|
+
var KNOWN_CRL_ENTRY_DETAIL_KEYS = { reason: 1 };
|
|
20840
|
+
var CRL_REASON_BY_NAME = intrinsic.create(null);
|
|
20841
|
+
_forEach(_keys(constants.NAMES.CRL_REASON), function(v) {
|
|
20842
|
+
CRL_REASON_BY_NAME[constants.NAMES.CRL_REASON[v]] = intrinsic.Number(v);
|
|
20843
|
+
});
|
|
20844
|
+
function _encodeCrlEntryDetails(spec) {
|
|
20845
|
+
if (guard.bytes.isByteSource(spec)) return guard.bytes.snapshotSource(spec, CmpError, "cmp/bad-rev-req", "RevDetails.crlEntryDetails (a pre-encoded Extensions DER)");
|
|
20846
|
+
guard.identifier.assertPlainRecord(spec, _err, "cmp/bad-rev-req", "RevDetails.crlEntryDetails ({ reason } or a pre-encoded Extensions DER)");
|
|
20847
|
+
guard.identifier.assertKnownKeys(spec, KNOWN_CRL_ENTRY_DETAIL_KEYS, _err, "cmp/bad-rev-req", "unknown crlEntryDetails field ");
|
|
20848
|
+
var reason = spec.reason;
|
|
20849
|
+
if (reason != null && (typeof reason !== "string" || !_hasOwn(CRL_REASON_BY_NAME, reason))) {
|
|
20850
|
+
throw _err("cmp/bad-rev-req", "unknown CRLReason " + _stringify(reason) + " (RFC 5280 sec. 5.3.1)");
|
|
20851
|
+
}
|
|
20852
|
+
var code = reason == null ? 0 : CRL_REASON_BY_NAME[reason];
|
|
20853
|
+
return b.sequence([_b.ext(O("reasonCode"), false, b.enumerated(_bigInt(code)))]);
|
|
20854
|
+
}
|
|
20855
|
+
var KNOWN_CRL_STATUS_KEYS = { dpn: 1, issuer: 1, thisUpdate: 1 };
|
|
20856
|
+
var KNOWN_DPN_KEYS = { fullName: 1 };
|
|
20857
|
+
function buildCrlStatusList(spec) {
|
|
20858
|
+
if (!spec || typeof spec !== "object" || _isBuffer(spec)) throw _err("cmp/bad-input", "a crlUpdate request must be an object { dpn | issuer, thisUpdate? }");
|
|
20859
|
+
guard.identifier.assertKnownKeys(spec, KNOWN_CRL_STATUS_KEYS, _err, "cmp/bad-input", "unknown crlUpdate field ");
|
|
20860
|
+
var dpnSpec = spec.dpn, issuerSpec = spec.issuer;
|
|
20861
|
+
if (dpnSpec == null && issuerSpec == null) {
|
|
20862
|
+
throw _err("cmp/bad-input", "a crlUpdate identifies the requested CRL by a dpn (a distribution point name), an issuer (the CA that issues it), or both (RFC 9483 sec. 4.3.4)");
|
|
20863
|
+
}
|
|
20864
|
+
if (dpnSpec != null && issuerSpec == null) {
|
|
20865
|
+
throw _err("cmp/bad-input", "a crlUpdate naming a dpn must also name the issuer whose CRL is acceptable: a distribution point name alone leaves the response unbound, since a complete CRL states no scope to compare it against (RFC 9483 sec. 4.3.4, RFC 5280 sec. 5.2.5). Drive an unbound request with pki.cmp.build + pki.cmp.transfer.");
|
|
20866
|
+
}
|
|
20867
|
+
var source, issuerNameDer = null, dpnNames = null;
|
|
20868
|
+
if (issuerSpec != null) issuerNameDer = _b.encodeName(issuerSpec);
|
|
20869
|
+
if (dpnSpec != null) {
|
|
20870
|
+
if (typeof dpnSpec !== "object" || _isBuffer(dpnSpec)) throw _err("cmp/bad-input", "crlUpdate.dpn must be { fullName: [<GeneralName>...] }");
|
|
20871
|
+
guard.identifier.assertKnownKeys(dpnSpec, KNOWN_DPN_KEYS, _err, "cmp/bad-input", "unknown crlUpdate.dpn field ");
|
|
20872
|
+
var fullName = dpnSpec.fullName;
|
|
20873
|
+
if (fullName == null) throw _err("cmp/bad-input", "crlUpdate.dpn requires fullName (the nameRelativeToCRLIssuer arm is not built; pki.crl.sign draws the same line for issuingDistributionPoint)");
|
|
20874
|
+
var entries = _isArray(fullName) ? fullName : [fullName];
|
|
20875
|
+
if (!entries.length) throw _err("cmp/bad-input", "crlUpdate.dpn.fullName must carry at least one GeneralName");
|
|
20876
|
+
dpnNames = _map(entries, function(e) {
|
|
20877
|
+
return _b.encodeGeneralName(e);
|
|
20878
|
+
});
|
|
20879
|
+
source = b.explicit(0, b.contextConstructed(0, _bufferConcat(dpnNames)));
|
|
20880
|
+
} else {
|
|
20881
|
+
source = b.explicit(1, b.sequence([b.explicit(4, b.raw(issuerNameDer))]));
|
|
20882
|
+
}
|
|
20883
|
+
var status = [source], askedInstant = null, asked = spec.thisUpdate;
|
|
20884
|
+
if (asked != null) {
|
|
20885
|
+
askedInstant = guard.time.instantOf(asked, _err, "cmp/bad-input", "crlUpdate.thisUpdate");
|
|
20886
|
+
_push(status, b.raw(_b.timeDer(new _Date(askedInstant), "crlUpdate.thisUpdate")));
|
|
20887
|
+
}
|
|
20888
|
+
return {
|
|
20889
|
+
der: b.sequence([b.sequence(status)]),
|
|
20890
|
+
issuerName: issuerNameDer,
|
|
20891
|
+
thisUpdate: askedInstant,
|
|
20892
|
+
dpn: dpnNames === null ? null : { kind: "fullName", names: dpnNames }
|
|
20893
|
+
};
|
|
20894
|
+
}
|
|
20895
|
+
var IDP_SCHEMA = pkix.issuingDistributionPoint("cmp/bad-info-value");
|
|
20896
|
+
function decodeIdpDistributionPoint(valueBytes) {
|
|
20897
|
+
var m;
|
|
20898
|
+
try {
|
|
20899
|
+
m = schema.walk(IDP_SCHEMA, asn1.decode(valueBytes), NS);
|
|
20900
|
+
} catch (e) {
|
|
20901
|
+
throw _err("cmp/bad-info-value", "the returned CRL carries a malformed issuingDistributionPoint extension (RFC 5280 sec. 5.2.5)", e);
|
|
20902
|
+
}
|
|
20903
|
+
if (!m.fields.distributionPoint.present) return null;
|
|
20904
|
+
var wrap = m.fields.distributionPoint.node;
|
|
20905
|
+
if (!wrap.children || wrap.children.length !== 1) {
|
|
20906
|
+
throw _err("cmp/bad-info-value", "an issuingDistributionPoint distributionPoint [0] must wrap exactly one DistributionPointName (RFC 5280 sec. 5.2.5)");
|
|
20907
|
+
}
|
|
20908
|
+
return pkix.distributionPointName(NS, wrap.children[0], "cmp/bad-info-value");
|
|
20909
|
+
}
|
|
20612
20910
|
function _encodeRevReqContent(list) {
|
|
20613
20911
|
if (!Array.isArray(list) || !list.length) throw _err("cmp/bad-rev-req", "rr must be a non-empty array of RevDetails");
|
|
20614
20912
|
return b.sequence(list.map(_encodeRevDetails));
|
|
@@ -20864,7 +21162,7 @@ var require_cmp_build = __commonJS({
|
|
|
20864
21162
|
if (!Buffer.isBuffer(secret) || !secret.length) throw _err("cmp/bad-input", "opts.mac.secret must be a non-empty string or Buffer");
|
|
20865
21163
|
}
|
|
20866
21164
|
var secretBuf = Buffer.isBuffer(secret) ? secret : Buffer.from(secret, "utf8");
|
|
20867
|
-
var prf = m.prf
|
|
21165
|
+
var prf = m.prf != null ? m.prf : "SHA-256";
|
|
20868
21166
|
if (!PBMAC1_PRF[prf]) throw _err("cmp/bad-input", "opts.mac.prf must be SHA-256 / SHA-384 / SHA-512");
|
|
20869
21167
|
var iterationCount = m.iterationCount != null ? m.iterationCount : PBMAC1_DEFAULT_ITER;
|
|
20870
21168
|
if (typeof iterationCount !== "number" || !Number.isInteger(iterationCount) || iterationCount < PBMAC1_MIN_ITER) throw _err("cmp/bad-input", "opts.mac.iterationCount must be at least " + PBMAC1_MIN_ITER + " (RFC 8018 sec. 4.2)");
|
|
@@ -21087,7 +21385,27 @@ var require_cmp_build = __commonJS({
|
|
|
21087
21385
|
if (opts.operation != null) segs.push(_wellKnownSeg(opts.operation, "operation"));
|
|
21088
21386
|
return u.origin + "/" + segs.join("/");
|
|
21089
21387
|
}
|
|
21090
|
-
module2.exports = {
|
|
21388
|
+
module2.exports = {
|
|
21389
|
+
build,
|
|
21390
|
+
transfer,
|
|
21391
|
+
wellKnownUrl,
|
|
21392
|
+
buildCrlStatusList,
|
|
21393
|
+
// @internal -- pki.cmp.session composes it for a crlUpdate support message
|
|
21394
|
+
// @internal -- one key, several legal SPKI encodings (a compressed EC point among them), so the
|
|
21395
|
+
// session compares root-rollover keys through the same definition the builders already use.
|
|
21396
|
+
samePublicKey: function(a, b2) {
|
|
21397
|
+
return _b.samePublicKey(a, b2);
|
|
21398
|
+
},
|
|
21399
|
+
// @internal -- the shared certificate-extension decoders, so a consumer reads basicConstraints or
|
|
21400
|
+
// keyUsage through the same definition every format uses instead of walking the bytes again.
|
|
21401
|
+
decodeCertExtension: function(dottedOid, valueBytes) {
|
|
21402
|
+
var dec = EXT_DECODERS[dottedOid];
|
|
21403
|
+
return dec ? dec(valueBytes) : null;
|
|
21404
|
+
},
|
|
21405
|
+
// @internal -- the CRL-side companion: schema-crl leaves issuingDistributionPoint raw, and the
|
|
21406
|
+
// session needs the point it names to bind a crlUpdate answer to the point that was requested.
|
|
21407
|
+
decodeIdpDistributionPoint
|
|
21408
|
+
};
|
|
21091
21409
|
}
|
|
21092
21410
|
});
|
|
21093
21411
|
|
|
@@ -23734,6 +24052,10 @@ var require_cmp_session = __commonJS({
|
|
|
23734
24052
|
var oid = require_oid();
|
|
23735
24053
|
var x509 = require_schema_x509();
|
|
23736
24054
|
var schemaCmp = require_schema_cmp();
|
|
24055
|
+
var schemaCrmf = require_schema_crmf();
|
|
24056
|
+
var schemaCrl = require_schema_crl();
|
|
24057
|
+
var crmfSign = require_crmf_sign();
|
|
24058
|
+
var cmpBuild = require_cmp_build();
|
|
23737
24059
|
var csr = require_schema_csr();
|
|
23738
24060
|
var guard = require_guard_all();
|
|
23739
24061
|
var compositeSig = require_composite_sig();
|
|
@@ -23778,6 +24100,9 @@ var require_cmp_session = __commonJS({
|
|
|
23778
24100
|
});
|
|
23779
24101
|
var OID_RSASSA_PSS = oid.byName("rsassaPss");
|
|
23780
24102
|
var OID_RSA_ENCRYPTION = oid.byName("rsaEncryption");
|
|
24103
|
+
var OID_IDP = oid.byName("issuingDistributionPoint");
|
|
24104
|
+
var OID_BASIC_CONSTRAINTS = oid.byName("basicConstraints");
|
|
24105
|
+
var OID_KEY_USAGE = oid.byName("keyUsage");
|
|
23781
24106
|
var HASH_OID_TO_DIGEST = {};
|
|
23782
24107
|
[["sha256", "SHA-256"], ["sha384", "SHA-384"], ["sha512", "SHA-512"]].forEach(function(row) {
|
|
23783
24108
|
var o = oid.byName(row[0]);
|
|
@@ -23817,7 +24142,58 @@ var require_cmp_session = __commonJS({
|
|
|
23817
24142
|
var DEFAULT_CERT_REQ_ID = 0;
|
|
23818
24143
|
var P10CR_CERT_REQ_ID = -1;
|
|
23819
24144
|
var ENROLL_ARMS = { ir: 1, cr: 1, kur: 1, p10cr: 1 };
|
|
23820
|
-
var RESPONSE_ARM = { ir: "ip", cr: "cp", kur: "kup", p10cr: "cp" };
|
|
24145
|
+
var RESPONSE_ARM = { ir: "ip", cr: "cp", kur: "kup", p10cr: "cp", rr: "rp", genm: "genp" };
|
|
24146
|
+
var WHOLE_MESSAGE_CERT_REQ_ID = -1;
|
|
24147
|
+
var INFO_OPS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
24148
|
+
caCerts: { name: "caCerts", requestOid: "caCerts", responseOid: "caCerts", value: false, read: "readCaCerts" },
|
|
24149
|
+
rootCaCert: { name: "rootCaCert", requestOid: "rootCaCert", responseOid: "rootCaKeyUpdate", value: "cert", read: "readRootCaKeyUpdate" },
|
|
24150
|
+
certReqTemplate: { name: "certReqTemplate", requestOid: "certReqTemplate", responseOid: "certReqTemplate", value: false, read: "readCertReqTemplate" },
|
|
24151
|
+
crlUpdate: { name: "crlUpdate", requestOid: "crlStatusList", responseOid: "crls", value: "crlStatus", read: "readCrls" }
|
|
24152
|
+
});
|
|
24153
|
+
var KNOWN_REVOKE_KEYS = { certificate: 1, certDetails: 1, reason: 1 };
|
|
24154
|
+
var RSA_ARCS = ["rsaEncryption", "rsaSignatureWithripemd160", "id-TA-RSA-v1-5-SHA-256"].map(function(n) {
|
|
24155
|
+
return oid.toArcs(oid.byName(n)).slice(0, -1);
|
|
24156
|
+
});
|
|
24157
|
+
var RSA_OFF_ARC = /* @__PURE__ */ Object.create(null);
|
|
24158
|
+
[
|
|
24159
|
+
"id-rsa-kem",
|
|
24160
|
+
"id-kem-rsa",
|
|
24161
|
+
"id-rsassa-pkcs1-v1_5-with-sha3-224",
|
|
24162
|
+
"id-rsassa-pkcs1-v1_5-with-sha3-256",
|
|
24163
|
+
"id-rsassa-pkcs1-v1_5-with-sha3-384",
|
|
24164
|
+
"id-rsassa-pkcs1-v1_5-with-sha3-512",
|
|
24165
|
+
"id-RSASSA-PSS-SHAKE128",
|
|
24166
|
+
"id-RSASSA-PSS-SHAKE256",
|
|
24167
|
+
"md4WithRSA",
|
|
24168
|
+
"md5WithRSA",
|
|
24169
|
+
"md4WithRSAEncryption",
|
|
24170
|
+
"rsaSignature",
|
|
24171
|
+
"mdc2WithRSASignature",
|
|
24172
|
+
"shaWithRSAEncryption",
|
|
24173
|
+
"rsaKeyTransport",
|
|
24174
|
+
"md2WithRSASignature",
|
|
24175
|
+
"md5WithRSASignature",
|
|
24176
|
+
"sha1WithRSASignature",
|
|
24177
|
+
"rsa",
|
|
24178
|
+
// the X.509 directory rsa public-key OID (2.5.8.1.1), distinct from PKCS#1 rsaEncryption
|
|
24179
|
+
"sqMod-nWithRSA",
|
|
24180
|
+
"mdc2WithRSA",
|
|
24181
|
+
// the X.500 directory signatureAlgorithm RSA OIDs (2.5.8.3.1, 2.5.8.3.100)
|
|
24182
|
+
"sm3WithRSAEncryption"
|
|
24183
|
+
// the Chinese GM/T RSA-with-SM3 signature (1.2.156.10197.1.504)
|
|
24184
|
+
].forEach(function(n) {
|
|
24185
|
+
var d = oid.byName(n);
|
|
24186
|
+
if (d) RSA_OFF_ARC[d] = 1;
|
|
24187
|
+
});
|
|
24188
|
+
var RSA_ARC_EXCLUDE = /* @__PURE__ */ Object.create(null);
|
|
24189
|
+
["mgf1", "pSpecified"].forEach(function(n) {
|
|
24190
|
+
var d = oid.byName(n);
|
|
24191
|
+
if (d) RSA_ARC_EXCLUDE[d] = 1;
|
|
24192
|
+
});
|
|
24193
|
+
var CRL_REASON_NAMES = /* @__PURE__ */ Object.create(null);
|
|
24194
|
+
Object.keys(constants.NAMES.CRL_REASON).forEach(function(v) {
|
|
24195
|
+
CRL_REASON_NAMES[constants.NAMES.CRL_REASON[v]] = 1;
|
|
24196
|
+
});
|
|
23821
24197
|
function _isGranted(code) {
|
|
23822
24198
|
return code === 0 || code === 1;
|
|
23823
24199
|
}
|
|
@@ -23958,7 +24334,7 @@ var require_cmp_session = __commonJS({
|
|
|
23958
24334
|
}
|
|
23959
24335
|
function session(opts) {
|
|
23960
24336
|
if (opts == null) opts = {};
|
|
23961
|
-
|
|
24337
|
+
guard.identifier.assertPlainRecord(opts, _err, "cmp/bad-input", "opts");
|
|
23962
24338
|
guard.identifier.assertKnownKeys(opts, KNOWN_SESSION_OPTS, _err, "cmp/bad-input", "unknown session opts field ");
|
|
23963
24339
|
opts = Object.assign({}, opts);
|
|
23964
24340
|
if (typeof opts.url !== "string" || !opts.url) throw _err("cmp/bad-input", "opts.url (the CMP endpoint) is required");
|
|
@@ -24043,6 +24419,9 @@ var require_cmp_session = __commonJS({
|
|
|
24043
24419
|
var caPubsWaitingCount = 0;
|
|
24044
24420
|
var activeCertReqId = DEFAULT_CERT_REQ_ID;
|
|
24045
24421
|
var expectedRespArm = "ip";
|
|
24422
|
+
var txnKind = "enroll";
|
|
24423
|
+
var expectedInfoOp = null;
|
|
24424
|
+
var crlQuery = null;
|
|
24046
24425
|
var requestedSpki = null;
|
|
24047
24426
|
var inFlight = false, completed = false, started = false;
|
|
24048
24427
|
var transcript = [];
|
|
@@ -24162,6 +24541,8 @@ var require_cmp_session = __commonJS({
|
|
|
24162
24541
|
function _classify(verdict) {
|
|
24163
24542
|
var body = verdict.body || {};
|
|
24164
24543
|
var arm = body.arm;
|
|
24544
|
+
if (arm === expectedRespArm && txnKind === "revoke") return _classifyRevRep(body);
|
|
24545
|
+
if (arm === expectedRespArm && txnKind === "info") return _classifyGenRep(body);
|
|
24165
24546
|
if (arm === expectedRespArm) {
|
|
24166
24547
|
var responses = body.decoded && body.decoded.response || [];
|
|
24167
24548
|
var resp = null;
|
|
@@ -24213,10 +24594,50 @@ var require_cmp_session = __commonJS({
|
|
|
24213
24594
|
if (code === 2) return { state: "rejected", resp };
|
|
24214
24595
|
return { state: "unexpected", reason: "a " + arm + " CertResponse status code " + code + " has no transition" };
|
|
24215
24596
|
}
|
|
24216
|
-
if (arm === "error") return
|
|
24597
|
+
if (arm === "error") return _classifyError(body);
|
|
24217
24598
|
if (arm === "pollRep") return { state: "pollRep", entries: body.decoded };
|
|
24218
24599
|
if (arm === "pkiconf") return { state: "pkiconf" };
|
|
24219
|
-
return { state: "unexpected", reason: "response arm " + JSON.stringify(arm) + " has no transition in
|
|
24600
|
+
return { state: "unexpected", reason: "response arm " + JSON.stringify(arm) + " has no transition in a " + txnKind + " transaction" };
|
|
24601
|
+
}
|
|
24602
|
+
function _classifyError(body) {
|
|
24603
|
+
var si = body.decoded && body.decoded.pKIStatusInfo;
|
|
24604
|
+
var code = si && si.status ? si.status.code : null;
|
|
24605
|
+
if (code === 3) {
|
|
24606
|
+
if (txnKind === "enroll") throw _err("cmp/bad-error", "an error message answering an enrollment must not carry status waiting -- the profile places enrollment waiting in an ip/cp/kup (RFC 9483 sec. 4.4)");
|
|
24607
|
+
if (si.failInfo != null) throw _err("cmp/bad-error", "an error message with status waiting must not carry failInfo (RFC 9483 sec. 4.4)");
|
|
24608
|
+
return { state: "waiting", resp: { status: si } };
|
|
24609
|
+
}
|
|
24610
|
+
if (code !== 2) throw _err("cmp/bad-error", "an error message carries status rejection(2), or waiting(3) for a revoke/info delayed delivery (RFC 9483 sec. 4.2); got " + (code == null ? "no status" : code));
|
|
24611
|
+
return { state: "rejected", status: si };
|
|
24612
|
+
}
|
|
24613
|
+
function _classifyRevRep(body) {
|
|
24614
|
+
var d = body.decoded || {};
|
|
24615
|
+
var list = d.status || [];
|
|
24616
|
+
if (list.length !== 1) {
|
|
24617
|
+
return { state: "unexpected", reason: "an rp answering a revocation must carry exactly one status (RFC 9483 sec. 4.2); got " + list.length };
|
|
24618
|
+
}
|
|
24619
|
+
var si = list[0];
|
|
24620
|
+
var code = si && si.status ? si.status.code : null;
|
|
24621
|
+
if (code === 0) {
|
|
24622
|
+
if (si.failInfo != null) {
|
|
24623
|
+
return { state: "unexpected", reason: "an accepted rp must not carry failInfo (RFC 9483 sec. 4.2)" };
|
|
24624
|
+
}
|
|
24625
|
+
return { state: "granted", status: si, revCerts: d.revCerts, crls: d.crls };
|
|
24626
|
+
}
|
|
24627
|
+
if (code === 2) return { state: "rejected", status: si };
|
|
24628
|
+
return { state: "unexpected", reason: "an rp status code " + code + " has no transition in a revocation (RFC 9483 sec. 4.2 allows accepted or rejection)" };
|
|
24629
|
+
}
|
|
24630
|
+
function _classifyGenRep(body) {
|
|
24631
|
+
var items = body.decoded || [];
|
|
24632
|
+
if (items.length !== 1) {
|
|
24633
|
+
return { state: "unexpected", reason: "a genp must carry exactly one InfoTypeAndValue (RFC 9483 sec. 4.3); got " + items.length };
|
|
24634
|
+
}
|
|
24635
|
+
var itav = items[0];
|
|
24636
|
+
var want = oid.byName(expectedInfoOp.responseOid);
|
|
24637
|
+
if (itav.type !== want) {
|
|
24638
|
+
return { state: "unexpected", reason: "a genp answering " + expectedInfoOp.name + " must carry infoType " + expectedInfoOp.responseOid + " (" + want + "); got " + itav.type };
|
|
24639
|
+
}
|
|
24640
|
+
return { state: "granted", itav };
|
|
24220
24641
|
}
|
|
24221
24642
|
function _statusOf(resp) {
|
|
24222
24643
|
return resp && resp.status ? resp.status : null;
|
|
@@ -24294,10 +24715,10 @@ var require_cmp_session = __commonJS({
|
|
|
24294
24715
|
return { done: t, polls, header: verdict.header };
|
|
24295
24716
|
}
|
|
24296
24717
|
}
|
|
24297
|
-
async function _confirm(certDer, header,
|
|
24718
|
+
async function _confirm(certDer, header, info2) {
|
|
24298
24719
|
if (opts.implicitConfirm && _implicitConfirmGranted(header)) return { confirmed: true, implicit: true };
|
|
24299
24720
|
var accept = true;
|
|
24300
|
-
if (typeof opts.acceptCert === "function") accept = await opts.acceptCert(Buffer.from(certDer),
|
|
24721
|
+
if (typeof opts.acceptCert === "function") accept = await opts.acceptCert(Buffer.from(certDer), info2) === true;
|
|
24301
24722
|
var h = _certConfHash(certDer);
|
|
24302
24723
|
var certHash = Buffer.from(await webcrypto.webcrypto.subtle.digest(h.digest, certDer));
|
|
24303
24724
|
var cs = { certHash, certReqId: activeCertReqId };
|
|
@@ -24373,8 +24794,8 @@ var require_cmp_session = __commonJS({
|
|
|
24373
24794
|
chain.push(c);
|
|
24374
24795
|
});
|
|
24375
24796
|
await _validateLeaf(leaf, caPubsAccum);
|
|
24376
|
-
var
|
|
24377
|
-
var conf = await _confirm(leaf, header,
|
|
24797
|
+
var info2 = { status: PKI_STATUS_NAMES[granted.code] || granted.code, grantedWithMods: granted.code === 1 };
|
|
24798
|
+
var conf = await _confirm(leaf, header, info2);
|
|
24378
24799
|
var certOut = Buffer.from(leaf), chainOut = chain.map(function(c) {
|
|
24379
24800
|
return Buffer.from(c);
|
|
24380
24801
|
});
|
|
@@ -24390,9 +24811,29 @@ var require_cmp_session = __commonJS({
|
|
|
24390
24811
|
polls: granted.polls || 0
|
|
24391
24812
|
});
|
|
24392
24813
|
}
|
|
24814
|
+
function _assertFresh(what) {
|
|
24815
|
+
if (completed || inFlight) {
|
|
24816
|
+
throw _err("cmp/bad-input", "this pki.cmp.session transaction is already " + (completed ? "completed" : "in flight") + "; create a new session per " + what + " (RFC 9810 sec. 5.1.1: one transactionID per transaction)");
|
|
24817
|
+
}
|
|
24818
|
+
}
|
|
24819
|
+
async function _runOneShot(bodySpec, arm, kind) {
|
|
24820
|
+
txnKind = kind;
|
|
24821
|
+
expectedRespArm = RESPONSE_ARM[arm];
|
|
24822
|
+
activeCertReqId = WHOLE_MESSAGE_CERT_REQ_ID;
|
|
24823
|
+
var verdict = await _send(bodySpec, arm);
|
|
24824
|
+
var t = _classify(verdict);
|
|
24825
|
+
var polls = 0;
|
|
24826
|
+
if (t.state === "waiting") {
|
|
24827
|
+
var polled = await _pollLoop(t.resp);
|
|
24828
|
+
polls = polled.polls;
|
|
24829
|
+
if (polled.timeout) return { timeout: true, polls, status: polled.status };
|
|
24830
|
+
t = polled.done;
|
|
24831
|
+
}
|
|
24832
|
+
return { done: t, polls };
|
|
24833
|
+
}
|
|
24393
24834
|
async function enroll(request) {
|
|
24394
|
-
|
|
24395
|
-
|
|
24835
|
+
_assertFresh("enrollment");
|
|
24836
|
+
guard.identifier.assertPlainRecord(request, _err, "cmp/bad-input", "enroll(request), a body spec { ir | cr | kur | p10cr },");
|
|
24396
24837
|
var arms = Object.keys(request).filter(function(k) {
|
|
24397
24838
|
return request[k] != null;
|
|
24398
24839
|
});
|
|
@@ -24415,6 +24856,7 @@ var require_cmp_session = __commonJS({
|
|
|
24415
24856
|
}
|
|
24416
24857
|
inFlight = true;
|
|
24417
24858
|
try {
|
|
24859
|
+
txnKind = "enroll";
|
|
24418
24860
|
expectedRespArm = RESPONSE_ARM[arms[0]];
|
|
24419
24861
|
var cid = typeof armSpec === "object" && !Buffer.isBuffer(armSpec) ? armSpec.certReqId : void 0;
|
|
24420
24862
|
activeCertReqId = _normalizeCertReqId(cid, arms[0] === "p10cr" ? P10CR_CERT_REQ_ID : DEFAULT_CERT_REQ_ID);
|
|
@@ -24443,8 +24885,351 @@ var require_cmp_session = __commonJS({
|
|
|
24443
24885
|
completed = started;
|
|
24444
24886
|
}
|
|
24445
24887
|
}
|
|
24888
|
+
function _assertRevokingOwnCertificate(certTemplateDer) {
|
|
24889
|
+
var own;
|
|
24890
|
+
try {
|
|
24891
|
+
own = guard.parsed.acceptDerived(opts.cert, "certificate", x509.parse, _err, "cmp/bad-input", "opts.cert");
|
|
24892
|
+
} catch (e) {
|
|
24893
|
+
if (e && e.isCmpError) throw e;
|
|
24894
|
+
throw _err("cmp/bad-input", "opts.cert must be a certificate to revoke one (RFC 9483 sec. 4.2)", e);
|
|
24895
|
+
}
|
|
24896
|
+
var tmpl = schemaCrmf.walkCertTemplate(asn1.decode(certTemplateDer));
|
|
24897
|
+
var sameSerial = tmpl.serialNumber != null && own.serialNumber != null && BigInt(tmpl.serialNumber) === BigInt(own.serialNumber);
|
|
24898
|
+
var sameIssuer = tmpl.issuer != null && guard.name.dnEqual(tmpl.issuer.rdns, own.issuer.rdns, _err, "cmp/bad-input", "the revoked certificate issuer");
|
|
24899
|
+
if (!sameSerial || !sameIssuer) {
|
|
24900
|
+
throw _err("cmp/bad-input", "a session revokes ITS OWN certificate: the issuer and serialNumber in certDetails must name opts.cert, because the signature over the request is the proof of authorization to revoke (RFC 9483 sec. 4.2). Revocation on behalf of another entity is an RA operation -- drive it with pki.cmp.build + pki.cmp.transfer.");
|
|
24901
|
+
}
|
|
24902
|
+
return own;
|
|
24903
|
+
}
|
|
24904
|
+
function _bindRevCerts(revCerts, own) {
|
|
24905
|
+
if (revCerts == null) return null;
|
|
24906
|
+
if (revCerts.length !== 1) {
|
|
24907
|
+
throw _err("cmp/bad-rev-rep", "an rp for a single revocation must name exactly one certificate in revCerts (RFC 9483 sec. 4.2); got " + revCerts.length);
|
|
24908
|
+
}
|
|
24909
|
+
var cid = revCerts[0];
|
|
24910
|
+
var dn = cid.issuer && cid.issuer.tagClass === "context" && cid.issuer.tagNumber === 4 ? cid.issuer.value : null;
|
|
24911
|
+
var sameSerial = cid.serialNumber != null && own.serialNumber != null && BigInt(cid.serialNumber) === BigInt(own.serialNumber);
|
|
24912
|
+
var sameIssuer = dn != null && guard.name.dnEqual(dn.rdns, own.issuer.rdns, _err, "cmp/bad-rev-rep", "the revCerts issuer");
|
|
24913
|
+
if (!sameSerial || !sameIssuer) {
|
|
24914
|
+
throw _err("cmp/bad-rev-rep", "the rp revCerts names a certificate other than the one this session revoked (RFC 9483 sec. 4.2), so a verified verdict must not report it as revoked");
|
|
24915
|
+
}
|
|
24916
|
+
return revCerts;
|
|
24917
|
+
}
|
|
24918
|
+
async function revoke(request) {
|
|
24919
|
+
_assertFresh("revocation");
|
|
24920
|
+
guard.identifier.assertPlainRecord(request, _err, "cmp/bad-input", "revoke(request), an object { certificate | certDetails, reason? },");
|
|
24921
|
+
guard.identifier.assertKnownKeys(request, KNOWN_REVOKE_KEYS, _err, "cmp/bad-input", "unknown revoke request field ");
|
|
24922
|
+
if (isMac) throw _err("cmp/bad-input", "a PBMAC1 session cannot revoke: the request must be signature-protected with the certificate being revoked (RFC 9483 sec. 4.2). Use a signature session ({ key, cert }).");
|
|
24923
|
+
var certificateArg = request.certificate, reasonArg = request.reason;
|
|
24924
|
+
var certDetails = request.certDetails;
|
|
24925
|
+
if (certificateArg == null === (certDetails == null)) {
|
|
24926
|
+
throw _err("cmp/bad-input", "revoke(request) names the certificate by EXACTLY ONE of certificate (the certificate itself) or certDetails ({ issuer, serialNumber })");
|
|
24927
|
+
}
|
|
24928
|
+
if (reasonArg != null && (typeof reasonArg !== "string" || !CRL_REASON_NAMES[reasonArg])) {
|
|
24929
|
+
throw _err("cmp/bad-input", "revoke request.reason must be a CRLReason name (RFC 5280 sec. 5.3.1); got " + JSON.stringify(reasonArg));
|
|
24930
|
+
}
|
|
24931
|
+
if (certificateArg != null) {
|
|
24932
|
+
var target;
|
|
24933
|
+
try {
|
|
24934
|
+
target = guard.parsed.acceptDerived(certificateArg, "certificate", x509.parse, _err, "cmp/bad-input", "revoke request.certificate");
|
|
24935
|
+
} catch (e) {
|
|
24936
|
+
if (e && e.isCmpError) throw e;
|
|
24937
|
+
throw _err("cmp/bad-input", "revoke request.certificate must be a certificate (DER / PEM / parsed)", e);
|
|
24938
|
+
}
|
|
24939
|
+
certDetails = { issuer: target.issuer.bytes, serialNumber: target.serialNumber };
|
|
24940
|
+
}
|
|
24941
|
+
var certTemplateDer;
|
|
24942
|
+
try {
|
|
24943
|
+
certTemplateDer = crmfSign.buildCertTemplate(certDetails);
|
|
24944
|
+
} catch (e) {
|
|
24945
|
+
if (e && e.isCmpError) throw e;
|
|
24946
|
+
throw _err("cmp/bad-rev-req", "revoke request.certDetails must be a CertTemplate naming issuer and serialNumber -- " + (e && e.message || e), e);
|
|
24947
|
+
}
|
|
24948
|
+
var own = _assertRevokingOwnCertificate(certTemplateDer);
|
|
24949
|
+
var body = { rr: [{ certDetails: certTemplateDer, crlEntryDetails: { reason: reasonArg == null ? void 0 : reasonArg } }] };
|
|
24950
|
+
inFlight = true;
|
|
24951
|
+
try {
|
|
24952
|
+
var out = await _runOneShot(body, "rr", "revoke");
|
|
24953
|
+
if (out.timeout) return _terminal("poll-timeout", { status: out.status, polls: out.polls });
|
|
24954
|
+
var t = out.done;
|
|
24955
|
+
if (t.state === "granted") {
|
|
24956
|
+
return _terminal("revoked", {
|
|
24957
|
+
status: t.status,
|
|
24958
|
+
polls: out.polls,
|
|
24959
|
+
revokedCerts: _bindRevCerts(t.revCerts, own),
|
|
24960
|
+
// the CertIds the responder confirms it revoked, bound to the certificate this session revoked
|
|
24961
|
+
// An rp MAY deliver CRLs, and the schema reads those slots as raw SEQUENCEs for the same
|
|
24962
|
+
// reason it does in a genp. They are surfaced on a verdict an operator acts on, so they
|
|
24963
|
+
// are held to being CertificateLists here, exactly as the support-message values are.
|
|
24964
|
+
crls: (t.crls || []).map(_asCrl)
|
|
24965
|
+
});
|
|
24966
|
+
}
|
|
24967
|
+
if (t.state === "rejected") return _terminal("rejected", { status: t.status || null, polls: out.polls });
|
|
24968
|
+
throw _err("cmp/unexpected-arm", t.reason || "the revocation transaction reached an unexpected state");
|
|
24969
|
+
} finally {
|
|
24970
|
+
inFlight = false;
|
|
24971
|
+
completed = started;
|
|
24972
|
+
}
|
|
24973
|
+
}
|
|
24974
|
+
async function info(request) {
|
|
24975
|
+
_assertFresh("support message");
|
|
24976
|
+
guard.identifier.assertPlainRecord(request, _err, "cmp/bad-input", "info(request), an object naming one support operation (caCerts / rootCaCert / certReqTemplate / crlUpdate),");
|
|
24977
|
+
guard.identifier.assertKnownKeys(request, INFO_OPS, _err, "cmp/bad-input", "unknown info request field ");
|
|
24978
|
+
var keys = Object.keys(request), names = [], values = [];
|
|
24979
|
+
for (var ki = 0; ki < keys.length; ki++) {
|
|
24980
|
+
var kv = request[keys[ki]];
|
|
24981
|
+
if (kv == null) continue;
|
|
24982
|
+
names[names.length] = keys[ki];
|
|
24983
|
+
values[values.length] = kv;
|
|
24984
|
+
}
|
|
24985
|
+
if (names.length !== 1) {
|
|
24986
|
+
throw _err("cmp/bad-input", "info(request) must name EXACTLY ONE support operation (caCerts / rootCaCert / certReqTemplate / crlUpdate); a genm carries a sequence of one InfoTypeAndValue (RFC 9483 sec. 4.3)");
|
|
24987
|
+
}
|
|
24988
|
+
var op = INFO_OPS[names[0]], asked = values[0];
|
|
24989
|
+
var itav = { infoType: op.requestOid };
|
|
24990
|
+
if (op.value === false) {
|
|
24991
|
+
if (asked !== true) throw _err("cmp/bad-input", "info request." + op.name + " takes `true`: this operation's genm carries no infoValue (RFC 9483 sec. 4.3.1 and sec. 4.3.3)");
|
|
24992
|
+
} else if (op.value === "cert") {
|
|
24993
|
+
var rootCaCertDer = _certificateArgument(asked, "info request rootCaCert");
|
|
24994
|
+
_assertCaCapable(x509.parse(rootCaCertDer), "info request rootCaCert", "cmp/bad-input");
|
|
24995
|
+
itav.infoValue = rootCaCertDer;
|
|
24996
|
+
} else if (op.value === "crlStatus") {
|
|
24997
|
+
var built = cmpBuild.buildCrlStatusList(asked);
|
|
24998
|
+
itav.infoValue = built.der;
|
|
24999
|
+
crlQuery = { issuerName: built.issuerName, thisUpdate: built.thisUpdate, dpn: built.dpn };
|
|
25000
|
+
}
|
|
25001
|
+
expectedInfoOp = op;
|
|
25002
|
+
inFlight = true;
|
|
25003
|
+
try {
|
|
25004
|
+
var out = await _runOneShot({ genm: [itav] }, "genm", "info");
|
|
25005
|
+
if (out.timeout) return _terminal("poll-timeout", { operation: op.name, status: out.status, polls: out.polls });
|
|
25006
|
+
var t = out.done;
|
|
25007
|
+
if (t.state === "granted") {
|
|
25008
|
+
var raw = t.itav.value;
|
|
25009
|
+
var value = null;
|
|
25010
|
+
if (raw != null) {
|
|
25011
|
+
try {
|
|
25012
|
+
value = schemaCmp[op.read](raw);
|
|
25013
|
+
} catch (e) {
|
|
25014
|
+
if (e && e.isCmpError) throw e;
|
|
25015
|
+
throw _err("cmp/bad-info-value", "the " + op.name + " response value is malformed -- " + (e && e.message || e), e);
|
|
25016
|
+
}
|
|
25017
|
+
value = await _checkInfoValue(op, value, itav.infoValue);
|
|
25018
|
+
}
|
|
25019
|
+
return _terminal("answered", { operation: op.name, present: raw != null, value, status: null, polls: out.polls });
|
|
25020
|
+
}
|
|
25021
|
+
if (t.state === "rejected") return _terminal("rejected", { operation: op.name, status: t.status || null, polls: out.polls });
|
|
25022
|
+
throw _err("cmp/unexpected-arm", t.reason || "the support-message transaction reached an unexpected state");
|
|
25023
|
+
} finally {
|
|
25024
|
+
inFlight = false;
|
|
25025
|
+
completed = started;
|
|
25026
|
+
}
|
|
25027
|
+
}
|
|
25028
|
+
function _checkInfoValue(op, value, requestValue) {
|
|
25029
|
+
if (op.name === "rootCaCert") {
|
|
25030
|
+
if (value.newWithOld == null) throw _err("cmp/bad-info-value", "a rootCaKeyUpdate response must carry newWithOld -- the certificate that lets an entity trusting the OLD root gain trust in the new one (RFC 9483 sec. 4.3.2)");
|
|
25031
|
+
return _checkRootCaKeyUpdate(value, requestValue);
|
|
25032
|
+
}
|
|
25033
|
+
if (op.name === "certReqTemplate") {
|
|
25034
|
+
var t = value.certTemplate;
|
|
25035
|
+
["publicKey", "serialNumber", "signingAlg", "issuerUID", "subjectUID"].forEach(function(f) {
|
|
25036
|
+
if (t[f] != null) throw _err("cmp/bad-info-value", "a certReqTemplate certTemplate must omit " + f + " (RFC 9483 sec. 4.3.3)");
|
|
25037
|
+
});
|
|
25038
|
+
if (value.keySpec != null) value.keySpec.forEach(_checkKeySpec);
|
|
25039
|
+
return value;
|
|
25040
|
+
}
|
|
25041
|
+
if (op.name === "caCerts") return value.map(function(d) {
|
|
25042
|
+
var der = _asCertificate(d, "a caCerts entry");
|
|
25043
|
+
_assertCaCapable(x509.parse(der), "caCerts entry");
|
|
25044
|
+
return der;
|
|
25045
|
+
});
|
|
25046
|
+
if (op.name === "crlUpdate") {
|
|
25047
|
+
if (value.length !== 1) throw _err("cmp/bad-info-value", "a crlUpdate response answers a single-source query with exactly one CRL -- the latest from the named source (RFC 9483 sec. 4.3.4); got " + value.length);
|
|
25048
|
+
return value.map(_bindCrlToQuery);
|
|
25049
|
+
}
|
|
25050
|
+
throw _err("cmp/bad-info-value", "no response rules are defined for the " + op.name + " support message");
|
|
25051
|
+
}
|
|
25052
|
+
async function _checkRootCaKeyUpdate(value, oldRootDer) {
|
|
25053
|
+
var newWithNew = _asCertificate(value.newWithNew, "the rootCaKeyUpdate newWithNew");
|
|
25054
|
+
var newWithOld = _asCertificate(value.newWithOld, "the rootCaKeyUpdate newWithOld");
|
|
25055
|
+
var oldWithNew = value.oldWithNew == null ? null : _asCertificate(value.oldWithNew, "the rootCaKeyUpdate oldWithNew");
|
|
25056
|
+
var pNewNew = x509.parse(newWithNew), pNewOld = x509.parse(newWithOld), pOldRoot = x509.parse(oldRootDer);
|
|
25057
|
+
_assertCaCapable(pNewNew, "rootCaKeyUpdate newWithNew");
|
|
25058
|
+
_assertCaCapable(pNewOld, "rootCaKeyUpdate newWithOld");
|
|
25059
|
+
if (!cmpBuild.samePublicKey(pNewOld.subjectPublicKeyInfo.bytes, pNewNew.subjectPublicKeyInfo.bytes)) {
|
|
25060
|
+
throw _err("cmp/bad-info-value", "the rootCaKeyUpdate newWithOld must certify the NEW root key, the one newWithNew carries (RFC 9483 sec. 4.3.2)");
|
|
25061
|
+
}
|
|
25062
|
+
_assertSameName(pNewOld.issuer, pOldRoot.subject, "newWithOld", "be issued by the OLD root named in the request");
|
|
25063
|
+
_assertSameName(pNewOld.subject, pNewNew.subject, "newWithOld", "name the same subject as newWithNew, the certificate it vouches for");
|
|
25064
|
+
if (guard.name.dnEqual(pNewNew.issuer.rdns, pNewNew.subject.rdns, _err, "cmp/bad-info-value", "the rootCaKeyUpdate newWithNew name")) {
|
|
25065
|
+
await _assertSignedBy(pNewNew, pNewNew, "newWithNew", "its own key, which a self-issued root certificate must be");
|
|
25066
|
+
}
|
|
25067
|
+
await _assertSignedBy(pNewOld, pOldRoot, "newWithOld", "the OLD root CA key");
|
|
25068
|
+
if (oldWithNew !== null) {
|
|
25069
|
+
var pOldNew = x509.parse(oldWithNew);
|
|
25070
|
+
_assertCaCapable(pOldNew, "rootCaKeyUpdate oldWithNew");
|
|
25071
|
+
if (!cmpBuild.samePublicKey(pOldNew.subjectPublicKeyInfo.bytes, pOldRoot.subjectPublicKeyInfo.bytes)) {
|
|
25072
|
+
throw _err("cmp/bad-info-value", "the rootCaKeyUpdate oldWithNew must certify the OLD root key (RFC 9483 sec. 4.3.2)");
|
|
25073
|
+
}
|
|
25074
|
+
_assertSameName(pOldNew.issuer, pNewNew.subject, "oldWithNew", "be issued by the NEW root");
|
|
25075
|
+
_assertSameName(pOldNew.subject, pOldRoot.subject, "oldWithNew", "name the OLD root it vouches for");
|
|
25076
|
+
await _assertSignedBy(pOldNew, pNewNew, "oldWithNew", "the NEW root CA key");
|
|
25077
|
+
}
|
|
25078
|
+
return { newWithNew, newWithOld, oldWithNew };
|
|
25079
|
+
}
|
|
25080
|
+
function _assertCaCapable(cert, which, code) {
|
|
25081
|
+
code = code || "cmp/bad-info-value";
|
|
25082
|
+
var bc = null, ku = null, bcCritical = false;
|
|
25083
|
+
cert.extensions.forEach(function(e) {
|
|
25084
|
+
if (e.oid === OID_BASIC_CONSTRAINTS) {
|
|
25085
|
+
bc = cmpBuild.decodeCertExtension(e.oid, e.value);
|
|
25086
|
+
bcCritical = e.critical === true;
|
|
25087
|
+
}
|
|
25088
|
+
if (e.oid === OID_KEY_USAGE) ku = cmpBuild.decodeCertExtension(e.oid, e.value);
|
|
25089
|
+
});
|
|
25090
|
+
if (!bc || bc.cA !== true) {
|
|
25091
|
+
throw _err(code, "the " + which + " must be a CA certificate (basicConstraints cA TRUE): an end-entity certificate certifies nothing and cannot serve as an issuer for chain construction (RFC 5280 sec. 6.1.4)");
|
|
25092
|
+
}
|
|
25093
|
+
if (!bcCritical) {
|
|
25094
|
+
throw _err(code, "the " + which + " marks basicConstraints non-critical, so a relying party that skips unrecognized extensions would not see the cA bit it must act on (RFC 5280 sec. 4.2.1.9)");
|
|
25095
|
+
}
|
|
25096
|
+
if (ku && ku.keyCertSign !== true) {
|
|
25097
|
+
throw _err(code, "the " + which + " carries a keyUsage that withholds keyCertSign, so it cannot sign certificates as a CA must (RFC 5280 sec. 6.1.4)");
|
|
25098
|
+
}
|
|
25099
|
+
}
|
|
25100
|
+
function _assertSameName(a, b, which, must) {
|
|
25101
|
+
if (!guard.name.dnEqual(a.rdns, b.rdns, _err, "cmp/bad-info-value", "a rootCaKeyUpdate name")) {
|
|
25102
|
+
throw _err("cmp/bad-info-value", "the rootCaKeyUpdate " + which + " must " + must + " (RFC 9483 sec. 4.3.2); got " + JSON.stringify(a.dn));
|
|
25103
|
+
}
|
|
25104
|
+
}
|
|
25105
|
+
async function _assertSignedBy(cert, signer, which, whose) {
|
|
25106
|
+
if (!_engine || !_engine.verifyWithSpki) {
|
|
25107
|
+
throw _err("cmp/bad-info-value", "the signature engine is unavailable, so a rootCaKeyUpdate cannot be checked; require pki.path to install it");
|
|
25108
|
+
}
|
|
25109
|
+
if (!guard.crypto.isOctetAligned(cert.signatureValue)) {
|
|
25110
|
+
throw _err("cmp/bad-info-value", "the rootCaKeyUpdate " + which + " signature is not octet-aligned (a BIT STRING with unused bits), which no valid signature is (RFC 9483 sec. 4.3.2)");
|
|
25111
|
+
}
|
|
25112
|
+
var ok = await _engine.verifyWithSpki(cert.signatureAlgorithm, cert.signatureValue.bytes, signer.subjectPublicKeyInfo.bytes, cert.tbsBytes);
|
|
25113
|
+
if (ok !== true) {
|
|
25114
|
+
throw _err("cmp/bad-info-value", "the rootCaKeyUpdate " + which + " is not signed by " + whose + ", so it cannot carry the trust transition it exists for (RFC 9483 sec. 4.3.2)");
|
|
25115
|
+
}
|
|
25116
|
+
}
|
|
25117
|
+
function _certificateArgument(value, what) {
|
|
25118
|
+
var der;
|
|
25119
|
+
if (typeof value === "string") {
|
|
25120
|
+
try {
|
|
25121
|
+
der = x509.pemDecode(value);
|
|
25122
|
+
} catch (e) {
|
|
25123
|
+
throw _err("cmp/bad-input", what + " is a string but not a PEM certificate", e);
|
|
25124
|
+
}
|
|
25125
|
+
} else if (value != null && Buffer.isBuffer(value.tbsBytes)) {
|
|
25126
|
+
throw _err("cmp/bad-input", what + " must carry the certificate's own bytes (DER or PEM): a parsed certificate keeps no source DER, and this request has to send the bytes the issuer signed");
|
|
25127
|
+
} else {
|
|
25128
|
+
der = guard.bytes.snapshot(value, CmpError, "cmp/bad-input", what);
|
|
25129
|
+
}
|
|
25130
|
+
return _asCertificate(der, what, "cmp/bad-input");
|
|
25131
|
+
}
|
|
25132
|
+
function _asCertificate(der, what, code) {
|
|
25133
|
+
try {
|
|
25134
|
+
x509.parse(der);
|
|
25135
|
+
} catch (e) {
|
|
25136
|
+
throw _err(code || "cmp/bad-info-value", what + " is not a valid X.509 certificate (RFC 9483 sec. 4.3)", e);
|
|
25137
|
+
}
|
|
25138
|
+
return Buffer.from(der);
|
|
25139
|
+
}
|
|
25140
|
+
function _asCrl(der) {
|
|
25141
|
+
try {
|
|
25142
|
+
schemaCrl.parse(der);
|
|
25143
|
+
} catch (e) {
|
|
25144
|
+
throw _err("cmp/bad-info-value", "a crlUpdate entry is not a valid CertificateList (RFC 9483 sec. 4.3.4)", e);
|
|
25145
|
+
}
|
|
25146
|
+
return Buffer.from(der);
|
|
25147
|
+
}
|
|
25148
|
+
function _bindCrlToQuery(der) {
|
|
25149
|
+
var parsed;
|
|
25150
|
+
try {
|
|
25151
|
+
parsed = schemaCrl.parse(der);
|
|
25152
|
+
} catch (e) {
|
|
25153
|
+
throw _err("cmp/bad-info-value", "a crlUpdate entry is not a valid CertificateList (RFC 9483 sec. 4.3.4)", e);
|
|
25154
|
+
}
|
|
25155
|
+
if (crlQuery && crlQuery.issuerName != null) {
|
|
25156
|
+
var want = schemaCmp.readName(crlQuery.issuerName);
|
|
25157
|
+
if (!guard.name.dnEqual(parsed.issuer.rdns, want.rdns, _err, "cmp/bad-info-value", "the crlUpdate issuer")) {
|
|
25158
|
+
throw _err("cmp/bad-info-value", "the returned CRL was issued by " + JSON.stringify(parsed.issuer.dn) + ", not by the source this request named (RFC 9483 sec. 4.3.4)");
|
|
25159
|
+
}
|
|
25160
|
+
}
|
|
25161
|
+
if (crlQuery && crlQuery.dpn != null) {
|
|
25162
|
+
var idpDpn = null, idpCritical = false, crlExts = parsed.crlExtensions || [];
|
|
25163
|
+
for (var xi = 0; xi < crlExts.length; xi++) {
|
|
25164
|
+
if (crlExts[xi].oid !== OID_IDP) continue;
|
|
25165
|
+
idpDpn = cmpBuild.decodeIdpDistributionPoint(crlExts[xi].value);
|
|
25166
|
+
idpCritical = crlExts[xi].critical === true;
|
|
25167
|
+
break;
|
|
25168
|
+
}
|
|
25169
|
+
if (idpDpn !== null && (!idpCritical || !guard.name.dpnCorresponds(crlQuery.dpn, idpDpn, _err, "cmp/bad-info-value", "the crlUpdate distribution point"))) {
|
|
25170
|
+
throw _err("cmp/bad-info-value", "the returned CRL is scoped to a distribution point other than the one this request named, or marks that scope non-critical where a relying party may ignore it (RFC 9483 sec. 4.3.4, RFC 5280 sec. 5.2.5)");
|
|
25171
|
+
}
|
|
25172
|
+
}
|
|
25173
|
+
if (crlQuery && crlQuery.thisUpdate != null) {
|
|
25174
|
+
var asked = crlQuery.thisUpdate;
|
|
25175
|
+
var got = guard.time.instantOf(parsed.thisUpdate, _err, "cmp/bad-info-value", "the returned CRL's thisUpdate");
|
|
25176
|
+
if (got <= asked) {
|
|
25177
|
+
throw _err("cmp/bad-info-value", "the returned CRL is no more recent than the thisUpdate this request supplied, so sec. 4.3.4 requires the response to carry no value at all");
|
|
25178
|
+
}
|
|
25179
|
+
}
|
|
25180
|
+
return Buffer.from(der);
|
|
25181
|
+
}
|
|
25182
|
+
var OID_REG_CTRL_ALG_ID = oid.byName("algId");
|
|
25183
|
+
var OID_REG_CTRL_RSA_KEY_LEN = oid.byName("rsaKeyLen");
|
|
25184
|
+
function _isRsaAlgorithm(dotted) {
|
|
25185
|
+
if (RSA_ARC_EXCLUDE[dotted] === 1) return false;
|
|
25186
|
+
var arcs = oid.toArcs(dotted);
|
|
25187
|
+
var underAny = false;
|
|
25188
|
+
for (var a = 0; !underAny && a < RSA_ARCS.length; a++) {
|
|
25189
|
+
var arc = RSA_ARCS[a];
|
|
25190
|
+
if (arcs.length > arc.length) {
|
|
25191
|
+
underAny = true;
|
|
25192
|
+
for (var i = 0; underAny && i < arc.length; i++) {
|
|
25193
|
+
underAny = arcs[i] === arc[i];
|
|
25194
|
+
}
|
|
25195
|
+
}
|
|
25196
|
+
}
|
|
25197
|
+
return underAny || RSA_OFF_ARC[dotted] === 1;
|
|
25198
|
+
}
|
|
25199
|
+
function _checkKeySpec(ctrl) {
|
|
25200
|
+
if (ctrl.type === OID_REG_CTRL_RSA_KEY_LEN) {
|
|
25201
|
+
var len;
|
|
25202
|
+
try {
|
|
25203
|
+
len = asn1.read.integer(asn1.decode(ctrl.value));
|
|
25204
|
+
} catch (e) {
|
|
25205
|
+
throw _err("cmp/bad-info-value", "a keySpec rsaKeyLen must be an INTEGER (RFC 9483 sec. 4.3.3)", e);
|
|
25206
|
+
}
|
|
25207
|
+
if (len <= 0n) throw _err("cmp/bad-info-value", "a keySpec rsaKeyLen must be a positive integer (RFC 9483 sec. 4.3.3); got " + len);
|
|
25208
|
+
ctrl.rsaKeyLen = len;
|
|
25209
|
+
return;
|
|
25210
|
+
}
|
|
25211
|
+
if (ctrl.type === OID_REG_CTRL_ALG_ID) {
|
|
25212
|
+
var alg;
|
|
25213
|
+
try {
|
|
25214
|
+
alg = schemaCmp.readAlgorithmIdentifier(ctrl.value);
|
|
25215
|
+
} catch (e) {
|
|
25216
|
+
if (e && e.isCmpError) throw e;
|
|
25217
|
+
throw _err("cmp/bad-info-value", "a keySpec algId must be an AlgorithmIdentifier (RFC 9483 sec. 4.3.3)", e);
|
|
25218
|
+
}
|
|
25219
|
+
if (_isRsaAlgorithm(alg.oid)) {
|
|
25220
|
+
throw _err("cmp/bad-info-value", "a keySpec algId must give an algorithm other than RSA, whose requirement is stated with rsaKeyLen instead (RFC 9483 sec. 4.3.3); got " + (alg.name || alg.oid));
|
|
25221
|
+
}
|
|
25222
|
+
ctrl.algorithm = alg.oid;
|
|
25223
|
+
ctrl.algorithmName = alg.name;
|
|
25224
|
+
ctrl.algorithmParameters = alg.parameters;
|
|
25225
|
+
return;
|
|
25226
|
+
}
|
|
25227
|
+
throw _err("cmp/bad-info-value", "a keySpec control must be id-regCtrl-algId or id-regCtrl-rsaKeyLen (RFC 9483 sec. 4.3.3); got " + ctrl.type);
|
|
25228
|
+
}
|
|
24446
25229
|
return {
|
|
24447
25230
|
enroll,
|
|
25231
|
+
revoke,
|
|
25232
|
+
info,
|
|
24448
25233
|
get transactionID() {
|
|
24449
25234
|
return Buffer.from(transactionID);
|
|
24450
25235
|
},
|
|
@@ -25669,16 +26454,7 @@ var require_path_validate = __commonJS({
|
|
|
25669
26454
|
var dp = certDPs[i];
|
|
25670
26455
|
if (!dp.distributionPoint) continue;
|
|
25671
26456
|
if (dp.cRLIssuer && !crlIssuerNamesIssuer(dp.cRLIssuer, issuerRdns)) continue;
|
|
25672
|
-
|
|
25673
|
-
if (idpDpn.kind === "fullName" && cdpn.kind === "fullName") {
|
|
25674
|
-
for (var a = 0; a < idpDpn.names.length; a++) {
|
|
25675
|
-
for (var c = 0; c < cdpn.names.length; c++) {
|
|
25676
|
-
if (idpDpn.names[a].equals(cdpn.names[c])) return dp;
|
|
25677
|
-
}
|
|
25678
|
-
}
|
|
25679
|
-
} else if (idpDpn.kind === "rdn" && cdpn.kind === "rdn") {
|
|
25680
|
-
if (idpDpn.bytes.equals(cdpn.bytes)) return dp;
|
|
25681
|
-
}
|
|
26457
|
+
if (guard.name.dpnCorresponds(idpDpn, dp.distributionPoint, E, "path/bad-idp", "a CRL distribution point")) return dp;
|
|
25682
26458
|
}
|
|
25683
26459
|
return null;
|
|
25684
26460
|
}
|
|
@@ -26014,7 +26790,7 @@ var require_path_validate = __commonJS({
|
|
|
26014
26790
|
dnEqual
|
|
26015
26791
|
});
|
|
26016
26792
|
cmpVerify.setEngine({ verifyWithSpki: _verifyWithSpki, build, validate });
|
|
26017
|
-
cmpSession.setEngine({ build, validate, toAnchor, coerceCert });
|
|
26793
|
+
cmpSession.setEngine({ build, validate, toAnchor, coerceCert, verifyWithSpki: _verifyWithSpki });
|
|
26018
26794
|
cmsVerify.setEngine({
|
|
26019
26795
|
build,
|
|
26020
26796
|
validate,
|
|
@@ -36593,8 +37369,24 @@ var require_acme = __commonJS({
|
|
|
36593
37369
|
}
|
|
36594
37370
|
return out;
|
|
36595
37371
|
}
|
|
37372
|
+
var _CLIENT_OPTS = {
|
|
37373
|
+
accountKey: 1,
|
|
37374
|
+
accountJwk: 1,
|
|
37375
|
+
alg: 1,
|
|
37376
|
+
transport: 1,
|
|
37377
|
+
tls: 1,
|
|
37378
|
+
timeout: 1,
|
|
37379
|
+
maxResponseBytes: 1,
|
|
37380
|
+
maxRedirects: 1,
|
|
37381
|
+
maxNonceRetries: 1,
|
|
37382
|
+
maxPolls: 1,
|
|
37383
|
+
maxTotalWait: 1,
|
|
37384
|
+
sleep: 1,
|
|
37385
|
+
clock: 1
|
|
37386
|
+
};
|
|
36596
37387
|
function client(directoryUrl, opts) {
|
|
36597
|
-
opts = opts
|
|
37388
|
+
opts = guard.identifier.optionsObject(opts, E, "acme/bad-input", "pki.acme.client options");
|
|
37389
|
+
guard.identifier.assertKnownKeys(opts, _CLIENT_OPTS, E, "acme/bad-input", "unknown pki.acme.client option ");
|
|
36598
37390
|
if (!opts.accountKey) throw E("acme/bad-input", "client requires opts.accountKey (the account private key)");
|
|
36599
37391
|
if (!_isObject(opts.accountJwk)) throw E("acme/bad-input", "client requires opts.accountJwk (the account public JWK)");
|
|
36600
37392
|
if (!_isString(opts.alg)) throw E("acme/bad-input", "client requires opts.alg (the account-key JWS alg)");
|
|
@@ -37747,11 +38539,13 @@ var require_trust = __commonJS({
|
|
|
37747
38539
|
}
|
|
37748
38540
|
return { anchors: _dedupAnchors(anchors) };
|
|
37749
38541
|
}
|
|
38542
|
+
var _ANCHOR_OPTS = { purpose: 1 };
|
|
37750
38543
|
function anchor(entry, opts) {
|
|
37751
38544
|
if (!entry || typeof entry !== "object") {
|
|
37752
38545
|
throw E("trust/bad-input", "anchor expects a trust-store entry ({ name, publicKey, algorithm, ... })");
|
|
37753
38546
|
}
|
|
37754
|
-
opts = opts
|
|
38547
|
+
opts = guard.identifier.optionsObject(opts, E, "trust/bad-input", "pki.trust.anchor options");
|
|
38548
|
+
guard.identifier.assertKnownKeys(opts, _ANCHOR_OPTS, E, "trust/bad-input", "unknown pki.trust.anchor option ");
|
|
37755
38549
|
var derived = _DERIVED_FROM.get(entry);
|
|
37756
38550
|
var meta = derived || entry;
|
|
37757
38551
|
if (!derived && (!Buffer.isBuffer(entry.publicKey) || typeof entry.algorithm !== "string" || !entry.name || !Array.isArray(entry.name.rdns))) {
|