micro509 0.17.1 → 0.19.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 (183) hide show
  1. package/CHANGELOG.md +165 -6
  2. package/dist/crypto/crypto.d.ts +12 -4
  3. package/dist/crypto/crypto.js +30 -17
  4. package/dist/crypto/crypto.js.map +1 -1
  5. package/dist/crypto.d.ts +8 -2
  6. package/dist/der/der.d.ts +14 -4
  7. package/dist/der/der.js +19 -19
  8. package/dist/der/der.js.map +1 -1
  9. package/dist/der.d.ts +26 -2
  10. package/dist/der.js +4 -4
  11. package/dist/index.d.ts +84 -16
  12. package/dist/index.js +19 -19
  13. package/dist/internal/asn1/asn1.d.ts +1 -2
  14. package/dist/internal/asn1/asn1.js +10 -2
  15. package/dist/internal/asn1/asn1.js.map +1 -1
  16. package/dist/internal/asn1/ber.js.map +1 -1
  17. package/dist/internal/asn1/decode-refusal.js.map +1 -1
  18. package/dist/internal/asn1/der.d.ts +1 -2
  19. package/dist/internal/asn1/der.js.map +1 -1
  20. package/dist/internal/asn1/oids.js +71 -353
  21. package/dist/internal/asn1/oids.js.map +1 -1
  22. package/dist/internal/asn1/oids.json.js +357 -0
  23. package/dist/internal/asn1/oids.json.js.map +1 -0
  24. package/dist/internal/crypto/algorithm-names.js +1 -1
  25. package/dist/internal/crypto/algorithm-names.js.map +1 -1
  26. package/dist/internal/crypto/ecdsa.js.map +1 -1
  27. package/dist/internal/crypto/hash.js.map +1 -1
  28. package/dist/internal/crypto/pbes2.d.ts +1 -2
  29. package/dist/internal/crypto/pbes2.js +70 -70
  30. package/dist/internal/crypto/pbes2.js.map +1 -1
  31. package/dist/internal/crypto/prime-ec.js +37 -0
  32. package/dist/internal/crypto/prime-ec.js.map +1 -0
  33. package/dist/internal/crypto/rsa-pss.js +50 -50
  34. package/dist/internal/crypto/rsa-pss.js.map +1 -1
  35. package/dist/internal/crypto/sig-verify.d.ts +41 -2
  36. package/dist/internal/crypto/sig-verify.js +125 -38
  37. package/dist/internal/crypto/sig-verify.js.map +1 -1
  38. package/dist/internal/crypto/signing.d.ts +1 -2
  39. package/dist/internal/crypto/signing.js +26 -26
  40. package/dist/internal/crypto/signing.js.map +1 -1
  41. package/dist/internal/jose/base64url.js.map +1 -1
  42. package/dist/internal/jose/json-data.js +108 -0
  43. package/dist/internal/jose/json-data.js.map +1 -0
  44. package/dist/internal/jose/strict-json.d.ts +1 -2
  45. package/dist/internal/jose/strict-json.js.map +1 -1
  46. package/dist/internal/shared/base64.js.map +1 -1
  47. package/dist/internal/shared/dn.d.ts +1 -2
  48. package/dist/internal/shared/dn.js +1 -1
  49. package/dist/internal/shared/dn.js.map +1 -1
  50. package/dist/internal/shared/idna.js.map +1 -1
  51. package/dist/internal/shared/ip.d.ts +1 -2
  52. package/dist/internal/shared/ip.js.map +1 -1
  53. package/dist/internal/shared/mailbox.js.map +1 -1
  54. package/dist/internal/shared/punycode.js.map +1 -1
  55. package/dist/internal/shared/uri-host.js.map +1 -1
  56. package/dist/internal/verify/name-constraints-engine.js +64 -64
  57. package/dist/internal/verify/name-constraints-engine.js.map +1 -1
  58. package/dist/internal/verify/policy-engine.js +1 -1
  59. package/dist/internal/verify/policy-engine.js.map +1 -1
  60. package/dist/internal/verify/spki-distrust.js.map +1 -1
  61. package/dist/internal/verify/verify-path.d.ts +1 -2
  62. package/dist/internal/verify/verify-path.js +234 -128
  63. package/dist/internal/verify/verify-path.js.map +1 -1
  64. package/dist/internal/x509/directory-name.js +10 -10
  65. package/dist/internal/x509/directory-name.js.map +1 -1
  66. package/dist/internal/x509/extension-bits.js.map +1 -1
  67. package/dist/internal/x509/extension-errors.d.ts +1 -2
  68. package/dist/internal/x509/extension-errors.js.map +1 -1
  69. package/dist/internal/x509/extension-registry.js +18 -18
  70. package/dist/internal/x509/extension-registry.js.map +1 -1
  71. package/dist/internal/x509/general-name-profile.js +9 -9
  72. package/dist/internal/x509/general-name-profile.js.map +1 -1
  73. package/dist/internal/x509/general-name.js +32 -32
  74. package/dist/internal/x509/general-name.js.map +1 -1
  75. package/dist/internal/x509/name-fields.js +1 -1
  76. package/dist/internal/x509/name-fields.js.map +1 -1
  77. package/dist/internal/x509/or-address.js.map +1 -1
  78. package/dist/jose/base64url.d.ts +4 -0
  79. package/dist/jose/base64url.js +14 -0
  80. package/dist/jose/base64url.js.map +1 -0
  81. package/dist/jose/errors.d.ts +9 -3
  82. package/dist/jose/errors.js.map +1 -1
  83. package/dist/jose/jwe.d.ts +64 -0
  84. package/dist/jose/jwe.js +188 -0
  85. package/dist/jose/jwe.js.map +1 -0
  86. package/dist/jose/jwks.d.ts +38 -10
  87. package/dist/jose/jwks.js +156 -96
  88. package/dist/jose/jwks.js.map +1 -1
  89. package/dist/jose/jws.d.ts +8 -6
  90. package/dist/jose/jws.js +216 -170
  91. package/dist/jose/jws.js.map +1 -1
  92. package/dist/jose/jwt.d.ts +8 -2
  93. package/dist/jose/jwt.js +98 -98
  94. package/dist/jose/jwt.js.map +1 -1
  95. package/dist/jose/remote-jwks.d.ts +1 -2
  96. package/dist/jose/remote-jwks.js +106 -108
  97. package/dist/jose/remote-jwks.js.map +1 -1
  98. package/dist/jose.d.ts +15 -4
  99. package/dist/jose.js +7 -5
  100. package/dist/kdf/argon2-arithmetic.js.map +1 -1
  101. package/dist/kdf/argon2-core.js.map +1 -1
  102. package/dist/kdf/argon2-memory.js.map +1 -1
  103. package/dist/kdf/argon2-portable.js.map +1 -1
  104. package/dist/kdf/argon2.d.ts +7 -2
  105. package/dist/kdf/argon2.js.map +1 -1
  106. package/dist/kdf.d.ts +6 -0
  107. package/dist/keys/keys.d.ts +31 -6
  108. package/dist/keys/keys.js +315 -233
  109. package/dist/keys/keys.js.map +1 -1
  110. package/dist/keys.d.ts +11 -2
  111. package/dist/keys.js +2 -2
  112. package/dist/pem/pem.d.ts +1 -2
  113. package/dist/pem/pem.js +40 -25
  114. package/dist/pem/pem.js.map +1 -1
  115. package/dist/pem.d.ts +6 -0
  116. package/dist/pkcs/pfx.d.ts +2 -3
  117. package/dist/pkcs/pfx.js +142 -142
  118. package/dist/pkcs/pfx.js.map +1 -1
  119. package/dist/pkcs/pkcs12-mac.d.ts +1 -2
  120. package/dist/pkcs/pkcs12-mac.js +122 -122
  121. package/dist/pkcs/pkcs12-mac.js.map +1 -1
  122. package/dist/pkcs/pkcs7.d.ts +24 -3
  123. package/dist/pkcs/pkcs7.js +294 -256
  124. package/dist/pkcs/pkcs7.js.map +1 -1
  125. package/dist/pkcs.d.ts +10 -1
  126. package/dist/pkcs.js +4 -4
  127. package/dist/result/result.d.ts +1 -2
  128. package/dist/result/result.js.map +1 -1
  129. package/dist/result.d.ts +6 -0
  130. package/dist/revocation/chain.d.ts +69 -16
  131. package/dist/revocation/chain.js +431 -303
  132. package/dist/revocation/chain.js.map +1 -1
  133. package/dist/revocation/crl.d.ts +67 -14
  134. package/dist/revocation/crl.js +656 -366
  135. package/dist/revocation/crl.js.map +1 -1
  136. package/dist/revocation/ocsp.d.ts +78 -24
  137. package/dist/revocation/ocsp.js +622 -436
  138. package/dist/revocation/ocsp.js.map +1 -1
  139. package/dist/revocation/revocation.d.ts +68 -14
  140. package/dist/revocation/revocation.js +195 -74
  141. package/dist/revocation/revocation.js.map +1 -1
  142. package/dist/revocation.d.ts +14 -5
  143. package/dist/revocation.js +4 -4
  144. package/dist/ssh/ssh.d.ts +2 -3
  145. package/dist/ssh/ssh.js +165 -170
  146. package/dist/ssh/ssh.js.map +1 -1
  147. package/dist/ssh/wire.d.ts +1 -2
  148. package/dist/ssh/wire.js +10 -10
  149. package/dist/ssh/wire.js.map +1 -1
  150. package/dist/ssh.d.ts +8 -0
  151. package/dist/verify/identity.d.ts +3 -4
  152. package/dist/verify/identity.js +33 -33
  153. package/dist/verify/identity.js.map +1 -1
  154. package/dist/verify/name-constraints.d.ts +9 -2
  155. package/dist/verify/policy.d.ts +9 -2
  156. package/dist/verify/verify.d.ts +85 -34
  157. package/dist/verify/verify.js +276 -226
  158. package/dist/verify/verify.js.map +1 -1
  159. package/dist/verify.d.ts +12 -2
  160. package/dist/x509/certificate.d.ts +4 -5
  161. package/dist/x509/certificate.js +40 -40
  162. package/dist/x509/certificate.js.map +1 -1
  163. package/dist/x509/csr.d.ts +3 -4
  164. package/dist/x509/csr.js +15 -15
  165. package/dist/x509/csr.js.map +1 -1
  166. package/dist/x509/extensions.d.ts +1 -2
  167. package/dist/x509/extensions.js +165 -165
  168. package/dist/x509/extensions.js.map +1 -1
  169. package/dist/x509/fingerprint.d.ts +1 -2
  170. package/dist/x509/fingerprint.js.map +1 -1
  171. package/dist/x509/name-text.d.ts +1 -2
  172. package/dist/x509/name-text.js.map +1 -1
  173. package/dist/x509/name.d.ts +1 -2
  174. package/dist/x509/name.js +15 -15
  175. package/dist/x509/name.js.map +1 -1
  176. package/dist/x509/parse.d.ts +9 -6
  177. package/dist/x509/parse.js +394 -394
  178. package/dist/x509/parse.js.map +1 -1
  179. package/dist/x509.d.ts +17 -4
  180. package/dist/x509.js +8 -8
  181. package/package.json +32 -33
  182. package/dist/internal/asn1/oids2.js +0 -75
  183. package/dist/internal/asn1/oids2.js.map +0 -1
