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