@rio-cloud/cdk-v2-constructs 8.2.0 → 8.2.1-alpha.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 (179) hide show
  1. package/.jsii +2 -2
  2. package/node_modules/@types/node/README.md +3 -3
  3. package/node_modules/@types/node/assert/strict.d.ts +105 -2
  4. package/node_modules/@types/node/assert.d.ts +211 -92
  5. package/node_modules/@types/node/async_hooks.d.ts +103 -19
  6. package/node_modules/@types/node/buffer.buffer.d.ts +472 -0
  7. package/node_modules/@types/node/buffer.d.ts +88 -516
  8. package/node_modules/@types/node/child_process.d.ts +167 -231
  9. package/node_modules/@types/node/cluster.d.ts +172 -26
  10. package/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  11. package/node_modules/@types/node/console.d.ts +66 -28
  12. package/node_modules/@types/node/constants.d.ts +14 -12
  13. package/node_modules/@types/node/crypto.d.ts +1458 -497
  14. package/node_modules/@types/node/dgram.d.ts +44 -30
  15. package/node_modules/@types/node/diagnostics_channel.d.ts +389 -4
  16. package/node_modules/@types/node/dns/promises.d.ts +120 -42
  17. package/node_modules/@types/node/dns.d.ts +209 -95
  18. package/node_modules/@types/node/domain.d.ts +14 -18
  19. package/node_modules/@types/node/events.d.ts +245 -113
  20. package/node_modules/@types/node/fs/promises.d.ts +194 -96
  21. package/node_modules/@types/node/fs.d.ts +695 -270
  22. package/node_modules/@types/node/globals.d.ts +97 -308
  23. package/node_modules/@types/node/globals.typedarray.d.ts +41 -0
  24. package/node_modules/@types/node/http.d.ts +363 -97
  25. package/node_modules/@types/node/http2.d.ts +684 -231
  26. package/node_modules/@types/node/https.d.ts +122 -87
  27. package/node_modules/@types/node/index.d.ts +24 -11
  28. package/node_modules/@types/node/inspector.d.ts +220 -2690
  29. package/node_modules/@types/node/inspector.generated.d.ts +4239 -0
  30. package/node_modules/@types/node/module.d.ts +705 -149
  31. package/node_modules/@types/node/net.d.ts +178 -54
  32. package/node_modules/@types/node/os.d.ts +47 -17
  33. package/node_modules/@types/node/package.json +22 -97
  34. package/node_modules/@types/node/path.d.ts +12 -3
  35. package/node_modules/@types/node/perf_hooks.d.ts +500 -97
  36. package/node_modules/@types/node/process.d.ts +657 -87
  37. package/node_modules/@types/node/punycode.d.ts +5 -5
  38. package/node_modules/@types/node/querystring.d.ts +24 -13
  39. package/node_modules/@types/node/readline/promises.d.ts +25 -14
  40. package/node_modules/@types/node/readline.d.ts +102 -41
  41. package/node_modules/@types/node/repl.d.ts +38 -30
  42. package/node_modules/@types/node/sea.d.ts +162 -0
  43. package/node_modules/@types/node/sqlite.d.ts +1040 -0
  44. package/node_modules/@types/node/stream/consumers.d.ts +33 -7
  45. package/node_modules/@types/node/stream/promises.d.ts +8 -1
  46. package/node_modules/@types/node/stream/web.d.ts +251 -28
  47. package/node_modules/@types/node/stream.d.ts +1060 -1055
  48. package/node_modules/@types/node/string_decoder.d.ts +8 -8
  49. package/node_modules/@types/node/test.d.ts +2133 -1166
  50. package/node_modules/@types/node/timers/promises.d.ts +31 -16
  51. package/node_modules/@types/node/timers.d.ts +159 -114
  52. package/node_modules/@types/node/tls.d.ts +232 -163
  53. package/node_modules/@types/node/trace_events.d.ts +43 -28
  54. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
  55. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  56. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  57. package/node_modules/@types/node/ts5.6/index.d.ts +103 -0
  58. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  59. package/node_modules/@types/node/ts5.7/index.d.ts +103 -0
  60. package/node_modules/@types/node/tty.d.ts +9 -9
  61. package/node_modules/@types/node/url.d.ts +236 -84
  62. package/node_modules/@types/node/util.d.ts +562 -412
  63. package/node_modules/@types/node/v8.d.ts +368 -21
  64. package/node_modules/@types/node/vm.d.ts +443 -149
  65. package/node_modules/@types/node/wasi.d.ts +62 -18
  66. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  67. package/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
  68. package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  69. package/node_modules/@types/node/web-globals/events.d.ts +97 -0
  70. package/node_modules/@types/node/web-globals/fetch.d.ts +62 -0
  71. package/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  72. package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  73. package/node_modules/@types/node/web-globals/streams.d.ts +22 -0
  74. package/node_modules/@types/node/worker_threads.d.ts +310 -107
  75. package/node_modules/@types/node/zlib.d.ts +301 -73
  76. package/node_modules/undici-types/LICENSE +21 -0
  77. package/node_modules/undici-types/agent.d.ts +13 -12
  78. package/node_modules/undici-types/api.d.ts +26 -26
  79. package/node_modules/undici-types/balanced-pool.d.ts +19 -7
  80. package/node_modules/undici-types/cache-interceptor.d.ts +173 -0
  81. package/node_modules/undici-types/client-stats.d.ts +15 -0
  82. package/node_modules/undici-types/client.d.ts +26 -15
  83. package/node_modules/undici-types/connector.d.ts +2 -2
  84. package/node_modules/undici-types/cookies.d.ts +2 -0
  85. package/node_modules/undici-types/diagnostics-channel.d.ts +19 -12
  86. package/node_modules/undici-types/dispatcher.d.ts +148 -113
  87. package/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  88. package/node_modules/undici-types/errors.d.ts +79 -46
  89. package/node_modules/undici-types/eventsource.d.ts +66 -0
  90. package/node_modules/undici-types/fetch.d.ts +41 -39
  91. package/node_modules/undici-types/formdata.d.ts +8 -8
  92. package/node_modules/undici-types/global-dispatcher.d.ts +4 -4
  93. package/node_modules/undici-types/global-origin.d.ts +5 -5
  94. package/node_modules/undici-types/h2c-client.d.ts +73 -0
  95. package/node_modules/undici-types/handlers.d.ts +11 -5
  96. package/node_modules/undici-types/header.d.ts +157 -1
  97. package/node_modules/undici-types/index.d.ts +68 -43
  98. package/node_modules/undici-types/interceptors.d.ts +71 -3
  99. package/node_modules/undici-types/mock-agent.d.ts +36 -18
  100. package/node_modules/undici-types/mock-call-history.d.ts +111 -0
  101. package/node_modules/undici-types/mock-client.d.ts +6 -4
  102. package/node_modules/undici-types/mock-errors.d.ts +3 -3
  103. package/node_modules/undici-types/mock-interceptor.d.ts +24 -23
  104. package/node_modules/undici-types/mock-pool.d.ts +6 -4
  105. package/node_modules/undici-types/package.json +1 -1
  106. package/node_modules/undici-types/patch.d.ts +0 -42
  107. package/node_modules/undici-types/pool-stats.d.ts +8 -8
  108. package/node_modules/undici-types/pool.d.ts +21 -8
  109. package/node_modules/undici-types/proxy-agent.d.ts +5 -6
  110. package/node_modules/undici-types/readable.d.ts +24 -17
  111. package/node_modules/undici-types/retry-agent.d.ts +8 -0
  112. package/node_modules/undici-types/retry-handler.d.ts +125 -0
  113. package/node_modules/undici-types/round-robin-pool.d.ts +41 -0
  114. package/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  115. package/node_modules/undici-types/util.d.ts +18 -0
  116. package/node_modules/undici-types/utility.d.ts +7 -0
  117. package/node_modules/undici-types/webidl.d.ts +157 -36
  118. package/node_modules/undici-types/websocket.d.ts +67 -12
  119. package/package.json +9 -60
  120. package/version.json +1 -1
  121. package/node_modules/@types/node/dom-events.d.ts +0 -122
  122. package/node_modules/@types/node/globals.global.d.ts +0 -1
  123. package/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
  124. package/node_modules/@types/node/ts4.8/assert.d.ts +0 -996
  125. package/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -539
  126. package/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2362
  127. package/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1540
  128. package/node_modules/@types/node/ts4.8/cluster.d.ts +0 -432
  129. package/node_modules/@types/node/ts4.8/console.d.ts +0 -415
  130. package/node_modules/@types/node/ts4.8/constants.d.ts +0 -19
  131. package/node_modules/@types/node/ts4.8/crypto.d.ts +0 -4455
  132. package/node_modules/@types/node/ts4.8/dgram.d.ts +0 -586
  133. package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -191
  134. package/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -425
  135. package/node_modules/@types/node/ts4.8/dns.d.ts +0 -809
  136. package/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -122
  137. package/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
  138. package/node_modules/@types/node/ts4.8/events.d.ts +0 -796
  139. package/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1232
  140. package/node_modules/@types/node/ts4.8/fs.d.ts +0 -4289
  141. package/node_modules/@types/node/ts4.8/globals.d.ts +0 -381
  142. package/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
  143. package/node_modules/@types/node/ts4.8/http.d.ts +0 -1888
  144. package/node_modules/@types/node/ts4.8/http2.d.ts +0 -2382
  145. package/node_modules/@types/node/ts4.8/https.d.ts +0 -550
  146. package/node_modules/@types/node/ts4.8/index.d.ts +0 -88
  147. package/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2747
  148. package/node_modules/@types/node/ts4.8/module.d.ts +0 -287
  149. package/node_modules/@types/node/ts4.8/net.d.ts +0 -949
  150. package/node_modules/@types/node/ts4.8/os.d.ts +0 -477
  151. package/node_modules/@types/node/ts4.8/path.d.ts +0 -191
  152. package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -639
  153. package/node_modules/@types/node/ts4.8/process.d.ts +0 -1532
  154. package/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
  155. package/node_modules/@types/node/ts4.8/querystring.d.ts +0 -141
  156. package/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -150
  157. package/node_modules/@types/node/ts4.8/readline.d.ts +0 -539
  158. package/node_modules/@types/node/ts4.8/repl.d.ts +0 -430
  159. package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
  160. package/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -83
  161. package/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -350
  162. package/node_modules/@types/node/ts4.8/stream.d.ts +0 -1701
  163. package/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
  164. package/node_modules/@types/node/ts4.8/test.d.ts +0 -1382
  165. package/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
  166. package/node_modules/@types/node/ts4.8/timers.d.ts +0 -240
  167. package/node_modules/@types/node/ts4.8/tls.d.ts +0 -1210
  168. package/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -182
  169. package/node_modules/@types/node/ts4.8/tty.d.ts +0 -208
  170. package/node_modules/@types/node/ts4.8/url.d.ts +0 -927
  171. package/node_modules/@types/node/ts4.8/util.d.ts +0 -2186
  172. package/node_modules/@types/node/ts4.8/v8.d.ts +0 -635
  173. package/node_modules/@types/node/ts4.8/vm.d.ts +0 -901
  174. package/node_modules/@types/node/ts4.8/wasi.d.ts +0 -158
  175. package/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -691
  176. package/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
  177. package/node_modules/argparse/CHANGELOG.md +0 -216
  178. package/node_modules/undici-types/file.d.ts +0 -39
  179. package/node_modules/undici-types/filereader.d.ts +0 -54
@@ -14,9 +14,10 @@
14
14
  * // Prints:
15
15
  * // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
16
16
  * ```
17
- * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/crypto.js)
17
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/crypto.js)
18
18
  */
19
19
  declare module "crypto" {
20
+ import { NonSharedBuffer } from "node:buffer";
20
21
  import * as stream from "node:stream";
21
22
  import { PeerCertificate } from "node:tls";
22
23
  /**
@@ -27,7 +28,7 @@ declare module "crypto" {
27
28
  * should not use this element anymore.
28
29
  *
29
30
  * The `node:crypto` module provides the `Certificate` class for working with SPKAC
30
- * data. The most common usage is handling output generated by the HTML5`<keygen>` element. Node.js uses [OpenSSL's SPKAC
31
+ * data. The most common usage is handling output generated by the HTML5 `<keygen>` element. Node.js uses [OpenSSL's SPKAC
31
32
  * implementation](https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html) internally.
32
33
  * @since v0.11.8
33
34
  */
@@ -44,7 +45,7 @@ declare module "crypto" {
44
45
  * @param encoding The `encoding` of the `spkac` string.
45
46
  * @return The challenge component of the `spkac` data structure, which includes a public key and a challenge.
46
47
  */
47
- static exportChallenge(spkac: BinaryLike): Buffer;
48
+ static exportChallenge(spkac: BinaryLike): NonSharedBuffer;
48
49
  /**
49
50
  * ```js
50
51
  * const { Certificate } = await import('node:crypto');
