@owf/x509 0.0.0-stage → 0.0.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.
@@ -0,0 +1,600 @@
1
+ import { IAsnParseOptions } from "@peculiar/asn1-schema";
2
+ import { AlgorithmIdentifier, Certificate as Certificate$1, Extension, GeneralName, KeyUsageType, Name, SubjectPublicKeyInfo } from "@peculiar/asn1-x509";
3
+ import { IdentityException, JsonWebKey, OrPromise } from "@owf/identity-common";
4
+ import "asn1js";
5
+ //#region src/constants.d.ts
6
+ /** X.520 attribute types and PKCS#9 emailAddress, as used in distinguished names */
7
+ export declare const ATTRIBUTE_TYPES: {
8
+ readonly commonName: '2.5.4.3';
9
+ readonly surname: '2.5.4.4';
10
+ readonly serialNumber: '2.5.4.5';
11
+ readonly countryName: '2.5.4.6';
12
+ readonly localityName: '2.5.4.7';
13
+ readonly stateOrProvinceName: '2.5.4.8';
14
+ readonly streetAddress: '2.5.4.9';
15
+ readonly organizationName: '2.5.4.10';
16
+ readonly organizationalUnitName: '2.5.4.11';
17
+ readonly title: '2.5.4.12';
18
+ readonly postalCode: '2.5.4.17';
19
+ readonly telephoneNumber: '2.5.4.20';
20
+ readonly givenName: '2.5.4.42';
21
+ readonly initials: '2.5.4.43';
22
+ readonly generationQualifier: '2.5.4.44';
23
+ readonly pseudonym: '2.5.4.65';
24
+ readonly organizationIdentifier: '2.5.4.97';
25
+ readonly emailAddress: '1.2.840.113549.1.9.1';
26
+ };
27
+ type AttributeName = keyof typeof ATTRIBUTE_TYPES;
28
+ /** Policy qualifier identifiers (RFC 5280 clause 4.2.1.4) */
29
+ export declare const POLICY_QUALIFIERS: {
30
+ readonly cps: '1.3.6.1.5.5.7.2.1';
31
+ readonly unotice: '1.3.6.1.5.5.7.2.2';
32
+ };
33
+ /** Access methods for the Authority Information Access extension (RFC 5280 clause 4.2.2.1) */
34
+ export declare const ACCESS_METHODS: {
35
+ readonly ocsp: '1.3.6.1.5.5.7.48.1';
36
+ readonly caIssuers: '1.3.6.1.5.5.7.48.2';
37
+ };
38
+ /** QCStatements extension (RFC 3739) and statements from ETSI EN 319 412-5 */
39
+ export declare const QC_STATEMENTS: {
40
+ readonly extension: "1.3.6.1.5.5.7.1.3";
41
+ readonly qcCompliance: "0.4.0.1862.1.1";
42
+ readonly qcSSCD: "0.4.0.1862.1.4";
43
+ readonly qcPDS: "0.4.0.1862.1.5";
44
+ readonly qcType: "0.4.0.1862.1.6";
45
+ readonly qcCClegislation: "0.4.0.1862.1.7";
46
+ };
47
+ /** QcType values (ETSI EN 319 412-5 clause 4.2.3) */
48
+ export declare const QC_TYPES: {
49
+ readonly esign: "0.4.0.1862.1.6.1";
50
+ readonly eseal: "0.4.0.1862.1.6.2";
51
+ readonly web: "0.4.0.1862.1.6.3";
52
+ };
53
+ type QcType = keyof typeof QC_TYPES;
54
+ /** Signature algorithms supported for creating and describing certificates and CRLs */
55
+ export declare const SIGNATURE_ALGORITHMS: {
56
+ readonly ES256: {
57
+ readonly oid: '1.2.840.10045.4.3.2';
58
+ readonly hash: 'SHA-256';
59
+ readonly family: 'ecdsa';
60
+ };
61
+ readonly ES384: {
62
+ readonly oid: '1.2.840.10045.4.3.3';
63
+ readonly hash: 'SHA-384';
64
+ readonly family: 'ecdsa';
65
+ };
66
+ readonly ES512: {
67
+ readonly oid: '1.2.840.10045.4.3.4';
68
+ readonly hash: 'SHA-512';
69
+ readonly family: 'ecdsa';
70
+ };
71
+ readonly RS256: {
72
+ readonly oid: '1.2.840.113549.1.1.11';
73
+ readonly hash: 'SHA-256';
74
+ readonly family: 'rsa';
75
+ };
76
+ readonly RS384: {
77
+ readonly oid: '1.2.840.113549.1.1.12';
78
+ readonly hash: 'SHA-384';
79
+ readonly family: 'rsa';
80
+ };
81
+ readonly RS512: {
82
+ readonly oid: '1.2.840.113549.1.1.13';
83
+ readonly hash: 'SHA-512';
84
+ readonly family: 'rsa';
85
+ };
86
+ };
87
+ type SignatureAlgorithm = keyof typeof SIGNATURE_ALGORITHMS;
88
+ /** Public key algorithm and curve identifiers */
89
+ export declare const KEY_ALGORITHMS: {
90
+ readonly ecPublicKey: '1.2.840.10045.2.1';
91
+ readonly rsaEncryption: '1.2.840.113549.1.1.1';
92
+ readonly 'P-256': '1.2.840.10045.3.1.7';
93
+ readonly 'P-384': '1.3.132.0.34';
94
+ readonly 'P-521': '1.3.132.0.35';
95
+ };
96
+ /** CRL entry revocation reasons (RFC 5280 clause 5.3.1) */
97
+ export declare const CRL_REASONS: {
98
+ readonly unspecified: 0;
99
+ readonly keyCompromise: 1;
100
+ readonly cACompromise: 2;
101
+ readonly affiliationChanged: 3;
102
+ readonly superseded: 4;
103
+ readonly cessationOfOperation: 5;
104
+ readonly certificateHold: 6;
105
+ readonly removeFromCRL: 8;
106
+ readonly privilegeWithdrawn: 9;
107
+ readonly aACompromise: 10;
108
+ };
109
+ type CrlReason = keyof typeof CRL_REASONS;
110
+ //#endregion
111
+ //#region src/encoding.d.ts
112
+ /** DER bytes, a base64 encoded DER string, or a PEM string */
113
+ type DerInput = Uint8Array | ArrayBuffer | string;
114
+ /** A DER encoded certificate as bytes, a base64 DER string, or a PEM string */
115
+ type CertificateInput = DerInput;
116
+ /** A DER encoded CRL as bytes, a base64 DER string, or a PEM string (`X509 CRL`) */
117
+ type CrlInput = DerInput;
118
+ export declare const PEM_LABELS: {
119
+ readonly certificate: 'CERTIFICATE';
120
+ readonly crl: 'X509 CRL';
121
+ };
122
+ /**
123
+ * Normalize a {@link DerInput} to DER bytes. PEM strings must use the given label; the
124
+ * first matching block is used.
125
+ */
126
+ export declare function toDer(input: DerInput, label?: string): Uint8Array;
127
+ /** Encode DER bytes as PEM. */
128
+ export declare function toPem(der: Uint8Array, label?: string): string;
129
+ //#endregion
130
+ //#region src/name.d.ts
131
+ /** One name attribute: a well-known attribute name or an attribute type OID, and its value */
132
+ type NameAttributeInput = readonly [AttributeName | string, string | undefined];
133
+ /**
134
+ * Compare two distinguished names attribute by attribute, ignoring case and insignificant
135
+ * whitespace in the values (a simplification of the RFC 5280 clause 7.1 matching rules).
136
+ */
137
+ export declare function namesEqual(a: DistinguishedName, b: DistinguishedName): boolean;
138
+ //#endregion
139
+ //#region src/types.d.ts
140
+ /** A single attribute of a distinguished name */
141
+ interface DistinguishedNameAttribute {
142
+ /** Attribute type OID */
143
+ type: string;
144
+ /** Well-known attribute name, when the OID is known */
145
+ name?: AttributeName;
146
+ /** Attribute value as string (non-string values are `#` followed by the hex encoded DER) */
147
+ value: string;
148
+ }
149
+ /** A distinguished name with accessors for common attributes */
150
+ interface DistinguishedName {
151
+ /** All attributes in encoding order (multi-valued RDNs are flattened) */
152
+ attributes: DistinguishedNameAttribute[];
153
+ /** RFC 4514 string representation, most specific RDN first */
154
+ rfc4514: string;
155
+ commonName?: string;
156
+ organizationName?: string;
157
+ organizationIdentifier?: string;
158
+ organizationalUnitNames: string[];
159
+ countryName?: string;
160
+ localityName?: string;
161
+ stateOrProvinceName?: string;
162
+ serialNumber?: string;
163
+ givenName?: string;
164
+ surname?: string;
165
+ pseudonym?: string;
166
+ }
167
+ interface ParsedPublicKey {
168
+ /** Key algorithm OID */
169
+ algorithm: string;
170
+ /** Named curve OID for EC keys */
171
+ namedCurve?: string;
172
+ /** DER encoded SubjectPublicKeyInfo */
173
+ spki: Uint8Array;
174
+ /** JWK representation, for EC (P-256, P-384, P-521) and RSA keys */
175
+ jwk?: JsonWebKey;
176
+ }
177
+ interface X509Extension {
178
+ oid: string;
179
+ critical: boolean;
180
+ /** DER encoded extension value (content of extnValue) */
181
+ value: Uint8Array;
182
+ }
183
+ /** Result of a signature over a DER structure (certificate or CRL) */
184
+ interface SignedStructure {
185
+ /** Signature algorithm OID */
186
+ signatureAlgorithm: string;
187
+ /** Signature algorithm name, when supported by this package */
188
+ signatureAlgorithmName?: SignatureAlgorithm;
189
+ /** The signature value as encoded in the structure (DER for ECDSA) */
190
+ signature: Uint8Array;
191
+ }
192
+ /** A certificate policy entry (RFC 5280 clause 4.2.1.4) */
193
+ interface CertificatePolicyInformation {
194
+ oid: string;
195
+ cpsUris: string[];
196
+ /** Explicit text of any user notice qualifiers */
197
+ userNotices: string[];
198
+ }
199
+ interface OtherNameValue {
200
+ typeId: string;
201
+ /** DER encoding of the value */
202
+ value: Uint8Array;
203
+ /** The decoded value when it is an ASN.1 string type */
204
+ text?: string;
205
+ }
206
+ interface SubjectAlternativeNames {
207
+ dnsNames: string[];
208
+ uris: string[];
209
+ emails: string[];
210
+ ipAddresses: string[];
211
+ directoryNames: DistinguishedName[];
212
+ otherNames: OtherNameValue[];
213
+ }
214
+ /** QCStatements (RFC 3739, ETSI EN 319 412-5) */
215
+ interface QcStatements {
216
+ /** All statement ids present, in order */
217
+ statementIds: string[];
218
+ /** id-etsi-qcs-QcCompliance present */
219
+ qcCompliance: boolean;
220
+ /** id-etsi-qcs-QcSSCD present */
221
+ qcSSCD: boolean;
222
+ /** Known QcType values; unknown type OIDs are returned as-is */
223
+ qcTypes: (QcType | string)[];
224
+ /** PKI disclosure statements */
225
+ pds: {
226
+ url: string;
227
+ language: string;
228
+ }[];
229
+ /** QcCClegislation country codes */
230
+ legislationCountries: string[];
231
+ }
232
+ /** A parsed X.509 certificate */
233
+ interface Certificate extends SignedStructure {
234
+ /** DER encoding of the certificate */
235
+ der: Uint8Array;
236
+ /** PEM encoding of the certificate */
237
+ pem: string;
238
+ /** X.509 version (1, 2 or 3) */
239
+ version: number;
240
+ /** Lowercase hex encoded serial number, as encoded (including a leading 00 octet if present) */
241
+ serialNumber: string;
242
+ issuer: DistinguishedName;
243
+ subject: DistinguishedName;
244
+ notBefore: Date;
245
+ notAfter: Date;
246
+ publicKey: ParsedPublicKey;
247
+ /** DER encoded TBSCertificate, i.e. the signed bytes */
248
+ tbsCertificate: Uint8Array;
249
+ policies: CertificatePolicyInformation[];
250
+ subjectAlternativeNames: SubjectAlternativeNames;
251
+ keyUsage?: KeyUsageType[];
252
+ extendedKeyUsage?: string[];
253
+ basicConstraints?: {
254
+ cA: boolean;
255
+ pathLenConstraint?: number;
256
+ };
257
+ /** Lowercase hex */
258
+ subjectKeyIdentifier?: string;
259
+ /** Lowercase hex */
260
+ authorityKeyIdentifier?: string;
261
+ /** URIs of the full names of all CRL distribution points */
262
+ crlDistributionPoints: string[];
263
+ ocspUrls: string[];
264
+ caIssuersUrls: string[];
265
+ qcStatements?: QcStatements;
266
+ extensions: X509Extension[];
267
+ }
268
+ interface RevokedCertificate {
269
+ /** Lowercase hex encoded serial number, as encoded */
270
+ serialNumber: string;
271
+ revocationDate: Date;
272
+ /** Absent means unspecified */
273
+ reason?: CrlReason;
274
+ invalidityDate?: Date;
275
+ /** Issuer of the revoked certificate for indirect CRLs (applies to this and following entries) */
276
+ certificateIssuer?: DistinguishedName;
277
+ extensions: X509Extension[];
278
+ }
279
+ interface IssuingDistributionPoint {
280
+ /** URIs of the distribution point full name */
281
+ distributionPointUris: string[];
282
+ onlyContainsUserCerts: boolean;
283
+ onlyContainsCACerts: boolean;
284
+ onlyContainsAttributeCerts: boolean;
285
+ indirectCRL: boolean;
286
+ /** Reason flags when the CRL covers only some reasons */
287
+ onlySomeReasons?: string[];
288
+ }
289
+ /** A parsed X.509 certificate revocation list (RFC 5280 clause 5) */
290
+ interface Crl extends SignedStructure {
291
+ der: Uint8Array;
292
+ pem: string;
293
+ /** CRL version (1 or 2) */
294
+ version: number;
295
+ issuer: DistinguishedName;
296
+ thisUpdate: Date;
297
+ nextUpdate?: Date;
298
+ /** DER encoded TBSCertList, i.e. the signed bytes */
299
+ tbsCertList: Uint8Array;
300
+ crlNumber?: bigint;
301
+ /** Set for delta CRLs: the CRL number of the base CRL */
302
+ deltaCrlIndicator?: bigint;
303
+ /** Lowercase hex */
304
+ authorityKeyIdentifier?: string;
305
+ issuingDistributionPoint?: IssuingDistributionPoint;
306
+ /** URIs of freshest CRL (delta CRL) distribution points */
307
+ freshestCrl: string[];
308
+ revokedCertificates: RevokedCertificate[];
309
+ extensions: X509Extension[];
310
+ }
311
+ /**
312
+ * Signs DER encoded to-be-signed bytes (TBSCertificate or TBSCertList) with the issuer key.
313
+ *
314
+ * The private key never has to be handed to this package: implement the callback with
315
+ * WebCrypto, a KMS, an HSM or a remote signing service.
316
+ */
317
+ type TbsSigner = (tbs: Uint8Array) => OrPromise<Uint8Array>;
318
+ /** Encoding of ECDSA signatures returned by a signer: `ieee-p1363` (r || s, WebCrypto) or `der` */
319
+ type SignatureEncoding = 'ieee-p1363' | 'der';
320
+ /**
321
+ * Hash function used to derive key identifiers. Receives the subject public key bytes and is
322
+ * called with `sha-256`; the first 160 bits are used (RFC 7093 method 1). Compatible with
323
+ * `digest` from `@owf/crypto`.
324
+ */
325
+ type KeyIdentifierHasher = (data: ArrayBuffer, alg: string) => OrPromise<Uint8Array>;
326
+ interface SignatureVerificationInput {
327
+ /** DER encoded to-be-signed bytes */
328
+ data: Uint8Array;
329
+ /** Signature as encoded in the structure (DER for ECDSA) */
330
+ signature: Uint8Array;
331
+ /** Signature as r || s for ECDSA, as expected by WebCrypto; same as `signature` for RSA */
332
+ signatureP1363: Uint8Array;
333
+ /** Signature algorithm OID */
334
+ signatureAlgorithm: string;
335
+ signatureAlgorithmName?: SignatureAlgorithm;
336
+ /** Public key of the signer */
337
+ publicKey: ParsedPublicKey;
338
+ }
339
+ type SignatureVerifier = (input: SignatureVerificationInput) => OrPromise<boolean>;
340
+ interface SubjectAlternativeNamesInput {
341
+ dnsNames?: string[];
342
+ uris?: string[];
343
+ emails?: string[];
344
+ /** otherName entries; use {@link stringOtherName} for string valued types */
345
+ otherNames?: {
346
+ typeId: string;
347
+ value: Uint8Array;
348
+ }[];
349
+ }
350
+ interface CertificateTemplate {
351
+ /** Subject attributes in encoding order, most general first (e.g. C, O, CN) */
352
+ subject: readonly NameAttributeInput[];
353
+ /** Public key of the subject as DER SubjectPublicKeyInfo or public JWK (private JWKs are rejected) */
354
+ subjectPublicKey: Uint8Array | JsonWebKey;
355
+ /**
356
+ * Certificate of the issuing CA; supplies the issuer name, authority key identifier and
357
+ * the key type for signature encoding. Omit for a self-signed certificate.
358
+ */
359
+ issuerCertificate?: CertificateInput;
360
+ /** Positive serial number as bytes or hex string (at most 20 octets) */
361
+ serialNumber: Uint8Array | string;
362
+ notBefore: Date;
363
+ notAfter: Date;
364
+ /** Algorithm the issuer key signs with */
365
+ signatureAlgorithm: SignatureAlgorithm;
366
+ /** Marked critical. Defaults to `{ cA: false }` */
367
+ basicConstraints?: {
368
+ cA: boolean;
369
+ pathLenConstraint?: number;
370
+ };
371
+ /** Marked critical. Defaults to `['digitalSignature']`, or `['keyCertSign', 'crlSign']` for CAs */
372
+ keyUsage?: KeyUsageType[];
373
+ extendedKeyUsage?: string[];
374
+ certificatePolicies?: {
375
+ oid: string;
376
+ cpsUris?: string[];
377
+ }[];
378
+ subjectAlternativeNames?: SubjectAlternativeNamesInput;
379
+ crlDistributionPoints?: string[];
380
+ ocspUrls?: string[];
381
+ caIssuersUrls?: string[];
382
+ /** QCStatements; QcCompliance is always included when set */
383
+ qcStatements?: {
384
+ qcTypes?: QcType[];
385
+ qcSSCD?: boolean;
386
+ pds?: {
387
+ url: string;
388
+ language: string;
389
+ }[];
390
+ legislationCountries?: string[];
391
+ };
392
+ /** Adds a subject key identifier (and the authority key identifier of self-signed certificates) */
393
+ hasher?: KeyIdentifierHasher;
394
+ /** Additional extensions, appended as-is */
395
+ extensions?: X509Extension[];
396
+ }
397
+ /** The to-be-signed bytes of a certificate or CRL, plus what is needed to assemble it */
398
+ interface PreparedSignedStructure {
399
+ tbs: Uint8Array;
400
+ signatureAlgorithm: SignatureAlgorithm;
401
+ /** Public key of the signer, used to encode ECDSA signatures */
402
+ signerPublicKey: ParsedPublicKey;
403
+ }
404
+ interface SignOptions {
405
+ signer: TbsSigner;
406
+ /** Encoding of ECDSA signatures returned by the signer; defaults to `ieee-p1363` (WebCrypto) */
407
+ signatureEncoding?: SignatureEncoding;
408
+ }
409
+ interface CrlTemplate {
410
+ /** Certificate of the CRL issuer */
411
+ issuerCertificate: CertificateInput;
412
+ thisUpdate: Date;
413
+ nextUpdate: Date;
414
+ /** Monotonically increasing CRL number (RFC 5280 clause 5.2.3) */
415
+ crlNumber: bigint | number;
416
+ signatureAlgorithm: SignatureAlgorithm;
417
+ revokedCertificates?: {
418
+ serialNumber: Uint8Array | string;
419
+ revocationDate: Date;
420
+ reason?: CrlReason;
421
+ invalidityDate?: Date;
422
+ }[];
423
+ /** Scope of the CRL; marked critical */
424
+ issuingDistributionPoint?: {
425
+ distributionPointUris?: string[];
426
+ onlyContainsUserCerts?: boolean;
427
+ onlyContainsCACerts?: boolean;
428
+ };
429
+ /** Additional CRL extensions, appended as-is */
430
+ extensions?: X509Extension[];
431
+ }
432
+ type RevocationStatus = {
433
+ status: 'good';
434
+ } | {
435
+ status: 'revoked';
436
+ revocationDate: Date;
437
+ reason?: CrlReason;
438
+ invalidityDate?: Date;
439
+ } | {
440
+ status: 'unknown';
441
+ reason: RevocationUnknownReason;
442
+ message: string;
443
+ };
444
+ type RevocationUnknownReason = 'issuer_mismatch' | 'crl_not_yet_valid' | 'crl_expired' | 'out_of_scope' | 'delta_crl' | 'unsupported_critical_extension' | 'invalid_signature';
445
+ interface RevocationCheckOptions {
446
+ /** Reference time for the CRL freshness check; defaults to now. `false` skips it. */
447
+ now?: Date | false;
448
+ }
449
+ //#endregion
450
+ //#region src/certificate.d.ts
451
+ /**
452
+ * Parse an X.509 certificate.
453
+ *
454
+ * Decodes the standard extensions of RFC 5280 plus QCStatements. Parsing does not verify the
455
+ * signature; use {@link verifyCertificateSignature} for that.
456
+ *
457
+ * @param input DER bytes, base64 encoded DER, or PEM
458
+ * @param options Resource limits forwarded to asn1js (`berOptions`)
459
+ * @throws X509Exception when the input is not a well-formed X.509 certificate
460
+ */
461
+ export declare function parseCertificate(input: CertificateInput, options?: IAsnParseOptions): Certificate;
462
+ //#endregion
463
+ //#region src/create.d.ts
464
+ /**
465
+ * Encode an otherName whose value is a PrintableString (or UTF8String for non-printable
466
+ * values), e.g. an `id-at-telephoneNumber` subject alternative name.
467
+ */
468
+ export declare function stringOtherName(typeId: string, value: string): {
469
+ typeId: string;
470
+ value: Uint8Array;
471
+ };
472
+ /**
473
+ * Build the TBSCertificate for a certificate template.
474
+ *
475
+ * Sign the returned `tbs` bytes with the issuer key wherever that key lives and pass the
476
+ * signature to {@link assembleCertificate}. {@link createCertificate} wraps both steps
477
+ * around a signer callback.
478
+ */
479
+ export declare function prepareCertificate(template: CertificateTemplate): Promise<PreparedSignedStructure>;
480
+ /**
481
+ * Combine a prepared TBSCertificate with the issuer signature.
482
+ *
483
+ * @param signatureEncoding Encoding of ECDSA signatures; WebCrypto produces `ieee-p1363` (default)
484
+ */
485
+ export declare function assembleCertificate(prepared: PreparedSignedStructure, signature: Uint8Array, signatureEncoding?: SignatureEncoding): Certificate;
486
+ /**
487
+ * Create an X.509 v3 certificate.
488
+ *
489
+ * The issuer key is never passed in: the `signer` callback receives the DER encoded
490
+ * TBSCertificate and returns the signature, so the key can stay in WebCrypto, a KMS or an
491
+ * HSM. Only the public key of the subject is needed; a JWK with private key material is
492
+ * rejected.
493
+ */
494
+ export declare function createCertificate(template: CertificateTemplate & SignOptions): Promise<Certificate>;
495
+ //#endregion
496
+ //#region src/crl.d.ts
497
+ interface ParseCrlOptions extends IAsnParseOptions {
498
+ /**
499
+ * Upper bound for the number of revoked certificate entries, protecting against resource
500
+ * exhaustion by untrusted input. Defaults to 100 000. Ignored when `berOptions.maxNodes`
501
+ * is set explicitly.
502
+ */
503
+ maxEntries?: number;
504
+ }
505
+ /**
506
+ * Parse an X.509 certificate revocation list (RFC 5280 clause 5).
507
+ *
508
+ * Parsing does not verify the signature; use {@link verifyCrlSignature} or {@link checkRevocation}.
509
+ *
510
+ * @param input DER bytes, base64 encoded DER, or PEM (`X509 CRL`)
511
+ * @throws X509Exception when the input is not a well-formed CRL or exceeds the size limits
512
+ */
513
+ export declare function parseCrl(input: CrlInput, options?: ParseCrlOptions): Crl;
514
+ /**
515
+ * Look up the revocation status of `certificate` in `crl`.
516
+ *
517
+ * This does **not** verify the CRL signature; use {@link checkRevocation} unless the CRL
518
+ * has already been verified. The CRL must be issued by the certificate issuer (or be an
519
+ * indirect CRL naming it), must be current, and must cover the certificate. Otherwise the
520
+ * status is `unknown` with the reason, and the caller should find a suitable CRL or fall
521
+ * back to OCSP.
522
+ */
523
+ export declare function getRevocationStatus(certificate: Certificate, crl: Crl, options?: RevocationCheckOptions): RevocationStatus;
524
+ /**
525
+ * Verify the CRL signature against `crlIssuerCertificate`, then look up the revocation
526
+ * status of `certificate` (see {@link getRevocationStatus}).
527
+ *
528
+ * The signature check is delegated to `verifier`; an invalid signature yields `unknown`
529
+ * with reason `invalid_signature`. Fetching the CRL (see `crlDistributionPoints` on the
530
+ * certificate) is up to the caller.
531
+ */
532
+ export declare function checkRevocation(options: {
533
+ certificate: Certificate;
534
+ crl: Crl;
535
+ crlIssuerCertificate: Certificate | CertificateInput;
536
+ verifier: SignatureVerifier;
537
+ now?: Date | false;
538
+ }): Promise<RevocationStatus>;
539
+ /**
540
+ * Build the TBSCertList of a v2 CRL. Sign the returned `tbs` bytes with the CRL issuer key
541
+ * and pass the signature to {@link assembleCrl}, or use {@link createCrl} with a signer.
542
+ */
543
+ export declare function prepareCrl(template: CrlTemplate): PreparedSignedStructure;
544
+ /** Combine a prepared TBSCertList with the issuer signature. */
545
+ export declare function assembleCrl(prepared: PreparedSignedStructure, signature: Uint8Array, signatureEncoding?: SignatureEncoding): Crl;
546
+ /**
547
+ * Create a v2 CRL. The CRL issuer key is never passed in: the `signer` callback receives the
548
+ * DER encoded TBSCertList and returns the signature.
549
+ */
550
+ export declare function createCrl(template: CrlTemplate & SignOptions): Promise<Crl>;
551
+ //#endregion
552
+ //#region src/der.d.ts
553
+ /** Convert an IEEE P1363 (r || s) ECDSA signature to DER. */
554
+ export declare function ecdsaP1363ToDer(signature: Uint8Array, coordinateLength: number): Uint8Array;
555
+ /** Convert a DER ECDSA signature to IEEE P1363 (r || s). */
556
+ export declare function ecdsaDerToP1363(signature: Uint8Array, coordinateLength: number): Uint8Array;
557
+ /**
558
+ * Convert a public JWK to a DER SubjectPublicKeyInfo. Refuses private keys: only the
559
+ * public part of the wallet-relying party key is needed to issue its certificate.
560
+ */
561
+ export declare function publicJwkToSpki(jwk: JsonWebKey): Uint8Array;
562
+ //#endregion
563
+ //#region src/extensions.d.ts
564
+ /** Telephone numbers from otherName entries with type-id id-at-telephoneNumber */
565
+ export declare function telephoneNumbers(names: SubjectAlternativeNames): string[];
566
+ //#endregion
567
+ //#region src/signature.d.ts
568
+ /**
569
+ * Combine prepared to-be-signed bytes with their signature into the DER encoding of the
570
+ * signed structure: `SEQUENCE { tbs, signatureAlgorithm, BIT STRING signature }`.
571
+ */
572
+ export declare function assembleSignedStructure(prepared: PreparedSignedStructure, signature: Uint8Array, signatureEncoding?: SignatureEncoding): Uint8Array;
573
+ /**
574
+ * Verify that `certificate` was signed by the key of `issuerCertificate`.
575
+ *
576
+ * The issuer name and, when both are present, the authority / subject key identifiers must
577
+ * match. The cryptographic check is delegated to `verifier`, so no global crypto is needed:
578
+ * with WebCrypto, import `publicKey.jwk` and verify `signatureP1363` over `data`.
579
+ *
580
+ * This checks a single link, not a path to a trust anchor.
581
+ */
582
+ export declare function verifyCertificateSignature(certificate: Certificate | CertificateInput, issuerCertificate: Certificate | CertificateInput, verifier: SignatureVerifier): Promise<boolean>;
583
+ /**
584
+ * Verify that `crl` was signed by `issuerCertificate`.
585
+ *
586
+ * The CRL issuer name and, when both are present, the key identifiers must match, and the
587
+ * issuer key usage (if present) must allow cRLSign (RFC 5280 clause 6.3.3).
588
+ */
589
+ export declare function verifyCrlSignature(crl: Crl, issuerCertificate: Certificate | CertificateInput, verifier: SignatureVerifier): Promise<boolean>;
590
+ //#endregion
591
+ //#region src/x509-exception.d.ts
592
+ /**
593
+ * X509Exception is thrown when a certificate or CRL cannot be parsed or created.
594
+ */
595
+ export declare class X509Exception extends IdentityException {
596
+ constructor(message: string, details?: unknown);
597
+ }
598
+ //#endregion
599
+ export type { AttributeName, Certificate, CertificateInput, CertificatePolicyInformation, CertificateTemplate, Crl, CrlInput, CrlReason, CrlTemplate, DerInput, DistinguishedName, DistinguishedNameAttribute, IssuingDistributionPoint, KeyIdentifierHasher, KeyUsageType, NameAttributeInput, OtherNameValue, ParseCrlOptions, ParsedPublicKey, PreparedSignedStructure, QcStatements, QcType, RevocationCheckOptions, RevocationStatus, RevocationUnknownReason, RevokedCertificate, SignOptions, SignatureAlgorithm, SignatureEncoding, SignatureVerificationInput, SignatureVerifier, SubjectAlternativeNames, SubjectAlternativeNamesInput, TbsSigner, X509Extension };
600
+ //# sourceMappingURL=index.d.mts.map