@@ -1,18 +1,19 @@
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 } from "../internal/asn1/decode-refusal.js";
3
- import { bitString as s, concatBytes as c, enumeratedFromNumber as l, explicitContext as u, generalizedTime as d, integer as f, nullValue as p, objectIdentifier as m, octetString as h, readElement as g, readRootElement as _, readSequenceChildren as v, sequence as y, tlv as b } from "../internal/asn1/der.js";
4
- import { childrenOf as x, decodeNonNegativeIntegerBigInt as S, decodeNonNegativeIntegerNumber as C, decodeObjectIdentifier as w, decodeString as T, extractBitStringValue as E, hexToBytes as D, parseTime as O, requireElement as k, toArrayBuffer as A, toHex as j } from "../internal/asn1/asn1.js";
5
- import { OIDS as M } from "../internal/asn1/oids2.js";
6
- import { getCrypto as N } from "../internal/crypto/webcrypto.js";
7
- import { base64Encode as P } from "../internal/shared/base64.js";
8
- import { pemDecodeOrThrow as F, pemEncode as I } from "../pem/pem.js";
9
- import { getVerifySignatureConfigResult as L, verifySignedDataDetailed as R } from "../internal/crypto/sig-verify.js";
10
- import { encodeAlgorithmIdentifier as z, getSignatureAlgorithm as B, signBytes as V } from "../internal/crypto/signing.js";
11
- import { describeHashAlgorithm as H, describeSignatureAlgorithm as U } from "../internal/crypto/algorithm-names.js";
12
- import { compareDistinguishedNames as W } from "../internal/shared/dn.js";
13
- import { parseCertificateDerOrThrow as G, parseCertificateFromSource as K } from "../x509/parse.js";
14
- import { assertCrlMaxAge as q, checkCertificateRevocationAgainstCrl as J, coversAllDistributionPointReasons as Y, parseCertificateRevocationListDerOrThrow as X, parseCertificateRevocationListPemOrThrow as Z } from "./crl.js";
15
- import { verifyCertificateChain as Q } from "../verify/verify.js";
1
+ import { childrenOf as e, decodeNonNegativeIntegerBigInt as t, decodeNonNegativeIntegerNumber as n, decodeObjectIdentifier as r, decodeString as i, extractBitStringValue as a, hexToBytes as o, parseTime as s, requireElement as c, signatureBits as l, toArrayBuffer as u, toHex as d } from "../internal/asn1/asn1.js";
2
+ import { decodeFailureResult as f, decodeRefusalOf as p } from "../internal/asn1/decode-refusal.js";
3
+ import { bitString as m, concatBytes as h, enumeratedFromNumber as g, explicitContext as _, generalizedTime as v, integer as y, nullValue as b, objectIdentifier as x, octetString as S, readElement as C, readRootElement as w, readSequenceChildren as T, sequence as E, tlv as D } from "../internal/asn1/der.js";
4
+ import { OIDS as O } from "../internal/asn1/oids.js";
5
+ import { describeHashAlgorithm as k, describeSignatureAlgorithm as A } from "../internal/crypto/algorithm-names.js";
6
+ import { callerVerification as ee, getVerifySignatureConfigResult as j, resolveSignatureVerifiers as M, verifySignedDataDetailed as N } from "../internal/crypto/sig-verify.js";
7
+ import { encodeAlgorithmIdentifier as P, getSignatureAlgorithm as F, signBytes as I } from "../internal/crypto/signing.js";
8
+ import { getCrypto as L } from "../internal/crypto/webcrypto.js";
9
+ import { base64Encode as R } from "../internal/shared/base64.js";
10
+ import { compareDistinguishedNames as z } from "../internal/shared/dn.js";
11
+ import { anchorWorkingKey as te, carriesTrustAnchorKey as ne, certificateWorkingKey as B, pathWorkingKey as V, withWorkingParameters as H, workingParametersAt as U } from "../internal/verify/verify-path.js";
12
+ import { pemDecodeOrThrow as W, pemEncode as G } from "../pem/pem.js";
13
+ import { DECODE_REFUSAL_CODES as K, failureResult as q, rethrowIfInvariant as J, successResult as Y, throwMicro509Error as X } from "../result/result.js";
14
+ import { assertClockSkew as re, assertCrlMaxAge as ie, checkCertificateRevocationAgainstCrlsBy as ae, coversAllDistributionPointReasons as oe, distinctSignedCrls as Z, normalizeCrl as se } from "./crl.js";
15
+ import { trustAnchorFromCertificate as Q, verifyCertificateChain as ce } from "../verify/verify.js";
16
+ import { parseCertificateDerOrThrow as $, parseCertificateFromSource as le } from "../x509/parse.js";
16
17
  // src/revocation/ocsp.ts
17
18
  /**
18
19
  * Full OCSP lifecycle: build requests, create/parse/verify/validate responses.
@@ -25,7 +26,7 @@ import { verifyCertificateChain as Q } from "../verify/verify.js";
25
26
  */
26
27
  /** Throws a {@link ResultError} for an OCSP encoder input-validation failure. */
27
28
  function throwOcspEncoderError(e, t) {
28
- i(e, t);
29
+ X(e, t);
29
30
  }