@@ -57,7 +58,7 @@ declare module "crypto" {
57
58
  * @param encoding The `encoding` of the `spkac` string.
58
59
  * @return The public key component of the `spkac` data structure, which includes a public key and a challenge.
59
60
  */
60
- static exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer;
61
+ static exportPublicKey(spkac: BinaryLike, encoding?: string): NonSharedBuffer;
61
62
  /**
62
63
  * ```js
63
64
  * import { Buffer } from 'node:buffer';
@@ -78,7 +79,7 @@ declare module "crypto" {
78
79
  * @returns The challenge component of the `spkac` data structure,
79
80
  * which includes a public key and a challenge.
80
81
  */
81
- exportChallenge(spkac: BinaryLike): Buffer;
82
+ exportChallenge(spkac: BinaryLike): NonSharedBuffer;
82
83
  /**
83
84
  * @deprecated
84
85
  * @param spkac
@@ -86,7 +87,7 @@ declare module "crypto" {
86
87
  * @returns The public key component of the `spkac` data structure,
87
88
  * which includes a public key and a challenge.
88
89
  */
89
- exportPublicKey(spkac: BinaryLike, encoding?: string): Buffer;
90
+ exportPublicKey(spkac: BinaryLike, encoding?: string): NonSharedBuffer;
90
91
  /**
91
92
  * @deprecated
92
93
  * @param spkac
@@ -96,15 +97,17 @@ declare module "crypto" {
96
97
  verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
97
98
  }
98
99
  namespace constants {
99
- // https://nodejs.org/dist/latest-v20.x/docs/api/crypto.html#crypto-constants
100
+ // https://nodejs.org/dist/latest-v24.x/docs/api/crypto.html#crypto-constants
100
101
  const OPENSSL_VERSION_NUMBER: number;
101
102
  /** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */
102
103
  const SSL_OP_ALL: number;
104
+ /** Instructs OpenSSL to allow a non-[EC]DHE-based key exchange mode for TLS v1.3 */
105
+ const SSL_OP_ALLOW_NO_DHE_KEX: number;
103
106
  /** Allows legacy insecure renegotiation between OpenSSL and unpatched clients or servers. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */
104
107
  const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
105
108
  /** Attempts to use the server's preferences instead of the client's when selecting a cipher. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */
106
109
  const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
107
- /** Instructs OpenSSL to use Cisco's "speshul" version of DTLS_BAD_VER. */
110
+ /** Instructs OpenSSL to use Cisco's version identifier of DTLS_BAD_VER. */
108
111
  const SSL_OP_CISCO_ANYCONNECT: number;
109
112
  /** Instructs OpenSSL to turn on cookie exchange. */
110
113
  const SSL_OP_COOKIE_EXCHANGE: number;
@@ -116,15 +119,29 @@ declare module "crypto" {
116
119
  const SSL_OP_LEGACY_SERVER_CONNECT: number;
117
120
  /** Instructs OpenSSL to disable support for SSL/TLS compression. */
118
121
  const SSL_OP_NO_COMPRESSION: number;
122
+ /** Instructs OpenSSL to disable encrypt-then-MAC. */
123
+ const SSL_OP_NO_ENCRYPT_THEN_MAC: number;
119
124
  const SSL_OP_NO_QUERY_MTU: number;
125
+ /** Instructs OpenSSL to disable renegotiation. */
126
+ const SSL_OP_NO_RENEGOTIATION: number;
120
127
  /** Instructs OpenSSL to always start a new session when performing renegotiation. */
121
128
  const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
129
+ /** Instructs OpenSSL to turn off SSL v2 */
122
130
  const SSL_OP_NO_SSLv2: number;
131
+ /** Instructs OpenSSL to turn off SSL v3 */
123
132
  const SSL_OP_NO_SSLv3: number;
133
+ /** Instructs OpenSSL to disable use of RFC4507bis tickets. */
124
134
  const SSL_OP_NO_TICKET: number;
135
+ /** Instructs OpenSSL to turn off TLS v1 */
125
136
  const SSL_OP_NO_TLSv1: number;
137
+ /** Instructs OpenSSL to turn off TLS v1.1 */
126
138
  const SSL_OP_NO_TLSv1_1: number;
139
+ /** Instructs OpenSSL to turn off TLS v1.2 */
127
140
  const SSL_OP_NO_TLSv1_2: number;
141
+ /** Instructs OpenSSL to turn off TLS v1.3 */
142
+ const SSL_OP_NO_TLSv1_3: number;
143
+ /** Instructs OpenSSL server to prioritize ChaCha20-Poly1305 when the client does. This option has no effect if `SSL_OP_CIPHER_SERVER_PREFERENCE` is not enabled. */
144
+ const SSL_OP_PRIORITIZE_CHACHA: number;
128
145
  /** Instructs OpenSSL to disable version rollback attack detection. */
129
146
  const SSL_OP_TLS_ROLLBACK_BUG: number;
130
147
  const ENGINE_METHOD_RSA: number;
@@ -363,7 +380,7 @@ declare module "crypto" {
363
380
  * @since v13.1.0
364
381
  * @param options `stream.transform` options
365
382
  */
366
- copy(options?: stream.TransformOptions): Hash;
383
+ copy(options?: HashOptions): Hash;
367
384
  /**
368
385
  * Updates the hash content with the given `data`, the encoding of which
369
386
  * is given in `inputEncoding`.
@@ -386,7 +403,7 @@ declare module "crypto" {
386
403
  * @since v0.1.92
387
404
  * @param encoding The `encoding` of the return value.
388
405
  */
389
- digest(): Buffer;
406
+ digest(): NonSharedBuffer;
390
407
  digest(encoding: BinaryToTextEncoding): string;
391
408
  }
392
409
  /**
@@ -454,6 +471,7 @@ declare module "crypto" {
454
471
  * // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
455
472
  * ```
456
473
  * @since v0.1.94
474
+ * @deprecated Since v20.13.0 Calling `Hmac` class directly with `Hmac()` or `new Hmac()` is deprecated due to being internals, not intended for public use. Please use the {@link createHmac} method to create Hmac instances.
457
475
  */
458
476
  class Hmac extends stream.Transform {
459
477
  private constructor();
@@ -479,7 +497,7 @@ declare module "crypto" {
479
497
  * @since v0.1.94
480
498
  * @param encoding The `encoding` of the return value.
481
499
  */
482
- digest(): Buffer;
500
+ digest(): NonSharedBuffer;
483
501
  digest(encoding: BinaryToTextEncoding): string;
484
502
  }
485
503
  type KeyObjectType = "secret" | "public" | "private";
@@ -493,50 +511,50 @@ declare module "crypto" {
493
511
  format: "jwk";
494
512
  }
495
513
  interface JsonWebKey {
496
- crv?: string | undefined;
497
- d?: string | undefined;
498
- dp?: string | undefined;
499
- dq?: string | undefined;
500
- e?: string | undefined;
501
- k?: string | undefined;
502
- kty?: string | undefined;
503
- n?: string | undefined;
504
- p?: string | undefined;
505
- q?: string | undefined;
506
- qi?: string | undefined;
507
- x?: string | undefined;
508
- y?: string | undefined;
514
+ crv?: string;
515
+ d?: string;
516
+ dp?: string;
517
+ dq?: string;
518
+ e?: string;
519
+ k?: string;
520
+ kty?: string;
521
+ n?: string;
522
+ p?: string;
523
+ q?: string;
524
+ qi?: string;
525
+ x?: string;
526
+ y?: string;
509
527
  [key: string]: unknown;
510
528
  }
511
529
  interface AsymmetricKeyDetails {
512
530
  /**
513
531
  * Key size in bits (RSA, DSA).
514
532
  */
515
- modulusLength?: number | undefined;
533
+ modulusLength?: number;
516
534
  /**
517
535
  * Public exponent (RSA).
518
536
  */
519
- publicExponent?: bigint | undefined;
537
+ publicExponent?: bigint;
520
538
  /**
521
539
  * Name of the message digest (RSA-PSS).
522
540
  */
523
- hashAlgorithm?: string | undefined;
541
+ hashAlgorithm?: string;
524
542
  /**
525
543
  * Name of the message digest used by MGF1 (RSA-PSS).
526
544
  */
527
- mgf1HashAlgorithm?: string | undefined;
545
+ mgf1HashAlgorithm?: string;
528
546
  /**
529
547
  * Minimal salt length in bytes (RSA-PSS).
530
548
  */
531
- saltLength?: number | undefined;
549
+ saltLength?: number;
532
550
  /**
533
551
  * Size of q in bits (DSA).
534
552
  */
535
- divisorLength?: number | undefined;
553
+ divisorLength?: number;
536
554
  /**
537
555
  * Name of the curve (EC).
538
556
  */
539
- namedCurve?: string | undefined;
557
+ namedCurve?: string;
540
558
  }
541
559
  /**
542
560
  * Node.js uses a `KeyObject` class to represent a symmetric or asymmetric key,
@@ -574,29 +592,14 @@ declare module "crypto" {
574
592
  */
575
593
  static from(key: webcrypto.CryptoKey): KeyObject;
576
594
  /**
577
- * For asymmetric keys, this property represents the type of the key. Supported key
578
- * types are:
579
- *
580
- * * `'rsa'` (OID 1.2.840.113549.1.1.1)
581
- * * `'rsa-pss'` (OID 1.2.840.113549.1.1.10)
582
- * * `'dsa'` (OID 1.2.840.10040.4.1)
583
- * * `'ec'` (OID 1.2.840.10045.2.1)
584
- * * `'x25519'` (OID 1.3.101.110)
585
- * * `'x448'` (OID 1.3.101.111)
586
- * * `'ed25519'` (OID 1.3.101.112)
587
- * * `'ed448'` (OID 1.3.101.113)
588
- * * `'dh'` (OID 1.2.840.113549.1.3.1)
595
+ * For asymmetric keys, this property represents the type of the key. See the
596
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types).
589
597
  *
590
598
  * This property is `undefined` for unrecognized `KeyObject` types and symmetric
591
599
  * keys.
592
600
  * @since v11.6.0
593
601
  */
594
- asymmetricKeyType?: KeyType | undefined;
595
- /**
596
- * For asymmetric keys, this property represents the size of the embedded key in
597
- * bytes. This property is `undefined` for symmetric keys.
598
- */
599
- asymmetricKeySize?: number | undefined;
602
+ asymmetricKeyType?: KeyType;
600
603
  /**
601
604
  * This property exists only on asymmetric keys. Depending on the type of the key,
602
605
  * this object contains information about the key. None of the information obtained
@@ -610,7 +613,7 @@ declare module "crypto" {
610
613
  * Other key details might be exposed via this API using additional attributes.
611
614
  * @since v15.7.0
612
615
  */
613
- asymmetricKeyDetails?: AsymmetricKeyDetails | undefined;
616
+ asymmetricKeyDetails?: AsymmetricKeyDetails;
614
617
  /**
615
618
  * For symmetric keys, the following encoding options can be used:
616
619
  *
@@ -634,15 +637,35 @@ declare module "crypto" {
634
637
  * PKCS#1 and SEC1 encryption.
635
638
  * @since v11.6.0
636
639
  */
637
- export(options: KeyExportOptions<"pem">): string | Buffer;
638
- export(options?: KeyExportOptions<"der">): Buffer;
640
+ export(options: KeyExportOptions<"pem">): string | NonSharedBuffer;
641
+ export(options?: KeyExportOptions<"der">): NonSharedBuffer;
639
642
  export(options?: JwkKeyExportOptions): JsonWebKey;
643
+ /**
644
+ * Returns `true` or `false` depending on whether the keys have exactly the same
645
+ * type, value, and parameters. This method is not [constant time](https://en.wikipedia.org/wiki/Timing_attack).
646
+ * @since v17.7.0, v16.15.0
647
+ * @param otherKeyObject A `KeyObject` with which to compare `keyObject`.
648
+ */
649
+ equals(otherKeyObject: KeyObject): boolean;
640
650
  /**
641
651
  * For secret keys, this property represents the size of the key in bytes. This
642
652
  * property is `undefined` for asymmetric keys.
643
653
  * @since v11.6.0
644
654
  */
645
- symmetricKeySize?: number | undefined;
655
+ symmetricKeySize?: number;
656
+ /**
657
+ * Converts a `KeyObject` instance to a `CryptoKey`.
658
+ * @since 22.10.0
659
+ */
660
+ toCryptoKey(
661
+ algorithm:
662
+ | webcrypto.AlgorithmIdentifier
663
+ | webcrypto.RsaHashedImportParams
664
+ | webcrypto.EcKeyImportParams
665
+ | webcrypto.HmacImportParams,
666
+ extractable: boolean,
667
+ keyUsages: readonly webcrypto.KeyUsage[],
668
+ ): webcrypto.CryptoKey;
646
669
  /**
647
670
  * Depending on the type of this `KeyObject`, this property is either`'secret'` for secret (symmetric) keys, `'public'` for public (asymmetric) keys
648
671
  * or `'private'` for private (asymmetric) keys.
@@ -650,9 +673,10 @@ declare module "crypto" {
650
673
  */
651
674
  type: KeyObjectType;
652
675
  }
653
- type CipherCCMTypes = "aes-128-ccm" | "aes-192-ccm" | "aes-256-ccm" | "chacha20-poly1305";
676
+ type CipherCCMTypes = "aes-128-ccm" | "aes-192-ccm" | "aes-256-ccm";
654
677
  type CipherGCMTypes = "aes-128-gcm" | "aes-192-gcm" | "aes-256-gcm";
655
678
  type CipherOCBTypes = "aes-128-ocb" | "aes-192-ocb" | "aes-256-ocb";
679
+ type CipherChaCha20Poly1305Types = "chacha20-poly1305";
656
680
  type BinaryLike = string | NodeJS.ArrayBufferView;
657
681
  type CipherKey = BinaryLike | KeyObject;
658
682
  interface CipherCCMOptions extends stream.TransformOptions {
@@ -664,48 +688,10 @@ declare module "crypto" {
664
688
  interface CipherOCBOptions extends stream.TransformOptions {
665
689
  authTagLength: number;
666
690
  }
667
- /**
668
- * Creates and returns a `Cipher` object that uses the given `algorithm` and`password`.
669
- *
670
- * The `options` argument controls stream behavior and is optional except when a
671
- * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the
672
- * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to set the length of the authentication
673
- * tag that will be returned by `getAuthTag()` and defaults to 16 bytes.
674
- * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
675
- *
676
- * The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
677
- * recent OpenSSL releases, `openssl list -cipher-algorithms` will
678
- * display the available cipher algorithms.
679
- *
680
- * The `password` is used to derive the cipher key and initialization vector (IV).
681
- * The value must be either a `'latin1'` encoded string, a `Buffer`, a`TypedArray`, or a `DataView`.
682
- *
683
- * **This function is semantically insecure for all**
684
- * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,**
685
- * **GCM, or CCM).**
686
- *
687
- * The implementation of `crypto.createCipher()` derives keys using the OpenSSL
688
- * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
689
- * iteration, and no salt. The lack of salt allows dictionary attacks as the same
690
- * password always creates the same key. The low iteration count and
691
- * non-cryptographically secure hash algorithm allow passwords to be tested very
692
- * rapidly.
693
- *
694
- * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) it is recommended that
695
- * developers derive a key and IV on
696
- * their own using {@link scrypt} and to use {@link createCipheriv} to create the `Cipher` object. Users should not use ciphers with counter mode
697
- * (e.g. CTR, GCM, or CCM) in `crypto.createCipher()`. A warning is emitted when
698
- * they are used in order to avoid the risk of IV reuse that causes
699
- * vulnerabilities. For the case when IV is reused in GCM, see [Nonce-Disrespecting Adversaries](https://github.com/nonce-disrespect/nonce-disrespect) for details.
700
- * @since v0.1.94
701
- * @deprecated Since v10.0.0 - Use {@link createCipheriv} instead.
702
- * @param options `stream.transform` options
703
- */
704
- function createCipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): CipherCCM;
705
- /** @deprecated since v10.0.0 use `createCipheriv()` */
706
- function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM;
707
- /** @deprecated since v10.0.0 use `createCipheriv()` */
708
- function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher;
691
+ interface CipherChaCha20Poly1305Options extends stream.TransformOptions {
692
+ /** @default 16 */
693
+ authTagLength?: number | undefined;
694
+ }
709
695
  /**
710
696
  * Creates and returns a `Cipher` object, with the given `algorithm`, `key` and
711
697
  * initialization vector (`iv`).
@@ -754,14 +740,20 @@ declare module "crypto" {
754
740
  iv: BinaryLike,
755
741
  options?: CipherGCMOptions,
756
742
  ): CipherGCM;
743
+ function createCipheriv(
744
+ algorithm: CipherChaCha20Poly1305Types,
745
+ key: CipherKey,
746
+ iv: BinaryLike,
747
+ options?: CipherChaCha20Poly1305Options,
748
+ ): CipherChaCha20Poly1305;
757
749
  function createCipheriv(
758
750
  algorithm: string,
759
751
  key: CipherKey,
760
752
  iv: BinaryLike | null,
761
753
  options?: stream.TransformOptions,
762
- ): Cipher;
754
+ ): Cipheriv;
763
755
  /**
764
- * Instances of the `Cipher` class are used to encrypt data. The class can be
756
+ * Instances of the `Cipheriv` class are used to encrypt data. The class can be
765
757
  * used in one of two ways:
766
758
  *
767
759
  * * As a `stream` that is both readable and writable, where plain unencrypted
@@ -769,11 +761,11 @@ declare module "crypto" {
769
761
  * * Using the `cipher.update()` and `cipher.final()` methods to produce
770
762
  * the encrypted data.
771
763
  *
772
- * The {@link createCipher} or {@link createCipheriv} methods are
773
- * used to create `Cipher` instances. `Cipher` objects are not to be created
764
+ * The {@link createCipheriv} method is
765
+ * used to create `Cipheriv` instances. `Cipheriv` objects are not to be created
774
766
  * directly using the `new` keyword.
775
767
  *
776
- * Example: Using `Cipher` objects as streams:
768
+ * Example: Using `Cipheriv` objects as streams:
777
769
  *
778
770
  * ```js
779
771
  * const {
@@ -808,7 +800,7 @@ declare module "crypto" {
808
800
  * });
809
801
  * ```
810
802
  *
811
- * Example: Using `Cipher` and piped streams:
803
+ * Example: Using `Cipheriv` and piped streams:
812
804
  *
813
805
  * ```js
814
806
  * import {
@@ -879,12 +871,12 @@ declare module "crypto" {
879
871
  * ```
880
872
  * @since v0.1.94
881
873
  */
882
- class Cipher extends stream.Transform {
874
+ class Cipheriv extends stream.Transform {
883
875
  private constructor();
884
876
  /**
885
877
  * Updates the cipher with `data`. If the `inputEncoding` argument is given,
886
- * the `data`argument is a string using the specified encoding. If the `inputEncoding`argument is not given, `data` must be a `Buffer`, `TypedArray`, or`DataView`. If `data` is a `Buffer`,
887
- * `TypedArray`, or `DataView`, then`inputEncoding` is ignored.
878
+ * the `data`argument is a string using the specified encoding. If the `inputEncoding`argument is not given, `data` must be a `Buffer`, `TypedArray`, or `DataView`. If `data` is a `Buffer`,
879
+ * `TypedArray`, or `DataView`, then `inputEncoding` is ignored.
888
880
  *
889
881
  * The `outputEncoding` specifies the output format of the enciphered
890
882
  * data. If the `outputEncoding`is specified, a string using the specified encoding is returned. If no`outputEncoding` is provided, a `Buffer` is returned.
@@ -895,22 +887,22 @@ declare module "crypto" {
895
887
  * @param inputEncoding The `encoding` of the data.
896
888
  * @param outputEncoding The `encoding` of the return value.
897
889
  */
898
- update(data: BinaryLike): Buffer;
899
- update(data: string, inputEncoding: Encoding): Buffer;
890
+ update(data: BinaryLike): NonSharedBuffer;
891
+ update(data: string, inputEncoding: Encoding): NonSharedBuffer;
900
892
  update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string;
901
893
  update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string;
902
894
  /**
903
- * Once the `cipher.final()` method has been called, the `Cipher` object can no
895
+ * Once the `cipher.final()` method has been called, the `Cipheriv` object can no
904
896
  * longer be used to encrypt data. Attempts to call `cipher.final()` more than
905
897
  * once will result in an error being thrown.
906
898
  * @since v0.1.94
907
899
  * @param outputEncoding The `encoding` of the return value.
908
900
  * @return Any remaining enciphered contents. If `outputEncoding` is specified, a string is returned. If an `outputEncoding` is not provided, a {@link Buffer} is returned.
909
901
  */
910
- final(): Buffer;
902
+ final(): NonSharedBuffer;
911
903
  final(outputEncoding: BufferEncoding): string;
912
904
  /**
913
- * When using block encryption algorithms, the `Cipher` class will automatically
905
+ * When using block encryption algorithms, the `Cipheriv` class will automatically
914
906
  * add padding to the input data to the appropriate block size. To disable the
915
907
  * default padding call `cipher.setAutoPadding(false)`.
916
908
  *
@@ -926,70 +918,48 @@ declare module "crypto" {
926
918
  */
927
919
  setAutoPadding(autoPadding?: boolean): this;
928
920
  }
929
- interface CipherCCM extends Cipher {
921
+ interface CipherCCM extends Cipheriv {
930
922
  setAAD(
931
923
  buffer: NodeJS.ArrayBufferView,
932
924
  options: {
933
925
  plaintextLength: number;
934
926
  },
935
927
  ): this;
936
- getAuthTag(): Buffer;
928
+ getAuthTag(): NonSharedBuffer;
937
929
  }
938
- interface CipherGCM extends Cipher {
930
+ interface CipherGCM extends Cipheriv {
939
931
  setAAD(
940
932
  buffer: NodeJS.ArrayBufferView,
941
933
  options?: {
942
934
  plaintextLength: number;
943
935
  },
944
936
  ): this;
945
- getAuthTag(): Buffer;
937
+ getAuthTag(): NonSharedBuffer;
946
938
  }
947
- interface CipherOCB extends Cipher {
939
+ interface CipherOCB extends Cipheriv {
948
940
  setAAD(
949
941
  buffer: NodeJS.ArrayBufferView,
950
942
  options?: {
951
943
  plaintextLength: number;
952
944
  },
953
945
  ): this;
954
- getAuthTag(): Buffer;
946
+ getAuthTag(): NonSharedBuffer;
947
+ }
948
+ interface CipherChaCha20Poly1305 extends Cipheriv {
949
+ setAAD(
950
+ buffer: NodeJS.ArrayBufferView,
951
+ options: {
952
+ plaintextLength: number;
953
+ },
954
+ ): this;
955
+ getAuthTag(): NonSharedBuffer;
955
956
  }
956
957
  /**
957
- * Creates and returns a `Decipher` object that uses the given `algorithm` and`password` (key).
958
- *
959
- * The `options` argument controls stream behavior and is optional except when a
960
- * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the
961
- * authentication tag in bytes, see `CCM mode`.
962
- * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
963
- *
964
- * **This function is semantically insecure for all**
965
- * **supported ciphers and fatally flawed for ciphers in counter mode (such as CTR,**
966
- * **GCM, or CCM).**
967
- *
968
- * The implementation of `crypto.createDecipher()` derives keys using the OpenSSL
969
- * function [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) with the digest algorithm set to MD5, one
970
- * iteration, and no salt. The lack of salt allows dictionary attacks as the same
971
- * password always creates the same key. The low iteration count and
972
- * non-cryptographically secure hash algorithm allow passwords to be tested very
973
- * rapidly.
974
- *
975
- * In line with OpenSSL's recommendation to use a more modern algorithm instead of [`EVP_BytesToKey`](https://www.openssl.org/docs/man3.0/man3/EVP_BytesToKey.html) it is recommended that
976
- * developers derive a key and IV on
977
- * their own using {@link scrypt} and to use {@link createDecipheriv} to create the `Decipher` object.
978
- * @since v0.1.94
979
- * @deprecated Since v10.0.0 - Use {@link createDecipheriv} instead.
980
- * @param options `stream.transform` options
981
- */
982
- function createDecipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): DecipherCCM;
983
- /** @deprecated since v10.0.0 use `createDecipheriv()` */
984
- function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM;
985
- /** @deprecated since v10.0.0 use `createDecipheriv()` */
986
- function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher;
987
- /**
988
- * Creates and returns a `Decipher` object that uses the given `algorithm`, `key`and initialization vector (`iv`).
958
+ * Creates and returns a `Decipheriv` object that uses the given `algorithm`, `key` and initialization vector (`iv`).
989
959
  *
990
960
  * The `options` argument controls stream behavior and is optional except when a
991
- * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the`authTagLength` option is required and specifies the length of the
992
- * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength`option is not required but can be used to restrict accepted authentication tags
961
+ * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the `authTagLength` option is required and specifies the length of the
962
+ * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength` option is not required but can be used to restrict accepted authentication tags
993
963
  * to those with the specified length.
994
964
  * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
995
965
  *
@@ -1031,14 +1001,20 @@ declare module "crypto" {
1031
1001
  iv: BinaryLike,
1032
1002
  options?: CipherGCMOptions,
1033
1003
  ): DecipherGCM;
1004
+ function createDecipheriv(
1005
+ algorithm: CipherChaCha20Poly1305Types,
1006
+ key: CipherKey,
1007
+ iv: BinaryLike,
1008
+ options?: CipherChaCha20Poly1305Options,
1009
+ ): DecipherChaCha20Poly1305;
1034
1010
  function createDecipheriv(
1035
1011
  algorithm: string,
1036
1012
  key: CipherKey,
1037
1013
  iv: BinaryLike | null,
1038
1014
  options?: stream.TransformOptions,
1039
- ): Decipher;
1015
+ ): Decipheriv;
1040
1016
  /**
1041
- * Instances of the `Decipher` class are used to decrypt data. The class can be
1017
+ * Instances of the `Decipheriv` class are used to decrypt data. The class can be
1042
1018
  * used in one of two ways:
1043
1019
  *
1044
1020
  * * As a `stream` that is both readable and writable, where plain encrypted
@@ -1046,11 +1022,11 @@ declare module "crypto" {
1046
1022
  * * Using the `decipher.update()` and `decipher.final()` methods to
1047
1023
  * produce the unencrypted data.
1048
1024
  *
1049
- * The {@link createDecipher} or {@link createDecipheriv} methods are
1050
- * used to create `Decipher` instances. `Decipher` objects are not to be created
1025
+ * The {@link createDecipheriv} method is
1026
+ * used to create `Decipheriv` instances. `Decipheriv` objects are not to be created
1051
1027
  * directly using the `new` keyword.
1052
1028
  *
1053
- * Example: Using `Decipher` objects as streams:
1029
+ * Example: Using `Decipheriv` objects as streams:
1054
1030
  *
1055
1031
  * ```js
1056
1032
  * import { Buffer } from 'node:buffer';
@@ -1089,7 +1065,7 @@ declare module "crypto" {
1089
1065
  * decipher.end();
1090
1066
  * ```
1091
1067
  *
1092
- * Example: Using `Decipher` and piped streams:
1068
+ * Example: Using `Decipheriv` and piped streams:
1093
1069
  *
1094
1070
  * ```js
1095
1071
  * import {
@@ -1145,15 +1121,15 @@ declare module "crypto" {
1145
1121
  * ```
1146
1122
  * @since v0.1.94
1147
1123
  */
1148
- class Decipher extends stream.Transform {
1124
+ class Decipheriv extends stream.Transform {
1149
1125
  private constructor();
1150
1126
  /**
1151
1127
  * Updates the decipher with `data`. If the `inputEncoding` argument is given,
1152
- * the `data`argument is a string using the specified encoding. If the `inputEncoding`argument is not given, `data` must be a `Buffer`. If `data` is a `Buffer` then `inputEncoding` is
1128
+ * the `data` argument is a string using the specified encoding. If the `inputEncoding` argument is not given, `data` must be a `Buffer`. If `data` is a `Buffer` then `inputEncoding` is
1153
1129
  * ignored.
1154
1130
  *
1155
1131
  * The `outputEncoding` specifies the output format of the enciphered
1156
- * data. If the `outputEncoding`is specified, a string using the specified encoding is returned. If no`outputEncoding` is provided, a `Buffer` is returned.
1132
+ * data. If the `outputEncoding` is specified, a string using the specified encoding is returned. If no `outputEncoding` is provided, a `Buffer` is returned.
1157
1133
  *
1158
1134
  * The `decipher.update()` method can be called multiple times with new data until `decipher.final()` is called. Calling `decipher.update()` after `decipher.final()` will result in an error
1159
1135
  * being thrown.
@@ -1161,22 +1137,22 @@ declare module "crypto" {
1161
1137
  * @param inputEncoding The `encoding` of the `data` string.
1162
1138
  * @param outputEncoding The `encoding` of the return value.
1163
1139
  */
1164
- update(data: NodeJS.ArrayBufferView): Buffer;
1165
- update(data: string, inputEncoding: Encoding): Buffer;
1140
+ update(data: NodeJS.ArrayBufferView): NonSharedBuffer;
1141
+ update(data: string, inputEncoding: Encoding): NonSharedBuffer;
1166
1142
  update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string;
1167
1143
  update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string;
1168
1144
  /**
1169
- * Once the `decipher.final()` method has been called, the `Decipher` object can
1145
+ * Once the `decipher.final()` method has been called, the `Decipheriv` object can
1170
1146
  * no longer be used to decrypt data. Attempts to call `decipher.final()` more
1171
1147
  * than once will result in an error being thrown.
1172
1148
  * @since v0.1.94
1173
1149
  * @param outputEncoding The `encoding` of the return value.
1174
1150
  * @return Any remaining deciphered contents. If `outputEncoding` is specified, a string is returned. If an `outputEncoding` is not provided, a {@link Buffer} is returned.
1175
1151
  */
1176
- final(): Buffer;
1152
+ final(): NonSharedBuffer;
1177
1153
  final(outputEncoding: BufferEncoding): string;
1178
1154
  /**
1179
- * When data has been encrypted without standard block padding, calling`decipher.setAutoPadding(false)` will disable automatic padding to prevent `decipher.final()` from checking for and
1155
+ * When data has been encrypted without standard block padding, calling `decipher.setAutoPadding(false)` will disable automatic padding to prevent `decipher.final()` from checking for and
1180
1156
  * removing padding.
1181
1157
  *
1182
1158
  * Turning auto padding off will only work if the input data's length is a
@@ -1189,7 +1165,7 @@ declare module "crypto" {
1189
1165
  */
1190
1166
  setAutoPadding(auto_padding?: boolean): this;
1191
1167
  }
1192
- interface DecipherCCM extends Decipher {
1168
+ interface DecipherCCM extends Decipheriv {
1193
1169
  setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1194
1170
  setAAD(
1195
1171
  buffer: NodeJS.ArrayBufferView,
@@ -1198,7 +1174,7 @@ declare module "crypto" {
1198
1174
  },
1199
1175
  ): this;
1200
1176
  }
1201
- interface DecipherGCM extends Decipher {
1177
+ interface DecipherGCM extends Decipheriv {
1202
1178
  setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1203
1179
  setAAD(
1204
1180
  buffer: NodeJS.ArrayBufferView,
@@ -1207,7 +1183,7 @@ declare module "crypto" {
1207
1183
  },
1208
1184
  ): this;
1209
1185
  }
1210
- interface DecipherOCB extends Decipher {
1186
+ interface DecipherOCB extends Decipheriv {
1211
1187
  setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1212
1188
  setAAD(
1213
1189
  buffer: NodeJS.ArrayBufferView,
@@ -1216,6 +1192,15 @@ declare module "crypto" {
1216
1192
  },
1217
1193
  ): this;
1218
1194
  }
1195
+ interface DecipherChaCha20Poly1305 extends Decipheriv {
1196
+ setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1197
+ setAAD(
1198
+ buffer: NodeJS.ArrayBufferView,
1199
+ options: {
1200
+ plaintextLength: number;
1201
+ },
1202
+ ): this;
1203
+ }
1219
1204
  interface PrivateKeyInput {
1220
1205
  key: string | Buffer;
1221
1206
  format?: KeyFormat | undefined;
@@ -1230,7 +1215,7 @@ declare module "crypto" {
1230
1215
  encoding?: string | undefined;
1231
1216
  }
1232
1217
  /**
1233
- * Asynchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`.
1218
+ * Asynchronously generates a new random secret key of the given `length`. The `type` will determine which validations will be performed on the `length`.
1234
1219
  *
1235
1220
  * ```js
1236
1221
  * const {
@@ -1256,7 +1241,7 @@ declare module "crypto" {
1256
1241
  callback: (err: Error | null, key: KeyObject) => void,
1257
1242
  ): void;
1258
1243
  /**
1259
- * Synchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`.
1244
+ * Synchronously generates a new random secret key of the given `length`. The `type` will determine which validations will be performed on the `length`.
1260
1245
  *
1261
1246
  * ```js
1262
1247
  * const {
@@ -1284,7 +1269,7 @@ declare module "crypto" {
1284
1269
  }
1285
1270
  /**
1286
1271
  * Creates and returns a new key object containing a private key. If `key` is a
1287
- * string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key`must be an object with the properties described above.
1272
+ * string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key` must be an object with the properties described above.
1288
1273
  *
1289
1274
  * If the private key is encrypted, a `passphrase` must be specified. The length
1290
1275
  * of the passphrase is limited to 1024 bytes.
@@ -1293,7 +1278,7 @@ declare module "crypto" {
1293
1278
  function createPrivateKey(key: PrivateKeyInput | string | Buffer | JsonWebKeyInput): KeyObject;
1294
1279
  /**
1295
1280
  * Creates and returns a new key object containing a public key. If `key` is a
1296
- * string or `Buffer`, `format` is assumed to be `'pem'`; if `key` is a `KeyObject`with type `'private'`, the public key is derived from the given private key;
1281
+ * string or `Buffer`, `format` is assumed to be `'pem'`; if `key` is a `KeyObject` with type `'private'`, the public key is derived from the given private key;
1297
1282
  * otherwise, `key` must be an object with the properties described above.
1298
1283
  *
1299
1284
  * If the format is `'pem'`, the `'key'` may also be an X.509 certificate.
@@ -1301,7 +1286,7 @@ declare module "crypto" {
1301
1286
  * Because public keys can be derived from private keys, a private key may be
1302
1287
  * passed instead of a public key. In that case, this function behaves as if {@link createPrivateKey} had been called, except that the type of the
1303
1288
  * returned `KeyObject` will be `'public'` and that the private key cannot be
1304
- * extracted from the returned `KeyObject`. Similarly, if a `KeyObject` with type`'private'` is given, a new `KeyObject` with type `'public'` will be returned
1289
+ * extracted from the returned `KeyObject`. Similarly, if a `KeyObject` with type `'private'` is given, a new `KeyObject` with type `'public'` will be returned
1305
1290
  * and it will be impossible to extract the private key from the returned object.
1306
1291
  * @since v11.6.0
1307
1292
  */
@@ -1326,6 +1311,7 @@ declare module "crypto" {
1326
1311
  * @since v0.1.92
1327
1312
  * @param options `stream.Writable` options
1328
1313
  */
1314
+ // TODO: signing algorithm type
1329
1315
  function createSign(algorithm: string, options?: stream.WritableOptions): Sign;
1330
1316
  type DSAEncoding = "der" | "ieee-p1363";
1331
1317
  interface SigningOptions {
@@ -1335,11 +1321,13 @@ declare module "crypto" {
1335
1321
  padding?: number | undefined;
1336
1322
  saltLength?: number | undefined;
1337
1323
  dsaEncoding?: DSAEncoding | undefined;
1324
+ context?: ArrayBuffer | NodeJS.ArrayBufferView | undefined;
1338
1325
  }
1339
1326
  interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {}
1340
1327
  interface SignKeyObjectInput extends SigningOptions {
1341
1328
  key: KeyObject;
1342
1329
  }
1330
+ interface SignJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
1343
1331
  interface VerifyPublicKeyInput extends PublicKeyInput, SigningOptions {}
1344
1332
  interface VerifyKeyObjectInput extends SigningOptions {
1345
1333
  key: KeyObject;
@@ -1426,7 +1414,7 @@ declare module "crypto" {
1426
1414
  /**
1427
1415
  * Calculates the signature on all the data passed through using either `sign.update()` or `sign.write()`.
1428
1416
  *
1429
- * If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an
1417
+ * If `privateKey` is not a `KeyObject`, this function behaves as if `privateKey` had been passed to {@link createPrivateKey}. If it is an
1430
1418
  * object, the following additional properties can be passed:
1431
1419
  *
1432
1420
  * If `outputEncoding` is provided a string is returned; otherwise a `Buffer` is returned.
@@ -1435,16 +1423,16 @@ declare module "crypto" {
1435
1423
  * called. Multiple calls to `sign.sign()` will result in an error being thrown.
1436
1424
  * @since v0.1.92
1437
1425
  */
1438
- sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput): Buffer;
1426
+ sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput): NonSharedBuffer;
1439
1427
  sign(
1440
- privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
1428
+ privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
1441
1429
  outputFormat: BinaryToTextEncoding,
1442
1430
  ): string;
1443
1431
  }
1444
1432
  /**
1445
1433
  * Creates and returns a `Verify` object that uses the given algorithm.
1446
1434
  * Use {@link getHashes} to obtain an array of names of the available
1447
- * signing algorithms. Optional `options` argument controls the`stream.Writable` behavior.
1435
+ * signing algorithms. Optional `options` argument controls the `stream.Writable` behavior.
1448
1436
  *
1449
1437
  * In some cases, a `Verify` instance can be created using the name of a signature
1450
1438
  * algorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use
@@ -1464,7 +1452,7 @@ declare module "crypto" {
1464
1452
  * * Using the `verify.update()` and `verify.verify()` methods to verify
1465
1453
  * the signature.
1466
1454
  *
1467
- * The {@link createVerify} method is used to create `Verify` instances.`Verify` objects are not to be created directly using the `new` keyword.
1455
+ * The {@link createVerify} method is used to create `Verify` instances. `Verify` objects are not to be created directly using the `new` keyword.
1468
1456
  *
1469
1457
  * See `Sign` for examples.
1470
1458
  * @since v0.1.92
@@ -1475,7 +1463,7 @@ declare module "crypto" {
1475
1463
  * Updates the `Verify` content with the given `data`, the encoding of which
1476
1464
  * is given in `inputEncoding`.
1477
1465
  * If `inputEncoding` is not provided, and the `data` is a string, an
1478
- * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`, then `inputEncoding` is ignored.
1466
+ * encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or `DataView`, then `inputEncoding` is ignored.
1479
1467
  *
1480
1468
  * This can be called many times with new data as it is streamed.
1481
1469
  * @since v0.1.92
@@ -1486,13 +1474,13 @@ declare module "crypto" {
1486
1474
  /**
1487
1475
  * Verifies the provided data using the given `object` and `signature`.
1488
1476
  *
1489
- * If `object` is not a `KeyObject`, this function behaves as if`object` had been passed to {@link createPublicKey}. If it is an
1477
+ * If `object` is not a `KeyObject`, this function behaves as if `object` had been passed to {@link createPublicKey}. If it is an
1490
1478
  * object, the following additional properties can be passed:
1491
1479
  *
1492
1480
  * The `signature` argument is the previously calculated signature for the data, in
1493
1481
  * the `signatureEncoding`.
1494
1482
  * If a `signatureEncoding` is specified, the `signature` is expected to be a
1495
- * string; otherwise `signature` is expected to be a `Buffer`,`TypedArray`, or `DataView`.
1483
+ * string; otherwise `signature` is expected to be a `Buffer`, `TypedArray`, or `DataView`.
1496
1484
  *
1497
1485
  * The `verify` object can not be used again after `verify.verify()` has been
1498
1486
  * called. Multiple calls to `verify.verify()` will result in an error being
@@ -1516,7 +1504,7 @@ declare module "crypto" {
1516
1504
  * Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
1517
1505
  * optional specific `generator`.
1518
1506
  *
1519
- * The `generator` argument can be a number, string, or `Buffer`. If`generator` is not specified, the value `2` is used.
1507
+ * The `generator` argument can be a number, string, or `Buffer`. If `generator` is not specified, the value `2` is used.
1520
1508
  *
1521
1509
  * If `primeEncoding` is specified, `prime` is expected to be a string; otherwise
1522
1510
  * a `Buffer`, `TypedArray`, or `DataView` is expected.
@@ -1594,7 +1582,7 @@ declare module "crypto" {
1594
1582
  * @since v0.5.0
1595
1583
  * @param encoding The `encoding` of the return value.
1596
1584
  */
1597
- generateKeys(): Buffer;
1585
+ generateKeys(): NonSharedBuffer;
1598
1586
  generateKeys(encoding: BinaryToTextEncoding): string;
1599
1587
  /**
1600
1588
  * Computes the shared secret using `otherPublicKey` as the other
@@ -1602,15 +1590,23 @@ declare module "crypto" {
1602
1590
  * key is interpreted using the specified `inputEncoding`, and secret is
1603
1591
  * encoded using specified `outputEncoding`.
1604
1592
  * If the `inputEncoding` is not
1605
- * provided, `otherPublicKey` is expected to be a `Buffer`,`TypedArray`, or `DataView`.
1593
+ * provided, `otherPublicKey` is expected to be a `Buffer`, `TypedArray`, or `DataView`.
1606
1594
  *
1607
1595
  * If `outputEncoding` is given a string is returned; otherwise, a `Buffer` is returned.
1608
1596
  * @since v0.5.0
1609
1597
  * @param inputEncoding The `encoding` of an `otherPublicKey` string.
1610
1598
  * @param outputEncoding The `encoding` of the return value.
1611
1599
  */
1612
- computeSecret(otherPublicKey: NodeJS.ArrayBufferView, inputEncoding?: null, outputEncoding?: null): Buffer;
1613
- computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding, outputEncoding?: null): Buffer;
1600
+ computeSecret(
1601
+ otherPublicKey: NodeJS.ArrayBufferView,
1602
+ inputEncoding?: null,
1603
+ outputEncoding?: null,
1604
+ ): NonSharedBuffer;
1605
+ computeSecret(
1606
+ otherPublicKey: string,
1607
+ inputEncoding: BinaryToTextEncoding,
1608
+ outputEncoding?: null,
1609
+ ): NonSharedBuffer;
1614
1610
  computeSecret(
1615
1611
  otherPublicKey: NodeJS.ArrayBufferView,
1616
1612
  inputEncoding: null,
@@ -1628,7 +1624,7 @@ declare module "crypto" {
1628
1624
  * @since v0.5.0
1629
1625
  * @param encoding The `encoding` of the return value.
1630
1626
  */
1631
- getPrime(): Buffer;
1627
+ getPrime(): NonSharedBuffer;
1632
1628
  getPrime(encoding: BinaryToTextEncoding): string;
1633
1629
  /**
1634
1630
  * Returns the Diffie-Hellman generator in the specified `encoding`.
@@ -1637,7 +1633,7 @@ declare module "crypto" {
1637
1633
  * @since v0.5.0
1638
1634
  * @param encoding The `encoding` of the return value.
1639
1635
  */
1640
- getGenerator(): Buffer;
1636
+ getGenerator(): NonSharedBuffer;
1641
1637
  getGenerator(encoding: BinaryToTextEncoding): string;
1642
1638
  /**
1643
1639
  * Returns the Diffie-Hellman public key in the specified `encoding`.
@@ -1646,7 +1642,7 @@ declare module "crypto" {
1646
1642
  * @since v0.5.0
1647
1643
  * @param encoding The `encoding` of the return value.
1648
1644
  */
1649
- getPublicKey(): Buffer;
1645
+ getPublicKey(): NonSharedBuffer;
1650
1646
  getPublicKey(encoding: BinaryToTextEncoding): string;
1651
1647
  /**
1652
1648
  * Returns the Diffie-Hellman private key in the specified `encoding`.
@@ -1655,10 +1651,10 @@ declare module "crypto" {
1655
1651
  * @since v0.5.0
1656
1652
  * @param encoding The `encoding` of the return value.
1657
1653
  */
1658
- getPrivateKey(): Buffer;
1654
+ getPrivateKey(): NonSharedBuffer;
1659
1655
  getPrivateKey(encoding: BinaryToTextEncoding): string;
1660
1656
  /**
1661
- * Sets the Diffie-Hellman public key. If the `encoding` argument is provided,`publicKey` is expected
1657
+ * Sets the Diffie-Hellman public key. If the `encoding` argument is provided, `publicKey` is expected
1662
1658
  * to be a string. If no `encoding` is provided, `publicKey` is expected
1663
1659
  * to be a `Buffer`, `TypedArray`, or `DataView`.
1664
1660
  * @since v0.5.0
@@ -1761,10 +1757,10 @@ declare module "crypto" {
1761
1757
  /**
1762
1758
  * Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2)
1763
1759
  * implementation. A selected HMAC digest algorithm specified by `digest` is
1764
- * applied to derive a key of the requested byte length (`keylen`) from the`password`, `salt` and `iterations`.
1760
+ * applied to derive a key of the requested byte length (`keylen`) from the `password`, `salt` and `iterations`.
1765
1761
  *
1766
- * The supplied `callback` function is called with two arguments: `err` and`derivedKey`. If an error occurs while deriving the key, `err` will be set;
1767
- * otherwise `err` will be `null`. By default, the successfully generated`derivedKey` will be passed to the callback as a `Buffer`. An error will be
1762
+ * The supplied `callback` function is called with two arguments: `err` and `derivedKey`. If an error occurs while deriving the key, `err` will be set;
1763
+ * otherwise `err` will be `null`. By default, the successfully generated `derivedKey` will be passed to the callback as a `Buffer`. An error will be
1768
1764
  * thrown if any of the input arguments specify invalid values or types.
1769
1765
  *
1770
1766
  * The `iterations` argument must be a number set as high as possible. The
@@ -1799,12 +1795,12 @@ declare module "crypto" {
1799
1795
  iterations: number,
1800
1796
  keylen: number,
1801
1797
  digest: string,
1802
- callback: (err: Error | null, derivedKey: Buffer) => void,
1798
+ callback: (err: Error | null, derivedKey: NonSharedBuffer) => void,
1803
1799
  ): void;
1804
1800
  /**
1805
1801
  * Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2)
1806
1802
  * implementation. A selected HMAC digest algorithm specified by `digest` is
1807
- * applied to derive a key of the requested byte length (`keylen`) from the`password`, `salt` and `iterations`.
1803
+ * applied to derive a key of the requested byte length (`keylen`) from the `password`, `salt` and `iterations`.
1808
1804
  *
1809
1805
  * If an error occurs an `Error` will be thrown, otherwise the derived key will be
1810
1806
  * returned as a `Buffer`.
@@ -1836,14 +1832,14 @@ declare module "crypto" {
1836
1832
  iterations: number,
1837
1833
  keylen: number,
1838
1834
  digest: string,
1839
- ): Buffer;
1835
+ ): NonSharedBuffer;
1840
1836
  /**
1841
1837
  * Generates cryptographically strong pseudorandom data. The `size` argument
1842
1838
  * is a number indicating the number of bytes to generate.
1843
1839
  *
1844
1840
  * If a `callback` function is provided, the bytes are generated asynchronously
1845
1841
  * and the `callback` function is invoked with two arguments: `err` and `buf`.
1846
- * If an error occurs, `err` will be an `Error` object; otherwise it is `null`. The`buf` argument is a `Buffer` containing the generated bytes.
1842
+ * If an error occurs, `err` will be an `Error` object; otherwise it is `null`. The `buf` argument is a `Buffer` containing the generated bytes.
1847
1843
  *
1848
1844
  * ```js
1849
1845
  * // Asynchronous
@@ -1889,15 +1885,15 @@ declare module "crypto" {
1889
1885
  * @param size The number of bytes to generate. The `size` must not be larger than `2**31 - 1`.
1890
1886
  * @return if the `callback` function is not provided.
1891
1887
  */
1892
- function randomBytes(size: number): Buffer;
1893
- function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
1894
- function pseudoRandomBytes(size: number): Buffer;
1895
- function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
1888
+ function randomBytes(size: number): NonSharedBuffer;
1889
+ function randomBytes(size: number, callback: (err: Error | null, buf: NonSharedBuffer) => void): void;
1890
+ function pseudoRandomBytes(size: number): NonSharedBuffer;
1891
+ function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: NonSharedBuffer) => void): void;
1896
1892
  /**
1897
1893
  * Return a random integer `n` such that `min <= n < max`. This
1898
1894
  * implementation avoids [modulo bias](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias).
1899
1895
  *
1900
- * The range (`max - min`) must be less than 248. `min` and `max` must
1896
+ * The range (`max - min`) must be less than 2**48. `min` and `max` must
1901
1897
  * be [safe integers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
1902
1898
  *
1903
1899
  * If the `callback` function is not provided, the random integer is
@@ -2014,7 +2010,7 @@ declare module "crypto" {
2014
2010
  * });
2015
2011
  * ```
2016
2012
  *
2017
- * Any `ArrayBuffer`, `TypedArray`, or `DataView` instance may be passed as`buffer`.
2013
+ * Any `ArrayBuffer`, `TypedArray`, or `DataView` instance may be passed as `buffer`.
2018
2014
  *
2019
2015
  * While this includes instances of `Float32Array` and `Float64Array`, this
2020
2016
  * function should not be used to generate random floating-point numbers. The
@@ -2094,7 +2090,7 @@ declare module "crypto" {
2094
2090
  *
2095
2091
  * When passing strings for `password` or `salt`, please consider `caveats when using strings as inputs to cryptographic APIs`.
2096
2092
  *
2097
- * The `callback` function is called with two arguments: `err` and `derivedKey`.`err` is an exception object when key derivation fails, otherwise `err` is`null`. `derivedKey` is passed to the
2093
+ * The `callback` function is called with two arguments: `err` and `derivedKey`. `err` is an exception object when key derivation fails, otherwise `err` is `null`. `derivedKey` is passed to the
2098
2094
  * callback as a `Buffer`.
2099
2095
  *
2100
2096
  * An exception is thrown when any of the input arguments specify invalid values
@@ -2122,14 +2118,14 @@ declare module "crypto" {
2122
2118
  password: BinaryLike,
2123
2119
  salt: BinaryLike,
2124
2120
  keylen: number,
2125
- callback: (err: Error | null, derivedKey: Buffer) => void,
2121
+ callback: (err: Error | null, derivedKey: NonSharedBuffer) => void,
2126
2122
  ): void;
2127
2123
  function scrypt(
2128
2124
  password: BinaryLike,
2129
2125
  salt: BinaryLike,
2130
2126
  keylen: number,
2131
2127
  options: ScryptOptions,
2132
- callback: (err: Error | null, derivedKey: Buffer) => void,
2128
+ callback: (err: Error | null, derivedKey: NonSharedBuffer) => void,
2133
2129
  ): void;
2134
2130
  /**
2135
2131
  * Provides a synchronous [scrypt](https://en.wikipedia.org/wiki/Scrypt) implementation. Scrypt is a password-based
@@ -2161,7 +2157,12 @@ declare module "crypto" {
2161
2157
  * ```
2162
2158
  * @since v10.5.0
2163
2159
  */
2164
- function scryptSync(password: BinaryLike, salt: BinaryLike, keylen: number, options?: ScryptOptions): Buffer;
2160
+ function scryptSync(
2161
+ password: BinaryLike,
2162
+ salt: BinaryLike,
2163
+ keylen: number,
2164
+ options?: ScryptOptions,
2165
+ ): NonSharedBuffer;
2165
2166
  interface RsaPublicKey {
2166
2167
  key: KeyLike;
2167
2168
  padding?: number | undefined;
@@ -2180,44 +2181,56 @@ declare module "crypto" {
2180
2181
  * Encrypts the content of `buffer` with `key` and returns a new `Buffer` with encrypted content. The returned data can be decrypted using
2181
2182
  * the corresponding private key, for example using {@link privateDecrypt}.
2182
2183
  *
2183
- * If `key` is not a `KeyObject`, this function behaves as if`key` had been passed to {@link createPublicKey}. If it is an
2184
- * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_OAEP_PADDING`.
2184
+ * If `key` is not a `KeyObject`, this function behaves as if `key` had been passed to {@link createPublicKey}. If it is an
2185
+ * object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_OAEP_PADDING`.
2185
2186
  *
2186
2187
  * Because RSA public keys can be derived from private keys, a private key may
2187
2188
  * be passed instead of a public key.
2188
2189
  * @since v0.11.14
2189
2190
  */
2190
- function publicEncrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
2191
+ function publicEncrypt(
2192
+ key: RsaPublicKey | RsaPrivateKey | KeyLike,
2193
+ buffer: NodeJS.ArrayBufferView | string,
2194
+ ): NonSharedBuffer;
2191
2195
  /**
2192
2196
  * Decrypts `buffer` with `key`.`buffer` was previously encrypted using
2193
2197
  * the corresponding private key, for example using {@link privateEncrypt}.
2194
2198
  *
2195
- * If `key` is not a `KeyObject`, this function behaves as if`key` had been passed to {@link createPublicKey}. If it is an
2196
- * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_PADDING`.
2199
+ * If `key` is not a `KeyObject`, this function behaves as if `key` had been passed to {@link createPublicKey}. If it is an
2200
+ * object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_PADDING`.
2197
2201
  *
2198
2202
  * Because RSA public keys can be derived from private keys, a private key may
2199
2203
  * be passed instead of a public key.
2200
2204
  * @since v1.1.0
2201
2205
  */
2202
- function publicDecrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
2206
+ function publicDecrypt(
2207
+ key: RsaPublicKey | RsaPrivateKey | KeyLike,
2208
+ buffer: NodeJS.ArrayBufferView | string,
2209
+ ): NonSharedBuffer;
2203
2210
  /**
2204
2211
  * Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using
2205
2212
  * the corresponding public key, for example using {@link publicEncrypt}.
2206
2213
  *
2207
- * If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an
2208
- * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_OAEP_PADDING`.
2214
+ * If `privateKey` is not a `KeyObject`, this function behaves as if `privateKey` had been passed to {@link createPrivateKey}. If it is an
2215
+ * object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_OAEP_PADDING`.
2209
2216
  * @since v0.11.14
2210
2217
  */
2211
- function privateDecrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
2218
+ function privateDecrypt(
2219
+ privateKey: RsaPrivateKey | KeyLike,
2220
+ buffer: NodeJS.ArrayBufferView | string,
2221
+ ): NonSharedBuffer;
2212
2222
  /**
2213
2223
  * Encrypts `buffer` with `privateKey`. The returned data can be decrypted using
2214
2224
  * the corresponding public key, for example using {@link publicDecrypt}.
2215
2225
  *
2216
- * If `privateKey` is not a `KeyObject`, this function behaves as if`privateKey` had been passed to {@link createPrivateKey}. If it is an
2217
- * object, the `padding` property can be passed. Otherwise, this function uses`RSA_PKCS1_PADDING`.
2226
+ * If `privateKey` is not a `KeyObject`, this function behaves as if `privateKey` had been passed to {@link createPrivateKey}. If it is an
2227
+ * object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_PADDING`.
2218
2228
  * @since v1.1.0
2219
2229
  */
2220
- function privateEncrypt(privateKey: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
2230
+ function privateEncrypt(
2231
+ privateKey: RsaPrivateKey | KeyLike,
2232
+ buffer: NodeJS.ArrayBufferView | string,
2233
+ ): NonSharedBuffer;
2221
2234
  /**
2222
2235
  * ```js
2223
2236
  * const {
@@ -2309,9 +2322,9 @@ declare module "crypto" {
2309
2322
  * On recent OpenSSL releases, `openssl ecparam -list_curves` will also display
2310
2323
  * the name and description of each available elliptic curve.
2311
2324
  *
2312
- * If `format` is not specified the point will be returned in `'uncompressed'`format.
2325
+ * If `format` is not specified the point will be returned in `'uncompressed'` format.
2313
2326
  *
2314
- * If the `inputEncoding` is not provided, `key` is expected to be a `Buffer`,`TypedArray`, or `DataView`.
2327
+ * If the `inputEncoding` is not provided, `key` is expected to be a `Buffer`, `TypedArray`, or `DataView`.
2315
2328
  *
2316
2329
  * Example (uncompressing a key):
2317
2330
  *
@@ -2346,20 +2359,20 @@ declare module "crypto" {
2346
2359
  inputEncoding?: BinaryToTextEncoding,
2347
2360
  outputEncoding?: "latin1" | "hex" | "base64" | "base64url",
2348
2361
  format?: "uncompressed" | "compressed" | "hybrid",
2349
- ): Buffer | string;
2362
+ ): NonSharedBuffer | string;
2350
2363
  /**
2351
2364
  * Generates private and public EC Diffie-Hellman key values, and returns
2352
2365
  * the public key in the specified `format` and `encoding`. This key should be
2353
2366
  * transferred to the other party.
2354
2367
  *
2355
- * The `format` argument specifies point encoding and can be `'compressed'` or`'uncompressed'`. If `format` is not specified, the point will be returned in`'uncompressed'` format.
2368
+ * The `format` argument specifies point encoding and can be `'compressed'` or `'uncompressed'`. If `format` is not specified, the point will be returned in`'uncompressed'` format.
2356
2369
  *
2357
2370
  * If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.
2358
2371
  * @since v0.11.14
2359
2372
  * @param encoding The `encoding` of the return value.
2360
2373
  * @param [format='uncompressed']
2361
2374
  */
2362
- generateKeys(): Buffer;
2375
+ generateKeys(): NonSharedBuffer;
2363
2376
  generateKeys(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
2364
2377
  /**
2365
2378
  * Computes the shared secret using `otherPublicKey` as the other
@@ -2367,19 +2380,19 @@ declare module "crypto" {
2367
2380
  * key is interpreted using specified `inputEncoding`, and the returned secret
2368
2381
  * is encoded using the specified `outputEncoding`.
2369
2382
  * If the `inputEncoding` is not
2370
- * provided, `otherPublicKey` is expected to be a `Buffer`, `TypedArray`, or`DataView`.
2383
+ * provided, `otherPublicKey` is expected to be a `Buffer`, `TypedArray`, or `DataView`.
2371
2384
  *
2372
2385
  * If `outputEncoding` is given a string will be returned; otherwise a `Buffer` is returned.
2373
2386
  *
2374
- * `ecdh.computeSecret` will throw an`ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY` error when `otherPublicKey`lies outside of the elliptic curve. Since `otherPublicKey` is
2387
+ * `ecdh.computeSecret` will throw an`ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY` error when `otherPublicKey` lies outside of the elliptic curve. Since `otherPublicKey` is
2375
2388
  * usually supplied from a remote user over an insecure network,
2376
2389
  * be sure to handle this exception accordingly.
2377
2390
  * @since v0.11.14
2378
2391
  * @param inputEncoding The `encoding` of the `otherPublicKey` string.
2379
2392
  * @param outputEncoding The `encoding` of the return value.
2380
2393
  */
2381
- computeSecret(otherPublicKey: NodeJS.ArrayBufferView): Buffer;
2382
- computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding): Buffer;
2394
+ computeSecret(otherPublicKey: NodeJS.ArrayBufferView): NonSharedBuffer;
2395
+ computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding): NonSharedBuffer;
2383
2396
  computeSecret(otherPublicKey: NodeJS.ArrayBufferView, outputEncoding: BinaryToTextEncoding): string;
2384
2397
  computeSecret(
2385
2398
  otherPublicKey: string,
@@ -2393,10 +2406,10 @@ declare module "crypto" {
2393
2406
  * @param encoding The `encoding` of the return value.
2394
2407
  * @return The EC Diffie-Hellman in the specified `encoding`.
2395
2408
  */
2396
- getPrivateKey(): Buffer;
2409
+ getPrivateKey(): NonSharedBuffer;
2397
2410
  getPrivateKey(encoding: BinaryToTextEncoding): string;
2398
2411
  /**
2399
- * The `format` argument specifies point encoding and can be `'compressed'` or`'uncompressed'`. If `format` is not specified the point will be returned in`'uncompressed'` format.
2412
+ * The `format` argument specifies point encoding and can be `'compressed'` or `'uncompressed'`. If `format` is not specified the point will be returned in`'uncompressed'` format.
2400
2413
  *
2401
2414
  * If `encoding` is specified, a string is returned; otherwise a `Buffer` is
2402
2415
  * returned.
@@ -2405,12 +2418,12 @@ declare module "crypto" {
2405
2418
  * @param [format='uncompressed']
2406
2419
  * @return The EC Diffie-Hellman public key in the specified `encoding` and `format`.
2407
2420
  */
2408
- getPublicKey(encoding?: null, format?: ECDHKeyFormat): Buffer;
2421
+ getPublicKey(encoding?: null, format?: ECDHKeyFormat): NonSharedBuffer;
2409
2422
  getPublicKey(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
2410
2423
  /**
2411
2424
  * Sets the EC Diffie-Hellman private key.
2412
2425
  * If `encoding` is provided, `privateKey` is expected
2413
- * to be a string; otherwise `privateKey` is expected to be a `Buffer`,`TypedArray`, or `DataView`.
2426
+ * to be a string; otherwise `privateKey` is expected to be a `Buffer`, `TypedArray`, or `DataView`.
2414
2427
  *
2415
2428
  * If `privateKey` is not valid for the curve specified when the `ECDH` object was
2416
2429
  * created, an error is thrown. Upon setting the private key, the associated
@@ -2430,7 +2443,7 @@ declare module "crypto" {
2430
2443
  */
2431
2444
  function createECDH(curveName: string): ECDH;
2432
2445
  /**
2433
- * This function compares the underlying bytes that represent the given`ArrayBuffer`, `TypedArray`, or `DataView` instances using a constant-time
2446
+ * This function compares the underlying bytes that represent the given `ArrayBuffer`, `TypedArray`, or `DataView` instances using a constant-time
2434
2447
  * algorithm.
2435
2448
  *
2436
2449
  * This function does not leak timing information that
@@ -2445,8 +2458,8 @@ declare module "crypto" {
2445
2458
  * entry, such as `Uint16Array`, the result will be computed using the platform
2446
2459
  * byte order.
2447
2460
  *
2448
- * **When both of the inputs are `Float32Array`s or`Float64Array`s, this function might return unexpected results due to IEEE 754**
2449
- * **encoding of floating-point numbers. In particular, neither `x === y` nor`Object.is(x, y)` implies that the byte representations of two floating-point**
2461
+ * **When both of the inputs are `Float32Array`s or `Float64Array`s, this function might return unexpected results due to IEEE 754**
2462
+ * **encoding of floating-point numbers. In particular, neither `x === y` nor `Object.is(x, y)` implies that the byte representations of two floating-point**
2450
2463
  * **numbers `x` and `y` are equal.**
2451
2464
  *
2452
2465
  * Use of `crypto.timingSafeEqual` does not guarantee that the _surrounding_ code
@@ -2455,7 +2468,34 @@ declare module "crypto" {
2455
2468
  * @since v6.6.0
2456
2469
  */
2457
2470
  function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
2458
- type KeyType = "rsa" | "rsa-pss" | "dsa" | "ec" | "ed25519" | "ed448" | "x25519" | "x448";
2471
+ type KeyType =
2472
+ | "dh"
2473
+ | "dsa"
2474
+ | "ec"
2475
+ | "ed25519"
2476
+ | "ed448"
2477
+ | "ml-dsa-44"
2478
+ | "ml-dsa-65"
2479
+ | "ml-dsa-87"
2480
+ | "ml-kem-1024"
2481
+ | "ml-kem-512"
2482
+ | "ml-kem-768"
2483
+ | "rsa-pss"
2484
+ | "rsa"
2485
+ | "slh-dsa-sha2-128f"
2486
+ | "slh-dsa-sha2-128s"
2487
+ | "slh-dsa-sha2-192f"
2488
+ | "slh-dsa-sha2-192s"
2489
+ | "slh-dsa-sha2-256f"
2490
+ | "slh-dsa-sha2-256s"
2491
+ | "slh-dsa-shake-128f"
2492
+ | "slh-dsa-shake-128s"
2493
+ | "slh-dsa-shake-192f"
2494
+ | "slh-dsa-shake-192s"
2495
+ | "slh-dsa-shake-256f"
2496
+ | "slh-dsa-shake-256s"
2497
+ | "x25519"
2498
+ | "x448";
2459
2499
  type KeyFormat = "pem" | "der" | "jwk";
2460
2500
  interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
2461
2501
  format: T;
@@ -2470,11 +2510,18 @@ declare module "crypto" {
2470
2510
  interface ED448KeyPairKeyObjectOptions {}
2471
2511
  interface X25519KeyPairKeyObjectOptions {}
2472
2512
  interface X448KeyPairKeyObjectOptions {}
2513
+ interface MLDSAKeyPairKeyObjectOptions {}
2514
+ interface MLKEMKeyPairKeyObjectOptions {}
2515
+ interface SLHDSAKeyPairKeyObjectOptions {}
2473
2516
  interface ECKeyPairKeyObjectOptions {
2474
2517
  /**
2475
2518
  * Name of the curve to use
2476
2519
  */
2477
2520
  namedCurve: string;
2521
+ /**
2522
+ * Must be `'named'` or `'explicit'`. Default: `'named'`.
2523
+ */
2524
+ paramEncoding?: "explicit" | "named" | undefined;
2478
2525
  }
2479
2526
  interface RSAKeyPairKeyObjectOptions {
2480
2527
  /**
@@ -2500,15 +2547,15 @@ declare module "crypto" {
2500
2547
  /**
2501
2548
  * Name of the message digest
2502
2549
  */
2503
- hashAlgorithm?: string;
2550
+ hashAlgorithm?: string | undefined;
2504
2551
  /**
2505
2552
  * Name of the message digest used by MGF1
2506
2553
  */
2507
- mgf1HashAlgorithm?: string;
2554
+ mgf1HashAlgorithm?: string | undefined;
2508
2555
  /**
2509
2556
  * Minimal salt length in bytes
2510
2557
  */
2511
- saltLength?: string;
2558
+ saltLength?: string | undefined;
2512
2559
  }
2513
2560
  interface DSAKeyPairKeyObjectOptions {
2514
2561
  /**
@@ -2551,15 +2598,15 @@ declare module "crypto" {
2551
2598
  /**
2552
2599
  * Name of the message digest
2553
2600
  */
2554
- hashAlgorithm?: string;
2601
+ hashAlgorithm?: string | undefined;
2555
2602
  /**
2556
2603
  * Name of the message digest used by MGF1
2557
2604
  */
2558
- mgf1HashAlgorithm?: string;
2605
+ mgf1HashAlgorithm?: string | undefined;
2559
2606
  /**
2560
2607
  * Minimal salt length in bytes
2561
2608
  */
2562
- saltLength?: string;
2609
+ saltLength?: string | undefined;
2563
2610
  publicKeyEncoding: {
2564
2611
  type: "spki";
2565
2612
  format: PubF;
@@ -2585,11 +2632,7 @@ declare module "crypto" {
2585
2632
  type: "pkcs8";
2586
2633
  };
2587
2634
  }
2588
- interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2589
- /**
2590
- * Name of the curve to use.
2591
- */
2592
- namedCurve: string;
2635
+ interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> extends ECKeyPairKeyObjectOptions {
2593
2636
  publicKeyEncoding: {
2594
2637
  type: "pkcs1" | "spki";
2595
2638
  format: PubF;
@@ -2634,17 +2677,44 @@ declare module "crypto" {
2634
2677
  type: "pkcs8";
2635
2678
  };
2636
2679
  }
2680
+ interface MLDSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2681
+ publicKeyEncoding: {
2682
+ type: "spki";
2683
+ format: PubF;
2684
+ };
2685
+ privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2686
+ type: "pkcs8";
2687
+ };
2688
+ }
2689
+ interface MLKEMKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2690
+ publicKeyEncoding: {
2691
+ type: "spki";
2692
+ format: PubF;
2693
+ };
2694
+ privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2695
+ type: "pkcs8";
2696
+ };
2697
+ }
2698
+ interface SLHDSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
2699
+ publicKeyEncoding: {
2700
+ type: "spki";
2701
+ format: PubF;
2702
+ };
2703
+ privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
2704
+ type: "pkcs8";
2705
+ };
2706
+ }
2637
2707
  interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
2638
2708
  publicKey: T1;
2639
2709
  privateKey: T2;
2640
2710
  }
2641
2711
  /**
2642
- * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
2643
- * Ed25519, Ed448, X25519, X448, and DH are currently supported.
2712
+ * Generates a new asymmetric key pair of the given `type`.
2713
+ * See the supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types).
2644
2714
  *
2645
2715
  * If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
2646
- * behaves as if `keyObject.export()` had been called on its result. Otherwise,
2647
- * the respective part of the key is returned as a `KeyObject`.
2716
+ * behaves as if {@link KeyObject.export `keyObject.export()`} had been called on its result. Otherwise,
2717
+ * the respective part of the key is returned as a {@link KeyObject `KeyObject`}.
2648
2718
  *
2649
2719
  * When encoding public keys, it is recommended to use `'spki'`. When encoding
2650
2720
  * private keys, it is recommended to use `'pkcs8'` with a strong passphrase,
@@ -2677,7 +2747,8 @@ declare module "crypto" {
2677
2747
  * When PEM encoding was selected, the respective key will be a string, otherwise
2678
2748
  * it will be a buffer containing the data encoded as DER.
2679
2749
  * @since v10.12.0
2680
- * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'`, `'x448'`, or `'dh'`.
2750
+ * @param type The asymmetric key type to generate. See the
2751
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types).
2681
2752
  */
2682
2753
  function generateKeyPairSync(
2683
2754
  type: "rsa",
@@ -2686,15 +2757,15 @@ declare module "crypto" {
2686
2757
  function generateKeyPairSync(
2687
2758
  type: "rsa",
2688
2759
  options: RSAKeyPairOptions<"pem", "der">,
2689
- ): KeyPairSyncResult<string, Buffer>;
2760
+ ): KeyPairSyncResult<string, NonSharedBuffer>;
2690
2761
  function generateKeyPairSync(
2691
2762
  type: "rsa",
2692
2763
  options: RSAKeyPairOptions<"der", "pem">,
2693
- ): KeyPairSyncResult<Buffer, string>;
2764
+ ): KeyPairSyncResult<NonSharedBuffer, string>;
2694
2765
  function generateKeyPairSync(
2695
2766
  type: "rsa",
2696
2767
  options: RSAKeyPairOptions<"der", "der">,
2697
- ): KeyPairSyncResult<Buffer, Buffer>;
2768
+ ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2698
2769
  function generateKeyPairSync(type: "rsa", options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2699
2770
  function generateKeyPairSync(
2700
2771
  type: "rsa-pss",
@@ -2703,15 +2774,15 @@ declare module "crypto" {
2703
2774
  function generateKeyPairSync(
2704
2775
  type: "rsa-pss",
2705
2776
  options: RSAPSSKeyPairOptions<"pem", "der">,
2706
- ): KeyPairSyncResult<string, Buffer>;
2777
+ ): KeyPairSyncResult<string, NonSharedBuffer>;
2707
2778
  function generateKeyPairSync(
2708
2779
  type: "rsa-pss",
2709
2780
  options: RSAPSSKeyPairOptions<"der", "pem">,
2710
- ): KeyPairSyncResult<Buffer, string>;
2781
+ ): KeyPairSyncResult<NonSharedBuffer, string>;
2711
2782
  function generateKeyPairSync(
2712
2783
  type: "rsa-pss",
2713
2784
  options: RSAPSSKeyPairOptions<"der", "der">,
2714
- ): KeyPairSyncResult<Buffer, Buffer>;
2785
+ ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2715
2786
  function generateKeyPairSync(type: "rsa-pss", options: RSAPSSKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2716
2787
  function generateKeyPairSync(
2717
2788
  type: "dsa",
@@ -2720,15 +2791,15 @@ declare module "crypto" {
2720
2791
  function generateKeyPairSync(
2721
2792
  type: "dsa",
2722
2793
  options: DSAKeyPairOptions<"pem", "der">,
2723
- ): KeyPairSyncResult<string, Buffer>;
2794
+ ): KeyPairSyncResult<string, NonSharedBuffer>;
2724
2795
  function generateKeyPairSync(
2725
2796
  type: "dsa",
2726
2797
  options: DSAKeyPairOptions<"der", "pem">,
2727
- ): KeyPairSyncResult<Buffer, string>;
2798
+ ): KeyPairSyncResult<NonSharedBuffer, string>;
2728
2799
  function generateKeyPairSync(
2729
2800
  type: "dsa",
2730
2801
  options: DSAKeyPairOptions<"der", "der">,
2731
- ): KeyPairSyncResult<Buffer, Buffer>;
2802
+ ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2732
2803
  function generateKeyPairSync(type: "dsa", options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2733
2804
  function generateKeyPairSync(
2734
2805
  type: "ec",
@@ -2737,15 +2808,15 @@ declare module "crypto" {
2737
2808
  function generateKeyPairSync(
2738
2809
  type: "ec",
2739
2810
  options: ECKeyPairOptions<"pem", "der">,
2740
- ): KeyPairSyncResult<string, Buffer>;
2811
+ ): KeyPairSyncResult<string, NonSharedBuffer>;
2741
2812
  function generateKeyPairSync(
2742
2813
  type: "ec",
2743
2814
  options: ECKeyPairOptions<"der", "pem">,
2744
- ): KeyPairSyncResult<Buffer, string>;
2815
+ ): KeyPairSyncResult<NonSharedBuffer, string>;
2745
2816
  function generateKeyPairSync(
2746
2817
  type: "ec",
2747
2818
  options: ECKeyPairOptions<"der", "der">,
2748
- ): KeyPairSyncResult<Buffer, Buffer>;
2819
+ ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2749
2820
  function generateKeyPairSync(type: "ec", options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2750
2821
  function generateKeyPairSync(
2751
2822
  type: "ed25519",
@@ -2754,15 +2825,15 @@ declare module "crypto" {
2754
2825
  function generateKeyPairSync(
2755
2826
  type: "ed25519",
2756
2827
  options: ED25519KeyPairOptions<"pem", "der">,
2757
- ): KeyPairSyncResult<string, Buffer>;
2828
+ ): KeyPairSyncResult<string, NonSharedBuffer>;
2758
2829
  function generateKeyPairSync(
2759
2830
  type: "ed25519",
2760
2831
  options: ED25519KeyPairOptions<"der", "pem">,
2761
- ): KeyPairSyncResult<Buffer, string>;
2832
+ ): KeyPairSyncResult<NonSharedBuffer, string>;
2762
2833
  function generateKeyPairSync(
2763
2834
  type: "ed25519",
2764
2835
  options: ED25519KeyPairOptions<"der", "der">,
2765
- ): KeyPairSyncResult<Buffer, Buffer>;
2836
+ ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2766
2837
  function generateKeyPairSync(type: "ed25519", options?: ED25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2767
2838
  function generateKeyPairSync(
2768
2839
  type: "ed448",
@@ -2771,15 +2842,15 @@ declare module "crypto" {
2771
2842
  function generateKeyPairSync(
2772
2843
  type: "ed448",
2773
2844
  options: ED448KeyPairOptions<"pem", "der">,
2774
- ): KeyPairSyncResult<string, Buffer>;
2845
+ ): KeyPairSyncResult<string, NonSharedBuffer>;
2775
2846
  function generateKeyPairSync(
2776
2847
  type: "ed448",
2777
2848
  options: ED448KeyPairOptions<"der", "pem">,
2778
- ): KeyPairSyncResult<Buffer, string>;
2849
+ ): KeyPairSyncResult<NonSharedBuffer, string>;
2779
2850
  function generateKeyPairSync(
2780
2851
  type: "ed448",
2781
2852
  options: ED448KeyPairOptions<"der", "der">,
2782
- ): KeyPairSyncResult<Buffer, Buffer>;
2853
+ ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2783
2854
  function generateKeyPairSync(type: "ed448", options?: ED448KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2784
2855
  function generateKeyPairSync(
2785
2856
  type: "x25519",
@@ -2788,15 +2859,15 @@ declare module "crypto" {
2788
2859
  function generateKeyPairSync(
2789
2860
  type: "x25519",
2790
2861
  options: X25519KeyPairOptions<"pem", "der">,
2791
- ): KeyPairSyncResult<string, Buffer>;
2862
+ ): KeyPairSyncResult<string, NonSharedBuffer>;
2792
2863
  function generateKeyPairSync(
2793
2864
  type: "x25519",
2794
2865
  options: X25519KeyPairOptions<"der", "pem">,
2795
- ): KeyPairSyncResult<Buffer, string>;
2866
+ ): KeyPairSyncResult<NonSharedBuffer, string>;
2796
2867
  function generateKeyPairSync(
2797
2868
  type: "x25519",
2798
2869
  options: X25519KeyPairOptions<"der", "der">,
2799
- ): KeyPairSyncResult<Buffer, Buffer>;
2870
+ ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2800
2871
  function generateKeyPairSync(type: "x25519", options?: X25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2801
2872
  function generateKeyPairSync(
2802
2873
  type: "x448",
@@ -2805,25 +2876,145 @@ declare module "crypto" {
2805
2876
  function generateKeyPairSync(
2806
2877
  type: "x448",
2807
2878
  options: X448KeyPairOptions<"pem", "der">,
2808
- ): KeyPairSyncResult<string, Buffer>;
2879
+ ): KeyPairSyncResult<string, NonSharedBuffer>;
2809
2880
  function generateKeyPairSync(
2810
2881
  type: "x448",
2811
2882
  options: X448KeyPairOptions<"der", "pem">,
2812
- ): KeyPairSyncResult<Buffer, string>;
2883
+ ): KeyPairSyncResult<NonSharedBuffer, string>;
2813
2884
  function generateKeyPairSync(
2814
2885
  type: "x448",
2815
2886
  options: X448KeyPairOptions<"der", "der">,
2816
- ): KeyPairSyncResult<Buffer, Buffer>;
2887
+ ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2817
2888
  function generateKeyPairSync(type: "x448", options?: X448KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
2889
+ function generateKeyPairSync(
2890
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
2891
+ options: MLDSAKeyPairOptions<"pem", "pem">,
2892
+ ): KeyPairSyncResult<string, string>;
2893
+ function generateKeyPairSync(
2894
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
2895
+ options: MLDSAKeyPairOptions<"pem", "der">,
2896
+ ): KeyPairSyncResult<string, NonSharedBuffer>;
2897
+ function generateKeyPairSync(
2898
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
2899
+ options: MLDSAKeyPairOptions<"der", "pem">,
2900
+ ): KeyPairSyncResult<NonSharedBuffer, string>;
2901
+ function generateKeyPairSync(
2902
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
2903
+ options: MLDSAKeyPairOptions<"der", "der">,
2904
+ ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2905
+ function generateKeyPairSync(
2906
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
2907
+ options?: MLDSAKeyPairKeyObjectOptions,
2908
+ ): KeyPairKeyObjectResult;
2909
+ function generateKeyPairSync(
2910
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
2911
+ options: MLKEMKeyPairOptions<"pem", "pem">,
2912
+ ): KeyPairSyncResult<string, string>;
2913
+ function generateKeyPairSync(
2914
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
2915
+ options: MLKEMKeyPairOptions<"pem", "der">,
2916
+ ): KeyPairSyncResult<string, NonSharedBuffer>;
2917
+ function generateKeyPairSync(
2918
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
2919
+ options: MLKEMKeyPairOptions<"der", "pem">,
2920
+ ): KeyPairSyncResult<NonSharedBuffer, string>;
2921
+ function generateKeyPairSync(
2922
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
2923
+ options: MLKEMKeyPairOptions<"der", "der">,
2924
+ ): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
2925
+ function generateKeyPairSync(
2926
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
2927
+ options?: MLKEMKeyPairKeyObjectOptions,
2928
+ ): KeyPairKeyObjectResult;
2929
+ function generateKeyPairSync(
2930
+ type:
2931
+ | "slh-dsa-sha2-128f"
2932
+ | "slh-dsa-sha2-128s"
2933
+ | "slh-dsa-sha2-192f"
2934
+ | "slh-dsa-sha2-192s"
2935
+ | "slh-dsa-sha2-256f"
2936
+ | "slh-dsa-sha2-256s"
2937
+ | "slh-dsa-shake-128f"
2938
+ | "slh-dsa-shake-128s"
2939
+ | "slh-dsa-shake-192f"
2940
+ | "slh-dsa-shake-192s"
2941
+ | "slh-dsa-shake-256f"
2942
+ | "slh-dsa-shake-256s",
2943
+ options: SLHDSAKeyPairOptions<"pem", "pem">,
2944
+ ): KeyPairSyncResult<string, string>;
2945
+ function generateKeyPairSync(
2946
+ type:
2947
+ | "slh-dsa-sha2-128f"
2948
+ | "slh-dsa-sha2-128s"
2949
+ | "slh-dsa-sha2-192f"
2950
+ | "slh-dsa-sha2-192s"
2951
+ | "slh-dsa-sha2-256f"
2952
+ | "slh-dsa-sha2-256s"
2953
+ | "slh-dsa-shake-128f"
2954
+ | "slh-dsa-shake-128s"
2955
+ | "slh-dsa-shake-192f"
2956
+ | "slh-dsa-shake-192s"
2957
+ | "slh-dsa-shake-256f"
2958
+ | "slh-dsa-shake-256s",
2959
+ options: SLHDSAKeyPairOptions<"pem", "der">,
2960
+ ): KeyPairSyncResult<string, Buffer>;
2961
+ function generateKeyPairSync(
2962
+ type:
2963
+ | "slh-dsa-sha2-128f"
2964
+ | "slh-dsa-sha2-128s"
2965
+ | "slh-dsa-sha2-192f"
2966
+ | "slh-dsa-sha2-192s"
2967
+ | "slh-dsa-sha2-256f"
2968
+ | "slh-dsa-sha2-256s"
2969
+ | "slh-dsa-shake-128f"
2970
+ | "slh-dsa-shake-128s"
2971
+ | "slh-dsa-shake-192f"
2972
+ | "slh-dsa-shake-192s"
2973
+ | "slh-dsa-shake-256f"
2974
+ | "slh-dsa-shake-256s",
2975
+ options: SLHDSAKeyPairOptions<"der", "pem">,
2976
+ ): KeyPairSyncResult<Buffer, string>;
2977
+ function generateKeyPairSync(
2978
+ type:
2979
+ | "slh-dsa-sha2-128f"
2980
+ | "slh-dsa-sha2-128s"
2981
+ | "slh-dsa-sha2-192f"
2982
+ | "slh-dsa-sha2-192s"
2983
+ | "slh-dsa-sha2-256f"
2984
+ | "slh-dsa-sha2-256s"
2985
+ | "slh-dsa-shake-128f"
2986
+ | "slh-dsa-shake-128s"
2987
+ | "slh-dsa-shake-192f"
2988
+ | "slh-dsa-shake-192s"
2989
+ | "slh-dsa-shake-256f"
2990
+ | "slh-dsa-shake-256s",
2991
+ options: SLHDSAKeyPairOptions<"der", "der">,
2992
+ ): KeyPairSyncResult<Buffer, Buffer>;
2993
+ function generateKeyPairSync(
2994
+ type:
2995
+ | "slh-dsa-sha2-128f"
2996
+ | "slh-dsa-sha2-128s"
2997
+ | "slh-dsa-sha2-192f"
2998
+ | "slh-dsa-sha2-192s"
2999
+ | "slh-dsa-sha2-256f"
3000
+ | "slh-dsa-sha2-256s"
3001
+ | "slh-dsa-shake-128f"
3002
+ | "slh-dsa-shake-128s"
3003
+ | "slh-dsa-shake-192f"
3004
+ | "slh-dsa-shake-192s"
3005
+ | "slh-dsa-shake-256f"
3006
+ | "slh-dsa-shake-256s",
3007
+ options?: SLHDSAKeyPairKeyObjectOptions,
3008
+ ): KeyPairKeyObjectResult;
2818
3009
  /**
2819
- * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
2820
- * Ed25519, Ed448, X25519, X448, and DH are currently supported.
3010
+ * Generates a new asymmetric key pair of the given `type`.
3011
+ * See the supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types).
2821
3012
  *
2822
3013
  * If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
2823
- * behaves as if `keyObject.export()` had been called on its result. Otherwise,
2824
- * the respective part of the key is returned as a `KeyObject`.
3014
+ * behaves as if {@link KeyObject.export `keyObject.export()`} had been called on its result. Otherwise,
3015
+ * the respective part of the key is returned as a {@link KeyObject `KeyObject`}.
2825
3016
  *
2826
- * It is recommended to encode public keys as `'spki'` and private keys as`'pkcs8'` with encryption for long-term storage:
3017
+ * It is recommended to encode public keys as `'spki'` and private keys as `'pkcs8'` with encryption for long-term storage:
2827
3018
  *
2828
3019
  * ```js
2829
3020
  * const {
@@ -2847,12 +3038,13 @@ declare module "crypto" {
2847
3038
  * });
2848
3039
  * ```
2849
3040
  *
2850
- * On completion, `callback` will be called with `err` set to `undefined` and`publicKey` / `privateKey` representing the generated key pair.
3041
+ * On completion, `callback` will be called with `err` set to `undefined` and `publicKey` / `privateKey` representing the generated key pair.
2851
3042
  *
2852
3043
  * If this method is invoked as its `util.promisify()` ed version, it returns
2853
3044
  * a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
2854
3045
  * @since v10.12.0
2855
- * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`, `'x25519'`, `'x448'`, or `'dh'`.
3046
+ * @param type The asymmetric key type to generate. See the
3047
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types).
2856
3048
  */
2857
3049
  function generateKeyPair(
2858
3050
  type: "rsa",
@@ -2862,17 +3054,17 @@ declare module "crypto" {
2862
3054
  function generateKeyPair(
2863
3055
  type: "rsa",
2864
3056
  options: RSAKeyPairOptions<"pem", "der">,
2865
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
3057
+ callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2866
3058
  ): void;
2867
3059
  function generateKeyPair(
2868
3060
  type: "rsa",
2869
3061
  options: RSAKeyPairOptions<"der", "pem">,
2870
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
3062
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2871
3063
  ): void;
2872
3064
  function generateKeyPair(
2873
3065
  type: "rsa",
2874
3066
  options: RSAKeyPairOptions<"der", "der">,
2875
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
3067
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2876
3068
  ): void;
2877
3069
  function generateKeyPair(
2878
3070
  type: "rsa",
@@ -2887,17 +3079,17 @@ declare module "crypto" {
2887
3079
  function generateKeyPair(
2888
3080
  type: "rsa-pss",
2889
3081
  options: RSAPSSKeyPairOptions<"pem", "der">,
2890
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
3082
+ callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2891
3083
  ): void;
2892
3084
  function generateKeyPair(
2893
3085
  type: "rsa-pss",
2894
3086
  options: RSAPSSKeyPairOptions<"der", "pem">,
2895
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
3087
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2896
3088
  ): void;
2897
3089
  function generateKeyPair(
2898
3090
  type: "rsa-pss",
2899
3091
  options: RSAPSSKeyPairOptions<"der", "der">,
2900
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
3092
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2901
3093
  ): void;
2902
3094
  function generateKeyPair(
2903
3095
  type: "rsa-pss",
@@ -2912,17 +3104,17 @@ declare module "crypto" {
2912
3104
  function generateKeyPair(
2913
3105
  type: "dsa",
2914
3106
  options: DSAKeyPairOptions<"pem", "der">,
2915
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
3107
+ callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2916
3108
  ): void;
2917
3109
  function generateKeyPair(
2918
3110
  type: "dsa",
2919
3111
  options: DSAKeyPairOptions<"der", "pem">,
2920
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
3112
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2921
3113
  ): void;
2922
3114
  function generateKeyPair(
2923
3115
  type: "dsa",
2924
3116
  options: DSAKeyPairOptions<"der", "der">,
2925
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
3117
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2926
3118
  ): void;
2927
3119
  function generateKeyPair(
2928
3120
  type: "dsa",
@@ -2937,17 +3129,17 @@ declare module "crypto" {
2937
3129
  function generateKeyPair(
2938
3130
  type: "ec",
2939
3131
  options: ECKeyPairOptions<"pem", "der">,
2940
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
3132
+ callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2941
3133
  ): void;
2942
3134
  function generateKeyPair(
2943
3135
  type: "ec",
2944
3136
  options: ECKeyPairOptions<"der", "pem">,
2945
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
3137
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2946
3138
  ): void;
2947
3139
  function generateKeyPair(
2948
3140
  type: "ec",
2949
3141
  options: ECKeyPairOptions<"der", "der">,
2950
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
3142
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2951
3143
  ): void;
2952
3144
  function generateKeyPair(
2953
3145
  type: "ec",
@@ -2962,17 +3154,17 @@ declare module "crypto" {
2962
3154
  function generateKeyPair(
2963
3155
  type: "ed25519",
2964
3156
  options: ED25519KeyPairOptions<"pem", "der">,
2965
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
3157
+ callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2966
3158
  ): void;
2967
3159
  function generateKeyPair(
2968
3160
  type: "ed25519",
2969
3161
  options: ED25519KeyPairOptions<"der", "pem">,
2970
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
3162
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2971
3163
  ): void;
2972
3164
  function generateKeyPair(
2973
3165
  type: "ed25519",
2974
3166
  options: ED25519KeyPairOptions<"der", "der">,
2975
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
3167
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
2976
3168
  ): void;
2977
3169
  function generateKeyPair(
2978
3170
  type: "ed25519",
@@ -2987,17 +3179,17 @@ declare module "crypto" {
2987
3179
  function generateKeyPair(
2988
3180
  type: "ed448",
2989
3181
  options: ED448KeyPairOptions<"pem", "der">,
2990
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
3182
+ callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
2991
3183
  ): void;
2992
3184
  function generateKeyPair(
2993
3185
  type: "ed448",
2994
3186
  options: ED448KeyPairOptions<"der", "pem">,
2995
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
3187
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
2996
3188
  ): void;
2997
3189
  function generateKeyPair(
2998
3190
  type: "ed448",
2999
3191
  options: ED448KeyPairOptions<"der", "der">,
3000
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
3192
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
3001
3193
  ): void;
3002
3194
  function generateKeyPair(
3003
3195
  type: "ed448",
@@ -3012,17 +3204,17 @@ declare module "crypto" {
3012
3204
  function generateKeyPair(
3013
3205
  type: "x25519",
3014
3206
  options: X25519KeyPairOptions<"pem", "der">,
3015
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
3207
+ callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
3016
3208
  ): void;
3017
3209
  function generateKeyPair(
3018
3210
  type: "x25519",
3019
3211
  options: X25519KeyPairOptions<"der", "pem">,
3020
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
3212
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
3021
3213
  ): void;
3022
3214
  function generateKeyPair(
3023
3215
  type: "x25519",
3024
3216
  options: X25519KeyPairOptions<"der", "der">,
3025
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
3217
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
3026
3218
  ): void;
3027
3219
  function generateKeyPair(
3028
3220
  type: "x25519",
@@ -3037,23 +3229,158 @@ declare module "crypto" {
3037
3229
  function generateKeyPair(
3038
3230
  type: "x448",
3039
3231
  options: X448KeyPairOptions<"pem", "der">,
3040
- callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
3232
+ callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
3041
3233
  ): void;
3042
3234
  function generateKeyPair(
3043
3235
  type: "x448",
3044
3236
  options: X448KeyPairOptions<"der", "pem">,
3045
- callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
3237
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
3046
3238
  ): void;
3047
3239
  function generateKeyPair(
3048
3240
  type: "x448",
3049
3241
  options: X448KeyPairOptions<"der", "der">,
3050
- callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
3242
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
3051
3243
  ): void;
3052
3244
  function generateKeyPair(
3053
3245
  type: "x448",
3054
3246
  options: X448KeyPairKeyObjectOptions | undefined,
3055
3247
  callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
3056
3248
  ): void;
3249
+ function generateKeyPair(
3250
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3251
+ options: MLDSAKeyPairOptions<"pem", "pem">,
3252
+ callback: (err: Error | null, publicKey: string, privateKey: string) => void,
3253
+ ): void;
3254
+ function generateKeyPair(
3255
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3256
+ options: MLDSAKeyPairOptions<"pem", "der">,
3257
+ callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
3258
+ ): void;
3259
+ function generateKeyPair(
3260
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3261
+ options: MLDSAKeyPairOptions<"der", "pem">,
3262
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
3263
+ ): void;
3264
+ function generateKeyPair(
3265
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3266
+ options: MLDSAKeyPairOptions<"der", "der">,
3267
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
3268
+ ): void;
3269
+ function generateKeyPair(
3270
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3271
+ options: MLDSAKeyPairKeyObjectOptions | undefined,
3272
+ callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
3273
+ ): void;
3274
+ function generateKeyPair(
3275
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3276
+ options: MLKEMKeyPairOptions<"pem", "pem">,
3277
+ callback: (err: Error | null, publicKey: string, privateKey: string) => void,
3278
+ ): void;
3279
+ function generateKeyPair(
3280
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3281
+ options: MLKEMKeyPairOptions<"pem", "der">,
3282
+ callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
3283
+ ): void;
3284
+ function generateKeyPair(
3285
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3286
+ options: MLKEMKeyPairOptions<"der", "pem">,
3287
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
3288
+ ): void;
3289
+ function generateKeyPair(
3290
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3291
+ options: MLKEMKeyPairOptions<"der", "der">,
3292
+ callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
3293
+ ): void;
3294
+ function generateKeyPair(
3295
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3296
+ options: MLKEMKeyPairKeyObjectOptions | undefined,
3297
+ callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
3298
+ ): void;
3299
+ function generateKeyPair(
3300
+ type:
3301
+ | "slh-dsa-sha2-128f"
3302
+ | "slh-dsa-sha2-128s"
3303
+ | "slh-dsa-sha2-192f"
3304
+ | "slh-dsa-sha2-192s"
3305
+ | "slh-dsa-sha2-256f"
3306
+ | "slh-dsa-sha2-256s"
3307
+ | "slh-dsa-shake-128f"
3308
+ | "slh-dsa-shake-128s"
3309
+ | "slh-dsa-shake-192f"
3310
+ | "slh-dsa-shake-192s"
3311
+ | "slh-dsa-shake-256f"
3312
+ | "slh-dsa-shake-256s",
3313
+ options: SLHDSAKeyPairOptions<"pem", "pem">,
3314
+ callback: (err: Error | null, publicKey: string, privateKey: string) => void,
3315
+ ): void;
3316
+ function generateKeyPair(
3317
+ type:
3318
+ | "slh-dsa-sha2-128f"
3319
+ | "slh-dsa-sha2-128s"
3320
+ | "slh-dsa-sha2-192f"
3321
+ | "slh-dsa-sha2-192s"
3322
+ | "slh-dsa-sha2-256f"
3323
+ | "slh-dsa-sha2-256s"
3324
+ | "slh-dsa-shake-128f"
3325
+ | "slh-dsa-shake-128s"
3326
+ | "slh-dsa-shake-192f"
3327
+ | "slh-dsa-shake-192s"
3328
+ | "slh-dsa-shake-256f"
3329
+ | "slh-dsa-shake-256s",
3330
+ options: SLHDSAKeyPairOptions<"pem", "der">,
3331
+ callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
3332
+ ): void;
3333
+ function generateKeyPair(
3334
+ type:
3335
+ | "slh-dsa-sha2-128f"
3336
+ | "slh-dsa-sha2-128s"
3337
+ | "slh-dsa-sha2-192f"
3338
+ | "slh-dsa-sha2-192s"
3339
+ | "slh-dsa-sha2-256f"
3340
+ | "slh-dsa-sha2-256s"
3341
+ | "slh-dsa-shake-128f"
3342
+ | "slh-dsa-shake-128s"
3343
+ | "slh-dsa-shake-192f"
3344
+ | "slh-dsa-shake-192s"
3345
+ | "slh-dsa-shake-256f"
3346
+ | "slh-dsa-shake-256s",
3347
+ options: SLHDSAKeyPairOptions<"der", "pem">,
3348
+ callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
3349
+ ): void;
3350
+ function generateKeyPair(
3351
+ type:
3352
+ | "slh-dsa-sha2-128f"
3353
+ | "slh-dsa-sha2-128s"
3354
+ | "slh-dsa-sha2-192f"
3355
+ | "slh-dsa-sha2-192s"
3356
+ | "slh-dsa-sha2-256f"
3357
+ | "slh-dsa-sha2-256s"
3358
+ | "slh-dsa-shake-128f"
3359
+ | "slh-dsa-shake-128s"
3360
+ | "slh-dsa-shake-192f"
3361
+ | "slh-dsa-shake-192s"
3362
+ | "slh-dsa-shake-256f"
3363
+ | "slh-dsa-shake-256s",
3364
+ options: SLHDSAKeyPairOptions<"der", "der">,
3365
+ callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
3366
+ ): void;
3367
+ function generateKeyPair(
3368
+ type:
3369
+ | "slh-dsa-sha2-128f"
3370
+ | "slh-dsa-sha2-128s"
3371
+ | "slh-dsa-sha2-192f"
3372
+ | "slh-dsa-sha2-192s"
3373
+ | "slh-dsa-sha2-256f"
3374
+ | "slh-dsa-sha2-256s"
3375
+ | "slh-dsa-shake-128f"
3376
+ | "slh-dsa-shake-128s"
3377
+ | "slh-dsa-shake-192f"
3378
+ | "slh-dsa-shake-192s"
3379
+ | "slh-dsa-shake-256f"
3380
+ | "slh-dsa-shake-256s",
3381
+ options: SLHDSAKeyPairKeyObjectOptions | undefined,
3382
+ callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
3383
+ ): void;
3057
3384
  namespace generateKeyPair {
3058
3385
  function __promisify__(
3059
3386
  type: "rsa",
@@ -3067,21 +3394,21 @@ declare module "crypto" {
3067
3394
  options: RSAKeyPairOptions<"pem", "der">,
3068
3395
  ): Promise<{
3069
3396
  publicKey: string;
3070
- privateKey: Buffer;
3397
+ privateKey: NonSharedBuffer;
3071
3398
  }>;
3072
3399
  function __promisify__(
3073
3400
  type: "rsa",
3074
3401
  options: RSAKeyPairOptions<"der", "pem">,
3075
3402
  ): Promise<{
3076
- publicKey: Buffer;
3403
+ publicKey: NonSharedBuffer;
3077
3404
  privateKey: string;
3078
3405
  }>;
3079
3406
  function __promisify__(
3080
3407
  type: "rsa",
3081
3408
  options: RSAKeyPairOptions<"der", "der">,
3082
3409
  ): Promise<{
3083
- publicKey: Buffer;
3084
- privateKey: Buffer;
3410
+ publicKey: NonSharedBuffer;
3411
+ privateKey: NonSharedBuffer;
3085
3412
  }>;
3086
3413
  function __promisify__(type: "rsa", options: RSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
3087
3414
  function __promisify__(
@@ -3096,21 +3423,21 @@ declare module "crypto" {
3096
3423
  options: RSAPSSKeyPairOptions<"pem", "der">,
3097
3424
  ): Promise<{
3098
3425
  publicKey: string;
3099
- privateKey: Buffer;
3426
+ privateKey: NonSharedBuffer;
3100
3427
  }>;
3101
3428
  function __promisify__(
3102
3429
  type: "rsa-pss",
3103
3430
  options: RSAPSSKeyPairOptions<"der", "pem">,
3104
3431
  ): Promise<{
3105
- publicKey: Buffer;
3432
+ publicKey: NonSharedBuffer;
3106
3433
  privateKey: string;
3107
3434
  }>;
3108
3435
  function __promisify__(
3109
3436
  type: "rsa-pss",
3110
3437
  options: RSAPSSKeyPairOptions<"der", "der">,
3111
3438
  ): Promise<{
3112
- publicKey: Buffer;
3113
- privateKey: Buffer;
3439
+ publicKey: NonSharedBuffer;
3440
+ privateKey: NonSharedBuffer;
3114
3441
  }>;
3115
3442
  function __promisify__(
3116
3443
  type: "rsa-pss",
@@ -3128,21 +3455,21 @@ declare module "crypto" {
3128
3455
  options: DSAKeyPairOptions<"pem", "der">,
3129
3456
  ): Promise<{
3130
3457
  publicKey: string;
3131
- privateKey: Buffer;
3458
+ privateKey: NonSharedBuffer;
3132
3459
  }>;
3133
3460
  function __promisify__(
3134
3461
  type: "dsa",
3135
3462
  options: DSAKeyPairOptions<"der", "pem">,
3136
3463
  ): Promise<{
3137
- publicKey: Buffer;
3464
+ publicKey: NonSharedBuffer;
3138
3465
  privateKey: string;
3139
3466
  }>;
3140
3467
  function __promisify__(
3141
3468
  type: "dsa",
3142
3469
  options: DSAKeyPairOptions<"der", "der">,
3143
3470
  ): Promise<{
3144
- publicKey: Buffer;
3145
- privateKey: Buffer;
3471
+ publicKey: NonSharedBuffer;
3472
+ privateKey: NonSharedBuffer;
3146
3473
  }>;
3147
3474
  function __promisify__(type: "dsa", options: DSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
3148
3475
  function __promisify__(
@@ -3157,21 +3484,21 @@ declare module "crypto" {
3157
3484
  options: ECKeyPairOptions<"pem", "der">,
3158
3485
  ): Promise<{
3159
3486
  publicKey: string;
3160
- privateKey: Buffer;
3487
+ privateKey: NonSharedBuffer;
3161
3488
  }>;
3162
3489
  function __promisify__(
3163
3490
  type: "ec",
3164
3491
  options: ECKeyPairOptions<"der", "pem">,
3165
3492
  ): Promise<{
3166
- publicKey: Buffer;
3493
+ publicKey: NonSharedBuffer;
3167
3494
  privateKey: string;
3168
3495
  }>;
3169
3496
  function __promisify__(
3170
3497
  type: "ec",
3171
3498
  options: ECKeyPairOptions<"der", "der">,
3172
3499
  ): Promise<{
3173
- publicKey: Buffer;
3174
- privateKey: Buffer;
3500
+ publicKey: NonSharedBuffer;
3501
+ privateKey: NonSharedBuffer;
3175
3502
  }>;
3176
3503
  function __promisify__(type: "ec", options: ECKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
3177
3504
  function __promisify__(
@@ -3186,21 +3513,21 @@ declare module "crypto" {
3186
3513
  options: ED25519KeyPairOptions<"pem", "der">,
3187
3514
  ): Promise<{
3188
3515
  publicKey: string;
3189
- privateKey: Buffer;
3516
+ privateKey: NonSharedBuffer;
3190
3517
  }>;
3191
3518
  function __promisify__(
3192
3519
  type: "ed25519",
3193
3520
  options: ED25519KeyPairOptions<"der", "pem">,
3194
3521
  ): Promise<{
3195
- publicKey: Buffer;
3522
+ publicKey: NonSharedBuffer;
3196
3523
  privateKey: string;
3197
3524
  }>;
3198
3525
  function __promisify__(
3199
3526
  type: "ed25519",
3200
3527
  options: ED25519KeyPairOptions<"der", "der">,
3201
3528
  ): Promise<{
3202
- publicKey: Buffer;
3203
- privateKey: Buffer;
3529
+ publicKey: NonSharedBuffer;
3530
+ privateKey: NonSharedBuffer;
3204
3531
  }>;
3205
3532
  function __promisify__(
3206
3533
  type: "ed25519",
@@ -3218,21 +3545,21 @@ declare module "crypto" {
3218
3545
  options: ED448KeyPairOptions<"pem", "der">,
3219
3546
  ): Promise<{
3220
3547
  publicKey: string;
3221
- privateKey: Buffer;
3548
+ privateKey: NonSharedBuffer;
3222
3549
  }>;
3223
3550
  function __promisify__(
3224
3551
  type: "ed448",
3225
3552
  options: ED448KeyPairOptions<"der", "pem">,
3226
3553
  ): Promise<{
3227
- publicKey: Buffer;
3554
+ publicKey: NonSharedBuffer;
3228
3555
  privateKey: string;
3229
3556
  }>;
3230
3557
  function __promisify__(
3231
3558
  type: "ed448",
3232
3559
  options: ED448KeyPairOptions<"der", "der">,
3233
3560
  ): Promise<{
3234
- publicKey: Buffer;
3235
- privateKey: Buffer;
3561
+ publicKey: NonSharedBuffer;
3562
+ privateKey: NonSharedBuffer;
3236
3563
  }>;
3237
3564
  function __promisify__(type: "ed448", options?: ED448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
3238
3565
  function __promisify__(
@@ -3247,21 +3574,21 @@ declare module "crypto" {
3247
3574
  options: X25519KeyPairOptions<"pem", "der">,
3248
3575
  ): Promise<{
3249
3576
  publicKey: string;
3250
- privateKey: Buffer;
3577
+ privateKey: NonSharedBuffer;
3251
3578
  }>;
3252
3579
  function __promisify__(
3253
3580
  type: "x25519",
3254
3581
  options: X25519KeyPairOptions<"der", "pem">,
3255
3582
  ): Promise<{
3256
- publicKey: Buffer;
3583
+ publicKey: NonSharedBuffer;
3257
3584
  privateKey: string;
3258
3585
  }>;
3259
3586
  function __promisify__(
3260
3587
  type: "x25519",
3261
3588
  options: X25519KeyPairOptions<"der", "der">,
3262
3589
  ): Promise<{
3263
- publicKey: Buffer;
3264
- privateKey: Buffer;
3590
+ publicKey: NonSharedBuffer;
3591
+ privateKey: NonSharedBuffer;
3265
3592
  }>;
3266
3593
  function __promisify__(
3267
3594
  type: "x25519",
@@ -3279,28 +3606,187 @@ declare module "crypto" {
3279
3606
  options: X448KeyPairOptions<"pem", "der">,
3280
3607
  ): Promise<{
3281
3608
  publicKey: string;
3282
- privateKey: Buffer;
3609
+ privateKey: NonSharedBuffer;
3283
3610
  }>;
3284
3611
  function __promisify__(
3285
3612
  type: "x448",
3286
3613
  options: X448KeyPairOptions<"der", "pem">,
3287
3614
  ): Promise<{
3288
- publicKey: Buffer;
3615
+ publicKey: NonSharedBuffer;
3289
3616
  privateKey: string;
3290
3617
  }>;
3291
3618
  function __promisify__(
3292
3619
  type: "x448",
3293
3620
  options: X448KeyPairOptions<"der", "der">,
3621
+ ): Promise<{
3622
+ publicKey: NonSharedBuffer;
3623
+ privateKey: NonSharedBuffer;
3624
+ }>;
3625
+ function __promisify__(type: "x448", options?: X448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
3626
+ function __promisify__(
3627
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3628
+ options: MLDSAKeyPairOptions<"pem", "pem">,
3629
+ ): Promise<{
3630
+ publicKey: string;
3631
+ privateKey: string;
3632
+ }>;
3633
+ function __promisify__(
3634
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3635
+ options: MLDSAKeyPairOptions<"pem", "der">,
3636
+ ): Promise<{
3637
+ publicKey: string;
3638
+ privateKey: NonSharedBuffer;
3639
+ }>;
3640
+ function __promisify__(
3641
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3642
+ options: MLDSAKeyPairOptions<"der", "pem">,
3643
+ ): Promise<{
3644
+ publicKey: NonSharedBuffer;
3645
+ privateKey: string;
3646
+ }>;
3647
+ function __promisify__(
3648
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3649
+ options: MLDSAKeyPairOptions<"der", "der">,
3650
+ ): Promise<{
3651
+ publicKey: NonSharedBuffer;
3652
+ privateKey: NonSharedBuffer;
3653
+ }>;
3654
+ function __promisify__(
3655
+ type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87",
3656
+ options?: MLDSAKeyPairKeyObjectOptions,
3657
+ ): Promise<KeyPairKeyObjectResult>;
3658
+ function __promisify__(
3659
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3660
+ options: MLKEMKeyPairOptions<"pem", "pem">,
3661
+ ): Promise<{
3662
+ publicKey: string;
3663
+ privateKey: string;
3664
+ }>;
3665
+ function __promisify__(
3666
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3667
+ options: MLKEMKeyPairOptions<"pem", "der">,
3668
+ ): Promise<{
3669
+ publicKey: string;
3670
+ privateKey: NonSharedBuffer;
3671
+ }>;
3672
+ function __promisify__(
3673
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3674
+ options: MLKEMKeyPairOptions<"der", "pem">,
3675
+ ): Promise<{
3676
+ publicKey: NonSharedBuffer;
3677
+ privateKey: string;
3678
+ }>;
3679
+ function __promisify__(
3680
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3681
+ options: MLKEMKeyPairOptions<"der", "der">,
3682
+ ): Promise<{
3683
+ publicKey: NonSharedBuffer;
3684
+ privateKey: NonSharedBuffer;
3685
+ }>;
3686
+ function __promisify__(
3687
+ type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768",
3688
+ options?: MLKEMKeyPairKeyObjectOptions,
3689
+ ): Promise<KeyPairKeyObjectResult>;
3690
+ function __promisify__(
3691
+ type:
3692
+ | "slh-dsa-sha2-128f"
3693
+ | "slh-dsa-sha2-128s"
3694
+ | "slh-dsa-sha2-192f"
3695
+ | "slh-dsa-sha2-192s"
3696
+ | "slh-dsa-sha2-256f"
3697
+ | "slh-dsa-sha2-256s"
3698
+ | "slh-dsa-shake-128f"
3699
+ | "slh-dsa-shake-128s"
3700
+ | "slh-dsa-shake-192f"
3701
+ | "slh-dsa-shake-192s"
3702
+ | "slh-dsa-shake-256f"
3703
+ | "slh-dsa-shake-256s",
3704
+ options: SLHDSAKeyPairOptions<"pem", "pem">,
3705
+ ): Promise<{
3706
+ publicKey: string;
3707
+ privateKey: string;
3708
+ }>;
3709
+ function __promisify__(
3710
+ type:
3711
+ | "slh-dsa-sha2-128f"
3712
+ | "slh-dsa-sha2-128s"
3713
+ | "slh-dsa-sha2-192f"
3714
+ | "slh-dsa-sha2-192s"
3715
+ | "slh-dsa-sha2-256f"
3716
+ | "slh-dsa-sha2-256s"
3717
+ | "slh-dsa-shake-128f"
3718
+ | "slh-dsa-shake-128s"
3719
+ | "slh-dsa-shake-192f"
3720
+ | "slh-dsa-shake-192s"
3721
+ | "slh-dsa-shake-256f"
3722
+ | "slh-dsa-shake-256s",
3723
+ options: SLHDSAKeyPairOptions<"pem", "der">,
3724
+ ): Promise<{
3725
+ publicKey: string;
3726
+ privateKey: Buffer;
3727
+ }>;
3728
+ function __promisify__(
3729
+ type:
3730
+ | "slh-dsa-sha2-128f"
3731
+ | "slh-dsa-sha2-128s"
3732
+ | "slh-dsa-sha2-192f"
3733
+ | "slh-dsa-sha2-192s"
3734
+ | "slh-dsa-sha2-256f"
3735
+ | "slh-dsa-sha2-256s"
3736
+ | "slh-dsa-shake-128f"
3737
+ | "slh-dsa-shake-128s"
3738
+ | "slh-dsa-shake-192f"
3739
+ | "slh-dsa-shake-192s"
3740
+ | "slh-dsa-shake-256f"
3741
+ | "slh-dsa-shake-256s",
3742
+ options: SLHDSAKeyPairOptions<"der", "pem">,
3743
+ ): Promise<{
3744
+ publicKey: Buffer;
3745
+ privateKey: string;
3746
+ }>;
3747
+ function __promisify__(
3748
+ type:
3749
+ | "slh-dsa-sha2-128f"
3750
+ | "slh-dsa-sha2-128s"
3751
+ | "slh-dsa-sha2-192f"
3752
+ | "slh-dsa-sha2-192s"
3753
+ | "slh-dsa-sha2-256f"
3754
+ | "slh-dsa-sha2-256s"
3755
+ | "slh-dsa-shake-128f"
3756
+ | "slh-dsa-shake-128s"
3757
+ | "slh-dsa-shake-192f"
3758
+ | "slh-dsa-shake-192s"
3759
+ | "slh-dsa-shake-256f"
3760
+ | "slh-dsa-shake-256s",
3761
+ options: SLHDSAKeyPairOptions<"der", "der">,
3294
3762
  ): Promise<{
3295
3763
  publicKey: Buffer;
3296
3764
  privateKey: Buffer;
3297
3765
  }>;
3298
- function __promisify__(type: "x448", options?: X448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
3766
+ function __promisify__(
3767
+ type:
3768
+ | "slh-dsa-sha2-128f"
3769
+ | "slh-dsa-sha2-128s"
3770
+ | "slh-dsa-sha2-192f"
3771
+ | "slh-dsa-sha2-192s"
3772
+ | "slh-dsa-sha2-256f"
3773
+ | "slh-dsa-sha2-256s"
3774
+ | "slh-dsa-shake-128f"
3775
+ | "slh-dsa-shake-128s"
3776
+ | "slh-dsa-shake-192f"
3777
+ | "slh-dsa-shake-192s"
3778
+ | "slh-dsa-shake-256f"
3779
+ | "slh-dsa-shake-256s",
3780
+ options?: SLHDSAKeyPairKeyObjectOptions,
3781
+ ): Promise<KeyPairKeyObjectResult>;
3299
3782
  }
3300
3783
  /**
3301
3784
  * Calculates and returns the signature for `data` using the given private key and
3302
3785
  * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
3303
- * dependent upon the key type (especially Ed25519 and Ed448).
3786
+ * dependent upon the key type.
3787
+ *
3788
+ * `algorithm` is required to be `null` or `undefined` for Ed25519, Ed448, and
3789
+ * ML-DSA.
3304
3790
  *
3305
3791
  * If `key` is not a `KeyObject`, this function behaves as if `key` had been
3306
3792
  * passed to {@link createPrivateKey}. If it is an object, the following
@@ -3312,17 +3798,21 @@ declare module "crypto" {
3312
3798
  function sign(
3313
3799
  algorithm: string | null | undefined,
3314
3800
  data: NodeJS.ArrayBufferView,
3315
- key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
3316
- ): Buffer;
3801
+ key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
3802
+ ): NonSharedBuffer;
3317
3803
  function sign(
3318
3804
  algorithm: string | null | undefined,
3319
3805
  data: NodeJS.ArrayBufferView,
3320
- key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
3321
- callback: (error: Error | null, data: Buffer) => void,
3806
+ key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
3807
+ callback: (error: Error | null, data: NonSharedBuffer) => void,
3322
3808
  ): void;
3323
3809
  /**
3324
- * Verifies the given signature for `data` using the given key and algorithm. If`algorithm` is `null` or `undefined`, then the algorithm is dependent upon the
3325
- * key type (especially Ed25519 and Ed448).
3810
+ * Verifies the given signature for `data` using the given key and algorithm. If
3811
+ * `algorithm` is `null` or `undefined`, then the algorithm is dependent upon the
3812
+ * key type.
3813
+ *
3814
+ * `algorithm` is required to be `null` or `undefined` for Ed25519, Ed448, and
3815
+ * ML-DSA.
3326
3816
  *
3327
3817
  * If `key` is not a `KeyObject`, this function behaves as if `key` had been
3328
3818
  * passed to {@link createPublicKey}. If it is an object, the following
@@ -3350,11 +3840,141 @@ declare module "crypto" {
3350
3840
  callback: (error: Error | null, result: boolean) => void,
3351
3841
  ): void;
3352
3842
  /**
3353
- * Computes the Diffie-Hellman secret based on a `privateKey` and a `publicKey`.
3354
- * Both keys must have the same `asymmetricKeyType`, which must be one of `'dh'`(for Diffie-Hellman), `'ec'` (for ECDH), `'x448'`, or `'x25519'` (for ECDH-ES).
3843
+ * Key decapsulation using a KEM algorithm with a private key.
3844
+ *
3845
+ * Supported key types and their KEM algorithms are:
3846
+ *
3847
+ * * `'rsa'` RSA Secret Value Encapsulation
3848
+ * * `'ec'` DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)
3849
+ * * `'x25519'` DHKEM(X25519, HKDF-SHA256)
3850
+ * * `'x448'` DHKEM(X448, HKDF-SHA512)
3851
+ * * `'ml-kem-512'` ML-KEM
3852
+ * * `'ml-kem-768'` ML-KEM
3853
+ * * `'ml-kem-1024'` ML-KEM
3854
+ *
3855
+ * If `key` is not a {@link KeyObject}, this function behaves as if `key` had been
3856
+ * passed to `crypto.createPrivateKey()`.
3857
+ *
3858
+ * If the `callback` function is provided this function uses libuv's threadpool.
3859
+ * @since v24.7.0
3860
+ */
3861
+ function decapsulate(
3862
+ key: KeyLike | PrivateKeyInput | JsonWebKeyInput,
3863
+ ciphertext: ArrayBuffer | NodeJS.ArrayBufferView,
3864
+ ): NonSharedBuffer;
3865
+ function decapsulate(
3866
+ key: KeyLike | PrivateKeyInput | JsonWebKeyInput,
3867
+ ciphertext: ArrayBuffer | NodeJS.ArrayBufferView,
3868
+ callback: (err: Error, sharedKey: NonSharedBuffer) => void,
3869
+ ): void;
3870
+ /**
3871
+ * Computes the Diffie-Hellman shared secret based on a `privateKey` and a `publicKey`.
3872
+ * Both keys must have the same `asymmetricKeyType` and must support either the DH or
3873
+ * ECDH operation.
3874
+ *
3875
+ * If the `callback` function is provided this function uses libuv's threadpool.
3355
3876
  * @since v13.9.0, v12.17.0
3356
3877
  */
3357
- function diffieHellman(options: { privateKey: KeyObject; publicKey: KeyObject }): Buffer;
3878
+ function diffieHellman(options: { privateKey: KeyObject; publicKey: KeyObject }): NonSharedBuffer;
3879
+ function diffieHellman(
3880
+ options: { privateKey: KeyObject; publicKey: KeyObject },
3881
+ callback: (err: Error | null, secret: NonSharedBuffer) => void,
3882
+ ): void;
3883
+ /**
3884
+ * Key encapsulation using a KEM algorithm with a public key.
3885
+ *
3886
+ * Supported key types and their KEM algorithms are:
3887
+ *
3888
+ * * `'rsa'` RSA Secret Value Encapsulation
3889
+ * * `'ec'` DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)
3890
+ * * `'x25519'` DHKEM(X25519, HKDF-SHA256)
3891
+ * * `'x448'` DHKEM(X448, HKDF-SHA512)
3892
+ * * `'ml-kem-512'` ML-KEM
3893
+ * * `'ml-kem-768'` ML-KEM
3894
+ * * `'ml-kem-1024'` ML-KEM
3895
+ *
3896
+ * If `key` is not a {@link KeyObject}, this function behaves as if `key` had been
3897
+ * passed to `crypto.createPublicKey()`.
3898
+ *
3899
+ * If the `callback` function is provided this function uses libuv's threadpool.
3900
+ * @since v24.7.0
3901
+ */
3902
+ function encapsulate(
3903
+ key: KeyLike | PublicKeyInput | JsonWebKeyInput,
3904
+ ): { sharedKey: NonSharedBuffer; ciphertext: NonSharedBuffer };
3905
+ function encapsulate(
3906
+ key: KeyLike | PublicKeyInput | JsonWebKeyInput,
3907
+ callback: (err: Error, result: { sharedKey: NonSharedBuffer; ciphertext: NonSharedBuffer }) => void,
3908
+ ): void;
3909
+ interface OneShotDigestOptions {
3910
+ /**
3911
+ * Encoding used to encode the returned digest.
3912
+ * @default 'hex'
3913
+ */
3914
+ outputEncoding?: BinaryToTextEncoding | "buffer" | undefined;
3915
+ /**
3916
+ * For XOF hash functions such as 'shake256', the outputLength option
3917
+ * can be used to specify the desired output length in bytes.
3918
+ */
3919
+ outputLength?: number | undefined;
3920
+ }
3921
+ interface OneShotDigestOptionsWithStringEncoding extends OneShotDigestOptions {
3922
+ outputEncoding?: BinaryToTextEncoding | undefined;
3923
+ }
3924
+ interface OneShotDigestOptionsWithBufferEncoding extends OneShotDigestOptions {
3925
+ outputEncoding: "buffer";
3926
+ }
3927
+ /**
3928
+ * A utility for creating one-shot hash digests of data. It can be faster than
3929
+ * the object-based `crypto.createHash()` when hashing a smaller amount of data
3930
+ * (<= 5MB) that's readily available. If the data can be big or if it is streamed,
3931
+ * it's still recommended to use `crypto.createHash()` instead.
3932
+ *
3933
+ * The `algorithm` is dependent on the available algorithms supported by the
3934
+ * version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
3935
+ * On recent releases of OpenSSL, `openssl list -digest-algorithms` will
3936
+ * display the available digest algorithms.
3937
+ *
3938
+ * If `options` is a string, then it specifies the `outputEncoding`.
3939
+ *
3940
+ * Example:
3941
+ *
3942
+ * ```js
3943
+ * import crypto from 'node:crypto';
3944
+ * import { Buffer } from 'node:buffer';
3945
+ *
3946
+ * // Hashing a string and return the result as a hex-encoded string.
3947
+ * const string = 'Node.js';
3948
+ * // 10b3493287f831e81a438811a1ffba01f8cec4b7
3949
+ * console.log(crypto.hash('sha1', string));
3950
+ *
3951
+ * // Encode a base64-encoded string into a Buffer, hash it and return
3952
+ * // the result as a buffer.
3953
+ * const base64 = 'Tm9kZS5qcw==';
3954
+ * // <Buffer 10 b3 49 32 87 f8 31 e8 1a 43 88 11 a1 ff ba 01 f8 ce c4 b7>
3955
+ * console.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));
3956
+ * ```
3957
+ * @since v21.7.0, v20.12.0
3958
+ * @param data When `data` is a string, it will be encoded as UTF-8 before being hashed. If a different
3959
+ * input encoding is desired for a string input, user could encode the string
3960
+ * into a `TypedArray` using either `TextEncoder` or `Buffer.from()` and passing
3961
+ * the encoded `TypedArray` into this API instead.
3962
+ */
3963
+ function hash(
3964
+ algorithm: string,
3965
+ data: BinaryLike,
3966
+ options?: OneShotDigestOptionsWithStringEncoding | BinaryToTextEncoding,
3967
+ ): string;
3968
+ function hash(
3969
+ algorithm: string,
3970
+ data: BinaryLike,
3971
+ options: OneShotDigestOptionsWithBufferEncoding | "buffer",
3972
+ ): NonSharedBuffer;
3973
+ function hash(
3974
+ algorithm: string,
3975
+ data: BinaryLike,
3976
+ options: OneShotDigestOptions | BinaryToTextEncoding | "buffer",
3977
+ ): string | NonSharedBuffer;
3358
3978
  type CipherMode = "cbc" | "ccm" | "cfb" | "ctr" | "ecb" | "gcm" | "ocb" | "ofb" | "stream" | "wrap" | "xts";
3359
3979
  interface CipherInfoOptions {
3360
3980
  /**
@@ -3407,9 +4027,9 @@ declare module "crypto" {
3407
4027
  */
3408
4028
  function getCipherInfo(nameOrNid: string | number, options?: CipherInfoOptions): CipherInfo | undefined;
3409
4029
  /**
3410
- * HKDF is a simple key derivation function defined in RFC 5869\. The given `ikm`,`salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
4030
+ * HKDF is a simple key derivation function defined in RFC 5869\. The given `ikm`, `salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
3411
4031
  *
3412
- * The supplied `callback` function is called with two arguments: `err` and`derivedKey`. If an errors occurs while deriving the key, `err` will be set;
4032
+ * The supplied `callback` function is called with two arguments: `err` and `derivedKey`. If an errors occurs while deriving the key, `err` will be set;
3413
4033
  * otherwise `err` will be `null`. The successfully generated `derivedKey` will
3414
4034
  * be passed to the callback as an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). An error will be thrown if any
3415
4035
  * of the input arguments specify invalid values or types.
@@ -3443,7 +4063,7 @@ declare module "crypto" {
3443
4063
  ): void;
3444
4064
  /**
3445
4065
  * Provides a synchronous HKDF key derivation function as defined in RFC 5869\. The
3446
- * given `ikm`, `salt` and `info` are used with the `digest` to derive a key of`keylen` bytes.
4066
+ * given `ikm`, `salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
3447
4067
  *
3448
4068
  * The successfully generated `derivedKey` will be returned as an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer).
3449
4069
  *
@@ -3518,23 +4138,23 @@ declare module "crypto" {
3518
4138
  /**
3519
4139
  * @default 'always'
3520
4140
  */
3521
- subject?: "always" | "default" | "never";
4141
+ subject?: "always" | "default" | "never" | undefined;
3522
4142
  /**
3523
4143
  * @default true
3524
4144
  */
3525
- wildcards?: boolean;
4145
+ wildcards?: boolean | undefined;
3526
4146
  /**
3527
4147
  * @default true
3528
4148
  */
3529
- partialWildcards?: boolean;
4149
+ partialWildcards?: boolean | undefined;
3530
4150
  /**
3531
4151
  * @default false
3532
4152
  */
3533
- multiLabelWildcards?: boolean;
4153
+ multiLabelWildcards?: boolean | undefined;
3534
4154
  /**
3535
4155
  * @default false
3536
4156
  */
3537
- singleLabelSubdomains?: boolean;
4157
+ singleLabelSubdomains?: boolean | undefined;
3538
4158
  }
3539
4159
  /**
3540
4160
  * Encapsulates an X509 certificate and provides read-only access to
@@ -3636,7 +4256,7 @@ declare module "crypto" {
3636
4256
  * available.
3637
4257
  * @since v15.9.0
3638
4258
  */
3639
- readonly issuerCertificate?: X509Certificate | undefined;
4259
+ readonly issuerCertificate: X509Certificate | undefined;
3640
4260
  /**
3641
4261
  * The public key `KeyObject` for this certificate.
3642
4262
  * @since v15.6.0
@@ -3646,7 +4266,7 @@ declare module "crypto" {
3646
4266
  * A `Buffer` containing the DER encoding of this certificate.
3647
4267
  * @since v15.6.0
3648
4268
  */
3649
- readonly raw: Buffer;
4269
+ readonly raw: NonSharedBuffer;
3650
4270
  /**
3651
4271
  * The serial number of this certificate.
3652
4272
  *
@@ -3656,16 +4276,36 @@ declare module "crypto" {
3656
4276
  * @since v15.6.0
3657
4277
  */
3658
4278
  readonly serialNumber: string;
4279
+ /**
4280
+ * The algorithm used to sign the certificate or `undefined` if the signature algorithm is unknown by OpenSSL.
4281
+ * @since v24.9.0
4282
+ */
4283
+ readonly signatureAlgorithm: string | undefined;
4284
+ /**
4285
+ * The OID of the algorithm used to sign the certificate.
4286
+ * @since v24.9.0
4287
+ */
4288
+ readonly signatureAlgorithmOid: string;
3659
4289
  /**
3660
4290
  * The date/time from which this certificate is considered valid.
3661
4291
  * @since v15.6.0
3662
4292
  */
3663
4293
  readonly validFrom: string;
4294
+ /**
4295
+ * The date/time from which this certificate is valid, encapsulated in a `Date` object.
4296
+ * @since v22.10.0
4297
+ */
4298
+ readonly validFromDate: Date;
3664
4299
  /**
3665
4300
  * The date/time until which this certificate is considered valid.
3666
4301
  * @since v15.6.0
3667
4302
  */
3668
4303
  readonly validTo: string;
4304
+ /**
4305
+ * The date/time until which this certificate is valid, encapsulated in a `Date` object.
4306
+ * @since v22.10.0
4307
+ */
4308
+ readonly validToDate: Date;
3669
4309
  constructor(buffer: BinaryLike);
3670
4310
  /**
3671
4311
  * Checks whether the certificate matches the given email address.
@@ -3718,7 +4358,23 @@ declare module "crypto" {
3718
4358
  */
3719
4359
  checkIP(ip: string): string | undefined;
3720
4360
  /**
3721
- * Checks whether this certificate was issued by the given `otherCert`.
4361
+ * Checks whether this certificate was potentially issued by the given `otherCert`
4362
+ * by comparing the certificate metadata.
4363
+ *
4364
+ * This is useful for pruning a list of possible issuer certificates which have been
4365
+ * selected using a more rudimentary filtering routine, i.e. just based on subject
4366
+ * and issuer names.
4367
+ *
4368
+ * Finally, to verify that this certificate's signature was produced by a private key
4369
+ * corresponding to `otherCert`'s public key use `x509.verify(publicKey)`
4370
+ * with `otherCert`'s public key represented as a `KeyObject`
4371
+ * like so
4372
+ *
4373
+ * ```js
4374
+ * if (!x509.verify(otherCert.publicKey)) {
4375
+ * throw new Error('otherCert did not issue x509');
4376
+ * }
4377
+ * ```
3722
4378
  * @since v15.6.0
3723
4379
  */
3724
4380
  checkIssued(otherCert: X509Certificate): boolean;
@@ -3772,7 +4428,7 @@ declare module "crypto" {
3772
4428
  /**
3773
4429
  * Generates a pseudorandom prime of `size` bits.
3774
4430
  *
3775
- * If `options.safe` is `true`, the prime will be a safe prime -- that is,`(prime - 1) / 2` will also be a prime.
4431
+ * If `options.safe` is `true`, the prime will be a safe prime -- that is, `(prime - 1) / 2` will also be a prime.
3776
4432
  *
3777
4433
  * The `options.add` and `options.rem` parameters can be used to enforce additional
3778
4434
  * requirements, e.g., for Diffie-Hellman:
@@ -3788,7 +4444,7 @@ declare module "crypto" {
3788
4444
  * * `options.rem` is ignored if `options.add` is not given.
3789
4445
  *
3790
4446
  * Both `options.add` and `options.rem` must be encoded as big-endian sequences
3791
- * if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or`DataView`.
4447
+ * if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or `DataView`.
3792
4448
  *
3793
4449
  * By default, the prime is encoded as a big-endian sequence of octets
3794
4450
  * in an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). If the `bigint` option is `true`, then a
@@ -3815,7 +4471,7 @@ declare module "crypto" {
3815
4471
  /**
3816
4472
  * Generates a pseudorandom prime of `size` bits.
3817
4473
  *
3818
- * If `options.safe` is `true`, the prime will be a safe prime -- that is,`(prime - 1) / 2` will also be a prime.
4474
+ * If `options.safe` is `true`, the prime will be a safe prime -- that is, `(prime - 1) / 2` will also be a prime.
3819
4475
  *
3820
4476
  * The `options.add` and `options.rem` parameters can be used to enforce additional
3821
4477
  * requirements, e.g., for Diffie-Hellman:
@@ -3831,7 +4487,7 @@ declare module "crypto" {
3831
4487
  * * `options.rem` is ignored if `options.add` is not given.
3832
4488
  *
3833
4489
  * Both `options.add` and `options.rem` must be encoded as big-endian sequences
3834
- * if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or`DataView`.
4490
+ * if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or `DataView`.
3835
4491
  *
3836
4492
  * By default, the prime is encoded as a big-endian sequence of octets
3837
4493
  * in an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). If the `bigint` option is `true`, then a
@@ -3877,7 +4533,7 @@ declare module "crypto" {
3877
4533
  *
3878
4534
  * `engine` could be either an id or a path to the engine's shared library.
3879
4535
  *
3880
- * The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`is a bit field taking one of or a mix of the following flags (defined in`crypto.constants`):
4536
+ * The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags` is a bit field taking one of or a mix of the following flags (defined in `crypto.constants`):
3881
4537
  *
3882
4538
  * * `crypto.constants.ENGINE_METHOD_RSA`
3883
4539
  * * `crypto.constants.ENGINE_METHOD_DSA`
@@ -3902,6 +4558,130 @@ declare module "crypto" {
3902
4558
  * @return Returns `typedArray`.
3903
4559
  */
3904
4560
  function getRandomValues<T extends webcrypto.BufferSource>(typedArray: T): T;
4561
+ type Argon2Algorithm = "argon2d" | "argon2i" | "argon2id";
4562
+ interface Argon2Parameters {
4563
+ /**
4564
+ * REQUIRED, this is the password for password hashing applications of Argon2.
4565
+ */
4566
+ message: string | ArrayBuffer | NodeJS.ArrayBufferView;
4567
+ /**
4568
+ * REQUIRED, must be at least 8 bytes long. This is the salt for password hashing applications of Argon2.
4569
+ */
4570
+ nonce: string | ArrayBuffer | NodeJS.ArrayBufferView;
4571
+ /**
4572
+ * REQUIRED, degree of parallelism determines how many computational chains (lanes)
4573
+ * can be run. Must be greater than 1 and less than `2**24-1`.
4574
+ */
4575
+ parallelism: number;
4576
+ /**
4577
+ * REQUIRED, the length of the key to generate. Must be greater than 4 and
4578
+ * less than `2**32-1`.
4579
+ */
4580
+ tagLength: number;
4581
+ /**
4582
+ * REQUIRED, memory cost in 1KiB blocks. Must be greater than
4583
+ * `8 * parallelism` and less than `2**32-1`. The actual number of blocks is rounded
4584
+ * down to the nearest multiple of `4 * parallelism`.
4585
+ */
4586
+ memory: number;
4587
+ /**
4588
+ * REQUIRED, number of passes (iterations). Must be greater than 1 and less
4589
+ * than `2**32-1`.
4590
+ */
4591
+ passes: number;
4592
+ /**
4593
+ * OPTIONAL, Random additional input,
4594
+ * similar to the salt, that should **NOT** be stored with the derived key. This is known as pepper in
4595
+ * password hashing applications. If used, must have a length not greater than `2**32-1` bytes.
4596
+ */
4597
+ secret?: string | ArrayBuffer | NodeJS.ArrayBufferView | undefined;
4598
+ /**
4599
+ * OPTIONAL, Additional data to
4600
+ * be added to the hash, functionally equivalent to salt or secret, but meant for
4601
+ * non-random data. If used, must have a length not greater than `2**32-1` bytes.
4602
+ */
4603
+ associatedData?: string | ArrayBuffer | NodeJS.ArrayBufferView | undefined;
4604
+ }
4605
+ /**
4606
+ * Provides an asynchronous [Argon2](https://www.rfc-editor.org/rfc/rfc9106.html) implementation. Argon2 is a password-based
4607
+ * key derivation function that is designed to be expensive computationally and
4608
+ * memory-wise in order to make brute-force attacks unrewarding.
4609
+ *
4610
+ * The `nonce` should be as unique as possible. It is recommended that a nonce is
4611
+ * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
4612
+ *
4613
+ * When passing strings for `message`, `nonce`, `secret` or `associatedData`, please
4614
+ * consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v24.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
4615
+ *
4616
+ * The `callback` function is called with two arguments: `err` and `derivedKey`.
4617
+ * `err` is an exception object when key derivation fails, otherwise `err` is
4618
+ * `null`. `derivedKey` is passed to the callback as a `Buffer`.
4619
+ *
4620
+ * An exception is thrown when any of the input arguments specify invalid values
4621
+ * or types.
4622
+ *
4623
+ * ```js
4624
+ * const { argon2, randomBytes } = await import('node:crypto');
4625
+ *
4626
+ * const parameters = {
4627
+ * message: 'password',
4628
+ * nonce: randomBytes(16),
4629
+ * parallelism: 4,
4630
+ * tagLength: 64,
4631
+ * memory: 65536,
4632
+ * passes: 3,
4633
+ * };
4634
+ *
4635
+ * argon2('argon2id', parameters, (err, derivedKey) => {
4636
+ * if (err) throw err;
4637
+ * console.log(derivedKey.toString('hex')); // 'af91dad...9520f15'
4638
+ * });
4639
+ * ```
4640
+ * @since v24.7.0
4641
+ * @param algorithm Variant of Argon2, one of `"argon2d"`, `"argon2i"` or `"argon2id"`.
4642
+ * @experimental
4643
+ */
4644
+ function argon2(
4645
+ algorithm: Argon2Algorithm,
4646
+ parameters: Argon2Parameters,
4647
+ callback: (err: Error | null, derivedKey: NonSharedBuffer) => void,
4648
+ ): void;
4649
+ /**
4650
+ * Provides a synchronous [Argon2][] implementation. Argon2 is a password-based
4651
+ * key derivation function that is designed to be expensive computationally and
4652
+ * memory-wise in order to make brute-force attacks unrewarding.
4653
+ *
4654
+ * The `nonce` should be as unique as possible. It is recommended that a nonce is
4655
+ * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
4656
+ *
4657
+ * When passing strings for `message`, `nonce`, `secret` or `associatedData`, please
4658
+ * consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v24.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
4659
+ *
4660
+ * An exception is thrown when key derivation fails, otherwise the derived key is
4661
+ * returned as a `Buffer`.
4662
+ *
4663
+ * An exception is thrown when any of the input arguments specify invalid values
4664
+ * or types.
4665
+ *
4666
+ * ```js
4667
+ * const { argon2Sync, randomBytes } = await import('node:crypto');
4668
+ *
4669
+ * const parameters = {
4670
+ * message: 'password',
4671
+ * nonce: randomBytes(16),
4672
+ * parallelism: 4,
4673
+ * tagLength: 64,
4674
+ * memory: 65536,
4675
+ * passes: 3,
4676
+ * };
4677
+ *
4678
+ * const derivedKey = argon2Sync('argon2id', parameters);
4679
+ * console.log(derivedKey.toString('hex')); // 'af91dad...9520f15'
4680
+ * ```
4681
+ * @since v24.7.0
4682
+ * @experimental
4683
+ */
4684
+ function argon2Sync(algorithm: Argon2Algorithm, parameters: Argon2Parameters): NonSharedBuffer;
3905
4685
  /**
3906
4686
  * A convenient alias for `crypto.webcrypto.subtle`.
3907
4687
  * @since v17.4.0
@@ -3916,21 +4696,30 @@ declare module "crypto" {
3916
4696
  const webcrypto: webcrypto.Crypto;
3917
4697
  namespace webcrypto {
3918
4698
  type BufferSource = ArrayBufferView | ArrayBuffer;
3919
- type KeyFormat = "jwk" | "pkcs8" | "raw" | "spki";
4699
+ type KeyFormat = "jwk" | "pkcs8" | "raw" | "raw-public" | "raw-secret" | "raw-seed" | "spki";
3920
4700
  type KeyType = "private" | "public" | "secret";
3921
4701
  type KeyUsage =
3922
- | "decrypt"
3923
- | "deriveBits"
3924
- | "deriveKey"
3925
4702
  | "encrypt"
4703
+ | "decrypt"
3926
4704
  | "sign"
3927
- | "unwrapKey"
3928
4705
  | "verify"
3929
- | "wrapKey";
4706
+ | "deriveKey"
4707
+ | "deriveBits"
4708
+ | "encapsulateBits"
4709
+ | "decapsulateBits"
4710
+ | "encapsulateKey"
4711
+ | "decapsulateKey"
4712
+ | "wrapKey"
4713
+ | "unwrapKey";
3930
4714
  type AlgorithmIdentifier = Algorithm | string;
3931
4715
  type HashAlgorithmIdentifier = AlgorithmIdentifier;
3932
4716
  type NamedCurve = string;
3933
4717
  type BigInteger = Uint8Array;
4718
+ interface AeadParams extends Algorithm {
4719
+ additionalData?: BufferSource;
4720
+ iv: BufferSource;
4721
+ tagLength: number;
4722
+ }
3934
4723
  interface AesCbcParams extends Algorithm {
3935
4724
  iv: BufferSource;
3936
4725
  }
@@ -3941,6 +4730,8 @@ declare module "crypto" {
3941
4730
  interface AesDerivedKeyParams extends Algorithm {
3942
4731
  length: number;
3943
4732
  }
4733
+ // TODO: remove in next major
4734
+ /** @deprecated Replaced by `AeadParams`. */
3944
4735
  interface AesGcmParams extends Algorithm {
3945
4736
  additionalData?: BufferSource;
3946
4737
  iv: BufferSource;
@@ -3955,6 +4746,23 @@ declare module "crypto" {
3955
4746
  interface Algorithm {
3956
4747
  name: string;
3957
4748
  }
4749
+ interface Argon2Params extends Algorithm {
4750
+ associatedData?: BufferSource;
4751
+ memory: number;
4752
+ nonce: BufferSource;
4753
+ parallelism: number;
4754
+ passes: number;
4755
+ secretValue?: BufferSource;
4756
+ version?: number;
4757
+ }
4758
+ interface CShakeParams extends Algorithm {
4759
+ customization?: BufferSource;
4760
+ functionName?: BufferSource;
4761
+ length: number;
4762
+ }
4763
+ interface ContextParams extends Algorithm {
4764
+ context?: BufferSource;
4765
+ }
3958
4766
  interface EcKeyAlgorithm extends KeyAlgorithm {
3959
4767
  namedCurve: NamedCurve;
3960
4768
  }
@@ -3970,9 +4778,6 @@ declare module "crypto" {
3970
4778
  interface EcdsaParams extends Algorithm {
3971
4779
  hash: HashAlgorithmIdentifier;
3972
4780
  }
3973
- interface Ed448Params extends Algorithm {
3974
- context?: BufferSource;
3975
- }
3976
4781
  interface HkdfParams extends Algorithm {
3977
4782
  hash: HashAlgorithmIdentifier;
3978
4783
  info: BufferSource;
@@ -4013,6 +4818,19 @@ declare module "crypto" {
4013
4818
  interface KeyAlgorithm {
4014
4819
  name: string;
4015
4820
  }
4821
+ interface KmacImportParams extends Algorithm {
4822
+ length?: number;
4823
+ }
4824
+ interface KmacKeyAlgorithm extends KeyAlgorithm {
4825
+ length: number;
4826
+ }
4827
+ interface KmacKeyGenParams extends Algorithm {
4828
+ length?: number;
4829
+ }
4830
+ interface KmacParams extends Algorithm {
4831
+ customization?: BufferSource;
4832
+ length: number;
4833
+ }
4016
4834
  interface Pbkdf2Params extends Algorithm {
4017
4835
  hash: HashAlgorithmIdentifier;
4018
4836
  iterations: number;
@@ -4047,7 +4865,7 @@ declare module "crypto" {
4047
4865
  saltLength: number;
4048
4866
  }
4049
4867
  /**
4050
- * Calling `require('node:crypto').webcrypto` returns an instance of the `Crypto` class.
4868
+ * Importing the `webcrypto` object (`import { webcrypto } from 'node:crypto'`) gives an instance of the `Crypto` class.
4051
4869
  * `Crypto` is a singleton that provides access to the remainder of the crypto API.
4052
4870
  * @since v15.0.0
4053
4871
  */
@@ -4066,22 +4884,15 @@ declare module "crypto" {
4066
4884
  * An error will be thrown if the given `typedArray` is larger than 65,536 bytes.
4067
4885
  * @since v15.0.0
4068
4886
  */
4069
- getRandomValues<T extends Exclude<NodeJS.TypedArray, Float32Array | Float64Array>>(typedArray: T): T;
4887
+ getRandomValues<T extends Exclude<NodeJS.TypedArray, Float16Array | Float32Array | Float64Array>>(
4888
+ typedArray: T,
4889
+ ): T;
4070
4890
  /**
4071
4891
  * Generates a random {@link https://www.rfc-editor.org/rfc/rfc4122.txt RFC 4122} version 4 UUID.
4072
4892
  * The UUID is generated using a cryptographic pseudorandom number generator.
4073
4893
  * @since v16.7.0
4074
4894
  */
4075
4895
  randomUUID(): UUID;
4076
- CryptoKey: CryptoKeyConstructor;
4077
- }
4078
- // This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable.
4079
- interface CryptoKeyConstructor {
4080
- /** Illegal constructor */
4081
- (_: { readonly _: unique symbol }): never; // Allows instanceof to work but not be callable by the user.
4082
- readonly length: 0;
4083
- readonly name: "CryptoKey";
4084
- readonly prototype: CryptoKey;
4085
4896
  }
4086
4897
  /**
4087
4898
  * @since v15.0.0
@@ -4136,31 +4947,81 @@ declare module "crypto" {
4136
4947
  */
4137
4948
  publicKey: CryptoKey;
4138
4949
  }
4950
+ interface EncapsulatedBits {
4951
+ sharedKey: ArrayBuffer;
4952
+ ciphertext: ArrayBuffer;
4953
+ }
4954
+ interface EncapsulatedKey {
4955
+ sharedKey: CryptoKey;
4956
+ ciphertext: ArrayBuffer;
4957
+ }
4139
4958
  /**
4140
4959
  * @since v15.0.0
4141
4960
  */
4142
4961
  interface SubtleCrypto {
4962
+ /**
4963
+ * A message recipient uses their asymmetric private key to decrypt an
4964
+ * "encapsulated key" (ciphertext), thereby recovering a temporary symmetric
4965
+ * key (represented as `ArrayBuffer`) which is then used to decrypt a message.
4966
+ *
4967
+ * The algorithms currently supported include:
4968
+ *
4969
+ * * `'ML-KEM-512'`
4970
+ * * `'ML-KEM-768'`
4971
+ * * `'ML-KEM-1024'`
4972
+ * @since v24.7.0
4973
+ * @returns Fulfills with `ArrayBuffer` upon success.
4974
+ */
4975
+ decapsulateBits(
4976
+ decapsulationAlgorithm: AlgorithmIdentifier,
4977
+ decapsulationKey: CryptoKey,
4978
+ ciphertext: BufferSource,
4979
+ ): Promise<ArrayBuffer>;
4980
+ /**
4981
+ * A message recipient uses their asymmetric private key to decrypt an
4982
+ * "encapsulated key" (ciphertext), thereby recovering a temporary symmetric
4983
+ * key (represented as `CryptoKey`) which is then used to decrypt a message.
4984
+ *
4985
+ * The algorithms currently supported include:
4986
+ *
4987
+ * * `'ML-KEM-512'`
4988
+ * * `'ML-KEM-768'`
4989
+ * * `'ML-KEM-1024'`
4990
+ * @since v24.7.0
4991
+ * @param usages See [Key usages](https://nodejs.org/docs/latest-v24.x/api/webcrypto.html#cryptokeyusages).
4992
+ * @returns Fulfills with `CryptoKey` upon success.
4993
+ */
4994
+ decapsulateKey(
4995
+ decapsulationAlgorithm: AlgorithmIdentifier,
4996
+ decapsulationKey: CryptoKey,
4997
+ ciphertext: BufferSource,
4998
+ sharedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | AesDerivedKeyParams | KmacImportParams,
4999
+ extractable: boolean,
5000
+ usages: KeyUsage[],
5001
+ ): Promise<CryptoKey>;
4143
5002
  /**
4144
5003
  * Using the method and parameters specified in `algorithm` and the keying material provided by `key`,
4145
- * `subtle.decrypt()` attempts to decipher the provided `data`. If successful,
5004
+ * this method attempts to decipher the provided `data`. If successful,
4146
5005
  * the returned promise will be resolved with an `<ArrayBuffer>` containing the plaintext result.
4147
5006
  *
4148
5007
  * The algorithms currently supported include:
4149
5008
  *
4150
- * - `'RSA-OAEP'`
4151
- * - `'AES-CTR'`
4152
- * - `'AES-CBC'`
4153
- * - `'AES-GCM'`
5009
+ * * `'AES-CBC'`
5010
+ * * `'AES-CTR'`
5011
+ * * `'AES-GCM'`
5012
+ * * `'AES-OCB'`
5013
+ * * `'ChaCha20-Poly1305'`
5014
+ * * `'RSA-OAEP'`
4154
5015
  * @since v15.0.0
4155
5016
  */
4156
5017
  decrypt(
4157
- algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
5018
+ algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
4158
5019
  key: CryptoKey,
4159
5020
  data: BufferSource,
4160
5021
  ): Promise<ArrayBuffer>;
4161
5022
  /**
4162
5023
  * Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`,
4163
- * `subtle.deriveBits()` attempts to generate `length` bits.
5024
+ * this method attempts to generate `length` bits.
4164
5025
  * The Node.js implementation requires that when `length` is a number it must be multiple of `8`.
4165
5026
  * When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed
4166
5027
  * for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms.
@@ -4168,45 +5029,50 @@ declare module "crypto" {
4168
5029
  *
4169
5030
  * The algorithms currently supported include:
4170
5031
  *
4171
- * - `'ECDH'`
4172
- * - `'X25519'`
4173
- * - `'X448'`
4174
- * - `'HKDF'`
4175
- * - `'PBKDF2'`
5032
+ * * `'Argon2d'`
5033
+ * * `'Argon2i'`
5034
+ * * `'Argon2id'`
5035
+ * * `'ECDH'`
5036
+ * * `'HKDF'`
5037
+ * * `'PBKDF2'`
5038
+ * * `'X25519'`
5039
+ * * `'X448'`
4176
5040
  * @since v15.0.0
4177
5041
  */
4178
- deriveBits(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, length: number | null): Promise<ArrayBuffer>;
4179
5042
  deriveBits(
4180
- algorithm: AlgorithmIdentifier | HkdfParams | Pbkdf2Params,
5043
+ algorithm: EcdhKeyDeriveParams,
5044
+ baseKey: CryptoKey,
5045
+ length?: number | null,
5046
+ ): Promise<ArrayBuffer>;
5047
+ deriveBits(
5048
+ algorithm: EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params | Argon2Params,
4181
5049
  baseKey: CryptoKey,
4182
5050
  length: number,
4183
5051
  ): Promise<ArrayBuffer>;
4184
5052
  /**
4185
5053
  * Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`,
4186
- * `subtle.deriveKey()` attempts to generate a new <CryptoKey>` based on the method and parameters in `derivedKeyAlgorithm`.
5054
+ * this method attempts to generate a new <CryptoKey>` based on the method and parameters in `derivedKeyAlgorithm`.
4187
5055
  *
4188
5056
  * Calling `subtle.deriveKey()` is equivalent to calling `subtle.deriveBits()` to generate raw keying material,
4189
5057
  * then passing the result into the `subtle.importKey()` method using the `deriveKeyAlgorithm`, `extractable`, and `keyUsages` parameters as input.
4190
5058
  *
4191
5059
  * The algorithms currently supported include:
4192
5060
  *
4193
- * - `'ECDH'`
4194
- * - `'X25519'`
4195
- * - `'X448'`
4196
- * - `'HKDF'`
4197
- * - `'PBKDF2'`
5061
+ * * `'Argon2d'`
5062
+ * * `'Argon2i'`
5063
+ * * `'Argon2id'`
5064
+ * * `'ECDH'`
5065
+ * * `'HKDF'`
5066
+ * * `'PBKDF2'`
5067
+ * * `'X25519'`
5068
+ * * `'X448'`
4198
5069
  * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
4199
5070
  * @since v15.0.0
4200
5071
  */
4201
5072
  deriveKey(
4202
- algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
5073
+ algorithm: EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params | Argon2Params,
4203
5074
  baseKey: CryptoKey,
4204
- derivedKeyAlgorithm:
4205
- | AlgorithmIdentifier
4206
- | AesDerivedKeyParams
4207
- | HmacImportParams
4208
- | HkdfParams
4209
- | Pbkdf2Params,
5075
+ derivedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | AesDerivedKeyParams | KmacImportParams,
4210
5076
  extractable: boolean,
4211
5077
  keyUsages: readonly KeyUsage[],
4212
5078
  ): Promise<CryptoKey>;
@@ -4216,30 +5082,73 @@ declare module "crypto" {
4216
5082
  *
4217
5083
  * If `algorithm` is provided as a `<string>`, it must be one of:
4218
5084
  *
4219
- * - `'SHA-1'`
4220
- * - `'SHA-256'`
4221
- * - `'SHA-384'`
4222
- * - `'SHA-512'`
5085
+ * * `'cSHAKE128'`
5086
+ * * `'cSHAKE256'`
5087
+ * * `'SHA-1'`
5088
+ * * `'SHA-256'`
5089
+ * * `'SHA-384'`
5090
+ * * `'SHA-512'`
5091
+ * * `'SHA3-256'`
5092
+ * * `'SHA3-384'`
5093
+ * * `'SHA3-512'`
4223
5094
  *
4224
5095
  * If `algorithm` is provided as an `<Object>`, it must have a `name` property whose value is one of the above.
4225
5096
  * @since v15.0.0
4226
5097
  */
4227
- digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
5098
+ digest(algorithm: AlgorithmIdentifier | CShakeParams, data: BufferSource): Promise<ArrayBuffer>;
5099
+ /**
5100
+ * Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key.
5101
+ * This encrypted key is the "encapsulated key" represented as `EncapsulatedBits`.
5102
+ *
5103
+ * The algorithms currently supported include:
5104
+ *
5105
+ * * `'ML-KEM-512'`
5106
+ * * `'ML-KEM-768'`
5107
+ * * `'ML-KEM-1024'`
5108
+ * @since v24.7.0
5109
+ * @returns Fulfills with `EncapsulatedBits` upon success.
5110
+ */
5111
+ encapsulateBits(
5112
+ encapsulationAlgorithm: AlgorithmIdentifier,
5113
+ encapsulationKey: CryptoKey,
5114
+ ): Promise<EncapsulatedBits>;
5115
+ /**
5116
+ * Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key.
5117
+ * This encrypted key is the "encapsulated key" represented as `EncapsulatedKey`.
5118
+ *
5119
+ * The algorithms currently supported include:
5120
+ *
5121
+ * * `'ML-KEM-512'`
5122
+ * * `'ML-KEM-768'`
5123
+ * * `'ML-KEM-1024'`
5124
+ * @since v24.7.0
5125
+ * @param usages See [Key usages](https://nodejs.org/docs/latest-v24.x/api/webcrypto.html#cryptokeyusages).
5126
+ * @returns Fulfills with `EncapsulatedKey` upon success.
5127
+ */
5128
+ encapsulateKey(
5129
+ encapsulationAlgorithm: AlgorithmIdentifier,
5130
+ encapsulationKey: CryptoKey,
5131
+ sharedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | AesDerivedKeyParams | KmacImportParams,
5132
+ extractable: boolean,
5133
+ usages: KeyUsage[],
5134
+ ): Promise<EncapsulatedKey>;
4228
5135
  /**
4229
5136
  * Using the method and parameters specified by `algorithm` and the keying material provided by `key`,
4230
- * `subtle.encrypt()` attempts to encipher `data`. If successful,
5137
+ * this method attempts to encipher `data`. If successful,
4231
5138
  * the returned promise is resolved with an `<ArrayBuffer>` containing the encrypted result.
4232
5139
  *
4233
5140
  * The algorithms currently supported include:
4234
5141
  *
4235
- * - `'RSA-OAEP'`
4236
- * - `'AES-CTR'`
4237
- * - `'AES-CBC'`
4238
- * - `'AES-GCM'`
5142
+ * * `'AES-CBC'`
5143
+ * * `'AES-CTR'`
5144
+ * * `'AES-GCM'`
5145
+ * * `'AES-OCB'`
5146
+ * * `'ChaCha20-Poly1305'`
5147
+ * * `'RSA-OAEP'`
4239
5148
  * @since v15.0.0
4240
5149
  */
4241
5150
  encrypt(
4242
- algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
5151
+ algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
4243
5152
  key: CryptoKey,
4244
5153
  data: BufferSource,
4245
5154
  ): Promise<ArrayBuffer>;
@@ -4253,35 +5162,47 @@ declare module "crypto" {
4253
5162
  *
4254
5163
  * When `format` is `'jwk'` and the export is successful, the returned promise will be resolved with a
4255
5164
  * JavaScript object conforming to the {@link https://tools.ietf.org/html/rfc7517 JSON Web Key} specification.
4256
- * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
5165
+ * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`,
5166
+ * `'raw-public'`, or `'raw-seed'`.
4257
5167
  * @returns `<Promise>` containing `<ArrayBuffer>`.
4258
5168
  * @since v15.0.0
4259
5169
  */
4260
5170
  exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
4261
5171
  exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
4262
5172
  /**
4263
- * Using the method and parameters provided in `algorithm`,
4264
- * `subtle.generateKey()` attempts to generate new keying material.
4265
- * Depending the method used, the method may generate either a single `<CryptoKey>` or a `<CryptoKeyPair>`.
5173
+ * Using the parameters provided in `algorithm`, this method
5174
+ * attempts to generate new keying material. Depending on the algorithm used
5175
+ * either a single `CryptoKey` or a `CryptoKeyPair` is generated.
4266
5176
  *
4267
- * The `<CryptoKeyPair>` (public and private key) generating algorithms supported include:
5177
+ * The `CryptoKeyPair` (public and private key) generating algorithms supported
5178
+ * include:
4268
5179
  *
4269
- * - `'RSASSA-PKCS1-v1_5'`
4270
- * - `'RSA-PSS'`
4271
- * - `'RSA-OAEP'`
4272
- * - `'ECDSA'`
4273
- * - `'Ed25519'`
4274
- * - `'Ed448'`
4275
- * - `'ECDH'`
4276
- * - `'X25519'`
4277
- * - `'X448'`
4278
- * The `<CryptoKey>` (secret key) generating algorithms supported include:
5180
+ * * `'ECDH'`
5181
+ * * `'ECDSA'`
5182
+ * * `'Ed25519'`
5183
+ * * `'Ed448'`
5184
+ * * `'ML-DSA-44'`
5185
+ * * `'ML-DSA-65'`
5186
+ * * `'ML-DSA-87'`
5187
+ * * `'ML-KEM-512'`
5188
+ * * `'ML-KEM-768'`
5189
+ * * `'ML-KEM-1024'`
5190
+ * * `'RSA-OAEP'`
5191
+ * * `'RSA-PSS'`
5192
+ * * `'RSASSA-PKCS1-v1_5'`
5193
+ * * `'X25519'`
5194
+ * * `'X448'`
4279
5195
  *
4280
- * - `'HMAC'`
4281
- * - `'AES-CTR'`
4282
- * - `'AES-CBC'`
4283
- * - `'AES-GCM'`
4284
- * - `'AES-KW'`
5196
+ * The `CryptoKey` (secret key) generating algorithms supported include:
5197
+ * * `'AES-CBC'`
5198
+ * * `'AES-CTR'`
5199
+ * * `'AES-GCM'`
5200
+ * * `'AES-KW'`
5201
+ * * `'AES-OCB'`
5202
+ * * `'ChaCha20-Poly1305'`
5203
+ * * `'HMAC'`
5204
+ * * `'KMAC128'`
5205
+ * * `'KMAC256'`
4285
5206
  * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
4286
5207
  * @since v15.0.0
4287
5208
  */
@@ -4291,7 +5212,7 @@ declare module "crypto" {
4291
5212
  keyUsages: readonly KeyUsage[],
4292
5213
  ): Promise<CryptoKeyPair>;
4293
5214
  generateKey(
4294
- algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params,
5215
+ algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params | KmacKeyGenParams,
4295
5216
  extractable: boolean,
4296
5217
  keyUsages: readonly KeyUsage[],
4297
5218
  ): Promise<CryptoKey>;
@@ -4301,12 +5222,23 @@ declare module "crypto" {
4301
5222
  keyUsages: KeyUsage[],
4302
5223
  ): Promise<CryptoKeyPair | CryptoKey>;
4303
5224
  /**
4304
- * The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format`
4305
- * to create a `<CryptoKey>` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments.
4306
- * If the import is successful, the returned promise will be resolved with the created `<CryptoKey>`.
5225
+ * Derives the public key from a given private key.
5226
+ * @since v24.7.0
5227
+ * @param key A private key from which to derive the corresponding public key.
5228
+ * @param keyUsages See [Key usages](https://nodejs.org/docs/latest-v24.x/api/webcrypto.html#cryptokeyusages).
5229
+ * @returns Fulfills with a `CryptoKey` upon success.
5230
+ */
5231
+ getPublicKey(key: CryptoKey, keyUsages: KeyUsage[]): Promise<CryptoKey>;
5232
+ /**
5233
+ * This method attempts to interpret the provided `keyData`
5234
+ * as the given `format` to create a `CryptoKey` instance using the provided
5235
+ * `algorithm`, `extractable`, and `keyUsages` arguments. If the import is
5236
+ * successful, the returned promise will be resolved with a {CryptoKey}
5237
+ * representation of the key material.
4307
5238
  *
4308
- * If importing a `'PBKDF2'` key, `extractable` must be `false`.
4309
- * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
5239
+ * If importing KDF algorithm keys, `extractable` must be `false`.
5240
+ * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`,
5241
+ * `'raw-public'`, or `'raw-seed'`.
4310
5242
  * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
4311
5243
  * @since v15.0.0
4312
5244
  */
@@ -4318,7 +5250,8 @@ declare module "crypto" {
4318
5250
  | RsaHashedImportParams
4319
5251
  | EcKeyImportParams
4320
5252
  | HmacImportParams
4321
- | AesKeyAlgorithm,
5253
+ | AesKeyAlgorithm
5254
+ | KmacImportParams,
4322
5255
  extractable: boolean,
4323
5256
  keyUsages: readonly KeyUsage[],
4324
5257
  ): Promise<CryptoKey>;
@@ -4330,62 +5263,81 @@ declare module "crypto" {
4330
5263
  | RsaHashedImportParams
4331
5264
  | EcKeyImportParams
4332
5265
  | HmacImportParams
4333
- | AesKeyAlgorithm,
5266
+ | AesKeyAlgorithm
5267
+ | KmacImportParams,
4334
5268
  extractable: boolean,
4335
5269
  keyUsages: KeyUsage[],
4336
5270
  ): Promise<CryptoKey>;
4337
5271
  /**
4338
5272
  * Using the method and parameters given by `algorithm` and the keying material provided by `key`,
4339
- * `subtle.sign()` attempts to generate a cryptographic signature of `data`. If successful,
5273
+ * this method attempts to generate a cryptographic signature of `data`. If successful,
4340
5274
  * the returned promise is resolved with an `<ArrayBuffer>` containing the generated signature.
4341
5275
  *
4342
5276
  * The algorithms currently supported include:
4343
5277
  *
4344
- * - `'RSASSA-PKCS1-v1_5'`
4345
- * - `'RSA-PSS'`
4346
- * - `'ECDSA'`
4347
- * - `'Ed25519'`
4348
- * - `'Ed448'`
4349
- * - `'HMAC'`
5278
+ * * `'ECDSA'`
5279
+ * * `'Ed25519'`
5280
+ * * `'Ed448'`
5281
+ * * `'HMAC'`
5282
+ * * `'KMAC128'`
5283
+ * * `'KMAC256'`
5284
+ * * `'ML-DSA-44'`
5285
+ * * `'ML-DSA-65'`
5286
+ * * `'ML-DSA-87'`
5287
+ * * `'RSA-PSS'`
5288
+ * * `'RSASSA-PKCS1-v1_5'`
4350
5289
  * @since v15.0.0
4351
5290
  */
4352
5291
  sign(
4353
- algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params,
5292
+ algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | ContextParams | KmacParams,
4354
5293
  key: CryptoKey,
4355
5294
  data: BufferSource,
4356
5295
  ): Promise<ArrayBuffer>;
4357
5296
  /**
4358
5297
  * In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
4359
- * The `subtle.unwrapKey()` method attempts to decrypt a wrapped key and create a `<CryptoKey>` instance.
5298
+ * This method attempts to decrypt a wrapped key and create a `<CryptoKey>` instance.
4360
5299
  * It is equivalent to calling `subtle.decrypt()` first on the encrypted key data (using the `wrappedKey`, `unwrapAlgo`, and `unwrappingKey` arguments as input)
4361
5300
  * then passing the results in to the `subtle.importKey()` method using the `unwrappedKeyAlgo`, `extractable`, and `keyUsages` arguments as inputs.
4362
5301
  * If successful, the returned promise is resolved with a `<CryptoKey>` object.
4363
5302
  *
4364
5303
  * The wrapping algorithms currently supported include:
4365
5304
  *
4366
- * - `'RSA-OAEP'`
4367
- * - `'AES-CTR'`
4368
- * - `'AES-CBC'`
4369
- * - `'AES-GCM'`
4370
- * - `'AES-KW'`
5305
+ * * `'AES-CBC'`
5306
+ * * `'AES-CTR'`
5307
+ * * `'AES-GCM'`
5308
+ * * `'AES-KW'`
5309
+ * * `'AES-OCB'`
5310
+ * * `'ChaCha20-Poly1305'`
5311
+ * * `'RSA-OAEP'`
4371
5312
  *
4372
5313
  * The unwrapped key algorithms supported include:
4373
5314
  *
4374
- * - `'RSASSA-PKCS1-v1_5'`
4375
- * - `'RSA-PSS'`
4376
- * - `'RSA-OAEP'`
4377
- * - `'ECDSA'`
4378
- * - `'Ed25519'`
4379
- * - `'Ed448'`
4380
- * - `'ECDH'`
4381
- * - `'X25519'`
4382
- * - `'X448'`
4383
- * - `'HMAC'`
4384
- * - `'AES-CTR'`
4385
- * - `'AES-CBC'`
4386
- * - `'AES-GCM'`
4387
- * - `'AES-KW'`
4388
- * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
5315
+ * * `'AES-CBC'`
5316
+ * * `'AES-CTR'`
5317
+ * * `'AES-GCM'`
5318
+ * * `'AES-KW'`
5319
+ * * `'AES-OCB'`
5320
+ * * `'ChaCha20-Poly1305'`
5321
+ * * `'ECDH'`
5322
+ * * `'ECDSA'`
5323
+ * * `'Ed25519'`
5324
+ * * `'Ed448'`
5325
+ * * `'HMAC'`
5326
+ * * `'KMAC128'`
5327
+ * * `'KMAC256'`
5328
+ * * `'ML-DSA-44'`
5329
+ * * `'ML-DSA-65'`
5330
+ * * `'ML-DSA-87'`
5331
+ * * `'ML-KEM-512'`
5332
+ * * `'ML-KEM-768'`
5333
+ * * `'ML-KEM-1024'`
5334
+ * * `'RSA-OAEP'`
5335
+ * * `'RSA-PSS'`
5336
+ * * `'RSASSA-PKCS1-v1_5'`
5337
+ * * `'X25519'`
5338
+ * * `'X448'`
5339
+ * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`,
5340
+ * `'raw-public'`, or `'raw-seed'`.
4389
5341
  * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
4390
5342
  * @since v15.0.0
4391
5343
  */
@@ -4393,40 +5345,46 @@ declare module "crypto" {
4393
5345
  format: KeyFormat,
4394
5346
  wrappedKey: BufferSource,
4395
5347
  unwrappingKey: CryptoKey,
4396
- unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
5348
+ unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
4397
5349
  unwrappedKeyAlgorithm:
4398
5350
  | AlgorithmIdentifier
4399
5351
  | RsaHashedImportParams
4400
5352
  | EcKeyImportParams
4401
5353
  | HmacImportParams
4402
- | AesKeyAlgorithm,
5354
+ | AesKeyAlgorithm
5355
+ | KmacImportParams,
4403
5356
  extractable: boolean,
4404
5357
  keyUsages: KeyUsage[],
4405
5358
  ): Promise<CryptoKey>;
4406
5359
  /**
4407
5360
  * Using the method and parameters given in `algorithm` and the keying material provided by `key`,
4408
- * `subtle.verify()` attempts to verify that `signature` is a valid cryptographic signature of `data`.
5361
+ * This method attempts to verify that `signature` is a valid cryptographic signature of `data`.
4409
5362
  * The returned promise is resolved with either `true` or `false`.
4410
5363
  *
4411
5364
  * The algorithms currently supported include:
4412
5365
  *
4413
- * - `'RSASSA-PKCS1-v1_5'`
4414
- * - `'RSA-PSS'`
4415
- * - `'ECDSA'`
4416
- * - `'Ed25519'`
4417
- * - `'Ed448'`
4418
- * - `'HMAC'`
5366
+ * * `'ECDSA'`
5367
+ * * `'Ed25519'`
5368
+ * * `'Ed448'`
5369
+ * * `'HMAC'`
5370
+ * * `'KMAC128'`
5371
+ * * `'KMAC256'`
5372
+ * * `'ML-DSA-44'`
5373
+ * * `'ML-DSA-65'`
5374
+ * * `'ML-DSA-87'`
5375
+ * * `'RSA-PSS'`
5376
+ * * `'RSASSA-PKCS1-v1_5'`
4419
5377
  * @since v15.0.0
4420
5378
  */
4421
5379
  verify(
4422
- algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params,
5380
+ algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | ContextParams | KmacParams,
4423
5381
  key: CryptoKey,
4424
5382
  signature: BufferSource,
4425
5383
  data: BufferSource,
4426
5384
  ): Promise<boolean>;
4427
5385
  /**
4428
5386
  * In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
4429
- * The `subtle.wrapKey()` method exports the keying material into the format identified by `format`,
5387
+ * This method exports the keying material into the format identified by `format`,
4430
5388
  * then encrypts it using the method and parameters specified by `wrapAlgo` and the keying material provided by `wrappingKey`.
4431
5389
  * It is the equivalent to calling `subtle.exportKey()` using `format` and `key` as the arguments,
4432
5390
  * then passing the result to the `subtle.encrypt()` method using `wrappingKey` and `wrapAlgo` as inputs.
@@ -4434,19 +5392,22 @@ declare module "crypto" {
4434
5392
  *
4435
5393
  * The wrapping algorithms currently supported include:
4436
5394
  *
4437
- * - `'RSA-OAEP'`
4438
- * - `'AES-CTR'`
4439
- * - `'AES-CBC'`
4440
- * - `'AES-GCM'`
4441
- * - `'AES-KW'`
4442
- * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
5395
+ * * `'AES-CBC'`
5396
+ * * `'AES-CTR'`
5397
+ * * `'AES-GCM'`
5398
+ * * `'AES-KW'`
5399
+ * * `'AES-OCB'`
5400
+ * * `'ChaCha20-Poly1305'`
5401
+ * * `'RSA-OAEP'`
5402
+ * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`,
5403
+ * `'raw-public'`, or `'raw-seed'`.
4443
5404
  * @since v15.0.0
4444
5405
  */
4445
5406
  wrapKey(
4446
5407
  format: KeyFormat,
4447
5408
  key: CryptoKey,
4448
5409
  wrappingKey: CryptoKey,
4449
- wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
5410
+ wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
4450
5411
  ): Promise<ArrayBuffer>;
4451
5412
  }
4452
5413
  }