micro509 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/CHANGELOG.md +2119 -0
  2. package/README.md +105 -225
  3. package/dist/crypto/crypto.d.ts +42 -11
  4. package/dist/crypto/crypto.js +53 -22
  5. package/dist/crypto/crypto.js.map +1 -1
  6. package/dist/crypto.d.ts +2 -2
  7. package/dist/crypto.js +1 -2
  8. package/dist/der/der.d.ts +41 -33
  9. package/dist/der/der.js +26 -24
  10. package/dist/der/der.js.map +1 -1
  11. package/dist/index.d.ts +11 -11
  12. package/dist/index.js +19 -19
  13. package/dist/internal/asn1/asn1.d.ts +3 -6
  14. package/dist/internal/asn1/asn1.js +343 -43
  15. package/dist/internal/asn1/asn1.js.map +1 -1
  16. package/dist/internal/asn1/ber.js +146 -0
  17. package/dist/internal/asn1/ber.js.map +1 -0
  18. package/dist/internal/asn1/decode-refusal.js +29 -0
  19. package/dist/internal/asn1/decode-refusal.js.map +1 -0
  20. package/dist/internal/asn1/der.d.ts +38 -41
  21. package/dist/internal/asn1/der.js +131 -52
  22. package/dist/internal/asn1/der.js.map +1 -1
  23. package/dist/internal/asn1/oids.js +83 -53
  24. package/dist/internal/asn1/oids.js.map +1 -1
  25. package/dist/internal/asn1/oids2.js +1 -2
  26. package/dist/internal/asn1/oids2.js.map +1 -1
  27. package/dist/internal/crypto/algorithm-names.js +1 -2
  28. package/dist/internal/crypto/algorithm-names.js.map +1 -1
  29. package/dist/internal/crypto/ecdsa.js +13 -8
  30. package/dist/internal/crypto/ecdsa.js.map +1 -1
  31. package/dist/internal/crypto/hash.js +1 -2
  32. package/dist/internal/crypto/hash.js.map +1 -1
  33. package/dist/internal/crypto/pbes2.d.ts +24 -11
  34. package/dist/internal/crypto/pbes2.js +79 -26
  35. package/dist/internal/crypto/pbes2.js.map +1 -1
  36. package/dist/internal/crypto/rsa-pss.js +46 -44
  37. package/dist/internal/crypto/rsa-pss.js.map +1 -1
  38. package/dist/internal/crypto/sig-verify.d.ts +4 -7
  39. package/dist/internal/crypto/sig-verify.js +107 -60
  40. package/dist/internal/crypto/sig-verify.js.map +1 -1
  41. package/dist/internal/crypto/signing.d.ts +1 -4
  42. package/dist/internal/crypto/signing.js +28 -29
  43. package/dist/internal/crypto/signing.js.map +1 -1
  44. package/dist/internal/crypto/webcrypto.js +1 -2
  45. package/dist/internal/crypto/webcrypto.js.map +1 -1
  46. package/dist/internal/shared/base64.js +1 -2
  47. package/dist/internal/shared/base64.js.map +1 -1
  48. package/dist/internal/shared/dn.d.ts +3 -6
  49. package/dist/internal/shared/dn.js +99 -53
  50. package/dist/internal/shared/dn.js.map +1 -1
  51. package/dist/internal/shared/idna-tables.js +7217 -0
  52. package/dist/internal/shared/idna-tables.js.map +1 -0
  53. package/dist/internal/shared/idna.js +296 -0
  54. package/dist/internal/shared/idna.js.map +1 -0
  55. package/dist/internal/shared/ip.d.ts +4 -7
  56. package/dist/internal/shared/ip.js +1 -2
  57. package/dist/internal/shared/ip.js.map +1 -1
  58. package/dist/internal/shared/mailbox.js +26 -0
  59. package/dist/internal/shared/mailbox.js.map +1 -0
  60. package/dist/internal/shared/punycode.js +101 -0
  61. package/dist/internal/shared/punycode.js.map +1 -0
  62. package/dist/internal/shared/rfc3454-tables.js +1 -2
  63. package/dist/internal/shared/rfc3454-tables.js.map +1 -1
  64. package/dist/internal/shared/rfc4518-tables.js +119 -0
  65. package/dist/internal/shared/rfc4518-tables.js.map +1 -0
  66. package/dist/internal/shared/uri-host.js +102 -0
  67. package/dist/internal/shared/uri-host.js.map +1 -0
  68. package/dist/internal/verify/name-constraints-engine.js +246 -131
  69. package/dist/internal/verify/name-constraints-engine.js.map +1 -1
  70. package/dist/internal/verify/policy-engine.js +6 -21
  71. package/dist/internal/verify/policy-engine.js.map +1 -1
  72. package/dist/internal/verify/spki-distrust.js +23 -0
  73. package/dist/internal/verify/spki-distrust.js.map +1 -0
  74. package/dist/internal/verify/verify-path.d.ts +1 -4
  75. package/dist/internal/verify/verify-path.js +282 -129
  76. package/dist/internal/verify/verify-path.js.map +1 -1
  77. package/dist/internal/x509/directory-name.js +1 -2
  78. package/dist/internal/x509/directory-name.js.map +1 -1
  79. package/dist/internal/x509/extension-bits.js +2 -3
  80. package/dist/internal/x509/extension-bits.js.map +1 -1
  81. package/dist/internal/x509/extension-errors.d.ts +1 -4
  82. package/dist/internal/x509/extension-errors.js +1 -2
  83. package/dist/internal/x509/extension-errors.js.map +1 -1
  84. package/dist/internal/x509/extension-registry.js +107 -89
  85. package/dist/internal/x509/extension-registry.js.map +1 -1
  86. package/dist/internal/x509/general-name-profile.js +129 -0
  87. package/dist/internal/x509/general-name-profile.js.map +1 -0
  88. package/dist/internal/x509/general-name-tags.js +1 -2
  89. package/dist/internal/x509/general-name-tags.js.map +1 -1
  90. package/dist/internal/x509/general-name.js +128 -42
  91. package/dist/internal/x509/general-name.js.map +1 -1
  92. package/dist/internal/x509/name-fields.js +1 -2
  93. package/dist/internal/x509/name-fields.js.map +1 -1
  94. package/dist/internal/x509/or-address.js +217 -0
  95. package/dist/internal/x509/or-address.js.map +1 -0
  96. package/dist/keys/keys.d.ts +122 -104
  97. package/dist/keys/keys.js +211 -204
  98. package/dist/keys/keys.js.map +1 -1
  99. package/dist/keys.d.ts +3 -3
  100. package/dist/pem/pem.d.ts +14 -17
  101. package/dist/pem/pem.js +16 -17
  102. package/dist/pem/pem.js.map +1 -1
  103. package/dist/pem.js +1 -2
  104. package/dist/pkcs/pfx.d.ts +57 -32
  105. package/dist/pkcs/pfx.js +209 -173
  106. package/dist/pkcs/pfx.js.map +1 -1
  107. package/dist/pkcs/pkcs12-mac.d.ts +104 -27
  108. package/dist/pkcs/pkcs12-mac.js +266 -79
  109. package/dist/pkcs/pkcs12-mac.js.map +1 -1
  110. package/dist/pkcs/pkcs7.d.ts +43 -37
  111. package/dist/pkcs/pkcs7.js +218 -217
  112. package/dist/pkcs/pkcs7.js.map +1 -1
  113. package/dist/pkcs.d.ts +4 -3
  114. package/dist/result/result.d.ts +27 -20
  115. package/dist/result/result.js +8 -3
  116. package/dist/result/result.js.map +1 -1
  117. package/dist/result.d.ts +2 -2
  118. package/dist/result.js +1 -2
  119. package/dist/revocation/chain.d.ts +101 -23
  120. package/dist/revocation/chain.js +436 -182
  121. package/dist/revocation/chain.js.map +1 -1
  122. package/dist/revocation/crl.d.ts +131 -67
  123. package/dist/revocation/crl.js +443 -327
  124. package/dist/revocation/crl.js.map +1 -1
  125. package/dist/revocation/ocsp.d.ts +94 -59
  126. package/dist/revocation/ocsp.js +331 -293
  127. package/dist/revocation/ocsp.js.map +1 -1
  128. package/dist/revocation/revocation.d.ts +47 -35
  129. package/dist/revocation/revocation.js +88 -57
  130. package/dist/revocation/revocation.js.map +1 -1
  131. package/dist/revocation.d.ts +3 -3
  132. package/dist/verify/identity.d.ts +16 -19
  133. package/dist/verify/identity.js +118 -89
  134. package/dist/verify/identity.js.map +1 -1
  135. package/dist/verify/name-constraints.d.ts +1 -4
  136. package/dist/verify/policy.d.ts +9 -7
  137. package/dist/verify/verify.d.ts +115 -46
  138. package/dist/verify/verify.js +373 -183
  139. package/dist/verify/verify.js.map +1 -1
  140. package/dist/verify.d.ts +2 -2
  141. package/dist/x509/certificate.d.ts +20 -21
  142. package/dist/x509/certificate.js +62 -46
  143. package/dist/x509/certificate.js.map +1 -1
  144. package/dist/x509/csr.d.ts +5 -7
  145. package/dist/x509/csr.js +10 -11
  146. package/dist/x509/csr.js.map +1 -1
  147. package/dist/x509/extensions.d.ts +154 -66
  148. package/dist/x509/extensions.js +317 -151
  149. package/dist/x509/extensions.js.map +1 -1
  150. package/dist/x509/fingerprint.d.ts +15 -7
  151. package/dist/x509/fingerprint.js +20 -3
  152. package/dist/x509/fingerprint.js.map +1 -1
  153. package/dist/x509/name-text.d.ts +7 -9
  154. package/dist/x509/name-text.js +18 -4
  155. package/dist/x509/name-text.js.map +1 -1
  156. package/dist/x509/name.d.ts +9 -11
  157. package/dist/x509/name.js +18 -19
  158. package/dist/x509/name.js.map +1 -1
  159. package/dist/x509/parse.d.ts +84 -69
  160. package/dist/x509/parse.js +421 -400
  161. package/dist/x509/parse.js.map +1 -1
  162. package/dist/x509.d.ts +3 -3
  163. package/dist/x509.js +3 -3
  164. package/package.json +76 -59
