micro509 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +78 -6
- package/dist/crypto/crypto.d.ts +2 -3
- package/dist/crypto.d.ts +6 -0
- package/dist/der/der.d.ts +14 -4
- package/dist/der/der.js +19 -19
- package/dist/der.d.ts +26 -2
- package/dist/der.js +4 -4
- package/dist/index.d.ts +82 -15
- package/dist/index.js +19 -19
- package/dist/internal/asn1/asn1.d.ts +1 -2
- package/dist/internal/asn1/der.d.ts +1 -2
- package/dist/internal/asn1/oids.js +71 -353
- package/dist/internal/asn1/oids.js.map +1 -1
- package/dist/internal/asn1/oids.json.js +357 -0
- package/dist/internal/asn1/oids.json.js.map +1 -0
- package/dist/internal/crypto/algorithm-names.js +1 -1
- package/dist/internal/crypto/pbes2.d.ts +1 -2
- package/dist/internal/crypto/pbes2.js +70 -70
- package/dist/internal/crypto/prime-ec.js +37 -0
- package/dist/internal/crypto/prime-ec.js.map +1 -0
- package/dist/internal/crypto/rsa-pss.js +50 -50
- package/dist/internal/crypto/sig-verify.d.ts +1 -2
- package/dist/internal/crypto/sig-verify.js +60 -60
- package/dist/internal/crypto/signing.d.ts +1 -2
- package/dist/internal/crypto/signing.js +26 -26
- package/dist/internal/jose/json-data.js +108 -0
- package/dist/internal/jose/json-data.js.map +1 -0
- package/dist/internal/jose/strict-json.d.ts +1 -2
- package/dist/internal/shared/dn.d.ts +1 -2
- package/dist/internal/shared/dn.js +1 -1
- package/dist/internal/shared/ip.d.ts +1 -2
- package/dist/internal/verify/name-constraints-engine.js +64 -64
- package/dist/internal/verify/policy-engine.js +1 -1
- package/dist/internal/verify/verify-path.d.ts +1 -2
- package/dist/internal/verify/verify-path.js +19 -19
- package/dist/internal/x509/directory-name.js +10 -10
- package/dist/internal/x509/extension-errors.d.ts +1 -2
- package/dist/internal/x509/extension-registry.js +18 -18
- package/dist/internal/x509/general-name-profile.js +9 -9
- package/dist/internal/x509/general-name.js +32 -32
- package/dist/internal/x509/name-fields.js +1 -1
- package/dist/jose/base64url.d.ts +4 -0
- package/dist/jose/base64url.js +14 -0
- package/dist/jose/base64url.js.map +1 -0
- package/dist/jose/errors.d.ts +9 -3
- package/dist/jose/errors.js.map +1 -1
- package/dist/jose/jwe.d.ts +64 -0
- package/dist/jose/jwe.js +188 -0
- package/dist/jose/jwe.js.map +1 -0
- package/dist/jose/jwks.d.ts +38 -10
- package/dist/jose/jwks.js +156 -96
- package/dist/jose/jwks.js.map +1 -1
- package/dist/jose/jws.d.ts +8 -6
- package/dist/jose/jws.js +216 -170
- package/dist/jose/jws.js.map +1 -1
- package/dist/jose/jwt.d.ts +8 -2
- package/dist/jose/jwt.js +98 -98
- package/dist/jose/remote-jwks.d.ts +1 -2
- package/dist/jose/remote-jwks.js +106 -108
- package/dist/jose/remote-jwks.js.map +1 -1
- package/dist/jose.d.ts +15 -4
- package/dist/jose.js +7 -5
- package/dist/kdf/argon2.d.ts +7 -2
- package/dist/kdf.d.ts +6 -0
- package/dist/keys/keys.d.ts +31 -6
- package/dist/keys/keys.js +315 -233
- package/dist/keys/keys.js.map +1 -1
- package/dist/keys.d.ts +11 -2
- package/dist/keys.js +2 -2
- package/dist/pem/pem.d.ts +1 -2
- package/dist/pem/pem.js +40 -25
- package/dist/pem/pem.js.map +1 -1
- package/dist/pem.d.ts +6 -0
- package/dist/pkcs/pfx.d.ts +2 -3
- package/dist/pkcs/pfx.js +142 -142
- package/dist/pkcs/pkcs12-mac.d.ts +1 -2
- package/dist/pkcs/pkcs12-mac.js +122 -122
- package/dist/pkcs/pkcs7.d.ts +14 -3
- package/dist/pkcs/pkcs7.js +268 -248
- package/dist/pkcs/pkcs7.js.map +1 -1
- package/dist/pkcs.d.ts +10 -1
- package/dist/pkcs.js +4 -4
- package/dist/result/result.d.ts +1 -2
- package/dist/result.d.ts +6 -0
- package/dist/revocation/chain.d.ts +2 -3
- package/dist/revocation/chain.js +52 -52
- package/dist/revocation/crl.d.ts +2 -3
- package/dist/revocation/crl.js +319 -319
- package/dist/revocation/crl.js.map +1 -1
- package/dist/revocation/ocsp.d.ts +2 -3
- package/dist/revocation/ocsp.js +395 -395
- package/dist/revocation/revocation.d.ts +2 -3
- package/dist/revocation/revocation.js +22 -22
- package/dist/revocation.d.ts +12 -3
- package/dist/revocation.js +4 -4
- package/dist/ssh/ssh.d.ts +2 -3
- package/dist/ssh/ssh.js +165 -170
- package/dist/ssh/ssh.js.map +1 -1
- package/dist/ssh/wire.d.ts +1 -2
- package/dist/ssh/wire.js +10 -10
- package/dist/ssh.d.ts +8 -0
- package/dist/verify/identity.d.ts +1 -2
- package/dist/verify/identity.js +31 -31
- package/dist/verify/name-constraints.d.ts +9 -2
- package/dist/verify/policy.d.ts +9 -2
- package/dist/verify/verify.d.ts +3 -4
- package/dist/verify/verify.js +121 -121
- package/dist/verify.d.ts +9 -0
- package/dist/x509/certificate.d.ts +4 -5
- package/dist/x509/certificate.js +40 -40
- package/dist/x509/csr.d.ts +3 -4
- package/dist/x509/csr.js +15 -15
- package/dist/x509/extensions.d.ts +1 -2
- package/dist/x509/extensions.js +165 -165
- package/dist/x509/extensions.js.map +1 -1
- package/dist/x509/fingerprint.d.ts +1 -2
- package/dist/x509/name-text.d.ts +1 -2
- package/dist/x509/name.d.ts +1 -2
- package/dist/x509/name.js +15 -15
- package/dist/x509/parse.d.ts +3 -4
- package/dist/x509/parse.js +423 -423
- package/dist/x509.d.ts +17 -4
- package/dist/x509.js +8 -8
- package/package.json +22 -23
- package/dist/internal/asn1/oids2.js +0 -75
- package/dist/internal/asn1/oids2.js.map +0 -1
package/dist/revocation/ocsp.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { decodeFailureResult as
|
|
3
|
-
import { bitString as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
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, toArrayBuffer as l, toHex as u } from "../internal/asn1/asn1.js";
|
|
2
|
+
import { decodeFailureResult as d, decodeRefusalOf as f } from "../internal/asn1/decode-refusal.js";
|
|
3
|
+
import { bitString as p, concatBytes as m, enumeratedFromNumber as h, explicitContext as g, generalizedTime as _, integer as v, nullValue as y, objectIdentifier as b, octetString as x, readElement as S, readRootElement as C, readSequenceChildren as w, sequence as T, tlv as E } from "../internal/asn1/der.js";
|
|
4
|
+
import { OIDS as D } from "../internal/asn1/oids.js";
|
|
5
|
+
import { describeHashAlgorithm as O, describeSignatureAlgorithm as k } from "../internal/crypto/algorithm-names.js";
|
|
6
|
+
import { getVerifySignatureConfigResult as A, verifySignedDataDetailed as j } from "../internal/crypto/sig-verify.js";
|
|
7
|
+
import { encodeAlgorithmIdentifier as M, getSignatureAlgorithm as N, signBytes as P } from "../internal/crypto/signing.js";
|
|
8
|
+
import { getCrypto as F } from "../internal/crypto/webcrypto.js";
|
|
9
|
+
import { base64Encode as I } from "../internal/shared/base64.js";
|
|
10
|
+
import { compareDistinguishedNames as L } from "../internal/shared/dn.js";
|
|
11
|
+
import { pemDecodeOrThrow as R, pemEncode as z } from "../pem/pem.js";
|
|
12
|
+
import { DECODE_REFUSAL_CODES as B, failureResult as V, rethrowIfInvariant as H, successResult as U, throwMicro509Error as W } from "../result/result.js";
|
|
13
|
+
import { assertCrlMaxAge as G, checkCertificateRevocationAgainstCrl as K, coversAllDistributionPointReasons as q, parseCertificateRevocationListDerOrThrow as J, parseCertificateRevocationListPemOrThrow as Y } from "./crl.js";
|
|
14
|
+
import { verifyCertificateChain as X } from "../verify/verify.js";
|
|
15
|
+
import { parseCertificateDerOrThrow as Z, parseCertificateFromSource as Q } from "../x509/parse.js";
|
|
16
16
|
// src/revocation/ocsp.ts
|
|
17
17
|
/**
|
|
18
18
|
* Full OCSP lifecycle: build requests, create/parse/verify/validate responses.
|
|
@@ -25,7 +25,7 @@ import { verifyCertificateChain as Q } from "../verify/verify.js";
|
|
|
25
25
|
*/
|
|
26
26
|
/** Throws a {@link ResultError} for an OCSP encoder input-validation failure. */
|
|
27
27
|
function throwOcspEncoderError(e, t) {
|
|
28
|
-
|
|
28
|
+
W(e, t);
|
|
29
29
|
}
|
|
30
30
|
function assertOcspDate(e, t) {
|
|
31
31
|
e !== void 0 && Number.isNaN(e.getTime()) && throwOcspEncoderError("invalid_date", `${t} must be a valid date`);
|
|
@@ -53,51 +53,51 @@ async function createOcspRequest(e) {
|
|
|
53
53
|
let t = e.hashAlgorithm ?? "SHA-256", n = [];
|
|
54
54
|
for (let r of e.requests) {
|
|
55
55
|
let e = normalizeCertificate(r.certificate), i = normalizeCertificate(r.issuerCertificate);
|
|
56
|
-
n.push(
|
|
56
|
+
n.push(T([await encodeOcspCertId(e, i, t)]));
|
|
57
57
|
}
|
|
58
|
-
let r = [
|
|
59
|
-
e.nonce !== void 0 && r.push(
|
|
60
|
-
let i =
|
|
58
|
+
let r = [T(n)];
|
|
59
|
+
e.nonce !== void 0 && r.push(g(2, T([T([b(D.ocspNonce), x(x(e.nonce))])])));
|
|
60
|
+
let i = T([T(r)]);
|
|
61
61
|
return {
|
|
62
62
|
der: i,
|
|
63
|
-
pem:
|
|
64
|
-
base64:
|
|
63
|
+
pem: z("OCSP REQUEST", i),
|
|
64
|
+
base64: I(i)
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
/** Throwing core for {@linkcode parseOcspRequestDer}. */
|
|
68
|
-
function parseOcspRequestDerOrThrow(
|
|
69
|
-
let
|
|
70
|
-
if (
|
|
71
|
-
let
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
let
|
|
77
|
-
if (
|
|
78
|
-
if (
|
|
79
|
-
let
|
|
80
|
-
let
|
|
81
|
-
if (
|
|
82
|
-
let
|
|
83
|
-
return parseOcspCertId(
|
|
68
|
+
function parseOcspRequestDerOrThrow(t) {
|
|
69
|
+
let n = w(t, { maxDepth: 64 });
|
|
70
|
+
if (n.length < 1 || n.length > 2) throw Error("Malformed OCSP request");
|
|
71
|
+
let r = c(n[0], "tbsRequest"), i = n[1];
|
|
72
|
+
if (i !== void 0 && i.tag !== 160) throw Error("Malformed OCSP request");
|
|
73
|
+
i !== void 0 && validateOcspOptionalSignature(t, i);
|
|
74
|
+
let a = e(t, r), o = skipOcspRequestVersion(t, a, 0);
|
|
75
|
+
o = skipOcspRequestorName(t, a, o);
|
|
76
|
+
let s = c(a[o], "requestList");
|
|
77
|
+
if (s.tag !== 48) throw Error("requestList must use SEQUENCE");
|
|
78
|
+
if (e(t, s).length === 0) throw Error("requestList must not be empty");
|
|
79
|
+
let l = e(t, s).map((n) => {
|
|
80
|
+
let r = e(t, n);
|
|
81
|
+
if (r.length < 1 || r.length > 2 || r[1] !== void 0 && r[1].tag !== 160) throw Error("Malformed OCSP request entry");
|
|
82
|
+
let i = c(r[0], "reqCert");
|
|
83
|
+
return parseOcspCertId(t.slice(i.start - i.headerLength, i.end));
|
|
84
84
|
});
|
|
85
|
-
|
|
86
|
-
let
|
|
87
|
-
if (
|
|
88
|
-
let
|
|
85
|
+
o += 1;
|
|
86
|
+
let u = a[o];
|
|
87
|
+
if (u !== void 0 && u.tag !== 162 || a.length !== o + (u === void 0 ? 0 : 1)) throw Error("Malformed OCSP request");
|
|
88
|
+
let d = u === void 0 ? void 0 : parseOcspNonceFromExtensions(t, u);
|
|
89
89
|
return {
|
|
90
|
-
der: new Uint8Array(
|
|
91
|
-
requests:
|
|
92
|
-
...
|
|
90
|
+
der: new Uint8Array(t),
|
|
91
|
+
requests: l,
|
|
92
|
+
...d === void 0 ? {} : { nonce: d }
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
function skipOcspRequestVersion(
|
|
96
|
-
if (
|
|
97
|
-
let
|
|
98
|
-
if (
|
|
99
|
-
if (
|
|
100
|
-
return
|
|
95
|
+
function skipOcspRequestVersion(t, r, i) {
|
|
96
|
+
if (r[i]?.tag !== 160) return i;
|
|
97
|
+
let a = c(r[i], "version"), o = e(t, a), s = c(o[0], "version");
|
|
98
|
+
if (o.length !== 1 || s.tag !== 2) throw Error("version must use INTEGER");
|
|
99
|
+
if (n(s.value, "OCSP request version") !== 0) throw Error("Unsupported OCSP request version");
|
|
100
|
+
return i + 1;
|
|
101
101
|
}
|
|
102
102
|
function skipOcspRequestorName(e, t, n) {
|
|
103
103
|
let r = t[n];
|
|
@@ -105,7 +105,7 @@ function skipOcspRequestorName(e, t, n) {
|
|
|
105
105
|
}
|
|
106
106
|
/** Decodes a PEM-encoded OCSP request (`-----BEGIN OCSP REQUEST-----`). */
|
|
107
107
|
function parseOcspRequestPemOrThrow(e) {
|
|
108
|
-
return parseOcspRequestDerOrThrow(
|
|
108
|
+
return parseOcspRequestDerOrThrow(R("OCSP REQUEST", e));
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* Decodes a DER-encoded OCSP request into a structured {@linkcode ParsedOcspRequest}.
|
|
@@ -113,11 +113,11 @@ function parseOcspRequestPemOrThrow(e) {
|
|
|
113
113
|
* Returns a typed failure (`code: 'malformed'`) on malformed input. For the
|
|
114
114
|
* throwing form use {@linkcode parseOcspRequestDerOrThrow}.
|
|
115
115
|
*/
|
|
116
|
-
function parseOcspRequestDer(
|
|
116
|
+
function parseOcspRequestDer(e) {
|
|
117
117
|
try {
|
|
118
|
-
return
|
|
119
|
-
} catch (
|
|
120
|
-
return
|
|
118
|
+
return U(parseOcspRequestDerOrThrow(e));
|
|
119
|
+
} catch (e) {
|
|
120
|
+
return H(e), d(e, B, "Malformed OCSP request");
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
@@ -126,56 +126,56 @@ function parseOcspRequestDer(t) {
|
|
|
126
126
|
* Returns a typed failure (`code: 'malformed'`) on malformed input. For the
|
|
127
127
|
* throwing form use {@linkcode parseOcspRequestPemOrThrow}.
|
|
128
128
|
*/
|
|
129
|
-
function parseOcspRequestPem(
|
|
129
|
+
function parseOcspRequestPem(e) {
|
|
130
130
|
try {
|
|
131
|
-
return
|
|
132
|
-
} catch (
|
|
133
|
-
return
|
|
131
|
+
return U(parseOcspRequestPemOrThrow(e));
|
|
132
|
+
} catch (e) {
|
|
133
|
+
return H(e), d(e, B, "Malformed OCSP request");
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
/** Throwing core for {@linkcode parseOcspResponseDer}. */
|
|
137
|
-
function parseOcspResponseDerOrThrow(
|
|
138
|
-
let
|
|
139
|
-
if (
|
|
140
|
-
let
|
|
141
|
-
if (
|
|
142
|
-
let
|
|
143
|
-
if (
|
|
144
|
-
der: new Uint8Array(
|
|
145
|
-
responseStatus:
|
|
137
|
+
function parseOcspResponseDerOrThrow(t) {
|
|
138
|
+
let i = w(t, { maxDepth: 64 });
|
|
139
|
+
if (i.length < 1 || i.length > 2) throw Error("Malformed OCSP response");
|
|
140
|
+
let o = c(i[0], "responseStatus");
|
|
141
|
+
if (o.tag !== 10) throw Error("responseStatus must use ENUMERATED");
|
|
142
|
+
let s = ocspResponseStatusFromCode(n(o.value, "OCSP responseStatus")), l = i[1];
|
|
143
|
+
if (l === void 0) return {
|
|
144
|
+
der: new Uint8Array(t),
|
|
145
|
+
responseStatus: s
|
|
146
146
|
};
|
|
147
|
-
if (
|
|
148
|
-
let
|
|
149
|
-
if (
|
|
150
|
-
let
|
|
151
|
-
if (
|
|
152
|
-
let
|
|
153
|
-
if (
|
|
154
|
-
let
|
|
155
|
-
if (
|
|
156
|
-
der: new Uint8Array(
|
|
157
|
-
responseStatus:
|
|
158
|
-
responseTypeOid:
|
|
147
|
+
if (l.tag !== 160) throw Error("Malformed OCSP response");
|
|
148
|
+
let u = e(t, l), d = c(u[0], "responseBytes");
|
|
149
|
+
if (u.length !== 1 || d.tag !== 48) throw Error("Malformed OCSP response");
|
|
150
|
+
let f = e(t, d);
|
|
151
|
+
if (f.length !== 2) throw Error("responseBytes must contain responseType and response");
|
|
152
|
+
let p = c(f[0], "responseType"), m = c(f[1], "response");
|
|
153
|
+
if (m.tag !== 4) throw Error("response must use OCTET STRING");
|
|
154
|
+
let h = r(p.value);
|
|
155
|
+
if (h !== D.ocspBasicResponse) return {
|
|
156
|
+
der: new Uint8Array(t),
|
|
157
|
+
responseStatus: s,
|
|
158
|
+
responseTypeOid: h
|
|
159
159
|
};
|
|
160
|
-
let
|
|
161
|
-
if (
|
|
162
|
-
let
|
|
163
|
-
if (
|
|
164
|
-
let
|
|
160
|
+
let g = m.value, _ = w(g);
|
|
161
|
+
if (_.length < 3 || _.length > 4) throw Error("Malformed BasicOCSPResponse");
|
|
162
|
+
let v = c(_[0], "responseData"), y = c(_[1], "signatureAlgorithm"), b = c(_[2], "signatureValue"), x = _[3];
|
|
163
|
+
if (x !== void 0 && x.tag !== 160) throw Error("Malformed BasicOCSPResponse");
|
|
164
|
+
let S = e(g, y), C = r(c(S[0], "signatureAlgorithm OID").value), T = S[1], E = T === void 0 ? void 0 : g.slice(T.start - T.headerLength, T.end), O = g.slice(v.start - v.headerLength, v.end), A = parseSignedOcspResponseData(O);
|
|
165
165
|
return {
|
|
166
|
-
der: new Uint8Array(
|
|
167
|
-
responseStatus:
|
|
168
|
-
responseTypeOid:
|
|
169
|
-
responseDataDer:
|
|
170
|
-
responderId:
|
|
171
|
-
signatureAlgorithmOid:
|
|
172
|
-
...
|
|
173
|
-
signatureAlgorithmName:
|
|
174
|
-
signatureValue:
|
|
175
|
-
producedAt:
|
|
176
|
-
responses:
|
|
177
|
-
...
|
|
178
|
-
...
|
|
166
|
+
der: new Uint8Array(t),
|
|
167
|
+
responseStatus: s,
|
|
168
|
+
responseTypeOid: h,
|
|
169
|
+
responseDataDer: O,
|
|
170
|
+
responderId: A.responderId,
|
|
171
|
+
signatureAlgorithmOid: C,
|
|
172
|
+
...E === void 0 ? {} : { signatureAlgorithmParametersDer: E },
|
|
173
|
+
signatureAlgorithmName: k(C, E),
|
|
174
|
+
signatureValue: a(b),
|
|
175
|
+
producedAt: A.producedAt,
|
|
176
|
+
responses: A.responses,
|
|
177
|
+
...A.nonce === void 0 ? {} : { nonce: A.nonce },
|
|
178
|
+
...x?.tag === 160 ? { certificates: parseEmbeddedCertificates(g, x) } : {}
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
@@ -194,7 +194,7 @@ function parseOcspResponseDerOrThrow(e) {
|
|
|
194
194
|
* ```
|
|
195
195
|
*/
|
|
196
196
|
function parseOcspResponsePemOrThrow(e) {
|
|
197
|
-
return parseOcspResponseDerOrThrow(
|
|
197
|
+
return parseOcspResponseDerOrThrow(R("OCSP RESPONSE", e));
|
|
198
198
|
}
|
|
199
199
|
/**
|
|
200
200
|
* Decodes a DER-encoded OCSP response into a structured {@linkcode ParsedOcspResponse}.
|
|
@@ -202,11 +202,11 @@ function parseOcspResponsePemOrThrow(e) {
|
|
|
202
202
|
* Returns a typed failure (`code: 'malformed'`) on malformed input. For the
|
|
203
203
|
* throwing form use {@linkcode parseOcspResponseDerOrThrow}.
|
|
204
204
|
*/
|
|
205
|
-
function parseOcspResponseDer(
|
|
205
|
+
function parseOcspResponseDer(e) {
|
|
206
206
|
try {
|
|
207
|
-
return
|
|
208
|
-
} catch (
|
|
209
|
-
return
|
|
207
|
+
return U(parseOcspResponseDerOrThrow(e));
|
|
208
|
+
} catch (e) {
|
|
209
|
+
return H(e), d(e, B, "Malformed OCSP response");
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
@@ -215,11 +215,11 @@ function parseOcspResponseDer(t) {
|
|
|
215
215
|
* Returns a typed failure (`code: 'malformed'`) on malformed input. For the
|
|
216
216
|
* throwing form use {@linkcode parseOcspResponsePemOrThrow}.
|
|
217
217
|
*/
|
|
218
|
-
function parseOcspResponsePem(
|
|
218
|
+
function parseOcspResponsePem(e) {
|
|
219
219
|
try {
|
|
220
|
-
return
|
|
221
|
-
} catch (
|
|
222
|
-
return
|
|
220
|
+
return U(parseOcspResponsePemOrThrow(e));
|
|
221
|
+
} catch (e) {
|
|
222
|
+
return H(e), d(e, B, "Malformed OCSP response");
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
/**
|
|
@@ -250,8 +250,8 @@ function parseOcspResponsePem(t) {
|
|
|
250
250
|
* ```
|
|
251
251
|
*/
|
|
252
252
|
async function createOcspResponse(e) {
|
|
253
|
-
let t = normalizeCertificate(e.signerCertificate), n =
|
|
254
|
-
|
|
253
|
+
let t = normalizeCertificate(e.signerCertificate), n = N(e.signerPrivateKey);
|
|
254
|
+
A(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
255
|
let r = e.producedAt ?? /* @__PURE__ */ new Date();
|
|
256
256
|
assertOcspDate(r, "producedAt");
|
|
257
257
|
let i = e.hashAlgorithm ?? "SHA-256", a = [];
|
|
@@ -260,23 +260,23 @@ async function createOcspResponse(e) {
|
|
|
260
260
|
let e = normalizeCertificate(t.certificate), n = normalizeCertificate(t.issuerCertificate);
|
|
261
261
|
a.push(await encodeSingleResponse(e, n, t, i));
|
|
262
262
|
}
|
|
263
|
-
let o = await digestBytes("SHA-1", extractSubjectPublicKeyBytes(t.subjectPublicKeyInfoDer)),
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
263
|
+
let o = await digestBytes("SHA-1", extractSubjectPublicKeyBytes(t.subjectPublicKeyInfoDer)), s = [
|
|
264
|
+
g(2, x(o)),
|
|
265
|
+
_(r),
|
|
266
|
+
T(a)
|
|
267
267
|
];
|
|
268
|
-
e.nonce !== void 0 &&
|
|
269
|
-
let
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
268
|
+
e.nonce !== void 0 && s.push(g(1, T([T([b(D.ocspNonce), x(x(e.nonce))])])));
|
|
269
|
+
let c = T(s), l = await P(e.signerPrivateKey, n, c), u = e.includedCertificates === void 0 ? [] : await Promise.all(e.includedCertificates.map(normalizeCertificate)), d = [
|
|
270
|
+
c,
|
|
271
|
+
M(n),
|
|
272
|
+
p(l)
|
|
273
273
|
];
|
|
274
|
-
|
|
275
|
-
let
|
|
274
|
+
u.length > 0 && d.push(g(0, T(u.map((e) => e.der))));
|
|
275
|
+
let f = T(d), m = T([E(10, Uint8Array.of(0)), g(0, T([b(D.ocspBasicResponse), x(f)]))]);
|
|
276
276
|
return {
|
|
277
|
-
der:
|
|
278
|
-
pem:
|
|
279
|
-
base64:
|
|
277
|
+
der: m,
|
|
278
|
+
pem: z("OCSP RESPONSE", m),
|
|
279
|
+
base64: I(m)
|
|
280
280
|
};
|
|
281
281
|
}
|
|
282
282
|
/**
|
|
@@ -285,33 +285,33 @@ async function createOcspResponse(e) {
|
|
|
285
285
|
* Does **not** check responder binding, freshness, or nonce — use
|
|
286
286
|
* {@linkcode validateOcspResponse} for full validation.
|
|
287
287
|
*/
|
|
288
|
-
async function verifyOcspResponseSignature(
|
|
289
|
-
let
|
|
288
|
+
async function verifyOcspResponseSignature(e, t) {
|
|
289
|
+
let n;
|
|
290
290
|
try {
|
|
291
|
-
|
|
292
|
-
} catch (
|
|
293
|
-
let
|
|
294
|
-
return
|
|
291
|
+
n = normalizeOcspResponse(e);
|
|
292
|
+
} catch (e) {
|
|
293
|
+
let t = f(e, B);
|
|
294
|
+
return t === void 0 ? verifyOcspResponseFailureResult("signature_invalid", "OCSP response signed content is malformed") : verifyOcspResponseFailureResult(t.code, t.message);
|
|
295
295
|
}
|
|
296
|
-
if (
|
|
297
|
-
let
|
|
296
|
+
if (n.responseDataDer === void 0 || n.signatureAlgorithmOid === void 0 || n.signatureValue === void 0) return verifyOcspResponseFailureResult("signature_invalid", "OCSP response is not signed");
|
|
297
|
+
let r;
|
|
298
298
|
try {
|
|
299
|
-
|
|
300
|
-
} catch (
|
|
301
|
-
let
|
|
302
|
-
return
|
|
299
|
+
r = normalizeCertificate(t);
|
|
300
|
+
} catch (e) {
|
|
301
|
+
let t = f(e, B);
|
|
302
|
+
return t === void 0 ? verifyOcspResponseFailureResult("signature_invalid", "OCSP signer certificate input is malformed") : verifyOcspResponseFailureResult(t.code, t.message);
|
|
303
303
|
}
|
|
304
|
-
let
|
|
304
|
+
let i;
|
|
305
305
|
try {
|
|
306
|
-
|
|
307
|
-
} catch (
|
|
308
|
-
let
|
|
309
|
-
return
|
|
306
|
+
i = await j(n.signatureAlgorithmOid, n.signatureAlgorithmParametersDer, r.publicKeyAlgorithmOid, r.publicKeyParametersOid, r.subjectPublicKeyInfoDer, n.signatureValue, n.responseDataDer);
|
|
307
|
+
} catch (e) {
|
|
308
|
+
let t = f(e, B);
|
|
309
|
+
return t === void 0 ? verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature verification failed") : verifyOcspResponseFailureResult(t.code, t.message);
|
|
310
310
|
}
|
|
311
|
-
return
|
|
311
|
+
return i.ok ? i.valid ? {
|
|
312
312
|
ok: !0,
|
|
313
|
-
value:
|
|
314
|
-
} : verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature does not verify") :
|
|
313
|
+
value: n
|
|
314
|
+
} : verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature does not verify") : i.code === "verification_error" ? verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature verification failed") : verifyOcspResponseFailureResult("signature_invalid", "OCSP response signature uses unsupported algorithm parameters");
|
|
315
315
|
}
|
|
316
316
|
/**
|
|
317
317
|
* Full OCSP response validation: response status check, signature verification,
|
|
@@ -334,59 +334,59 @@ async function verifyOcspResponseSignature(t, n) {
|
|
|
334
334
|
* }
|
|
335
335
|
* ```
|
|
336
336
|
*/
|
|
337
|
-
async function validateOcspResponse(
|
|
338
|
-
|
|
339
|
-
let
|
|
337
|
+
async function validateOcspResponse(e) {
|
|
338
|
+
G(e.responderRevocationCrlMaxAgeMs);
|
|
339
|
+
let t;
|
|
340
340
|
try {
|
|
341
|
-
|
|
342
|
-
} catch (
|
|
343
|
-
let
|
|
344
|
-
return
|
|
345
|
-
}
|
|
346
|
-
if (
|
|
347
|
-
let
|
|
348
|
-
if (!
|
|
349
|
-
let { issuer:
|
|
350
|
-
if (!
|
|
351
|
-
let
|
|
352
|
-
if (
|
|
353
|
-
let
|
|
354
|
-
at:
|
|
355
|
-
skew:
|
|
356
|
-
profile:
|
|
341
|
+
t = normalizeOcspResponse(e.response);
|
|
342
|
+
} catch (e) {
|
|
343
|
+
let t = f(e, B);
|
|
344
|
+
return t === void 0 ? validateOcspResponseFailureResult("signature_invalid", "OCSP response signed content is malformed") : validateOcspResponseFailureResult(t.code, t.message);
|
|
345
|
+
}
|
|
346
|
+
if (t.responseStatus !== "successful") return validateOcspResponseFailureResult("response_status_invalid", `OCSP response status is ${t.responseStatus}`);
|
|
347
|
+
let n = await normalizeOcspValidationInput(e, t);
|
|
348
|
+
if (!n.ok) return n;
|
|
349
|
+
let { issuer: r, trustedResponders: i, signer: a } = n, o = await verifyOcspResponseSignature(t, a);
|
|
350
|
+
if (!o.ok) return validateOcspResponseFailureResult(o.code, o.message);
|
|
351
|
+
let s = await validateOcspResponderAuthorization(e, t, r, a, i);
|
|
352
|
+
if (s !== void 0) return s;
|
|
353
|
+
let c = e.at ?? /* @__PURE__ */ new Date(), l = e.clockSkewMs ?? 0, u = await validateOcspResponseFreshness(t, r, {
|
|
354
|
+
at: c,
|
|
355
|
+
skew: l,
|
|
356
|
+
profile: e.profile ?? "rfc6960"
|
|
357
357
|
});
|
|
358
|
-
if (
|
|
359
|
-
if (hasDuplicateOcspResponseCertificateSerial(
|
|
360
|
-
if (
|
|
361
|
-
let
|
|
362
|
-
if (
|
|
358
|
+
if (u !== void 0) return u;
|
|
359
|
+
if (hasDuplicateOcspResponseCertificateSerial(t.responses ?? [])) return validateOcspResponseFailureResult("signature_invalid", "OCSP response contains multiple status entries for the same certificate");
|
|
360
|
+
if (e.request !== void 0) {
|
|
361
|
+
let n = validateOcspRequestCoverage(e.request, t);
|
|
362
|
+
if (n !== void 0) return n;
|
|
363
363
|
}
|
|
364
364
|
return {
|
|
365
365
|
ok: !0,
|
|
366
|
-
value:
|
|
366
|
+
value: t
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
369
|
/** Re-parses OCSP validation certificates and resolves the response signer. */
|
|
370
|
-
async function normalizeOcspValidationInput(
|
|
371
|
-
let
|
|
370
|
+
async function normalizeOcspValidationInput(e, t) {
|
|
371
|
+
let n;
|
|
372
372
|
try {
|
|
373
|
-
|
|
374
|
-
} catch (
|
|
375
|
-
let
|
|
376
|
-
return
|
|
373
|
+
n = normalizeCertificate(e.issuerCertificate);
|
|
374
|
+
} catch (e) {
|
|
375
|
+
let t = f(e, B);
|
|
376
|
+
return t === void 0 ? validateOcspResponseFailureResult("signature_invalid", "issuer certificate input is malformed") : validateOcspResponseFailureResult(t.code, t.message);
|
|
377
377
|
}
|
|
378
378
|
try {
|
|
379
|
-
let
|
|
379
|
+
let r = (e.trustedOcspResponders ?? []).map(normalizeCertificate), i = await resolveOcspResponderCertificate(e, t, r);
|
|
380
380
|
return {
|
|
381
381
|
ok: !0,
|
|
382
|
-
parsedResponse:
|
|
383
|
-
issuer:
|
|
384
|
-
trustedResponders:
|
|
382
|
+
parsedResponse: t,
|
|
383
|
+
issuer: n,
|
|
384
|
+
trustedResponders: r,
|
|
385
385
|
signer: normalizeCertificate(i)
|
|
386
386
|
};
|
|
387
|
-
} catch (
|
|
388
|
-
let
|
|
389
|
-
return
|
|
387
|
+
} catch (e) {
|
|
388
|
+
let t = f(e, B);
|
|
389
|
+
return t === void 0 ? validateOcspResponseFailureResult("signature_invalid", "OCSP responder certificate input is malformed") : validateOcspResponseFailureResult(t.code, t.message);
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
392
|
/** Selects the responder certificate from explicit, embedded, trusted, or issuer inputs. */
|
|
@@ -399,18 +399,18 @@ async function validateOcspResponderAuthorization(e, t, n, r, i) {
|
|
|
399
399
|
let o = i.some((e) => isSameOcspCertificate(r, e));
|
|
400
400
|
if (!(isSameOcspCertificate(r, n) || o)) return await validateDelegatedOcspResponder(e, t, n, r);
|
|
401
401
|
}
|
|
402
|
-
async function safeValidateOcspResponderIdBinding(
|
|
402
|
+
async function safeValidateOcspResponderIdBinding(e, t) {
|
|
403
403
|
try {
|
|
404
|
-
return await validateOcspResponderIdBinding(
|
|
405
|
-
} catch (
|
|
406
|
-
let
|
|
407
|
-
return
|
|
404
|
+
return await validateOcspResponderIdBinding(e.responderId, t);
|
|
405
|
+
} catch (e) {
|
|
406
|
+
let t = f(e, B);
|
|
407
|
+
return t === void 0 ? validateOcspResponseFailureResult("signature_invalid", "OCSP responder certificate input is malformed") : validateOcspResponseFailureResult(t.code, t.message);
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
async function validateDelegatedOcspResponder(e, t, n, r) {
|
|
411
411
|
let i = e.allowChainedResponderCertificate === !0;
|
|
412
412
|
if (!i && !isDirectlyIssuedByOcspIssuer(r, n)) return validateOcspResponseFailureResult("responder_chain_invalid", "Delegated OCSP responder must be directly issued by issuer certificate");
|
|
413
|
-
if (!(await
|
|
413
|
+
if (!(await X({
|
|
414
414
|
leaf: r.der,
|
|
415
415
|
intermediates: i ? buildOcspResponderIntermediates(t.certificates, r, n) : [],
|
|
416
416
|
roots: [n.der],
|
|
@@ -442,27 +442,27 @@ function validateOcspSingleResponseTimes(e, t, { at: n, skew: r, profile: i }) {
|
|
|
442
442
|
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
443
|
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
444
|
}
|
|
445
|
-
function validateOcspRequestCoverage(
|
|
446
|
-
let
|
|
445
|
+
function validateOcspRequestCoverage(e, t) {
|
|
446
|
+
let n;
|
|
447
447
|
try {
|
|
448
|
-
|
|
449
|
-
} catch (
|
|
450
|
-
let
|
|
451
|
-
return
|
|
448
|
+
n = normalizeOcspRequest(e);
|
|
449
|
+
} catch (e) {
|
|
450
|
+
let t = f(e, B);
|
|
451
|
+
return t === void 0 ? validateOcspResponseFailureResult("request_mismatch", "OCSP request input is malformed") : validateOcspResponseFailureResult(t.code, t.message);
|
|
452
452
|
}
|
|
453
|
-
return
|
|
453
|
+
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
454
|
}
|
|
455
455
|
function validateOcspRequestIdCoverage(e, t, n) {
|
|
456
456
|
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
457
|
for (let n of e) if (!t.has(n)) return validateOcspResponseFailureResult("request_mismatch", "OCSP response does not cover every requested certId");
|
|
458
458
|
}
|
|
459
459
|
/** Builds a `VerifyOcspResponseSignatureFailureResult`. */
|
|
460
|
-
function verifyOcspResponseFailureResult(e,
|
|
461
|
-
return
|
|
460
|
+
function verifyOcspResponseFailureResult(e, t) {
|
|
461
|
+
return V(e, t);
|
|
462
462
|
}
|
|
463
463
|
/** Builds a `ValidateOcspResponseFailureResult`. */
|
|
464
|
-
function validateOcspResponseFailureResult(e,
|
|
465
|
-
return
|
|
464
|
+
function validateOcspResponseFailureResult(e, t) {
|
|
465
|
+
return V(e, t);
|
|
466
466
|
}
|
|
467
467
|
/**
|
|
468
468
|
* Reports whether a certificate carries the `id-pkix-ocsp-nocheck` extension
|
|
@@ -475,11 +475,11 @@ function hasOcspNoCheckExtension(e) {
|
|
|
475
475
|
}
|
|
476
476
|
/** Whether a parsed certificate carries `id-pkix-ocsp-nocheck` with its NULL value. */
|
|
477
477
|
function carriesOcspNoCheck(e) {
|
|
478
|
-
return e.extensions.some((e) => e.oid ===
|
|
478
|
+
return e.extensions.some((e) => e.oid === D.ocspNoCheck && e.valueHex === "0500");
|
|
479
479
|
}
|
|
480
480
|
/** Parses a CRL from PEM string, DER bytes, or an already-parsed CRL. */
|
|
481
481
|
function parseResponderCrlFromSource(e) {
|
|
482
|
-
return typeof e == "object" && "issuer" in e ? e : typeof e == "string" ?
|
|
482
|
+
return typeof e == "object" && "issuer" in e ? e : typeof e == "string" ? Y(e) : J(e);
|
|
483
483
|
}
|
|
484
484
|
function responderCrlCheck(e, t, n) {
|
|
485
485
|
return {
|
|
@@ -506,7 +506,7 @@ async function checkDelegatedResponderRevocation(e, t, n) {
|
|
|
506
506
|
} catch {
|
|
507
507
|
continue;
|
|
508
508
|
}
|
|
509
|
-
let n = await
|
|
509
|
+
let n = await K({
|
|
510
510
|
...i,
|
|
511
511
|
crl: t
|
|
512
512
|
});
|
|
@@ -516,7 +516,7 @@ async function checkDelegatedResponderRevocation(e, t, n) {
|
|
|
516
516
|
for (let e of n.value.coveredReasons) a.add(e);
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
|
-
return o ? validateOcspResponseFailureResult("responder_revocation_unknown", "Delegated OCSP responder carries an unrecognized CRL reason code") :
|
|
519
|
+
return o ? validateOcspResponseFailureResult("responder_revocation_unknown", "Delegated OCSP responder carries an unrecognized CRL reason code") : q(a) || r === "honor-nocheck" ? { ok: !0 } : validateOcspResponseFailureResult("responder_revocation_unknown", "Delegated OCSP responder revocation status could not be established");
|
|
520
520
|
}
|
|
521
521
|
/** Accepts PEM, DER, or already-parsed OCSP response and returns a parsed response. */
|
|
522
522
|
function normalizeOcspResponse(e) {
|
|
@@ -532,29 +532,29 @@ function normalizeOcspRequest(e) {
|
|
|
532
532
|
if (hasReparseableOcspRequestShape(e)) return parseOcspRequestDerOrThrow(new Uint8Array(e.der));
|
|
533
533
|
throw Error("OCSP request input is malformed");
|
|
534
534
|
}
|
|
535
|
-
function parseSignedOcspResponseData(
|
|
536
|
-
let
|
|
537
|
-
if (
|
|
538
|
-
let
|
|
539
|
-
if (
|
|
540
|
-
let
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
let
|
|
546
|
-
|
|
547
|
-
let
|
|
548
|
-
if (
|
|
549
|
-
if (
|
|
550
|
-
let
|
|
551
|
-
if (
|
|
552
|
-
let
|
|
553
|
-
return assertUniqueOcspResponseCertIds(
|
|
554
|
-
responderId:
|
|
555
|
-
producedAt:
|
|
556
|
-
responses:
|
|
557
|
-
...
|
|
535
|
+
function parseSignedOcspResponseData(t) {
|
|
536
|
+
let r = w(t);
|
|
537
|
+
if (r.length < 3 || r.length > 5) throw Error("Malformed OCSP responseData");
|
|
538
|
+
let i = 0;
|
|
539
|
+
if (r[i]?.tag === 160) {
|
|
540
|
+
let a = c(r[i], "version"), o = e(t, a), s = c(o[0], "version");
|
|
541
|
+
if (o.length !== 1 || s.tag !== 2) throw Error("version must use INTEGER");
|
|
542
|
+
if (n(s.value, "OCSP response version") !== 0) throw Error("Unsupported OCSP response version");
|
|
543
|
+
i += 1;
|
|
544
|
+
}
|
|
545
|
+
let a = parseOcspResponderId(t, c(r[i], "responderID"));
|
|
546
|
+
i += 1;
|
|
547
|
+
let o = c(r[i], "producedAt"), l = c(r[i + 1], "responses");
|
|
548
|
+
if (l.tag !== 48) throw Error("responses must use SEQUENCE");
|
|
549
|
+
if (e(t, l).length === 0) throw Error("responses must not be empty");
|
|
550
|
+
let u = r[i + 2];
|
|
551
|
+
if (u !== void 0 && u.tag !== 161 || r.length !== i + 2 + (u === void 0 ? 0 : 1)) throw Error("Malformed OCSP responseData");
|
|
552
|
+
let d = u === void 0 ? void 0 : parseOcspNonceFromExtensions(t, u), f = e(t, l).map((e) => parseSingleResponse(t, e));
|
|
553
|
+
return assertUniqueOcspResponseCertIds(f), {
|
|
554
|
+
responderId: a,
|
|
555
|
+
producedAt: s(o),
|
|
556
|
+
responses: f,
|
|
557
|
+
...d === void 0 ? {} : { nonce: d }
|
|
558
558
|
};
|
|
559
559
|
}
|
|
560
560
|
/** Searches embedded certificates for one whose subject or key hash matches the responder ID. */
|
|
@@ -569,15 +569,15 @@ async function validateOcspResponderIdBinding(e, t) {
|
|
|
569
569
|
}
|
|
570
570
|
/** Returns `true` if the certificate matches the responder ID (subject name or key hash). */
|
|
571
571
|
async function matchesOcspResponderId(e, t) {
|
|
572
|
-
return e.type === "byName" ? compareOcspResponderNames(e.name, t.subject) :
|
|
572
|
+
return e.type === "byName" ? compareOcspResponderNames(e.name, t.subject) : u(await digestBytes("SHA-1", extractSubjectPublicKeyBytes(t.subjectPublicKeyInfoDer))) === e.keyHashHex;
|
|
573
573
|
}
|
|
574
574
|
/** Identity check — same serial, issuer, subject, and SPKI. */
|
|
575
575
|
function isSameOcspCertificate(e, t) {
|
|
576
|
-
return e.serialNumberHex === t.serialNumberHex &&
|
|
576
|
+
return e.serialNumberHex === t.serialNumberHex && L(e.issuer, t.issuer) && L(e.subject, t.subject) && e.subjectPublicKeyInfoDer.length === t.subjectPublicKeyInfoDer.length && e.subjectPublicKeyInfoDer.every((e, n) => e === t.subjectPublicKeyInfoDer[n]);
|
|
577
577
|
}
|
|
578
578
|
/** Returns `true` if `signer` was directly issued by `issuer` (name + AKI match). */
|
|
579
579
|
function isDirectlyIssuedByOcspIssuer(e, t) {
|
|
580
|
-
return !(!
|
|
580
|
+
return !(!L(e.issuer, t.subject) || e.authorityKeyIdentifier !== void 0 && t.subjectKeyIdentifier !== void 0 && e.authorityKeyIdentifier !== t.subjectKeyIdentifier);
|
|
581
581
|
}
|
|
582
582
|
/** Filters embedded certificates to produce an intermediate chain (excluding signer and issuer). */
|
|
583
583
|
function buildOcspResponderIntermediates(e, t, n) {
|
|
@@ -588,12 +588,12 @@ function buildOcspResponderIntermediates(e, t, n) {
|
|
|
588
588
|
}
|
|
589
589
|
/** DER-encodes a CertID SEQUENCE (hashAlgorithm, issuerNameHash, issuerKeyHash, serialNumber). */
|
|
590
590
|
async function encodeOcspCertId(e, t, n) {
|
|
591
|
-
let r = n === "SHA-1" ?
|
|
592
|
-
return
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
591
|
+
let r = n === "SHA-1" ? D.sha1 : D.sha256, i = await buildParsedOcspCertId(r, t, e.serialNumberHex);
|
|
592
|
+
return T([
|
|
593
|
+
T([b(r), y()]),
|
|
594
|
+
x(o(i.issuerNameHashHex)),
|
|
595
|
+
x(o(i.issuerKeyHashHex)),
|
|
596
|
+
v(o(i.serialNumberHex))
|
|
597
597
|
]);
|
|
598
598
|
}
|
|
599
599
|
/** Computes issuer name/key hashes for a CertID given the hash algorithm OID and issuer certificate. */
|
|
@@ -601,171 +601,171 @@ async function buildParsedOcspCertId(e, t, n) {
|
|
|
601
601
|
let r = ocspHashAlgorithmFromOid(e);
|
|
602
602
|
return {
|
|
603
603
|
hashAlgorithmOid: e,
|
|
604
|
-
hashAlgorithmName:
|
|
605
|
-
issuerNameHashHex:
|
|
606
|
-
issuerKeyHashHex:
|
|
604
|
+
hashAlgorithmName: O(e),
|
|
605
|
+
issuerNameHashHex: u(await digestBytes(r, o(t.subject.derHex))),
|
|
606
|
+
issuerKeyHashHex: u(await digestBytes(r, extractSubjectPublicKeyBytes(t.subjectPublicKeyInfoDer))),
|
|
607
607
|
serialNumberHex: n
|
|
608
608
|
};
|
|
609
609
|
}
|
|
610
610
|
/** Hashes `bytes` with the given WebCrypto algorithm name. */
|
|
611
611
|
async function digestBytes(e, t) {
|
|
612
|
-
return new Uint8Array(await
|
|
612
|
+
return new Uint8Array(await F().subtle.digest(e, l(t)));
|
|
613
613
|
}
|
|
614
614
|
/** DER-encodes a SingleResponse (certId, certStatus, thisUpdate, optional nextUpdate). */
|
|
615
615
|
async function encodeSingleResponse(e, t, n, r) {
|
|
616
616
|
let i = await encodeOcspCertId(e, t, r), a = encodeOcspCertStatus(n);
|
|
617
|
-
return
|
|
617
|
+
return T([
|
|
618
618
|
i,
|
|
619
619
|
a,
|
|
620
|
-
|
|
621
|
-
...n.nextUpdate === void 0 ? [] : [
|
|
620
|
+
_(n.thisUpdate ?? /* @__PURE__ */ new Date()),
|
|
621
|
+
...n.nextUpdate === void 0 ? [] : [g(0, _(n.nextUpdate))]
|
|
622
622
|
]);
|
|
623
623
|
}
|
|
624
624
|
/** DER-encodes the CertStatus CHOICE (good [0], revoked [1], unknown [2]). */
|
|
625
625
|
function encodeOcspCertStatus(e) {
|
|
626
626
|
switch (e.certStatus) {
|
|
627
|
-
case "good": return
|
|
628
|
-
case "unknown": return
|
|
627
|
+
case "good": return E(128, /* @__PURE__ */ new Uint8Array());
|
|
628
|
+
case "unknown": return E(130, /* @__PURE__ */ new Uint8Array());
|
|
629
629
|
case "revoked": {
|
|
630
|
-
let t = [
|
|
631
|
-
return e.revocationReasonCode !== void 0 && t.push(
|
|
630
|
+
let t = [_(e.revokedAt ?? e.thisUpdate ?? /* @__PURE__ */ new Date())];
|
|
631
|
+
return e.revocationReasonCode !== void 0 && t.push(g(0, h(e.revocationReasonCode))), E(161, m(t));
|
|
632
632
|
}
|
|
633
633
|
default: throw Error(`Unhandled CertStatus type: ${String(e)}`);
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
636
|
/** Accepts PEM, DER, or already-parsed certificate and returns a parsed certificate. */
|
|
637
637
|
function normalizeCertificate(e) {
|
|
638
|
-
return hasParsedCertificateShape(e) ?
|
|
638
|
+
return hasParsedCertificateShape(e) ? Z(new Uint8Array(e.der)) : Q(e);
|
|
639
639
|
}
|
|
640
640
|
/** Type guard: distinguishes a `ParsedCertificate` from raw `Uint8Array`. */
|
|
641
641
|
function hasParsedCertificateShape(e) {
|
|
642
642
|
return typeof e != "string" && "subjectPublicKeyInfoDer" in e;
|
|
643
643
|
}
|
|
644
644
|
/** Decodes a DER-encoded CertID SEQUENCE into a {@linkcode ParsedOcspCertId}. */
|
|
645
|
-
function parseOcspCertId(
|
|
646
|
-
let
|
|
647
|
-
if (
|
|
648
|
-
let
|
|
649
|
-
if (
|
|
650
|
-
let
|
|
651
|
-
if (
|
|
652
|
-
let
|
|
653
|
-
if (
|
|
654
|
-
let
|
|
655
|
-
if (
|
|
656
|
-
if (
|
|
657
|
-
let
|
|
658
|
-
if (
|
|
645
|
+
function parseOcspCertId(t) {
|
|
646
|
+
let n = C(t, { maxDepth: 64 });
|
|
647
|
+
if (n.tag !== 48) throw Error("CertID must use SEQUENCE");
|
|
648
|
+
let i = e(t, n);
|
|
649
|
+
if (i.length !== 4) throw Error("CertID must contain hashAlgorithm, issuerNameHash, issuerKeyHash, and serialNumber");
|
|
650
|
+
let a = c(i[0], "hashAlgorithm");
|
|
651
|
+
if (a.tag !== 48) throw Error("hashAlgorithm must use SEQUENCE");
|
|
652
|
+
let o = e(t, a);
|
|
653
|
+
if (o.length < 1 || o.length > 2) throw Error("Malformed hashAlgorithm");
|
|
654
|
+
let s = c(o[0], "hashAlgorithm OID"), l = r(s.value);
|
|
655
|
+
if (c(i[1], "issuerNameHash").tag !== 4) throw Error("issuerNameHash must use OCTET STRING");
|
|
656
|
+
if (c(i[2], "issuerKeyHash").tag !== 4) throw Error("issuerKeyHash must use OCTET STRING");
|
|
657
|
+
let d = c(i[3], "serialNumber");
|
|
658
|
+
if (d.tag !== 2) throw Error("serialNumber must use INTEGER");
|
|
659
659
|
return {
|
|
660
|
-
hashAlgorithmOid:
|
|
661
|
-
hashAlgorithmName:
|
|
662
|
-
issuerNameHashHex:
|
|
663
|
-
issuerKeyHashHex:
|
|
664
|
-
serialNumberHex:
|
|
660
|
+
hashAlgorithmOid: l,
|
|
661
|
+
hashAlgorithmName: O(l),
|
|
662
|
+
issuerNameHashHex: u(c(i[1], "issuerNameHash").value),
|
|
663
|
+
issuerKeyHashHex: u(c(i[2], "issuerKeyHash").value),
|
|
664
|
+
serialNumberHex: u(d.value)
|
|
665
665
|
};
|
|
666
666
|
}
|
|
667
667
|
/** Decodes a SingleResponse from its ASN.1 element within the ResponseData. */
|
|
668
|
-
function parseSingleResponse(
|
|
669
|
-
let
|
|
670
|
-
if (
|
|
671
|
-
let
|
|
672
|
-
|
|
673
|
-
let
|
|
674
|
-
if (
|
|
668
|
+
function parseSingleResponse(t, n) {
|
|
669
|
+
let r = e(t, n);
|
|
670
|
+
if (r.length < 3 || r.length > 5) throw Error("Malformed OCSP SingleResponse");
|
|
671
|
+
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;
|
|
672
|
+
u !== void 0 && (validateOcspSingleResponseNextUpdate(t, u), l += 1);
|
|
673
|
+
let d = r[l];
|
|
674
|
+
if (d !== void 0 && d.tag !== 161 || r.length !== l + (d === void 0 ? 0 : 1)) throw Error("Malformed OCSP SingleResponse");
|
|
675
675
|
return {
|
|
676
|
-
certId: parseOcspCertId(
|
|
677
|
-
thisUpdate:
|
|
678
|
-
...parseOcspSingleResponseNextUpdate(
|
|
679
|
-
...parseOcspCertStatusFields(
|
|
676
|
+
certId: parseOcspCertId(t.slice(i.start - i.headerLength, i.end)),
|
|
677
|
+
thisUpdate: s(o),
|
|
678
|
+
...parseOcspSingleResponseNextUpdate(t, u),
|
|
679
|
+
...parseOcspCertStatusFields(t, a)
|
|
680
680
|
};
|
|
681
681
|
}
|
|
682
|
-
function parseOcspSingleResponseNextUpdate(
|
|
683
|
-
return
|
|
682
|
+
function parseOcspSingleResponseNextUpdate(t, n) {
|
|
683
|
+
return n === void 0 ? {} : { nextUpdate: s(c(e(t, n)[0], "nextUpdate")) };
|
|
684
684
|
}
|
|
685
|
-
function parseOcspCertStatusFields(
|
|
686
|
-
if (
|
|
687
|
-
if (
|
|
685
|
+
function parseOcspCertStatusFields(t, n) {
|
|
686
|
+
if (n.tag === 128) {
|
|
687
|
+
if (n.value.length !== 0) throw Error("OCSP good certStatus must be empty");
|
|
688
688
|
return { certStatus: "good" };
|
|
689
689
|
}
|
|
690
|
-
if (
|
|
691
|
-
if (
|
|
690
|
+
if (n.tag === 130) {
|
|
691
|
+
if (n.value.length !== 0) throw Error("OCSP unknown certStatus must be empty");
|
|
692
692
|
return { certStatus: "unknown" };
|
|
693
693
|
}
|
|
694
|
-
if (
|
|
695
|
-
let
|
|
696
|
-
if (
|
|
694
|
+
if (n.tag !== 161) throw Error(`Unsupported OCSP certStatus tag: ${String(n.tag)}`);
|
|
695
|
+
let r = e(t, n);
|
|
696
|
+
if (r.length < 1 || r.length > 2) throw Error("Malformed OCSP revoked certStatus");
|
|
697
697
|
return {
|
|
698
698
|
certStatus: "revoked",
|
|
699
|
-
revokedAt:
|
|
700
|
-
...parseOcspRevocationReason(
|
|
699
|
+
revokedAt: s(c(r[0], "revocationTime")),
|
|
700
|
+
...parseOcspRevocationReason(t, r[1])
|
|
701
701
|
};
|
|
702
702
|
}
|
|
703
|
-
function parseOcspRevocationReason(
|
|
704
|
-
if (
|
|
705
|
-
if (
|
|
706
|
-
let
|
|
707
|
-
if (
|
|
708
|
-
return { revocationReasonCode:
|
|
703
|
+
function parseOcspRevocationReason(n, r) {
|
|
704
|
+
if (r === void 0) return {};
|
|
705
|
+
if (r.tag !== 160) throw Error("Malformed OCSP revoked certStatus");
|
|
706
|
+
let i = e(n, r), a = c(i[0], "revocationReason");
|
|
707
|
+
if (i.length !== 1 || a.tag !== 10) throw Error("revocationReason must use ENUMERATED");
|
|
708
|
+
return { revocationReasonCode: t(a.value, "OCSP revocationReason") };
|
|
709
709
|
}
|
|
710
710
|
/** Decodes a ResponderID from its context-tagged ASN.1 element (byName [1] or byKeyHash [2]). */
|
|
711
|
-
function parseOcspResponderId(
|
|
712
|
-
switch (
|
|
711
|
+
function parseOcspResponderId(t, n) {
|
|
712
|
+
switch (n.tag) {
|
|
713
713
|
case 162: {
|
|
714
|
-
let
|
|
715
|
-
if (
|
|
716
|
-
let
|
|
717
|
-
if (
|
|
718
|
-
if (
|
|
714
|
+
let r = e(t, n);
|
|
715
|
+
if (r.length !== 1) throw Error("ResponderID byKey must wrap exactly one OCTET STRING");
|
|
716
|
+
let i = c(r[0], "ResponderID byKey");
|
|
717
|
+
if (i.tag !== 4) throw Error("ResponderID byKey must wrap an OCTET STRING");
|
|
718
|
+
if (i.value.length !== 20) throw Error("ResponderID byKey must be a 20-byte SHA-1 KeyHash");
|
|
719
719
|
return {
|
|
720
720
|
type: "byKeyHash",
|
|
721
|
-
keyHashHex:
|
|
721
|
+
keyHashHex: u(i.value)
|
|
722
722
|
};
|
|
723
723
|
}
|
|
724
724
|
case 161:
|
|
725
|
-
if (
|
|
725
|
+
if (e(t, n).length !== 1) throw Error("ResponderID byName must wrap exactly one Name");
|
|
726
726
|
return {
|
|
727
727
|
type: "byName",
|
|
728
|
-
name: parseResponderName(
|
|
728
|
+
name: parseResponderName(t, c(e(t, n)[0], "ResponderID byName"))
|
|
729
729
|
};
|
|
730
|
-
default: throw Error(`Unsupported OCSP responderID tag: ${String(
|
|
730
|
+
default: throw Error(`Unsupported OCSP responderID tag: ${String(n.tag)}`);
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
733
|
/** Decodes a Name SEQUENCE from the ResponderID byName form. */
|
|
734
|
-
function parseResponderName(
|
|
735
|
-
if (
|
|
736
|
-
let
|
|
737
|
-
for (let
|
|
738
|
-
let
|
|
739
|
-
|
|
740
|
-
for (let
|
|
734
|
+
function parseResponderName(t, n) {
|
|
735
|
+
if (n.tag !== 48) throw Error("ResponderID byName must use Name SEQUENCE");
|
|
736
|
+
let r = [], i = [], a = {};
|
|
737
|
+
for (let o of e(t, n)) {
|
|
738
|
+
let e = parseResponderNameAttributeSet(t, o);
|
|
739
|
+
r.push(e);
|
|
740
|
+
for (let t of e.attributes) i.push(t), t.key !== void 0 && a[t.key] === void 0 && (a[t.key] = t.value);
|
|
741
741
|
}
|
|
742
742
|
return {
|
|
743
|
-
derHex:
|
|
744
|
-
rdns:
|
|
745
|
-
attributes:
|
|
746
|
-
values:
|
|
743
|
+
derHex: u(t.slice(n.start - n.headerLength, n.end)),
|
|
744
|
+
rdns: r,
|
|
745
|
+
attributes: i,
|
|
746
|
+
values: a
|
|
747
747
|
};
|
|
748
748
|
}
|
|
749
749
|
/** Decodes one RDN SET from a responder name. */
|
|
750
|
-
function parseResponderNameAttributeSet(
|
|
751
|
-
let
|
|
752
|
-
for (let
|
|
753
|
-
let
|
|
754
|
-
oid:
|
|
755
|
-
valueTag:
|
|
756
|
-
value:
|
|
750
|
+
function parseResponderNameAttributeSet(t, n) {
|
|
751
|
+
let a = [], o = {};
|
|
752
|
+
for (let s of e(t, n)) {
|
|
753
|
+
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 ? {
|
|
754
|
+
oid: l,
|
|
755
|
+
valueTag: u.tag,
|
|
756
|
+
value: f
|
|
757
757
|
} : {
|
|
758
|
-
oid:
|
|
759
|
-
key:
|
|
760
|
-
valueTag:
|
|
761
|
-
value:
|
|
758
|
+
oid: l,
|
|
759
|
+
key: d,
|
|
760
|
+
valueTag: u.tag,
|
|
761
|
+
value: f
|
|
762
762
|
};
|
|
763
|
-
|
|
763
|
+
a.push(p), d !== void 0 && o[d] === void 0 && (o[d] = f);
|
|
764
764
|
}
|
|
765
765
|
return {
|
|
766
|
-
derHex:
|
|
767
|
-
attributes:
|
|
768
|
-
values:
|
|
766
|
+
derHex: u(t.slice(n.start - n.headerLength, n.end)),
|
|
767
|
+
attributes: a,
|
|
768
|
+
values: o
|
|
769
769
|
};
|
|
770
770
|
}
|
|
771
771
|
/** RDN-by-RDN responder name comparison with RFC 4518 string prep. */
|
|
@@ -815,57 +815,57 @@ function prepareOcspNameCompareString(e) {
|
|
|
815
815
|
/** 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
816
|
function responderNameKeyFromOid(e) {
|
|
817
817
|
switch (e) {
|
|
818
|
-
case
|
|
819
|
-
case
|
|
820
|
-
case
|
|
821
|
-
case
|
|
822
|
-
case
|
|
823
|
-
case
|
|
824
|
-
case
|
|
825
|
-
case
|
|
826
|
-
case
|
|
827
|
-
case
|
|
828
|
-
case
|
|
829
|
-
case
|
|
818
|
+
case D.commonName: return "commonName";
|
|
819
|
+
case D.surname: return "surname";
|
|
820
|
+
case D.serialNumber: return "serialNumber";
|
|
821
|
+
case D.countryName: return "country";
|
|
822
|
+
case D.localityName: return "locality";
|
|
823
|
+
case D.stateOrProvinceName: return "state";
|
|
824
|
+
case D.streetAddress: return "street";
|
|
825
|
+
case D.organizationName: return "organization";
|
|
826
|
+
case D.organizationalUnitName: return "organizationalUnit";
|
|
827
|
+
case D.title: return "title";
|
|
828
|
+
case D.givenName: return "givenName";
|
|
829
|
+
case D.emailAddress: return "emailAddress";
|
|
830
830
|
default: return;
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
833
|
/** Extracts the nonce value (as hex) from an OCSP extensions wrapper, if present. */
|
|
834
|
-
function parseOcspNonceFromExtensions(
|
|
835
|
-
let
|
|
836
|
-
if (
|
|
837
|
-
let
|
|
838
|
-
for (let
|
|
839
|
-
let
|
|
840
|
-
if (
|
|
841
|
-
let
|
|
842
|
-
if (
|
|
843
|
-
|
|
844
|
-
let
|
|
845
|
-
if (
|
|
846
|
-
if (
|
|
847
|
-
let
|
|
848
|
-
if (
|
|
849
|
-
|
|
850
|
-
}
|
|
851
|
-
return
|
|
834
|
+
function parseOcspNonceFromExtensions(t, n) {
|
|
835
|
+
let i = e(t, n), a = c(i[0], "extensions");
|
|
836
|
+
if (i.length !== 1 || a.tag !== 48) throw Error("Malformed OCSP extensions");
|
|
837
|
+
let o = /* @__PURE__ */ new Set(), s;
|
|
838
|
+
for (let n of e(t, a)) {
|
|
839
|
+
let i = e(t, n);
|
|
840
|
+
if (i.length < 2 || i.length > 3 || i.length === 3 && i[1]?.tag !== 1) throw Error("Malformed OCSP extension");
|
|
841
|
+
let a = r(c(i[0], "extension OID").value);
|
|
842
|
+
if (o.has(a)) throw Error(`Duplicate OCSP extension OID: ${a}`);
|
|
843
|
+
o.add(a);
|
|
844
|
+
let l = c(i[i.length - 1], "extnValue");
|
|
845
|
+
if (l.tag !== 4) throw Error("OCSP extension value must use OCTET STRING");
|
|
846
|
+
if (a !== D.ocspNonce) continue;
|
|
847
|
+
let d = C(l.value, { maxDepth: 64 });
|
|
848
|
+
if (d.tag !== 4) throw Error("OCSP nonce extension value must use OCTET STRING");
|
|
849
|
+
s = u(d.value);
|
|
850
|
+
}
|
|
851
|
+
return s;
|
|
852
852
|
}
|
|
853
853
|
/** Decodes the optional `certs [0]` field from a BasicOCSPResponse. */
|
|
854
|
-
function parseEmbeddedCertificates(
|
|
855
|
-
let
|
|
856
|
-
if (
|
|
857
|
-
let
|
|
858
|
-
for (;
|
|
859
|
-
let
|
|
860
|
-
|
|
854
|
+
function parseEmbeddedCertificates(t, n) {
|
|
855
|
+
let r = [], i = e(t, n)[0];
|
|
856
|
+
if (i === void 0 || i.tag !== 48) throw Error("Malformed BasicOCSPResponse certs");
|
|
857
|
+
let a = i.start;
|
|
858
|
+
for (; a < i.end;) {
|
|
859
|
+
let e = S(t, a);
|
|
860
|
+
r.push(Z(t.slice(a, e.end))), a = e.end;
|
|
861
861
|
}
|
|
862
|
-
return
|
|
862
|
+
return r;
|
|
863
863
|
}
|
|
864
864
|
/** Extracts the raw public key bytes (without BIT STRING padding byte) from SPKI DER. */
|
|
865
|
-
function extractSubjectPublicKeyBytes(
|
|
866
|
-
let
|
|
867
|
-
if (
|
|
868
|
-
return
|
|
865
|
+
function extractSubjectPublicKeyBytes(t) {
|
|
866
|
+
let n = e(t, S(t)), r = c(n[1], "subjectPublicKey BIT STRING");
|
|
867
|
+
if (r.tag !== 3) throw Error("SPKI missing subjectPublicKey BIT STRING");
|
|
868
|
+
return r.value.slice(1);
|
|
869
869
|
}
|
|
870
870
|
/** Maps an integer response-status code to its {@linkcode OcspResponseStatus} string. */
|
|
871
871
|
function ocspResponseStatusFromCode(e) {
|
|
@@ -902,29 +902,29 @@ function hasDuplicateOcspResponseCertificateSerial(e) {
|
|
|
902
902
|
}
|
|
903
903
|
return !1;
|
|
904
904
|
}
|
|
905
|
-
function validateOcspRequestorName(
|
|
906
|
-
let
|
|
907
|
-
if (
|
|
905
|
+
function validateOcspRequestorName(t, n) {
|
|
906
|
+
let r = e(t, n), i = c(r[0], "requestorName");
|
|
907
|
+
if (r.length !== 1 || (i.tag & 192) != 128) throw Error("requestorName must wrap exactly one GeneralName");
|
|
908
908
|
}
|
|
909
|
-
function validateOcspOptionalSignature(
|
|
910
|
-
let
|
|
911
|
-
if (
|
|
912
|
-
let
|
|
913
|
-
if (
|
|
914
|
-
let
|
|
915
|
-
if (validateAlgorithmIdentifierShape(
|
|
916
|
-
let
|
|
917
|
-
if (
|
|
909
|
+
function validateOcspOptionalSignature(t, n) {
|
|
910
|
+
let r = e(t, n), i = c(r[0], "optionalSignature");
|
|
911
|
+
if (r.length !== 1 || i.tag !== 48) throw Error("optionalSignature must wrap exactly one Signature");
|
|
912
|
+
let o = e(t, i);
|
|
913
|
+
if (o.length < 2 || o.length > 3 || o[0]?.tag !== 48 || o[2] !== void 0 && o[2]?.tag !== 160) throw Error("Malformed optionalSignature");
|
|
914
|
+
let s = c(o[0], "signatureAlgorithm"), l = c(o[1], "signature"), u = o[2];
|
|
915
|
+
if (validateAlgorithmIdentifierShape(t, s, "optionalSignature algorithm"), a(l), u !== void 0) {
|
|
916
|
+
let n = e(t, u);
|
|
917
|
+
if (n.length !== 1 || n[0]?.tag !== 48) throw Error("optionalSignature certs must use SEQUENCE OF Certificate");
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
|
-
function validateOcspSingleResponseNextUpdate(
|
|
921
|
-
let
|
|
922
|
-
if (
|
|
920
|
+
function validateOcspSingleResponseNextUpdate(t, n) {
|
|
921
|
+
let r = e(t, n), i = c(r[0], "nextUpdate");
|
|
922
|
+
if (r.length !== 1 || i.tag !== 23 && i.tag !== 24) throw Error("nextUpdate must wrap exactly one time value");
|
|
923
923
|
}
|
|
924
|
-
function validateAlgorithmIdentifierShape(
|
|
925
|
-
let
|
|
926
|
-
if (
|
|
927
|
-
|
|
924
|
+
function validateAlgorithmIdentifierShape(t, n, i) {
|
|
925
|
+
let a = e(t, n);
|
|
926
|
+
if (n.tag !== 48 || a.length < 1 || a.length > 2 || a[0]?.tag !== 6) throw Error(`${i} must use AlgorithmIdentifier SEQUENCE`);
|
|
927
|
+
r(c(a[0], `${i} OID`).value);
|
|
928
928
|
}
|
|
929
929
|
function normalizeHex(e) {
|
|
930
930
|
return e.toLowerCase();
|
|
@@ -932,8 +932,8 @@ function normalizeHex(e) {
|
|
|
932
932
|
/** Maps a hash algorithm OID to the WebCrypto algorithm name. Throws on unsupported OIDs. */
|
|
933
933
|
function ocspHashAlgorithmFromOid(e) {
|
|
934
934
|
switch (e) {
|
|
935
|
-
case
|
|
936
|
-
case
|
|
935
|
+
case D.sha1: return "SHA-1";
|
|
936
|
+
case D.sha256: return "SHA-256";
|
|
937
937
|
default: throw Error(`Unsupported OCSP hash algorithm OID: ${e}`);
|
|
938
938
|
}
|
|
939
939
|
}
|