micro509 0.14.0 → 0.16.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.
Files changed (164) hide show
  1. package/CHANGELOG.md +2119 -0
  2. package/README.md +105 -225
  3. package/dist/crypto/crypto.d.ts +42 -11
  4. package/dist/crypto/crypto.js +53 -22
  5. package/dist/crypto/crypto.js.map +1 -1
  6. package/dist/crypto.d.ts +2 -2
  7. package/dist/crypto.js +1 -2
  8. package/dist/der/der.d.ts +41 -33
  9. package/dist/der/der.js +26 -24
  10. package/dist/der/der.js.map +1 -1
  11. package/dist/index.d.ts +11 -11
  12. package/dist/index.js +19 -19
  13. package/dist/internal/asn1/asn1.d.ts +3 -6
  14. package/dist/internal/asn1/asn1.js +343 -43
  15. package/dist/internal/asn1/asn1.js.map +1 -1
  16. package/dist/internal/asn1/ber.js +146 -0
  17. package/dist/internal/asn1/ber.js.map +1 -0
  18. package/dist/internal/asn1/decode-refusal.js +29 -0
  19. package/dist/internal/asn1/decode-refusal.js.map +1 -0
  20. package/dist/internal/asn1/der.d.ts +38 -41
  21. package/dist/internal/asn1/der.js +131 -52
  22. package/dist/internal/asn1/der.js.map +1 -1
  23. package/dist/internal/asn1/oids.js +83 -53
  24. package/dist/internal/asn1/oids.js.map +1 -1
  25. package/dist/internal/asn1/oids2.js +1 -2
  26. package/dist/internal/asn1/oids2.js.map +1 -1
  27. package/dist/internal/crypto/algorithm-names.js +1 -2
  28. package/dist/internal/crypto/algorithm-names.js.map +1 -1
  29. package/dist/internal/crypto/ecdsa.js +13 -8
  30. package/dist/internal/crypto/ecdsa.js.map +1 -1
  31. package/dist/internal/crypto/hash.js +1 -2
  32. package/dist/internal/crypto/hash.js.map +1 -1
  33. package/dist/internal/crypto/pbes2.d.ts +24 -11
  34. package/dist/internal/crypto/pbes2.js +79 -26
  35. package/dist/internal/crypto/pbes2.js.map +1 -1
  36. package/dist/internal/crypto/rsa-pss.js +46 -44
  37. package/dist/internal/crypto/rsa-pss.js.map +1 -1
  38. package/dist/internal/crypto/sig-verify.d.ts +4 -7
  39. package/dist/internal/crypto/sig-verify.js +107 -60
  40. package/dist/internal/crypto/sig-verify.js.map +1 -1
  41. package/dist/internal/crypto/signing.d.ts +1 -4
  42. package/dist/internal/crypto/signing.js +28 -29
  43. package/dist/internal/crypto/signing.js.map +1 -1
  44. package/dist/internal/crypto/webcrypto.js +1 -2
  45. package/dist/internal/crypto/webcrypto.js.map +1 -1
  46. package/dist/internal/shared/base64.js +1 -2
  47. package/dist/internal/shared/base64.js.map +1 -1
  48. package/dist/internal/shared/dn.d.ts +3 -6
  49. package/dist/internal/shared/dn.js +99 -53
  50. package/dist/internal/shared/dn.js.map +1 -1
  51. package/dist/internal/shared/idna-tables.js +7217 -0
  52. package/dist/internal/shared/idna-tables.js.map +1 -0
  53. package/dist/internal/shared/idna.js +296 -0
  54. package/dist/internal/shared/idna.js.map +1 -0
  55. package/dist/internal/shared/ip.d.ts +4 -7
  56. package/dist/internal/shared/ip.js +1 -2
  57. package/dist/internal/shared/ip.js.map +1 -1
  58. package/dist/internal/shared/mailbox.js +26 -0
  59. package/dist/internal/shared/mailbox.js.map +1 -0
  60. package/dist/internal/shared/punycode.js +101 -0
  61. package/dist/internal/shared/punycode.js.map +1 -0
  62. package/dist/internal/shared/rfc3454-tables.js +1 -2
  63. package/dist/internal/shared/rfc3454-tables.js.map +1 -1
  64. package/dist/internal/shared/rfc4518-tables.js +119 -0
  65. package/dist/internal/shared/rfc4518-tables.js.map +1 -0
  66. package/dist/internal/shared/uri-host.js +102 -0
  67. package/dist/internal/shared/uri-host.js.map +1 -0
  68. package/dist/internal/verify/name-constraints-engine.js +246 -131
  69. package/dist/internal/verify/name-constraints-engine.js.map +1 -1
  70. package/dist/internal/verify/policy-engine.js +6 -21
  71. package/dist/internal/verify/policy-engine.js.map +1 -1
  72. package/dist/internal/verify/spki-distrust.js +23 -0
  73. package/dist/internal/verify/spki-distrust.js.map +1 -0
  74. package/dist/internal/verify/verify-path.d.ts +1 -4
  75. package/dist/internal/verify/verify-path.js +282 -129
  76. package/dist/internal/verify/verify-path.js.map +1 -1
  77. package/dist/internal/x509/directory-name.js +1 -2
  78. package/dist/internal/x509/directory-name.js.map +1 -1
  79. package/dist/internal/x509/extension-bits.js +2 -3
  80. package/dist/internal/x509/extension-bits.js.map +1 -1
  81. package/dist/internal/x509/extension-errors.d.ts +1 -4
  82. package/dist/internal/x509/extension-errors.js +1 -2
  83. package/dist/internal/x509/extension-errors.js.map +1 -1
  84. package/dist/internal/x509/extension-registry.js +107 -89
  85. package/dist/internal/x509/extension-registry.js.map +1 -1
  86. package/dist/internal/x509/general-name-profile.js +129 -0
  87. package/dist/internal/x509/general-name-profile.js.map +1 -0
  88. package/dist/internal/x509/general-name-tags.js +1 -2
  89. package/dist/internal/x509/general-name-tags.js.map +1 -1
  90. package/dist/internal/x509/general-name.js +128 -42
  91. package/dist/internal/x509/general-name.js.map +1 -1
  92. package/dist/internal/x509/name-fields.js +1 -2
  93. package/dist/internal/x509/name-fields.js.map +1 -1
  94. package/dist/internal/x509/or-address.js +217 -0
  95. package/dist/internal/x509/or-address.js.map +1 -0
  96. package/dist/keys/keys.d.ts +122 -104
  97. package/dist/keys/keys.js +211 -204
  98. package/dist/keys/keys.js.map +1 -1
  99. package/dist/keys.d.ts +3 -3
  100. package/dist/pem/pem.d.ts +14 -17
  101. package/dist/pem/pem.js +16 -17
  102. package/dist/pem/pem.js.map +1 -1
  103. package/dist/pem.js +1 -2
  104. package/dist/pkcs/pfx.d.ts +57 -32
  105. package/dist/pkcs/pfx.js +209 -173
  106. package/dist/pkcs/pfx.js.map +1 -1
  107. package/dist/pkcs/pkcs12-mac.d.ts +104 -27
  108. package/dist/pkcs/pkcs12-mac.js +266 -79
  109. package/dist/pkcs/pkcs12-mac.js.map +1 -1
  110. package/dist/pkcs/pkcs7.d.ts +43 -37
  111. package/dist/pkcs/pkcs7.js +218 -217
  112. package/dist/pkcs/pkcs7.js.map +1 -1
  113. package/dist/pkcs.d.ts +4 -3
  114. package/dist/result/result.d.ts +27 -20
  115. package/dist/result/result.js +8 -3
  116. package/dist/result/result.js.map +1 -1
  117. package/dist/result.d.ts +2 -2
  118. package/dist/result.js +1 -2
  119. package/dist/revocation/chain.d.ts +101 -23
  120. package/dist/revocation/chain.js +436 -182
  121. package/dist/revocation/chain.js.map +1 -1
  122. package/dist/revocation/crl.d.ts +131 -67
  123. package/dist/revocation/crl.js +443 -327
  124. package/dist/revocation/crl.js.map +1 -1
  125. package/dist/revocation/ocsp.d.ts +94 -59
  126. package/dist/revocation/ocsp.js +331 -293
  127. package/dist/revocation/ocsp.js.map +1 -1
  128. package/dist/revocation/revocation.d.ts +47 -35
  129. package/dist/revocation/revocation.js +88 -57
  130. package/dist/revocation/revocation.js.map +1 -1
  131. package/dist/revocation.d.ts +3 -3
  132. package/dist/verify/identity.d.ts +16 -19
  133. package/dist/verify/identity.js +118 -89
  134. package/dist/verify/identity.js.map +1 -1
  135. package/dist/verify/name-constraints.d.ts +1 -4
  136. package/dist/verify/policy.d.ts +9 -7
  137. package/dist/verify/verify.d.ts +115 -46
  138. package/dist/verify/verify.js +373 -183
  139. package/dist/verify/verify.js.map +1 -1
  140. package/dist/verify.d.ts +2 -2
  141. package/dist/x509/certificate.d.ts +20 -21
  142. package/dist/x509/certificate.js +62 -46
  143. package/dist/x509/certificate.js.map +1 -1
  144. package/dist/x509/csr.d.ts +5 -7
  145. package/dist/x509/csr.js +10 -11
  146. package/dist/x509/csr.js.map +1 -1
  147. package/dist/x509/extensions.d.ts +154 -66
  148. package/dist/x509/extensions.js +317 -151
  149. package/dist/x509/extensions.js.map +1 -1
  150. package/dist/x509/fingerprint.d.ts +15 -7
  151. package/dist/x509/fingerprint.js +20 -3
  152. package/dist/x509/fingerprint.js.map +1 -1
  153. package/dist/x509/name-text.d.ts +7 -9
  154. package/dist/x509/name-text.js +18 -4
  155. package/dist/x509/name-text.js.map +1 -1
  156. package/dist/x509/name.d.ts +9 -11
  157. package/dist/x509/name.js +18 -19
  158. package/dist/x509/name.js.map +1 -1
  159. package/dist/x509/parse.d.ts +84 -69
  160. package/dist/x509/parse.js +421 -400
  161. package/dist/x509/parse.js.map +1 -1
  162. package/dist/x509.d.ts +3 -3
  163. package/dist/x509.js +3 -3
  164. package/package.json +76 -59