30
31
  function assertOcspDate(e, t) {
31
32
  e !== void 0 && Number.isNaN(e.getTime()) && throwOcspEncoderError("invalid_date", `${t} must be a valid date`);
@@ -33,6 +34,19 @@ function assertOcspDate(e, t) {
33
34
  function assertOcspRevocationReasonCode(e) {
34
35
  e !== void 0 && !(Number.isSafeInteger(e) && e >= 0) && throwOcspEncoderError("invalid_revocation_reason_code", "revocationReasonCode must be a non-negative integer");
35
36
  }
37
+ function ocspKeyOf(e) {
38
+ return e.kind === "certificate" ? e.certificate : e.trustAnchor;
39
+ }
40
+ /** The name and key a CertID for `issuer` hashes (RFC 6960 §4.1.1). */
41
+ function certIdIssuerKey(e) {
42
+ return e.kind === "certificate" ? e.certificate : {
43
+ ...e.trustAnchor,
44
+ subject: e.certificateIssuer
45
+ };
46
+ }
47
+ function ocspCertificateOf(e) {
48
+ return e.kind === "certificate" ? e.certificate : void 0;
49
+ }
36
50
  /**
37
51
  * Builds a DER-encoded OCSP request containing one or more CertID entries
38
52
  * and an optional nonce extension.
@@ -53,51 +67,51 @@ async function createOcspRequest(e) {
53
67
  let t = e.hashAlgorithm ?? "SHA-256", n = [];
54
68
  for (let r of e.requests) {
55
69
  let e = normalizeCertificate(r.certificate), i = normalizeCertificate(r.issuerCertificate);
56
- n.push(y([await encodeOcspCertId(e, i, t)]));
70
+ n.push(E([await encodeOcspCertId(e, i, t)]));
57
71
  }
58
- let r = [y(n)];
59
- e.nonce !== void 0 && r.push(u(2, y([y([m(M.ocspNonce), h(h(e.nonce))])])));
60
- let i = y([y(r)]);
72
+ let r = [E(n)];
73
+ e.nonce !== void 0 && r.push(_(2, E([E([x(O.ocspNonce), S(S(e.nonce))])])));
74
+ let i = E([E(r)]);
61
75
  return {
62
76
  der: i,
63
- pem: I("OCSP REQUEST", i),
64
- base64: P(i)
77
+ pem: G("OCSP REQUEST", i),
78
+ base64: R(i)
65
79
  };
66
80
  }
67
81
  /** Throwing core for {@linkcode parseOcspRequestDer}. */
68
- function parseOcspRequestDerOrThrow(e) {
69
- let t = v(e, { maxDepth: 64 });
70
- if (t.length < 1 || t.length > 2) throw Error("Malformed OCSP request");
71
- let n = k(t[0], "tbsRequest"), r = t[1];
72
- if (r !== void 0 && r.tag !== 160) throw Error("Malformed OCSP request");
73
- r !== void 0 && validateOcspOptionalSignature(e, r);
74
- let i = x(e, n), a = skipOcspRequestVersion(e, i, 0);
75
- a = skipOcspRequestorName(e, i, a);
76
- let o = k(i[a], "requestList");
77
- if (o.tag !== 48) throw Error("requestList must use SEQUENCE");
78
- if (x(e, o).length === 0) throw Error("requestList must not be empty");
79
- let s = x(e, o).map((t) => {
80
- let n = x(e, t);
81
- if (n.length < 1 || n.length > 2 || n[1] !== void 0 && n[1].tag !== 160) throw Error("Malformed OCSP request entry");
82
- let r = k(n[0], "reqCert");
83
- return parseOcspCertId(e.slice(r.start - r.headerLength, r.end));
82
+ function parseOcspRequestDerOrThrow(t) {
83
+ let n = T(t, { maxDepth: 64 });
84
+ if (n.length < 1 || n.length > 2) throw Error("Malformed OCSP request");
85
+ let r = c(n[0], "tbsRequest"), i = n[1];
86
+ if (i !== void 0 && i.tag !== 160) throw Error("Malformed OCSP request");
87
+ i !== void 0 && validateOcspOptionalSignature(t, i);
88
+ let a = e(t, r), o = skipOcspRequestVersion(t, a, 0);
89
+ o = skipOcspRequestorName(t, a, o);
90
+ let s = c(a[o], "requestList");
91
+ if (s.tag !== 48) throw Error("requestList must use SEQUENCE");
92
+ if (e(t, s).length === 0) throw Error("requestList must not be empty");
93
+ let l = e(t, s).map((n) => {
94
+ let r = e(t, n);
95
+ if (r.length < 1 || r.length > 2 || r[1] !== void 0 && r[1].tag !== 160) throw Error("Malformed OCSP request entry");
96
+ let i = c(r[0], "reqCert");
97
+ return parseOcspCertId(t.slice(i.start - i.headerLength, i.end));
84
98
  });
85
- a += 1;
86
- let c = i[a];
87
- if (c !== void 0 && c.tag !== 162 || i.length !== a + (c === void 0 ? 0 : 1)) throw Error("Malformed OCSP request");
88
- let l = c === void 0 ? void 0 : parseOcspNonceFromExtensions(e, c);
99
+ o += 1;
100
+ let u = a[o];
101
+ if (u !== void 0 && u.tag !== 162 || a.length !== o + (u === void 0 ? 0 : 1)) throw Error("Malformed OCSP request");
102
+ let d = u === void 0 ? void 0 : parseOcspNonceFromExtensions(t, u);
89
103
  return {
90
- der: new Uint8Array(e),
91
- requests: s,
92
- ...l === void 0 ? {} : { nonce: l }
104
+ der: new Uint8Array(t),
105
+ requests: l,
106
+ ...d === void 0 ? {} : { nonce: d }
93
107
  };
94
108
  }
95
- function skipOcspRequestVersion(e, t, n) {
96
- if (t[n]?.tag !== 160) return n;
97
- let r = k(t[n], "version"), i = x(e, r), a = k(i[0], "version");
98
- if (i.length !== 1 || a.tag !== 2) throw Error("version must use INTEGER");
99
- if (C(a.value, "OCSP request version") !== 0) throw Error("Unsupported OCSP request version");
100
- return n + 1;
109
+ function skipOcspRequestVersion(t, r, i) {
110
+ if (r[i]?.tag !== 160) return i;
111
+ let a = c(r[i], "version"), o = e(t, a), s = c(o[0], "version");
112
+ if (o.length !== 1 || s.tag !== 2) throw Error("version must use INTEGER");
113
+ if (n(s.value, "OCSP request version") !== 0) throw Error("Unsupported OCSP request version");
114
+ return i + 1;
101
115
  }
102
116
  function skipOcspRequestorName(e, t, n) {
103
117
  let r = t[n];
@@ -105,7 +119,7 @@ function skipOcspRequestorName(e, t, n) {
105
119
  }
106
120
  /** Decodes a PEM-encoded OCSP request (`-----BEGIN OCSP REQUEST-----`). */
107
121
  function parseOcspRequestPemOrThrow(e) {
108
- return parseOcspRequestDerOrThrow(F("OCSP REQUEST", e));
122
+ return parseOcspRequestDerOrThrow(W("OCSP REQUEST", e));
109
123
  }
110
124
  /**
111
125
  * Decodes a DER-encoded OCSP request into a structured {@linkcode ParsedOcspRequest}.
@@ -113,11 +127,11 @@ function parseOcspRequestPemOrThrow(e) {
113
127
  * Returns a typed failure (`code: 'malformed'`) on malformed input. For the
114
128
  * throwing form use {@linkcode parseOcspRequestDerOrThrow}.
115
129
  */
116
- function parseOcspRequestDer(t) {
130
+ function parseOcspRequestDer(e) {
117
131
  try {
118
- return r(parseOcspRequestDerOrThrow(t));
119
- } catch (t) {
120
- return n(t), a(t, e, "Malformed OCSP request");
132
+ return Y(parseOcspRequestDerOrThrow(e));
133
+ } catch (e) {
134
+ return J(e), f(e, K, "Malformed OCSP request");
121
135
  }
122
136
  }
123
137
  /**
@@ -126,56 +140,56 @@ function parseOcspRequestDer(t) {
126
140
  * Returns a typed failure (`code: 'malformed'`) on malformed input. For the
127
141
  * throwing form use {@linkcode parseOcspRequestPemOrThrow}.
128
142
  */
129
- function parseOcspRequestPem(t) {
143
+ function parseOcspRequestPem(e) {
130
144
  try {
131
- return r(parseOcspRequestPemOrThrow(t));
132
- } catch (t) {
133
- return n(t), a(t, e, "Malformed OCSP request");
145
+ return Y(parseOcspRequestPemOrThrow(e));
146
+ } catch (e) {
147
+ return J(e), f(e, K, "Malformed OCSP request");
134
148
  }
135
149
  }
136
150
  /** Throwing core for {@linkcode parseOcspResponseDer}. */
137
- function parseOcspResponseDerOrThrow(e) {
138
- let t = v(e, { maxDepth: 64 });
139
- if (t.length < 1 || t.length > 2) throw Error("Malformed OCSP response");
140
- let n = k(t[0], "responseStatus");
141
- if (n.tag !== 10) throw Error("responseStatus must use ENUMERATED");
142
- let r = ocspResponseStatusFromCode(C(n.value, "OCSP responseStatus")), i = t[1];
143
- if (i === void 0) return {
144
- der: new Uint8Array(e),
145
- responseStatus: r
151
+ function parseOcspResponseDerOrThrow(t) {
152
+ let i = T(t, { maxDepth: 64 });
153
+ if (i.length < 1 || i.length > 2) throw Error("Malformed OCSP response");
154
+ let a = c(i[0], "responseStatus");
155
+ if (a.tag !== 10) throw Error("responseStatus must use ENUMERATED");
156
+ let o = ocspResponseStatusFromCode(n(a.value, "OCSP responseStatus")), s = i[1];
157
+ if (s === void 0) return {
158
+ der: new Uint8Array(t),
159
+ responseStatus: o
146
160
  };
147
- if (i.tag !== 160) throw Error("Malformed OCSP response");
148
- let a = x(e, i), o = k(a[0], "responseBytes");
149
- if (a.length !== 1 || o.tag !== 48) throw Error("Malformed OCSP response");
150
- let s = x(e, o);
151
- if (s.length !== 2) throw Error("responseBytes must contain responseType and response");
152
- let c = k(s[0], "responseType"), l = k(s[1], "response");
153
- if (l.tag !== 4) throw Error("response must use OCTET STRING");
154
- let u = w(c.value);
155
- if (u !== M.ocspBasicResponse) return {
156
- der: new Uint8Array(e),
157
- responseStatus: r,
158
- responseTypeOid: u
161
+ if (s.tag !== 160) throw Error("Malformed OCSP response");
162
+ let u = e(t, s), d = c(u[0], "responseBytes");
163
+ if (u.length !== 1 || d.tag !== 48) throw Error("Malformed OCSP response");
164
+ let f = e(t, d);
165
+ if (f.length !== 2) throw Error("responseBytes must contain responseType and response");
166
+ let p = c(f[0], "responseType"), m = c(f[1], "response");
167
+ if (m.tag !== 4) throw Error("response must use OCTET STRING");
168
+ let h = r(p.value);
169
+ if (h !== O.ocspBasicResponse) return {
170
+ der: new Uint8Array(t),
171
+ responseStatus: o,
172
+ responseTypeOid: h
159
173
  };
160
- let d = l.value, f = v(d);
161
- if (f.length < 3 || f.length > 4) throw Error("Malformed BasicOCSPResponse");
162
- let p = k(f[0], "responseData"), m = k(f[1], "signatureAlgorithm"), h = k(f[2], "signatureValue"), g = f[3];
163
- if (g !== void 0 && g.tag !== 160) throw Error("Malformed BasicOCSPResponse");
164
- let _ = x(d, m), y = w(k(_[0], "signatureAlgorithm OID").value), b = _[1], S = b === void 0 ? void 0 : d.slice(b.start - b.headerLength, b.end), T = d.slice(p.start - p.headerLength, p.end), D = parseSignedOcspResponseData(T);
174
+ let g = m.value, _ = T(g);
175
+ if (_.length < 3 || _.length > 4) throw Error("Malformed BasicOCSPResponse");
176
+ let v = c(_[0], "responseData"), y = c(_[1], "signatureAlgorithm"), b = c(_[2], "signatureValue"), x = _[3];
177
+ if (x !== void 0 && x.tag !== 160) throw Error("Malformed BasicOCSPResponse");
178
+ let S = e(g, y), C = r(c(S[0], "signatureAlgorithm OID").value), w = S[1], E = w === void 0 ? void 0 : g.slice(w.start - w.headerLength, w.end), D = g.slice(v.start - v.headerLength, v.end), k = parseSignedOcspResponseData(D);
165
179
  return {
166
- der: new Uint8Array(e),
167
- responseStatus: r,
168
- responseTypeOid: u,
169
- responseDataDer: T,
170
- responderId: D.responderId,
171
- signatureAlgorithmOid: y,
172
- ...S === void 0 ? {} : { signatureAlgorithmParametersDer: S },
173
- signatureAlgorithmName: U(y, S),
174
- signatureValue: E(h),
175
- producedAt: D.producedAt,
176
- responses: D.responses,
177
- ...D.nonce === void 0 ? {} : { nonce: D.nonce },
178
- ...g?.tag === 160 ? { certificates: parseEmbeddedCertificates(d, g) } : {}
180
+ der: new Uint8Array(t),
181
+ responseStatus: o,
182
+ responseTypeOid: h,
183
+ responseDataDer: D,
184
+ responderId: k.responderId,
185
+ signatureAlgorithmOid: C,
186
+ ...E === void 0 ? {} : { signatureAlgorithmParametersDer: E },
187
+ signatureAlgorithmName: A(C, E),
188
+ ...l(b),
189
+ producedAt: k.producedAt,
190
+ responses: k.responses,
191
+ ...k.nonce === void 0 ? {} : { nonce: k.nonce },
192
+ ...x?.tag === 160 ? { certificates: parseEmbeddedCertificates(g, x) } : {}
179
193
  };
180
194
  }
181
195
  /**
@@ -194,7 +208,7 @@ function parseOcspResponseDerOrThrow(e) {
194
208
  * ```
195
209
  */
196
210
  function parseOcspResponsePemOrThrow(e) {
197
- return parseOcspResponseDerOrThrow(F("OCSP RESPONSE", e));
211
+ return parseOcspResponseDerOrThrow(W("OCSP RESPONSE", e));
198
212
  }
199
213
  /**
200
214
  * Decodes a DER-encoded OCSP response into a structured {@linkcode ParsedOcspResponse}.
@@ -202,11 +216,11 @@ function parseOcspResponsePemOrThrow(e) {
202
216
  * Returns a typed failure (`code: 'malformed'`) on malformed input. For the
203
217
  * throwing form use {@linkcode parseOcspResponseDerOrThrow}.
204
218
  */
205
- function parseOcspResponseDer(t) {
219
+ function parseOcspResponseDer(e) {
206
220
  try {
207
- return r(parseOcspResponseDerOrThrow(t));
208
- } catch (t) {
209
- return n(t), a(t, e, "Malformed OCSP response");
221
+ return Y(parseOcspResponseDerOrThrow(e));
222
+ } catch (e) {
223
+ return J(e), f(e, K, "Malformed OCSP response");
210
224
  }
211
225
  }
212
226
  /**
@@ -215,11 +229,11 @@ function parseOcspResponseDer(t) {
215
229
  * Returns a typed failure (`code: 'malformed'`) on malformed input. For the
216
230
  * throwing form use {@linkcode parseOcspResponsePemOrThrow}.
217
231
  */
218
- function parseOcspResponsePem(t) {
232
+ function parseOcspResponsePem(e) {
219
233
  try {
220
- return r(parseOcspResponsePemOrThrow(t));
221
- } catch (t) {
222
- return n(t), a(t, e, "Malformed OCSP response");
234
+ return Y(parseOcspResponsePemOrThrow(e));
235
+ } catch (e) {
236
+ return J(e), f(e, K, "Malformed OCSP response");
223
237
  }
224
238
  }
225
239
  /**
@@ -250,8 +264,8 @@ function parseOcspResponsePem(t) {
250
264
  * ```
251
265
  */
252
266
  async function createOcspResponse(e) {
253
- let t = normalizeCertificate(e.signerCertificate), n = B(e.signerPrivateKey);
254
- L(n.algorithmOid, n.parameters, t.publicKeyAlgorithmOid, t.publicKeyParametersOid, "signer").ok || throwOcspEncoderError("signer_certificate_key_mismatch", "signerCertificate must carry a public key that verifies the signer key algorithm");
267
+ let t = normalizeCertificate(e.signerCertificate), n = F(e.signerPrivateKey);
268
+ j(n.algorithmOid, n.parameters, t.publicKeyAlgorithmOid, t.publicKeyParametersOid, "signer").ok || throwOcspEncoderError("signer_certificate_key_mismatch", "signerCertificate must carry a public key that verifies the signer key algorithm");
255
269
  let r = e.producedAt ?? /* @__PURE__ */ new Date();
256
270
  assertOcspDate(r, "producedAt");
257
271
  let i = e.hashAlgorithm ?? "SHA-256", a = [];
@@ -260,23 +274,23 @@ async function createOcspResponse(e) {
260
274
  let e = normalizeCertificate(t.certificate), n = normalizeCertificate(t.issuerCertificate);
261
275
  a.push(await encodeSingleResponse(e, n, t, i));
262
276
  }
263
- let o = await digestBytes("SHA-1", extractSubjectPublicKeyBytes(t.subjectPublicKeyInfoDer)), c = [
264
- u(2, h(o)),
265
- d(r),
266
- y(a)
277
+ let o = await digestBytes("SHA-1", extractSubjectPublicKeyBytes(t.subjectPublicKeyInfoDer)), s = [
278
+ _(2, S(o)),
279
+ v(r),
280
+ E(a)
267
281
  ];
268
- e.nonce !== void 0 && c.push(u(1, y([y([m(M.ocspNonce), h(h(e.nonce))])])));
269
- let l = y(c), f = await V(e.signerPrivateKey, n, l), p = e.includedCertificates === void 0 ? [] : await Promise.all(e.includedCertificates.map(normalizeCertificate)), g = [
270
- l,
271
- z(n),
272
- s(f)
282
+ e.nonce !== void 0 && s.push(_(1, E([E([x(O.ocspNonce), S(S(e.nonce))])])));
283
+ let c = E(s), l = await I(e.signerPrivateKey, n, c), u = e.includedCertificates === void 0 ? [] : await Promise.all(e.includedCertificates.map(normalizeCertificate)), d = [
284
+ c,
285
+ P(n),
286
+ m(l)
273
287
  ];
274
- p.length > 0 && g.push(u(0, y(p.map((e) => e.der))));
275
- let _ = y(g), v = y([b(10, Uint8Array.of(0)), u(0, y([m(M.ocspBasicResponse), h(_)]))]);
288
+ u.length > 0 && d.push(_(0, E(u.map((e) => e.der))));
289
+ let f = E(d), p = E([D(10, Uint8Array.of(0)), _(0, E([x(O.ocspBasicResponse), S(f)]))]);
276
290
  return {
277
- der: v,
278
- pem: I("OCSP RESPONSE", v),
279
- base64: P(v)
291
+ der: p,
292
+ pem: G("OCSP RESPONSE", p),
293
+ base64: R(p)
280
294
  };
281
295
  }
282
296
  /**
@@ -285,33 +299,41 @@ async function createOcspResponse(e) {
285
299
  * Does **not** check responder binding, freshness, or nonce — use
286
300
  * {@linkcode validateOcspResponse} for full validation.
287
301
  */
288
- async function verifyOcspResponseSignature(t, n) {
302
+ async function verifyOcspResponseSignature(e, t, n = {}) {
303
+ return await verifyOcspResponseSignatureWith(e, t, ee(n.signatureVerifiers));
304
+ }
305
+ async function verifyOcspResponseSignatureWith(e, t, n) {
289
306
  let r;
290
307
  try {
291
- r = normalizeOcspResponse(t);
292
- } catch (t) {
293
- let n = o(t, e);
294
- return n === void 0 ? verifyOcspResponseFailureResult("signature_invalid", "OCSP response signed content is malformed") : verifyOcspResponseFailureResult(n.code, n.message);
308
+ r = normalizeOcspResponse(e);
309
+ } catch (e) {
310
+ let t = p(e, K);
311
+ return t === void 0 ? verifyOcspResponseFailureResult("malformed", "OCSP response signed content is malformed") : verifyOcspResponseFailureResult(t.code, t.message);
295
312
  }
296
313
  if (r.responseDataDer === void 0 || r.signatureAlgorithmOid === void 0 || r.signatureValue === void 0) return verifyOcspResponseFailureResult("signature_invalid", "OCSP response is not signed");
297
314
  let i;
298
315
  try {
299
- i = normalizeCertificate(n);
300
- } catch (t) {
301
- let n = o(t, e);
302
- return n === void 0 ? verifyOcspResponseFailureResult("signature_invalid", "OCSP signer certificate input is malformed") : verifyOcspResponseFailureResult(n.code, n.message);
316
+ i = normalizeCertificate(t);
317
+ } catch (e) {
318
+ let t = p(e, K);
319
+ return t === void 0 ? verifyOcspResponseFailureResult("malformed", "OCSP signer certificate input is malformed") : verifyOcspResponseFailureResult(t.code, t.message);
303
320
  }
304
- let a;
321
+ return await verifyOcspResponseSignatureByKey(r, i, n);
322
+ }
323
+ /** Verifies the signature of a parsed OCSP response with `signer`'s public key. */
324
+ async function verifyOcspResponseSignatureByKey(e, t, n) {
325
+ if (e.responseDataDer === void 0 || e.signatureAlgorithmOid === void 0 || e.signatureValue === void 0) return verifyOcspResponseFailureResult("signature_invalid", "OCSP response is not signed");
326
+ let r;
305
327
  try {
306
- a = await R(r.signatureAlgorithmOid, r.signatureAlgorithmParametersDer, i.publicKeyAlgorithmOid, i.publicKeyParametersOid, i.subjectPublicKeyInfoDer, r.signatureValue, r.responseDataDer);
307
- } catch (t) {
308
- let n = o(t, e);
309
- return n === void 0 ? verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature verification failed") : verifyOcspResponseFailureResult(n.code, n.message);
328
+ r = await N(e.signatureAlgorithmOid, e.signatureAlgorithmParametersDer, t.publicKeyAlgorithmOid, t.publicKeyParametersOid, t.subjectPublicKeyInfoDer, e.signatureValue, e.signatureValueUnusedBits ?? 0, e.responseDataDer, n);
329
+ } catch (e) {
330
+ let t = p(e, K);
331
+ return t === void 0 ? verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature verification failed") : verifyOcspResponseFailureResult(t.code, t.message);
310
332
  }
311
- return a.ok ? a.valid ? {
333
+ return r.ok ? r.valid ? {
312
334
  ok: !0,
313
- value: r
314
- } : verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature does not verify") : a.code === "verification_error" ? verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature verification failed") : verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature uses unsupported algorithm parameters");
335
+ value: e
336
+ } : verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature does not verify") : r.code === "verification_error" ? verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature verification failed") : verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature uses unsupported algorithm parameters");
315
337
  }
316
338
  /**
317
339
  * Full OCSP response validation: response status check, signature verification,
@@ -334,91 +356,231 @@ async function verifyOcspResponseSignature(t, n) {
334
356
  * }
335
357
  * ```
336
358
  */
337
- async function validateOcspResponse(t) {
338
- q(t.responderRevocationCrlMaxAgeMs);
339
- let n;
359
+ async function validateOcspResponse(e) {
360
+ return await validateOcspResponseWith(e, { verifiers: M(e.signatureVerifiers) });
361
+ }
362
+ /**
363
+ * {@linkcode validateOcspResponse} with resolved caller verifiers and the
364
+ * issuer's working key.
365
+ *
366
+ * @internal
367
+ */
368
+ async function validateOcspResponseWith(e, t) {
369
+ return await validateOcspResponseBy(e, {
370
+ kind: "certificate",
371
+ certificate: e.issuerCertificate
372
+ }, t);
373
+ }
374
+ /**
375
+ * {@linkcode validateOcspResponse} for a certificate that `issuer` issued,
376
+ * which may be a bare trust anchor.
377
+ *
378
+ * @internal
379
+ */
380
+ async function validateOcspResponseBy(e, t, n) {
381
+ let r = {
382
+ ...e,
383
+ at: e.at ?? /* @__PURE__ */ new Date()
384
+ };
385
+ ie(r.responderRevocationCrlMaxAgeMs), re(r.clockSkewMs);
386
+ let i;
340
387
  try {
341
- n = normalizeOcspResponse(t.response);
342
- } catch (t) {
343
- let n = o(t, e);
344
- return n === void 0 ? validateOcspResponseFailureResult("signature_invalid", "OCSP response signed content is malformed") : validateOcspResponseFailureResult(n.code, n.message);
345
- }
346
- if (n.responseStatus !== "successful") return validateOcspResponseFailureResult("response_status_invalid", `OCSP response status is ${n.responseStatus}`);
347
- let r = await normalizeOcspValidationInput(t, n);
348
- if (!r.ok) return r;
349
- let { issuer: i, trustedResponders: a, signer: s } = r, c = await verifyOcspResponseSignature(n, s);
350
- if (!c.ok) return validateOcspResponseFailureResult(c.code, c.message);
351
- let l = await validateOcspResponderAuthorization(t, n, i, s, a);
352
- if (l !== void 0) return l;
353
- let u = t.at ?? /* @__PURE__ */ new Date(), d = t.clockSkewMs ?? 0, f = await validateOcspResponseFreshness(n, i, {
354
- at: u,
355
- skew: d,
356
- profile: t.profile ?? "rfc6960"
388
+ i = normalizeOcspResponse(r.response);
389
+ } catch (e) {
390
+ let t = p(e, K);
391
+ return t === void 0 ? validateOcspResponseFailureResult("malformed", "OCSP response signed content is malformed") : validateOcspResponseFailureResult(t.code, t.message);
392
+ }
393
+ if (i.responseStatus !== "successful") return validateOcspResponseFailureResult("response_status_invalid", `OCSP response status is ${i.responseStatus}`);
394
+ let a = await normalizeOcspValidationInput(r, t, i);
395
+ if (!a.ok) return a;
396
+ let { issuer: o, trustedResponders: s, signer: c } = a, l = n.issuerWorkingKey ?? (o.kind === "certificate" ? B(o.certificate) : te(o.trustAnchor)), u = {
397
+ ...n,
398
+ issuerWorkingKey: l,
399
+ deltaBudget: n.deltaBudget ?? { remaining: 32 }
400
+ }, d = await classifyOcspResponder(r, i, o, c, s, u), f = await verifyOcspResponseSignatureByKey(i, ocspKeyOf(c), {
401
+ verifiers: n.verifiers,
402
+ workingParameters: { parametersDer: responderWorkingParameters(d, l) }
403
+ });
404
+ if (!f.ok) return validateOcspResponseFailureResult(f.code, f.message);
405
+ let m = await validateOcspResponderAuthorization(r, i, d, u);
406
+ if (m !== void 0) return m;
407
+ let h = r.at ?? /* @__PURE__ */ new Date(), g = r.clockSkewMs ?? 0, _ = await validateOcspResponseFreshness(i, certIdIssuerKey(o), {
408
+ at: h,
409
+ skew: g,
410
+ profile: r.profile ?? "rfc6960"
357
411
  });
358
- if (f !== void 0) return f;
359
- if (hasDuplicateOcspResponseCertificateSerial(n.responses ?? [])) return validateOcspResponseFailureResult("signature_invalid", "OCSP response contains multiple status entries for the same certificate");
360
- if (t.request !== void 0) {
361
- let e = validateOcspRequestCoverage(t.request, n);
412
+ if (_ !== void 0) return _;
413
+ if (hasDuplicateOcspResponseCertificateSerial(i.responses ?? [])) return validateOcspResponseFailureResult("signature_invalid", "OCSP response contains multiple status entries for the same certificate");
414
+ if (r.request !== void 0) {
415
+ let e = validateOcspRequestCoverage(r.request, i);
362
416
  if (e !== void 0) return e;
363
417
  }
364
418
  return {
365
419
  ok: !0,
366
- value: n
420
+ value: i
367
421
  };
368
422
  }
369
423
  /** Re-parses OCSP validation certificates and resolves the response signer. */
370
- async function normalizeOcspValidationInput(t, n) {
424
+ async function normalizeOcspValidationInput(e, t, n) {
371
425
  let r;
372
426
  try {
373
- r = normalizeCertificate(t.issuerCertificate);
374
- } catch (t) {
375
- let n = o(t, e);
376
- return n === void 0 ? validateOcspResponseFailureResult("signature_invalid", "issuer certificate input is malformed") : validateOcspResponseFailureResult(n.code, n.message);
427
+ r = t.kind === "certificate" ? {
428
+ kind: "certificate",
429
+ certificate: normalizeCertificate(t.certificate)
430
+ } : t;
431
+ } catch (e) {
432
+ let t = p(e, K);
433
+ return t === void 0 ? validateOcspResponseFailureResult("malformed", "issuer certificate input is malformed") : validateOcspResponseFailureResult(t.code, t.message);
377
434
  }
378
435
  try {
379
- let e = (t.trustedOcspResponders ?? []).map(normalizeCertificate), i = await resolveOcspResponderCertificate(t, n, e);
436
+ let i = (e.trustedOcspResponders ?? []).map(normalizeCertificate), a = await resolveOcspResponderCertificate(e, t, n, i);
380
437
  return {
381
438
  ok: !0,
382
439
  parsedResponse: n,
383
440
  issuer: r,
384
- trustedResponders: e,
385
- signer: normalizeCertificate(i)
441
+ trustedResponders: i,
442
+ signer: a === void 0 ? r : {
443
+ kind: "certificate",
444
+ certificate: normalizeCertificate(a)
445
+ }
386
446
  };
387
- } catch (t) {
388
- let n = o(t, e);
389
- return n === void 0 ? validateOcspResponseFailureResult("signature_invalid", "OCSP responder certificate input is malformed") : validateOcspResponseFailureResult(n.code, n.message);
447
+ } catch (e) {
448
+ let t = p(e, K);
449
+ return t === void 0 ? validateOcspResponseFailureResult("malformed", "OCSP responder certificate input is malformed") : validateOcspResponseFailureResult(t.code, t.message);
390
450
  }
391
451
  }
392
- /** Selects the responder certificate from explicit, embedded, trusted, or issuer inputs. */
393
- async function resolveOcspResponderCertificate(e, t, n) {
394
- return e.responderCertificate ?? await findMatchingOcspResponderCertificate(t.certificates, t.responderId) ?? await findMatchingOcspResponderCertificate(n, t.responderId) ?? t.certificates?.[0] ?? e.issuerCertificate;
395
- }
396
- async function validateOcspResponderAuthorization(e, t, n, r, i) {
397
- let a = await safeValidateOcspResponderIdBinding(t, r);
398
- if (!a.ok) return a;
399
- let o = i.some((e) => isSameOcspCertificate(r, e));
400
- if (!(isSameOcspCertificate(r, n) || o)) return await validateDelegatedOcspResponder(e, t, n, r);
452
+ /**
453
+ * Selects the responder certificate from explicit, embedded, trusted, or issuer
454
+ * inputs. `undefined` means the bare trust anchor issuer signed the response
455
+ * with its own key.
456
+ */
457
+ async function resolveOcspResponderCertificate(e, t, n, r) {
458
+ let i = e.responderCertificate ?? await findMatchingOcspResponderCertificate(n.certificates, n.responderId) ?? await findMatchingOcspResponderCertificate(r, n.responderId);
459
+ if (i !== void 0) return i;
460
+ if (t.kind === "certificate") return n.certificates?.[0] ?? t.certificate;
461
+ let a = n.responderId;
462
+ return a === void 0 || await matchesOcspResponderId(a, t.trustAnchor) ? void 0 : n.certificates?.[0];
463
+ }
464
+ async function classifyOcspResponder(e, t, n, r, i, a) {
465
+ if (r.kind === "trust_anchor" || isOcspIssuer(r.certificate, n)) return {
466
+ kind: "issuer",
467
+ signer: r
468
+ };
469
+ let o = r.certificate;
470
+ return i.some((e) => isSameOcspCertificate(o, e)) ? {
471
+ kind: "trusted",
472
+ certificate: o
473
+ } : {
474
+ kind: "delegated",
475
+ certificate: o,
476
+ path: await validateDelegatedResponderPath(e, t, n, o, a)
477
+ };
401
478
  }
402
- async function safeValidateOcspResponderIdBinding(t, n) {
403
- try {
404
- return await validateOcspResponderIdBinding(t.responderId, n);
405
- } catch (t) {
406
- let n = o(t, e);
407
- return n === void 0 ? validateOcspResponseFailureResult("signature_invalid", "OCSP responder certificate input is malformed") : validateOcspResponseFailureResult(n.code, n.message);
479
+ /**
480
+ * The key parameters a responder's signature verifies with: the issuer's
481
+ * working key, a trusted responder's own or inherited parameters, or those its
482
+ * delegated path gives it.
483
+ */
484
+ function responderWorkingParameters(e, t) {
485
+ return e.kind === "issuer" ? t.parametersDer : e.kind === "delegated" && e.path.ok ? e.path.parametersDer : U([e.certificate], 0, 0, t);
486
+ }
487
+ async function validateOcspResponderAuthorization(e, t, n, r) {
488
+ let i = await validateOcspResponderIdBinding(t.responderId, n.kind === "issuer" ? ocspKeyOf(n.signer) : n.certificate);
489
+ if (!i.ok) return i;
490
+ if (n.kind !== "delegated") return;
491
+ if (!n.path.ok) return n.path;
492
+ let a = await validateDelegatedOcspResponder(e, n.path.issuer, n.certificate, {
493
+ ...r,
494
+ issuerWorkingKey: n.path.issuerWorkingKey
495
+ });
496
+ if (a !== void 0) return a;
497
+ for (let t of n.path.caCertificates) {
498
+ let n = await checkDelegatedResponderRevocation(t.certificate, t.issuer, e, {
499
+ ...r,
500
+ issuerWorkingKey: t.issuerWorkingKey
501
+ });
502
+ if (!n.ok) return n;
408
503
  }
409
504
  }
410
- async function validateDelegatedOcspResponder(e, t, n, r) {
411
- let i = e.allowChainedResponderCertificate === !0;
412
- if (!i && !isDirectlyIssuedByOcspIssuer(r, n)) return validateOcspResponseFailureResult("responder_chain_invalid", "Delegated OCSP responder must be directly issued by issuer certificate");
413
- if (!(await Q({
505
+ /**
506
+ * Whether `signer` is the issuer itself: the issuer certificate, or a
507
+ * certificate carrying the bare trust anchor's name and key.
508
+ */
509
+ function isOcspIssuer(e, t) {
510
+ return t.kind === "certificate" ? isSameOcspCertificate(e, t.certificate) : ne(e, t.trustAnchor);
511
+ }
512
+ /**
513
+ * Validates a delegated responder's certification path below `issuer`, which
514
+ * starts from the issuer's working key (RFC 5280 §6.1.4 (e)), and returns the
515
+ * parameters that path gives the responder's key.
516
+ */
517
+ async function validateDelegatedResponderPath(e, t, n, r, i) {
518
+ let a = i.issuerWorkingKey, o = e.allowChainedResponderCertificate === !0;
519
+ if (!o && !isDirectlyIssuedByOcspIssuer(r, ocspKeyOf(n))) return validateOcspResponseFailureResult("responder_chain_invalid", "Delegated OCSP responder must be directly issued by issuer certificate");
520
+ let s = await ce({
414
521
  leaf: r.der,
415
- intermediates: i ? buildOcspResponderIntermediates(t.certificates, r, n) : [],
416
- roots: [n.der],
417
- ...e.at === void 0 ? {} : { at: e.at }
418
- })).ok) return validateOcspResponseFailureResult("responder_chain_invalid", "OCSP responder certificate chain does not validate");
419
- if (r.extendedKeyUsage === void 0 || !r.extendedKeyUsage.includes("ocspSigning")) return validateOcspResponseFailureResult("ocsp_signing_missing", "Delegated OCSP responder lacks ocspSigning EKU");
420
- let a = await checkDelegatedResponderRevocation(r, n, e);
421
- return a.ok ? void 0 : a;
522
+ intermediates: o ? buildOcspResponderIntermediates(t.certificates, r, ocspCertificateOf(n)) : [],
523
+ ...delegatedPathStart(n, a),
524
+ ...e.at === void 0 ? {} : { at: e.at },
525
+ ...e.signatureVerifiers !== void 0 && { signatureVerifiers: e.signatureVerifiers },
526
+ ...i.distrustedSpkiSha256 !== void 0 && { distrustedSpkiSha256: i.distrustedSpkiSha256 }
527
+ });
528
+ if (!s.ok) return validateOcspResponseFailureResult("responder_chain_invalid", "OCSP responder certificate chain does not validate");
529
+ let [c, ...l] = responderPathLinks(s.value, n, a);
530
+ return {
531
+ ok: !0,
532
+ parametersDer: V(s.value, 0).parametersDer,
533
+ issuer: c?.issuer ?? n,
534
+ issuerWorkingKey: c?.issuerWorkingKey ?? a,
535
+ caCertificates: l
536
+ };
537
+ }
538
+ /**
539
+ * Each certificate of a delegated responder's validated path below the OCSP
540
+ * issuer, with the next certificate as its issuer and the OCSP issuer above
541
+ * the last.
542
+ */
543
+ function responderPathLinks(e, t, n) {
544
+ return (e.anchorCertificateInChain ? e.chain.slice(0, -1) : e.chain).map((r, i) => {
545
+ let a = e.chain[i + 1];
546
+ return a === void 0 ? {
547
+ certificate: r,
548
+ issuer: t,
549
+ issuerWorkingKey: n
550
+ } : {
551
+ certificate: r,
552
+ issuer: {
553
+ kind: "certificate",
554
+ certificate: a
555
+ },
556
+ issuerWorkingKey: V(e, i + 1)
557
+ };
558
+ });
559
+ }
560
+ /**
561
+ * Where a delegated responder's path starts: the issuer certificate as root,
562
+ * or trust anchor information carrying the issuer's working key when the
563
+ * issuer inherits its parameters or is a bare anchor.
564
+ */
565
+ function delegatedPathStart(e, t) {
566
+ if (e.kind === "trust_anchor") return {
567
+ roots: [],
568
+ trustAnchors: [e.trustAnchor]
569
+ };
570
+ let n = B(e.certificate).parametersDer, r = t.parametersDer;
571
+ return r === void 0 || n !== void 0 && sameDer(n, r) ? { roots: [e.certificate.der] } : {
572
+ roots: [],
573
+ trustAnchors: [H(Q(e.certificate), r)]
574
+ };
575
+ }
576
+ function sameDer(e, t) {
577
+ return e.length === t.length && e.every((e, n) => e === t[n]);
578
+ }
579
+ /** The ocspSigning and revocation checks on a delegated responder whose path validated. */
580
+ async function validateDelegatedOcspResponder(e, t, n, r) {
581
+ if (n.extendedKeyUsage === void 0 || !n.extendedKeyUsage.includes("ocspSigning")) return validateOcspResponseFailureResult("ocsp_signing_missing", "Delegated OCSP responder lacks ocspSigning EKU");
582
+ let i = await checkDelegatedResponderRevocation(n, t, e, r);
583
+ return i.ok ? void 0 : i;
422
584
  }
423
585
  /** Checks response-level and per-certificate OCSP timestamps against the validation time. */
424
586
  async function validateOcspResponseFreshness(e, t, n) {
@@ -442,27 +604,27 @@ function validateOcspSingleResponseTimes(e, t, { at: n, skew: r, profile: i }) {
442
604
  if (e.thisUpdate.getTime() - r > n.getTime() || e.nextUpdate !== void 0 && e.nextUpdate.getTime() + r < n.getTime()) return validateOcspResponseFailureResult("stale_response", "OCSP response is not valid at requested time");
443
605
  if (t !== void 0 && e.nextUpdate !== void 0 && t.getTime() - r > e.nextUpdate.getTime()) return validateOcspResponseFailureResult("stale_response", "OCSP response producedAt is later than nextUpdate");
444
606
  }
445
- function validateOcspRequestCoverage(t, n) {
446
- let r;
607
+ function validateOcspRequestCoverage(e, t) {
608
+ let n;
447
609
  try {
448
- r = normalizeOcspRequest(t);
449
- } catch (t) {
450
- let n = o(t, e);
451
- return n === void 0 ? validateOcspResponseFailureResult("request_mismatch", "OCSP request input is malformed") : validateOcspResponseFailureResult(n.code, n.message);
610
+ n = normalizeOcspRequest(e);
611
+ } catch (e) {
612
+ let t = p(e, K);
613
+ return t === void 0 ? validateOcspResponseFailureResult("malformed", "OCSP request input is malformed") : validateOcspResponseFailureResult(t.code, t.message);
452
614
  }
453
- return r.nonce !== void 0 && r.nonce !== n.nonce ? validateOcspResponseFailureResult("nonce_mismatch", "OCSP response nonce does not match request nonce") : validateOcspRequestIdCoverage(new Set(r.requests.map((e) => serializeCertId(e))), new Set((n.responses ?? []).map((e) => serializeCertId(e.certId))), n.responses ?? []);
615
+ return n.nonce !== void 0 && n.nonce !== t.nonce ? validateOcspResponseFailureResult("nonce_mismatch", "OCSP response nonce does not match request nonce") : validateOcspRequestIdCoverage(new Set(n.requests.map((e) => serializeCertId(e))), new Set((t.responses ?? []).map((e) => serializeCertId(e.certId))), t.responses ?? []);
454
616
  }
455
617
  function validateOcspRequestIdCoverage(e, t, n) {
456
618
  for (let t of n) if (!e.has(serializeCertId(t.certId))) return validateOcspResponseFailureResult("request_mismatch", "OCSP response includes a certId not present in request");
457
619
  for (let n of e) if (!t.has(n)) return validateOcspResponseFailureResult("request_mismatch", "OCSP response does not cover every requested certId");
458
620
  }
459
621
  /** Builds a `VerifyOcspResponseSignatureFailureResult`. */
460
- function verifyOcspResponseFailureResult(e, n) {
461
- return t(e, n);
622
+ function verifyOcspResponseFailureResult(e, t) {
623
+ return q(e, t);
462
624
  }
463
625
  /** Builds a `ValidateOcspResponseFailureResult`. */
464
- function validateOcspResponseFailureResult(e, n) {
465
- return t(e, n);
626
+ function validateOcspResponseFailureResult(e, t) {
627
+ return q(e, t);
466
628
  }
467
629
  /**
468
630
  * Reports whether a certificate carries the `id-pkix-ocsp-nocheck` extension
@@ -473,50 +635,74 @@ function validateOcspResponseFailureResult(e, n) {
473
635
  function hasOcspNoCheckExtension(e) {
474
636
  return carriesOcspNoCheck(normalizeCertificate(e));
475
637
  }
638
+ /** The RFC 9608 §4 exemption a certificate parsed from its signed DER carries. */
639
+ function revocationSkipReasonOf(e) {
640
+ return e.noRevAvail === !0 ? "no_rev_avail" : carriesOcspNoCheck(e) ? "ocsp_nocheck" : void 0;
641
+ }
476
642
  /** Whether a parsed certificate carries `id-pkix-ocsp-nocheck` with its NULL value. */
477
643
  function carriesOcspNoCheck(e) {
478
- return e.extensions.some((e) => e.oid === M.ocspNoCheck && e.valueHex === "0500");
644
+ return e.extensions.some((e) => e.oid === O.ocspNoCheck && e.valueHex === "0500");
479
645
  }
480
- /** Parses a CRL from PEM string, DER bytes, or an already-parsed CRL. */
481
- function parseResponderCrlFromSource(e) {
482
- return typeof e == "object" && "issuer" in e ? e : typeof e == "string" ? Z(e) : X(e);
646
+ /** The CRLs among `sources` that parse, split into complete and delta CRLs. */
647
+ function partitionResponderCrls(e) {
648
+ let t = [], n = [];
649
+ for (let r of e) {
650
+ let e;
651
+ try {
652
+ e = se(r);
653
+ } catch {
654
+ continue;
655
+ }
656
+ (e.baseCrlNumber === void 0 ? t : n).push(e);
657
+ }
658
+ return {
659
+ complete: Z(t),
660
+ delta: Z(n)
661
+ };
483
662
  }
484
- function responderCrlCheck(e, t, n) {
663
+ function responderCrlCheck(e) {
485
664
  return {
486
- certificate: e,
487
- issuerCertificate: t,
488
- at: n.at ?? /* @__PURE__ */ new Date(),
489
- ...n.responderRevocationCrlMaxAgeMs === void 0 ? {} : { maxAgeMs: n.responderRevocationCrlMaxAgeMs },
490
- ...n.clockSkewMs === void 0 ? {} : { clockSkewMs: n.clockSkewMs },
491
- ...n.responderRevocationUnrecognizedReasonCode === void 0 ? {} : { unrecognizedReasonCode: n.responderRevocationUnrecognizedReasonCode }
665
+ at: e.at ?? /* @__PURE__ */ new Date(),
666
+ ...e.responderRevocationCrlMaxAgeMs === void 0 ? {} : { maxAgeMs: e.responderRevocationCrlMaxAgeMs },
667
+ ...e.clockSkewMs === void 0 ? {} : { clockSkewMs: e.clockSkewMs },
668
+ ...e.responderRevocationUnrecognizedReasonCode === void 0 ? {} : { unrecognizedReasonCode: e.responderRevocationUnrecognizedReasonCode },
669
+ ...e.responderRevocationUnreadSupersededDeltaCrls === void 0 ? {} : { unreadSupersededDeltaCrls: e.responderRevocationUnreadSupersededDeltaCrls }
492
670
  };
493
671
  }
672
+ /** The responder revocation outcome that `policy` and the responder's own extensions settle before any CRL is read. */
673
+ function responderRevocationSettledWithoutCrls(e, t) {
674
+ if (t === "skip") return { ok: !0 };
675
+ let n = revocationSkipReasonOf(e);
676
+ return n === "no_rev_avail" ? t === "require-evidence" ? validateOcspResponseFailureResult("responder_revocation_unknown", "Delegated OCSP responder carries noRevAvail, which no CRL lists") : { ok: !0 } : n === "ocsp_nocheck" && t !== "require-evidence" ? { ok: !0 } : void 0;
677
+ }
494
678
  /**
495
679
  * Applies the delegated-responder revocation policy (RFC 6960 §4.2.2.2.1).
496
680
  * See {@linkcode OcspResponderRevocationPolicy} for the policy semantics.
497
681
  */
498
- async function checkDelegatedResponderRevocation(e, t, n) {
499
- let r = n.responderRevocationPolicy ?? "honor-nocheck";
500
- if (r === "skip" || r === "honor-nocheck" && hasOcspNoCheckExtension(e)) return { ok: !0 };
501
- let i = responderCrlCheck(e, t, n), a = /* @__PURE__ */ new Set(), o = !1;
502
- for (let e of n.responderRevocationCrls ?? []) {
503
- let t;
504
- try {
505
- t = parseResponderCrlFromSource(e);
506
- } catch {
682
+ async function checkDelegatedResponderRevocation(e, t, n, r) {
683
+ let i = n.responderRevocationPolicy ?? "nocheck-or-evidence", a = responderRevocationSettledWithoutCrls(e, i);
684
+ if (a !== void 0) return a;
685
+ let o = responderCrlCheck(n), s = {
686
+ verifiers: r.verifiers,
687
+ workingParameters: { parametersDer: r.issuerWorkingKey.parametersDer }
688
+ }, c = partitionResponderCrls(n.responderRevocationCrls ?? []), l = /* @__PURE__ */ new Set(), u = !1, d = !1;
689
+ for (let n of c.complete) {
690
+ let i = await ae(e, n, c.delta, t, o, s, [r.deltaBudget]);
691
+ if (i.kind === "unsettled") {
692
+ d = !0;
507
693
  continue;
508
694
  }
509
- let n = await J({
510
- ...i,
511
- crl: t
512
- });
513
- if (!n.ok) o ||= n.code === "reason_code_unrecognized";
695
+ let a = i.result;
696
+ if (!a.ok) u ||= a.code === "reason_code_unrecognized";
514
697
  else {
515
- if (n.value.status === "revoked") return validateOcspResponseFailureResult("responder_revoked", "Delegated OCSP responder certificate is revoked");
516
- for (let e of n.value.coveredReasons) a.add(e);
698
+ if (a.value.status === "revoked") return validateOcspResponseFailureResult("responder_revoked", "Delegated OCSP responder certificate is revoked");
699
+ for (let e of a.value.coveredReasons) l.add(e);
517
700
  }
518
701
  }
519
- return o ? validateOcspResponseFailureResult("responder_revocation_unknown", "Delegated OCSP responder carries an unrecognized CRL reason code") : Y(a) || r === "honor-nocheck" ? { ok: !0 } : validateOcspResponseFailureResult("responder_revocation_unknown", "Delegated OCSP responder revocation status could not be established");
702
+ return u ? validateOcspResponseFailureResult("responder_revocation_unknown", "Delegated OCSP responder carries an unrecognized CRL reason code") : d ? validateOcspResponseFailureResult("responder_revocation_unknown", "A delta CRL for the delegated OCSP responder could not settle its status") : oe(l) || i === "honor-nocheck" && !hasCriticalCrlDistributionPoints(e) ? { ok: !0 } : validateOcspResponseFailureResult("responder_revocation_unknown", "Delegated OCSP responder revocation status could not be established");
703
+ }
704
+ function hasCriticalCrlDistributionPoints(e) {
705
+ return e.extensions.some((e) => e.oid === O.cRLDistributionPoints && e.critical);
520
706
  }
521
707
  /** Accepts PEM, DER, or already-parsed OCSP response and returns a parsed response. */
522
708
  function normalizeOcspResponse(e) {
@@ -532,29 +718,29 @@ function normalizeOcspRequest(e) {
532
718
  if (hasReparseableOcspRequestShape(e)) return parseOcspRequestDerOrThrow(new Uint8Array(e.der));
533
719
  throw Error("OCSP request input is malformed");
534
720
  }
535
- function parseSignedOcspResponseData(e) {
536
- let t = v(e);
537
- if (t.length < 3 || t.length > 5) throw Error("Malformed OCSP responseData");
538
- let n = 0;
539
- if (t[n]?.tag === 160) {
540
- let r = k(t[n], "version"), i = x(e, r), a = k(i[0], "version");
541
- if (i.length !== 1 || a.tag !== 2) throw Error("version must use INTEGER");
542
- if (C(a.value, "OCSP response version") !== 0) throw Error("Unsupported OCSP response version");
543
- n += 1;
544
- }
545
- let r = parseOcspResponderId(e, k(t[n], "responderID"));
546
- n += 1;
547
- let i = k(t[n], "producedAt"), a = k(t[n + 1], "responses");
548
- if (a.tag !== 48) throw Error("responses must use SEQUENCE");
549
- if (x(e, a).length === 0) throw Error("responses must not be empty");
550
- let o = t[n + 2];
551
- if (o !== void 0 && o.tag !== 161 || t.length !== n + 2 + (o === void 0 ? 0 : 1)) throw Error("Malformed OCSP responseData");
552
- let s = o === void 0 ? void 0 : parseOcspNonceFromExtensions(e, o), c = x(e, a).map((t) => parseSingleResponse(e, t));
553
- return assertUniqueOcspResponseCertIds(c), {
554
- responderId: r,
555
- producedAt: O(i),
556
- responses: c,
557
- ...s === void 0 ? {} : { nonce: s }
721
+ function parseSignedOcspResponseData(t) {
722
+ let r = T(t);
723
+ if (r.length < 3 || r.length > 5) throw Error("Malformed OCSP responseData");
724
+ let i = 0;
725
+ if (r[i]?.tag === 160) {
726
+ let a = c(r[i], "version"), o = e(t, a), s = c(o[0], "version");
727
+ if (o.length !== 1 || s.tag !== 2) throw Error("version must use INTEGER");
728
+ if (n(s.value, "OCSP response version") !== 0) throw Error("Unsupported OCSP response version");
729
+ i += 1;
730
+ }
731
+ let a = parseOcspResponderId(t, c(r[i], "responderID"));
732
+ i += 1;
733
+ let o = c(r[i], "producedAt"), l = c(r[i + 1], "responses");
734
+ if (l.tag !== 48) throw Error("responses must use SEQUENCE");
735
+ if (e(t, l).length === 0) throw Error("responses must not be empty");
736
+ let u = r[i + 2];
737
+ if (u !== void 0 && u.tag !== 161 || r.length !== i + 2 + (u === void 0 ? 0 : 1)) throw Error("Malformed OCSP responseData");
738
+ let d = u === void 0 ? void 0 : parseOcspNonceFromExtensions(t, u), f = e(t, l).map((e) => parseSingleResponse(t, e));
739
+ return assertUniqueOcspResponseCertIds(f), {
740
+ responderId: a,
741
+ producedAt: s(o),
742
+ responses: f,
743
+ ...d === void 0 ? {} : { nonce: d }
558
744
  };
559
745
  }
560
746
  /** Searches embedded certificates for one whose subject or key hash matches the responder ID. */
@@ -569,31 +755,31 @@ async function validateOcspResponderIdBinding(e, t) {
569
755
  }
570
756
  /** Returns `true` if the certificate matches the responder ID (subject name or key hash). */
571
757
  async function matchesOcspResponderId(e, t) {
572
- return e.type === "byName" ? compareOcspResponderNames(e.name, t.subject) : j(await digestBytes("SHA-1", extractSubjectPublicKeyBytes(t.subjectPublicKeyInfoDer))) === e.keyHashHex;
758
+ return e.type === "byName" ? compareOcspResponderNames(e.name, t.subject) : d(await digestBytes("SHA-1", extractSubjectPublicKeyBytes(t.subjectPublicKeyInfoDer))) === e.keyHashHex;
573
759
  }
574
760
  /** Identity check — same serial, issuer, subject, and SPKI. */
575
761
  function isSameOcspCertificate(e, t) {
576
- return e.serialNumberHex === t.serialNumberHex && W(e.issuer, t.issuer) && W(e.subject, t.subject) && e.subjectPublicKeyInfoDer.length === t.subjectPublicKeyInfoDer.length && e.subjectPublicKeyInfoDer.every((e, n) => e === t.subjectPublicKeyInfoDer[n]);
762
+ return e.serialNumberHex === t.serialNumberHex && z(e.issuer, t.issuer) && z(e.subject, t.subject) && e.subjectPublicKeyInfoDer.length === t.subjectPublicKeyInfoDer.length && e.subjectPublicKeyInfoDer.every((e, n) => e === t.subjectPublicKeyInfoDer[n]);
577
763
  }
578
764
  /** Returns `true` if `signer` was directly issued by `issuer` (name + AKI match). */
579
765
  function isDirectlyIssuedByOcspIssuer(e, t) {
580
- return !(!W(e.issuer, t.subject) || e.authorityKeyIdentifier !== void 0 && t.subjectKeyIdentifier !== void 0 && e.authorityKeyIdentifier !== t.subjectKeyIdentifier);
766
+ return !(!z(e.issuer, t.subject) || e.authorityKeyIdentifier !== void 0 && t.subjectKeyIdentifier !== void 0 && e.authorityKeyIdentifier !== t.subjectKeyIdentifier);
581
767
  }
582
768
  /** Filters embedded certificates to produce an intermediate chain (excluding signer and issuer). */
583
769
  function buildOcspResponderIntermediates(e, t, n) {
584
770
  if (e === void 0) return [];
585
771
  let r = [];
586
- for (let i of e) isSameOcspCertificate(i, t) || isSameOcspCertificate(i, n) || r.push(i.der);
772
+ for (let i of e) isSameOcspCertificate(i, t) || n !== void 0 && isSameOcspCertificate(i, n) || r.push(i.der);
587
773
  return r;
588
774
  }
589
775
  /** DER-encodes a CertID SEQUENCE (hashAlgorithm, issuerNameHash, issuerKeyHash, serialNumber). */
590
776
  async function encodeOcspCertId(e, t, n) {
591
- let r = n === "SHA-1" ? M.sha1 : M.sha256, i = await buildParsedOcspCertId(r, t, e.serialNumberHex);
592
- return y([
593
- y([m(r), p()]),
594
- h(D(i.issuerNameHashHex)),
595
- h(D(i.issuerKeyHashHex)),
596
- f(D(i.serialNumberHex))
777
+ let r = n === "SHA-1" ? O.sha1 : O.sha256, i = await buildParsedOcspCertId(r, t, e.serialNumberHex);
778
+ return E([
779
+ E([x(r), b()]),
780
+ S(o(i.issuerNameHashHex)),
781
+ S(o(i.issuerKeyHashHex)),
782
+ y(o(i.serialNumberHex))
597
783
  ]);
598
784
  }
599
785
  /** Computes issuer name/key hashes for a CertID given the hash algorithm OID and issuer certificate. */
@@ -601,171 +787,171 @@ async function buildParsedOcspCertId(e, t, n) {
601
787
  let r = ocspHashAlgorithmFromOid(e);
602
788
  return {
603
789
  hashAlgorithmOid: e,
604
- hashAlgorithmName: H(e),
605
- issuerNameHashHex: j(await digestBytes(r, D(t.subject.derHex))),
606
- issuerKeyHashHex: j(await digestBytes(r, extractSubjectPublicKeyBytes(t.subjectPublicKeyInfoDer))),
790
+ hashAlgorithmName: k(e),
791
+ issuerNameHashHex: d(await digestBytes(r, o(t.subject.derHex))),
792
+ issuerKeyHashHex: d(await digestBytes(r, extractSubjectPublicKeyBytes(t.subjectPublicKeyInfoDer))),
607
793
  serialNumberHex: n
608
794
  };
609
795
  }
610
796
  /** Hashes `bytes` with the given WebCrypto algorithm name. */
611
797
  async function digestBytes(e, t) {
612
- return new Uint8Array(await N().subtle.digest(e, A(t)));
798
+ return new Uint8Array(await L().subtle.digest(e, u(t)));
613
799
  }
614
800
  /** DER-encodes a SingleResponse (certId, certStatus, thisUpdate, optional nextUpdate). */
615
801
  async function encodeSingleResponse(e, t, n, r) {
616
802
  let i = await encodeOcspCertId(e, t, r), a = encodeOcspCertStatus(n);
617
- return y([
803
+ return E([
618
804
  i,
619
805
  a,
620
- d(n.thisUpdate ?? /* @__PURE__ */ new Date()),
621
- ...n.nextUpdate === void 0 ? [] : [u(0, d(n.nextUpdate))]
806
+ v(n.thisUpdate ?? /* @__PURE__ */ new Date()),
807
+ ...n.nextUpdate === void 0 ? [] : [_(0, v(n.nextUpdate))]
622
808
  ]);
623
809
  }
624
810
  /** DER-encodes the CertStatus CHOICE (good [0], revoked [1], unknown [2]). */
625
811
  function encodeOcspCertStatus(e) {
626
812
  switch (e.certStatus) {
627
- case "good": return b(128, /* @__PURE__ */ new Uint8Array());
628
- case "unknown": return b(130, /* @__PURE__ */ new Uint8Array());
813
+ case "good": return D(128, /* @__PURE__ */ new Uint8Array());
814
+ case "unknown": return D(130, /* @__PURE__ */ new Uint8Array());
629
815
  case "revoked": {
630
- let t = [d(e.revokedAt ?? e.thisUpdate ?? /* @__PURE__ */ new Date())];
631
- return e.revocationReasonCode !== void 0 && t.push(u(0, l(e.revocationReasonCode))), b(161, c(t));
816
+ let t = [v(e.revokedAt ?? e.thisUpdate ?? /* @__PURE__ */ new Date())];
817
+ return e.revocationReasonCode !== void 0 && t.push(_(0, g(e.revocationReasonCode))), D(161, h(t));
632
818
  }
633
819
  default: throw Error(`Unhandled CertStatus type: ${String(e)}`);
634
820
  }
635
821
  }
636
822
  /** Accepts PEM, DER, or already-parsed certificate and returns a parsed certificate. */
637
823
  function normalizeCertificate(e) {
638
- return hasParsedCertificateShape(e) ? G(new Uint8Array(e.der)) : K(e);
824
+ return hasParsedCertificateShape(e) ? $(new Uint8Array(e.der)) : le(e);
639
825
  }
640
826
  /** Type guard: distinguishes a `ParsedCertificate` from raw `Uint8Array`. */
641
827
  function hasParsedCertificateShape(e) {
642
828
  return typeof e != "string" && "subjectPublicKeyInfoDer" in e;
643
829
  }
644
830
  /** Decodes a DER-encoded CertID SEQUENCE into a {@linkcode ParsedOcspCertId}. */
645
- function parseOcspCertId(e) {
646
- let t = _(e, { maxDepth: 64 });
647
- if (t.tag !== 48) throw Error("CertID must use SEQUENCE");
648
- let n = x(e, t);
649
- if (n.length !== 4) throw Error("CertID must contain hashAlgorithm, issuerNameHash, issuerKeyHash, and serialNumber");
650
- let r = k(n[0], "hashAlgorithm");
651
- if (r.tag !== 48) throw Error("hashAlgorithm must use SEQUENCE");
652
- let i = x(e, r);
653
- if (i.length < 1 || i.length > 2) throw Error("Malformed hashAlgorithm");
654
- let a = k(i[0], "hashAlgorithm OID"), o = w(a.value);
655
- if (k(n[1], "issuerNameHash").tag !== 4) throw Error("issuerNameHash must use OCTET STRING");
656
- if (k(n[2], "issuerKeyHash").tag !== 4) throw Error("issuerKeyHash must use OCTET STRING");
657
- let s = k(n[3], "serialNumber");
658
- if (s.tag !== 2) throw Error("serialNumber must use INTEGER");
831
+ function parseOcspCertId(t) {
832
+ let n = w(t, { maxDepth: 64 });
833
+ if (n.tag !== 48) throw Error("CertID must use SEQUENCE");
834
+ let i = e(t, n);
835
+ if (i.length !== 4) throw Error("CertID must contain hashAlgorithm, issuerNameHash, issuerKeyHash, and serialNumber");
836
+ let a = c(i[0], "hashAlgorithm");
837
+ if (a.tag !== 48) throw Error("hashAlgorithm must use SEQUENCE");
838
+ let o = e(t, a);
839
+ if (o.length < 1 || o.length > 2) throw Error("Malformed hashAlgorithm");
840
+ let s = c(o[0], "hashAlgorithm OID"), l = r(s.value);
841
+ if (c(i[1], "issuerNameHash").tag !== 4) throw Error("issuerNameHash must use OCTET STRING");
842
+ if (c(i[2], "issuerKeyHash").tag !== 4) throw Error("issuerKeyHash must use OCTET STRING");
843
+ let u = c(i[3], "serialNumber");
844
+ if (u.tag !== 2) throw Error("serialNumber must use INTEGER");
659
845
  return {
660
- hashAlgorithmOid: o,
661
- hashAlgorithmName: H(o),
662
- issuerNameHashHex: j(k(n[1], "issuerNameHash").value),
663
- issuerKeyHashHex: j(k(n[2], "issuerKeyHash").value),
664
- serialNumberHex: j(s.value)
846
+ hashAlgorithmOid: l,
847
+ hashAlgorithmName: k(l),
848
+ issuerNameHashHex: d(c(i[1], "issuerNameHash").value),
849
+ issuerKeyHashHex: d(c(i[2], "issuerKeyHash").value),
850
+ serialNumberHex: d(u.value)
665
851
  };
666
852
  }
667
853
  /** Decodes a SingleResponse from its ASN.1 element within the ResponseData. */
668
- function parseSingleResponse(e, t) {
669
- let n = x(e, t);
670
- if (n.length < 3 || n.length > 5) throw Error("Malformed OCSP SingleResponse");
671
- let r = k(n[0], "certId"), i = k(n[1], "certStatus"), a = k(n[2], "thisUpdate"), o = 3, s = n[o]?.tag === 160 ? n[o] : void 0;
672
- s !== void 0 && (validateOcspSingleResponseNextUpdate(e, s), o += 1);
673
- let c = n[o];
674
- if (c !== void 0 && c.tag !== 161 || n.length !== o + (c === void 0 ? 0 : 1)) throw Error("Malformed OCSP SingleResponse");
854
+ function parseSingleResponse(t, n) {
855
+ let r = e(t, n);
856
+ if (r.length < 3 || r.length > 5) throw Error("Malformed OCSP SingleResponse");
857
+ let i = c(r[0], "certId"), a = c(r[1], "certStatus"), o = c(r[2], "thisUpdate"), l = 3, u = r[l]?.tag === 160 ? r[l] : void 0;
858
+ u !== void 0 && (validateOcspSingleResponseNextUpdate(t, u), l += 1);
859
+ let d = r[l];
860
+ if (d !== void 0 && d.tag !== 161 || r.length !== l + (d === void 0 ? 0 : 1)) throw Error("Malformed OCSP SingleResponse");
675
861
  return {
676
- certId: parseOcspCertId(e.slice(r.start - r.headerLength, r.end)),
677
- thisUpdate: O(a),
678
- ...parseOcspSingleResponseNextUpdate(e, s),
679
- ...parseOcspCertStatusFields(e, i)
862
+ certId: parseOcspCertId(t.slice(i.start - i.headerLength, i.end)),
863
+ thisUpdate: s(o),
864
+ ...parseOcspSingleResponseNextUpdate(t, u),
865
+ ...parseOcspCertStatusFields(t, a)
680
866
  };
681
867
  }
682
- function parseOcspSingleResponseNextUpdate(e, t) {
683
- return t === void 0 ? {} : { nextUpdate: O(k(x(e, t)[0], "nextUpdate")) };
868
+ function parseOcspSingleResponseNextUpdate(t, n) {
869
+ return n === void 0 ? {} : { nextUpdate: s(c(e(t, n)[0], "nextUpdate")) };
684
870
  }
685
- function parseOcspCertStatusFields(e, t) {
686
- if (t.tag === 128) {
687
- if (t.value.length !== 0) throw Error("OCSP good certStatus must be empty");
871
+ function parseOcspCertStatusFields(t, n) {
872
+ if (n.tag === 128) {
873
+ if (n.value.length !== 0) throw Error("OCSP good certStatus must be empty");
688
874
  return { certStatus: "good" };
689
875
  }
690
- if (t.tag === 130) {
691
- if (t.value.length !== 0) throw Error("OCSP unknown certStatus must be empty");
876
+ if (n.tag === 130) {
877
+ if (n.value.length !== 0) throw Error("OCSP unknown certStatus must be empty");
692
878
  return { certStatus: "unknown" };
693
879
  }
694
- if (t.tag !== 161) throw Error(`Unsupported OCSP certStatus tag: ${String(t.tag)}`);
695
- let n = x(e, t);
696
- if (n.length < 1 || n.length > 2) throw Error("Malformed OCSP revoked certStatus");
880
+ if (n.tag !== 161) throw Error(`Unsupported OCSP certStatus tag: ${String(n.tag)}`);
881
+ let r = e(t, n);
882
+ if (r.length < 1 || r.length > 2) throw Error("Malformed OCSP revoked certStatus");
697
883
  return {
698
884
  certStatus: "revoked",
699
- revokedAt: O(k(n[0], "revocationTime")),
700
- ...parseOcspRevocationReason(e, n[1])
885
+ revokedAt: s(c(r[0], "revocationTime")),
886
+ ...parseOcspRevocationReason(t, r[1])
701
887
  };
702
888
  }
703
- function parseOcspRevocationReason(e, t) {
704
- if (t === void 0) return {};
705
- if (t.tag !== 160) throw Error("Malformed OCSP revoked certStatus");
706
- let n = x(e, t), r = k(n[0], "revocationReason");
707
- if (n.length !== 1 || r.tag !== 10) throw Error("revocationReason must use ENUMERATED");
708
- return { revocationReasonCode: S(r.value, "OCSP revocationReason") };
889
+ function parseOcspRevocationReason(n, r) {
890
+ if (r === void 0) return {};
891
+ if (r.tag !== 160) throw Error("Malformed OCSP revoked certStatus");
892
+ let i = e(n, r), a = c(i[0], "revocationReason");
893
+ if (i.length !== 1 || a.tag !== 10) throw Error("revocationReason must use ENUMERATED");
894
+ return { revocationReasonCode: t(a.value, "OCSP revocationReason") };
709
895
  }
710
896
  /** Decodes a ResponderID from its context-tagged ASN.1 element (byName [1] or byKeyHash [2]). */
711
- function parseOcspResponderId(e, t) {
712
- switch (t.tag) {
897
+ function parseOcspResponderId(t, n) {
898
+ switch (n.tag) {
713
899
  case 162: {
714
- let n = x(e, t);
715
- if (n.length !== 1) throw Error("ResponderID byKey must wrap exactly one OCTET STRING");
716
- let r = k(n[0], "ResponderID byKey");
717
- if (r.tag !== 4) throw Error("ResponderID byKey must wrap an OCTET STRING");
718
- if (r.value.length !== 20) throw Error("ResponderID byKey must be a 20-byte SHA-1 KeyHash");
900
+ let r = e(t, n);
901
+ if (r.length !== 1) throw Error("ResponderID byKey must wrap exactly one OCTET STRING");
902
+ let i = c(r[0], "ResponderID byKey");
903
+ if (i.tag !== 4) throw Error("ResponderID byKey must wrap an OCTET STRING");
904
+ if (i.value.length !== 20) throw Error("ResponderID byKey must be a 20-byte SHA-1 KeyHash");
719
905
  return {
720
906
  type: "byKeyHash",
721
- keyHashHex: j(r.value)
907
+ keyHashHex: d(i.value)
722
908
  };
723
909
  }
724
910
  case 161:
725
- if (x(e, t).length !== 1) throw Error("ResponderID byName must wrap exactly one Name");
911
+ if (e(t, n).length !== 1) throw Error("ResponderID byName must wrap exactly one Name");
726
912
  return {
727
913
  type: "byName",
728
- name: parseResponderName(e, k(x(e, t)[0], "ResponderID byName"))
914
+ name: parseResponderName(t, c(e(t, n)[0], "ResponderID byName"))
729
915
  };
730
- default: throw Error(`Unsupported OCSP responderID tag: ${String(t.tag)}`);
916
+ default: throw Error(`Unsupported OCSP responderID tag: ${String(n.tag)}`);
731
917
  }
732
918
  }
733
919
  /** Decodes a Name SEQUENCE from the ResponderID byName form. */
734
- function parseResponderName(e, t) {
735
- if (t.tag !== 48) throw Error("ResponderID byName must use Name SEQUENCE");
736
- let n = [], r = [], i = {};
737
- for (let a of x(e, t)) {
738
- let t = parseResponderNameAttributeSet(e, a);
739
- n.push(t);
740
- for (let e of t.attributes) r.push(e), e.key !== void 0 && i[e.key] === void 0 && (i[e.key] = e.value);
920
+ function parseResponderName(t, n) {
921
+ if (n.tag !== 48) throw Error("ResponderID byName must use Name SEQUENCE");
922
+ let r = [], i = [], a = {};
923
+ for (let o of e(t, n)) {
924
+ let e = parseResponderNameAttributeSet(t, o);
925
+ r.push(e);
926
+ for (let t of e.attributes) i.push(t), t.key !== void 0 && a[t.key] === void 0 && (a[t.key] = t.value);
741
927
  }
742
928
  return {
743
- derHex: j(e.slice(t.start - t.headerLength, t.end)),
744
- rdns: n,
745
- attributes: r,
746
- values: i
929
+ derHex: d(t.slice(n.start - n.headerLength, n.end)),
930
+ rdns: r,
931
+ attributes: i,
932
+ values: a
747
933
  };
748
934
  }
749
935
  /** Decodes one RDN SET from a responder name. */
750
- function parseResponderNameAttributeSet(e, t) {
751
- let n = [], r = {};
752
- for (let i of x(e, t)) {
753
- let t = x(e, i), a = w(k(t[0], "name OID").value), o = k(t[1], "name value"), s = responderNameKeyFromOid(a), c = T(o.tag, o.value), l = s === void 0 ? {
754
- oid: a,
755
- valueTag: o.tag,
756
- value: c
936
+ function parseResponderNameAttributeSet(t, n) {
937
+ let a = [], o = {};
938
+ for (let s of e(t, n)) {
939
+ let n = e(t, s), l = r(c(n[0], "name OID").value), u = c(n[1], "name value"), d = responderNameKeyFromOid(l), f = i(u.tag, u.value), p = d === void 0 ? {
940
+ oid: l,
941
+ valueTag: u.tag,
942
+ value: f
757
943
  } : {
758
- oid: a,
759
- key: s,
760
- valueTag: o.tag,
761
- value: c
944
+ oid: l,
945
+ key: d,
946
+ valueTag: u.tag,
947
+ value: f
762
948
  };
763
- n.push(l), s !== void 0 && r[s] === void 0 && (r[s] = c);
949
+ a.push(p), d !== void 0 && o[d] === void 0 && (o[d] = f);
764
950
  }
765
951
  return {
766
- derHex: j(e.slice(t.start - t.headerLength, t.end)),
767
- attributes: n,
768
- values: r
952
+ derHex: d(t.slice(n.start - n.headerLength, n.end)),
953
+ attributes: a,
954
+ values: o
769
955
  };
770
956
  }
771
957
  /** RDN-by-RDN responder name comparison with RFC 4518 string prep. */
@@ -815,57 +1001,57 @@ function prepareOcspNameCompareString(e) {
815
1001
  /** Maps a directory attribute type OID (X.520 `id-at` arc plus the legacy PKCS #9 emailAddress) to its friendly key name for responder name parsing. */
816
1002
  function responderNameKeyFromOid(e) {
817
1003
  switch (e) {
818
- case M.commonName: return "commonName";
819
- case M.surname: return "surname";
820
- case M.serialNumber: return "serialNumber";
821
- case M.countryName: return "country";
822
- case M.localityName: return "locality";
823
- case M.stateOrProvinceName: return "state";
824
- case M.streetAddress: return "street";
825
- case M.organizationName: return "organization";
826
- case M.organizationalUnitName: return "organizationalUnit";
827
- case M.title: return "title";
828
- case M.givenName: return "givenName";
829
- case M.emailAddress: return "emailAddress";
1004
+ case O.commonName: return "commonName";
1005
+ case O.surname: return "surname";
1006
+ case O.serialNumber: return "serialNumber";
1007
+ case O.countryName: return "country";
1008
+ case O.localityName: return "locality";
1009
+ case O.stateOrProvinceName: return "state";
1010
+ case O.streetAddress: return "street";
1011
+ case O.organizationName: return "organization";
1012
+ case O.organizationalUnitName: return "organizationalUnit";
1013
+ case O.title: return "title";
1014
+ case O.givenName: return "givenName";
1015
+ case O.emailAddress: return "emailAddress";
830
1016
  default: return;
831
1017
  }
832
1018
  }
833
1019
  /** Extracts the nonce value (as hex) from an OCSP extensions wrapper, if present. */
834
- function parseOcspNonceFromExtensions(e, t) {
835
- let n = x(e, t), r = k(n[0], "extensions");
836
- if (n.length !== 1 || r.tag !== 48) throw Error("Malformed OCSP extensions");
837
- let i = /* @__PURE__ */ new Set(), a;
838
- for (let t of x(e, r)) {
839
- let n = x(e, t);
840
- if (n.length < 2 || n.length > 3 || n.length === 3 && n[1]?.tag !== 1) throw Error("Malformed OCSP extension");
841
- let r = w(k(n[0], "extension OID").value);
842
- if (i.has(r)) throw Error(`Duplicate OCSP extension OID: ${r}`);
843
- i.add(r);
844
- let o = k(n[n.length - 1], "extnValue");
845
- if (o.tag !== 4) throw Error("OCSP extension value must use OCTET STRING");
846
- if (r !== M.ocspNonce) continue;
847
- let s = _(o.value, { maxDepth: 64 });
848
- if (s.tag !== 4) throw Error("OCSP nonce extension value must use OCTET STRING");
849
- a = j(s.value);
850
- }
851
- return a;
1020
+ function parseOcspNonceFromExtensions(t, n) {
1021
+ let i = e(t, n), a = c(i[0], "extensions");
1022
+ if (i.length !== 1 || a.tag !== 48) throw Error("Malformed OCSP extensions");
1023
+ let o = /* @__PURE__ */ new Set(), s;
1024
+ for (let n of e(t, a)) {
1025
+ let i = e(t, n);
1026
+ if (i.length < 2 || i.length > 3 || i.length === 3 && i[1]?.tag !== 1) throw Error("Malformed OCSP extension");
1027
+ let a = r(c(i[0], "extension OID").value);
1028
+ if (o.has(a)) throw Error(`Duplicate OCSP extension OID: ${a}`);
1029
+ o.add(a);
1030
+ let l = c(i[i.length - 1], "extnValue");
1031
+ if (l.tag !== 4) throw Error("OCSP extension value must use OCTET STRING");
1032
+ if (a !== O.ocspNonce) continue;
1033
+ let u = w(l.value, { maxDepth: 64 });
1034
+ if (u.tag !== 4) throw Error("OCSP nonce extension value must use OCTET STRING");
1035
+ s = d(u.value);
1036
+ }
1037
+ return s;
852
1038
  }
853
1039
  /** Decodes the optional `certs [0]` field from a BasicOCSPResponse. */
854
- function parseEmbeddedCertificates(e, t) {
855
- let n = [], r = x(e, t)[0];
856
- if (r === void 0 || r.tag !== 48) throw Error("Malformed BasicOCSPResponse certs");
857
- let i = r.start;
858
- for (; i < r.end;) {
859
- let t = g(e, i);
860
- n.push(G(e.slice(i, t.end))), i = t.end;
1040
+ function parseEmbeddedCertificates(t, n) {
1041
+ let r = [], i = e(t, n)[0];
1042
+ if (i === void 0 || i.tag !== 48) throw Error("Malformed BasicOCSPResponse certs");
1043
+ let a = i.start;
1044
+ for (; a < i.end;) {
1045
+ let e = C(t, a);
1046
+ r.push($(t.slice(a, e.end))), a = e.end;
861
1047
  }
862
- return n;
1048
+ return r;
863
1049
  }
864
1050
  /** Extracts the raw public key bytes (without BIT STRING padding byte) from SPKI DER. */
865
- function extractSubjectPublicKeyBytes(e) {
866
- let t = x(e, g(e)), n = k(t[1], "subjectPublicKey BIT STRING");
867
- if (n.tag !== 3) throw Error("SPKI missing subjectPublicKey BIT STRING");
868
- return n.value.slice(1);
1051
+ function extractSubjectPublicKeyBytes(t) {
1052
+ let n = e(t, C(t)), r = c(n[1], "subjectPublicKey BIT STRING");
1053
+ if (r.tag !== 3) throw Error("SPKI missing subjectPublicKey BIT STRING");
1054
+ return r.value.slice(1);
869
1055
  }
870
1056
  /** Maps an integer response-status code to its {@linkcode OcspResponseStatus} string. */
871
1057
  function ocspResponseStatusFromCode(e) {
@@ -902,29 +1088,29 @@ function hasDuplicateOcspResponseCertificateSerial(e) {
902
1088
  }
903
1089
  return !1;
904
1090
  }
905
- function validateOcspRequestorName(e, t) {
906
- let n = x(e, t), r = k(n[0], "requestorName");
907
- if (n.length !== 1 || (r.tag & 192) != 128) throw Error("requestorName must wrap exactly one GeneralName");
908
- }
909
- function validateOcspOptionalSignature(e, t) {
910
- let n = x(e, t), r = k(n[0], "optionalSignature");
911
- if (n.length !== 1 || r.tag !== 48) throw Error("optionalSignature must wrap exactly one Signature");
912
- let i = x(e, r);
913
- if (i.length < 2 || i.length > 3 || i[0]?.tag !== 48 || i[2] !== void 0 && i[2]?.tag !== 160) throw Error("Malformed optionalSignature");
914
- let a = k(i[0], "signatureAlgorithm"), o = k(i[1], "signature"), s = i[2];
915
- if (validateAlgorithmIdentifierShape(e, a, "optionalSignature algorithm"), E(o), s !== void 0) {
916
- let t = x(e, s);
917
- if (t.length !== 1 || t[0]?.tag !== 48) throw Error("optionalSignature certs must use SEQUENCE OF Certificate");
1091
+ function validateOcspRequestorName(t, n) {
1092
+ let r = e(t, n), i = c(r[0], "requestorName");
1093
+ if (r.length !== 1 || (i.tag & 192) != 128) throw Error("requestorName must wrap exactly one GeneralName");
1094
+ }
1095
+ function validateOcspOptionalSignature(t, n) {
1096
+ let r = e(t, n), i = c(r[0], "optionalSignature");
1097
+ if (r.length !== 1 || i.tag !== 48) throw Error("optionalSignature must wrap exactly one Signature");
1098
+ let o = e(t, i);
1099
+ if (o.length < 2 || o.length > 3 || o[0]?.tag !== 48 || o[2] !== void 0 && o[2]?.tag !== 160) throw Error("Malformed optionalSignature");
1100
+ let s = c(o[0], "signatureAlgorithm"), l = c(o[1], "signature"), u = o[2];
1101
+ if (validateAlgorithmIdentifierShape(t, s, "optionalSignature algorithm"), a(l), u !== void 0) {
1102
+ let n = e(t, u);
1103
+ if (n.length !== 1 || n[0]?.tag !== 48) throw Error("optionalSignature certs must use SEQUENCE OF Certificate");
918
1104
  }
919
1105
  }
920
- function validateOcspSingleResponseNextUpdate(e, t) {
921
- let n = x(e, t), r = k(n[0], "nextUpdate");
922
- if (n.length !== 1 || r.tag !== 23 && r.tag !== 24) throw Error("nextUpdate must wrap exactly one time value");
1106
+ function validateOcspSingleResponseNextUpdate(t, n) {
1107
+ let r = e(t, n), i = c(r[0], "nextUpdate");
1108
+ if (r.length !== 1 || i.tag !== 23 && i.tag !== 24) throw Error("nextUpdate must wrap exactly one time value");
923
1109
  }
924
- function validateAlgorithmIdentifierShape(e, t, n) {
925
- let r = x(e, t);
926
- if (t.tag !== 48 || r.length < 1 || r.length > 2 || r[0]?.tag !== 6) throw Error(`${n} must use AlgorithmIdentifier SEQUENCE`);
927
- w(k(r[0], `${n} OID`).value);
1110
+ function validateAlgorithmIdentifierShape(t, n, i) {
1111
+ let a = e(t, n);
1112
+ if (n.tag !== 48 || a.length < 1 || a.length > 2 || a[0]?.tag !== 6) throw Error(`${i} must use AlgorithmIdentifier SEQUENCE`);
1113
+ r(c(a[0], `${i} OID`).value);
928
1114
  }
929
1115
  function normalizeHex(e) {
930
1116
  return e.toLowerCase();
@@ -932,8 +1118,8 @@ function normalizeHex(e) {
932
1118
  /** Maps a hash algorithm OID to the WebCrypto algorithm name. Throws on unsupported OIDs. */
933
1119
  function ocspHashAlgorithmFromOid(e) {
934
1120
  switch (e) {
935
- case M.sha1: return "SHA-1";
936
- case M.sha256: return "SHA-256";
1121
+ case O.sha1: return "SHA-1";
1122
+ case O.sha256: return "SHA-256";
937
1123
  default: throw Error(`Unsupported OCSP hash algorithm OID: ${e}`);
938
1124
  }
939
1125
  }
@@ -946,6 +1132,6 @@ function serializeCertId(e) {
946
1132
  e.serialNumberHex
947
1133
  ].join(":");
948
1134
  }
949
- export { carriesOcspNoCheck, createOcspRequest, createOcspResponse, hasOcspNoCheckExtension, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, validateOcspResponse, verifyOcspResponseSignature };
1135
+ export { carriesOcspNoCheck, createOcspRequest, createOcspResponse, hasOcspNoCheckExtension, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, revocationSkipReasonOf, validateOcspResponse, validateOcspResponseBy, validateOcspResponseWith, verifyOcspResponseSignature };
950
1136
 
951
1137
  //# sourceMappingURL=ocsp.js.map