micro509 0.18.0 → 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 (99) hide show
  1. package/CHANGELOG.md +88 -1
  2. package/dist/crypto/crypto.d.ts +11 -2
  3. package/dist/crypto/crypto.js +30 -17
  4. package/dist/crypto/crypto.js.map +1 -1
  5. package/dist/crypto.d.ts +2 -2
  6. package/dist/der/der.js.map +1 -1
  7. package/dist/index.d.ts +6 -5
  8. package/dist/internal/asn1/asn1.js +10 -2
  9. package/dist/internal/asn1/asn1.js.map +1 -1
  10. package/dist/internal/asn1/ber.js.map +1 -1
  11. package/dist/internal/asn1/decode-refusal.js.map +1 -1
  12. package/dist/internal/asn1/der.js.map +1 -1
  13. package/dist/internal/asn1/oids.js.map +1 -1
  14. package/dist/internal/crypto/algorithm-names.js.map +1 -1
  15. package/dist/internal/crypto/ecdsa.js.map +1 -1
  16. package/dist/internal/crypto/hash.js.map +1 -1
  17. package/dist/internal/crypto/pbes2.js.map +1 -1
  18. package/dist/internal/crypto/prime-ec.js.map +1 -1
  19. package/dist/internal/crypto/rsa-pss.js.map +1 -1
  20. package/dist/internal/crypto/sig-verify.d.ts +40 -0
  21. package/dist/internal/crypto/sig-verify.js +152 -65
  22. package/dist/internal/crypto/sig-verify.js.map +1 -1
  23. package/dist/internal/crypto/signing.js.map +1 -1
  24. package/dist/internal/jose/base64url.js.map +1 -1
  25. package/dist/internal/jose/json-data.js.map +1 -1
  26. package/dist/internal/jose/strict-json.js.map +1 -1
  27. package/dist/internal/shared/base64.js.map +1 -1
  28. package/dist/internal/shared/dn.js.map +1 -1
  29. package/dist/internal/shared/idna.js.map +1 -1
  30. package/dist/internal/shared/ip.js.map +1 -1
  31. package/dist/internal/shared/mailbox.js.map +1 -1
  32. package/dist/internal/shared/punycode.js.map +1 -1
  33. package/dist/internal/shared/uri-host.js.map +1 -1
  34. package/dist/internal/verify/name-constraints-engine.js.map +1 -1
  35. package/dist/internal/verify/policy-engine.js.map +1 -1
  36. package/dist/internal/verify/spki-distrust.js.map +1 -1
  37. package/dist/internal/verify/verify-path.js +222 -116
  38. package/dist/internal/verify/verify-path.js.map +1 -1
  39. package/dist/internal/x509/directory-name.js.map +1 -1
  40. package/dist/internal/x509/extension-bits.js.map +1 -1
  41. package/dist/internal/x509/extension-errors.js.map +1 -1
  42. package/dist/internal/x509/extension-registry.js.map +1 -1
  43. package/dist/internal/x509/general-name-profile.js.map +1 -1
  44. package/dist/internal/x509/general-name.js.map +1 -1
  45. package/dist/internal/x509/name-fields.js.map +1 -1
  46. package/dist/internal/x509/or-address.js.map +1 -1
  47. package/dist/jose/base64url.js.map +1 -1
  48. package/dist/jose/errors.js.map +1 -1
  49. package/dist/jose/jwe.js.map +1 -1
  50. package/dist/jose/jwks.js.map +1 -1
  51. package/dist/jose/jws.js.map +1 -1
  52. package/dist/jose/jwt.js.map +1 -1
  53. package/dist/jose/remote-jwks.js.map +1 -1
  54. package/dist/kdf/argon2-arithmetic.js.map +1 -1
  55. package/dist/kdf/argon2-core.js.map +1 -1
  56. package/dist/kdf/argon2-memory.js.map +1 -1
  57. package/dist/kdf/argon2-portable.js.map +1 -1
  58. package/dist/kdf/argon2.js.map +1 -1
  59. package/dist/keys/keys.js.map +1 -1
  60. package/dist/pem/pem.js.map +1 -1
  61. package/dist/pkcs/pfx.js.map +1 -1
  62. package/dist/pkcs/pkcs12-mac.js +1 -1
  63. package/dist/pkcs/pkcs12-mac.js.map +1 -1
  64. package/dist/pkcs/pkcs7.d.ts +10 -0
  65. package/dist/pkcs/pkcs7.js +106 -88
  66. package/dist/pkcs/pkcs7.js.map +1 -1
  67. package/dist/result/result.js.map +1 -1
  68. package/dist/revocation/chain.d.ts +67 -13
  69. package/dist/revocation/chain.js +429 -301
  70. package/dist/revocation/chain.js.map +1 -1
  71. package/dist/revocation/crl.d.ts +65 -11
  72. package/dist/revocation/crl.js +492 -202
  73. package/dist/revocation/crl.js.map +1 -1
  74. package/dist/revocation/ocsp.d.ts +79 -24
  75. package/dist/revocation/ocsp.js +417 -231
  76. package/dist/revocation/ocsp.js.map +1 -1
  77. package/dist/revocation/revocation.d.ts +68 -13
  78. package/dist/revocation/revocation.js +194 -73
  79. package/dist/revocation/revocation.js.map +1 -1
  80. package/dist/revocation.d.ts +4 -4
  81. package/dist/ssh/ssh.js.map +1 -1
  82. package/dist/ssh/wire.js.map +1 -1
  83. package/dist/verify/identity.d.ts +2 -2
  84. package/dist/verify/identity.js +2 -2
  85. package/dist/verify/identity.js.map +1 -1
  86. package/dist/verify/verify.d.ts +84 -32
  87. package/dist/verify/verify.js +221 -171
  88. package/dist/verify/verify.js.map +1 -1
  89. package/dist/verify.d.ts +3 -2
  90. package/dist/x509/certificate.js.map +1 -1
  91. package/dist/x509/csr.js.map +1 -1
  92. package/dist/x509/extensions.js.map +1 -1
  93. package/dist/x509/fingerprint.js.map +1 -1
  94. package/dist/x509/name-text.js.map +1 -1
  95. package/dist/x509/name.js.map +1 -1
  96. package/dist/x509/parse.d.ts +6 -2
  97. package/dist/x509/parse.js +121 -121
  98. package/dist/x509/parse.js.map +1 -1
  99. package/package.json +11 -11
package/CHANGELOG.md CHANGED
@@ -18,6 +18,92 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
18
 
19
19
  ## [Unreleased]
20
20
 