@@ -1,19 +1,18 @@
1
- import { Pbes2EncryptionOptions, Pbes2EncryptionScheme, Pbes2Parameters, Pbes2Prf, parsePbes2AlgorithmIdentifier } from "../internal/crypto/pbes2.js";
2
- import { ErrorResult, Micro509Error } from "../result/result.js";
3
- //#region src/keys/keys.d.ts
1
+ import { KdfLimitOptions, Pbes2EncryptionOptions, Pbes2EncryptionScheme, Pbes2Parameters, Pbes2Prf, parsePbes2AlgorithmIdentifier } from "../internal/crypto/pbes2.js";
2
+ import { DecodeFailureCode, ErrorResult, Micro509Error } from "../result/result.js";
4
3
  /** Hash algorithm paired with an RSA key. */
5
- type RsaHash = "SHA-256" | "SHA-384" | "SHA-512";
4
+ export type RsaHash = "SHA-256" | "SHA-384" | "SHA-512";
6
5
  /** RSA signature padding scheme. */
7
- type RsaSignatureScheme = "pkcs1-v1_5" | "pss";
6
+ export type RsaSignatureScheme = "pkcs1-v1_5" | "pss";
8
7
  /**
9
8
  * RSA padding scheme: a signature scheme, or `'oaep'` for RSA-OAEP encryption
10
9
  * keys (usable with {@linkcode encryptRsaOaep} / {@linkcode decryptRsaOaep}).
11
10
  */
12
- type RsaScheme = RsaSignatureScheme | "oaep";
11
+ export type RsaScheme = RsaSignatureScheme | "oaep";
13
12
  /** NIST elliptic curve for ECDSA keys. */
14
- type EcNamedCurve = "P-256" | "P-384" | "P-521";
13
+ export type EcNamedCurve = "P-256" | "P-384" | "P-521";
15
14
  /** RSA variant of {@linkcode KeyAlgorithmInput}. */
