micro509 0.14.0 → 0.15.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 +2064 -0
- package/README.md +105 -225
- package/dist/crypto/crypto.d.ts +42 -11
- package/dist/crypto/crypto.js +53 -22
- package/dist/crypto/crypto.js.map +1 -1
- package/dist/crypto.d.ts +2 -2
- package/dist/crypto.js +1 -2
- package/dist/der/der.d.ts +41 -33
- package/dist/der/der.js +26 -24
- package/dist/der/der.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +19 -19
- package/dist/internal/asn1/asn1.d.ts +3 -6
- package/dist/internal/asn1/asn1.js +343 -43
- package/dist/internal/asn1/asn1.js.map +1 -1
- package/dist/internal/asn1/ber.js +146 -0
- package/dist/internal/asn1/ber.js.map +1 -0
- package/dist/internal/asn1/decode-refusal.js +29 -0
- package/dist/internal/asn1/decode-refusal.js.map +1 -0
- package/dist/internal/asn1/der.d.ts +38 -41
- package/dist/internal/asn1/der.js +131 -52
- package/dist/internal/asn1/der.js.map +1 -1
- package/dist/internal/asn1/oids.js +83 -53
- package/dist/internal/asn1/oids.js.map +1 -1
- package/dist/internal/asn1/oids2.js +1 -2
- package/dist/internal/asn1/oids2.js.map +1 -1
- package/dist/internal/crypto/algorithm-names.js +1 -2
- package/dist/internal/crypto/algorithm-names.js.map +1 -1
- package/dist/internal/crypto/ecdsa.js +13 -8
- package/dist/internal/crypto/ecdsa.js.map +1 -1
- package/dist/internal/crypto/hash.js +1 -2
- package/dist/internal/crypto/hash.js.map +1 -1
- package/dist/internal/crypto/pbes2.d.ts +24 -11
- package/dist/internal/crypto/pbes2.js +79 -26
- package/dist/internal/crypto/pbes2.js.map +1 -1
- package/dist/internal/crypto/rsa-pss.js +46 -44
- package/dist/internal/crypto/rsa-pss.js.map +1 -1
- package/dist/internal/crypto/sig-verify.d.ts +4 -7
- package/dist/internal/crypto/sig-verify.js +107 -60
- package/dist/internal/crypto/sig-verify.js.map +1 -1
- package/dist/internal/crypto/signing.d.ts +1 -4
- package/dist/internal/crypto/signing.js +28 -29
- package/dist/internal/crypto/signing.js.map +1 -1
- package/dist/internal/crypto/webcrypto.js +1 -2
- package/dist/internal/crypto/webcrypto.js.map +1 -1
- package/dist/internal/shared/base64.js +1 -2
- package/dist/internal/shared/base64.js.map +1 -1
- package/dist/internal/shared/dn.d.ts +3 -6
- package/dist/internal/shared/dn.js +99 -53
- package/dist/internal/shared/dn.js.map +1 -1
- package/dist/internal/shared/idna-tables.js +7217 -0
- package/dist/internal/shared/idna-tables.js.map +1 -0
- package/dist/internal/shared/idna.js +296 -0
- package/dist/internal/shared/idna.js.map +1 -0
- package/dist/internal/shared/ip.d.ts +4 -7
- package/dist/internal/shared/ip.js +1 -2
- package/dist/internal/shared/ip.js.map +1 -1
- package/dist/internal/shared/mailbox.js +26 -0
- package/dist/internal/shared/mailbox.js.map +1 -0
- package/dist/internal/shared/punycode.js +101 -0
- package/dist/internal/shared/punycode.js.map +1 -0
- package/dist/internal/shared/rfc3454-tables.js +1 -2
- package/dist/internal/shared/rfc3454-tables.js.map +1 -1
- package/dist/internal/shared/rfc4518-tables.js +119 -0
- package/dist/internal/shared/rfc4518-tables.js.map +1 -0
- package/dist/internal/shared/uri-host.js +102 -0
- package/dist/internal/shared/uri-host.js.map +1 -0
- package/dist/internal/verify/name-constraints-engine.js +246 -131
- package/dist/internal/verify/name-constraints-engine.js.map +1 -1
- package/dist/internal/verify/policy-engine.js +6 -21
- package/dist/internal/verify/policy-engine.js.map +1 -1
- package/dist/internal/verify/verify-path.d.ts +1 -4
- package/dist/internal/verify/verify-path.js +267 -131
- package/dist/internal/verify/verify-path.js.map +1 -1
- package/dist/internal/x509/directory-name.js +1 -2
- package/dist/internal/x509/directory-name.js.map +1 -1
- package/dist/internal/x509/extension-bits.js +2 -3
- package/dist/internal/x509/extension-bits.js.map +1 -1
- package/dist/internal/x509/extension-errors.d.ts +1 -4
- package/dist/internal/x509/extension-errors.js +1 -2
- package/dist/internal/x509/extension-errors.js.map +1 -1
- package/dist/internal/x509/extension-registry.js +107 -89
- package/dist/internal/x509/extension-registry.js.map +1 -1
- package/dist/internal/x509/general-name-profile.js +129 -0
- package/dist/internal/x509/general-name-profile.js.map +1 -0
- package/dist/internal/x509/general-name-tags.js +1 -2
- package/dist/internal/x509/general-name-tags.js.map +1 -1
- package/dist/internal/x509/general-name.js +128 -42
- package/dist/internal/x509/general-name.js.map +1 -1
- package/dist/internal/x509/name-fields.js +1 -2
- package/dist/internal/x509/name-fields.js.map +1 -1
- package/dist/internal/x509/or-address.js +217 -0
- package/dist/internal/x509/or-address.js.map +1 -0
- package/dist/keys/keys.d.ts +112 -97
- package/dist/keys/keys.js +211 -204
- package/dist/keys/keys.js.map +1 -1
- package/dist/keys.d.ts +3 -3
- package/dist/pem/pem.d.ts +14 -17
- package/dist/pem/pem.js +16 -17
- package/dist/pem/pem.js.map +1 -1
- package/dist/pem.js +1 -2
- package/dist/pkcs/pfx.d.ts +57 -32
- package/dist/pkcs/pfx.js +209 -173
- package/dist/pkcs/pfx.js.map +1 -1
- package/dist/pkcs/pkcs12-mac.d.ts +104 -27
- package/dist/pkcs/pkcs12-mac.js +266 -79
- package/dist/pkcs/pkcs12-mac.js.map +1 -1
- package/dist/pkcs/pkcs7.d.ts +43 -37
- package/dist/pkcs/pkcs7.js +218 -217
- package/dist/pkcs/pkcs7.js.map +1 -1
- package/dist/pkcs.d.ts +4 -3
- package/dist/result/result.d.ts +27 -20
- package/dist/result/result.js +8 -3
- package/dist/result/result.js.map +1 -1
- package/dist/result.d.ts +2 -2
- package/dist/result.js +1 -2
- package/dist/revocation/chain.d.ts +101 -23
- package/dist/revocation/chain.js +436 -182
- package/dist/revocation/chain.js.map +1 -1
- package/dist/revocation/crl.d.ts +131 -67
- package/dist/revocation/crl.js +444 -323
- package/dist/revocation/crl.js.map +1 -1
- package/dist/revocation/ocsp.d.ts +94 -59
- package/dist/revocation/ocsp.js +331 -293
- package/dist/revocation/ocsp.js.map +1 -1
- package/dist/revocation/revocation.d.ts +47 -35
- package/dist/revocation/revocation.js +88 -57
- package/dist/revocation/revocation.js.map +1 -1
- package/dist/revocation.d.ts +3 -3
- package/dist/verify/identity.d.ts +16 -19
- package/dist/verify/identity.js +118 -89
- package/dist/verify/identity.js.map +1 -1
- package/dist/verify/name-constraints.d.ts +1 -4
- package/dist/verify/policy.d.ts +9 -7
- package/dist/verify/verify.d.ts +84 -46
- package/dist/verify/verify.js +300 -152
- package/dist/verify/verify.js.map +1 -1
- package/dist/verify.d.ts +2 -2
- package/dist/x509/certificate.d.ts +20 -21
- package/dist/x509/certificate.js +62 -46
- package/dist/x509/certificate.js.map +1 -1
- package/dist/x509/csr.d.ts +5 -7
- package/dist/x509/csr.js +10 -11
- package/dist/x509/csr.js.map +1 -1
- package/dist/x509/extensions.d.ts +154 -66
- package/dist/x509/extensions.js +317 -151
- package/dist/x509/extensions.js.map +1 -1
- package/dist/x509/fingerprint.d.ts +4 -7
- package/dist/x509/fingerprint.js +1 -2
- package/dist/x509/fingerprint.js.map +1 -1
- package/dist/x509/name-text.d.ts +7 -9
- package/dist/x509/name-text.js +18 -4
- package/dist/x509/name-text.js.map +1 -1
- package/dist/x509/name.d.ts +9 -11
- package/dist/x509/name.js +18 -19
- package/dist/x509/name.js.map +1 -1
- package/dist/x509/parse.d.ts +84 -69
- package/dist/x509/parse.js +421 -400
- package/dist/x509/parse.js.map +1 -1
- package/dist/x509.d.ts +2 -2
- package/package.json +76 -59
package/dist/revocation/crl.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
1
|
+
import { DECODE_REFUSAL_CODES as e, failureResult as t, rethrowIfInvariant as n, successResult as r, throwMicro509Error as i } from "../result/result.js";
|
|
2
|
+
import { decodeFailureResult as a, decodeRefusalOf as o, rethrowDecodeRefusal as s } from "../internal/asn1/decode-refusal.js";
|
|
3
|
+
import { bitString as c, concatBytes as l, explicitContext as u, generalizedTime as d, implicitConstructedContext as f, implicitPrimitiveContext as p, integer as m, integerFromNumber as h, optionalBytesEqual as ee, readElement as g, readRootElement as _, readSequenceChildren as v, sequence as y, time as b, tlv as x } from "../internal/asn1/der.js";
|
|
4
|
+
import { childrenOf as S, decodeBoolean as C, decodeIntegerMagnitude as w, decodeIntegerNumber as T, decodeNonNegativeIntegerBigInt as te, decodeObjectIdentifier as E, decodeString as D, extractBitStringValue as O, hexToBytes as k, parseTime as A, requireElement as j, toHex as M } from "../internal/asn1/asn1.js";
|
|
5
|
+
import { OIDS as N } from "../internal/asn1/oids2.js";
|
|
6
|
+
import { base64Encode as P } from "../internal/shared/base64.js";
|
|
7
|
+
import { pemDecodeOrThrow as F, pemEncode as I } from "../pem/pem.js";
|
|
8
|
+
import { verifySignedDataDetailed as L } from "../internal/crypto/sig-verify.js";
|
|
9
|
+
import { encodeAlgorithmIdentifier as R, getSignatureAlgorithm as ne, signBytes as re } from "../internal/crypto/signing.js";
|
|
10
|
+
import { describeSignatureAlgorithm as z } from "../internal/crypto/algorithm-names.js";
|
|
11
|
+
import { encodeDistributionPointReasonFlagsContent as B, parseDistributionPointReasonFlagsContent as V } from "../internal/x509/extension-bits.js";
|
|
12
|
+
import { parseGeneralName as H, parseGeneralNames as U } from "../internal/x509/general-name.js";
|
|
13
|
+
import { parsePresentedSrvName as W } from "../internal/x509/general-name-profile.js";
|
|
14
|
+
import { nameFieldKeyFromOid as G } from "../internal/x509/name-fields.js";
|
|
15
|
+
import { compareDistinguishedNames as K, compareRelativeDistinguishedNames as q } from "../internal/shared/dn.js";
|
|
16
|
+
import { encodeName as J, encodeRelativeDistinguishedName as Y, isNameInputEmpty as ie } from "../x509/name.js";
|
|
17
|
+
import { encodeCrlDistributionPoints as ae, encodeExtension as X, encodeSubjectAltName as oe, issuerKeyIdentifier as se } from "../x509/extensions.js";
|
|
18
|
+
import { parseCertificateDerOrThrow as ce, parseCertificateFromSource as Z } from "../x509/parse.js";
|
|
19
|
+
// src/revocation/crl.ts
|
|
19
20
|
/**
|
|
20
21
|
* Full CRL lifecycle: create, parse, verify, validate, and revocation check.
|
|
21
22
|
*
|
|
@@ -25,7 +26,7 @@ import { encodeAlgorithmIdentifier as Z, getSignatureAlgorithm as te, signBytes
|
|
|
25
26
|
* @module
|
|
26
27
|
*/
|
|
27
28
|
/** RFC 5280 §5.3.1 CRLReason integer codes, keyed by reason name. */
|
|
28
|
-
const
|
|
29
|
+
const le = {
|
|
29
30
|
unspecified: 0,
|
|
30
31
|
keyCompromise: 1,
|
|
31
32
|
cACompromise: 2,
|
|
@@ -54,8 +55,9 @@ function coversAllDistributionPointReasons(e) {
|
|
|
54
55
|
/**
|
|
55
56
|
* Signs and encodes an X.509 v2 CRL.
|
|
56
57
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
58
|
+
* Always embeds the Authority Key Identifier and CRLNumber extensions
|
|
59
|
+
* (RFC 5280 §5.2), plus delta CRL indicator, issuing distribution point and
|
|
60
|
+
* freshest-CRL extensions as configured.
|
|
59
61
|
*
|
|
60
62
|
* @example
|
|
61
63
|
* ```ts
|
|
@@ -64,7 +66,7 @@ function coversAllDistributionPointReasons(e) {
|
|
|
64
66
|
* const crl = await createCertificateRevocationList({
|
|
65
67
|
* issuer: { commonName: 'Example CA' },
|
|
66
68
|
* signerPrivateKey: caPrivateKey,
|
|
67
|
-
*
|
|
69
|
+
* issuerCertificate: caCertificatePem,
|
|
68
70
|
* thisUpdate: new Date('2025-01-01'),
|
|
69
71
|
* nextUpdate: new Date('2025-02-01'),
|
|
70
72
|
* crlNumber: 42,
|
|
@@ -75,25 +77,29 @@ function coversAllDistributionPointReasons(e) {
|
|
|
75
77
|
* // crl.pem, crl.der, crl.base64
|
|
76
78
|
* ```
|
|
77
79
|
*/
|
|
78
|
-
async function createCertificateRevocationList(
|
|
79
|
-
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
80
|
+
async function createCertificateRevocationList(e) {
|
|
81
|
+
ie(e.issuer) && throwCrlEncoderError("issuer_distinguished_name_empty", "issuer must be a non-empty distinguished name");
|
|
82
|
+
let t = issuerCertificateOf(e.issuerCertificate), n = encodeCrlNumber(e.crlNumber, "crlNumber"), r = e.baseCrlNumber === void 0 ? void 0 : encodeCrlNumber(e.baseCrlNumber, "baseCrlNumber"), i = ne(e.signerPrivateKey), a = e.thisUpdate ?? /* @__PURE__ */ new Date(), o = e.nextUpdate;
|
|
83
|
+
assertCrlDate(a, "thisUpdate"), assertCrlDate(o, "nextUpdate");
|
|
84
|
+
for (let t of e.revokedCertificates ?? []) assertCrlDate(t.revocationDate, "revocationDate"), assertCrlDate(t.invalidityDate, "invalidityDate");
|
|
85
|
+
Math.floor(o.getTime() / 1e3) <= Math.floor(a.getTime() / 1e3) && throwCrlEncoderError("next_update_not_after_this_update", "nextUpdate must be at least one second later than thisUpdate");
|
|
86
|
+
let s = buildCrlExtensions(t, n, r, e.issuingDistributionPoint, e.freshestCrlDistributionPoints), l = e.revokedCertificates ?? [], d = l.length === 0 ? [] : [y(l.map((e) => createRevokedCertificate(e, a)))], f = y([
|
|
87
|
+
h(1),
|
|
88
|
+
R(i),
|
|
89
|
+
J(e.issuer),
|
|
90
|
+
b(a),
|
|
91
|
+
b(o),
|
|
92
|
+
...d,
|
|
93
|
+
u(0, y(s))
|
|
94
|
+
]), p = await re(e.signerPrivateKey, i, f), m = y([
|
|
95
|
+
f,
|
|
96
|
+
R(i),
|
|
97
|
+
c(p)
|
|
92
98
|
]);
|
|
93
99
|
return {
|
|
94
100
|
der: m,
|
|
95
|
-
pem:
|
|
96
|
-
base64:
|
|
101
|
+
pem: I("X509 CRL", m),
|
|
102
|
+
base64: P(m)
|
|
97
103
|
};
|
|
98
104
|
}
|
|
99
105
|
/**
|
|
@@ -103,19 +109,19 @@ async function createCertificateRevocationList(t) {
|
|
|
103
109
|
* {@linkcode validateCertificateRevocationList} for that.
|
|
104
110
|
*/
|
|
105
111
|
function parseCertificateRevocationListDerOrThrow(e) {
|
|
106
|
-
let t =
|
|
112
|
+
let t = v(e, { maxDepth: 64 });
|
|
107
113
|
if (t.length !== 3) throw Error("Malformed CRL");
|
|
108
|
-
let n =
|
|
114
|
+
let n = j(t[0], "TBSCertList"), r = j(t[1], "signatureAlgorithm"), i = j(t[2], "signatureValue"), a = parseSignedCrlFields(e.slice(n.start - n.headerLength, n.end)), o = parseAlgorithmIdentifier(e, r);
|
|
109
115
|
return assertMatchingCrlSignatureAlgorithms(a.signature, o), {
|
|
110
116
|
der: new Uint8Array(e),
|
|
111
117
|
version: a.version,
|
|
112
118
|
tbsCertListDer: e.slice(n.start - n.headerLength, n.end),
|
|
113
|
-
signatureValue:
|
|
119
|
+
signatureValue: O(i),
|
|
114
120
|
issuer: a.issuer,
|
|
115
121
|
thisUpdate: a.thisUpdate,
|
|
116
122
|
...a.nextUpdate === void 0 ? {} : { nextUpdate: a.nextUpdate },
|
|
117
123
|
signatureAlgorithmOid: o.oid,
|
|
118
|
-
signatureAlgorithmName:
|
|
124
|
+
signatureAlgorithmName: z(o.oid, o.parametersDer),
|
|
119
125
|
...o.parametersDer === void 0 ? {} : { signatureAlgorithmParametersDer: o.parametersDer },
|
|
120
126
|
...a.authorityKeyIdentifier === void 0 ? {} : { authorityKeyIdentifier: a.authorityKeyIdentifier },
|
|
121
127
|
...a.crlNumber === void 0 ? {} : { crlNumber: a.crlNumber },
|
|
@@ -137,7 +143,7 @@ function parseCertificateRevocationListDerOrThrow(e) {
|
|
|
137
143
|
* ```
|
|
138
144
|
*/
|
|
139
145
|
function parseCertificateRevocationListPemOrThrow(e) {
|
|
140
|
-
return parseCertificateRevocationListDerOrThrow(
|
|
146
|
+
return parseCertificateRevocationListDerOrThrow(F("X509 CRL", e));
|
|
141
147
|
}
|
|
142
148
|
/**
|
|
143
149
|
* Decodes a DER-encoded X.509 CRL into a structured {@linkcode ParsedCertificateRevocationList}.
|
|
@@ -147,11 +153,11 @@ function parseCertificateRevocationListPemOrThrow(e) {
|
|
|
147
153
|
* Does not verify the signature — call {@linkcode verifyCertificateRevocationListSignature} or
|
|
148
154
|
* {@linkcode validateCertificateRevocationList} for that.
|
|
149
155
|
*/
|
|
150
|
-
function parseCertificateRevocationListDer(
|
|
156
|
+
function parseCertificateRevocationListDer(t) {
|
|
151
157
|
try {
|
|
152
|
-
return
|
|
153
|
-
} catch (
|
|
154
|
-
return
|
|
158
|
+
return r(parseCertificateRevocationListDerOrThrow(t));
|
|
159
|
+
} catch (t) {
|
|
160
|
+
return n(t), a(t, e, "Malformed CRL");
|
|
155
161
|
}
|
|
156
162
|
}
|
|
157
163
|
/**
|
|
@@ -160,11 +166,11 @@ function parseCertificateRevocationListDer(e) {
|
|
|
160
166
|
* Returns a typed failure (`code: 'malformed'`) on malformed input. For the
|
|
161
167
|
* throwing form use {@linkcode parseCertificateRevocationListPemOrThrow}.
|
|
162
168
|
*/
|
|
163
|
-
function parseCertificateRevocationListPem(
|
|
169
|
+
function parseCertificateRevocationListPem(t) {
|
|
164
170
|
try {
|
|
165
|
-
return
|
|
166
|
-
} catch (
|
|
167
|
-
return
|
|
171
|
+
return r(parseCertificateRevocationListPemOrThrow(t));
|
|
172
|
+
} catch (t) {
|
|
173
|
+
return n(t), a(t, e, "Malformed CRL");
|
|
168
174
|
}
|
|
169
175
|
}
|
|
170
176
|
/**
|
|
@@ -173,58 +179,88 @@ function parseCertificateRevocationListPem(e) {
|
|
|
173
179
|
* Does **not** check issuer name match, key-usage, or freshness — use
|
|
174
180
|
* {@linkcode validateCertificateRevocationList} for full validation.
|
|
175
181
|
*/
|
|
176
|
-
async function verifyCertificateRevocationListSignature(
|
|
177
|
-
let
|
|
182
|
+
async function verifyCertificateRevocationListSignature(t, n) {
|
|
183
|
+
let r, i;
|
|
178
184
|
try {
|
|
179
|
-
|
|
180
|
-
} catch {
|
|
181
|
-
|
|
185
|
+
r = typeof t == "string" ? parseCertificateRevocationListPemOrThrow(t) : parseCertificateRevocationListDerOrThrow(new Uint8Array(t)), i = typeof n == "string" ? parseIssuerCertificatePem(n) : parseIssuerCertificateDer(new Uint8Array(n));
|
|
186
|
+
} catch (t) {
|
|
187
|
+
let n = o(t, e);
|
|
188
|
+
return n === void 0 ? verifyCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list or issuer certificate input is malformed") : verifyCertificateRevocationListFailureResult(n.code, n.message);
|
|
182
189
|
}
|
|
183
|
-
let
|
|
190
|
+
let a;
|
|
184
191
|
try {
|
|
185
|
-
|
|
186
|
-
} catch {
|
|
187
|
-
|
|
192
|
+
a = await L(r.signatureAlgorithmOid, r.signatureAlgorithmParametersDer, i.publicKeyAlgorithmOid, i.publicKeyParametersOid, i.subjectPublicKeyInfoDer, r.signatureValue, r.tbsCertListDer);
|
|
193
|
+
} catch (t) {
|
|
194
|
+
let n = o(t, e);
|
|
195
|
+
return n === void 0 ? verifyCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature verification failed") : verifyCertificateRevocationListFailureResult(n.code, n.message);
|
|
188
196
|
}
|
|
189
|
-
return
|
|
197
|
+
return a.ok ? a.valid ? {
|
|
190
198
|
ok: !0,
|
|
191
|
-
value:
|
|
192
|
-
} : verifyCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature does not verify") :
|
|
199
|
+
value: r
|
|
200
|
+
} : verifyCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature does not verify") : a.code === "verification_error" ? verifyCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature verification failed") : verifyCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature uses unsupported algorithm parameters");
|
|
193
201
|
}
|
|
194
202
|
/**
|
|
195
203
|
* Full CRL validation: issuer name match, authority key identifier match,
|
|
196
|
-
*
|
|
197
|
-
*
|
|
204
|
+
* a v3 issuer certificate's key usage must be present and assert cRLSign
|
|
205
|
+
* (RFC 10007 §4), signature verification, `thisUpdate`/`nextUpdate`
|
|
206
|
+
* freshness check (with optional clock-skew tolerance), and the optional
|
|
207
|
+
* `maxAgeMs` bound on `thisUpdate`. A CRL that omits `nextUpdate` fails with
|
|
208
|
+
* `stale_crl` unless `maxAgeMs` is set.
|
|
198
209
|
*/
|
|
199
210
|
async function validateCertificateRevocationList(e) {
|
|
200
|
-
|
|
211
|
+
assertCrlMaxAge(e.maxAgeMs);
|
|
212
|
+
let t = await authenticateCrl(e.crl, e.issuerCertificate);
|
|
213
|
+
if (!t.ok) return t;
|
|
214
|
+
let n = crlFreshnessFailure(t.value, e.at ?? /* @__PURE__ */ new Date(), e.clockSkewMs ?? 0, e.maxAgeMs);
|
|
215
|
+
return n === void 0 ? t : validateCertificateRevocationListFailureResult("stale_crl", n);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Verifies the issuer binding, cRLSign permission and signature of `crl`
|
|
219
|
+
* against `issuerCertificate`, without freshness checks.
|
|
220
|
+
*
|
|
221
|
+
* @internal
|
|
222
|
+
*/
|
|
223
|
+
async function authenticateCrl(t, n) {
|
|
224
|
+
let r;
|
|
201
225
|
try {
|
|
202
|
-
|
|
203
|
-
} catch {
|
|
204
|
-
|
|
226
|
+
r = normalizeCrl(t);
|
|
227
|
+
} catch (t) {
|
|
228
|
+
let n = o(t, e);
|
|
229
|
+
return n === void 0 ? validateCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signed content is malformed") : validateCertificateRevocationListFailureResult(n.code, n.message);
|
|
205
230
|
}
|
|
206
|
-
let
|
|
231
|
+
let i;
|
|
207
232
|
try {
|
|
208
|
-
|
|
209
|
-
} catch {
|
|
210
|
-
|
|
233
|
+
i = normalizeCrlCertificate(n);
|
|
234
|
+
} catch (t) {
|
|
235
|
+
let n = o(t, e);
|
|
236
|
+
return n === void 0 ? validateCertificateRevocationListFailureResult("signature_invalid", "issuer certificate input is malformed") : validateCertificateRevocationListFailureResult(n.code, n.message);
|
|
211
237
|
}
|
|
212
|
-
if (!
|
|
213
|
-
if (
|
|
214
|
-
if (
|
|
215
|
-
|
|
238
|
+
if (!K(r.issuer, i.subject)) return validateCertificateRevocationListFailureResult("issuer_mismatch", "CRL issuer name does not match certificate subject");
|
|
239
|
+
if (r.authorityKeyIdentifier !== void 0 && i.subjectKeyIdentifier !== void 0 && r.authorityKeyIdentifier !== i.subjectKeyIdentifier) return validateCertificateRevocationListFailureResult("issuer_mismatch", "CRL authority key identifier does not match issuer subject key identifier");
|
|
240
|
+
if (i.keyUsage === void 0 && i.version === 3) return validateCertificateRevocationListFailureResult("crl_sign_not_permitted", "v3 issuer certificate has no key usage extension");
|
|
241
|
+
if (i.keyUsage !== void 0 && !i.keyUsage.flags.includes("cRLSign")) return validateCertificateRevocationListFailureResult("crl_sign_not_permitted", "issuer certificate key usage does not permit CRL signing");
|
|
242
|
+
let a;
|
|
216
243
|
try {
|
|
217
|
-
|
|
218
|
-
} catch {
|
|
219
|
-
|
|
244
|
+
a = await L(r.signatureAlgorithmOid, r.signatureAlgorithmParametersDer, i.publicKeyAlgorithmOid, i.publicKeyParametersOid, i.subjectPublicKeyInfoDer, r.signatureValue, r.tbsCertListDer);
|
|
245
|
+
} catch (t) {
|
|
246
|
+
let n = o(t, e);
|
|
247
|
+
return n === void 0 ? validateCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature verification failed") : validateCertificateRevocationListFailureResult(n.code, n.message);
|
|
220
248
|
}
|
|
221
|
-
|
|
222
|
-
if (!r.valid) return validateCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature does not verify");
|
|
223
|
-
let i = e.at ?? /* @__PURE__ */ new Date(), a = e.clockSkewMs ?? 0;
|
|
224
|
-
return t.thisUpdate.getTime() - a > i.getTime() || t.nextUpdate !== void 0 && t.nextUpdate.getTime() + a < i.getTime() ? validateCertificateRevocationListFailureResult("stale_crl", "CRL is not valid at requested time") : {
|
|
249
|
+
return a.ok ? a.valid ? {
|
|
225
250
|
ok: !0,
|
|
226
|
-
value:
|
|
227
|
-
};
|
|
251
|
+
value: r
|
|
252
|
+
} : validateCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature does not verify") : a.code === "verification_error" ? validateCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature verification failed") : validateCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature uses unsupported algorithm parameters");
|
|
253
|
+
}
|
|
254
|
+
function assertCrlMaxAge(e) {
|
|
255
|
+
if (e !== void 0 && (!Number.isFinite(e) || e < 0)) throw RangeError(`Invalid maxAgeMs: must be a non-negative number, got ${e}`);
|
|
256
|
+
}
|
|
257
|
+
function crlFreshnessFailure(e, t, n, r) {
|
|
258
|
+
if (e.thisUpdate.getTime() - n > t.getTime() || e.nextUpdate !== void 0 && e.nextUpdate.getTime() + n < t.getTime()) return "CRL is not valid at requested time";
|
|
259
|
+
if (e.nextUpdate === void 0 && r === void 0) return "CRL has no nextUpdate and no maximum age is set";
|
|
260
|
+
if (r !== void 0 && t.getTime() - e.thisUpdate.getTime() > r + n) return "CRL thisUpdate is older than the maximum age";
|
|
261
|
+
}
|
|
262
|
+
function isCurrentDeltaCrl(e, t, n, r) {
|
|
263
|
+
return e.nextUpdate !== void 0 && crlFreshnessFailure(e, t, n, r) === void 0;
|
|
228
264
|
}
|
|
229
265
|
/**
|
|
230
266
|
* End-to-end revocation check: validates the CRL (and optional delta CRL),
|
|
@@ -248,33 +284,70 @@ async function validateCertificateRevocationList(e) {
|
|
|
248
284
|
* }
|
|
249
285
|
* ```
|
|
250
286
|
*/
|
|
251
|
-
async function checkCertificateRevocationAgainstCrl(
|
|
252
|
-
|
|
287
|
+
async function checkCertificateRevocationAgainstCrl(t) {
|
|
288
|
+
assertCrlMaxAge(t.maxAgeMs);
|
|
289
|
+
let n;
|
|
253
290
|
try {
|
|
254
|
-
|
|
255
|
-
} catch {
|
|
256
|
-
|
|
291
|
+
n = normalizeCrlCertificate(t.certificate);
|
|
292
|
+
} catch (t) {
|
|
293
|
+
let n = o(t, e);
|
|
294
|
+
return n === void 0 ? checkCertificateRevocationAgainstCrlFailureResult("non_applicable", "certificate input is malformed") : checkCertificateRevocationAgainstCrlFailureResult(n.code, n.message);
|
|
257
295
|
}
|
|
258
|
-
let
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (
|
|
296
|
+
let r = await authenticateCrl(t.crl, t.issuerCertificate);
|
|
297
|
+
if (!r.ok) return checkCertificateRevocationAgainstCrlFailureResult(r.code, r.message);
|
|
298
|
+
let i = await checkRevocationAgainstAuthenticatedCrl(n, r.value, t);
|
|
299
|
+
return i.kind === "checked" ? i.result : i.failure;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Checks `certificate` against a complete CRL that {@linkcode authenticateCrl}
|
|
303
|
+
* accepted for `input.issuerCertificate`, updated by `input.deltaCrl` when given.
|
|
304
|
+
*
|
|
305
|
+
* @internal
|
|
306
|
+
*/
|
|
307
|
+
async function checkRevocationAgainstAuthenticatedCrl(e, t, n) {
|
|
308
|
+
if (n.deltaCrl === void 0) {
|
|
309
|
+
let e = crlFreshnessFailure(t, n.at ?? /* @__PURE__ */ new Date(), n.clockSkewMs ?? 0, n.maxAgeMs);
|
|
310
|
+
if (e !== void 0) return {
|
|
311
|
+
kind: "checked",
|
|
312
|
+
result: checkCertificateRevocationAgainstCrlFailureResult("stale_crl", e)
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
let r = await validateOptionalDeltaCrl(n, t);
|
|
316
|
+
if (!r.ok) return {
|
|
317
|
+
kind: "delta_rejected",
|
|
318
|
+
failure: r
|
|
319
|
+
};
|
|
320
|
+
let i = r.value, a = checkCrlApplicability(e, t);
|
|
321
|
+
if (!a.ok) return {
|
|
322
|
+
kind: "checked",
|
|
323
|
+
result: a.failure
|
|
324
|
+
};
|
|
325
|
+
if (i !== void 0) {
|
|
326
|
+
let t = checkCrlApplicability(e, i, !0);
|
|
327
|
+
if (!t.ok) return {
|
|
328
|
+
kind: "delta_rejected",
|
|
329
|
+
failure: t.failure
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
let o = findRevokedCertificateEntry(e, t);
|
|
333
|
+
if (!o.ok) return {
|
|
334
|
+
kind: "checked",
|
|
335
|
+
result: o
|
|
336
|
+
};
|
|
271
337
|
let s;
|
|
272
|
-
if (
|
|
273
|
-
let
|
|
274
|
-
if (!
|
|
275
|
-
|
|
338
|
+
if (i !== void 0) {
|
|
339
|
+
let r = findRevokedCertificateEntry(e, i);
|
|
340
|
+
if (!r.ok) return {
|
|
341
|
+
kind: "delta_unresolved",
|
|
342
|
+
failure: r,
|
|
343
|
+
complete: resolveCertificateRevocationStatus(e, void 0, t, o.entry, void 0, a.coveredReasons, n.unrecognizedReasonCode ?? "revoked")
|
|
344
|
+
};
|
|
345
|
+
s = r.entry;
|
|
276
346
|
}
|
|
277
|
-
return
|
|
347
|
+
return {
|
|
348
|
+
kind: "checked",
|
|
349
|
+
result: resolveCertificateRevocationStatus(e, i?.thisUpdate, t, o.entry, s, a.coveredReasons, n.unrecognizedReasonCode ?? "revoked")
|
|
350
|
+
};
|
|
278
351
|
}
|
|
279
352
|
/** RFC 5280 §6.3.3 (d): interim_reasons_mask from the matched DP and the CRL's IDP. */
|
|
280
353
|
function interimReasonsMask(e, t) {
|
|
@@ -288,30 +361,33 @@ async function validateOptionalDeltaCrl(e, t) {
|
|
|
288
361
|
crl: e.deltaCrl,
|
|
289
362
|
issuerCertificate: e.issuerCertificate,
|
|
290
363
|
...e.at === void 0 ? {} : { at: e.at },
|
|
291
|
-
...e.clockSkewMs === void 0 ? {} : { clockSkewMs: e.clockSkewMs }
|
|
364
|
+
...e.clockSkewMs === void 0 ? {} : { clockSkewMs: e.clockSkewMs },
|
|
365
|
+
...e.maxAgeMs === void 0 ? {} : { maxAgeMs: e.maxAgeMs }
|
|
292
366
|
});
|
|
293
|
-
|
|
367
|
+
if (!n.ok) return checkCertificateRevocationAgainstCrlFailureResult(n.code, n.message);
|
|
368
|
+
if (n.value.nextUpdate === void 0) return checkCertificateRevocationAgainstCrlFailureResult("stale_crl", "delta CRL has no nextUpdate");
|
|
369
|
+
let r;
|
|
370
|
+
try {
|
|
371
|
+
r = checkDeltaCrlCompatibility(t, n.value);
|
|
372
|
+
} catch (e) {
|
|
373
|
+
return crlNameRefusalFailure(e);
|
|
374
|
+
}
|
|
375
|
+
return r ?? {
|
|
294
376
|
ok: !0,
|
|
295
377
|
value: n.value
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
function checkCrlAndDeltaApplicability(e, t, n) {
|
|
299
|
-
let r = checkCrlApplicability(e, t);
|
|
300
|
-
if (!r.ok || n === void 0) return r;
|
|
301
|
-
let i = checkCrlApplicability(e, n, !0);
|
|
302
|
-
return i.ok ? r : i;
|
|
378
|
+
};
|
|
303
379
|
}
|
|
304
380
|
/** Builds a `VerifyCertificateRevocationListSignatureFailureResult`. */
|
|
305
|
-
function verifyCertificateRevocationListFailureResult(e,
|
|
306
|
-
return
|
|
381
|
+
function verifyCertificateRevocationListFailureResult(e, n) {
|
|
382
|
+
return t(e, n);
|
|
307
383
|
}
|
|
308
384
|
/** Builds a `ValidateCertificateRevocationListFailureResult`. */
|
|
309
|
-
function validateCertificateRevocationListFailureResult(e,
|
|
310
|
-
return
|
|
385
|
+
function validateCertificateRevocationListFailureResult(e, n) {
|
|
386
|
+
return t(e, n);
|
|
311
387
|
}
|
|
312
388
|
/** Builds a `CheckCertificateRevocationAgainstCrlFailureResult`. */
|
|
313
|
-
function checkCertificateRevocationAgainstCrlFailureResult(e,
|
|
314
|
-
return
|
|
389
|
+
function checkCertificateRevocationAgainstCrlFailureResult(e, n, r) {
|
|
390
|
+
return t(e, n, r);
|
|
315
391
|
}
|
|
316
392
|
/** Wraps a success value into a `CheckCertificateRevocationAgainstCrlResult`. */
|
|
317
393
|
function checkCertificateRevocationAgainstCrlSuccess(e) {
|
|
@@ -325,11 +401,18 @@ function checkCertificateRevocationAgainstCrlSuccess(e) {
|
|
|
325
401
|
* CRL's revoked entries. Does **not** validate the CRL or check applicability.
|
|
326
402
|
*/
|
|
327
403
|
function isCertificateRevoked(e, t) {
|
|
328
|
-
let n = typeof e == "string" ? normalizeHex(e) :
|
|
404
|
+
let n = typeof e == "string" ? normalizeHex(e) : M(e);
|
|
329
405
|
return t.revokedCertificates.some((e) => normalizeHex(e.serialNumberHex) === n);
|
|
330
406
|
}
|
|
331
407
|
/** Searches CRL entries for the certificate's serial, respecting indirect-CRL issuer overrides. */
|
|
332
408
|
function findRevokedCertificateEntry(e, t) {
|
|
409
|
+
try {
|
|
410
|
+
return lookupRevokedCertificateEntry(e, t);
|
|
411
|
+
} catch (e) {
|
|
412
|
+
return crlNameRefusalFailure(e);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
function lookupRevokedCertificateEntry(e, t) {
|
|
333
416
|
let n = normalizeHex(e.serialNumberHex), r, i = !1, a;
|
|
334
417
|
for (let o of t.revokedCertificates) {
|
|
335
418
|
if (o.certificateIssuer !== void 0 && (r = o.certificateIssuer), normalizeHex(o.serialNumberHex) !== n) continue;
|
|
@@ -337,26 +420,42 @@ function findRevokedCertificateEntry(e, t) {
|
|
|
337
420
|
if (s === "match") {
|
|
338
421
|
if (a !== void 0) return checkCertificateRevocationAgainstCrlFailureResult("signature_invalid", "CRL contains multiple revoked entries for certificate");
|
|
339
422
|
a = o;
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
s === "unsupported" && (i = !0);
|
|
423
|
+
} else s === "unsupported" && (i = !0);
|
|
343
424
|
}
|
|
344
425
|
return a === void 0 ? i ? nonApplicable("unsupported_indirect_crl", "indirect CRL entry certificateIssuer must include a directoryName") : { ok: !0 } : {
|
|
345
426
|
ok: !0,
|
|
346
427
|
entry: a
|
|
347
428
|
};
|
|
348
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* Whether `crl` covers `certificate` under {@linkcode checkCrlApplicability}.
|
|
432
|
+
*
|
|
433
|
+
* @internal
|
|
434
|
+
*/
|
|
435
|
+
function isCrlApplicableTo(e, t) {
|
|
436
|
+
return checkCrlApplicability(e, t).ok;
|
|
437
|
+
}
|
|
349
438
|
/** RFC 5280 §6.3 CRL applicability: scope, distribution-point, reason, and indirect-CRL checks. */
|
|
350
439
|
function checkCrlApplicability(e, t, n = !1) {
|
|
440
|
+
try {
|
|
441
|
+
return evaluateCrlApplicability(e, t, n);
|
|
442
|
+
} catch (e) {
|
|
443
|
+
return {
|
|
444
|
+
ok: !1,
|
|
445
|
+
failure: crlNameRefusalFailure(e)
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
function evaluateCrlApplicability(e, t, n) {
|
|
351
450
|
if (!n && t.baseCrlNumber !== void 0) return notApplicableOutcome("unsupported_delta_crl", "a delta CRL cannot be used as the primary complete CRL input");
|
|
352
451
|
let r = t.issuingDistributionPoint, i = r?.indirectCrl === !0;
|
|
353
|
-
if (!i && !
|
|
452
|
+
if (!i && !K(e.issuer, t.issuer)) return notApplicableOutcome("issuer_mismatch", "CRL issuer does not match certificate issuer for direct CRL processing");
|
|
354
453
|
if (r?.onlyContainsAttributeCerts === !0) return notApplicableOutcome("certificate_scope_mismatch", "attribute-certificate-only CRLs are not applicable to public-key certificates");
|
|
355
454
|
let a = e.basicConstraints?.ca === !0;
|
|
356
455
|
if (r?.onlyContainsUserCerts === !0 && a) return notApplicableOutcome("certificate_scope_mismatch", "CRL only applies to end-entity certificates");
|
|
357
456
|
if (r?.onlyContainsCACerts === !0 && !a) return notApplicableOutcome("certificate_scope_mismatch", "CRL only applies to CA certificates");
|
|
358
457
|
let o = e.crlDistributionPoints ?? [];
|
|
359
|
-
if (o.length === 0) return r?.distributionPoint !== void 0 && !matchesDistributionPointName(issuerFallbackDistributionPointName(e), r.distributionPoint, t.issuer, void 0) ? notApplicableOutcome("distribution_point_mismatch", "CRL issuing distribution point does not name the certificate issuer") : i && !
|
|
458
|
+
if (o.length === 0) return r?.distributionPoint !== void 0 && !matchesDistributionPointName(issuerFallbackDistributionPointName(e), r.distributionPoint, t.issuer, void 0) ? notApplicableOutcome("distribution_point_mismatch", "CRL issuing distribution point does not name the certificate issuer") : i && !K(e.issuer, t.issuer) ? notApplicableOutcome("issuer_mismatch", "indirect CRLs for alternate certificate issuers require matching CRLIssuer distribution points") : {
|
|
360
459
|
ok: !0,
|
|
361
460
|
coveredReasons: interimReasonsMask(void 0, r)
|
|
362
461
|
};
|
|
@@ -403,9 +502,7 @@ function scanCrlDistributionPoints(e, t, n, r, i) {
|
|
|
403
502
|
if (e === "matched") {
|
|
404
503
|
s = !0;
|
|
405
504
|
for (let e of interimReasonsMask(c, r)) a.add(e);
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
o.add(e);
|
|
505
|
+
} else o.add(e);
|
|
409
506
|
}
|
|
410
507
|
return s ? { coveredReasons: [...a] } : resolveScanFailure(o);
|
|
411
508
|
}
|
|
@@ -425,7 +522,7 @@ function scanCrlDistributionPoint(e, t, n, r, i) {
|
|
|
425
522
|
}
|
|
426
523
|
function scanCrlDistributionPointIssuer(e, t, n, r) {
|
|
427
524
|
if (!r) return e.crlIssuer === void 0 ? void 0 : "indirect_distribution_point";
|
|
428
|
-
if (
|
|
525
|
+
if (K(t.issuer, n.issuer) && e.crlIssuer === void 0) return;
|
|
429
526
|
let i = matchesIndirectCrlIssuer(e.crlIssuer, n);
|
|
430
527
|
return i === "unsupported" ? "unsupported_indirect_crl_issuer" : i ? void 0 : "indirect_issuer_mismatch";
|
|
431
528
|
}
|
|
@@ -436,37 +533,30 @@ function crlDistributionPointScanFailure(e) {
|
|
|
436
533
|
function checkDeltaCrlCompatibility(e, t) {
|
|
437
534
|
if (e.baseCrlNumber !== void 0) return nonApplicable("delta_crl_incompatible", "complete CRL input must not itself be a delta CRL");
|
|
438
535
|
if (t.baseCrlNumber === void 0) return nonApplicable("delta_crl_incompatible", "delta CRL input must include a delta CRL indicator");
|
|
439
|
-
if (!
|
|
536
|
+
if (!K(e.issuer, t.issuer)) return nonApplicable("delta_crl_incompatible", "complete and delta CRLs must share the same issuer");
|
|
440
537
|
if (e.authorityKeyIdentifier !== t.authorityKeyIdentifier) return nonApplicable("delta_crl_incompatible", "complete and delta CRLs must share the same authority key identifier");
|
|
441
538
|
if (!sameIssuingDistributionPoint(e.issuingDistributionPoint, t.issuingDistributionPoint)) return nonApplicable("delta_crl_incompatible", "complete and delta CRLs must share the same issuing distribution point scope");
|
|
442
539
|
if (e.crlNumber === void 0 || t.crlNumber === void 0) return nonApplicable("delta_crl_incompatible", "complete and delta CRLs must both carry CRL numbers for delta processing");
|
|
443
540
|
if (e.crlNumber < t.baseCrlNumber) return nonApplicable("delta_crl_incompatible", "delta CRL base number must not exceed the complete CRL number");
|
|
444
541
|
if (e.crlNumber >= t.crlNumber) return nonApplicable("delta_crl_incompatible", "delta CRL number must be newer than the complete CRL number");
|
|
542
|
+
if (e.thisUpdate.getTime() > t.thisUpdate.getTime()) return nonApplicable("delta_crl_incompatible", "delta CRL thisUpdate must not precede the complete CRL thisUpdate");
|
|
445
543
|
}
|
|
446
544
|
/** Checks whether any `crlIssuer` GeneralName matches the CRL's issuer via directoryName DER comparison. */
|
|
447
545
|
function matchesIndirectCrlIssuer(e, t) {
|
|
448
546
|
if (e === void 0) return !1;
|
|
449
547
|
let n = !1;
|
|
450
|
-
for (let r of e) {
|
|
451
|
-
if (r.
|
|
452
|
-
|
|
453
|
-
continue;
|
|
454
|
-
}
|
|
455
|
-
n = !0;
|
|
456
|
-
}
|
|
548
|
+
for (let r of e) if (r.type === "directoryName") {
|
|
549
|
+
if (directoryNameDerHexMatchesParsedName(r.derHex, t.issuer)) return !0;
|
|
550
|
+
} else n = !0;
|
|
457
551
|
return n ? "unsupported" : !1;
|
|
458
552
|
}
|
|
459
553
|
/** Determines whether a revoked entry's effective issuer matches the certificate's issuer. */
|
|
460
554
|
function matchesRevokedEntryIssuer(e, t, n) {
|
|
461
|
-
if (n === void 0) return
|
|
555
|
+
if (n === void 0) return K(e.issuer, t.issuer) ? "match" : "mismatch";
|
|
462
556
|
let r = !1;
|
|
463
|
-
for (let t of n) {
|
|
464
|
-
if (t.
|
|
465
|
-
|
|
466
|
-
continue;
|
|
467
|
-
}
|
|
468
|
-
r = !0;
|
|
469
|
-
}
|
|
557
|
+
for (let t of n) if (t.type === "directoryName") {
|
|
558
|
+
if (directoryNameDerHexMatchesParsedName(t.derHex, e.issuer)) return "match";
|
|
559
|
+
} else r = !0;
|
|
470
560
|
return r ? "unsupported" : "mismatch";
|
|
471
561
|
}
|
|
472
562
|
/** Shorthand for building a `non_applicable` failure result with the given reason. */
|
|
@@ -482,28 +572,28 @@ function nonApplicable(e, t) {
|
|
|
482
572
|
* emit it, a complete-CRL `certificateHold` entry or a certificate that
|
|
483
573
|
* expired before the delta CRL's thisUpdate.
|
|
484
574
|
*/
|
|
485
|
-
function resolveCertificateRevocationStatus(e, t, n, r, i, a) {
|
|
486
|
-
if (i !== void 0)
|
|
487
|
-
if (
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
...i.reasonCode === void 0 ? {} : { reasonCode: i.reasonCode }
|
|
497
|
-
});
|
|
498
|
-
return checkCertificateRevocationAgainstCrlSuccess(r === void 0 ? {
|
|
575
|
+
function resolveCertificateRevocationStatus(e, t, n, r, i, a, o) {
|
|
576
|
+
if (i !== void 0) {
|
|
577
|
+
if (i.reasonCode === "removeFromCRL") {
|
|
578
|
+
if (r?.reasonCode === "certificateHold" || t !== void 0 && e.notAfter.getTime() < t.getTime()) return checkCertificateRevocationAgainstCrlSuccess({
|
|
579
|
+
status: "good",
|
|
580
|
+
crl: n,
|
|
581
|
+
coveredReasons: a
|
|
582
|
+
});
|
|
583
|
+
} else return revokedEntryResult(n, i, o);
|
|
584
|
+
}
|
|
585
|
+
return r === void 0 ? checkCertificateRevocationAgainstCrlSuccess({
|
|
499
586
|
status: "good",
|
|
500
587
|
crl: n,
|
|
501
588
|
coveredReasons: a
|
|
502
|
-
} :
|
|
589
|
+
}) : revokedEntryResult(n, r, o);
|
|
590
|
+
}
|
|
591
|
+
function revokedEntryResult(e, t, n) {
|
|
592
|
+
return n === "reject" && typeof t.reasonCode == "object" ? checkCertificateRevocationAgainstCrlFailureResult("reason_code_unrecognized", `CRL entry carries unrecognized reason code ${String(t.reasonCode.code)}`) : checkCertificateRevocationAgainstCrlSuccess({
|
|
503
593
|
status: "revoked",
|
|
504
|
-
crl:
|
|
505
|
-
revocationDate:
|
|
506
|
-
...
|
|
594
|
+
crl: e,
|
|
595
|
+
revocationDate: t.revocationDate,
|
|
596
|
+
...t.reasonCode === void 0 ? {} : { reasonCode: t.reasonCode }
|
|
507
597
|
});
|
|
508
598
|
}
|
|
509
599
|
/**
|
|
@@ -521,7 +611,7 @@ function matchesDistributionPointName(e, t, n, r) {
|
|
|
521
611
|
let r = resolveRelativeNameToDnHex(n, e.relativeName);
|
|
522
612
|
return t.fullName.some((e) => e.type === "directoryName" && e.derHex === r);
|
|
523
613
|
}
|
|
524
|
-
if (e.type === "relativeName" && t.type === "relativeName") return
|
|
614
|
+
if (e.type === "relativeName" && t.type === "relativeName") return q(e.relativeName, t.relativeName);
|
|
525
615
|
if (e.type === "fullName" && t.type === "relativeName") {
|
|
526
616
|
let r = resolveRelativeNameToDnHex(n, t.relativeName);
|
|
527
617
|
return e.fullName.some((e) => e.type === "directoryName" && e.derHex === r);
|
|
@@ -541,12 +631,13 @@ function matchesIdpNameAgainstCrlIssuer(e, t, n) {
|
|
|
541
631
|
}
|
|
542
632
|
/** Constructs a full DN by appending an RDN to an existing Name, returning hex-encoded DER. */
|
|
543
633
|
function resolveRelativeNameToDnHex(e, t) {
|
|
544
|
-
let n = e.rdns.map((e) =>
|
|
545
|
-
return n.push(r),
|
|
634
|
+
let n = e.rdns.map((e) => k(e.derHex)), r = rebuildRelativeNameAsSet(k(t.derHex));
|
|
635
|
+
return n.push(r), M(y(n));
|
|
546
636
|
}
|
|
547
637
|
/** Converts an implicit-tagged [1] relativeName to a proper SET-tagged RDN. */
|
|
548
638
|
function rebuildRelativeNameAsSet(e) {
|
|
549
|
-
|
|
639
|
+
let t = _(e, { maxDepth: 64 });
|
|
640
|
+
return x(49, t.value);
|
|
550
641
|
}
|
|
551
642
|
/** Deep-compares two issuing distribution point extensions for delta-CRL compatibility. */
|
|
552
643
|
function sameIssuingDistributionPoint(e, t) {
|
|
@@ -554,7 +645,7 @@ function sameIssuingDistributionPoint(e, t) {
|
|
|
554
645
|
}
|
|
555
646
|
/** Compares two DistributionPointName values (fullName set or relativeName). */
|
|
556
647
|
function sameDistributionPointName(e, t) {
|
|
557
|
-
return e === void 0 || t === void 0 ? e === t : e.type === "fullName" && t.type === "fullName" ? sameGeneralNameSet(e.fullName, t.fullName) : e.type === "relativeName" && t.type === "relativeName" &&
|
|
648
|
+
return e === void 0 || t === void 0 ? e === t : e.type === "fullName" && t.type === "fullName" ? sameGeneralNameSet(e.fullName, t.fullName) : e.type === "relativeName" && t.type === "relativeName" && q(e.relativeName, t.relativeName);
|
|
558
649
|
}
|
|
559
650
|
/** Set-equality comparison for GeneralName arrays (order-independent). */
|
|
560
651
|
function sameGeneralNameSet(e, t) {
|
|
@@ -583,15 +674,24 @@ function hasOverlappingReasons(e, t) {
|
|
|
583
674
|
}
|
|
584
675
|
/** Value-equality for two GeneralName entries, using DER comparison for directoryName. */
|
|
585
676
|
function compareGeneralNames(e, t) {
|
|
586
|
-
if (e.type === "dns" && t.type === "dns"
|
|
677
|
+
if (e.type === "dns" && t.type === "dns") return e.value.toLowerCase() === t.value.toLowerCase();
|
|
678
|
+
if (e.type === "srv" && t.type === "srv") return compareSrvNames(e.value.toLowerCase(), t.value.toLowerCase());
|
|
587
679
|
if (e.type === "email" && t.type === "email") return compareRfc822Names(e.value, t.value);
|
|
588
|
-
if (e.type === "ip" && t.type === "ip") return e.value === t.value;
|
|
680
|
+
if (e.type === "smtpUtf8Mailbox" && t.type === "smtpUtf8Mailbox" || e.type === "ip" && t.type === "ip") return e.value === t.value;
|
|
589
681
|
if (e.type === "uri" && t.type === "uri") return compareUniformResourceIdentifiers(e.value, t.value);
|
|
590
682
|
if (e.type === "directoryName" && t.type === "directoryName") {
|
|
591
683
|
let n = parseDerHexName(e.derHex), r = parseDerHexName(t.derHex);
|
|
592
|
-
return n === void 0 || r === void 0 ? !1 :
|
|
684
|
+
return n === void 0 || r === void 0 ? !1 : K(n, r);
|
|
593
685
|
}
|
|
594
|
-
return
|
|
686
|
+
return compareOpaqueGeneralNames(e, t);
|
|
687
|
+
}
|
|
688
|
+
function compareSrvNames(e, t) {
|
|
689
|
+
let n = W(e), r = W(t);
|
|
690
|
+
return n === void 0 || r === void 0 ? e === t : n.service === r.service && n.name === r.name;
|
|
691
|
+
}
|
|
692
|
+
/** Encoding equality for the GeneralName alternatives carried as DER or an OID. */
|
|
693
|
+
function compareOpaqueGeneralNames(e, t) {
|
|
694
|
+
return e.type === "otherName" && t.type === "otherName" ? e.typeId === t.typeId && bytesEqual(e.value, t.value) : e.type === "upn" && t.type === "upn" ? e.value === t.value : e.type === "krb5PrincipalName" && t.type === "krb5PrincipalName" ? e.realm === t.realm && e.nameType === t.nameType && e.nameString.length === t.nameString.length && e.nameString.every((e, n) => e === t.nameString[n]) : e.type === "x400Address" && t.type === "x400Address" || e.type === "ediPartyName" && t.type === "ediPartyName" ? bytesEqual(e.value, t.value) : e.type === "registeredID" && t.type === "registeredID" ? e.value === t.value : e.type === "unknown" && t.type === "unknown" && e.tag === t.tag && bytesEqual(e.value, t.value);
|
|
595
695
|
}
|
|
596
696
|
/** RFC 5280 §7.5: rfc822Name local-part is case-sensitive, the host-part case-insensitive. */
|
|
597
697
|
function compareRfc822Names(e, t) {
|
|
@@ -609,7 +709,7 @@ function compareUniformResourceIdentifiers(e, t) {
|
|
|
609
709
|
* the default port that scheme-based normalization elides. `ldaps` is included
|
|
610
710
|
* as the TLS form of the mandatory `ldap` scheme.
|
|
611
711
|
*/
|
|
612
|
-
const
|
|
712
|
+
const ue = /* @__PURE__ */ new Map([
|
|
613
713
|
["ftp", "21"],
|
|
614
714
|
["http", "80"],
|
|
615
715
|
["https", "443"],
|
|
@@ -638,7 +738,7 @@ function normalizeUriForComparison(e) {
|
|
|
638
738
|
if (e === void 0) return;
|
|
639
739
|
t.hostname = e;
|
|
640
740
|
}
|
|
641
|
-
return t.port ===
|
|
741
|
+
return t.port === ue.get(t.protocol.slice(0, -1)) && (t.port = ""), normalizePercentEncoding(t.href);
|
|
642
742
|
}
|
|
643
743
|
/**
|
|
644
744
|
* Reparses a host under a special scheme so the URL parser applies IDNA and
|
|
@@ -662,10 +762,10 @@ function decodeHostPercentEncoding(e) {
|
|
|
662
762
|
return e;
|
|
663
763
|
}
|
|
664
764
|
}
|
|
665
|
-
const
|
|
765
|
+
const de = /%[0-9A-Fa-f]{2}/g;
|
|
666
766
|
/** RFC 3986 §6.2.2.2: unreserved triplets decode, every other triplet uppercases. */
|
|
667
767
|
function normalizePercentEncoding(e) {
|
|
668
|
-
return e.replace(
|
|
768
|
+
return e.replace(de, (e) => {
|
|
669
769
|
let t = Number.parseInt(e.slice(1), 16);
|
|
670
770
|
return isUnreservedUriCharacter(t) ? String.fromCharCode(t) : e.toUpperCase();
|
|
671
771
|
});
|
|
@@ -680,51 +780,30 @@ function bytesEqual(e, t) {
|
|
|
680
780
|
for (let n = 0; n < e.length; n += 1) if (e[n] !== t[n]) return !1;
|
|
681
781
|
return !0;
|
|
682
782
|
}
|
|
683
|
-
/** Set-equality comparison for RDN attribute sets (order-independent, RFC 4518 string prep). */
|
|
684
|
-
function compareRelativeDistinguishedNames(e, t) {
|
|
685
|
-
if (e.attributes.length !== t.attributes.length) return !1;
|
|
686
|
-
let n = Array.from({ length: t.attributes.length }, () => !1);
|
|
687
|
-
for (let r of e.attributes) {
|
|
688
|
-
let e = !1;
|
|
689
|
-
for (let i = 0; i < t.attributes.length; i += 1) {
|
|
690
|
-
let a = t.attributes[i];
|
|
691
|
-
if (!(a === void 0 || n[i]) && R(r, a)) {
|
|
692
|
-
n[i] = !0, e = !0;
|
|
693
|
-
break;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
if (!e) return !1;
|
|
697
|
-
}
|
|
698
|
-
return !0;
|
|
699
|
-
}
|
|
700
783
|
/** Assembles the CRL-level v2 extensions (AKI, CRLNumber, deltaCRLIndicator, IDP, freshestCRL). */
|
|
701
|
-
|
|
702
|
-
let
|
|
703
|
-
|
|
704
|
-
let t = await M(e);
|
|
705
|
-
o.push(W(T.authorityKeyIdentifier, f([a(0, H(t))])));
|
|
706
|
-
}
|
|
707
|
-
return t !== void 0 && o.push(W(T.cRLNumber, s(t))), n !== void 0 && o.push(W(T.deltaCRLIndicator, s(n), !0)), r !== void 0 && o.push(W(T.issuingDistributionPoint, encodeIssuingDistributionPoint(r), !0)), i !== void 0 && i.length > 0 && o.push(W(T.freshestCRL, U(i))), o;
|
|
784
|
+
function buildCrlExtensions(e, t, n, r, i) {
|
|
785
|
+
let a = [X(N.authorityKeyIdentifier, y([p(0, se(e))])), X(N.cRLNumber, t)];
|
|
786
|
+
return n !== void 0 && a.push(X(N.deltaCRLIndicator, n, !0)), r !== void 0 && a.push(X(N.issuingDistributionPoint, encodeIssuingDistributionPoint(r), !0)), i !== void 0 && i.length > 0 && a.push(X(N.freshestCRL, ae(i))), a;
|
|
708
787
|
}
|
|
709
788
|
/** DER-encodes a single revokedCertificate SEQUENCE (serial, date, optional extensions). */
|
|
710
789
|
function createRevokedCertificate(e, t) {
|
|
711
790
|
let n = buildRevokedCertificateExtensions(e);
|
|
712
|
-
return
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
...n.length === 0 ? [] : [
|
|
791
|
+
return y([
|
|
792
|
+
m(e.serialNumber),
|
|
793
|
+
b(e.revocationDate ?? t),
|
|
794
|
+
...n.length === 0 ? [] : [y(n)]
|
|
716
795
|
]);
|
|
717
796
|
}
|
|
718
797
|
/** Encodes CRL entry extensions (reasonCode, invalidityDate). */
|
|
719
798
|
function buildRevokedCertificateExtensions(e) {
|
|
720
799
|
let t = [];
|
|
721
|
-
return e.reasonCode !== void 0 && t.push(
|
|
800
|
+
return e.reasonCode !== void 0 && t.push(X(N.cRLReason, x(10, Uint8Array.of(le[e.reasonCode])))), e.invalidityDate !== void 0 && t.push(X(N.invalidityDate, d(e.invalidityDate))), t;
|
|
722
801
|
}
|
|
723
802
|
/** Decodes per-entry CRL extensions (reasonCode, invalidityDate, certificateIssuer). */
|
|
724
803
|
function parseRevokedCertificateExtensions(e, t) {
|
|
725
804
|
if (e === void 0 || t === void 0) return {};
|
|
726
805
|
let n = {}, r = /* @__PURE__ */ new Set();
|
|
727
|
-
for (let i of
|
|
806
|
+
for (let i of S(e, t)) parseRevokedCertificateExtension(e, i, r, n);
|
|
728
807
|
return {
|
|
729
808
|
...n.reasonCode === void 0 ? {} : { reasonCode: n.reasonCode },
|
|
730
809
|
...n.invalidityDate === void 0 ? {} : { invalidityDate: n.invalidityDate },
|
|
@@ -732,30 +811,37 @@ function parseRevokedCertificateExtensions(e, t) {
|
|
|
732
811
|
};
|
|
733
812
|
}
|
|
734
813
|
function parseRevokedCertificateExtension(e, t, n, r) {
|
|
735
|
-
let i =
|
|
814
|
+
let i = S(e, t);
|
|
736
815
|
if (i.length < 2 || i.length > 3 || i.length === 3 && i[1]?.tag !== 1) throw Error("Malformed revoked certificate extension");
|
|
737
|
-
let a =
|
|
816
|
+
let a = E(j(i[0], "revoked certificate extension OID").value);
|
|
738
817
|
if (n.has(a)) throw Error(`Duplicate revoked certificate extension OID: ${a}`);
|
|
739
818
|
n.add(a);
|
|
740
|
-
let o = C(i[i.length - 1], "revoked certificate extension value");
|
|
741
|
-
if (
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
819
|
+
let o = i.length === 3 && C(j(i[1], "revoked certificate extension critical").value), s = j(i[i.length - 1], "revoked certificate extension value");
|
|
820
|
+
if (s.tag !== 4) throw Error("Revoked certificate extension value must use OCTET STRING");
|
|
821
|
+
if (o && !isSupportedRevokedCertificateExtensionOid(a)) throw Error(`Unsupported critical revoked certificate extension OID: ${a}`);
|
|
822
|
+
applyRevokedCertificateExtensionValue(a, s.value, o, r);
|
|
823
|
+
}
|
|
824
|
+
function isSupportedRevokedCertificateExtensionOid(e) {
|
|
825
|
+
return e === N.cRLReason || e === N.invalidityDate || e === N.certificateIssuer;
|
|
826
|
+
}
|
|
827
|
+
function applyRevokedCertificateExtensionValue(e, t, n, r) {
|
|
828
|
+
if (e === N.cRLReason) {
|
|
829
|
+
let e = _(t, { maxDepth: 64 });
|
|
830
|
+
if (e.tag !== 10) throw Error("cRLReason must use ENUMERATED");
|
|
831
|
+
let i = parsedRevocationReason(te(e.value, "cRLReason"));
|
|
832
|
+
if (n && typeof i != "string") throw Error(`Critical cRLReason holds unrecognized reason code ${String(i.code)}`);
|
|
833
|
+
r.reasonCode = i;
|
|
748
834
|
}
|
|
749
|
-
if (e ===
|
|
750
|
-
let e =
|
|
835
|
+
if (e === N.invalidityDate && (r.invalidityDate = A(_(t, { maxDepth: 64 }))), e === N.certificateIssuer) {
|
|
836
|
+
let e = _(t, { maxDepth: 64 });
|
|
751
837
|
if (e.tag !== 48) throw Error("certificateIssuer must use SEQUENCE");
|
|
752
|
-
|
|
838
|
+
r.certificateIssuer = U(t, e);
|
|
753
839
|
}
|
|
754
840
|
}
|
|
755
841
|
/** Decodes the IssuingDistributionPoint extension from its OCTET STRING content. */
|
|
756
842
|
function parseIssuingDistributionPoint(e) {
|
|
757
|
-
let t =
|
|
758
|
-
for (let r of
|
|
843
|
+
let t = _(e, { maxDepth: 64 }), n = {};
|
|
844
|
+
for (let r of S(e, t)) parseIssuingDistributionPointField(e, r, n);
|
|
759
845
|
return {
|
|
760
846
|
...n.distributionPoint === void 0 ? {} : { distributionPoint: n.distributionPoint },
|
|
761
847
|
...n.onlySomeReasons === void 0 ? {} : { onlySomeReasons: n.onlySomeReasons },
|
|
@@ -823,7 +909,7 @@ function parseIssuingDistributionPointField(e, t, n) {
|
|
|
823
909
|
return;
|
|
824
910
|
case 131:
|
|
825
911
|
if (n.onlySomeReasons !== void 0) throw Error("IssuingDistributionPoint onlySomeReasons must not repeat");
|
|
826
|
-
n.onlySomeReasons =
|
|
912
|
+
n.onlySomeReasons = V(t.value);
|
|
827
913
|
return;
|
|
828
914
|
case 132:
|
|
829
915
|
n.indirectCrl = parseUniqueIssuingDistributionPointBoolean(n.indirectCrl, t, "indirectCrl");
|
|
@@ -836,28 +922,28 @@ function parseIssuingDistributionPointField(e, t, n) {
|
|
|
836
922
|
}
|
|
837
923
|
function parseUniqueIssuingDistributionPointBoolean(e, t, n) {
|
|
838
924
|
if (e !== void 0) throw Error(`IssuingDistributionPoint ${n} must not repeat`);
|
|
839
|
-
return
|
|
925
|
+
return C(t.value);
|
|
840
926
|
}
|
|
841
927
|
/** Decodes a SEQUENCE OF DistributionPoint from DER. */
|
|
842
928
|
function parseDistributionPoints(e) {
|
|
843
|
-
let t =
|
|
929
|
+
let t = _(e, { maxDepth: 64 });
|
|
844
930
|
if (t.tag !== 48) throw Error("DistributionPoints must use SEQUENCE");
|
|
845
|
-
let n =
|
|
931
|
+
let n = S(e, t);
|
|
846
932
|
if (n.length === 0) throw Error("DistributionPoints must not be empty");
|
|
847
933
|
return n.map((t) => parseDistributionPoint(e, t));
|
|
848
934
|
}
|
|
849
935
|
/** Decodes a DistributionPointName (fullName or relativeName). */
|
|
850
936
|
function parseDistributionPointName(e, t) {
|
|
851
|
-
let n =
|
|
937
|
+
let n = S(e, t);
|
|
852
938
|
if (n.length !== 1) throw Error("distributionPointName must contain exactly one choice");
|
|
853
|
-
let r =
|
|
939
|
+
let r = j(n[0], "distributionPointName");
|
|
854
940
|
if (r.tag === 160) {
|
|
855
|
-
let t =
|
|
941
|
+
let t = S(e, r);
|
|
856
942
|
if (t.length === 0) throw Error("distributionPointName fullName must not be empty");
|
|
857
943
|
for (let e of t) if ((e.tag & 192) != 128) throw Error("distributionPointName fullName must contain GeneralName entries");
|
|
858
944
|
return {
|
|
859
945
|
type: "fullName",
|
|
860
|
-
fullName: t.map((t) =>
|
|
946
|
+
fullName: t.map((t) => H(e, t))
|
|
861
947
|
};
|
|
862
948
|
}
|
|
863
949
|
if (r.tag === 161) return {
|
|
@@ -870,7 +956,7 @@ function parseDistributionPointName(e, t) {
|
|
|
870
956
|
function parseDistributionPoint(e, t) {
|
|
871
957
|
if (t.tag !== 48) throw Error("DistributionPoint must use SEQUENCE");
|
|
872
958
|
let n = {};
|
|
873
|
-
for (let r of
|
|
959
|
+
for (let r of S(e, t)) parseDistributionPointField(e, r, n);
|
|
874
960
|
if (n.distributionPoint === void 0 && n.crlIssuer === void 0) throw Error("DistributionPoint must include distributionPoint or crlIssuer");
|
|
875
961
|
return {
|
|
876
962
|
...n.distributionPoint === void 0 ? {} : { distributionPoint: n.distributionPoint },
|
|
@@ -888,11 +974,11 @@ function parseDistributionPointField(e, t, n) {
|
|
|
888
974
|
}
|
|
889
975
|
case 129:
|
|
890
976
|
if (n.reasons !== void 0) throw Error("DistributionPoint reasons must not repeat");
|
|
891
|
-
n.reasons =
|
|
977
|
+
n.reasons = V(t.value);
|
|
892
978
|
return;
|
|
893
979
|
case 162:
|
|
894
980
|
if (n.crlIssuer !== void 0) throw Error("DistributionPoint crlIssuer must not repeat");
|
|
895
|
-
n.crlIssuer =
|
|
981
|
+
n.crlIssuer = U(e, t);
|
|
896
982
|
return;
|
|
897
983
|
default: throw Error(`Unsupported DistributionPoint field tag: ${String(t.tag)}`);
|
|
898
984
|
}
|
|
@@ -900,8 +986,8 @@ function parseDistributionPointField(e, t, n) {
|
|
|
900
986
|
/** Decodes a RelativeDistinguishedName SET from an implicitly-tagged context element. */
|
|
901
987
|
function parseRelativeName(e, t) {
|
|
902
988
|
let n = [], r = {};
|
|
903
|
-
for (let i of
|
|
904
|
-
let t =
|
|
989
|
+
for (let i of S(e, t)) {
|
|
990
|
+
let t = S(e, i), a = E(j(t[0], "name OID").value), o = j(t[1], "name value"), s = G(a), c = decodeNameValue(o), l = s === void 0 ? {
|
|
905
991
|
oid: a,
|
|
906
992
|
valueTag: o.tag,
|
|
907
993
|
value: c
|
|
@@ -914,22 +1000,40 @@ function parseRelativeName(e, t) {
|
|
|
914
1000
|
n.push(l), s !== void 0 && r[s] === void 0 && (r[s] = c);
|
|
915
1001
|
}
|
|
916
1002
|
return {
|
|
917
|
-
derHex:
|
|
1003
|
+
derHex: M(e.slice(t.start - t.headerLength, t.end)),
|
|
918
1004
|
attributes: n,
|
|
919
1005
|
values: r
|
|
920
1006
|
};
|
|
921
1007
|
}
|
|
922
1008
|
/** Decodes an ASN.1 string element (UTF8String, PrintableString, etc.) to a JS string. */
|
|
923
1009
|
function decodeNameValue(e) {
|
|
924
|
-
return
|
|
925
|
-
}
|
|
926
|
-
/** Reads an implicitly-tagged BOOLEAN from a context element. Absent content → `false`. */
|
|
927
|
-
function parseImplicitBoolean(e) {
|
|
928
|
-
return (e.value[0] ?? 0) !== 0;
|
|
1010
|
+
return D(e.tag, e.value);
|
|
929
1011
|
}
|
|
930
1012
|
/** Throws a {@link ResultError} for a CRL encoder input-validation failure. */
|
|
931
1013
|
function throwCrlEncoderError(e, t) {
|
|
932
|
-
|
|
1014
|
+
i(e, t);
|
|
1015
|
+
}
|
|
1016
|
+
/** The parsed issuer certificate of a CRL being built. */
|
|
1017
|
+
function issuerCertificateOf(t) {
|
|
1018
|
+
try {
|
|
1019
|
+
return normalizeCrlCertificate(t);
|
|
1020
|
+
} catch (t) {
|
|
1021
|
+
return s(t, e), throwCrlEncoderError("issuer_certificate_invalid", "issuerCertificate must be a PEM, DER or parsed certificate");
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
/** RFC 5280 §5.2.3 `CRLNumber ::= INTEGER (0..MAX)` as a DER INTEGER of at most 20 content octets. */
|
|
1025
|
+
function encodeCrlNumber(e, t) {
|
|
1026
|
+
let n = typeof e == "bigint" ? e : Number.isSafeInteger(e) ? BigInt(e) : -1n, r = n.toString(16), i = n < 0n ? void 0 : k(r.length % 2 == 0 ? r : `0${r}`), a = i?.[0];
|
|
1027
|
+
return (i === void 0 || a === void 0 || i.length + +(a >= 128) > 20) && throwCrlEncoderError("crl_number_invalid", `${t} must be a non-negative integer of at most 20 octets (RFC 5280 §5.2.3)`), m(i);
|
|
1028
|
+
}
|
|
1029
|
+
/** RFC 5280 §5.2.3: a received CRLNumber of any length, since verifiers MUST handle up to 20 octets. */
|
|
1030
|
+
function decodeCrlNumber(e) {
|
|
1031
|
+
let t = _(e, { maxDepth: 64 });
|
|
1032
|
+
if (t.tag !== 2) throw Error("CRLNumber must be an INTEGER");
|
|
1033
|
+
return w(t.value, "CRLNumber"), BigInt(`0x${M(t.value)}`);
|
|
1034
|
+
}
|
|
1035
|
+
function assertCrlDate(e, t) {
|
|
1036
|
+
e !== void 0 && Number.isNaN(e.getTime()) && throwCrlEncoderError("invalid_date", `${t} must be a valid date`);
|
|
933
1037
|
}
|
|
934
1038
|
/** DER-encodes an IssuingDistributionPoint extension value. Throws on mutually-exclusive scope flags. */
|
|
935
1039
|
function encodeIssuingDistributionPoint(e) {
|
|
@@ -939,37 +1043,31 @@ function encodeIssuingDistributionPoint(e) {
|
|
|
939
1043
|
e.onlyContainsAttributeCerts === !0
|
|
940
1044
|
].filter(Boolean).length > 1) throw Error("IssuingDistributionPoint can assert at most one of user, CA, or attribute cert scope");
|
|
941
1045
|
let t = [];
|
|
942
|
-
return e.distributionPoint !== void 0 && t.push(
|
|
1046
|
+
return e.distributionPoint !== void 0 && t.push(f(0, encodeDistributionPointName(e.distributionPoint))), e.onlyContainsUserCerts && t.push(p(1, Uint8Array.of(255))), e.onlyContainsCACerts && t.push(p(2, Uint8Array.of(255))), e.onlySomeReasons !== void 0 && e.onlySomeReasons.length > 0 && t.push(p(3, B(e.onlySomeReasons))), e.indirectCrl && t.push(p(4, Uint8Array.of(255))), e.onlyContainsAttributeCerts && t.push(p(5, Uint8Array.of(255))), y(t);
|
|
943
1047
|
}
|
|
944
1048
|
/** DER-encodes a DistributionPointName (fullName or relativeName). */
|
|
945
1049
|
function encodeDistributionPointName(e) {
|
|
946
1050
|
if (e === void 0) throw Error("IssuingDistributionPoint distributionPoint is required");
|
|
947
1051
|
switch (e.type) {
|
|
948
|
-
case "fullName": return e.fullName.length === 0 && throwCrlEncoderError("distribution_point_full_name_empty", "DistributionPointName fullName must not be empty"),
|
|
1052
|
+
case "fullName": return e.fullName.length === 0 && throwCrlEncoderError("distribution_point_full_name_empty", "DistributionPointName fullName must not be empty"), f(0, concatGeneralNames(e.fullName));
|
|
949
1053
|
case "relativeName": {
|
|
950
|
-
let t =
|
|
951
|
-
return
|
|
1054
|
+
let t = Y(e.relativeName), n = g(t);
|
|
1055
|
+
return f(1, t.slice(n.start, n.end));
|
|
952
1056
|
}
|
|
953
1057
|
default: throw Error(`Unhandled DistributionPointName type: ${String(e)}`);
|
|
954
1058
|
}
|
|
955
1059
|
}
|
|
956
1060
|
/** DER-encodes and concatenates a list of GeneralName values. */
|
|
957
1061
|
function concatGeneralNames(e) {
|
|
958
|
-
return
|
|
1062
|
+
return l(e.map((e) => oe(e)));
|
|
959
1063
|
}
|
|
960
1064
|
/** Parses a Name SEQUENCE element into a full {@linkcode ParsedName}. */
|
|
961
1065
|
function parseIssuer(e, t) {
|
|
962
|
-
let n =
|
|
963
|
-
for (let n of
|
|
1066
|
+
let n = M(e.slice(t.start - t.headerLength, t.end)), r = [], i = [], a = {};
|
|
1067
|
+
for (let n of S(e, t)) {
|
|
964
1068
|
let t = [], o = {};
|
|
965
|
-
for (let r of
|
|
966
|
-
let n =
|
|
967
|
-
try {
|
|
968
|
-
u = y(c.tag, c.value);
|
|
969
|
-
} catch {
|
|
970
|
-
u = oe.decode(c.value);
|
|
971
|
-
}
|
|
972
|
-
let d = I(l), f = d === void 0 ? {
|
|
1069
|
+
for (let r of S(e, n)) {
|
|
1070
|
+
let n = S(e, r), s = j(n[0], "issuer attribute OID"), c = j(n[1], "issuer attribute value"), l = E(s.value), u = decodeNameValue(c), d = G(l), f = d === void 0 ? {
|
|
973
1071
|
oid: l,
|
|
974
1072
|
valueTag: c.tag,
|
|
975
1073
|
value: u
|
|
@@ -982,7 +1080,7 @@ function parseIssuer(e, t) {
|
|
|
982
1080
|
t.push(f), i.push(f), d !== void 0 && (o[d] === void 0 && (o[d] = u), a[d] === void 0 && (a[d] = u));
|
|
983
1081
|
}
|
|
984
1082
|
r.push({
|
|
985
|
-
derHex:
|
|
1083
|
+
derHex: M(e.slice(n.start - n.headerLength, n.end)),
|
|
986
1084
|
attributes: t,
|
|
987
1085
|
values: o
|
|
988
1086
|
});
|
|
@@ -994,28 +1092,38 @@ function parseIssuer(e, t) {
|
|
|
994
1092
|
values: a
|
|
995
1093
|
};
|
|
996
1094
|
}
|
|
997
|
-
/**
|
|
998
|
-
|
|
1095
|
+
/**
|
|
1096
|
+
* Re-parses a hex-encoded DER Name into a {@linkcode ParsedName}. Returns
|
|
1097
|
+
* `undefined` on malformed input and throws a decode refusal.
|
|
1098
|
+
*/
|
|
1099
|
+
function parseDerHexName(t) {
|
|
999
1100
|
try {
|
|
1000
|
-
let
|
|
1001
|
-
return n.tag === 48 ? parseIssuer(
|
|
1002
|
-
} catch {
|
|
1101
|
+
let e = k(t), n = unwrapNameElement(e, _(e, { maxDepth: 64 }));
|
|
1102
|
+
return n.tag === 48 ? parseIssuer(e, n) : void 0;
|
|
1103
|
+
} catch (t) {
|
|
1104
|
+
s(t, e);
|
|
1003
1105
|
return;
|
|
1004
1106
|
}
|
|
1005
1107
|
}
|
|
1108
|
+
/** The failure for a decode refusal a directoryName comparison threw. */
|
|
1109
|
+
function crlNameRefusalFailure(t) {
|
|
1110
|
+
let n = o(t, e);
|
|
1111
|
+
if (n === void 0) throw t;
|
|
1112
|
+
return checkCertificateRevocationAgainstCrlFailureResult(n.code, n.message);
|
|
1113
|
+
}
|
|
1006
1114
|
function unwrapNameElement(e, t) {
|
|
1007
1115
|
if (t.tag !== 48) return t;
|
|
1008
|
-
let n =
|
|
1116
|
+
let n = S(e, t), r = n[0];
|
|
1009
1117
|
return n.length === 1 && r?.tag === 48 ? r : t;
|
|
1010
1118
|
}
|
|
1011
1119
|
/** Semantic comparison of a GeneralName directoryName `derHex` against a {@linkcode ParsedName}. */
|
|
1012
1120
|
function directoryNameDerHexMatchesParsedName(e, t) {
|
|
1013
1121
|
let n = parseDerHexName(e);
|
|
1014
|
-
return n !== void 0 &&
|
|
1122
|
+
return n !== void 0 && K(n, t);
|
|
1015
1123
|
}
|
|
1016
1124
|
/** Extracts the keyIdentifier field from an AuthorityKeyIdentifier extension value. */
|
|
1017
1125
|
function parseAuthorityKeyIdentifier(e) {
|
|
1018
|
-
let t =
|
|
1126
|
+
let t = _(e, {
|
|
1019
1127
|
maxDepth: 64,
|
|
1020
1128
|
allowOpaqueConstructedTags: [161, 162]
|
|
1021
1129
|
});
|
|
@@ -1025,7 +1133,7 @@ function parseAuthorityKeyIdentifier(e) {
|
|
|
1025
1133
|
sawAuthorityCertSerialNumber: !1,
|
|
1026
1134
|
lastFieldOrder: -1
|
|
1027
1135
|
};
|
|
1028
|
-
for (let r of
|
|
1136
|
+
for (let r of S(e, t)) parseAuthorityKeyIdentifierField(e, r, n);
|
|
1029
1137
|
return n.keyIdentifier;
|
|
1030
1138
|
}
|
|
1031
1139
|
function parseAuthorityKeyIdentifierField(e, t, n) {
|
|
@@ -1045,12 +1153,12 @@ function parseAuthorityKeyIdentifierField(e, t, n) {
|
|
|
1045
1153
|
function parseAuthorityKeyIdentifierKeyId(e, t) {
|
|
1046
1154
|
if (t.keyIdentifier !== void 0) throw Error("authorityKeyIdentifier keyIdentifier must not repeat");
|
|
1047
1155
|
if (t.lastFieldOrder >= 0) throw Error("authorityKeyIdentifier fields must preserve DER order");
|
|
1048
|
-
t.keyIdentifier =
|
|
1156
|
+
t.keyIdentifier = M(e.value), t.lastFieldOrder = 0;
|
|
1049
1157
|
}
|
|
1050
1158
|
function parseAuthorityKeyIdentifierIssuer(e, t, n) {
|
|
1051
1159
|
if (n.sawAuthorityCertIssuer) throw Error("authorityKeyIdentifier authorityCertIssuer must not repeat");
|
|
1052
1160
|
if (n.lastFieldOrder >= 1) throw Error("authorityKeyIdentifier fields must preserve DER order");
|
|
1053
|
-
|
|
1161
|
+
U(e, t), n.sawAuthorityCertIssuer = !0, n.lastFieldOrder = 1;
|
|
1054
1162
|
}
|
|
1055
1163
|
function parseAuthorityKeyIdentifierSerial(e, t) {
|
|
1056
1164
|
if (t.sawAuthorityCertSerialNumber) throw Error("authorityKeyIdentifier authorityCertSerialNumber must not repeat");
|
|
@@ -1065,13 +1173,13 @@ function validateImplicitSerialNumberEncoding(e, t) {
|
|
|
1065
1173
|
}
|
|
1066
1174
|
/** RFC 5280 §5.1.1.2: signatureAlgorithm MUST equal the tbsCertList signature field. */
|
|
1067
1175
|
function assertMatchingCrlSignatureAlgorithms(e, t) {
|
|
1068
|
-
if (e.oid !== t.oid || !
|
|
1176
|
+
if (e.oid !== t.oid || !ee(e.parametersDer, t.parametersDer)) throw Error("CRL signatureAlgorithm must match TBSCertList signature");
|
|
1069
1177
|
}
|
|
1070
1178
|
/** Extracts the algorithm OID from an AlgorithmIdentifier SEQUENCE. */
|
|
1071
1179
|
function parseAlgorithmIdentifier(e, t) {
|
|
1072
|
-
let n =
|
|
1073
|
-
return i === void 0 ? { oid:
|
|
1074
|
-
oid:
|
|
1180
|
+
let n = S(e, t), r = j(n[0], "algorithm OID"), i = n[1];
|
|
1181
|
+
return i === void 0 ? { oid: E(r.value) } : {
|
|
1182
|
+
oid: E(r.value),
|
|
1075
1183
|
parametersDer: e.slice(i.start - i.headerLength, i.end)
|
|
1076
1184
|
};
|
|
1077
1185
|
}
|
|
@@ -1079,30 +1187,46 @@ function parseAlgorithmIdentifier(e, t) {
|
|
|
1079
1187
|
function normalizeHex(e) {
|
|
1080
1188
|
return e.toLowerCase();
|
|
1081
1189
|
}
|
|
1082
|
-
/**
|
|
1190
|
+
/**
|
|
1191
|
+
* Maps an integer CRLReason code to its {@linkcode RevocationReason} name, or to
|
|
1192
|
+
* an {@linkcode UnrecognizedRevocationReason} carrying a code outside RFC 5280
|
|
1193
|
+
* §5.3.1. Returns `undefined` only when `code` is `undefined`.
|
|
1194
|
+
*/
|
|
1083
1195
|
function revocationReasonFromCode(e) {
|
|
1196
|
+
return e === void 0 ? void 0 : parsedRevocationReason(e);
|
|
1197
|
+
}
|
|
1198
|
+
function parsedRevocationReason(e) {
|
|
1084
1199
|
switch (e) {
|
|
1085
|
-
case
|
|
1086
|
-
case
|
|
1087
|
-
case
|
|
1088
|
-
case
|
|
1089
|
-
case
|
|
1090
|
-
case
|
|
1091
|
-
case
|
|
1092
|
-
case
|
|
1093
|
-
case
|
|
1094
|
-
case
|
|
1200
|
+
case 0n: return "unspecified";
|
|
1201
|
+
case 1n: return "keyCompromise";
|
|
1202
|
+
case 2n: return "cACompromise";
|
|
1203
|
+
case 3n: return "affiliationChanged";
|
|
1204
|
+
case 4n: return "superseded";
|
|
1205
|
+
case 5n: return "cessationOfOperation";
|
|
1206
|
+
case 6n: return "certificateHold";
|
|
1207
|
+
case 8n: return "removeFromCRL";
|
|
1208
|
+
case 9n: return "privilegeWithdrawn";
|
|
1209
|
+
case 10n: return "aACompromise";
|
|
1210
|
+
default: return {
|
|
1211
|
+
type: "unrecognized",
|
|
1212
|
+
code: e
|
|
1213
|
+
};
|
|
1095
1214
|
}
|
|
1096
1215
|
}
|
|
1097
1216
|
/** Thin wrapper — parses a DER-encoded certificate for use as a CRL issuer. */
|
|
1098
1217
|
function parseIssuerCertificateDer(e) {
|
|
1099
|
-
return
|
|
1218
|
+
return Z(e);
|
|
1100
1219
|
}
|
|
1101
1220
|
/** Thin wrapper — parses a PEM-encoded certificate for use as a CRL issuer. */
|
|
1102
1221
|
function parseIssuerCertificatePem(e) {
|
|
1103
|
-
return
|
|
1222
|
+
return Z(e);
|
|
1104
1223
|
}
|
|
1105
|
-
/**
|
|
1224
|
+
/**
|
|
1225
|
+
* Parses PEM, DER, or an already-parsed CRL's `der`, so every decoded field
|
|
1226
|
+
* comes from the signed bytes.
|
|
1227
|
+
*
|
|
1228
|
+
* @internal
|
|
1229
|
+
*/
|
|
1106
1230
|
function normalizeCrl(e) {
|
|
1107
1231
|
if (typeof e == "string") return parseCertificateRevocationListPemOrThrow(e);
|
|
1108
1232
|
if (e instanceof Uint8Array) return parseCertificateRevocationListDerOrThrow(new Uint8Array(e));
|
|
@@ -1110,22 +1234,22 @@ function normalizeCrl(e) {
|
|
|
1110
1234
|
throw Error("certificate revocation list input is malformed");
|
|
1111
1235
|
}
|
|
1112
1236
|
function parseSignedCrlFields(e) {
|
|
1113
|
-
let t =
|
|
1114
|
-
d !== void 0 && (
|
|
1115
|
-
let f =
|
|
1116
|
-
f?.tag === 48 && (
|
|
1117
|
-
let m =
|
|
1237
|
+
let t = _(e, { maxDepth: 64 }), n = S(e, t), r = parseCrlVersionField(n), i = r.version, a = j(n[r.nextIndex], "signature"), o = r.nextIndex + 1, s = j(n[o], "issuer"), c = j(n[o + 1], "thisUpdate"), l = o + 2, u = n[l], d = u !== void 0 && (u.tag === 23 || u.tag === 24) ? A(u) : void 0;
|
|
1238
|
+
d !== void 0 && (l += 1);
|
|
1239
|
+
let f = n[l], p = f?.tag === 48 ? parseRevokedCertificates(e, f, i) : [];
|
|
1240
|
+
f?.tag === 48 && (l += 1);
|
|
1241
|
+
let m = n[l], h = parseCrlExtensionFields(e, m, i);
|
|
1118
1242
|
return {
|
|
1119
|
-
version:
|
|
1120
|
-
signature: parseAlgorithmIdentifier(e,
|
|
1121
|
-
issuer: parseIssuer(e,
|
|
1122
|
-
thisUpdate:
|
|
1243
|
+
version: i,
|
|
1244
|
+
signature: parseAlgorithmIdentifier(e, a),
|
|
1245
|
+
issuer: parseIssuer(e, s),
|
|
1246
|
+
thisUpdate: A(c),
|
|
1123
1247
|
...d === void 0 ? {} : { nextUpdate: d },
|
|
1124
|
-
...
|
|
1125
|
-
...
|
|
1126
|
-
...
|
|
1127
|
-
...
|
|
1128
|
-
...
|
|
1248
|
+
...h.authorityKeyIdentifier === void 0 ? {} : { authorityKeyIdentifier: h.authorityKeyIdentifier },
|
|
1249
|
+
...h.crlNumber === void 0 ? {} : { crlNumber: h.crlNumber },
|
|
1250
|
+
...h.baseCrlNumber === void 0 ? {} : { baseCrlNumber: h.baseCrlNumber },
|
|
1251
|
+
...h.issuingDistributionPoint === void 0 ? {} : { issuingDistributionPoint: h.issuingDistributionPoint },
|
|
1252
|
+
...h.freshestCrlDistributionPoints === void 0 ? {} : { freshestCrlDistributionPoints: h.freshestCrlDistributionPoints },
|
|
1129
1253
|
revokedCertificates: p
|
|
1130
1254
|
};
|
|
1131
1255
|
}
|
|
@@ -1136,7 +1260,7 @@ function parseCrlVersionField(e) {
|
|
|
1136
1260
|
version: 1,
|
|
1137
1261
|
nextIndex: 0
|
|
1138
1262
|
};
|
|
1139
|
-
let n =
|
|
1263
|
+
let n = T(t.value) + 1;
|
|
1140
1264
|
if (n !== 2) throw Error(`Unsupported CRL version: ${String(n)}`);
|
|
1141
1265
|
return {
|
|
1142
1266
|
version: n,
|
|
@@ -1144,17 +1268,17 @@ function parseCrlVersionField(e) {
|
|
|
1144
1268
|
};
|
|
1145
1269
|
}
|
|
1146
1270
|
function parseRevokedCertificates(e, t, n) {
|
|
1147
|
-
return
|
|
1271
|
+
return S(e, t).map((t) => parseRevokedCertificateEntry(e, t, n));
|
|
1148
1272
|
}
|
|
1149
1273
|
function parseRevokedCertificateEntry(e, t, n) {
|
|
1150
|
-
let r = e.slice(t.start - t.headerLength, t.end), i =
|
|
1274
|
+
let r = e.slice(t.start - t.headerLength, t.end), i = v(r), a = j(i[0], "revoked serialNumber");
|
|
1151
1275
|
if (a.tag !== 2) throw Error("revoked serialNumber must use INTEGER");
|
|
1152
1276
|
let o = i[2];
|
|
1153
1277
|
if (o !== void 0 && n !== 2) throw Error("revoked certificate extensions require CRL version 2");
|
|
1154
1278
|
let s = parseRevokedCertificateExtensions(r, o);
|
|
1155
1279
|
return {
|
|
1156
|
-
serialNumberHex:
|
|
1157
|
-
revocationDate:
|
|
1280
|
+
serialNumberHex: M(a.value),
|
|
1281
|
+
revocationDate: A(j(i[1], "revocationDate")),
|
|
1158
1282
|
...s.reasonCode === void 0 ? {} : { reasonCode: s.reasonCode },
|
|
1159
1283
|
...s.invalidityDate === void 0 ? {} : { invalidityDate: s.invalidityDate },
|
|
1160
1284
|
...s.certificateIssuer === void 0 ? {} : { certificateIssuer: s.certificateIssuer }
|
|
@@ -1163,34 +1287,34 @@ function parseRevokedCertificateEntry(e, t, n) {
|
|
|
1163
1287
|
function parseCrlExtensionFields(e, t, n) {
|
|
1164
1288
|
if (t?.tag !== 160) return {};
|
|
1165
1289
|
if (n !== 2) throw Error("CRL extensions require version 2");
|
|
1166
|
-
let r = {}, i = /* @__PURE__ */ new Set(), a =
|
|
1167
|
-
for (let t of
|
|
1290
|
+
let r = {}, i = /* @__PURE__ */ new Set(), a = j(S(e, t)[0], "crl extensions");
|
|
1291
|
+
for (let t of S(e, a)) parseCrlExtensionField(e, t, i, r);
|
|
1168
1292
|
return r;
|
|
1169
1293
|
}
|
|
1170
1294
|
function parseCrlExtensionField(e, t, n, r) {
|
|
1171
|
-
let i =
|
|
1295
|
+
let i = S(e, t);
|
|
1172
1296
|
if (i.length < 2 || i.length > 3 || i.length === 3 && i[1]?.tag !== 1) throw Error("Malformed CRL extension");
|
|
1173
|
-
let a =
|
|
1297
|
+
let a = E(j(i[0], "extension OID").value);
|
|
1174
1298
|
if (n.has(a)) throw Error(`Duplicate CRL extension OID: ${a}`);
|
|
1175
1299
|
n.add(a);
|
|
1176
|
-
let o = i.length === 3 &&
|
|
1300
|
+
let o = i.length === 3 && C(j(i[1], "extension critical").value), s = j(i[i.length - 1], "extension value");
|
|
1177
1301
|
if (s.tag !== 4) throw Error("CRL extension value must use OCTET STRING");
|
|
1178
1302
|
if (!isSupportedCrlExtensionOid(a) && o) throw Error(`Unsupported critical CRL extension OID: ${a}`);
|
|
1179
1303
|
applyParsedCrlExtensionField(a, s.value, r);
|
|
1180
1304
|
}
|
|
1181
1305
|
function isSupportedCrlExtensionOid(e) {
|
|
1182
|
-
return e ===
|
|
1306
|
+
return e === N.authorityKeyIdentifier || e === N.cRLNumber || e === N.deltaCRLIndicator || e === N.issuingDistributionPoint || e === N.freshestCRL;
|
|
1183
1307
|
}
|
|
1184
1308
|
function applyParsedCrlExtensionField(e, t, n) {
|
|
1185
|
-
if (e ===
|
|
1309
|
+
if (e === N.authorityKeyIdentifier) {
|
|
1186
1310
|
let e = parseAuthorityKeyIdentifier(t);
|
|
1187
1311
|
e !== void 0 && (n.authorityKeyIdentifier = e);
|
|
1188
1312
|
}
|
|
1189
|
-
e ===
|
|
1313
|
+
e === N.cRLNumber && (n.crlNumber = decodeCrlNumber(t)), e === N.deltaCRLIndicator && (n.baseCrlNumber = decodeCrlNumber(t)), e === N.issuingDistributionPoint && (n.issuingDistributionPoint = parseIssuingDistributionPoint(t)), e === N.freshestCRL && (n.freshestCrlDistributionPoints = parseDistributionPoints(t));
|
|
1190
1314
|
}
|
|
1191
1315
|
/** Accepts PEM, DER, or already-parsed certificate and returns a parsed certificate. */
|
|
1192
1316
|
function normalizeCrlCertificate(e) {
|
|
1193
|
-
return hasParsedCertificateShape(e) ?
|
|
1317
|
+
return hasParsedCertificateShape(e) ? ce(new Uint8Array(e.der)) : Z(e);
|
|
1194
1318
|
}
|
|
1195
1319
|
function hasParsedCertificateShape(e) {
|
|
1196
1320
|
return typeof e != "string" && "subjectPublicKeyInfoDer" in e;
|
|
@@ -1198,9 +1322,6 @@ function hasParsedCertificateShape(e) {
|
|
|
1198
1322
|
function hasReparseableCrlShape(e) {
|
|
1199
1323
|
return "der" in e && e.der instanceof Uint8Array;
|
|
1200
1324
|
}
|
|
1201
|
-
|
|
1202
|
-
const oe = new TextDecoder();
|
|
1203
|
-
//#endregion
|
|
1204
|
-
export { Q as ALL_DISTRIBUTION_POINT_REASONS, checkCertificateRevocationAgainstCrl, coversAllDistributionPointReasons, createCertificateRevocationList, isCertificateRevoked, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, revocationReasonFromCode, validateCertificateRevocationList, verifyCertificateRevocationListSignature };
|
|
1325
|
+
export { Q as ALL_DISTRIBUTION_POINT_REASONS, assertCrlMaxAge, authenticateCrl, checkCertificateRevocationAgainstCrl, checkRevocationAgainstAuthenticatedCrl, coversAllDistributionPointReasons, createCertificateRevocationList, isCertificateRevoked, isCrlApplicableTo, isCurrentDeltaCrl, normalizeCrl, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, revocationReasonFromCode, validateCertificateRevocationList, verifyCertificateRevocationListSignature };
|
|
1205
1326
|
|
|
1206
1327
|
//# sourceMappingURL=crl.js.map
|