21
+ ## [0.19.0] - 2026-11-16
22
+
23
+ Verify signatures WebCrypto cannot run, such as DSA, with caller verifiers
24
+ across chains, CRLs, OCSP, CSRs and CMS. Revocation checking fails closed in
25
+ more places: delegated OCSP responders and CRL signers need revocation
26
+ evidence, delta CRLs are read newest first through one shared search, and a
27
+ delta CRL the attempt limits leave unread makes the status indeterminate.
28
+
29
+ ### Added
30
+
31
+ - **Caller signature verifiers.** `signatureVerifiers` maps a signature
32
+ algorithm OID to `(input) => Promise<boolean>`. Path building and
33
+ validation, `verifyCertificateChain`, CRL and OCSP verification, chain
34
+ revocation, `checkCertificateRevocation`, `verifyCertificateSigningRequest`,
35
+ `verifyPkcs7SignedData` and `verifySignature` accept it. A verifier runs only
36
+ for a signature native verification refuses, and only a resolved `true`
37
+ counts as valid. Naming a natively verified OID, a non-OID key, one OID
38
+ twice or a non-function throws `RangeError`. The input carries the RFC 5280
39
+ §6.1 working key parameters, so a DSA key without parameters inherits them
40
+ from its path ([RFC 5280 §6.1.4][rfc5280-section-6.1.4]).
41
+ [#14](https://github.com/kjanat/micro509/issues/14)
42
+ - Parsed certificates, CSRs, CRLs and OCSP responses keep a signature's unused
43
+ bit count as `signatureValueUnusedBits`. Native verification fails a
44
+ non-zero count as `signature_invalid`.
45
+ - `checkChainRevocation` takes `trustAnchor`, `distrustedSpkiSha256` and
46
+ `policy.crlSignerSelfEvidence` (`'delegated'` by default, or `'any'`).
47
+ - `unreadSupersededDeltaCrls` on `RevocationPolicy` and
48
+ `checkCertificateRevocation`, and
49
+ `responderRevocationUnreadSupersededDeltaCrls` on `validateOcspResponse`.
50
+ `'indeterminate'` is the default; `'ignore'` skips an unread delta CRL that
51
+ one already read supersedes.
52
+ - The verification guide explains peer authentication: only the transport's
53
+ proof of possession ties the leaf to a TLS peer. A recipe authenticates a
54
+ TLS client by the handshake certificate's SPKI.
55
+ [#236](https://github.com/kjanat/micro509/issues/236)
56
+
57
+ ### Changed
58
+
59
+ - `responderRevocationPolicy` defaults to `'nocheck-or-evidence'`. A delegated
60
+ OCSP responder without `id-pkix-ocsp-nocheck` or `noRevAvail` needs CRL
61
+ evidence and otherwise fails with `responder_revocation_unknown`
62
+ ([RFC 9608 §4][rfc9608-section-4]). `'honor-nocheck'` stays as an opt-in.
63
+ This changes verification defaults.
64
+ - A delegated CRL signer outside the chain needs CRLs covering every reason,
65
+ checked against the issuer its own validated path gives it, and every CA on
66
+ that path outside the chain must be good
67
+ ([RFC 5280 §6.3.3][rfc5280-section-6.3.3]).
68
+ - Chain revocation, CRL signers, delegated responders,
69
+ `checkCertificateRevocation` and `checkCertificateRevocationAgainstCrl` share
70
+ one delta CRL search. It reads applicable delta CRLs newest first, current
71
+ or not. A non-current CRL settles only a revocation other than
72
+ `certificateHold` of an unexpired certificate
73
+ ([RFC 5280 §5.3.1][rfc5280-section-5.3.1]). A delta CRL left unread by the
74
+ 4-per-base and 32-per-call limits yields `delta_crl_retry_limit_exceeded`
75
+ unless the base CRL holds a lasting revocation.
76
+ - `checkCertificateRevocation` checks each distinct complete CRL once with the
77
+ newest applicable delta CRL in its evidence, returns `skipped` with
78
+ `skipReason: 'no_rev_avail'` for a `noRevAvail` certificate, and records
79
+ `delta_crl_unusable`, `delta_crl_retry_limit_exceeded` and `malformed` in
80
+ `details.indeterminateEvidence`.
81
+ - Input that does not decode fails with `malformed` across path building,
82
+ validation, CSR, CRL, OCSP and service identity APIs, instead of a code that
83
+ names a different problem.
84
+ - A negative or non-finite `clockSkewMs` throws `RangeError`.
85
+ - Nested revocation checks share one evaluation instant when `at` is omitted.
86
+
87
+ ### Fixed
88
+
89
+ - A revoked CA directly under a bare trust anchor passed chain revocation.
90
+ - A CRL past its `nextUpdate`, over the age bound or without `nextUpdate`
91
+ reported `stale_crl` for a certificate it revoked, so soft-fail allowed it.
92
+ - Four older current clean delta CRLs could spend the attempt limit ahead of a
93
+ newer expired delta CRL revoking for keyCompromise.
94
+ - An undecodable `deltaCrl` hid a revocation in its complete CRL.
95
+ - A CRL signer outside the chain counted as good without a CRL covering it, or
96
+ under a revoked CA.
97
+ - `verifySignature` and `verifySignatureWithKey` refused a native algorithm
98
+ whose OID had a redundant leading zero.
99
+
100
+ ### Security
101
+
102
+ - Tests cover the three node-forge 1.4.1 advisories: a `pathLenConstraint`
103
+ without keyUsage, deeply nested BIT STRINGs, and non-canonical DigestInfo
104
+ with an e=3 forgery. micro509 needed no change and refuses each case.
105
+ [#256](https://github.com/kjanat/micro509/issues/256)
106
+
21
107
  ## [0.18.0] - 2026-11-14
22
108
 
23
109
  Sign and verify JWTs with RS384, RS512, ES256 and ES384, encrypt with compact
@@ -2142,7 +2228,8 @@ Initial prerelease. API may change before 1.0.
2142
2228
  - Zero runtime dependencies, WebCrypto-native, tree-shakeable subpath exports;
2143
2229
  runs on Node, Bun, Deno, browsers, and Cloudflare Workers.
2144
2230
 
2145
- [Unreleased]: https://github.com/kjanat/micro509/compare/v0.18.0...HEAD
2231
+ [Unreleased]: https://github.com/kjanat/micro509/compare/v0.19.0...HEAD
2232
+ [0.19.0]: https://github.com/kjanat/micro509/compare/v0.18.0...v0.19.0
2146
2233
  [0.18.0]: https://github.com/kjanat/micro509/compare/v0.17.1...v0.18.0
2147
2234
  [0.17.1]: https://github.com/kjanat/micro509/compare/v0.17.0...v0.17.1
2148
2235
  [0.17.0]: https://github.com/kjanat/micro509/compare/v0.16.0...v0.17.0
@@ -1,4 +1,4 @@
1
- import { VerifySignatureConfigFailure, VerifySignedDataFailure, VerifySignedDataResult, VerifySignedDataSuccess } from "../internal/crypto/sig-verify.js";
1
+ import { SignatureVerifier, SignatureVerifierInput, SignatureVerifiers, VerifySignatureConfigFailure, VerifySignedDataFailure, VerifySignedDataResult, VerifySignedDataSuccess } from "../internal/crypto/sig-verify.js";
2
2
  import { SignatureProfileInput } from "../internal/crypto/signing.js";
3
3
  import { EcNamedCurve } from "../keys/keys.js";
4
4
  /** Failure: the signature algorithm parameters exceed a micro509 decoding limit. */
@@ -34,6 +34,15 @@ export interface VerifySignatureInput {
34
34
  readonly signature: Uint8Array;
35
35
  /** The exact bytes the signature covers. */
36
36
  readonly data: Uint8Array;
37
+ /**
38
+ * Caller verifiers for signature algorithms micro509 does not verify through
39
+ * WebCrypto, keyed by dotted-decimal signature algorithm OID. One runs only
40
+ * where the result would otherwise be
41
+ * `unsupported_signature_algorithm_parameters`, with the parameters in
42
+ * `signerSpkiDer`. A key that micro509 verifies natively, a key that is no OID,
43
+ * or a value that is no function throws `RangeError`.
44
+ */
45
+ readonly signatureVerifiers?: SignatureVerifiers;
37
46
  }
38
47
  /** Input for {@linkcode verifySignatureWithKey}. */
39
48
  export interface VerifySignatureWithKeyInput {
@@ -100,4 +109,4 @@ export declare function ecdsaSignatureDerToRaw(signature: Uint8Array, curve: EcN
100
109
  * Throws when the input length does not match the curve.
101
110
  */
102
111
  export declare function ecdsaSignatureRawToDer(signature: Uint8Array, curve: EcNamedCurve): Uint8Array;
103
- export type { SignatureProfileInput, VerifySignatureConfigFailure, VerifySignedDataFailure, VerifySignedDataResult, VerifySignedDataSuccess };
112
+ export type { SignatureProfileInput, SignatureVerifier, SignatureVerifierInput, SignatureVerifiers, VerifySignatureConfigFailure, VerifySignedDataFailure, VerifySignedDataResult, VerifySignedDataSuccess };
@@ -1,7 +1,8 @@
1
- import { DECODE_LIMIT_CODES as e, decodeRefusalOf as t } from "../internal/asn1/decode-refusal.js";
2
- import { derEcdsaSignatureToRaw as n, rawEcdsaSignatureToDer as r } from "../internal/crypto/ecdsa.js";
3
- import { verifySignedDataDetailed as i, verifySignedDataWithKeyDetailed as a } from "../internal/crypto/sig-verify.js";
4
- import { getSignatureAlgorithm as o, signBytes as s } from "../internal/crypto/signing.js";
1
+ import { canonicalizeOid as e } from "../internal/asn1/asn1.js";
2
+ import { DECODE_LIMIT_CODES as t, decodeRefusalOf as n, rethrowDecodeRefusal as r } from "../internal/asn1/decode-refusal.js";
3
+ import { derEcdsaSignatureToRaw as i, rawEcdsaSignatureToDer as a } from "../internal/crypto/ecdsa.js";
4
+ import { callerVerification as o, verifySignedDataDetailed as s, verifySignedDataWithKeyDetailed as c } from "../internal/crypto/sig-verify.js";
5
+ import { getSignatureAlgorithm as l, signBytes as u } from "../internal/crypto/signing.js";
5
6
  // src/crypto/crypto.ts
6
7
  /**
7
8
  * Detached-signature primitives: verify a signature against a signer's SPKI or CryptoKey,
@@ -18,12 +19,12 @@ import { getSignatureAlgorithm as o, signBytes as s } from "../internal/crypto/s
18
19
  * Returns the same validity, unsupported-parameter, operational-error and decoding-limit
19
20
  * branches as {@linkcode verifySignature}.
20
21
  */
21
- async function verifySignatureWithKey(n) {
22
+ async function verifySignatureWithKey(e) {
22
23
  try {
23
- return await a(n.publicKey, n.signatureAlgorithm.oid, n.signatureAlgorithm.parametersDer, n.signature, n.data, n.signatureEncoding);
24
- } catch (n) {
25
- let r = t(n, e);
26
- if (r === void 0) throw n;
24
+ return await c(e.publicKey, canonicalSignatureOid(e.signatureAlgorithm.oid), e.signatureAlgorithm.parametersDer, e.signature, e.data, e.signatureEncoding);
25
+ } catch (e) {
26
+ let r = n(e, t);
27
+ if (r === void 0) throw e;
27
28
  return {
28
29
  ok: !1,
29
30
  code: r.code,
@@ -32,6 +33,18 @@ async function verifySignatureWithKey(n) {
32
33
  }
33
34
  }
34
35
  /**
36
+ * `oid` in its canonical spelling, so dispatch and the caller verifier lookup
37
+ * compare OIDs canonically. A string that is no OID stays as given, and
38
+ * dispatch refuses it.
39
+ */
40
+ function canonicalSignatureOid(n) {
41
+ try {
42
+ return e(n);
43
+ } catch (e) {
44
+ return r(e, t), n;
45
+ }
46
+ }
47
+ /**
35
48
  * Verifies a detached signature against the signer's DER `SubjectPublicKeyInfo`.
36
49
  *
37
50
  * Supports RSA PKCS#1 v1.5 (SHA-256/384/512), RSA-PSS with parsed parameters,
@@ -42,12 +55,12 @@ async function verifySignatureWithKey(n) {
42
55
  * `unsupported_signature_algorithm_parameters`, `verification_error` or
43
56
  * `limit_exceeded` failures otherwise.
44
57
  */
45
- async function verifySignature(n) {
58
+ async function verifySignature(e) {
46
59
  try {
47
- return await i(n.signatureAlgorithm.oid, n.signatureAlgorithm.parametersDer, n.publicKeyAlgorithm.oid, n.publicKeyAlgorithm.parametersOid, n.signerSpkiDer, n.signature, n.data);
48
- } catch (n) {
49
- let r = t(n, e);
50
- if (r === void 0) throw n;
60
+ return await s(canonicalSignatureOid(e.signatureAlgorithm.oid), e.signatureAlgorithm.parametersDer, e.publicKeyAlgorithm.oid, e.publicKeyAlgorithm.parametersOid, e.signerSpkiDer, e.signature, 0, e.data, o(e.signatureVerifiers));
61
+ } catch (e) {
62
+ let r = n(e, t);
63
+ if (r === void 0) throw e;
51
64
  return {
52
65
  ok: !1,
53
66
  code: r.code,
@@ -65,7 +78,7 @@ async function verifySignature(n) {
65
78
  * signatures are returned DER-encoded. Throws on unsupported key algorithms.
66
79
  */
67
80
  async function signData(e, t, n) {
68
- let r = o(e, n), i = await s(e, r, t);
81
+ let r = l(e, n), i = await u(e, r, t);
69
82
  return r.parameters === void 0 ? {
70
83
  signature: i,
71
84
  algorithmOid: r.algorithmOid
@@ -81,7 +94,7 @@ async function signData(e, t, n) {
81
94
  * Throws on malformed DER or integers too large for the curve.
82
95
  */
83
96
  function ecdsaSignatureDerToRaw(e, t) {
84
- return n(e, ecdsaPartLength(t));
97
+ return i(e, ecdsaPartLength(t));
85
98
  }
86
99
  /**
87
100
  * Converts a fixed-width raw `r || s` ECDSA signature to the DER
@@ -89,7 +102,7 @@ function ecdsaSignatureDerToRaw(e, t) {
89
102
  * Throws when the input length does not match the curve.
90
103
  */
91
104
  function ecdsaSignatureRawToDer(e, t) {
92
- return r(e, ecdsaPartLength(t));
105
+ return a(e, ecdsaPartLength(t));
93
106
  }
94
107
  /** Byte width of one ECDSA signature integer for the given curve. */
95
108
  function ecdsaPartLength(e) {
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.js","names":["_exhaustive","verifySignedDataWithKeyDetailed","input","error","refusal","decodeRefusalOf","DECODE_LIMIT_CODES","verifySignedDataDetailed","algorithm","getSignatureAlgorithm","privateKey","profile","signature","signBytes","data","derEcdsaSignatureToRaw","curve","rawEcdsaSignatureToDer"],"sources":["../../src/crypto/crypto.ts"],"sourcesContent":["/**\n * Detached-signature primitives: verify a signature against a signer's SPKI or CryptoKey,\n * sign arbitrary bytes with a WebCrypto private key, and convert ECDSA\n * signatures between DER `ECDSA-Sig-Value` and fixed-width raw encodings.\n *\n * @module\n */\n\nimport { DECODE_LIMIT_CODES, decodeRefusalOf } from '#micro509/internal/asn1/decode-refusal';\nimport { derEcdsaSignatureToRaw, rawEcdsaSignatureToDer } from '#micro509/internal/crypto/ecdsa';\nimport type { VerifySignedDataResult } from '#micro509/internal/crypto/sig-verify';\nimport {\n\tverifySignedDataDetailed,\n\tverifySignedDataWithKeyDetailed,\n} from '#micro509/internal/crypto/sig-verify';\nimport type { SignatureProfileInput } from '#micro509/internal/crypto/signing';\nimport { getSignatureAlgorithm, signBytes } from '#micro509/internal/crypto/signing';\nimport type { EcNamedCurve } from '#micro509/keys/keys';\n\nexport type {\n\tVerifySignatureConfigFailure,\n\tVerifySignedDataFailure,\n\tVerifySignedDataResult,\n\tVerifySignedDataSuccess,\n} from '#micro509/internal/crypto/sig-verify';\nexport type { SignatureProfileInput } from '#micro509/internal/crypto/signing';\n\n/** Failure: the signature algorithm parameters exceed a micro509 decoding limit. */\nexport interface VerifySignatureLimitFailure {\n\t/** Discriminant for the failure branch. */\n\treadonly ok: false;\n\t/** Machine-readable failure code. */\n\treadonly code: 'limit_exceeded';\n\t/** Human-readable description of the limit. */\n\treadonly reason: string;\n}\n\n/** Result of {@linkcode verifySignature} and {@linkcode verifySignatureWithKey}. */\nexport type VerifySignatureResult = VerifySignedDataResult | VerifySignatureLimitFailure;\n\n/** Input for {@linkcode verifySignature}. */\nexport interface VerifySignatureInput {\n\t/** DER `SubjectPublicKeyInfo` of the signer (`subjectPublicKeyInfoDer` on a parsed certificate). */\n\treadonly signerSpkiDer: Uint8Array;\n\t/** The signature algorithm as carried beside the signature. */\n\treadonly signatureAlgorithm: {\n\t\t/** Dotted-decimal signature algorithm OID. */\n\t\treadonly oid: string;\n\t\t/** DER algorithm parameters when the algorithm carries them (RSA-PSS). */\n\t\treadonly parametersDer?: Uint8Array;\n\t};\n\t/** The signer's public key algorithm as carried in its SPKI. */\n\treadonly publicKeyAlgorithm: {\n\t\t/** Dotted-decimal public key algorithm OID. */\n\t\treadonly oid: string;\n\t\t/** Named-curve or scheme parameters OID, when present. */\n\t\treadonly parametersOid?: string;\n\t};\n\t/** The signature bytes. ECDSA accepts DER or raw encoding. */\n\treadonly signature: Uint8Array;\n\t/** The exact bytes the signature covers. */\n\treadonly data: Uint8Array;\n}\n\n/** Input for {@linkcode verifySignatureWithKey}. */\nexport interface VerifySignatureWithKeyInput {\n\t/** An existing public key with verify usage; extractability is not required. */\n\treadonly publicKey: CryptoKey;\n\t/** Explicit signature OID and parameters, including RSA-PSS salt length. */\n\treadonly signatureAlgorithm: VerifySignatureInput['signatureAlgorithm'];\n\t/** ECDSA accepts raw r || s or DER; RSA and Ed25519 require raw. No encoding retry occurs. */\n\treadonly signatureEncoding: 'raw' | 'der';\n\t/** The signature bytes in the declared encoding. */\n\treadonly signature: Uint8Array;\n\t/** The exact bytes the signature covers. */\n\treadonly data: Uint8Array;\n}\n\n/**\n * Verifies a detached signature using an existing WebCrypto public key without\n * exporting or importing it. Repeated calls may reuse non-extractable keys.\n * Signature algorithms and parameters follow {@linkcode verifySignature}; RSA\n * scheme and hash must match the key. ECDSA encoding is explicit and never retried.\n * Returns the same validity, unsupported-parameter, operational-error and decoding-limit\n * branches as {@linkcode verifySignature}.\n */\nexport async function verifySignatureWithKey(\n\tinput: VerifySignatureWithKeyInput,\n): Promise<VerifySignatureResult> {\n\ttry {\n\t\treturn await verifySignedDataWithKeyDetailed(\n\t\t\tinput.publicKey,\n\t\t\tinput.signatureAlgorithm.oid,\n\t\t\tinput.signatureAlgorithm.parametersDer,\n\t\t\tinput.signature,\n\t\t\tinput.data,\n\t\t\tinput.signatureEncoding,\n\t\t);\n\t} catch (error) {\n\t\tconst refusal = decodeRefusalOf(error, DECODE_LIMIT_CODES);\n\t\tif (refusal === undefined) throw error;\n\t\treturn { ok: false, code: refusal.code, reason: refusal.message };\n\t}\n}\n\n/** Result of {@linkcode signData}: the signature plus its on-wire algorithm identity. */\nexport interface SignDataResult {\n\t/** The signature bytes. ECDSA is DER `ECDSA-Sig-Value`, everything else raw. */\n\treadonly signature: Uint8Array;\n\t/** Dotted-decimal signature algorithm OID. */\n\treadonly algorithmOid: string;\n\t/** DER algorithm parameters when the algorithm carries them (NULL for PKCS#1 v1.5, RSA-PSS params). */\n\treadonly parametersDer?: Uint8Array;\n}\n\n/**\n * Verifies a detached signature against the signer's DER `SubjectPublicKeyInfo`.\n *\n * Supports RSA PKCS#1 v1.5 (SHA-256/384/512), RSA-PSS with parsed parameters,\n * ECDSA P-256/P-384/P-521, and Ed25519. When an ECDSA signature fails to\n * verify under one encoding, the alternate DER/raw encoding is retried.\n *\n * Returns a typed union: `{ ok: true, valid }` when verification ran,\n * `unsupported_signature_algorithm_parameters`, `verification_error` or\n * `limit_exceeded` failures otherwise.\n */\nexport async function verifySignature(input: VerifySignatureInput): Promise<VerifySignatureResult> {\n\ttry {\n\t\treturn await verifySignedDataDetailed(\n\t\t\tinput.signatureAlgorithm.oid,\n\t\t\tinput.signatureAlgorithm.parametersDer,\n\t\t\tinput.publicKeyAlgorithm.oid,\n\t\t\tinput.publicKeyAlgorithm.parametersOid,\n\t\t\tinput.signerSpkiDer,\n\t\t\tinput.signature,\n\t\t\tinput.data,\n\t\t);\n\t} catch (error) {\n\t\tconst refusal = decodeRefusalOf(error, DECODE_LIMIT_CODES);\n\t\tif (refusal === undefined) {\n\t\t\tthrow error;\n\t\t}\n\t\treturn { ok: false, code: refusal.code, reason: refusal.message };\n\t}\n}\n\n/**\n * Signs `data` with a WebCrypto private key and returns the signature beside\n * the resolved `AlgorithmIdentifier` material for embedding in a signed\n * structure.\n *\n * The algorithm is inferred from the key (RSASSA-PKCS1-v1_5, ECDSA, Ed25519);\n * RSA-PSS keys require an explicit `{ kind: 'rsa-pss' }` profile. ECDSA\n * signatures are returned DER-encoded. Throws on unsupported key algorithms.\n */\nexport async function signData(\n\tprivateKey: CryptoKey,\n\tdata: Uint8Array,\n\tprofile?: SignatureProfileInput,\n): Promise<SignDataResult> {\n\tconst algorithm = getSignatureAlgorithm(privateKey, profile);\n\tconst signature = await signBytes(privateKey, algorithm, data);\n\treturn algorithm.parameters === undefined\n\t\t? { signature, algorithmOid: algorithm.algorithmOid }\n\t\t: { signature, algorithmOid: algorithm.algorithmOid, parametersDer: algorithm.parameters };\n}\n\n/**\n * Converts a DER `ECDSA-Sig-Value` (RFC 5480: SEQUENCE of INTEGERs r and s)\n * to the fixed-width raw `r || s` encoding WebCrypto and JOSE use.\n * Throws on malformed DER or integers too large for the curve.\n */\nexport function ecdsaSignatureDerToRaw(signature: Uint8Array, curve: EcNamedCurve): Uint8Array {\n\treturn derEcdsaSignatureToRaw(signature, ecdsaPartLength(curve));\n}\n\n/**\n * Converts a fixed-width raw `r || s` ECDSA signature to the DER\n * `ECDSA-Sig-Value` encoding X.509 and CMS structures embed.\n * Throws when the input length does not match the curve.\n */\nexport function ecdsaSignatureRawToDer(signature: Uint8Array, curve: EcNamedCurve): Uint8Array {\n\treturn rawEcdsaSignatureToDer(signature, ecdsaPartLength(curve));\n}\n\n/** Byte width of one ECDSA signature integer for the given curve. */\nfunction ecdsaPartLength(curve: EcNamedCurve): number {\n\tswitch (curve) {\n\t\tcase 'P-256':\n\t\t\treturn 32;\n\t\tcase 'P-384':\n\t\t\treturn 48;\n\t\tcase 'P-521':\n\t\t\treturn 66;\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = curve;\n\t\t\tthrow new Error(`Unhandled EcNamedCurve: ${String(_exhaustive)}`);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsFA,eAAsB,uBACrB,GACiC;CACjC,IAAI;EACH,OAAO,MAAMC,EACZC,EAAM,WACNA,EAAM,mBAAmB,KACzBA,EAAM,mBAAmB,eACzBA,EAAM,WACNA,EAAM,MACNA,EAAM,iBACP;CACD,SAASC,GAAO;EACf,IAAMC,IAAUC,EAAgBF,GAAOG,CAAkB;EACzD,IAAIF,MAAY,KAAA,GAAW,MAAMD;EACjC,OAAO;GAAE,IAAI;GAAO,MAAMC,EAAQ;GAAM,QAAQA,EAAQ;EAAQ;CACjE;AACD;;;;;;;;;;;;AAuBA,eAAsB,gBAAgB,GAA6D;CAClG,IAAI;EACH,OAAO,MAAMG,EACZL,EAAM,mBAAmB,KACzBA,EAAM,mBAAmB,eACzBA,EAAM,mBAAmB,KACzBA,EAAM,mBAAmB,eACzBA,EAAM,eACNA,EAAM,WACNA,EAAM,IACP;CACD,SAASC,GAAO;EACf,IAAMC,IAAUC,EAAgBF,GAAOG,CAAkB;EACzD,IAAIF,MAAY,KAAA,GACf,MAAMD;EAEP,OAAO;GAAE,IAAI;GAAO,MAAMC,EAAQ;GAAM,QAAQA,EAAQ;EAAQ;CACjE;AACD;;;;;;;;;;AAWA,eAAsB,SACrB,GACA,GACA,GAC0B;CAC1B,IAAMI,IAAYC,EAAsBC,GAAYC,CAAO,GACrDC,IAAY,MAAMC,EAAUH,GAAYF,GAAWM,CAAI;CAC7D,OAAON,EAAU,eAAe,KAAA,IAC7B;EAAE;EAAW,cAAcA,EAAU;CAAa,IAClD;EAAE;EAAW,cAAcA,EAAU;EAAc,eAAeA,EAAU;CAAW;AAC3F;;;;;;AAOA,SAAgB,uBAAuB,GAAuB,GAAiC;CAC9F,OAAOO,EAAuBH,GAAW,gBAAgBI,CAAK,CAAC;AAChE;;;;;;AAOA,SAAgB,uBAAuB,GAAuB,GAAiC;CAC9F,OAAOC,EAAuBL,GAAW,gBAAgBI,CAAK,CAAC;AAChE;;AAGA,SAAS,gBAAgB,GAA6B;CACrD,QAAQA,GAAR;EACC,KAAK,SACJ,OAAO;EACR,KAAK,SACJ,OAAO;EACR,KAAK,SACJ,OAAO;EACR,SAEC,MAAU,MAAM,2BAA2B,OAAOhB,CAAW,GAAG;CAElE;AACD"}
1
+ {"version":3,"file":"crypto.js","names":["_exhaustive","canonicalizeOid","DECODE_LIMIT_CODES","decodeRefusalOf","rethrowDecodeRefusal","derEcdsaSignatureToRaw","rawEcdsaSignatureToDer","callerVerification","verifySignedDataDetailed","verifySignedDataWithKeyDetailed","getSignatureAlgorithm","signBytes","input","error","refusal","oid","privateKey","data","profile","algorithm","signature","curve"],"sources":["../../src/crypto/crypto.ts"],"sourcesContent":["/**\n * Detached-signature primitives: verify a signature against a signer's SPKI or CryptoKey,\n * sign arbitrary bytes with a WebCrypto private key, and convert ECDSA\n * signatures between DER `ECDSA-Sig-Value` and fixed-width raw encodings.\n *\n * @module\n */\n\nimport { canonicalizeOid } from '#micro509/internal/asn1/asn1';\nimport {\n\tDECODE_LIMIT_CODES,\n\tdecodeRefusalOf,\n\trethrowDecodeRefusal,\n} from '#micro509/internal/asn1/decode-refusal';\nimport { derEcdsaSignatureToRaw, rawEcdsaSignatureToDer } from '#micro509/internal/crypto/ecdsa';\nimport type {\n\tSignatureVerifiers,\n\tVerifySignedDataResult,\n} from '#micro509/internal/crypto/sig-verify';\nimport {\n\tcallerVerification,\n\tverifySignedDataDetailed,\n\tverifySignedDataWithKeyDetailed,\n} from '#micro509/internal/crypto/sig-verify';\nimport type { SignatureProfileInput } from '#micro509/internal/crypto/signing';\nimport { getSignatureAlgorithm, signBytes } from '#micro509/internal/crypto/signing';\nimport type { EcNamedCurve } from '#micro509/keys/keys';\n\nexport type {\n\tSignatureVerifier,\n\tSignatureVerifierInput,\n\tSignatureVerifiers,\n\tVerifySignatureConfigFailure,\n\tVerifySignedDataFailure,\n\tVerifySignedDataResult,\n\tVerifySignedDataSuccess,\n} from '#micro509/internal/crypto/sig-verify';\nexport type { SignatureProfileInput } from '#micro509/internal/crypto/signing';\n\n/** Failure: the signature algorithm parameters exceed a micro509 decoding limit. */\nexport interface VerifySignatureLimitFailure {\n\t/** Discriminant for the failure branch. */\n\treadonly ok: false;\n\t/** Machine-readable failure code. */\n\treadonly code: 'limit_exceeded';\n\t/** Human-readable description of the limit. */\n\treadonly reason: string;\n}\n\n/** Result of {@linkcode verifySignature} and {@linkcode verifySignatureWithKey}. */\nexport type VerifySignatureResult = VerifySignedDataResult | VerifySignatureLimitFailure;\n\n/** Input for {@linkcode verifySignature}. */\nexport interface VerifySignatureInput {\n\t/** DER `SubjectPublicKeyInfo` of the signer (`subjectPublicKeyInfoDer` on a parsed certificate). */\n\treadonly signerSpkiDer: Uint8Array;\n\t/** The signature algorithm as carried beside the signature. */\n\treadonly signatureAlgorithm: {\n\t\t/** Dotted-decimal signature algorithm OID. */\n\t\treadonly oid: string;\n\t\t/** DER algorithm parameters when the algorithm carries them (RSA-PSS). */\n\t\treadonly parametersDer?: Uint8Array;\n\t};\n\t/** The signer's public key algorithm as carried in its SPKI. */\n\treadonly publicKeyAlgorithm: {\n\t\t/** Dotted-decimal public key algorithm OID. */\n\t\treadonly oid: string;\n\t\t/** Named-curve or scheme parameters OID, when present. */\n\t\treadonly parametersOid?: string;\n\t};\n\t/** The signature bytes. ECDSA accepts DER or raw encoding. */\n\treadonly signature: Uint8Array;\n\t/** The exact bytes the signature covers. */\n\treadonly data: Uint8Array;\n\t/**\n\t * Caller verifiers for signature algorithms micro509 does not verify through\n\t * WebCrypto, keyed by dotted-decimal signature algorithm OID. One runs only\n\t * where the result would otherwise be\n\t * `unsupported_signature_algorithm_parameters`, with the parameters in\n\t * `signerSpkiDer`. A key that micro509 verifies natively, a key that is no OID,\n\t * or a value that is no function throws `RangeError`.\n\t */\n\treadonly signatureVerifiers?: SignatureVerifiers;\n}\n\n/** Input for {@linkcode verifySignatureWithKey}. */\nexport interface VerifySignatureWithKeyInput {\n\t/** An existing public key with verify usage; extractability is not required. */\n\treadonly publicKey: CryptoKey;\n\t/** Explicit signature OID and parameters, including RSA-PSS salt length. */\n\treadonly signatureAlgorithm: VerifySignatureInput['signatureAlgorithm'];\n\t/** ECDSA accepts raw r || s or DER; RSA and Ed25519 require raw. No encoding retry occurs. */\n\treadonly signatureEncoding: 'raw' | 'der';\n\t/** The signature bytes in the declared encoding. */\n\treadonly signature: Uint8Array;\n\t/** The exact bytes the signature covers. */\n\treadonly data: Uint8Array;\n}\n\n/**\n * Verifies a detached signature using an existing WebCrypto public key without\n * exporting or importing it. Repeated calls may reuse non-extractable keys.\n * Signature algorithms and parameters follow {@linkcode verifySignature}; RSA\n * scheme and hash must match the key. ECDSA encoding is explicit and never retried.\n * Returns the same validity, unsupported-parameter, operational-error and decoding-limit\n * branches as {@linkcode verifySignature}.\n */\nexport async function verifySignatureWithKey(\n\tinput: VerifySignatureWithKeyInput,\n): Promise<VerifySignatureResult> {\n\ttry {\n\t\treturn await verifySignedDataWithKeyDetailed(\n\t\t\tinput.publicKey,\n\t\t\tcanonicalSignatureOid(input.signatureAlgorithm.oid),\n\t\t\tinput.signatureAlgorithm.parametersDer,\n\t\t\tinput.signature,\n\t\t\tinput.data,\n\t\t\tinput.signatureEncoding,\n\t\t);\n\t} catch (error) {\n\t\tconst refusal = decodeRefusalOf(error, DECODE_LIMIT_CODES);\n\t\tif (refusal === undefined) throw error;\n\t\treturn { ok: false, code: refusal.code, reason: refusal.message };\n\t}\n}\n\n/**\n * `oid` in its canonical spelling, so dispatch and the caller verifier lookup\n * compare OIDs canonically. A string that is no OID stays as given, and\n * dispatch refuses it.\n */\nfunction canonicalSignatureOid(oid: string): string {\n\ttry {\n\t\treturn canonicalizeOid(oid);\n\t} catch (error) {\n\t\trethrowDecodeRefusal(error, DECODE_LIMIT_CODES);\n\t\treturn oid;\n\t}\n}\n\n/** Result of {@linkcode signData}: the signature plus its on-wire algorithm identity. */\nexport interface SignDataResult {\n\t/** The signature bytes. ECDSA is DER `ECDSA-Sig-Value`, everything else raw. */\n\treadonly signature: Uint8Array;\n\t/** Dotted-decimal signature algorithm OID. */\n\treadonly algorithmOid: string;\n\t/** DER algorithm parameters when the algorithm carries them (NULL for PKCS#1 v1.5, RSA-PSS params). */\n\treadonly parametersDer?: Uint8Array;\n}\n\n/**\n * Verifies a detached signature against the signer's DER `SubjectPublicKeyInfo`.\n *\n * Supports RSA PKCS#1 v1.5 (SHA-256/384/512), RSA-PSS with parsed parameters,\n * ECDSA P-256/P-384/P-521, and Ed25519. When an ECDSA signature fails to\n * verify under one encoding, the alternate DER/raw encoding is retried.\n *\n * Returns a typed union: `{ ok: true, valid }` when verification ran,\n * `unsupported_signature_algorithm_parameters`, `verification_error` or\n * `limit_exceeded` failures otherwise.\n */\nexport async function verifySignature(input: VerifySignatureInput): Promise<VerifySignatureResult> {\n\ttry {\n\t\treturn await verifySignedDataDetailed(\n\t\t\tcanonicalSignatureOid(input.signatureAlgorithm.oid),\n\t\t\tinput.signatureAlgorithm.parametersDer,\n\t\t\tinput.publicKeyAlgorithm.oid,\n\t\t\tinput.publicKeyAlgorithm.parametersOid,\n\t\t\tinput.signerSpkiDer,\n\t\t\tinput.signature,\n\t\t\t0,\n\t\t\tinput.data,\n\t\t\tcallerVerification(input.signatureVerifiers),\n\t\t);\n\t} catch (error) {\n\t\tconst refusal = decodeRefusalOf(error, DECODE_LIMIT_CODES);\n\t\tif (refusal === undefined) {\n\t\t\tthrow error;\n\t\t}\n\t\treturn { ok: false, code: refusal.code, reason: refusal.message };\n\t}\n}\n\n/**\n * Signs `data` with a WebCrypto private key and returns the signature beside\n * the resolved `AlgorithmIdentifier` material for embedding in a signed\n * structure.\n *\n * The algorithm is inferred from the key (RSASSA-PKCS1-v1_5, ECDSA, Ed25519);\n * RSA-PSS keys require an explicit `{ kind: 'rsa-pss' }` profile. ECDSA\n * signatures are returned DER-encoded. Throws on unsupported key algorithms.\n */\nexport async function signData(\n\tprivateKey: CryptoKey,\n\tdata: Uint8Array,\n\tprofile?: SignatureProfileInput,\n): Promise<SignDataResult> {\n\tconst algorithm = getSignatureAlgorithm(privateKey, profile);\n\tconst signature = await signBytes(privateKey, algorithm, data);\n\treturn algorithm.parameters === undefined\n\t\t? { signature, algorithmOid: algorithm.algorithmOid }\n\t\t: { signature, algorithmOid: algorithm.algorithmOid, parametersDer: algorithm.parameters };\n}\n\n/**\n * Converts a DER `ECDSA-Sig-Value` (RFC 5480: SEQUENCE of INTEGERs r and s)\n * to the fixed-width raw `r || s` encoding WebCrypto and JOSE use.\n * Throws on malformed DER or integers too large for the curve.\n */\nexport function ecdsaSignatureDerToRaw(signature: Uint8Array, curve: EcNamedCurve): Uint8Array {\n\treturn derEcdsaSignatureToRaw(signature, ecdsaPartLength(curve));\n}\n\n/**\n * Converts a fixed-width raw `r || s` ECDSA signature to the DER\n * `ECDSA-Sig-Value` encoding X.509 and CMS structures embed.\n * Throws when the input length does not match the curve.\n */\nexport function ecdsaSignatureRawToDer(signature: Uint8Array, curve: EcNamedCurve): Uint8Array {\n\treturn rawEcdsaSignatureToDer(signature, ecdsaPartLength(curve));\n}\n\n/** Byte width of one ECDSA signature integer for the given curve. */\nfunction ecdsaPartLength(curve: EcNamedCurve): number {\n\tswitch (curve) {\n\t\tcase 'P-256':\n\t\t\treturn 32;\n\t\tcase 'P-384':\n\t\t\treturn 48;\n\t\tcase 'P-521':\n\t\t\treturn 66;\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = curve;\n\t\t\tthrow new Error(`Unhandled EcNamedCurve: ${String(_exhaustive)}`);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2GA,eAAsB,uBACrBY,GACiC;CACjC,IAAI;EACH,OAAO,MAAMH,EACZG,EAAM,WACN,sBAAsBA,EAAM,mBAAmB,GAAG,GAClDA,EAAM,mBAAmB,eACzBA,EAAM,WACNA,EAAM,MACNA,EAAM,iBACP;CACD,SAASC,GAAO;EACf,IAAMC,IAAUX,EAAgBU,GAAOX,CAAkB;EACzD,IAAIY,MAAY,KAAA,GAAW,MAAMD;EACjC,OAAO;GAAE,IAAI;GAAO,MAAMC,EAAQ;GAAM,QAAQA,EAAQ;EAAQ;CACjE;AACD;;;;;;AAOA,SAAS,sBAAsBC,GAAqB;CACnD,IAAI;EACH,OAAOd,EAAgBc,CAAG;CAC3B,SAASF,GAAO;EAEf,OADAT,EAAqBS,GAAOX,CAAkB,GACvCa;CACR;AACD;;;;;;;;;;;;AAuBA,eAAsB,gBAAgBH,GAA6D;CAClG,IAAI;EACH,OAAO,MAAMJ,EACZ,sBAAsBI,EAAM,mBAAmB,GAAG,GAClDA,EAAM,mBAAmB,eACzBA,EAAM,mBAAmB,KACzBA,EAAM,mBAAmB,eACzBA,EAAM,eACNA,EAAM,WACN,GACAA,EAAM,MACNL,EAAmBK,EAAM,kBAAkB,CAC5C;CACD,SAASC,GAAO;EACf,IAAMC,IAAUX,EAAgBU,GAAOX,CAAkB;EACzD,IAAIY,MAAY,KAAA,GACf,MAAMD;EAEP,OAAO;GAAE,IAAI;GAAO,MAAMC,EAAQ;GAAM,QAAQA,EAAQ;EAAQ;CACjE;AACD;;;;;;;;;;AAWA,eAAsB,SACrBE,GACAC,GACAC,GAC0B;CAC1B,IAAMC,IAAYT,EAAsBM,GAAYE,CAAO,GACrDE,IAAY,MAAMT,EAAUK,GAAYG,GAAWF,CAAI;CAC7D,OAAOE,EAAU,eAAe,KAAA,IAC7B;EAAEC;EAAW,cAAcD,EAAU;CAAa,IAClD;EAAEC;EAAW,cAAcD,EAAU;EAAc,eAAeA,EAAU;CAAW;AAC3F;;;;;;AAOA,SAAgB,uBAAuBC,GAAuBC,GAAiC;CAC9F,OAAOhB,EAAuBe,GAAW,gBAAgBC,CAAK,CAAC;AAChE;;;;;;AAOA,SAAgB,uBAAuBD,GAAuBC,GAAiC;CAC9F,OAAOf,EAAuBc,GAAW,gBAAgBC,CAAK,CAAC;AAChE;;AAGA,SAAS,gBAAgBA,GAA6B;CACrD,QAAQA,GAAR;EACC,KAAK,SACJ,OAAO;EACR,KAAK,SACJ,OAAO;EACR,KAAK,SACJ,OAAO;EACR,SAEC,MAAU,MAAM,2BAA2B,OAAOrB,CAAW,GAAG;CAElE;AACD"}
package/dist/crypto.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @module micro509/crypto
6
6
  */
7
- import { VerifySignatureConfigFailure, VerifySignedDataFailure, VerifySignedDataResult, VerifySignedDataSuccess } from "./internal/crypto/sig-verify.js";
7
+ import { SignatureVerifier, SignatureVerifierInput, SignatureVerifiers, VerifySignatureConfigFailure, VerifySignedDataFailure, VerifySignedDataResult, VerifySignedDataSuccess } from "./internal/crypto/sig-verify.js";
8
8
  import { SignatureProfileInput } from "./internal/crypto/signing.js";
9
9
  import { SignDataResult, VerifySignatureInput, VerifySignatureLimitFailure, VerifySignatureResult, VerifySignatureWithKeyInput, ecdsaSignatureDerToRaw, ecdsaSignatureRawToDer, signData, verifySignature, verifySignatureWithKey } from "./crypto/crypto.js";
10
- export { type SignDataResult, type SignatureProfileInput, type VerifySignatureConfigFailure, type VerifySignatureInput, type VerifySignatureLimitFailure, type VerifySignatureResult, type VerifySignatureWithKeyInput, type VerifySignedDataFailure, type VerifySignedDataResult, type VerifySignedDataSuccess, ecdsaSignatureDerToRaw, ecdsaSignatureRawToDer, signData, verifySignature, verifySignatureWithKey };
10
+ export { type SignDataResult, type SignatureProfileInput, type SignatureVerifier, type SignatureVerifierInput, type SignatureVerifiers, type VerifySignatureConfigFailure, type VerifySignatureInput, type VerifySignatureLimitFailure, type VerifySignatureResult, type VerifySignatureWithKeyInput, type VerifySignedDataFailure, type VerifySignedDataResult, type VerifySignedDataSuccess, ecdsaSignatureDerToRaw, ecdsaSignatureRawToDer, signData, verifySignature, verifySignatureWithKey };
@@ -1 +1 @@
1
- {"version":3,"file":"der.js","names":["successResult","decode","error","rethrowIfInvariant","decodeFailureResult","DECODE_REFUSAL_CODES","fallback","element","tag","label","readElement","bytes","offset","readRootElement","options","readSequenceChildren","childrenOf","source","parent","decodeBoolean","decodeIntegerNumber","decodeObjectIdentifier","decodeBitString","decodeString","parseTime"],"sources":["../../src/der/der.ts"],"sourcesContent":["/**\n * Element-oriented DER readers and decoders.\n *\n * Each decoder validates the element's tag before reading its value, so a\n * mis-tagged element fails instead of yielding a wrong value.\n *\n * The `OrThrow` variants throw on malformed input.\n * The plain variants return a {@linkcode DecodeDerResult}.\n *\n * @module\n */\n\nimport type { DerBitString } from '#micro509/internal/asn1/asn1';\nimport {\n\tchildrenOf,\n\tdecodeBitString,\n\tdecodeBoolean,\n\tdecodeIntegerNumber,\n\tdecodeObjectIdentifier,\n\tdecodeString,\n\tparseTime,\n} from '#micro509/internal/asn1/asn1';\nimport { DECODE_REFUSAL_CODES, decodeFailureResult } from '#micro509/internal/asn1/decode-refusal';\nimport type {\n\tDerElement,\n\tReadRootElementOptions,\n\tReadSequenceChildrenOptions,\n} from '#micro509/internal/asn1/der';\nimport { readElement, readRootElement, readSequenceChildren } from '#micro509/internal/asn1/der';\nimport type { DecodeFailureCode, ErrorResult, Micro509Error } from '#micro509/result/result';\nimport { rethrowIfInvariant, successResult } from '#micro509/result/result';\n\n/**\n * Machine-readable failure reason for the DER readers and decoders.\n *\n * `malformed` is input that breaks DER or the decoder's ASN.1 type.\n * `unsupported` is input the type may allow but micro509 does not decode: a\n * TeletexString octet outside the X.690 §8.23.5.2 initial state.\n * `limit_exceeded` is an implementation limit: an OBJECT IDENTIFIER\n * sub-identifier encoded in more than 64 octets, a tag number of 2^53 or more,\n * or DER nested deeper than 64 levels.\n */\nexport type DecodeDerErrorCode = DecodeFailureCode;\n\n/** Structured failure payload for DER reading and decoding. */\nexport interface DecodeDerFailure extends Micro509Error<DecodeDerErrorCode> {\n\t/** Always `false` for failures. */\n\treadonly ok: false;\n}\n\n/** Success-or-failure result from a DER reader or decoder. */\nexport type DecodeDerResult<TValue> =\n\t| { readonly ok: true; readonly value: TValue }\n\t| ErrorResult<DecodeDerErrorCode, Record<never, never>, DecodeDerFailure>;\n\nfunction attempt<TValue>(decode: () => TValue, fallback: string): DecodeDerResult<TValue> {\n\ttry {\n\t\treturn successResult(decode());\n\t} catch (error) {\n\t\trethrowIfInvariant(error);\n\t\treturn decodeFailureResult(error, DECODE_REFUSAL_CODES, fallback);\n\t}\n}\n\nfunction requireTag(element: DerElement, tag: number, label: string): DerElement {\n\tif (element.tag !== tag) {\n\t\tthrow new Error(`Expected ${label}`);\n\t}\n\treturn element;\n}\n\n/**\n * Reads one TLV element from {@linkcode bytes} starting at {@linkcode offset}.\n *\n * @param offset Byte position of the tag octet. Defaults to 0.\n * @throws if the element is truncated, indefinite-length, or non-minimally encoded.\n */\nexport function readDerElementOrThrow(bytes: Uint8Array, offset = 0): DerElement {\n\treturn readElement(bytes, offset);\n}\n\n/**\n * Reads one TLV element from {@linkcode bytes} starting at {@linkcode offset}.\n *\n * @param offset Byte position of the tag octet. Defaults to 0.\n */\nexport function readDerElement(bytes: Uint8Array, offset = 0): DecodeDerResult<DerElement> {\n\treturn attempt(() => readDerElementOrThrow(bytes, offset), 'Malformed DER element');\n}\n\n/**\n * Reads the single top-level TLV element from {@linkcode bytes}.\n *\n * @throws if {@linkcode bytes} carries trailing data, or nesting exceeds the depth guard.\n */\nexport function readDerRootOrThrow(\n\tbytes: Uint8Array,\n\toptions?: ReadRootElementOptions,\n): DerElement {\n\treturn readRootElement(bytes, options);\n}\n\n/** Reads the single top-level TLV element from {@linkcode bytes}. */\nexport function readDerRoot(\n\tbytes: Uint8Array,\n\toptions?: ReadRootElementOptions,\n): DecodeDerResult<DerElement> {\n\treturn attempt(() => readDerRootOrThrow(bytes, options), 'Malformed DER element');\n}\n\n/**\n * Reads a DER-encoded SEQUENCE from {@linkcode bytes} and returns its direct children.\n *\n * @throws if the root element is not a SEQUENCE, or if child boundaries are inconsistent.\n */\nexport function readDerSequenceOrThrow(\n\tbytes: Uint8Array,\n\toptions?: ReadSequenceChildrenOptions,\n): DerElement[] {\n\treturn readSequenceChildren(bytes, options);\n}\n\n/** Reads a DER-encoded SEQUENCE from {@linkcode bytes} and returns its direct children. */\nexport function readDerSequence(\n\tbytes: Uint8Array,\n\toptions?: ReadSequenceChildrenOptions,\n): DecodeDerResult<DerElement[]> {\n\treturn attempt(() => readDerSequenceOrThrow(bytes, options), 'Malformed DER sequence');\n}\n\n/**\n * Reads the direct children of a constructed {@linkcode parent} within {@linkcode source}.\n *\n * @throws if a child overflows {@linkcode parent}, or data is left between the last child and its end.\n */\nexport function derChildrenOrThrow(source: Uint8Array, parent: DerElement): DerElement[] {\n\treturn childrenOf(source, parent);\n}\n\n/** Reads the direct children of a constructed {@linkcode parent} within {@linkcode source}. */\nexport function derChildren(source: Uint8Array, parent: DerElement): DecodeDerResult<DerElement[]> {\n\treturn attempt(() => derChildrenOrThrow(source, parent), 'Malformed DER container');\n}\n\n/**\n * Decodes a BOOLEAN element (tag `0x01`).\n *\n * @throws if {@linkcode element} is mis-tagged, or holds anything but `0x00` or `0xff`.\n */\nexport function decodeDerBooleanOrThrow(element: DerElement): boolean {\n\treturn decodeBoolean(requireTag(element, 0x01, 'BOOLEAN').value);\n}\n\n/** Decodes a BOOLEAN element (tag `0x01`). */\nexport function decodeDerBoolean(element: DerElement): DecodeDerResult<boolean> {\n\treturn attempt(() => decodeDerBooleanOrThrow(element), 'Malformed BOOLEAN');\n}\n\n/**\n * Decodes an INTEGER element (tag `0x02`) into a `number`.\n *\n * @throws if {@linkcode element} is mis-tagged, negative, non-minimally encoded,\n * or exceeds {@linkcode Number.MAX_SAFE_INTEGER}.\n */\nexport function decodeDerIntegerOrThrow(element: DerElement): number {\n\treturn decodeIntegerNumber(requireTag(element, 0x02, 'INTEGER').value);\n}\n\n/** Decodes an INTEGER element (tag `0x02`) into a `number`. */\nexport function decodeDerInteger(element: DerElement): DecodeDerResult<number> {\n\treturn attempt(() => decodeDerIntegerOrThrow(element), 'Malformed INTEGER');\n}\n\n/**\n * Decodes an OCTET STRING element (tag `0x04`) into its payload bytes.\n *\n * @throws if {@linkcode element} is mis-tagged.\n */\nexport function decodeDerOctetStringOrThrow(element: DerElement): Uint8Array {\n\treturn requireTag(element, 0x04, 'OCTET STRING').value;\n}\n\n/** Decodes an OCTET STRING element (tag `0x04`) into its payload bytes. */\nexport function decodeDerOctetString(element: DerElement): DecodeDerResult<Uint8Array> {\n\treturn attempt(() => decodeDerOctetStringOrThrow(element), 'Malformed OCTET STRING');\n}\n\n/**\n * Decodes an OBJECT IDENTIFIER element (tag `0x06`) into dotted-decimal form.\n *\n * @throws if {@linkcode element} is mis-tagged, or holds a malformed sub-identifier.\n */\nexport function decodeDerOidOrThrow(element: DerElement): string {\n\treturn decodeObjectIdentifier(requireTag(element, 0x06, 'OBJECT IDENTIFIER').value);\n}\n\n/** Decodes an OBJECT IDENTIFIER element (tag `0x06`) into dotted-decimal form. */\nexport function decodeDerOid(element: DerElement): DecodeDerResult<string> {\n\treturn attempt(() => decodeDerOidOrThrow(element), 'Malformed OBJECT IDENTIFIER');\n}\n\n/**\n * Decodes a BIT STRING element (tag `0x03`) into a {@linkcode DerBitString}.\n *\n * Unused trailing bits are returned as encoded, with a violation of {@linkcode https://www.itu.int/rec/T-REC-X.690-202102-I/en | X.690 §11.2.1} reported\n * through {@linkcode DerBitString.nonZeroPadding}, since certificates in the wild carry them.\n *\n * @throws if {@linkcode element} is mis-tagged, or claims more than seven unused bits.\n */\nexport function decodeDerBitStringOrThrow(element: DerElement): DerBitString {\n\treturn decodeBitString(element);\n}\n\n/**\n * Decodes a BIT STRING element (tag `0x03`) into a {@linkcode DerBitString}.\n *\n * Unused trailing bits are returned as encoded, with a violation of {@linkcode https://www.itu.int/rec/T-REC-X.690-202102-I/en | X.690 §11.2.1} reported\n * through {@linkcode DerBitString.nonZeroPadding}, since certificates in the wild carry them.\n */\nexport function decodeDerBitString(element: DerElement): DecodeDerResult<DerBitString> {\n\treturn attempt(() => decodeDerBitStringOrThrow(element), 'Malformed BIT STRING');\n}\n\n/**\n * Decodes a string element into text, dispatching on its tag.\n *\n * Supports UTF8String, PrintableString, TeletexString, IA5String, UniversalString, and BMPString.\n * A TeletexString decodes only in its X.690 §8.23.5.2 initial state.\n *\n * @throws on every other string tag, and on a TeletexString octet outside that state.\n */\nexport function decodeDerStringOrThrow(element: DerElement): string {\n\treturn decodeString(element.tag, element.value);\n}\n\n/**\n * Decodes a string element into text, dispatching on its tag.\n *\n * Supports UTF8String, PrintableString, TeletexString, IA5String, UniversalString, and BMPString.\n * A TeletexString decodes only in its X.690 §8.23.5.2 initial state.\n */\nexport function decodeDerString(element: DerElement): DecodeDerResult<string> {\n\treturn attempt(() => decodeDerStringOrThrow(element), 'Malformed string');\n}\n\n/**\n * Decodes a UTCTime (tag `0x17`) or GeneralizedTime (tag `0x18`) element into a {@linkcode Date}.\n *\n * @throws if {@linkcode element} carries any other tag, or a malformed time value.\n */\nexport function decodeDerTimeOrThrow(element: DerElement): Date {\n\treturn parseTime(element);\n}\n\n/** Decodes a UTCTime (tag `0x17`) or GeneralizedTime (tag `0x18`) element into a {@linkcode Date}. */\nexport function decodeDerTime(element: DerElement): DecodeDerResult<Date> {\n\treturn attempt(() => decodeDerTimeOrThrow(element), 'Malformed time');\n}\n"],"mappings":";;;;;AAuDA,SAAS,QAAgB,GAAsB,GAA2C;CACzF,IAAI;EACH,OAAOA,EAAcC,EAAO,CAAC;CAC9B,SAASC,GAAO;EAEf,OADAC,EAAmBD,CAAK,GACjBE,EAAoBF,GAAOG,GAAsBC,CAAQ;CACjE;AACD;AAEA,SAAS,WAAW,GAAqB,GAAa,GAA2B;CAChF,IAAIC,EAAQ,QAAQC,GACnB,MAAU,MAAM,YAAYC,GAAO;CAEpC,OAAOF;AACR;;;;;;;AAQA,SAAgB,sBAAsB,GAAmB,IAAS,GAAe;CAChF,OAAOG,EAAYC,GAAOC,CAAM;AACjC;;;;;;AAOA,SAAgB,eAAe,GAAmB,IAAS,GAAgC;CAC1F,OAAO,cAAc,sBAAsBD,GAAOC,CAAM,GAAG,uBAAuB;AACnF;;;;;;AAOA,SAAgB,mBACf,GACA,GACa;CACb,OAAOC,EAAgBF,GAAOG,CAAO;AACtC;;AAGA,SAAgB,YACf,GACA,GAC8B;CAC9B,OAAO,cAAc,mBAAmBH,GAAOG,CAAO,GAAG,uBAAuB;AACjF;;;;;;AAOA,SAAgB,uBACf,GACA,GACe;CACf,OAAOC,EAAqBJ,GAAOG,CAAO;AAC3C;;AAGA,SAAgB,gBACf,GACA,GACgC;CAChC,OAAO,cAAc,uBAAuBH,GAAOG,CAAO,GAAG,wBAAwB;AACtF;;;;;;AAOA,SAAgB,mBAAmB,GAAoB,GAAkC;CACxF,OAAOE,EAAWC,GAAQC,CAAM;AACjC;;AAGA,SAAgB,YAAY,GAAoB,GAAmD;CAClG,OAAO,cAAc,mBAAmBD,GAAQC,CAAM,GAAG,yBAAyB;AACnF;;;;;;AAOA,SAAgB,wBAAwB,GAA8B;CACrE,OAAOC,EAAc,WAAWZ,GAAS,GAAM,SAAS,CAAC,CAAC,KAAK;AAChE;;AAGA,SAAgB,iBAAiB,GAA+C;CAC/E,OAAO,cAAc,wBAAwBA,CAAO,GAAG,mBAAmB;AAC3E;;;;;;;AAQA,SAAgB,wBAAwB,GAA6B;CACpE,OAAOa,EAAoB,WAAWb,GAAS,GAAM,SAAS,CAAC,CAAC,KAAK;AACtE;;AAGA,SAAgB,iBAAiB,GAA8C;CAC9E,OAAO,cAAc,wBAAwBA,CAAO,GAAG,mBAAmB;AAC3E;;;;;;AAOA,SAAgB,4BAA4B,GAAiC;CAC5E,OAAO,WAAWA,GAAS,GAAM,cAAc,CAAC,CAAC;AAClD;;AAGA,SAAgB,qBAAqB,GAAkD;CACtF,OAAO,cAAc,4BAA4BA,CAAO,GAAG,wBAAwB;AACpF;;;;;;AAOA,SAAgB,oBAAoB,GAA6B;CAChE,OAAOc,EAAuB,WAAWd,GAAS,GAAM,mBAAmB,CAAC,CAAC,KAAK;AACnF;;AAGA,SAAgB,aAAa,GAA8C;CAC1E,OAAO,cAAc,oBAAoBA,CAAO,GAAG,6BAA6B;AACjF;;;;;;;;;AAUA,SAAgB,0BAA0B,GAAmC;CAC5E,OAAOe,EAAgBf,CAAO;AAC/B;;;;;;;AAQA,SAAgB,mBAAmB,GAAoD;CACtF,OAAO,cAAc,0BAA0BA,CAAO,GAAG,sBAAsB;AAChF;;;;;;;;;AAUA,SAAgB,uBAAuB,GAA6B;CACnE,OAAOgB,EAAahB,EAAQ,KAAKA,EAAQ,KAAK;AAC/C;;;;;;;AAQA,SAAgB,gBAAgB,GAA8C;CAC7E,OAAO,cAAc,uBAAuBA,CAAO,GAAG,kBAAkB;AACzE;;;;;;AAOA,SAAgB,qBAAqB,GAA2B;CAC/D,OAAOiB,EAAUjB,CAAO;AACzB;;AAGA,SAAgB,cAAc,GAA4C;CACzE,OAAO,cAAc,qBAAqBA,CAAO,GAAG,gBAAgB;AACrE"}
1
+ {"version":3,"file":"der.js","names":["childrenOf","decodeBitString","decodeBoolean","decodeIntegerNumber","decodeObjectIdentifier","decodeString","parseTime","decodeFailureResult","readElement","readRootElement","readSequenceChildren","DECODE_REFUSAL_CODES","rethrowIfInvariant","successResult","decode","fallback","error","element","tag","label","bytes","offset","options","source","parent"],"sources":["../../src/der/der.ts"],"sourcesContent":["/**\n * Element-oriented DER readers and decoders.\n *\n * Each decoder validates the element's tag before reading its value, so a\n * mis-tagged element fails instead of yielding a wrong value.\n *\n * The `OrThrow` variants throw on malformed input.\n * The plain variants return a {@linkcode DecodeDerResult}.\n *\n * @module\n */\n\nimport type { DerBitString } from '#micro509/internal/asn1/asn1';\nimport {\n\tchildrenOf,\n\tdecodeBitString,\n\tdecodeBoolean,\n\tdecodeIntegerNumber,\n\tdecodeObjectIdentifier,\n\tdecodeString,\n\tparseTime,\n} from '#micro509/internal/asn1/asn1';\nimport { DECODE_REFUSAL_CODES, decodeFailureResult } from '#micro509/internal/asn1/decode-refusal';\nimport type {\n\tDerElement,\n\tReadRootElementOptions,\n\tReadSequenceChildrenOptions,\n} from '#micro509/internal/asn1/der';\nimport { readElement, readRootElement, readSequenceChildren } from '#micro509/internal/asn1/der';\nimport type { DecodeFailureCode, ErrorResult, Micro509Error } from '#micro509/result/result';\nimport { rethrowIfInvariant, successResult } from '#micro509/result/result';\n\n/**\n * Machine-readable failure reason for the DER readers and decoders.\n *\n * `malformed` is input that breaks DER or the decoder's ASN.1 type.\n * `unsupported` is input the type may allow but micro509 does not decode: a\n * TeletexString octet outside the X.690 §8.23.5.2 initial state.\n * `limit_exceeded` is an implementation limit: an OBJECT IDENTIFIER\n * sub-identifier encoded in more than 64 octets, a tag number of 2^53 or more,\n * or DER nested deeper than 64 levels.\n */\nexport type DecodeDerErrorCode = DecodeFailureCode;\n\n/** Structured failure payload for DER reading and decoding. */\nexport interface DecodeDerFailure extends Micro509Error<DecodeDerErrorCode> {\n\t/** Always `false` for failures. */\n\treadonly ok: false;\n}\n\n/** Success-or-failure result from a DER reader or decoder. */\nexport type DecodeDerResult<TValue> =\n\t| { readonly ok: true; readonly value: TValue }\n\t| ErrorResult<DecodeDerErrorCode, Record<never, never>, DecodeDerFailure>;\n\nfunction attempt<TValue>(decode: () => TValue, fallback: string): DecodeDerResult<TValue> {\n\ttry {\n\t\treturn successResult(decode());\n\t} catch (error) {\n\t\trethrowIfInvariant(error);\n\t\treturn decodeFailureResult(error, DECODE_REFUSAL_CODES, fallback);\n\t}\n}\n\nfunction requireTag(element: DerElement, tag: number, label: string): DerElement {\n\tif (element.tag !== tag) {\n\t\tthrow new Error(`Expected ${label}`);\n\t}\n\treturn element;\n}\n\n/**\n * Reads one TLV element from {@linkcode bytes} starting at {@linkcode offset}.\n *\n * @param offset Byte position of the tag octet. Defaults to 0.\n * @throws if the element is truncated, indefinite-length, or non-minimally encoded.\n */\nexport function readDerElementOrThrow(bytes: Uint8Array, offset = 0): DerElement {\n\treturn readElement(bytes, offset);\n}\n\n/**\n * Reads one TLV element from {@linkcode bytes} starting at {@linkcode offset}.\n *\n * @param offset Byte position of the tag octet. Defaults to 0.\n */\nexport function readDerElement(bytes: Uint8Array, offset = 0): DecodeDerResult<DerElement> {\n\treturn attempt(() => readDerElementOrThrow(bytes, offset), 'Malformed DER element');\n}\n\n/**\n * Reads the single top-level TLV element from {@linkcode bytes}.\n *\n * @throws if {@linkcode bytes} carries trailing data, or nesting exceeds the depth guard.\n */\nexport function readDerRootOrThrow(\n\tbytes: Uint8Array,\n\toptions?: ReadRootElementOptions,\n): DerElement {\n\treturn readRootElement(bytes, options);\n}\n\n/** Reads the single top-level TLV element from {@linkcode bytes}. */\nexport function readDerRoot(\n\tbytes: Uint8Array,\n\toptions?: ReadRootElementOptions,\n): DecodeDerResult<DerElement> {\n\treturn attempt(() => readDerRootOrThrow(bytes, options), 'Malformed DER element');\n}\n\n/**\n * Reads a DER-encoded SEQUENCE from {@linkcode bytes} and returns its direct children.\n *\n * @throws if the root element is not a SEQUENCE, or if child boundaries are inconsistent.\n */\nexport function readDerSequenceOrThrow(\n\tbytes: Uint8Array,\n\toptions?: ReadSequenceChildrenOptions,\n): DerElement[] {\n\treturn readSequenceChildren(bytes, options);\n}\n\n/** Reads a DER-encoded SEQUENCE from {@linkcode bytes} and returns its direct children. */\nexport function readDerSequence(\n\tbytes: Uint8Array,\n\toptions?: ReadSequenceChildrenOptions,\n): DecodeDerResult<DerElement[]> {\n\treturn attempt(() => readDerSequenceOrThrow(bytes, options), 'Malformed DER sequence');\n}\n\n/**\n * Reads the direct children of a constructed {@linkcode parent} within {@linkcode source}.\n *\n * @throws if a child overflows {@linkcode parent}, or data is left between the last child and its end.\n */\nexport function derChildrenOrThrow(source: Uint8Array, parent: DerElement): DerElement[] {\n\treturn childrenOf(source, parent);\n}\n\n/** Reads the direct children of a constructed {@linkcode parent} within {@linkcode source}. */\nexport function derChildren(source: Uint8Array, parent: DerElement): DecodeDerResult<DerElement[]> {\n\treturn attempt(() => derChildrenOrThrow(source, parent), 'Malformed DER container');\n}\n\n/**\n * Decodes a BOOLEAN element (tag `0x01`).\n *\n * @throws if {@linkcode element} is mis-tagged, or holds anything but `0x00` or `0xff`.\n */\nexport function decodeDerBooleanOrThrow(element: DerElement): boolean {\n\treturn decodeBoolean(requireTag(element, 0x01, 'BOOLEAN').value);\n}\n\n/** Decodes a BOOLEAN element (tag `0x01`). */\nexport function decodeDerBoolean(element: DerElement): DecodeDerResult<boolean> {\n\treturn attempt(() => decodeDerBooleanOrThrow(element), 'Malformed BOOLEAN');\n}\n\n/**\n * Decodes an INTEGER element (tag `0x02`) into a `number`.\n *\n * @throws if {@linkcode element} is mis-tagged, negative, non-minimally encoded,\n * or exceeds {@linkcode Number.MAX_SAFE_INTEGER}.\n */\nexport function decodeDerIntegerOrThrow(element: DerElement): number {\n\treturn decodeIntegerNumber(requireTag(element, 0x02, 'INTEGER').value);\n}\n\n/** Decodes an INTEGER element (tag `0x02`) into a `number`. */\nexport function decodeDerInteger(element: DerElement): DecodeDerResult<number> {\n\treturn attempt(() => decodeDerIntegerOrThrow(element), 'Malformed INTEGER');\n}\n\n/**\n * Decodes an OCTET STRING element (tag `0x04`) into its payload bytes.\n *\n * @throws if {@linkcode element} is mis-tagged.\n */\nexport function decodeDerOctetStringOrThrow(element: DerElement): Uint8Array {\n\treturn requireTag(element, 0x04, 'OCTET STRING').value;\n}\n\n/** Decodes an OCTET STRING element (tag `0x04`) into its payload bytes. */\nexport function decodeDerOctetString(element: DerElement): DecodeDerResult<Uint8Array> {\n\treturn attempt(() => decodeDerOctetStringOrThrow(element), 'Malformed OCTET STRING');\n}\n\n/**\n * Decodes an OBJECT IDENTIFIER element (tag `0x06`) into dotted-decimal form.\n *\n * @throws if {@linkcode element} is mis-tagged, or holds a malformed sub-identifier.\n */\nexport function decodeDerOidOrThrow(element: DerElement): string {\n\treturn decodeObjectIdentifier(requireTag(element, 0x06, 'OBJECT IDENTIFIER').value);\n}\n\n/** Decodes an OBJECT IDENTIFIER element (tag `0x06`) into dotted-decimal form. */\nexport function decodeDerOid(element: DerElement): DecodeDerResult<string> {\n\treturn attempt(() => decodeDerOidOrThrow(element), 'Malformed OBJECT IDENTIFIER');\n}\n\n/**\n * Decodes a BIT STRING element (tag `0x03`) into a {@linkcode DerBitString}.\n *\n * Unused trailing bits are returned as encoded, with a violation of {@linkcode https://www.itu.int/rec/T-REC-X.690-202102-I/en | X.690 §11.2.1} reported\n * through {@linkcode DerBitString.nonZeroPadding}, since certificates in the wild carry them.\n *\n * @throws if {@linkcode element} is mis-tagged, or claims more than seven unused bits.\n */\nexport function decodeDerBitStringOrThrow(element: DerElement): DerBitString {\n\treturn decodeBitString(element);\n}\n\n/**\n * Decodes a BIT STRING element (tag `0x03`) into a {@linkcode DerBitString}.\n *\n * Unused trailing bits are returned as encoded, with a violation of {@linkcode https://www.itu.int/rec/T-REC-X.690-202102-I/en | X.690 §11.2.1} reported\n * through {@linkcode DerBitString.nonZeroPadding}, since certificates in the wild carry them.\n */\nexport function decodeDerBitString(element: DerElement): DecodeDerResult<DerBitString> {\n\treturn attempt(() => decodeDerBitStringOrThrow(element), 'Malformed BIT STRING');\n}\n\n/**\n * Decodes a string element into text, dispatching on its tag.\n *\n * Supports UTF8String, PrintableString, TeletexString, IA5String, UniversalString, and BMPString.\n * A TeletexString decodes only in its X.690 §8.23.5.2 initial state.\n *\n * @throws on every other string tag, and on a TeletexString octet outside that state.\n */\nexport function decodeDerStringOrThrow(element: DerElement): string {\n\treturn decodeString(element.tag, element.value);\n}\n\n/**\n * Decodes a string element into text, dispatching on its tag.\n *\n * Supports UTF8String, PrintableString, TeletexString, IA5String, UniversalString, and BMPString.\n * A TeletexString decodes only in its X.690 §8.23.5.2 initial state.\n */\nexport function decodeDerString(element: DerElement): DecodeDerResult<string> {\n\treturn attempt(() => decodeDerStringOrThrow(element), 'Malformed string');\n}\n\n/**\n * Decodes a UTCTime (tag `0x17`) or GeneralizedTime (tag `0x18`) element into a {@linkcode Date}.\n *\n * @throws if {@linkcode element} carries any other tag, or a malformed time value.\n */\nexport function decodeDerTimeOrThrow(element: DerElement): Date {\n\treturn parseTime(element);\n}\n\n/** Decodes a UTCTime (tag `0x17`) or GeneralizedTime (tag `0x18`) element into a {@linkcode Date}. */\nexport function decodeDerTime(element: DerElement): DecodeDerResult<Date> {\n\treturn attempt(() => decodeDerTimeOrThrow(element), 'Malformed time');\n}\n"],"mappings":";;;;;AAuDA,SAAS,QAAgBc,GAAsBC,GAA2C;CACzF,IAAI;EACH,OAAOF,EAAcC,EAAO,CAAC;CAC9B,SAASE,GAAO;EAEf,OADAJ,EAAmBI,CAAK,GACjBT,EAAoBS,GAAOL,GAAsBI,CAAQ;CACjE;AACD;AAEA,SAAS,WAAWE,GAAqBC,GAAaC,GAA2B;CAChF,IAAIF,EAAQ,QAAQC,GACnB,MAAU,MAAM,YAAYC,GAAO;CAEpC,OAAOF;AACR;;;;;;;AAQA,SAAgB,sBAAsBG,GAAmBC,IAAS,GAAe;CAChF,OAAOb,EAAYY,GAAOC,CAAM;AACjC;;;;;;AAOA,SAAgB,eAAeD,GAAmBC,IAAS,GAAgC;CAC1F,OAAO,cAAc,sBAAsBD,GAAOC,CAAM,GAAG,uBAAuB;AACnF;;;;;;AAOA,SAAgB,mBACfD,GACAE,GACa;CACb,OAAOb,EAAgBW,GAAOE,CAAO;AACtC;;AAGA,SAAgB,YACfF,GACAE,GAC8B;CAC9B,OAAO,cAAc,mBAAmBF,GAAOE,CAAO,GAAG,uBAAuB;AACjF;;;;;;AAOA,SAAgB,uBACfF,GACAE,GACe;CACf,OAAOZ,EAAqBU,GAAOE,CAAO;AAC3C;;AAGA,SAAgB,gBACfF,GACAE,GACgC;CAChC,OAAO,cAAc,uBAAuBF,GAAOE,CAAO,GAAG,wBAAwB;AACtF;;;;;;AAOA,SAAgB,mBAAmBC,GAAoBC,GAAkC;CACxF,OAAOxB,EAAWuB,GAAQC,CAAM;AACjC;;AAGA,SAAgB,YAAYD,GAAoBC,GAAmD;CAClG,OAAO,cAAc,mBAAmBD,GAAQC,CAAM,GAAG,yBAAyB;AACnF;;;;;;AAOA,SAAgB,wBAAwBP,GAA8B;CACrE,OAAOf,EAAc,WAAWe,GAAS,GAAM,SAAS,CAAC,CAAC,KAAK;AAChE;;AAGA,SAAgB,iBAAiBA,GAA+C;CAC/E,OAAO,cAAc,wBAAwBA,CAAO,GAAG,mBAAmB;AAC3E;;;;;;;AAQA,SAAgB,wBAAwBA,GAA6B;CACpE,OAAOd,EAAoB,WAAWc,GAAS,GAAM,SAAS,CAAC,CAAC,KAAK;AACtE;;AAGA,SAAgB,iBAAiBA,GAA8C;CAC9E,OAAO,cAAc,wBAAwBA,CAAO,GAAG,mBAAmB;AAC3E;;;;;;AAOA,SAAgB,4BAA4BA,GAAiC;CAC5E,OAAO,WAAWA,GAAS,GAAM,cAAc,CAAC,CAAC;AAClD;;AAGA,SAAgB,qBAAqBA,GAAkD;CACtF,OAAO,cAAc,4BAA4BA,CAAO,GAAG,wBAAwB;AACpF;;;;;;AAOA,SAAgB,oBAAoBA,GAA6B;CAChE,OAAOb,EAAuB,WAAWa,GAAS,GAAM,mBAAmB,CAAC,CAAC,KAAK;AACnF;;AAGA,SAAgB,aAAaA,GAA8C;CAC1E,OAAO,cAAc,oBAAoBA,CAAO,GAAG,6BAA6B;AACjF;;;;;;;;;AAUA,SAAgB,0BAA0BA,GAAmC;CAC5E,OAAOhB,EAAgBgB,CAAO;AAC/B;;;;;;;AAQA,SAAgB,mBAAmBA,GAAoD;CACtF,OAAO,cAAc,0BAA0BA,CAAO,GAAG,sBAAsB;AAChF;;;;;;;;;AAUA,SAAgB,uBAAuBA,GAA6B;CACnE,OAAOZ,EAAaY,EAAQ,KAAKA,EAAQ,KAAK;AAC/C;;;;;;;AAQA,SAAgB,gBAAgBA,GAA8C;CAC7E,OAAO,cAAc,uBAAuBA,CAAO,GAAG,kBAAkB;AACzE;;;;;;AAOA,SAAgB,qBAAqBA,GAA2B;CAC/D,OAAOX,EAAUW,CAAO;AACzB;;AAGA,SAAgB,cAAcA,GAA4C;CACzE,OAAO,cAAc,qBAAqBA,CAAO,GAAG,gBAAgB;AACrE"}
package/dist/index.d.ts CHANGED
@@ -72,16 +72,17 @@ import { CreatePfxErrorCode, CreatePfxFailure, CreatePfxInput, CreatePfxResult,
72
72
  import { CreatePkcs7CertBagErrorCode, CreatePkcs7CertBagFailure, CreatePkcs7CertBagResult, CreatePkcs7SignedDataErrorCode, CreatePkcs7SignedDataFailure, CreatePkcs7SignedDataInput, CreatePkcs7SignedDataResult, ParsePkcs7CertBagResult, ParsePkcs7ErrorCode, ParsePkcs7Failure, ParsePkcs7SignedDataResult, ParsedCertificateChoice, ParsedPkcs7SignedData, ParsedPkcs7SignerInfo, ParsedPkcs7SignerInfoBase, ParsedSignerIdentifier, Pkcs7CertBagMaterial, Pkcs7CertificateSource, Pkcs7SignedDataMaterial, Pkcs7Signer, VerifiedPkcs7Signer, VerifyPkcs7SignedDataErrorCode, VerifyPkcs7SignedDataFailure, VerifyPkcs7SignedDataOptions, VerifyPkcs7SignedDataResult, createPkcs7CertBag, createPkcs7SignedData, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, verifyPkcs7SignedData } from "./pkcs/pkcs7.js";
73
73
  import { CreatePkcs12MacDataErrorCode, ParsePkcs12MacDataErrorCode, ParsePkcs12MacDataFailure, ParsePkcs12MacDataOptions, ParsePkcs12MacDataResult, ParsedPkcs12MacData, Pkcs12MacOptions } from "./pkcs/pkcs12-mac.js";
74
74
  import { DECODE_REFUSAL_CODES, DecodeFailureCode, DecodeRefusalCode, ErrorResult, IndexedErrorResult, IndexedMicro509Error, Micro509Error, Result, ResultError, isResultError, unwrap, unwrapOr } from "./result/result.js";
75
- import { CertificateRevocationListMaterial, CheckCertificateRevocationAgainstCrlErrorCode, CheckCertificateRevocationAgainstCrlFailure, CheckCertificateRevocationAgainstCrlFailureDetails, CheckCertificateRevocationAgainstCrlGoodValue, CheckCertificateRevocationAgainstCrlInput, CheckCertificateRevocationAgainstCrlResult, CheckCertificateRevocationAgainstCrlRevokedValue, CheckCertificateRevocationAgainstCrlValue, CreateCertificateRevocationListInput, CrlApplicabilityFailureReason, CrlCertificateSource, CrlEncoderErrorCode, CrlSource, ParseCertificateRevocationListErrorCode, ParseCertificateRevocationListFailure, ParseCertificateRevocationListResult, ParsedCertificateRevocationList, ParsedRevocationReason, ParsedRevokedCertificate, RevocationReason, RevokedCertificateInput, UnrecognizedReasonCodePolicy, UnrecognizedRevocationReason, ValidateCertificateRevocationListFailure, ValidateCertificateRevocationListInput, ValidateCertificateRevocationListResult, VerifyCertificateRevocationListSignatureFailure, VerifyCertificateRevocationListSignatureResult, checkCertificateRevocationAgainstCrl, createCertificateRevocationList, isCertificateRevoked, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, revocationReasonFromCode, validateCertificateRevocationList, verifyCertificateRevocationListSignature } from "./revocation/crl.js";
75
+ import { CertificateRevocationListMaterial, CheckCertificateRevocationAgainstCrlErrorCode, CheckCertificateRevocationAgainstCrlFailure, CheckCertificateRevocationAgainstCrlFailureDetails, CheckCertificateRevocationAgainstCrlGoodValue, CheckCertificateRevocationAgainstCrlInput, CheckCertificateRevocationAgainstCrlResult, CheckCertificateRevocationAgainstCrlRevokedValue, CheckCertificateRevocationAgainstCrlValue, CreateCertificateRevocationListInput, CrlApplicabilityFailureReason, CrlCertificateSource, CrlEncoderErrorCode, CrlSource, ParseCertificateRevocationListErrorCode, ParseCertificateRevocationListFailure, ParseCertificateRevocationListResult, ParsedCertificateRevocationList, ParsedRevocationReason, ParsedRevokedCertificate, RevocationReason, RevokedCertificateInput, SupersededDeltaCrlPolicy, UnrecognizedReasonCodePolicy, UnrecognizedRevocationReason, ValidateCertificateRevocationListFailure, ValidateCertificateRevocationListInput, ValidateCertificateRevocationListResult, VerifyCertificateRevocationListSignatureFailure, VerifyCertificateRevocationListSignatureOptions, VerifyCertificateRevocationListSignatureResult, checkCertificateRevocationAgainstCrl, createCertificateRevocationList, isCertificateRevoked, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, revocationReasonFromCode, validateCertificateRevocationList, verifyCertificateRevocationListSignature } from "./revocation/crl.js";
76
76
  import { CertificateRevocationStatus, CheckChainRevocationInput, CheckChainRevocationResult, CheckChainRevocationValue, OcspResponseSource, REVOCATION_INDETERMINATE_REASONS, RevocationExecutionError, RevocationIndeterminateReason, RevocationParseError, RevocationPolicy, RevocationProcessingError, RevocationSource, TrustedOcspResponder, checkChainRevocation } from "./revocation/chain.js";
77
- import { CheckCertificateRevocationErrorCode, CheckCertificateRevocationFailureDetails, CheckCertificateRevocationInput, CheckCertificateRevocationResult, CheckCertificateRevocationValue, ConfiguredOcspResponder, ConfiguredOcspResponderCertificate, OcspResponderCandidate, OcspResponderSource, REVOCATION_INDETERMINATE_REASON_CODES, ResolveOcspResponderCandidatesInput, RevocationCertificateSource, RevocationCheckGoodValue, RevocationCheckIndeterminateValue, RevocationCheckRevokedValue, RevocationCrlEvidenceInput, RevocationEvidenceInput, RevocationEvidenceKind, RevocationIndeterminateEvidence, RevocationIndeterminateReasonCode, RevocationOcspEvidenceInput, RevocationStatus, checkCertificateRevocation, getCertificateOcspResponderUris, resolveOcspResponderCandidates } from "./revocation/revocation.js";
78
- import { CreateOcspCertStatusInput, CreateOcspRequestInput, CreateOcspRequestItemInput, CreateOcspResponseInput, CreateOcspSingleResponseInput, OcspCertStatus, OcspCertificateSource, OcspEncoderErrorCode, OcspHashAlgorithm, OcspRequestMaterial, OcspRequestSource, OcspResponderRevocationPolicy, OcspResponseMaterial, OcspResponseStatus, ParseOcspRequestErrorCode, ParseOcspRequestFailure, ParseOcspRequestResult, ParseOcspResponseErrorCode, ParseOcspResponseFailure, ParseOcspResponseResult, ParsedOcspCertId, ParsedOcspCertStatus, ParsedOcspRequest, ParsedOcspResponderId, ParsedOcspResponse, ParsedOcspSingleResponse, ValidateOcspResponseErrorCode, ValidateOcspResponseFailure, ValidateOcspResponseInput, ValidateOcspResponseResult, VerifyOcspResponseSignatureFailure, VerifyOcspResponseSignatureResult, createOcspRequest, createOcspResponse, hasOcspNoCheckExtension, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, validateOcspResponse, verifyOcspResponseSignature } from "./revocation/ocsp.js";
77
+ import { CheckCertificateRevocationErrorCode, CheckCertificateRevocationFailureDetails, CheckCertificateRevocationInput, CheckCertificateRevocationResult, CheckCertificateRevocationValue, ConfiguredOcspResponder, ConfiguredOcspResponderCertificate, OcspResponderCandidate, OcspResponderSource, REVOCATION_INDETERMINATE_REASON_CODES, ResolveOcspResponderCandidatesInput, RevocationCertificateSource, RevocationCheckGoodValue, RevocationCheckIndeterminateValue, RevocationCheckRevokedValue, RevocationCheckSkippedValue, RevocationCrlEvidenceInput, RevocationEvidenceInput, RevocationEvidenceKind, RevocationIndeterminateEvidence, RevocationIndeterminateReasonCode, RevocationOcspEvidenceInput, RevocationStatus, checkCertificateRevocation, getCertificateOcspResponderUris, resolveOcspResponderCandidates } from "./revocation/revocation.js";
78
+ import { CreateOcspCertStatusInput, CreateOcspRequestInput, CreateOcspRequestItemInput, CreateOcspResponseInput, CreateOcspSingleResponseInput, OcspCertStatus, OcspCertificateSource, OcspEncoderErrorCode, OcspHashAlgorithm, OcspRequestMaterial, OcspRequestSource, OcspResponderRevocationPolicy, OcspResponseMaterial, OcspResponseStatus, ParseOcspRequestErrorCode, ParseOcspRequestFailure, ParseOcspRequestResult, ParseOcspResponseErrorCode, ParseOcspResponseFailure, ParseOcspResponseResult, ParsedOcspCertId, ParsedOcspCertStatus, ParsedOcspRequest, ParsedOcspResponderId, ParsedOcspResponse, ParsedOcspSingleResponse, RevocationSkipReason, ValidateOcspResponseErrorCode, ValidateOcspResponseFailure, ValidateOcspResponseInput, ValidateOcspResponseResult, VerifyOcspResponseSignatureFailure, VerifyOcspResponseSignatureOptions, VerifyOcspResponseSignatureResult, createOcspRequest, createOcspResponse, hasOcspNoCheckExtension, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, validateOcspResponse, verifyOcspResponseSignature } from "./revocation/ocsp.js";
79
79
  import { AuthorityInformationAccess, AuthorityInformationAccessInput, BasicConstraints, CertificateExtensionsInput, CertificatePolicies, DisplayTextType, DistributionPoint, DistributionPointName, ExtendedKeyUsage, GeneralName, GeneralSubtree, InhibitAnyPolicy, IssuingDistributionPoint, IssuingDistributionPointBase, IssuingDistributionPointForAttributeCerts, IssuingDistributionPointForCaCerts, IssuingDistributionPointForUserCerts, KeyUsage, NameConstraintForm, NameConstraints, OversizedDisplayText, ParsedBitFlags, ParsedNameConstraintForm, PolicyConstraints, PolicyInformation, PolicyMapping, PolicyMappings, PolicyQualifierInfo, SubjectAltName } from "./x509/extensions.js";
80
80
  import { DecodedExtensionMap, DecodedExtensionValue, ExtensionDecoder, ExtensionDecoderMap, MatchCertificatePrivateKeyErrorCode, MatchCertificatePrivateKeyFailure, MatchCertificatePrivateKeyFailureResult, MatchCertificatePrivateKeyResult, MatchCertificatePrivateKeySuccess, ParseCertificateChainResult, ParseCertificateErrorCode, ParseCertificateFailure, ParseCertificateResult, ParseCertificateSigningRequestErrorCode, ParseCertificateSigningRequestFailure, ParseCertificateSigningRequestResult, ParseOptions, ParsedCertificate, ParsedCertificateSigningRequest, ParsedDistributionPoint, ParsedDistributionPointName, ParsedExtension, ParsedIssuingDistributionPoint, ParsedIssuingDistributionPointBase, ParsedIssuingDistributionPointScope, ParsedName, ParsedNameAttribute, ParsedRelativeDistinguishedName, certificateMatchesPrivateKey, decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, findExtension, getSubjectPublicKey, getSubjectPublicKeyOrThrow, matchCertificatePrivateKey, parseCertificateChainPem, parseCertificateChainPemOrThrow, parseCertificateDer, parseCertificateDerOrThrow, parseCertificateFromSource, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow, parseCertificatesFromSource, parseDistinguishedNameDer } from "./x509/parse.js";
81
- import { BuildCandidatePathInput, BuildCandidatePathResult, CandidatePath, CertificateSource, ChainRevocationInput, CsrSource, EkuCheckFailure, EkuCheckPurpose, EkuCheckResult, TrustAnchor, VERIFY_ERROR_CODES, ValidateCandidatePathInput, ValidateCandidatePathResult, ValidateCandidatePathSuccess, ValidateForCaInput, ValidateForCodeSigningInput, ValidateForTlsClientInput, ValidateForTlsServerInput, VerifiedCertificateChain, VerifyCertificateChainInput, VerifyChainFailure, VerifyChainResult, VerifyErrorCode, VerifyFailureDetails, VerifyFailureSource, VerifyPurpose, VerifyRequestFailure, VerifyRequestResult, buildCandidatePath, checkExtendedKeyUsage, trustAnchorFromCertificate, validateCandidatePath, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, verifyCertificateChain, verifyCertificateSigningRequest } from "./verify/verify.js";
81
+ import { BuildCandidatePathInput, BuildCandidatePathResult, CandidatePath, CandidatePathAnchor, CandidatePathCertificates, CertificateSource, ChainRevocationInput, CsrSource, EkuCheckFailure, EkuCheckPurpose, EkuCheckResult, TrustAnchor, VERIFY_ERROR_CODES, ValidateCandidatePathInput, ValidateCandidatePathResult, ValidateCandidatePathSuccess, ValidateForCaInput, ValidateForCodeSigningInput, ValidateForTlsClientInput, ValidateForTlsServerInput, VerifiedCertificateChain, VerifiedPolicyOutcome, VerifyCertificateChainInput, VerifyCertificateSigningRequestOptions, VerifyChainFailure, VerifyChainResult, VerifyErrorCode, VerifyFailureDetails, VerifyFailureSource, VerifyPurpose, VerifyRequestFailure, VerifyRequestResult, buildCandidatePath, checkExtendedKeyUsage, trustAnchorFromCertificate, validateCandidatePath, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, verifyCertificateChain, verifyCertificateSigningRequest } from "./verify/verify.js";
82
82
  import { ConstrainedPolicy, PolicyValidationInput, PolicyValidationOutcome } from "./verify/policy.js";
83
83
  import { DnsServiceIdentityInput, IpServiceIdentityInput, MatchServiceIdentityErrorCode, MatchServiceIdentityFailure, MatchServiceIdentityFailureDetails, MatchServiceIdentityFailureResult, MatchServiceIdentityInput, MatchServiceIdentityResult, MatchServiceIdentitySuccess, ServiceIdentityInput, ServiceIdentityType, SrvServiceIdentityInput, UriServiceIdentityInput, matchCertificateServiceIdentity, matchServiceIdentity } from "./verify/identity.js";
84
84
  import { InitialNameConstraintsInput } from "./verify/name-constraints.js";
85
+ import { SignatureVerifier, SignatureVerifierInput, SignatureVerifiers } from "./internal/crypto/sig-verify.js";
85
86
  import { isSelfIssued } from "./internal/verify/verify-path.js";
86
87
  import { CertificateFingerprint, CertificateFingerprintAlgorithm, CertificateFingerprintSource, certificateFingerprint, subjectPublicKeyInfoFingerprint } from "./x509/fingerprint.js";
87
88
  import { CertificateMaterial, CreateCertificateErrorCode, CreateCertificateInput, CreateSelfSignedCertificateBase, CreateSelfSignedCertificateInput, SelfSignedCertificateResult, SelfSignedKeySource, ValidityInput, createCertificate, createSelfSignedCertificate } from "./x509/certificate.js";
@@ -90,4 +91,4 @@ import { ExtensionEncoderErrorCode } from "./internal/x509/extension-errors.js";
90
91
  import { NameAttribute, NameEncoderErrorCode, NameFieldKey, NameInput, NameObject, RelativeDistinguishedNameInput } from "./x509/name.js";
91
92
  import { SubjectAltNameTextOptions, distinguishedNameToString, relativeDistinguishedNameToString, subjectAltNameLabel, subjectAltNameToString } from "./x509/name-text.js";
92
93
  import { compareDistinguishedNames } from "./internal/shared/dn.js";
93
- export { type AuthorityInformationAccess, type AuthorityInformationAccessInput, type BasicConstraints, type BuildCandidatePathInput, type BuildCandidatePathResult, type CandidatePath, type CategorizePemBlocksResult, type CategorizedPemBlocks, type CertificateExtensionsInput, type CertificateFingerprint, type CertificateFingerprintAlgorithm, type CertificateFingerprintSource, type CertificateMaterial, type CertificatePolicies, type CertificateRevocationListMaterial, type CertificateRevocationStatus, type CertificateSource, type ChainRevocationInput, type CheckCertificateRevocationAgainstCrlErrorCode, type CheckCertificateRevocationAgainstCrlFailure, type CheckCertificateRevocationAgainstCrlFailureDetails, type CheckCertificateRevocationAgainstCrlGoodValue, type CheckCertificateRevocationAgainstCrlInput, type CheckCertificateRevocationAgainstCrlResult, type CheckCertificateRevocationAgainstCrlRevokedValue, type CheckCertificateRevocationAgainstCrlValue, type CheckCertificateRevocationErrorCode, type CheckCertificateRevocationFailureDetails, type CheckCertificateRevocationInput, type CheckCertificateRevocationResult, type CheckCertificateRevocationValue, type CheckChainRevocationInput, type CheckChainRevocationResult, type CheckChainRevocationValue, type ConfiguredOcspResponder, type ConfiguredOcspResponderCertificate, type ConstrainedPolicy, type CreateCertificateErrorCode, type CreateCertificateInput, type CreateCertificateRevocationListInput, type CreateCsrInput, type CreateOcspCertStatusInput, type CreateOcspRequestInput, type CreateOcspRequestItemInput, type CreateOcspResponseInput, type CreateOcspSingleResponseInput, type CreatePfxErrorCode, type CreatePfxFailure, type CreatePfxInput, type CreatePfxResult, type CreatePkcs12MacDataErrorCode, type CreatePkcs7CertBagErrorCode, type CreatePkcs7CertBagFailure, type CreatePkcs7CertBagResult, type CreatePkcs7SignedDataErrorCode, type CreatePkcs7SignedDataFailure, type CreatePkcs7SignedDataInput, type CreatePkcs7SignedDataResult, type CreateSelfSignedCertificateBase, type CreateSelfSignedCertificateInput, type CrlApplicabilityFailureReason, type CrlCertificateSource, type CrlEncoderErrorCode, type CrlSource, type CsrMaterial, type CsrSource, DECODE_REFUSAL_CODES, type DecodeFailureCode, type DecodeRefusalCode, type DecodedExtensionMap, type DecodedExtensionValue, type DecryptRsaOaepErrorCode, type DecryptRsaOaepFailure, type DecryptRsaOaepResult, type DisplayTextType, type DistributionPoint, type DistributionPointName, type DnsServiceIdentityInput, type EcKeyAlgorithmInput, type EcNamedCurve, type Ed25519KeyAlgorithmInput, type EkuCheckFailure, type EkuCheckPurpose, type EkuCheckResult, type EncryptRsaOaepErrorCode, type EncryptRsaOaepFailure, type EncryptRsaOaepResult, type EncryptedPkcs8Options, type ErrorResult, type ExtendedKeyUsage, type ExtensionDecoder, type ExtensionDecoderMap, type ExtensionEncoderErrorCode, type GeneralName, type GeneralSubtree, type ImportEcKeyInput, type ImportEd25519KeyInput, type ImportEncryptedKeyErrorCode, type ImportEncryptedKeyFailure, type ImportEncryptedKeyOptions, type ImportEncryptedKeyResult, type ImportKeyErrorCode, type ImportKeyErrorDetails, type ImportKeyFailure, type ImportKeyReason, type ImportKeyResult, type ImportKeyStage, type ImportRsaKeyInput, type IndexedErrorResult, type IndexedMicro509Error, type InhibitAnyPolicy, type InitialNameConstraintsInput, type IpServiceIdentityInput, type IssuingDistributionPoint, type IssuingDistributionPointBase, type IssuingDistributionPointForAttributeCerts, type IssuingDistributionPointForCaCerts, type IssuingDistributionPointForUserCerts, type KdfLimitOptions, type KeyAlgorithmInput, type KeyPairMaterial, type KeyUsage, type LegacyPemEncryptionOptions, type MatchCertificatePrivateKeyErrorCode, type MatchCertificatePrivateKeyFailure, type MatchCertificatePrivateKeyFailureResult, type MatchCertificatePrivateKeyResult, type MatchCertificatePrivateKeySuccess, type MatchServiceIdentityErrorCode, type MatchServiceIdentityFailure, type MatchServiceIdentityFailureDetails, type MatchServiceIdentityFailureResult, type MatchServiceIdentityInput, type MatchServiceIdentityResult, type MatchServiceIdentitySuccess, type Micro509Error, type NameAttribute, type NameConstraintForm, type NameConstraints, type NameEncoderErrorCode, type NameFieldKey, type NameInput, type NameObject, type OcspCertStatus, type OcspCertificateSource, type OcspEncoderErrorCode, type OcspHashAlgorithm, type OcspRequestMaterial, type OcspRequestSource, type OcspResponderCandidate, type OcspResponderRevocationPolicy, type OcspResponderSource, type OcspResponseMaterial, type OcspResponseSource, type OcspResponseStatus, type OversizedDisplayText, type ParseCertificateChainResult, type ParseCertificateErrorCode, type ParseCertificateFailure, type ParseCertificateResult, type ParseCertificateRevocationListErrorCode, type ParseCertificateRevocationListFailure, type ParseCertificateRevocationListResult, type ParseCertificateSigningRequestErrorCode, type ParseCertificateSigningRequestFailure, type ParseCertificateSigningRequestResult, type ParseOcspRequestErrorCode, type ParseOcspRequestFailure, type ParseOcspRequestResult, type ParseOcspResponseErrorCode, type ParseOcspResponseFailure, type ParseOcspResponseResult, type ParseOptions, type ParsePfxErrorCode, type ParsePfxFailure, type ParsePfxOptions, type ParsePfxResult, type ParsePkcs12MacDataErrorCode, type ParsePkcs12MacDataFailure, type ParsePkcs12MacDataOptions, type ParsePkcs12MacDataResult, type ParsePkcs7CertBagResult, type ParsePkcs7ErrorCode, type ParsePkcs7Failure, type ParsePkcs7SignedDataResult, type ParsedBitFlags, type ParsedCertificate, type ParsedCertificateChoice, type ParsedCertificateRevocationList, type ParsedCertificateSigningRequest, type ParsedDistributionPoint, type ParsedDistributionPointName, type ParsedExtension, type ParsedIssuingDistributionPoint, type ParsedIssuingDistributionPointBase, type ParsedIssuingDistributionPointScope, type ParsedName, type ParsedNameAttribute, type ParsedNameConstraintForm, type ParsedOcspCertId, type ParsedOcspCertStatus, type ParsedOcspRequest, type ParsedOcspResponderId, type ParsedOcspResponse, type ParsedOcspSingleResponse, type ParsedPfx, type ParsedPfxAttribute, type ParsedPfxBag, type ParsedPfxBagAttributes, type ParsedPkcs12MacData, type ParsedPkcs7SignedData, type ParsedPkcs7SignerInfo, type ParsedPkcs7SignerInfoBase, type ParsedRelativeDistinguishedName, type ParsedRevocationReason, type ParsedRevokedCertificate, type ParsedSignerIdentifier, type Pbes2Parameters, type PemBlock, type PemDecodeResult, type PemErrorCode, type PemFailure, type PfxBagAttributesInput, type PfxCertificateBagInput, type PfxCertificateSource, type PfxEncoderErrorCode, type PfxEncryptionOptions, type PfxMaterial, type PfxPrivateKeyBagInput, type PfxPrivateKeySource, type Pkcs12MacOptions, type Pkcs7CertBagMaterial, type Pkcs7CertificateSource, type Pkcs7SignedDataMaterial, type Pkcs7Signer, type PolicyConstraints, type PolicyInformation, type PolicyMapping, type PolicyMappings, type PolicyQualifierInfo, type PolicyValidationInput, type PolicyValidationOutcome, type PrivateKeyImportInput, type PublicKeyImportInput, REVOCATION_INDETERMINATE_REASONS, REVOCATION_INDETERMINATE_REASON_CODES, type RelativeDistinguishedNameInput, type ResolveOcspResponderCandidatesInput, type Result, type ResultError, type RevocationCertificateSource, type RevocationCheckGoodValue, type RevocationCheckIndeterminateValue, type RevocationCheckRevokedValue, type RevocationCrlEvidenceInput, type RevocationEvidenceInput, type RevocationEvidenceKind, type RevocationExecutionError, type RevocationIndeterminateEvidence, type RevocationIndeterminateReason, type RevocationIndeterminateReasonCode, type RevocationOcspEvidenceInput, type RevocationParseError, type RevocationPolicy, type RevocationProcessingError, type RevocationReason, type RevocationSource, type RevocationStatus, type RevokedCertificateInput, type RsaHash, type RsaKeyAlgorithmInput, type RsaOaepOptions, type RsaScheme, type RsaSignatureScheme, type SelfSignedCertificateResult, type SelfSignedKeySource, type ServiceIdentityInput, type ServiceIdentityType, type SplitPemBlocksResult, type SrvServiceIdentityInput, type SubjectAltName, type SubjectAltNameTextOptions, type TrustAnchor, type TrustedOcspResponder, type UnrecognizedReasonCodePolicy, type UnrecognizedRevocationReason, type UriServiceIdentityInput, VERIFY_ERROR_CODES, type ValidateCandidatePathInput, type ValidateCandidatePathResult, type ValidateCandidatePathSuccess, type ValidateCertificateRevocationListFailure, type ValidateCertificateRevocationListInput, type ValidateCertificateRevocationListResult, type ValidateForCaInput, type ValidateForCodeSigningInput, type ValidateForTlsClientInput, type ValidateForTlsServerInput, type ValidateOcspResponseErrorCode, type ValidateOcspResponseFailure, type ValidateOcspResponseInput, type ValidateOcspResponseResult, type ValidityInput, type VerifiedCertificateChain, type VerifiedPkcs7Signer, type VerifyCertificateChainInput, type VerifyCertificateRevocationListSignatureFailure, type VerifyCertificateRevocationListSignatureResult, type VerifyChainFailure, type VerifyChainResult, type VerifyErrorCode, type VerifyFailureDetails, type VerifyFailureSource, type VerifyOcspResponseSignatureFailure, type VerifyOcspResponseSignatureResult, type VerifyPkcs7SignedDataErrorCode, type VerifyPkcs7SignedDataFailure, type VerifyPkcs7SignedDataOptions, type VerifyPkcs7SignedDataResult, type VerifyPurpose, type VerifyRequestFailure, type VerifyRequestResult, buildCandidatePath, categorizePemBlocks, categorizePemBlocksOrThrow, certificateFingerprint, certificateMatchesPrivateKey, checkCertificateRevocation, checkCertificateRevocationAgainstCrl, checkChainRevocation, checkExtendedKeyUsage, compareDistinguishedNames, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBag, createPkcs7SignedData, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, decryptRsaOaep, decryptRsaOaepOrThrow, defineExtensionDecoder, defineExtensionDecoderMap, derivePublicKey, distinguishedNameToString, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, findExtension, generateKeyPair, getCertificateOcspResponderUris, getSubjectPublicKey, getSubjectPublicKeyOrThrow, hasOcspNoCheckExtension, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPrivateKeyPem, importPrivateKeyPemOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow, inspectEncryptedPkcs8Der, isCertificateRevoked, isResultError, isSelfIssued as isSelfIssuedCertificate, matchCertificatePrivateKey, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateChainPemOrThrow, parseCertificateDer, parseCertificateDerOrThrow, parseCertificateFromSource, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow, parseCertificatesFromSource, parseDistinguishedNameDer, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemDecodeOrThrow, pemEncode, relativeDistinguishedNameToString, resolveOcspResponderCandidates, revocationReasonFromCode, splitPemBlocks, splitPemBlocksOrThrow, subjectAltNameLabel, subjectAltNameToString, subjectPublicKeyInfoFingerprint, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationListSignature, verifyCertificateSigningRequest, verifyOcspResponseSignature, verifyPkcs7SignedData };
94
+ export { type AuthorityInformationAccess, type AuthorityInformationAccessInput, type BasicConstraints, type BuildCandidatePathInput, type BuildCandidatePathResult, type CandidatePath, type CandidatePathAnchor, type CandidatePathCertificates, type CategorizePemBlocksResult, type CategorizedPemBlocks, type CertificateExtensionsInput, type CertificateFingerprint, type CertificateFingerprintAlgorithm, type CertificateFingerprintSource, type CertificateMaterial, type CertificatePolicies, type CertificateRevocationListMaterial, type CertificateRevocationStatus, type CertificateSource, type ChainRevocationInput, type CheckCertificateRevocationAgainstCrlErrorCode, type CheckCertificateRevocationAgainstCrlFailure, type CheckCertificateRevocationAgainstCrlFailureDetails, type CheckCertificateRevocationAgainstCrlGoodValue, type CheckCertificateRevocationAgainstCrlInput, type CheckCertificateRevocationAgainstCrlResult, type CheckCertificateRevocationAgainstCrlRevokedValue, type CheckCertificateRevocationAgainstCrlValue, type CheckCertificateRevocationErrorCode, type CheckCertificateRevocationFailureDetails, type CheckCertificateRevocationInput, type CheckCertificateRevocationResult, type CheckCertificateRevocationValue, type CheckChainRevocationInput, type CheckChainRevocationResult, type CheckChainRevocationValue, type ConfiguredOcspResponder, type ConfiguredOcspResponderCertificate, type ConstrainedPolicy, type CreateCertificateErrorCode, type CreateCertificateInput, type CreateCertificateRevocationListInput, type CreateCsrInput, type CreateOcspCertStatusInput, type CreateOcspRequestInput, type CreateOcspRequestItemInput, type CreateOcspResponseInput, type CreateOcspSingleResponseInput, type CreatePfxErrorCode, type CreatePfxFailure, type CreatePfxInput, type CreatePfxResult, type CreatePkcs12MacDataErrorCode, type CreatePkcs7CertBagErrorCode, type CreatePkcs7CertBagFailure, type CreatePkcs7CertBagResult, type CreatePkcs7SignedDataErrorCode, type CreatePkcs7SignedDataFailure, type CreatePkcs7SignedDataInput, type CreatePkcs7SignedDataResult, type CreateSelfSignedCertificateBase, type CreateSelfSignedCertificateInput, type CrlApplicabilityFailureReason, type CrlCertificateSource, type CrlEncoderErrorCode, type CrlSource, type CsrMaterial, type CsrSource, DECODE_REFUSAL_CODES, type DecodeFailureCode, type DecodeRefusalCode, type DecodedExtensionMap, type DecodedExtensionValue, type DecryptRsaOaepErrorCode, type DecryptRsaOaepFailure, type DecryptRsaOaepResult, type DisplayTextType, type DistributionPoint, type DistributionPointName, type DnsServiceIdentityInput, type EcKeyAlgorithmInput, type EcNamedCurve, type Ed25519KeyAlgorithmInput, type EkuCheckFailure, type EkuCheckPurpose, type EkuCheckResult, type EncryptRsaOaepErrorCode, type EncryptRsaOaepFailure, type EncryptRsaOaepResult, type EncryptedPkcs8Options, type ErrorResult, type ExtendedKeyUsage, type ExtensionDecoder, type ExtensionDecoderMap, type ExtensionEncoderErrorCode, type GeneralName, type GeneralSubtree, type ImportEcKeyInput, type ImportEd25519KeyInput, type ImportEncryptedKeyErrorCode, type ImportEncryptedKeyFailure, type ImportEncryptedKeyOptions, type ImportEncryptedKeyResult, type ImportKeyErrorCode, type ImportKeyErrorDetails, type ImportKeyFailure, type ImportKeyReason, type ImportKeyResult, type ImportKeyStage, type ImportRsaKeyInput, type IndexedErrorResult, type IndexedMicro509Error, type InhibitAnyPolicy, type InitialNameConstraintsInput, type IpServiceIdentityInput, type IssuingDistributionPoint, type IssuingDistributionPointBase, type IssuingDistributionPointForAttributeCerts, type IssuingDistributionPointForCaCerts, type IssuingDistributionPointForUserCerts, type KdfLimitOptions, type KeyAlgorithmInput, type KeyPairMaterial, type KeyUsage, type LegacyPemEncryptionOptions, type MatchCertificatePrivateKeyErrorCode, type MatchCertificatePrivateKeyFailure, type MatchCertificatePrivateKeyFailureResult, type MatchCertificatePrivateKeyResult, type MatchCertificatePrivateKeySuccess, type MatchServiceIdentityErrorCode, type MatchServiceIdentityFailure, type MatchServiceIdentityFailureDetails, type MatchServiceIdentityFailureResult, type MatchServiceIdentityInput, type MatchServiceIdentityResult, type MatchServiceIdentitySuccess, type Micro509Error, type NameAttribute, type NameConstraintForm, type NameConstraints, type NameEncoderErrorCode, type NameFieldKey, type NameInput, type NameObject, type OcspCertStatus, type OcspCertificateSource, type OcspEncoderErrorCode, type OcspHashAlgorithm, type OcspRequestMaterial, type OcspRequestSource, type OcspResponderCandidate, type OcspResponderRevocationPolicy, type OcspResponderSource, type OcspResponseMaterial, type OcspResponseSource, type OcspResponseStatus, type OversizedDisplayText, type ParseCertificateChainResult, type ParseCertificateErrorCode, type ParseCertificateFailure, type ParseCertificateResult, type ParseCertificateRevocationListErrorCode, type ParseCertificateRevocationListFailure, type ParseCertificateRevocationListResult, type ParseCertificateSigningRequestErrorCode, type ParseCertificateSigningRequestFailure, type ParseCertificateSigningRequestResult, type ParseOcspRequestErrorCode, type ParseOcspRequestFailure, type ParseOcspRequestResult, type ParseOcspResponseErrorCode, type ParseOcspResponseFailure, type ParseOcspResponseResult, type ParseOptions, type ParsePfxErrorCode, type ParsePfxFailure, type ParsePfxOptions, type ParsePfxResult, type ParsePkcs12MacDataErrorCode, type ParsePkcs12MacDataFailure, type ParsePkcs12MacDataOptions, type ParsePkcs12MacDataResult, type ParsePkcs7CertBagResult, type ParsePkcs7ErrorCode, type ParsePkcs7Failure, type ParsePkcs7SignedDataResult, type ParsedBitFlags, type ParsedCertificate, type ParsedCertificateChoice, type ParsedCertificateRevocationList, type ParsedCertificateSigningRequest, type ParsedDistributionPoint, type ParsedDistributionPointName, type ParsedExtension, type ParsedIssuingDistributionPoint, type ParsedIssuingDistributionPointBase, type ParsedIssuingDistributionPointScope, type ParsedName, type ParsedNameAttribute, type ParsedNameConstraintForm, type ParsedOcspCertId, type ParsedOcspCertStatus, type ParsedOcspRequest, type ParsedOcspResponderId, type ParsedOcspResponse, type ParsedOcspSingleResponse, type ParsedPfx, type ParsedPfxAttribute, type ParsedPfxBag, type ParsedPfxBagAttributes, type ParsedPkcs12MacData, type ParsedPkcs7SignedData, type ParsedPkcs7SignerInfo, type ParsedPkcs7SignerInfoBase, type ParsedRelativeDistinguishedName, type ParsedRevocationReason, type ParsedRevokedCertificate, type ParsedSignerIdentifier, type Pbes2Parameters, type PemBlock, type PemDecodeResult, type PemErrorCode, type PemFailure, type PfxBagAttributesInput, type PfxCertificateBagInput, type PfxCertificateSource, type PfxEncoderErrorCode, type PfxEncryptionOptions, type PfxMaterial, type PfxPrivateKeyBagInput, type PfxPrivateKeySource, type Pkcs12MacOptions, type Pkcs7CertBagMaterial, type Pkcs7CertificateSource, type Pkcs7SignedDataMaterial, type Pkcs7Signer, type PolicyConstraints, type PolicyInformation, type PolicyMapping, type PolicyMappings, type PolicyQualifierInfo, type PolicyValidationInput, type PolicyValidationOutcome, type PrivateKeyImportInput, type PublicKeyImportInput, REVOCATION_INDETERMINATE_REASONS, REVOCATION_INDETERMINATE_REASON_CODES, type RelativeDistinguishedNameInput, type ResolveOcspResponderCandidatesInput, type Result, type ResultError, type RevocationCertificateSource, type RevocationCheckGoodValue, type RevocationCheckIndeterminateValue, type RevocationCheckRevokedValue, type RevocationCheckSkippedValue, type RevocationCrlEvidenceInput, type RevocationEvidenceInput, type RevocationEvidenceKind, type RevocationExecutionError, type RevocationIndeterminateEvidence, type RevocationIndeterminateReason, type RevocationIndeterminateReasonCode, type RevocationOcspEvidenceInput, type RevocationParseError, type RevocationPolicy, type RevocationProcessingError, type RevocationReason, type RevocationSkipReason, type RevocationSource, type RevocationStatus, type RevokedCertificateInput, type RsaHash, type RsaKeyAlgorithmInput, type RsaOaepOptions, type RsaScheme, type RsaSignatureScheme, type SelfSignedCertificateResult, type SelfSignedKeySource, type ServiceIdentityInput, type ServiceIdentityType, type SignatureVerifier, type SignatureVerifierInput, type SignatureVerifiers, type SplitPemBlocksResult, type SrvServiceIdentityInput, type SubjectAltName, type SubjectAltNameTextOptions, type SupersededDeltaCrlPolicy, type TrustAnchor, type TrustedOcspResponder, type UnrecognizedReasonCodePolicy, type UnrecognizedRevocationReason, type UriServiceIdentityInput, VERIFY_ERROR_CODES, type ValidateCandidatePathInput, type ValidateCandidatePathResult, type ValidateCandidatePathSuccess, type ValidateCertificateRevocationListFailure, type ValidateCertificateRevocationListInput, type ValidateCertificateRevocationListResult, type ValidateForCaInput, type ValidateForCodeSigningInput, type ValidateForTlsClientInput, type ValidateForTlsServerInput, type ValidateOcspResponseErrorCode, type ValidateOcspResponseFailure, type ValidateOcspResponseInput, type ValidateOcspResponseResult, type ValidityInput, type VerifiedCertificateChain, type VerifiedPkcs7Signer, type VerifiedPolicyOutcome, type VerifyCertificateChainInput, type VerifyCertificateRevocationListSignatureFailure, type VerifyCertificateRevocationListSignatureOptions, type VerifyCertificateRevocationListSignatureResult, type VerifyCertificateSigningRequestOptions, type VerifyChainFailure, type VerifyChainResult, type VerifyErrorCode, type VerifyFailureDetails, type VerifyFailureSource, type VerifyOcspResponseSignatureFailure, type VerifyOcspResponseSignatureOptions, type VerifyOcspResponseSignatureResult, type VerifyPkcs7SignedDataErrorCode, type VerifyPkcs7SignedDataFailure, type VerifyPkcs7SignedDataOptions, type VerifyPkcs7SignedDataResult, type VerifyPurpose, type VerifyRequestFailure, type VerifyRequestResult, buildCandidatePath, categorizePemBlocks, categorizePemBlocksOrThrow, certificateFingerprint, certificateMatchesPrivateKey, checkCertificateRevocation, checkCertificateRevocationAgainstCrl, checkChainRevocation, checkExtendedKeyUsage, compareDistinguishedNames, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBag, createPkcs7SignedData, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, decryptRsaOaep, decryptRsaOaepOrThrow, defineExtensionDecoder, defineExtensionDecoderMap, derivePublicKey, distinguishedNameToString, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, findExtension, generateKeyPair, getCertificateOcspResponderUris, getSubjectPublicKey, getSubjectPublicKeyOrThrow, hasOcspNoCheckExtension, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPrivateKeyPem, importPrivateKeyPemOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow, inspectEncryptedPkcs8Der, isCertificateRevoked, isResultError, isSelfIssued as isSelfIssuedCertificate, matchCertificatePrivateKey, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateChainPemOrThrow, parseCertificateDer, parseCertificateDerOrThrow, parseCertificateFromSource, parseCertificatePem, parseCertificatePemOrThrow, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, parseCertificateSigningRequestDer, parseCertificateSigningRequestDerOrThrow, parseCertificateSigningRequestPem, parseCertificateSigningRequestPemOrThrow, parseCertificatesFromSource, parseDistinguishedNameDer, parseOcspRequestDer, parseOcspRequestDerOrThrow, parseOcspRequestPem, parseOcspRequestPemOrThrow, parseOcspResponseDer, parseOcspResponseDerOrThrow, parseOcspResponsePem, parseOcspResponsePemOrThrow, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemDecodeOrThrow, pemEncode, relativeDistinguishedNameToString, resolveOcspResponderCandidates, revocationReasonFromCode, splitPemBlocks, splitPemBlocksOrThrow, subjectAltNameLabel, subjectAltNameToString, subjectPublicKeyInfoFingerprint, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationListSignature, verifyCertificateSigningRequest, verifyOcspResponseSignature, verifyPkcs7SignedData };
@@ -91,7 +91,7 @@ function extractBitStringValue(e) {
91
91
  if (e.tag !== 3) throw Error("Expected BIT STRING");
92
92
  let t = e.value[0];
93
93
  if (t === void 0 || t > 7) throw Error("Invalid BIT STRING");
94
- if (t !== 0) throw Error("BIT STRING must have zero unused bits");
94
+ if (t !== 0) throw Error("BIT STRING value is not a whole number of octets");
95
95
  return e.value.slice(1);
96
96
  }
97
97
  /**
@@ -116,6 +116,14 @@ function decodeBitString(e) {
116
116
  nonZeroPadding: t > 0 && n.length > 0 && ((n[n.length - 1] ?? 0) & r) !== 0
117
117
  };
118
118
  }
119
+ /** A signed object's `signatureValue` BIT STRING as its octets and unused-bit count. */
120
+ function signatureBits(e) {
121
+ let { bytes: t, unusedBits: n } = decodeBitString(e);
122
+ return {
123
+ signatureValue: t,
124
+ signatureValueUnusedBits: n
125
+ };
126
+ }
119
127
  /**
120
128
  * Parses a {@linkcode DerElement} with tag UTCTime (`0x17`) or GeneralizedTime (`0x18`) into a {@linkcode Date}.
121
129
  *
@@ -577,6 +585,6 @@ const h = /* @__PURE__ */ new Map([
577
585
  function checkUniversalElement(e) {
578
586
  return e.tag & 192 ? "valid" : (e.tag & 31) == 31 ? e.tagNumber <= 36 ? "unsupported" : "malformed" : h.get(e.tag)?.(e) ?? "malformed";
579
587
  }
580
- export { canonicalizeOid, checkStrictDer, childrenOf, decodeBitString, decodeBoolean, decodeIntegerMagnitude, decodeIntegerNumber, decodeNonNegativeIntegerBigInt, decodeNonNegativeIntegerNumber, decodeObjectIdentifier, decodeString, decodeVisibleString, extractBitStringValue, hexToBytes, isNumericStringContents, parseTime, requireElement, toArrayBuffer, toHex };
588
+ export { canonicalizeOid, checkStrictDer, childrenOf, decodeBitString, decodeBoolean, decodeIntegerMagnitude, decodeIntegerNumber, decodeNonNegativeIntegerBigInt, decodeNonNegativeIntegerNumber, decodeObjectIdentifier, decodeString, decodeVisibleString, extractBitStringValue, hexToBytes, isNumericStringContents, parseTime, requireElement, signatureBits, toArrayBuffer, toHex };
581
589
 
582
590
  //# sourceMappingURL=asn1.js.map