16
- interface RsaKeyAlgorithmInput {
15
+ export interface RsaKeyAlgorithmInput {
17
16
  /** Discriminant selecting RSA key generation. */
18
17
  readonly kind: "rsa";
19
18
  /** RSA modulus size in bits. Defaults to `2048`. */
@@ -27,21 +26,21 @@ interface RsaKeyAlgorithmInput {
27
26
  readonly scheme?: RsaScheme;
28
27
  }
29
28
  /** ECDSA variant of {@linkcode KeyAlgorithmInput}. */
30
- interface EcKeyAlgorithmInput {
29
+ export interface EcKeyAlgorithmInput {
31
30
  /** Discriminant selecting ECDSA key generation. */
32
31
  readonly kind: "ecdsa";
33
32
  /** NIST curve. Defaults to `'P-256'`. */
34
33
  readonly curve?: EcNamedCurve;
35
34
  }
36
35
  /** Ed25519 variant of {@linkcode KeyAlgorithmInput}. */
37
- interface Ed25519KeyAlgorithmInput {
36
+ export interface Ed25519KeyAlgorithmInput {
38
37
  /** Discriminant selecting Ed25519 key generation. */
39
38
  readonly kind: "ed25519";
40
39
  }
41
40
  /** Input for {@linkcode generateKeyPair}. Selects algorithm family and parameters. */
42
- type KeyAlgorithmInput = RsaKeyAlgorithmInput | EcKeyAlgorithmInput | Ed25519KeyAlgorithmInput;
41
+ export type KeyAlgorithmInput = RsaKeyAlgorithmInput | EcKeyAlgorithmInput | Ed25519KeyAlgorithmInput;
43
42
  /** Key pair with convenience export helpers. Returned by {@linkcode generateKeyPair}. */
44
- interface KeyPairMaterial {
43
+ export interface KeyPairMaterial {
45
44
  /** The WebCrypto public key (extractable, `verify` usage; `encrypt` for RSA-OAEP). */
46
45
  readonly publicKey: CryptoKey;
47
46
  /** The WebCrypto private key (extractable, `sign` usage; `decrypt` for RSA-OAEP). */
@@ -60,38 +59,41 @@ interface KeyPairMaterial {
60
59
  exportPrivateJwk(): Promise<JsonWebKey>;
61
60
  }
62
61
  /** RSA variant of {@linkcode PublicKeyImportInput} / {@linkcode PrivateKeyImportInput}. */
63
- interface ImportRsaKeyInput {
62
+ export type ImportRsaKeyInput = {
64
63
  /** Discriminant selecting RSA import. */
65
64
  readonly kind: "rsa";
66
- /** Hash algorithm. Defaults to `'SHA-256'`. */
65
+ } & ({
66
+ /** Signature padding scheme. Defaults to `'pkcs1-v1_5'`. */
67
+ readonly scheme?: RsaSignatureScheme;
68
+ /** Signature hash. Defaults to `'SHA-256'`. */
67
69
  readonly hash?: RsaHash;
68
- /**
69
- * Padding scheme. Defaults to `'pkcs1-v1_5'`. Pass `'oaep'` to import an
70
- * RSA-OAEP encryption key (`encrypt`/`decrypt` usage instead of `verify`/`sign`).
71
- */
72
- readonly scheme?: RsaScheme;
73
- }
70
+ } | {
71
+ /** Import an encryption key with `encrypt`/`decrypt` usages. */
72
+ readonly scheme: "oaep";
73
+ /** Hash. Defaults to `'SHA-256'`. Explicit `'SHA-1'` supports legacy OAEP envelopes. */
74
+ readonly hash?: RsaHash | "SHA-1";
75
+ });
74
76
  /** ECDSA variant of {@linkcode PublicKeyImportInput} / {@linkcode PrivateKeyImportInput}. */
75
- interface ImportEcKeyInput {
77
+ export interface ImportEcKeyInput {
76
78
  /** Discriminant selecting ECDSA import. */
77
79
  readonly kind: "ecdsa";
78
80
  /** NIST curve the key belongs to. Required for EC import. */
79
81
  readonly curve: EcNamedCurve;
80
82
  }
81
83
  /** Ed25519 variant of {@linkcode PublicKeyImportInput} / {@linkcode PrivateKeyImportInput}. */
82
- interface ImportEd25519KeyInput {
84
+ export interface ImportEd25519KeyInput {
83
85
  /** Discriminant selecting Ed25519 import. */
84
86
  readonly kind: "ed25519";
85
87
  }
86
88
  /** Algorithm descriptor for public key import functions. */
87
- type PublicKeyImportInput = ImportRsaKeyInput | ImportEcKeyInput | ImportEd25519KeyInput;
89
+ export type PublicKeyImportInput = ImportRsaKeyInput | ImportEcKeyInput | ImportEd25519KeyInput;
88
90
  /** Algorithm descriptor for private key import functions. Same shape as {@linkcode PublicKeyImportInput}. */
89
- type PrivateKeyImportInput = PublicKeyImportInput;
91
+ export type PrivateKeyImportInput = PublicKeyImportInput;
90
92
  /** PBES2 encryption options for the encrypted PKCS#8 export/import functions. */
91
- interface EncryptedPkcs8Options {
93
+ export interface EncryptedPkcs8Options {
92
94
  /** Password fed to PBKDF2 for key derivation. */
93
95
  readonly password: string;
94
- /** PBKDF2 iteration count. Default: `100_000`. */
96
+ /** PBKDF2 iteration count, an integer from 1 to 4294967295. Default: `100_000`. */
95
97
  readonly iterations?: number;
96
98
  /** PBKDF2 salt. Default: 16 cryptographically random bytes. */
97
99
  readonly salt?: Uint8Array;
@@ -103,7 +105,7 @@ interface EncryptedPkcs8Options {
103
105
  readonly prf?: "HMAC-SHA-1" | "HMAC-SHA-256";
104
106
  }
105
107
  /** Options for OpenSSL-style `Proc-Type: 4,ENCRYPTED` PEM encryption (PKCS#1/SEC1). */
106
- interface LegacyPemEncryptionOptions {
108
+ export interface LegacyPemEncryptionOptions {
107
109
  /** Passphrase used to derive the encryption key. */
108
110
  readonly password: string;
109
111
  /** 16-byte initialization vector. Random when omitted. */
@@ -111,21 +113,28 @@ interface LegacyPemEncryptionOptions {
111
113
  /** AES-CBC cipher. Defaults to `'AES-256-CBC'`. */
112
114
  readonly cipher?: "AES-128-CBC" | "AES-192-CBC" | "AES-256-CBC";
113
115
  }
114
- /** Machine-readable failure reason for the `import*` key functions. */
115
- type ImportKeyErrorCode = "malformed";
116
+ /**
117
+ * Machine-readable failure reason for the `import*` key functions.
118
+ *
119
+ * `limit_exceeded` is an implementation limit: an OBJECT IDENTIFIER
120
+ * sub-identifier encoded in more than 64 octets, a tag number of 2^53 or more,
121
+ * or DER nested deeper than 64 levels.
122
+ */
123
+ export type ImportKeyErrorCode = Exclude<DecodeFailureCode, "unsupported">;
116
124
  /** Structured failure payload for key import. */
117
- interface ImportKeyFailure extends Micro509Error<ImportKeyErrorCode> {
125
+ export interface ImportKeyFailure extends Micro509Error<ImportKeyErrorCode> {
118
126
  /** Always `false` for failures. */
119
127
  readonly ok: false;
120
128
  }
121
129
  /**
122
130
  * Success-or-failure result returned by the public `import*` key functions.
123
131
  *
124
- * On failure, `code` is always `'malformed'`: structurally invalid input,
125
- * algorithm mismatches, and wrong-password decryption failures all surface
126
- * the same way (see the throwing `*OrThrow` variants for raw error messages).
132
+ * On failure, `code` is `'malformed'` for structurally invalid input,
133
+ * algorithm mismatches, and wrong-password decryption failures alike (see the
134
+ * throwing `*OrThrow` variants for raw error messages), and `'limit_exceeded'`
135
+ * for an implementation limit.
127
136
  */
128
- type ImportKeyResult<T> = {
137
+ export type ImportKeyResult<T> = {
129
138
  readonly ok: true;
130
139
  readonly value: T;
131
140
  } | ErrorResult<ImportKeyErrorCode, Record<never, never>, ImportKeyFailure>;
@@ -133,11 +142,16 @@ type ImportKeyResult<T> = {
133
142
  * Machine-readable failure reason for the `importEncrypted*` key functions.
134
143
  *
135
144
  * Distinguishes a wrong decryption password (`'invalid_password'`) from
136
- * structurally invalid input or algorithm mismatches (`'malformed'`).
137
- */
138
- type ImportEncryptedKeyErrorCode = "malformed" | "invalid_password";
145
+ * structurally invalid input or algorithm mismatches (`'malformed'`), from an
146
+ * encoded KDF iteration count above the caller's limit
147
+ * (`'kdf_iterations_exceeded'`), and from a decoding limit of micro509's own
148
+ * (`'limit_exceeded'`, see {@linkcode ImportKeyErrorCode}).
149
+ */
150
+ export type ImportEncryptedKeyErrorCode = ImportKeyErrorCode | "invalid_password" | "kdf_iterations_exceeded";
151
+ /** Options for the encrypted PKCS#8 import functions. */
152
+ export type ImportEncryptedKeyOptions = KdfLimitOptions;
139
153
  /** Structured failure payload for encrypted key import. */
140
- interface ImportEncryptedKeyFailure extends Micro509Error<ImportEncryptedKeyErrorCode> {
154
+ export interface ImportEncryptedKeyFailure extends Micro509Error<ImportEncryptedKeyErrorCode> {
141
155
  /** Always `false` for failures. */
142
156
  readonly ok: false;
143
157
  }
@@ -147,12 +161,12 @@ interface ImportEncryptedKeyFailure extends Micro509Error<ImportEncryptedKeyErro
147
161
  * On failure, `code` is `'invalid_password'` when decryption failed (wrong
148
162
  * password or corrupted ciphertext) and `'malformed'` for everything else.
149
163
  */
150
- type ImportEncryptedKeyResult<T> = {
164
+ export type ImportEncryptedKeyResult<T> = {
151
165
  readonly ok: true;
152
166
  readonly value: T;
153
167
  } | ErrorResult<ImportEncryptedKeyErrorCode, Record<never, never>, ImportEncryptedKeyFailure>;
154
168
  /** Options shared by {@linkcode encryptRsaOaep} and {@linkcode decryptRsaOaep}. */
155
- interface RsaOaepOptions {
169
+ export interface RsaOaepOptions {
156
170
  /**
157
171
  * Optional OAEP label bound to the ciphertext. Not encrypted, but decryption
158
172
  * fails unless the exact same label is presented. Default: empty.
@@ -166,14 +180,14 @@ interface RsaOaepOptions {
166
180
  * usage; `'message_too_long'` when the plaintext exceeds the OAEP capacity of
167
181
  * the key (modulus bytes − 2 × hash bytes − 2).
168
182
  */
169
- type EncryptRsaOaepErrorCode = "invalid_key" | "message_too_long";
183
+ export type EncryptRsaOaepErrorCode = "invalid_key" | "message_too_long";
170
184
  /** Structured failure payload for {@linkcode encryptRsaOaep}. */
171
- interface EncryptRsaOaepFailure extends Micro509Error<EncryptRsaOaepErrorCode> {
185
+ export interface EncryptRsaOaepFailure extends Micro509Error<EncryptRsaOaepErrorCode> {
172
186
  /** Always `false` for failures. */
173
187
  readonly ok: false;
174
188
  }
175
189
  /** Success-or-failure result returned by {@linkcode encryptRsaOaep}. */
176
- type EncryptRsaOaepResult = {
190
+ export type EncryptRsaOaepResult = {
177
191
  readonly ok: true;
178
192
  readonly value: Uint8Array;
179
193
  } | ErrorResult<EncryptRsaOaepErrorCode, Record<never, never>, EncryptRsaOaepFailure>;
@@ -185,14 +199,14 @@ type EncryptRsaOaepResult = {
185
199
  * wrong label, tampered or truncated ciphertext) — OAEP deliberately does not
186
200
  * reveal which.
187
201
  */
188
- type DecryptRsaOaepErrorCode = "invalid_key" | "decryption_failed";
202
+ export type DecryptRsaOaepErrorCode = "invalid_key" | "decryption_failed";
189
203
  /** Structured failure payload for {@linkcode decryptRsaOaep}. */
190
- interface DecryptRsaOaepFailure extends Micro509Error<DecryptRsaOaepErrorCode> {
204
+ export interface DecryptRsaOaepFailure extends Micro509Error<DecryptRsaOaepErrorCode> {
191
205
  /** Always `false` for failures. */
192
206
  readonly ok: false;
193
207
  }
194
208
  /** Success-or-failure result returned by {@linkcode decryptRsaOaep}. */
195
- type DecryptRsaOaepResult = {
209
+ export type DecryptRsaOaepResult = {
196
210
  readonly ok: true;
197
211
  readonly value: Uint8Array;
198
212
  } | ErrorResult<DecryptRsaOaepErrorCode, Record<never, never>, DecryptRsaOaepFailure>;
@@ -212,14 +226,14 @@ type DecryptRsaOaepResult = {
212
226
  * const pem = await keys.exportPkcs8Pem();
213
227
  * ```
214
228
  */
215
- declare function generateKeyPair(algorithm?: KeyAlgorithmInput): Promise<KeyPairMaterial>;
229
+ export declare function generateKeyPair(algorithm?: KeyAlgorithmInput): Promise<KeyPairMaterial>;
216
230
  /**
217
231
  * Export a public key as DER-encoded SubjectPublicKeyInfo.
218
232
  *
219
233
  * @see {@linkcode importSpkiDer} for the inverse operation
220
234
  * @see {@linkcode exportSpkiPem} for PEM output
221
235
  */
222
- declare function exportSpkiDer(publicKey: CryptoKey): Promise<Uint8Array>;
236
+ export declare function exportSpkiDer(publicKey: CryptoKey): Promise<Uint8Array>;
223
237
  /**
224
238
  * Export a private key as DER-encoded PKCS#8 PrivateKeyInfo.
225
239
  *
@@ -227,7 +241,7 @@ declare function exportSpkiDer(publicKey: CryptoKey): Promise<Uint8Array>;
227
241
  * @see {@linkcode exportPkcs8Pem} for PEM output
228
242
  * @see {@linkcode exportEncryptedPkcs8Der} for password-protected export
229
243
  */
230
- declare function exportPkcs8Der(privateKey: CryptoKey): Promise<Uint8Array>;
244
+ export declare function exportPkcs8Der(privateKey: CryptoKey): Promise<Uint8Array>;
231
245
  /**
232
246
  * Export a public key as a JSON Web Key.
233
247
  *
@@ -237,14 +251,14 @@ declare function exportPkcs8Der(privateKey: CryptoKey): Promise<Uint8Array>;
237
251
  * const jwk = await exportPublicJwk(keys.publicKey);
238
252
  * ```
239
253
  */
240
- declare function exportPublicJwk(publicKey: CryptoKey): Promise<JsonWebKey>;
254
+ export declare function exportPublicJwk(publicKey: CryptoKey): Promise<JsonWebKey>;
241
255
  /**
242
256
  * Export a private key as a JSON Web Key.
243
257
  *
244
258
  * @see {@linkcode importPrivateJwk} for the inverse operation
245
259
  * @see {@linkcode exportPublicJwk} for public key export
246
260
  */
247
- declare function exportPrivateJwk(privateKey: CryptoKey): Promise<JsonWebKey>;
261
+ export declare function exportPrivateJwk(privateKey: CryptoKey): Promise<JsonWebKey>;
248
262
  /**
249
263
  * Export a private key as PEM-encoded PKCS#8 PrivateKeyInfo.
250
264
  *
@@ -260,7 +274,7 @@ declare function exportPrivateJwk(privateKey: CryptoKey): Promise<JsonWebKey>;
260
274
  * @see {@linkcode importPkcs8Pem} for the inverse operation
261
275
  * @see {@linkcode exportEncryptedPkcs8Pem} for password-protected export
262
276
  */
263
- declare function exportPkcs8Pem(privateKey: CryptoKey): Promise<string>;
277
+ export declare function exportPkcs8Pem(privateKey: CryptoKey): Promise<string>;
264
278
  /**
265
279
  * Export a private key as DER-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.
266
280
  *
@@ -269,10 +283,12 @@ declare function exportPkcs8Pem(privateKey: CryptoKey): Promise<string>;
269
283
  * @param privateKey - The private key to export
270
284
  * @param options - Encryption options including password and optional algorithm settings
271
285
  *
286
+ * @throws {RangeError} If `options.iterations` is not an integer from 1 to 4294967295
287
+ *
272
288
  * @see {@linkcode importEncryptedPkcs8Der} for the inverse operation
273
289
  * @see {@linkcode exportEncryptedPkcs8Pem} for PEM output
274
290
  */
275
- declare function exportEncryptedPkcs8Der(privateKey: CryptoKey, options: EncryptedPkcs8Options): Promise<Uint8Array>;
291
+ export declare function exportEncryptedPkcs8Der(privateKey: CryptoKey, options: EncryptedPkcs8Options): Promise<Uint8Array>;
276
292
  /**
277
293
  * Export a private key as PEM-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.
278
294
  *
@@ -287,7 +303,7 @@ declare function exportEncryptedPkcs8Der(privateKey: CryptoKey, options: Encrypt
287
303
  *
288
304
  * @see {@linkcode importEncryptedPkcs8Pem} for the inverse operation
289
305
  */
290
- declare function exportEncryptedPkcs8Pem(privateKey: CryptoKey, options: EncryptedPkcs8Options): Promise<string>;
306
+ export declare function exportEncryptedPkcs8Pem(privateKey: CryptoKey, options: EncryptedPkcs8Options): Promise<string>;
291
307
  /**
292
308
  * Export an RSA private key as DER-encoded PKCS#1 RSAPrivateKey.
293
309
  *
@@ -299,7 +315,7 @@ declare function exportEncryptedPkcs8Pem(privateKey: CryptoKey, options: Encrypt
299
315
  * @see {@linkcode importPkcs1Der} for the inverse operation
300
316
  * @see {@linkcode exportPkcs1Pem} for PEM output
301
317
  */
302
- declare function exportPkcs1Der(privateKey: CryptoKey): Promise<Uint8Array>;
318
+ export declare function exportPkcs1Der(privateKey: CryptoKey): Promise<Uint8Array>;
303
319
  /**
304
320
  * Export an RSA private key as PEM-encoded PKCS#1 RSAPrivateKey.
305
321
  *
@@ -308,7 +324,7 @@ declare function exportPkcs1Der(privateKey: CryptoKey): Promise<Uint8Array>;
308
324
  * @see {@linkcode importPkcs1Pem} for the inverse operation
309
325
  * @see {@linkcode exportEncryptedPkcs1Pem} for password-protected export
310
326
  */
311
- declare function exportPkcs1Pem(privateKey: CryptoKey): Promise<string>;
327
+ export declare function exportPkcs1Pem(privateKey: CryptoKey): Promise<string>;
312
328
  /**
313
329
  * Export an RSA private key as legacy `Proc-Type: 4,ENCRYPTED` PEM (PKCS#1).
314
330
  *
@@ -319,7 +335,7 @@ declare function exportPkcs1Pem(privateKey: CryptoKey): Promise<string>;
319
335
  *
320
336
  * @see {@linkcode importEncryptedPkcs1Pem} for the inverse operation
321
337
  */
322
- declare function exportEncryptedPkcs1Pem(privateKey: CryptoKey, options: LegacyPemEncryptionOptions): Promise<string>;
338
+ export declare function exportEncryptedPkcs1Pem(privateKey: CryptoKey, options: LegacyPemEncryptionOptions): Promise<string>;
323
339
  /**
324
340
  * Export an EC private key as DER-encoded SEC 1 ECPrivateKey.
325
341
  *
@@ -335,7 +351,7 @@ declare function exportEncryptedPkcs1Pem(privateKey: CryptoKey, options: LegacyP
335
351
  * @see {@linkcode importSec1Der} for the inverse operation
336
352
  * @see {@linkcode exportSec1Pem} for PEM output
337
353
  */
338
- declare function exportSec1Der(privateKey: CryptoKey): Promise<Uint8Array>;
354
+ export declare function exportSec1Der(privateKey: CryptoKey): Promise<Uint8Array>;
339
355
  /**
340
356
  * Export an EC private key as PEM-encoded SEC 1 ECPrivateKey.
341
357
  *
@@ -344,7 +360,7 @@ declare function exportSec1Der(privateKey: CryptoKey): Promise<Uint8Array>;
344
360
  * @see {@linkcode importSec1Pem} for the inverse operation
345
361
  * @see {@linkcode exportEncryptedSec1Pem} for password-protected export
346
362
  */
347
- declare function exportSec1Pem(privateKey: CryptoKey): Promise<string>;
363
+ export declare function exportSec1Pem(privateKey: CryptoKey): Promise<string>;
348
364
  /**
349
365
  * Export an EC private key as legacy `Proc-Type: 4,ENCRYPTED` PEM (SEC 1).
350
366
  *
@@ -355,7 +371,7 @@ declare function exportSec1Pem(privateKey: CryptoKey): Promise<string>;
355
371
  *
356
372
  * @see {@linkcode importEncryptedSec1Pem} for the inverse operation
357
373
  */
358
- declare function exportEncryptedSec1Pem(privateKey: CryptoKey, options: LegacyPemEncryptionOptions): Promise<string>;
374
+ export declare function exportEncryptedSec1Pem(privateKey: CryptoKey, options: LegacyPemEncryptionOptions): Promise<string>;
359
375
  /**
360
376
  * Export a public key as PEM-encoded SubjectPublicKeyInfo.
361
377
  *
@@ -365,7 +381,7 @@ declare function exportEncryptedSec1Pem(privateKey: CryptoKey, options: LegacyPe
365
381
  * const pem = await exportSpkiPem(keys.publicKey);
366
382
  * ```
367
383
  */
368
- declare function exportSpkiPem(publicKey: CryptoKey): Promise<string>;
384
+ export declare function exportSpkiPem(publicKey: CryptoKey): Promise<string>;
369
385
  /**
370
386
  * Derive the matching public key from an imported (or generated) private key.
371
387
  *
@@ -396,7 +412,7 @@ declare function exportSpkiPem(publicKey: CryptoKey): Promise<string>;
396
412
  *
397
413
  * @see {@linkcode exportSpkiDer} for exporting the derived key
398
414
  */
399
- declare function derivePublicKey(privateKey: CryptoKey): Promise<CryptoKey>;
415
+ export declare function derivePublicKey(privateKey: CryptoKey): Promise<CryptoKey>;
400
416
  /**
401
417
  * Export a key as raw base64 (no PEM headers).
402
418
  *
@@ -408,7 +424,7 @@ declare function derivePublicKey(privateKey: CryptoKey): Promise<CryptoKey>;
408
424
  * @see {@linkcode importSpkiBase64} for public key import
409
425
  * @see {@linkcode importPkcs8Base64} for private key import
410
426
  */
411
- declare function exportBinaryBase64(key: CryptoKey): Promise<string>;
427
+ export declare function exportBinaryBase64(key: CryptoKey): Promise<string>;
412
428
  /**
413
429
  * Import a public key from DER-encoded SubjectPublicKeyInfo.
414
430
  *
@@ -426,13 +442,13 @@ declare function exportBinaryBase64(key: CryptoKey): Promise<string>;
426
442
  * @see {@linkcode exportSpkiDer} for the inverse operation
427
443
  * @see {@linkcode importSpkiPem} for PEM input
428
444
  */
429
- declare function importSpkiDerOrThrow(der: Uint8Array, algorithm?: PublicKeyImportInput): Promise<CryptoKey>;
445
+ export declare function importSpkiDerOrThrow(der: Uint8Array, algorithm?: PublicKeyImportInput): Promise<CryptoKey>;
430
446
  /**
431
447
  * Import a public key from DER-encoded SubjectPublicKeyInfo.
432
448
  *
433
449
  * @see `importSpkiDerOrThrow` for the throwing variant
434
450
  */
435
- declare function importSpkiDer(der: Uint8Array, algorithm?: PublicKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
451
+ export declare function importSpkiDer(der: Uint8Array, algorithm?: PublicKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
436
452
  /**
437
453
  * Import a public key from PEM-encoded SubjectPublicKeyInfo.
438
454
  *
@@ -446,26 +462,26 @@ declare function importSpkiDer(der: Uint8Array, algorithm?: PublicKeyImportInput
446
462
  *
447
463
  * @see {@linkcode exportSpkiPem} for the inverse operation
448
464
  */
449
- declare function importSpkiPemOrThrow(pem: string, algorithm?: PublicKeyImportInput): Promise<CryptoKey>;
465
+ export declare function importSpkiPemOrThrow(pem: string, algorithm?: PublicKeyImportInput): Promise<CryptoKey>;
450
466
  /**
451
467
  * Import a public key from PEM-encoded SubjectPublicKeyInfo.
452
468
  *
453
469
  * @see `importSpkiPemOrThrow` for the throwing variant
454
470
  */
455
- declare function importSpkiPem(pem: string, algorithm?: PublicKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
471
+ export declare function importSpkiPem(pem: string, algorithm?: PublicKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
456
472
  /**
457
473
  * Import a public key from base64-encoded SubjectPublicKeyInfo (no PEM headers).
458
474
  *
459
475
  * @see {@linkcode exportBinaryBase64} for the inverse operation
460
476
  * @see {@linkcode importSpkiPem} for PEM input with headers
461
477
  */
462
- declare function importSpkiBase64OrThrow(base64: string, algorithm?: PublicKeyImportInput): Promise<CryptoKey>;
478
+ export declare function importSpkiBase64OrThrow(base64: string, algorithm?: PublicKeyImportInput): Promise<CryptoKey>;
463
479
  /**
464
480
  * Import a public key from base64-encoded SubjectPublicKeyInfo (no PEM headers).
465
481
  *
466
482
  * @see `importSpkiBase64OrThrow` for the throwing variant
467
483
  */
468
- declare function importSpkiBase64(base64: string, algorithm?: PublicKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
484
+ export declare function importSpkiBase64(base64: string, algorithm?: PublicKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
469
485
  /**
470
486
  * Import a private key from DER-encoded PKCS#8 PrivateKeyInfo.
471
487
  *
@@ -490,13 +506,13 @@ declare function importSpkiBase64(base64: string, algorithm?: PublicKeyImportInp
490
506
  * @see {@linkcode importPkcs8Pem} for PEM input
491
507
  * @see {@linkcode importEncryptedPkcs8Der} for encrypted PKCS#8
492
508
  */
493
- declare function importPkcs8DerOrThrow(der: Uint8Array, algorithm?: PrivateKeyImportInput): Promise<CryptoKey>;
509
+ export declare function importPkcs8DerOrThrow(der: Uint8Array, algorithm?: PrivateKeyImportInput): Promise<CryptoKey>;
494
510
  /**
495
511
  * Import a private key from DER-encoded PKCS#8 PrivateKeyInfo.
496
512
  *
497
513
  * @see `importPkcs8DerOrThrow` for the throwing variant
498
514
  */
499
- declare function importPkcs8Der(der: Uint8Array, algorithm?: PrivateKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
515
+ export declare function importPkcs8Der(der: Uint8Array, algorithm?: PrivateKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
500
516
  /**
501
517
  * Import a private key from PEM-encoded PKCS#8 PrivateKeyInfo.
502
518
  *
@@ -509,13 +525,13 @@ declare function importPkcs8Der(der: Uint8Array, algorithm?: PrivateKeyImportInp
509
525
  * const inferred = await importPkcs8PemOrThrow(pemString);
510
526
  * ```
511
527
  */
512
- declare function importPkcs8PemOrThrow(pem: string, algorithm?: PrivateKeyImportInput): Promise<CryptoKey>;
528
+ export declare function importPkcs8PemOrThrow(pem: string, algorithm?: PrivateKeyImportInput): Promise<CryptoKey>;
513
529
  /**
514
530
  * Import a private key from PEM-encoded PKCS#8 PrivateKeyInfo.
515
531
  *
516
532
  * @see `importPkcs8PemOrThrow` for the throwing variant
517
533
  */
518
- declare function importPkcs8Pem(pem: string, algorithm?: PrivateKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
534
+ export declare function importPkcs8Pem(pem: string, algorithm?: PrivateKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
519
535
  /**
520
536
  * Import a private key from DER-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.
521
537
  *
@@ -527,25 +543,28 @@ declare function importPkcs8Pem(pem: string, algorithm?: PrivateKeyImportInput):
527
543
  * @param der - DER-encoded EncryptedPrivateKeyInfo bytes
528
544
  * @param password - Decryption password
529
545
  * @param algorithm - Optional expected algorithm; must match decrypted key when given
546
+ * @param options - KDF work-factor limit
530
547
  *
531
- * @throws {Error} If DER is malformed, password is wrong, or algorithm doesn't match
548
+ * @throws {Error} If DER is malformed, password is wrong, the PBKDF2 iteration
549
+ * count exceeds `options.maxKdfIterations`, or algorithm doesn't match
532
550
  *
533
551
  * @see {@linkcode exportEncryptedPkcs8Der} for the inverse operation
534
552
  */
535
- declare function importEncryptedPkcs8DerOrThrow(der: Uint8Array, password: string, algorithm?: PrivateKeyImportInput): Promise<CryptoKey>;
553
+ export declare function importEncryptedPkcs8DerOrThrow(der: Uint8Array, password: string, algorithm?: PrivateKeyImportInput, options?: ImportEncryptedKeyOptions): Promise<CryptoKey>;
536
554
  /**
537
555
  * Reads the PBES2 encryption parameters of a DER PKCS#8
538
556
  * `EncryptedPrivateKeyInfo` (RFC 5958 §3) without the password: PBKDF2
539
557
  * iteration count, salt, and PRF, plus the AES-CBC variant and IV.
540
- * Throws on malformed DER or a non-PBES2 encryption algorithm.
558
+ * Throws on malformed DER, a non-PBES2 encryption algorithm, or a PBKDF2
559
+ * iteration count outside 1 to 4294967295.
541
560
  */
542
- declare function inspectEncryptedPkcs8Der(der: Uint8Array): Pbes2Parameters;
561
+ export declare function inspectEncryptedPkcs8Der(der: Uint8Array): Pbes2Parameters;
543
562
  /**
544
563
  * Import a private key from DER-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.
545
564
  *
546
565
  * @see `importEncryptedPkcs8DerOrThrow` for the throwing variant
547
566
  */
548
- declare function importEncryptedPkcs8Der(der: Uint8Array, password: string, algorithm?: PrivateKeyImportInput): Promise<ImportEncryptedKeyResult<CryptoKey>>;
567
+ export declare function importEncryptedPkcs8Der(der: Uint8Array, password: string, algorithm?: PrivateKeyImportInput, options?: ImportEncryptedKeyOptions): Promise<ImportEncryptedKeyResult<CryptoKey>>;
549
568
  /**
550
569
  * Import a private key from PEM-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.
551
570
  *
@@ -558,13 +577,13 @@ declare function importEncryptedPkcs8Der(der: Uint8Array, password: string, algo
558
577
  * const inferred = await importEncryptedPkcs8PemOrThrow(pem, 'secret');
559
578
  * ```
560
579
  */
561
- declare function importEncryptedPkcs8PemOrThrow(pem: string, password: string, algorithm?: PrivateKeyImportInput): Promise<CryptoKey>;
580
+ export declare function importEncryptedPkcs8PemOrThrow(pem: string, password: string, algorithm?: PrivateKeyImportInput, options?: ImportEncryptedKeyOptions): Promise<CryptoKey>;
562
581
  /**
563
582
  * Import a private key from PEM-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.
564
583
  *
565
584
  * @see `importEncryptedPkcs8PemOrThrow` for the throwing variant
566
585
  */
567
- declare function importEncryptedPkcs8Pem(pem: string, password: string, algorithm?: PrivateKeyImportInput): Promise<ImportEncryptedKeyResult<CryptoKey>>;
586
+ export declare function importEncryptedPkcs8Pem(pem: string, password: string, algorithm?: PrivateKeyImportInput, options?: ImportEncryptedKeyOptions): Promise<ImportEncryptedKeyResult<CryptoKey>>;
568
587
  /**
569
588
  * Import an RSA private key from DER-encoded PKCS#1 RSAPrivateKey.
570
589
  *
@@ -573,13 +592,13 @@ declare function importEncryptedPkcs8Pem(pem: string, password: string, algorith
573
592
  * @see {@linkcode exportPkcs1Der} for the inverse operation
574
593
  * @see {@linkcode importPkcs1Pem} for PEM input
575
594
  */
576
- declare function importPkcs1DerOrThrow(der: Uint8Array, algorithm?: ImportRsaKeyInput): Promise<CryptoKey>;
595
+ export declare function importPkcs1DerOrThrow(der: Uint8Array, algorithm?: ImportRsaKeyInput): Promise<CryptoKey>;
577
596
  /**
578
597
  * Import an RSA private key from DER-encoded PKCS#1 RSAPrivateKey.
579
598
  *
580
599
  * @see `importPkcs1DerOrThrow` for the throwing variant
581
600
  */
582
- declare function importPkcs1Der(der: Uint8Array, algorithm?: ImportRsaKeyInput): Promise<ImportKeyResult<CryptoKey>>;
601
+ export declare function importPkcs1Der(der: Uint8Array, algorithm?: ImportRsaKeyInput): Promise<ImportKeyResult<CryptoKey>>;
583
602
  /**
584
603
  * Import an RSA private key from PEM-encoded PKCS#1 RSAPrivateKey.
585
604
  *
@@ -588,13 +607,13 @@ declare function importPkcs1Der(der: Uint8Array, algorithm?: ImportRsaKeyInput):
588
607
  * @see {@linkcode exportPkcs1Pem} for the inverse operation
589
608
  * @see {@linkcode importEncryptedPkcs1Pem} for encrypted PEM
590
609
  */
591
- declare function importPkcs1PemOrThrow(pem: string, algorithm?: ImportRsaKeyInput): Promise<CryptoKey>;
610
+ export declare function importPkcs1PemOrThrow(pem: string, algorithm?: ImportRsaKeyInput): Promise<CryptoKey>;
592
611
  /**
593
612
  * Import an RSA private key from PEM-encoded PKCS#1 RSAPrivateKey.
594
613
  *
595
614
  * @see `importPkcs1PemOrThrow` for the throwing variant
596
615
  */
597
- declare function importPkcs1Pem(pem: string, algorithm?: ImportRsaKeyInput): Promise<ImportKeyResult<CryptoKey>>;
616
+ export declare function importPkcs1Pem(pem: string, algorithm?: ImportRsaKeyInput): Promise<ImportKeyResult<CryptoKey>>;
598
617
  /**
599
618
  * Import an RSA private key from legacy `Proc-Type: 4,ENCRYPTED` PEM (PKCS#1).
600
619
  *
@@ -603,26 +622,26 @@ declare function importPkcs1Pem(pem: string, algorithm?: ImportRsaKeyInput): Pro
603
622
  * @see {@linkcode exportEncryptedPkcs1Pem} for the inverse operation
604
623
  * @see {@linkcode importEncryptedPkcs8Pem} for modern PBES2 encryption
605
624
  */
606
- declare function importEncryptedPkcs1PemOrThrow(pem: string, password: string, algorithm?: ImportRsaKeyInput): Promise<CryptoKey>;
625
+ export declare function importEncryptedPkcs1PemOrThrow(pem: string, password: string, algorithm?: ImportRsaKeyInput): Promise<CryptoKey>;
607
626
  /**
608
627
  * Import an RSA private key from legacy `Proc-Type: 4,ENCRYPTED` PEM (PKCS#1).
609
628
  *
610
629
  * @see `importEncryptedPkcs1PemOrThrow` for the throwing variant
611
630
  */
612
- declare function importEncryptedPkcs1Pem(pem: string, password: string, algorithm?: ImportRsaKeyInput): Promise<ImportEncryptedKeyResult<CryptoKey>>;
631
+ export declare function importEncryptedPkcs1Pem(pem: string, password: string, algorithm?: ImportRsaKeyInput): Promise<ImportEncryptedKeyResult<CryptoKey>>;
613
632
  /**
614
633
  * Import a private key from base64-encoded PKCS#8 PrivateKeyInfo (no PEM headers).
615
634
  *
616
635
  * @see {@linkcode exportBinaryBase64} for the inverse operation
617
636
  * @see {@linkcode importPkcs8Pem} for PEM input with headers
618
637
  */
619
- declare function importPkcs8Base64OrThrow(base64: string, algorithm?: PrivateKeyImportInput): Promise<CryptoKey>;
638
+ export declare function importPkcs8Base64OrThrow(base64: string, algorithm?: PrivateKeyImportInput): Promise<CryptoKey>;
620
639
  /**
621
640
  * Import a private key from base64-encoded PKCS#8 PrivateKeyInfo (no PEM headers).
622
641
  *
623
642
  * @see `importPkcs8Base64OrThrow` for the throwing variant
624
643
  */
625
- declare function importPkcs8Base64(base64: string, algorithm?: PrivateKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
644
+ export declare function importPkcs8Base64(base64: string, algorithm?: PrivateKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
626
645
  /**
627
646
  * Import an EC private key from DER-encoded SEC 1 ECPrivateKey.
628
647
  *
@@ -640,13 +659,13 @@ declare function importPkcs8Base64(base64: string, algorithm?: PrivateKeyImportI
640
659
  * @see {@linkcode exportSec1Der} for the inverse operation
641
660
  * @see {@linkcode importSec1Pem} for PEM input
642
661
  */
643
- declare function importSec1DerOrThrow(der: Uint8Array, algorithm?: ImportEcKeyInput): Promise<CryptoKey>;
662
+ export declare function importSec1DerOrThrow(der: Uint8Array, algorithm?: ImportEcKeyInput): Promise<CryptoKey>;
644
663
  /**
645
664
  * Import an EC private key from DER-encoded SEC 1 ECPrivateKey.
646
665
  *
647
666
  * @see `importSec1DerOrThrow` for the throwing variant
648
667
  */
649
- declare function importSec1Der(der: Uint8Array, algorithm?: ImportEcKeyInput): Promise<ImportKeyResult<CryptoKey>>;
668
+ export declare function importSec1Der(der: Uint8Array, algorithm?: ImportEcKeyInput): Promise<ImportKeyResult<CryptoKey>>;
650
669
  /**
651
670
  * Import an EC private key from PEM-encoded SEC 1 ECPrivateKey.
652
671
  *
@@ -657,13 +676,13 @@ declare function importSec1Der(der: Uint8Array, algorithm?: ImportEcKeyInput): P
657
676
  * @see {@linkcode exportSec1Pem} for the inverse operation
658
677
  * @see {@linkcode importEncryptedSec1Pem} for encrypted PEM
659
678
  */
660
- declare function importSec1PemOrThrow(pem: string, algorithm?: ImportEcKeyInput): Promise<CryptoKey>;
679
+ export declare function importSec1PemOrThrow(pem: string, algorithm?: ImportEcKeyInput): Promise<CryptoKey>;
661
680
  /**
662
681
  * Import an EC private key from PEM-encoded SEC 1 ECPrivateKey.
663
682
  *
664
683
  * @see `importSec1PemOrThrow` for the throwing variant
665
684
  */
666
- declare function importSec1Pem(pem: string, algorithm?: ImportEcKeyInput): Promise<ImportKeyResult<CryptoKey>>;
685
+ export declare function importSec1Pem(pem: string, algorithm?: ImportEcKeyInput): Promise<ImportKeyResult<CryptoKey>>;
667
686
  /**
668
687
  * Import an EC private key from legacy `Proc-Type: 4,ENCRYPTED` PEM (SEC 1).
669
688
  *
@@ -672,13 +691,13 @@ declare function importSec1Pem(pem: string, algorithm?: ImportEcKeyInput): Promi
672
691
  * @see {@linkcode exportEncryptedSec1Pem} for the inverse operation
673
692
  * @see {@linkcode importEncryptedPkcs8Pem} for modern PBES2 encryption
674
693
  */
675
- declare function importEncryptedSec1PemOrThrow(pem: string, password: string, algorithm?: ImportEcKeyInput): Promise<CryptoKey>;
694
+ export declare function importEncryptedSec1PemOrThrow(pem: string, password: string, algorithm?: ImportEcKeyInput): Promise<CryptoKey>;
676
695
  /**
677
696
  * Import an EC private key from legacy `Proc-Type: 4,ENCRYPTED` PEM (SEC 1).
678
697
  *
679
698
  * @see `importEncryptedSec1PemOrThrow` for the throwing variant
680
699
  */
681
- declare function importEncryptedSec1Pem(pem: string, password: string, algorithm?: ImportEcKeyInput): Promise<ImportEncryptedKeyResult<CryptoKey>>;
700
+ export declare function importEncryptedSec1Pem(pem: string, password: string, algorithm?: ImportEcKeyInput): Promise<ImportEncryptedKeyResult<CryptoKey>>;
682
701
  /**
683
702
  * Import a public verification key from a JSON Web Key.
684
703
  *
@@ -695,13 +714,13 @@ declare function importEncryptedSec1Pem(pem: string, password: string, algorithm
695
714
  *
696
715
  * @see {@linkcode exportPublicJwk} for the inverse operation
697
716
  */
698
- declare function importPublicJwkOrThrow(jwk: JsonWebKey, algorithm?: PublicKeyImportInput): Promise<CryptoKey>;
717
+ export declare function importPublicJwkOrThrow(jwk: JsonWebKey, algorithm?: PublicKeyImportInput): Promise<CryptoKey>;
699
718
  /**
700
719
  * Import a public verification key from a JSON Web Key.
701
720
  *
702
721
  * @see `importPublicJwkOrThrow` for the throwing variant
703
722
  */
704
- declare function importPublicJwk(jwk: JsonWebKey, algorithm?: PublicKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
723
+ export declare function importPublicJwk(jwk: JsonWebKey, algorithm?: PublicKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
705
724
  /**
706
725
  * Import a private signing key from a JSON Web Key.
707
726
  *
@@ -724,13 +743,13 @@ declare function importPublicJwk(jwk: JsonWebKey, algorithm?: PublicKeyImportInp
724
743
  *
725
744
  * @see {@linkcode exportPrivateJwk} for the inverse operation
726
745
  */
727
- declare function importPrivateJwkOrThrow(jwk: JsonWebKey, algorithm?: PrivateKeyImportInput): Promise<CryptoKey>;
746
+ export declare function importPrivateJwkOrThrow(jwk: JsonWebKey, algorithm?: PrivateKeyImportInput): Promise<CryptoKey>;
728
747
  /**
729
748
  * Import a private signing key from a JSON Web Key.
730
749
  *
731
750
  * @see `importPrivateJwkOrThrow` for the throwing variant
732
751
  */
733
- declare function importPrivateJwk(jwk: JsonWebKey, algorithm?: PrivateKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
752
+ export declare function importPrivateJwk(jwk: JsonWebKey, algorithm?: PrivateKeyImportInput): Promise<ImportKeyResult<CryptoKey>>;
734
753
  /**
735
754
  * Encrypt a small message with an RSA-OAEP public key.
736
755
  *
@@ -758,7 +777,7 @@ declare function importPrivateJwk(jwk: JsonWebKey, algorithm?: PrivateKeyImportI
758
777
  * @see {@linkcode decryptRsaOaepOrThrow} for the inverse operation
759
778
  * @see `encryptRsaOaep` for the Result-returning variant
760
779
  */
761
- declare function encryptRsaOaepOrThrow(publicKey: CryptoKey, plaintext: Uint8Array, options?: RsaOaepOptions): Promise<Uint8Array>;
780
+ export declare function encryptRsaOaepOrThrow(publicKey: CryptoKey, plaintext: Uint8Array, options?: RsaOaepOptions): Promise<Uint8Array>;
762
781
  /**
763
782
  * Encrypt a small message with an RSA-OAEP public key.
764
783
  *
@@ -775,7 +794,7 @@ declare function encryptRsaOaepOrThrow(publicKey: CryptoKey, plaintext: Uint8Arr
775
794
  *
776
795
  * @see `encryptRsaOaepOrThrow` for the throwing variant
777
796
  */
778
- declare function encryptRsaOaep(publicKey: CryptoKey, plaintext: Uint8Array, options?: RsaOaepOptions): Promise<EncryptRsaOaepResult>;
797
+ export declare function encryptRsaOaep(publicKey: CryptoKey, plaintext: Uint8Array, options?: RsaOaepOptions): Promise<EncryptRsaOaepResult>;
779
798
  /**
780
799
  * Decrypt an RSA-OAEP ciphertext with the matching private key.
781
800
  *
@@ -798,7 +817,7 @@ declare function encryptRsaOaep(publicKey: CryptoKey, plaintext: Uint8Array, opt
798
817
  * @see {@linkcode encryptRsaOaepOrThrow} for the inverse operation
799
818
  * @see `decryptRsaOaep` for the Result-returning variant
800
819
  */
801
- declare function decryptRsaOaepOrThrow(privateKey: CryptoKey, ciphertext: Uint8Array, options?: RsaOaepOptions): Promise<Uint8Array>;
820
+ export declare function decryptRsaOaepOrThrow(privateKey: CryptoKey, ciphertext: Uint8Array, options?: RsaOaepOptions): Promise<Uint8Array>;
802
821
  /**
803
822
  * Decrypt an RSA-OAEP ciphertext with the matching private key.
804
823
  *
@@ -814,7 +833,6 @@ declare function decryptRsaOaepOrThrow(privateKey: CryptoKey, ciphertext: Uint8A
814
833
  *
815
834
  * @see `decryptRsaOaepOrThrow` for the throwing variant
816
835
  */
817
- declare function decryptRsaOaep(privateKey: CryptoKey, ciphertext: Uint8Array, options?: RsaOaepOptions): Promise<DecryptRsaOaepResult>;
818
- //#endregion
819
- export { DecryptRsaOaepErrorCode, DecryptRsaOaepFailure, DecryptRsaOaepResult, EcKeyAlgorithmInput, EcNamedCurve, Ed25519KeyAlgorithmInput, EncryptRsaOaepErrorCode, EncryptRsaOaepFailure, EncryptRsaOaepResult, EncryptedPkcs8Options, ImportEcKeyInput, ImportEd25519KeyInput, ImportEncryptedKeyErrorCode, ImportEncryptedKeyFailure, ImportEncryptedKeyResult, ImportKeyErrorCode, ImportKeyFailure, ImportKeyResult, ImportRsaKeyInput, KeyAlgorithmInput, KeyPairMaterial, LegacyPemEncryptionOptions, type Pbes2EncryptionOptions, type Pbes2EncryptionScheme, type Pbes2Parameters, type Pbes2Prf, PrivateKeyImportInput, PublicKeyImportInput, RsaHash, RsaKeyAlgorithmInput, RsaOaepOptions, RsaScheme, RsaSignatureScheme, decryptRsaOaep, decryptRsaOaepOrThrow, derivePublicKey, encryptRsaOaep, encryptRsaOaepOrThrow, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, generateKeyPair, importEncryptedPkcs1Pem, importEncryptedPkcs1PemOrThrow, importEncryptedPkcs8Der, importEncryptedPkcs8DerOrThrow, importEncryptedPkcs8Pem, importEncryptedPkcs8PemOrThrow, importEncryptedSec1Pem, importEncryptedSec1PemOrThrow, importPkcs1Der, importPkcs1DerOrThrow, importPkcs1Pem, importPkcs1PemOrThrow, importPkcs8Base64, importPkcs8Base64OrThrow, importPkcs8Der, importPkcs8DerOrThrow, importPkcs8Pem, importPkcs8PemOrThrow, importPrivateJwk, importPrivateJwkOrThrow, importPublicJwk, importPublicJwkOrThrow, importSec1Der, importSec1DerOrThrow, importSec1Pem, importSec1PemOrThrow, importSpkiBase64, importSpkiBase64OrThrow, importSpkiDer, importSpkiDerOrThrow, importSpkiPem, importSpkiPemOrThrow, inspectEncryptedPkcs8Der, parsePbes2AlgorithmIdentifier };
836
+ export declare function decryptRsaOaep(privateKey: CryptoKey, ciphertext: Uint8Array, options?: RsaOaepOptions): Promise<DecryptRsaOaepResult>;
837
+ export { type KdfLimitOptions, type Pbes2EncryptionOptions, type Pbes2EncryptionScheme, type Pbes2Parameters, type Pbes2Prf, parsePbes2AlgorithmIdentifier };
820
838
  //# sourceMappingURL=keys.d.ts.map