@@ -1,21 +1,22 @@
1
- import { bitString as e, concatBytes as t, explicitContext as n, generalizedTime as r, implicitConstructedContext as i, implicitPrimitiveContext as a, integer as o, integerFromNumber as s, optionalBytesEqual as c, readElement as l, readRootElement as u, readSequenceChildren as d, sequence as f, time as p, tlv as m } from "../internal/asn1/der.js";
2
- import { childrenOf as h, decodeBoolean as g, decodeIntegerNumber as _, decodeObjectIdentifier as v, decodeString as y, extractBitStringValue as b, hexToBytes as x, parseTime as S, requireElement as C, toHex as w } from "../internal/asn1/asn1.js";
3
- import { OIDS as T } from "../internal/asn1/oids2.js";
4
- import { base64Encode as E } from "../internal/shared/base64.js";
5
- import { failureResult as D, rethrowIfInvariant as O, successResult as k, throwMicro509Error as ee } from "../result/result.js";
6
- import { pemDecodeOrThrow as A, pemEncode as j } from "../pem/pem.js";
7
- import { exportSpkiDer as M } from "../keys/keys.js";
8
- import { describeSignatureAlgorithm as N } from "../internal/crypto/algorithm-names.js";
9
- import { encodeDistributionPointReasonFlagsContent as P, parseDistributionPointReasonFlagsContent as F } from "../internal/x509/extension-bits.js";
10
- import { nameFieldKeyFromOid as I } from "../internal/x509/name-fields.js";
11
- import { compareDistinguishedNames as L, compareNameAttributeValue as R } from "../internal/shared/dn.js";
12
- import { encodeName as z, encodeRelativeDistinguishedName as B, isNameInputEmpty as V } from "../x509/name.js";
13
- import { buildSubjectKeyIdentifier as H, encodeCrlDistributionPoints as U, encodeExtension as W, encodeSubjectAltName as G } from "../x509/extensions.js";
14
- import { parseGeneralName as K, parseGeneralNames as q } from "../internal/x509/general-name.js";
15
- import { parseCertificateDerOrThrow as J, parseCertificateFromSource as Y } from "../x509/parse.js";
16
- import { verifySignedDataDetailed as X } from "../internal/crypto/sig-verify.js";
17
- import { encodeAlgorithmIdentifier as Z, getSignatureAlgorithm as te, signBytes as ne } from "../internal/crypto/signing.js";
18
- //#region src/revocation/crl.ts
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 re = {
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
- * Embeds Authority Key Identifier, CRLNumber, delta CRL indicator,
58
- * issuing distribution point, and freshest-CRL extensions as configured.
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
- * issuerPublicKey: caPublicKey,
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(t) {
79
- V(t.issuer) && throwCrlEncoderError("issuer_distinguished_name_empty", "issuer must be a non-empty distinguished name");
80
- let r = te(t.signerPrivateKey), i = t.thisUpdate ?? /* @__PURE__ */ new Date(), a = t.nextUpdate, o = await buildCrlExtensions(t.issuerPublicKey, t.crlNumber, t.baseCrlNumber, t.issuingDistributionPoint, t.freshestCrlDistributionPoints), c = t.revokedCertificates ?? [], l = c.length === 0 ? [] : [f(c.map((e) => createRevokedCertificate(e, i)))], u = f([
81
- s(1),
82
- Z(r),
83
- z(t.issuer),
84
- p(i),
85
- ...a === void 0 ? [] : [p(a)],
86
- ...l,
87
- ...o.length === 0 ? [] : [n(0, f(o))]
88
- ]), d = await ne(t.signerPrivateKey, r, u), m = f([
89
- u,
90
- Z(r),
91
- e(d)
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: j("X509 CRL", m),
96
- base64: E(m)
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 = d(e, { maxDepth: 64 });
112
+ let t = v(e, { maxDepth: 64 });
107
113
  if (t.length !== 3) throw Error("Malformed CRL");
108
- let n = C(t[0], "TBSCertList"), r = C(t[1], "signatureAlgorithm"), i = C(t[2], "signatureValue"), a = parseSignedCrlFields(e.slice(n.start - n.headerLength, n.end)), o = parseAlgorithmIdentifier(e, r);
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: b(i),
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: N(o.oid, o.parametersDer),
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(A("X509 CRL", e));
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(e) {
156
+ function parseCertificateRevocationListDer(t) {
151
157
  try {
152
- return k(parseCertificateRevocationListDerOrThrow(e));
153
- } catch (e) {
154
- return O(e), D("malformed", e instanceof Error ? e.message : "Malformed CRL");
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(e) {
169
+ function parseCertificateRevocationListPem(t) {
164
170
  try {
165
- return k(parseCertificateRevocationListPemOrThrow(e));
166
- } catch (e) {
167
- return O(e), D("malformed", e instanceof Error ? e.message : "Malformed CRL");
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(e, t) {
177
- let n, r;
182
+ async function verifyCertificateRevocationListSignature(t, n) {
183
+ let r, i;
178
184
  try {
179
- n = typeof e == "string" ? parseCertificateRevocationListPemOrThrow(e) : parseCertificateRevocationListDerOrThrow(new Uint8Array(e)), r = typeof t == "string" ? parseIssuerCertificatePem(t) : parseIssuerCertificateDer(new Uint8Array(t));
180
- } catch {
181
- return verifyCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list or issuer certificate input is malformed");
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 i;
190
+ let a;
184
191
  try {
185
- i = await X(n.signatureAlgorithmOid, n.signatureAlgorithmParametersDer, r.publicKeyAlgorithmOid, r.publicKeyParametersOid, r.subjectPublicKeyInfoDer, n.signatureValue, n.tbsCertListDer);
186
- } catch {
187
- return verifyCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature verification failed");
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 i.ok ? i.valid ? {
197
+ return a.ok ? a.valid ? {
190
198
  ok: !0,
191
- value: n
192
- } : verifyCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature does not verify") : i.code === "verification_error" ? verifyCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature verification failed") : verifyCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature uses unsupported algorithm parameters");
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
- * cRLSign key-usage check, signature verification, and `thisUpdate`/`nextUpdate`
197
- * freshness check (with optional clock-skew tolerance).
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
- let t;
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
- t = normalizeCrl(e.crl);
203
- } catch {
204
- return validateCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signed content is malformed");
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 n;
231
+ let i;
207
232
  try {
208
- n = normalizeCrlCertificate(e.issuerCertificate);
209
- } catch {
210
- return validateCertificateRevocationListFailureResult("signature_invalid", "issuer certificate input is malformed");
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 (!L(t.issuer, n.subject)) return validateCertificateRevocationListFailureResult("issuer_mismatch", "CRL issuer name does not match certificate subject");
213
- if (t.authorityKeyIdentifier !== void 0 && n.subjectKeyIdentifier !== void 0 && t.authorityKeyIdentifier !== n.subjectKeyIdentifier) return validateCertificateRevocationListFailureResult("issuer_mismatch", "CRL authority key identifier does not match issuer subject key identifier");
214
- if (n.keyUsage !== void 0 && !n.keyUsage.flags.includes("cRLSign")) return validateCertificateRevocationListFailureResult("crl_sign_not_permitted", "issuer certificate key usage does not permit CRL signing");
215
- let r;
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
- r = await X(t.signatureAlgorithmOid, t.signatureAlgorithmParametersDer, n.publicKeyAlgorithmOid, n.publicKeyParametersOid, n.subjectPublicKeyInfoDer, t.signatureValue, t.tbsCertListDer);
218
- } catch {
219
- return validateCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature verification failed");
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
- if (!r.ok) return r.code === "verification_error" ? validateCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature verification failed") : validateCertificateRevocationListFailureResult("signature_invalid", "certificate revocation list signature uses unsupported algorithm parameters");
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: t
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(e) {
252
- let t;
287
+ async function checkCertificateRevocationAgainstCrl(t) {
288
+ assertCrlMaxAge(t.maxAgeMs);
289
+ let n;
253
290
  try {
254
- t = normalizeCrlCertificate(e.certificate);
255
- } catch {
256
- return checkCertificateRevocationAgainstCrlFailureResult("non_applicable", "certificate input is malformed");
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 n = await validateCertificateRevocationList({
259
- crl: e.crl,
260
- issuerCertificate: e.issuerCertificate,
261
- ...e.at === void 0 ? {} : { at: e.at },
262
- ...e.clockSkewMs === void 0 ? {} : { clockSkewMs: e.clockSkewMs }
263
- });
264
- if (!n.ok) return checkCertificateRevocationAgainstCrlFailureResult(n.code, n.message);
265
- let r = await validateOptionalDeltaCrl(e, n.value);
266
- if (!r.ok) return r;
267
- let i = checkCrlAndDeltaApplicability(t, n.value, r.value);
268
- if (!i.ok) return i.failure;
269
- let a = i.coveredReasons, o = findRevokedCertificateEntry(t, n.value);
270
- if (!o.ok) return o;
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 (r.value !== void 0) {
273
- let e = findRevokedCertificateEntry(t, r.value);
274
- if (!e.ok) return e;
275
- s = e.entry;
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 resolveCertificateRevocationStatus(t, r.value?.thisUpdate, n.value, o.entry, s, a);
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
- return n.ok ? checkDeltaCrlCompatibility(t, n.value) ?? {
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
- } : checkCertificateRevocationAgainstCrlFailureResult(n.code, n.message);
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, t) {
306
- return D(e, t);
381
+ function verifyCertificateRevocationListFailureResult(e, n) {
382
+ return t(e, n);
307
383
  }
308
384
  /** Builds a `ValidateCertificateRevocationListFailureResult`. */
309
- function validateCertificateRevocationListFailureResult(e, t) {
310
- return D(e, t);
385
+ function validateCertificateRevocationListFailureResult(e, n) {
386
+ return t(e, n);
311
387
  }
312
388
  /** Builds a `CheckCertificateRevocationAgainstCrlFailureResult`. */
313
- function checkCertificateRevocationAgainstCrlFailureResult(e, t, n) {
314
- return D(e, t, n);
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) : w(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
- continue;
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 && !L(e.issuer, t.issuer)) return notApplicableOutcome("issuer_mismatch", "CRL issuer does not match certificate issuer for direct CRL processing");
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 && !L(e.issuer, t.issuer) ? notApplicableOutcome("issuer_mismatch", "indirect CRLs for alternate certificate issuers require matching CRLIssuer distribution points") : {
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
- continue;
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 (L(t.issuer, n.issuer) && e.crlIssuer === void 0) return;
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,25 @@ 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 (!L(e.issuer, t.issuer)) return nonApplicable("delta_crl_incompatible", "complete and delta CRLs must share the same issuer");
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
- /** Checks whether any `crlIssuer` GeneralName matches the CRL's issuer via directoryName DER comparison. */
544
+ /** RFC 5280 §4.2.1.13 requires only the CRL issuer DN, with identical DER encoding. */
447
545
  function matchesIndirectCrlIssuer(e, t) {
448
- if (e === void 0) return !1;
449
- let n = !1;
450
- for (let r of e) {
451
- if (r.type === "directoryName") {
452
- if (directoryNameDerHexMatchesParsedName(r.derHex, t.issuer)) return !0;
453
- continue;
454
- }
455
- n = !0;
456
- }
457
- return n ? "unsupported" : !1;
546
+ return e === void 0 || e.length === 0 ? !1 : e.some((e) => e.type !== "directoryName") ? "unsupported" : e.every((e) => e.type === "directoryName" && e.derHex.toLowerCase() === t.issuer.derHex.toLowerCase());
458
547
  }
459
548
  /** Determines whether a revoked entry's effective issuer matches the certificate's issuer. */
460
549
  function matchesRevokedEntryIssuer(e, t, n) {
461
- if (n === void 0) return L(e.issuer, t.issuer) ? "match" : "mismatch";
550
+ if (n === void 0) return K(e.issuer, t.issuer) ? "match" : "mismatch";
462
551
  let r = !1;
463
- for (let t of n) {
464
- if (t.type === "directoryName") {
465
- if (directoryNameDerHexMatchesParsedName(t.derHex, e.issuer)) return "match";
466
- continue;
467
- }
468
- r = !0;
469
- }
552
+ for (let t of n) if (t.type === "directoryName") {
553
+ if (directoryNameDerHexMatchesParsedName(t.derHex, e.issuer)) return "match";
554
+ } else r = !0;
470
555
  return r ? "unsupported" : "mismatch";
471
556
  }
472
557
  /** Shorthand for building a `non_applicable` failure result with the given reason. */
@@ -482,28 +567,28 @@ function nonApplicable(e, t) {
482
567
  * emit it, a complete-CRL `certificateHold` entry or a certificate that
483
568
  * expired before the delta CRL's thisUpdate.
484
569
  */
485
- function resolveCertificateRevocationStatus(e, t, n, r, i, a) {
486
- if (i !== void 0) if (i.reasonCode === "removeFromCRL") {
487
- if (r?.reasonCode === "certificateHold" || t !== void 0 && e.notAfter.getTime() < t.getTime()) return checkCertificateRevocationAgainstCrlSuccess({
488
- status: "good",
489
- crl: n,
490
- coveredReasons: a
491
- });
492
- } else return checkCertificateRevocationAgainstCrlSuccess({
493
- status: "revoked",
494
- crl: n,
495
- revocationDate: i.revocationDate,
496
- ...i.reasonCode === void 0 ? {} : { reasonCode: i.reasonCode }
497
- });
498
- return checkCertificateRevocationAgainstCrlSuccess(r === void 0 ? {
570
+ function resolveCertificateRevocationStatus(e, t, n, r, i, a, o) {
571
+ if (i !== void 0) {
572
+ if (i.reasonCode === "removeFromCRL") {
573
+ if (r?.reasonCode === "certificateHold" || t !== void 0 && e.notAfter.getTime() < t.getTime()) return checkCertificateRevocationAgainstCrlSuccess({
574
+ status: "good",
575
+ crl: n,
576
+ coveredReasons: a
577
+ });
578
+ } else return revokedEntryResult(n, i, o);
579
+ }
580
+ return r === void 0 ? checkCertificateRevocationAgainstCrlSuccess({
499
581
  status: "good",
500
582
  crl: n,
501
583
  coveredReasons: a
502
- } : {
584
+ }) : revokedEntryResult(n, r, o);
585
+ }
586
+ function revokedEntryResult(e, t, n) {
587
+ return n === "reject" && typeof t.reasonCode == "object" ? checkCertificateRevocationAgainstCrlFailureResult("reason_code_unrecognized", `CRL entry carries unrecognized reason code ${String(t.reasonCode.code)}`) : checkCertificateRevocationAgainstCrlSuccess({
503
588
  status: "revoked",
504
- crl: n,
505
- revocationDate: r.revocationDate,
506
- ...r.reasonCode === void 0 ? {} : { reasonCode: r.reasonCode }
589
+ crl: e,
590
+ revocationDate: t.revocationDate,
591
+ ...t.reasonCode === void 0 ? {} : { reasonCode: t.reasonCode }
507
592
  });
508
593
  }
509
594
  /**
@@ -521,7 +606,7 @@ function matchesDistributionPointName(e, t, n, r) {
521
606
  let r = resolveRelativeNameToDnHex(n, e.relativeName);
522
607
  return t.fullName.some((e) => e.type === "directoryName" && e.derHex === r);
523
608
  }
524
- if (e.type === "relativeName" && t.type === "relativeName") return compareRelativeDistinguishedNames(e.relativeName, t.relativeName);
609
+ if (e.type === "relativeName" && t.type === "relativeName") return q(e.relativeName, t.relativeName);
525
610
  if (e.type === "fullName" && t.type === "relativeName") {
526
611
  let r = resolveRelativeNameToDnHex(n, t.relativeName);
527
612
  return e.fullName.some((e) => e.type === "directoryName" && e.derHex === r);
@@ -541,12 +626,13 @@ function matchesIdpNameAgainstCrlIssuer(e, t, n) {
541
626
  }
542
627
  /** Constructs a full DN by appending an RDN to an existing Name, returning hex-encoded DER. */
543
628
  function resolveRelativeNameToDnHex(e, t) {
544
- let n = e.rdns.map((e) => x(e.derHex)), r = rebuildRelativeNameAsSet(x(t.derHex));
545
- return n.push(r), w(f(n));
629
+ let n = e.rdns.map((e) => k(e.derHex)), r = rebuildRelativeNameAsSet(k(t.derHex));
630
+ return n.push(r), M(y(n));
546
631
  }
547
632
  /** Converts an implicit-tagged [1] relativeName to a proper SET-tagged RDN. */
548
633
  function rebuildRelativeNameAsSet(e) {
549
- return m(49, u(e, { maxDepth: 64 }).value);
634
+ let t = _(e, { maxDepth: 64 });
635
+ return x(49, t.value);
550
636
  }
551
637
  /** Deep-compares two issuing distribution point extensions for delta-CRL compatibility. */
552
638
  function sameIssuingDistributionPoint(e, t) {
@@ -554,7 +640,7 @@ function sameIssuingDistributionPoint(e, t) {
554
640
  }
555
641
  /** Compares two DistributionPointName values (fullName set or relativeName). */
556
642
  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" && compareRelativeDistinguishedNames(e.relativeName, t.relativeName);
643
+ 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
644
  }
559
645
  /** Set-equality comparison for GeneralName arrays (order-independent). */
560
646
  function sameGeneralNameSet(e, t) {
@@ -583,15 +669,24 @@ function hasOverlappingReasons(e, t) {
583
669
  }
584
670
  /** Value-equality for two GeneralName entries, using DER comparison for directoryName. */
585
671
  function compareGeneralNames(e, t) {
586
- if (e.type === "dns" && t.type === "dns" || e.type === "srv" && t.type === "srv") return e.value.toLowerCase() === t.value.toLowerCase();
672
+ if (e.type === "dns" && t.type === "dns") return e.value.toLowerCase() === t.value.toLowerCase();
673
+ if (e.type === "srv" && t.type === "srv") return compareSrvNames(e.value.toLowerCase(), t.value.toLowerCase());
587
674
  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;
675
+ if (e.type === "smtpUtf8Mailbox" && t.type === "smtpUtf8Mailbox" || e.type === "ip" && t.type === "ip") return e.value === t.value;
589
676
  if (e.type === "uri" && t.type === "uri") return compareUniformResourceIdentifiers(e.value, t.value);
590
677
  if (e.type === "directoryName" && t.type === "directoryName") {
591
678
  let n = parseDerHexName(e.derHex), r = parseDerHexName(t.derHex);
592
- return n === void 0 || r === void 0 ? !1 : L(n, r);
679
+ return n === void 0 || r === void 0 ? !1 : K(n, r);
593
680
  }
594
- return e.type === "unknown" && t.type === "unknown" && e.tag === t.tag && bytesEqual(e.value, t.value);
681
+ return compareOpaqueGeneralNames(e, t);
682
+ }
683
+ function compareSrvNames(e, t) {
684
+ let n = W(e), r = W(t);
685
+ return n === void 0 || r === void 0 ? e === t : n.service === r.service && n.name === r.name;
686
+ }
687
+ /** Encoding equality for the GeneralName alternatives carried as DER or an OID. */
688
+ function compareOpaqueGeneralNames(e, t) {
689
+ 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
690
  }
596
691
  /** RFC 5280 §7.5: rfc822Name local-part is case-sensitive, the host-part case-insensitive. */
597
692
  function compareRfc822Names(e, t) {
@@ -609,7 +704,7 @@ function compareUniformResourceIdentifiers(e, t) {
609
704
  * the default port that scheme-based normalization elides. `ldaps` is included
610
705
  * as the TLS form of the mandatory `ldap` scheme.
611
706
  */
612
- const ie = /* @__PURE__ */ new Map([
707
+ const ue = /* @__PURE__ */ new Map([
613
708
  ["ftp", "21"],
614
709
  ["http", "80"],
615
710
  ["https", "443"],
@@ -638,7 +733,7 @@ function normalizeUriForComparison(e) {
638
733
  if (e === void 0) return;
639
734
  t.hostname = e;
640
735
  }
641
- return t.port === ie.get(t.protocol.slice(0, -1)) && (t.port = ""), normalizePercentEncoding(t.href);
736
+ return t.port === ue.get(t.protocol.slice(0, -1)) && (t.port = ""), normalizePercentEncoding(t.href);
642
737
  }
643
738
  /**
644
739
  * Reparses a host under a special scheme so the URL parser applies IDNA and
@@ -662,10 +757,10 @@ function decodeHostPercentEncoding(e) {
662
757
  return e;
663
758
  }
664
759
  }
665
- const ae = /%[0-9A-Fa-f]{2}/g;
760
+ const de = /%[0-9A-Fa-f]{2}/g;
666
761
  /** RFC 3986 §6.2.2.2: unreserved triplets decode, every other triplet uppercases. */
667
762
  function normalizePercentEncoding(e) {
668
- return e.replace(ae, (e) => {
763
+ return e.replace(de, (e) => {
669
764
  let t = Number.parseInt(e.slice(1), 16);
670
765
  return isUnreservedUriCharacter(t) ? String.fromCharCode(t) : e.toUpperCase();
671
766
  });
@@ -680,51 +775,30 @@ function bytesEqual(e, t) {
680
775
  for (let n = 0; n < e.length; n += 1) if (e[n] !== t[n]) return !1;
681
776
  return !0;
682
777
  }
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
778
  /** Assembles the CRL-level v2 extensions (AKI, CRLNumber, deltaCRLIndicator, IDP, freshestCRL). */
701
- async function buildCrlExtensions(e, t, n, r, i) {
702
- let o = [];
703
- if (e !== void 0) {
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;
779
+ function buildCrlExtensions(e, t, n, r, i) {
780
+ let a = [X(N.authorityKeyIdentifier, y([p(0, se(e))])), X(N.cRLNumber, t)];
781
+ 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
782
  }
709
783
  /** DER-encodes a single revokedCertificate SEQUENCE (serial, date, optional extensions). */
710
784
  function createRevokedCertificate(e, t) {
711
785
  let n = buildRevokedCertificateExtensions(e);
712
- return f([
713
- o(e.serialNumber),
714
- p(e.revocationDate ?? t),
715
- ...n.length === 0 ? [] : [f(n)]
786
+ return y([
787
+ m(e.serialNumber),
788
+ b(e.revocationDate ?? t),
789
+ ...n.length === 0 ? [] : [y(n)]
716
790
  ]);
717
791
  }
718
792
  /** Encodes CRL entry extensions (reasonCode, invalidityDate). */
719
793
  function buildRevokedCertificateExtensions(e) {
720
794
  let t = [];
721
- return e.reasonCode !== void 0 && t.push(W(T.cRLReason, m(10, Uint8Array.of(re[e.reasonCode])))), e.invalidityDate !== void 0 && t.push(W(T.invalidityDate, r(e.invalidityDate))), t;
795
+ 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
796
  }
723
797
  /** Decodes per-entry CRL extensions (reasonCode, invalidityDate, certificateIssuer). */
724
798
  function parseRevokedCertificateExtensions(e, t) {
725
799
  if (e === void 0 || t === void 0) return {};
726
800
  let n = {}, r = /* @__PURE__ */ new Set();
727
- for (let i of h(e, t)) parseRevokedCertificateExtension(e, i, r, n);
801
+ for (let i of S(e, t)) parseRevokedCertificateExtension(e, i, r, n);
728
802
  return {
729
803
  ...n.reasonCode === void 0 ? {} : { reasonCode: n.reasonCode },
730
804
  ...n.invalidityDate === void 0 ? {} : { invalidityDate: n.invalidityDate },
@@ -732,30 +806,37 @@ function parseRevokedCertificateExtensions(e, t) {
732
806
  };
733
807
  }
734
808
  function parseRevokedCertificateExtension(e, t, n, r) {
735
- let i = h(e, t);
809
+ let i = S(e, t);
736
810
  if (i.length < 2 || i.length > 3 || i.length === 3 && i[1]?.tag !== 1) throw Error("Malformed revoked certificate extension");
737
- let a = v(C(i[0], "revoked certificate extension OID").value);
811
+ let a = E(j(i[0], "revoked certificate extension OID").value);
738
812
  if (n.has(a)) throw Error(`Duplicate revoked certificate extension OID: ${a}`);
739
813
  n.add(a);
740
- let o = C(i[i.length - 1], "revoked certificate extension value");
741
- if (o.tag !== 4) throw Error("Revoked certificate extension value must use OCTET STRING");
742
- applyRevokedCertificateExtensionValue(a, o.value, r);
743
- }
744
- function applyRevokedCertificateExtensionValue(e, t, n) {
745
- if (e === T.cRLReason) {
746
- let e = revocationReasonFromCode(l(t).value[0]);
747
- e !== void 0 && (n.reasonCode = e);
814
+ let o = i.length === 3 && C(j(i[1], "revoked certificate extension critical").value), s = j(i[i.length - 1], "revoked certificate extension value");
815
+ if (s.tag !== 4) throw Error("Revoked certificate extension value must use OCTET STRING");
816
+ if (o && !isSupportedRevokedCertificateExtensionOid(a)) throw Error(`Unsupported critical revoked certificate extension OID: ${a}`);
817
+ applyRevokedCertificateExtensionValue(a, s.value, o, r);
818
+ }
819
+ function isSupportedRevokedCertificateExtensionOid(e) {
820
+ return e === N.cRLReason || e === N.invalidityDate || e === N.certificateIssuer;
821
+ }
822
+ function applyRevokedCertificateExtensionValue(e, t, n, r) {
823
+ if (e === N.cRLReason) {
824
+ let e = _(t, { maxDepth: 64 });
825
+ if (e.tag !== 10) throw Error("cRLReason must use ENUMERATED");
826
+ let i = parsedRevocationReason(te(e.value, "cRLReason"));
827
+ if (n && typeof i != "string") throw Error(`Critical cRLReason holds unrecognized reason code ${String(i.code)}`);
828
+ r.reasonCode = i;
748
829
  }
749
- if (e === T.invalidityDate && (n.invalidityDate = S(l(t))), e === T.certificateIssuer) {
750
- let e = u(t, { maxDepth: 64 });
830
+ if (e === N.invalidityDate && (r.invalidityDate = A(_(t, { maxDepth: 64 }))), e === N.certificateIssuer) {
831
+ let e = _(t, { maxDepth: 64 });
751
832
  if (e.tag !== 48) throw Error("certificateIssuer must use SEQUENCE");
752
- n.certificateIssuer = q(t, e);
833
+ r.certificateIssuer = U(t, e);
753
834
  }
754
835
  }
755
836
  /** Decodes the IssuingDistributionPoint extension from its OCTET STRING content. */
756
837
  function parseIssuingDistributionPoint(e) {
757
- let t = u(e, { maxDepth: 64 }), n = {};
758
- for (let r of h(e, t)) parseIssuingDistributionPointField(e, r, n);
838
+ let t = _(e, { maxDepth: 64 }), n = {};
839
+ for (let r of S(e, t)) parseIssuingDistributionPointField(e, r, n);
759
840
  return {
760
841
  ...n.distributionPoint === void 0 ? {} : { distributionPoint: n.distributionPoint },
761
842
  ...n.onlySomeReasons === void 0 ? {} : { onlySomeReasons: n.onlySomeReasons },
@@ -823,7 +904,7 @@ function parseIssuingDistributionPointField(e, t, n) {
823
904
  return;
824
905
  case 131:
825
906
  if (n.onlySomeReasons !== void 0) throw Error("IssuingDistributionPoint onlySomeReasons must not repeat");
826
- n.onlySomeReasons = F(t.value);
907
+ n.onlySomeReasons = V(t.value);
827
908
  return;
828
909
  case 132:
829
910
  n.indirectCrl = parseUniqueIssuingDistributionPointBoolean(n.indirectCrl, t, "indirectCrl");
@@ -836,28 +917,28 @@ function parseIssuingDistributionPointField(e, t, n) {
836
917
  }
837
918
  function parseUniqueIssuingDistributionPointBoolean(e, t, n) {
838
919
  if (e !== void 0) throw Error(`IssuingDistributionPoint ${n} must not repeat`);
839
- return parseImplicitBoolean(t);
920
+ return C(t.value);
840
921
  }
841
922
  /** Decodes a SEQUENCE OF DistributionPoint from DER. */
842
923
  function parseDistributionPoints(e) {
843
- let t = u(e, { maxDepth: 64 });
924
+ let t = _(e, { maxDepth: 64 });
844
925
  if (t.tag !== 48) throw Error("DistributionPoints must use SEQUENCE");
845
- let n = h(e, t);
926
+ let n = S(e, t);
846
927
  if (n.length === 0) throw Error("DistributionPoints must not be empty");
847
928
  return n.map((t) => parseDistributionPoint(e, t));
848
929
  }
849
930
  /** Decodes a DistributionPointName (fullName or relativeName). */
850
931
  function parseDistributionPointName(e, t) {
851
- let n = h(e, t);
932
+ let n = S(e, t);
852
933
  if (n.length !== 1) throw Error("distributionPointName must contain exactly one choice");
853
- let r = C(n[0], "distributionPointName");
934
+ let r = j(n[0], "distributionPointName");
854
935
  if (r.tag === 160) {
855
- let t = h(e, r);
936
+ let t = S(e, r);
856
937
  if (t.length === 0) throw Error("distributionPointName fullName must not be empty");
857
938
  for (let e of t) if ((e.tag & 192) != 128) throw Error("distributionPointName fullName must contain GeneralName entries");
858
939
  return {
859
940
  type: "fullName",
860
- fullName: t.map((t) => K(e, t))
941
+ fullName: t.map((t) => H(e, t))
861
942
  };
862
943
  }
863
944
  if (r.tag === 161) return {
@@ -870,7 +951,7 @@ function parseDistributionPointName(e, t) {
870
951
  function parseDistributionPoint(e, t) {
871
952
  if (t.tag !== 48) throw Error("DistributionPoint must use SEQUENCE");
872
953
  let n = {};
873
- for (let r of h(e, t)) parseDistributionPointField(e, r, n);
954
+ for (let r of S(e, t)) parseDistributionPointField(e, r, n);
874
955
  if (n.distributionPoint === void 0 && n.crlIssuer === void 0) throw Error("DistributionPoint must include distributionPoint or crlIssuer");
875
956
  return {
876
957
  ...n.distributionPoint === void 0 ? {} : { distributionPoint: n.distributionPoint },
@@ -888,11 +969,11 @@ function parseDistributionPointField(e, t, n) {
888
969
  }
889
970
  case 129:
890
971
  if (n.reasons !== void 0) throw Error("DistributionPoint reasons must not repeat");
891
- n.reasons = F(t.value);
972
+ n.reasons = V(t.value);
892
973
  return;
893
974
  case 162:
894
975
  if (n.crlIssuer !== void 0) throw Error("DistributionPoint crlIssuer must not repeat");
895
- n.crlIssuer = q(e, t);
976
+ n.crlIssuer = U(e, t);
896
977
  return;
897
978
  default: throw Error(`Unsupported DistributionPoint field tag: ${String(t.tag)}`);
898
979
  }
@@ -900,8 +981,8 @@ function parseDistributionPointField(e, t, n) {
900
981
  /** Decodes a RelativeDistinguishedName SET from an implicitly-tagged context element. */
901
982
  function parseRelativeName(e, t) {
902
983
  let n = [], r = {};
903
- for (let i of h(e, t)) {
904
- let t = h(e, i), a = v(C(t[0], "name OID").value), o = C(t[1], "name value"), s = I(a), c = decodeNameValue(o), l = s === void 0 ? {
984
+ for (let i of S(e, t)) {
985
+ 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
986
  oid: a,
906
987
  valueTag: o.tag,
907
988
  value: c
@@ -914,22 +995,40 @@ function parseRelativeName(e, t) {
914
995
  n.push(l), s !== void 0 && r[s] === void 0 && (r[s] = c);
915
996
  }
916
997
  return {
917
- derHex: w(e.slice(t.start - t.headerLength, t.end)),
998
+ derHex: M(e.slice(t.start - t.headerLength, t.end)),
918
999
  attributes: n,
919
1000
  values: r
920
1001
  };
921
1002
  }
922
1003
  /** Decodes an ASN.1 string element (UTF8String, PrintableString, etc.) to a JS string. */
923
1004
  function decodeNameValue(e) {
924
- return y(e.tag, e.value);
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;
1005
+ return D(e.tag, e.value);
929
1006
  }
930
1007
  /** Throws a {@link ResultError} for a CRL encoder input-validation failure. */
931
1008
  function throwCrlEncoderError(e, t) {
932
- ee(e, t);
1009
+ i(e, t);
1010
+ }
1011
+ /** The parsed issuer certificate of a CRL being built. */
1012
+ function issuerCertificateOf(t) {
1013
+ try {
1014
+ return normalizeCrlCertificate(t);
1015
+ } catch (t) {
1016
+ return s(t, e), throwCrlEncoderError("issuer_certificate_invalid", "issuerCertificate must be a PEM, DER or parsed certificate");
1017
+ }
1018
+ }
1019
+ /** RFC 5280 §5.2.3 `CRLNumber ::= INTEGER (0..MAX)` as a DER INTEGER of at most 20 content octets. */
1020
+ function encodeCrlNumber(e, t) {
1021
+ 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];
1022
+ 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);
1023
+ }
1024
+ /** RFC 5280 §5.2.3: a received CRLNumber of any length, since verifiers MUST handle up to 20 octets. */
1025
+ function decodeCrlNumber(e) {
1026
+ let t = _(e, { maxDepth: 64 });
1027
+ if (t.tag !== 2) throw Error("CRLNumber must be an INTEGER");
1028
+ return w(t.value, "CRLNumber"), BigInt(`0x${M(t.value)}`);
1029
+ }
1030
+ function assertCrlDate(e, t) {
1031
+ e !== void 0 && Number.isNaN(e.getTime()) && throwCrlEncoderError("invalid_date", `${t} must be a valid date`);
933
1032
  }
934
1033
  /** DER-encodes an IssuingDistributionPoint extension value. Throws on mutually-exclusive scope flags. */
935
1034
  function encodeIssuingDistributionPoint(e) {
@@ -939,37 +1038,31 @@ function encodeIssuingDistributionPoint(e) {
939
1038
  e.onlyContainsAttributeCerts === !0
940
1039
  ].filter(Boolean).length > 1) throw Error("IssuingDistributionPoint can assert at most one of user, CA, or attribute cert scope");
941
1040
  let t = [];
942
- return e.distributionPoint !== void 0 && t.push(i(0, encodeDistributionPointName(e.distributionPoint))), e.onlyContainsUserCerts && t.push(a(1, Uint8Array.of(255))), e.onlyContainsCACerts && t.push(a(2, Uint8Array.of(255))), e.onlySomeReasons !== void 0 && e.onlySomeReasons.length > 0 && t.push(a(3, P(e.onlySomeReasons))), e.indirectCrl && t.push(a(4, Uint8Array.of(255))), e.onlyContainsAttributeCerts && t.push(a(5, Uint8Array.of(255))), f(t);
1041
+ 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
1042
  }
944
1043
  /** DER-encodes a DistributionPointName (fullName or relativeName). */
945
1044
  function encodeDistributionPointName(e) {
946
1045
  if (e === void 0) throw Error("IssuingDistributionPoint distributionPoint is required");
947
1046
  switch (e.type) {
948
- case "fullName": return e.fullName.length === 0 && throwCrlEncoderError("distribution_point_full_name_empty", "DistributionPointName fullName must not be empty"), i(0, concatGeneralNames(e.fullName));
1047
+ 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
1048
  case "relativeName": {
950
- let t = B(e.relativeName), n = l(t);
951
- return i(1, t.slice(n.start, n.end));
1049
+ let t = Y(e.relativeName), n = g(t);
1050
+ return f(1, t.slice(n.start, n.end));
952
1051
  }
953
1052
  default: throw Error(`Unhandled DistributionPointName type: ${String(e)}`);
954
1053
  }
955
1054
  }
956
1055
  /** DER-encodes and concatenates a list of GeneralName values. */
957
1056
  function concatGeneralNames(e) {
958
- return t(e.map((e) => G(e)));
1057
+ return l(e.map((e) => oe(e)));
959
1058
  }
960
1059
  /** Parses a Name SEQUENCE element into a full {@linkcode ParsedName}. */
961
1060
  function parseIssuer(e, t) {
962
- let n = w(e.slice(t.start - t.headerLength, t.end)), r = [], i = [], a = {};
963
- for (let n of h(e, t)) {
1061
+ let n = M(e.slice(t.start - t.headerLength, t.end)), r = [], i = [], a = {};
1062
+ for (let n of S(e, t)) {
964
1063
  let t = [], o = {};
965
- for (let r of h(e, n)) {
966
- let n = h(e, r), s = C(n[0], "issuer attribute OID"), c = C(n[1], "issuer attribute value"), l = v(s.value), u;
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 ? {
1064
+ for (let r of S(e, n)) {
1065
+ 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
1066
  oid: l,
974
1067
  valueTag: c.tag,
975
1068
  value: u
@@ -982,7 +1075,7 @@ function parseIssuer(e, t) {
982
1075
  t.push(f), i.push(f), d !== void 0 && (o[d] === void 0 && (o[d] = u), a[d] === void 0 && (a[d] = u));
983
1076
  }
984
1077
  r.push({
985
- derHex: w(e.slice(n.start - n.headerLength, n.end)),
1078
+ derHex: M(e.slice(n.start - n.headerLength, n.end)),
986
1079
  attributes: t,
987
1080
  values: o
988
1081
  });
@@ -994,28 +1087,38 @@ function parseIssuer(e, t) {
994
1087
  values: a
995
1088
  };
996
1089
  }
997
- /** Re-parses a hex-encoded DER Name into a {@linkcode ParsedName}. Returns `undefined` on malformed input. */
998
- function parseDerHexName(e) {
1090
+ /**
1091
+ * Re-parses a hex-encoded DER Name into a {@linkcode ParsedName}. Returns
1092
+ * `undefined` on malformed input and throws a decode refusal.
1093
+ */
1094
+ function parseDerHexName(t) {
999
1095
  try {
1000
- let t = x(e), n = unwrapNameElement(t, u(t, { maxDepth: 64 }));
1001
- return n.tag === 48 ? parseIssuer(t, n) : void 0;
1002
- } catch {
1096
+ let e = k(t), n = unwrapNameElement(e, _(e, { maxDepth: 64 }));
1097
+ return n.tag === 48 ? parseIssuer(e, n) : void 0;
1098
+ } catch (t) {
1099
+ s(t, e);
1003
1100
  return;
1004
1101
  }
1005
1102
  }
1103
+ /** The failure for a decode refusal a directoryName comparison threw. */
1104
+ function crlNameRefusalFailure(t) {
1105
+ let n = o(t, e);
1106
+ if (n === void 0) throw t;
1107
+ return checkCertificateRevocationAgainstCrlFailureResult(n.code, n.message);
1108
+ }
1006
1109
  function unwrapNameElement(e, t) {
1007
1110
  if (t.tag !== 48) return t;
1008
- let n = h(e, t), r = n[0];
1111
+ let n = S(e, t), r = n[0];
1009
1112
  return n.length === 1 && r?.tag === 48 ? r : t;
1010
1113
  }
1011
1114
  /** Semantic comparison of a GeneralName directoryName `derHex` against a {@linkcode ParsedName}. */
1012
1115
  function directoryNameDerHexMatchesParsedName(e, t) {
1013
1116
  let n = parseDerHexName(e);
1014
- return n !== void 0 && L(n, t);
1117
+ return n !== void 0 && K(n, t);
1015
1118
  }
1016
1119
  /** Extracts the keyIdentifier field from an AuthorityKeyIdentifier extension value. */
1017
1120
  function parseAuthorityKeyIdentifier(e) {
1018
- let t = u(e, {
1121
+ let t = _(e, {
1019
1122
  maxDepth: 64,
1020
1123
  allowOpaqueConstructedTags: [161, 162]
1021
1124
  });
@@ -1025,7 +1128,7 @@ function parseAuthorityKeyIdentifier(e) {
1025
1128
  sawAuthorityCertSerialNumber: !1,
1026
1129
  lastFieldOrder: -1
1027
1130
  };
1028
- for (let r of h(e, t)) parseAuthorityKeyIdentifierField(e, r, n);
1131
+ for (let r of S(e, t)) parseAuthorityKeyIdentifierField(e, r, n);
1029
1132
  return n.keyIdentifier;
1030
1133
  }
1031
1134
  function parseAuthorityKeyIdentifierField(e, t, n) {
@@ -1045,12 +1148,12 @@ function parseAuthorityKeyIdentifierField(e, t, n) {
1045
1148
  function parseAuthorityKeyIdentifierKeyId(e, t) {
1046
1149
  if (t.keyIdentifier !== void 0) throw Error("authorityKeyIdentifier keyIdentifier must not repeat");
1047
1150
  if (t.lastFieldOrder >= 0) throw Error("authorityKeyIdentifier fields must preserve DER order");
1048
- t.keyIdentifier = w(e.value), t.lastFieldOrder = 0;
1151
+ t.keyIdentifier = M(e.value), t.lastFieldOrder = 0;
1049
1152
  }
1050
1153
  function parseAuthorityKeyIdentifierIssuer(e, t, n) {
1051
1154
  if (n.sawAuthorityCertIssuer) throw Error("authorityKeyIdentifier authorityCertIssuer must not repeat");
1052
1155
  if (n.lastFieldOrder >= 1) throw Error("authorityKeyIdentifier fields must preserve DER order");
1053
- q(e, t), n.sawAuthorityCertIssuer = !0, n.lastFieldOrder = 1;
1156
+ U(e, t), n.sawAuthorityCertIssuer = !0, n.lastFieldOrder = 1;
1054
1157
  }
1055
1158
  function parseAuthorityKeyIdentifierSerial(e, t) {
1056
1159
  if (t.sawAuthorityCertSerialNumber) throw Error("authorityKeyIdentifier authorityCertSerialNumber must not repeat");
@@ -1065,13 +1168,13 @@ function validateImplicitSerialNumberEncoding(e, t) {
1065
1168
  }
1066
1169
  /** RFC 5280 §5.1.1.2: signatureAlgorithm MUST equal the tbsCertList signature field. */
1067
1170
  function assertMatchingCrlSignatureAlgorithms(e, t) {
1068
- if (e.oid !== t.oid || !c(e.parametersDer, t.parametersDer)) throw Error("CRL signatureAlgorithm must match TBSCertList signature");
1171
+ if (e.oid !== t.oid || !ee(e.parametersDer, t.parametersDer)) throw Error("CRL signatureAlgorithm must match TBSCertList signature");
1069
1172
  }
1070
1173
  /** Extracts the algorithm OID from an AlgorithmIdentifier SEQUENCE. */
1071
1174
  function parseAlgorithmIdentifier(e, t) {
1072
- let n = h(e, t), r = C(n[0], "algorithm OID"), i = n[1];
1073
- return i === void 0 ? { oid: v(r.value) } : {
1074
- oid: v(r.value),
1175
+ let n = S(e, t), r = j(n[0], "algorithm OID"), i = n[1];
1176
+ return i === void 0 ? { oid: E(r.value) } : {
1177
+ oid: E(r.value),
1075
1178
  parametersDer: e.slice(i.start - i.headerLength, i.end)
1076
1179
  };
1077
1180
  }
@@ -1079,30 +1182,46 @@ function parseAlgorithmIdentifier(e, t) {
1079
1182
  function normalizeHex(e) {
1080
1183
  return e.toLowerCase();
1081
1184
  }
1082
- /** Maps an integer CRLReason code back to its {@linkcode RevocationReason} string, or `undefined` for unknown codes. */
1185
+ /**
1186
+ * Maps an integer CRLReason code to its {@linkcode RevocationReason} name, or to
1187
+ * an {@linkcode UnrecognizedRevocationReason} carrying a code outside RFC 5280
1188
+ * §5.3.1. Returns `undefined` only when `code` is `undefined`.
1189
+ */
1083
1190
  function revocationReasonFromCode(e) {
1191
+ return e === void 0 ? void 0 : parsedRevocationReason(e);
1192
+ }
1193
+ function parsedRevocationReason(e) {
1084
1194
  switch (e) {
1085
- case 0: return "unspecified";
1086
- case 1: return "keyCompromise";
1087
- case 2: return "cACompromise";
1088
- case 3: return "affiliationChanged";
1089
- case 4: return "superseded";
1090
- case 5: return "cessationOfOperation";
1091
- case 6: return "certificateHold";
1092
- case 8: return "removeFromCRL";
1093
- case 9: return "privilegeWithdrawn";
1094
- case 10: return "aACompromise";
1195
+ case 0n: return "unspecified";
1196
+ case 1n: return "keyCompromise";
1197
+ case 2n: return "cACompromise";
1198
+ case 3n: return "affiliationChanged";
1199
+ case 4n: return "superseded";
1200
+ case 5n: return "cessationOfOperation";
1201
+ case 6n: return "certificateHold";
1202
+ case 8n: return "removeFromCRL";
1203
+ case 9n: return "privilegeWithdrawn";
1204
+ case 10n: return "aACompromise";
1205
+ default: return {
1206
+ type: "unrecognized",
1207
+ code: e
1208
+ };
1095
1209
  }
1096
1210
  }
1097
1211
  /** Thin wrapper — parses a DER-encoded certificate for use as a CRL issuer. */
1098
1212
  function parseIssuerCertificateDer(e) {
1099
- return Y(e);
1213
+ return Z(e);
1100
1214
  }
1101
1215
  /** Thin wrapper — parses a PEM-encoded certificate for use as a CRL issuer. */
1102
1216
  function parseIssuerCertificatePem(e) {
1103
- return Y(e);
1217
+ return Z(e);
1104
1218
  }
1105
- /** Accepts PEM, DER, or already-parsed CRL and returns a parsed CRL. */
1219
+ /**
1220
+ * Parses PEM, DER, or an already-parsed CRL's `der`, so every decoded field
1221
+ * comes from the signed bytes.
1222
+ *
1223
+ * @internal
1224
+ */
1106
1225
  function normalizeCrl(e) {
1107
1226
  if (typeof e == "string") return parseCertificateRevocationListPemOrThrow(e);
1108
1227
  if (e instanceof Uint8Array) return parseCertificateRevocationListDerOrThrow(new Uint8Array(e));
@@ -1110,22 +1229,22 @@ function normalizeCrl(e) {
1110
1229
  throw Error("certificate revocation list input is malformed");
1111
1230
  }
1112
1231
  function parseSignedCrlFields(e) {
1113
- let t = h(e, u(e, { maxDepth: 64 })), n = parseCrlVersionField(t), r = n.version, i = C(t[n.nextIndex], "signature"), a = n.nextIndex + 1, o = C(t[a], "issuer"), s = C(t[a + 1], "thisUpdate"), c = a + 2, l = t[c], d = l !== void 0 && (l.tag === 23 || l.tag === 24) ? S(l) : void 0;
1114
- d !== void 0 && (c += 1);
1115
- let f = t[c], p = f?.tag === 48 ? parseRevokedCertificates(e, f, r) : [];
1116
- f?.tag === 48 && (c += 1);
1117
- let m = t[c], g = parseCrlExtensionFields(e, m, r);
1232
+ 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;
1233
+ d !== void 0 && (l += 1);
1234
+ let f = n[l], p = f?.tag === 48 ? parseRevokedCertificates(e, f, i) : [];
1235
+ f?.tag === 48 && (l += 1);
1236
+ let m = n[l], h = parseCrlExtensionFields(e, m, i);
1118
1237
  return {
1119
- version: r,
1120
- signature: parseAlgorithmIdentifier(e, i),
1121
- issuer: parseIssuer(e, o),
1122
- thisUpdate: S(s),
1238
+ version: i,
1239
+ signature: parseAlgorithmIdentifier(e, a),
1240
+ issuer: parseIssuer(e, s),
1241
+ thisUpdate: A(c),
1123
1242
  ...d === void 0 ? {} : { nextUpdate: d },
1124
- ...g.authorityKeyIdentifier === void 0 ? {} : { authorityKeyIdentifier: g.authorityKeyIdentifier },
1125
- ...g.crlNumber === void 0 ? {} : { crlNumber: g.crlNumber },
1126
- ...g.baseCrlNumber === void 0 ? {} : { baseCrlNumber: g.baseCrlNumber },
1127
- ...g.issuingDistributionPoint === void 0 ? {} : { issuingDistributionPoint: g.issuingDistributionPoint },
1128
- ...g.freshestCrlDistributionPoints === void 0 ? {} : { freshestCrlDistributionPoints: g.freshestCrlDistributionPoints },
1243
+ ...h.authorityKeyIdentifier === void 0 ? {} : { authorityKeyIdentifier: h.authorityKeyIdentifier },
1244
+ ...h.crlNumber === void 0 ? {} : { crlNumber: h.crlNumber },
1245
+ ...h.baseCrlNumber === void 0 ? {} : { baseCrlNumber: h.baseCrlNumber },
1246
+ ...h.issuingDistributionPoint === void 0 ? {} : { issuingDistributionPoint: h.issuingDistributionPoint },
1247
+ ...h.freshestCrlDistributionPoints === void 0 ? {} : { freshestCrlDistributionPoints: h.freshestCrlDistributionPoints },
1129
1248
  revokedCertificates: p
1130
1249
  };
1131
1250
  }
@@ -1136,7 +1255,7 @@ function parseCrlVersionField(e) {
1136
1255
  version: 1,
1137
1256
  nextIndex: 0
1138
1257
  };
1139
- let n = _(t.value) + 1;
1258
+ let n = T(t.value) + 1;
1140
1259
  if (n !== 2) throw Error(`Unsupported CRL version: ${String(n)}`);
1141
1260
  return {
1142
1261
  version: n,
@@ -1144,17 +1263,17 @@ function parseCrlVersionField(e) {
1144
1263
  };
1145
1264
  }
1146
1265
  function parseRevokedCertificates(e, t, n) {
1147
- return h(e, t).map((t) => parseRevokedCertificateEntry(e, t, n));
1266
+ return S(e, t).map((t) => parseRevokedCertificateEntry(e, t, n));
1148
1267
  }
1149
1268
  function parseRevokedCertificateEntry(e, t, n) {
1150
- let r = e.slice(t.start - t.headerLength, t.end), i = d(r), a = C(i[0], "revoked serialNumber");
1269
+ let r = e.slice(t.start - t.headerLength, t.end), i = v(r), a = j(i[0], "revoked serialNumber");
1151
1270
  if (a.tag !== 2) throw Error("revoked serialNumber must use INTEGER");
1152
1271
  let o = i[2];
1153
1272
  if (o !== void 0 && n !== 2) throw Error("revoked certificate extensions require CRL version 2");
1154
1273
  let s = parseRevokedCertificateExtensions(r, o);
1155
1274
  return {
1156
- serialNumberHex: w(a.value),
1157
- revocationDate: S(C(i[1], "revocationDate")),
1275
+ serialNumberHex: M(a.value),
1276
+ revocationDate: A(j(i[1], "revocationDate")),
1158
1277
  ...s.reasonCode === void 0 ? {} : { reasonCode: s.reasonCode },
1159
1278
  ...s.invalidityDate === void 0 ? {} : { invalidityDate: s.invalidityDate },
1160
1279
  ...s.certificateIssuer === void 0 ? {} : { certificateIssuer: s.certificateIssuer }
@@ -1163,34 +1282,34 @@ function parseRevokedCertificateEntry(e, t, n) {
1163
1282
  function parseCrlExtensionFields(e, t, n) {
1164
1283
  if (t?.tag !== 160) return {};
1165
1284
  if (n !== 2) throw Error("CRL extensions require version 2");
1166
- let r = {}, i = /* @__PURE__ */ new Set(), a = C(h(e, t)[0], "crl extensions");
1167
- for (let t of h(e, a)) parseCrlExtensionField(e, t, i, r);
1285
+ let r = {}, i = /* @__PURE__ */ new Set(), a = j(S(e, t)[0], "crl extensions");
1286
+ for (let t of S(e, a)) parseCrlExtensionField(e, t, i, r);
1168
1287
  return r;
1169
1288
  }
1170
1289
  function parseCrlExtensionField(e, t, n, r) {
1171
- let i = h(e, t);
1290
+ let i = S(e, t);
1172
1291
  if (i.length < 2 || i.length > 3 || i.length === 3 && i[1]?.tag !== 1) throw Error("Malformed CRL extension");
1173
- let a = v(C(i[0], "extension OID").value);
1292
+ let a = E(j(i[0], "extension OID").value);
1174
1293
  if (n.has(a)) throw Error(`Duplicate CRL extension OID: ${a}`);
1175
1294
  n.add(a);
1176
- let o = i.length === 3 && g(C(i[1], "extension critical").value), s = C(i[i.length - 1], "extension value");
1295
+ let o = i.length === 3 && C(j(i[1], "extension critical").value), s = j(i[i.length - 1], "extension value");
1177
1296
  if (s.tag !== 4) throw Error("CRL extension value must use OCTET STRING");
1178
1297
  if (!isSupportedCrlExtensionOid(a) && o) throw Error(`Unsupported critical CRL extension OID: ${a}`);
1179
1298
  applyParsedCrlExtensionField(a, s.value, r);
1180
1299
  }
1181
1300
  function isSupportedCrlExtensionOid(e) {
1182
- return e === T.authorityKeyIdentifier || e === T.cRLNumber || e === T.deltaCRLIndicator || e === T.issuingDistributionPoint || e === T.freshestCRL;
1301
+ return e === N.authorityKeyIdentifier || e === N.cRLNumber || e === N.deltaCRLIndicator || e === N.issuingDistributionPoint || e === N.freshestCRL;
1183
1302
  }
1184
1303
  function applyParsedCrlExtensionField(e, t, n) {
1185
- if (e === T.authorityKeyIdentifier) {
1304
+ if (e === N.authorityKeyIdentifier) {
1186
1305
  let e = parseAuthorityKeyIdentifier(t);
1187
1306
  e !== void 0 && (n.authorityKeyIdentifier = e);
1188
1307
  }
1189
- e === T.cRLNumber && (n.crlNumber = _(l(t).value)), e === T.deltaCRLIndicator && (n.baseCrlNumber = _(l(t).value)), e === T.issuingDistributionPoint && (n.issuingDistributionPoint = parseIssuingDistributionPoint(t)), e === T.freshestCRL && (n.freshestCrlDistributionPoints = parseDistributionPoints(t));
1308
+ 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
1309
  }
1191
1310
  /** Accepts PEM, DER, or already-parsed certificate and returns a parsed certificate. */
1192
1311
  function normalizeCrlCertificate(e) {
1193
- return hasParsedCertificateShape(e) ? J(new Uint8Array(e.der)) : Y(e);
1312
+ return hasParsedCertificateShape(e) ? ce(new Uint8Array(e.der)) : Z(e);
1194
1313
  }
1195
1314
  function hasParsedCertificateShape(e) {
1196
1315
  return typeof e != "string" && "subjectPublicKeyInfoDer" in e;
@@ -1198,9 +1317,6 @@ function hasParsedCertificateShape(e) {
1198
1317
  function hasReparseableCrlShape(e) {
1199
1318
  return "der" in e && e.der instanceof Uint8Array;
1200
1319
  }
1201
- /** Shared UTF-8 decoder instance. */
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 };
1320
+ 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
1321
 
1206
1322
  //# sourceMappingURL=crl.js.map