aws-delivlib 15.4.0 → 15.4.2
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.
- package/lib/custom-resource-handlers/src/certificate-signing-request.tsbuildinfo +1 -1
- package/lib/custom-resource-handlers/src/pgp-secret.tsbuildinfo +1 -1
- package/lib/custom-resource-handlers/src/private-key.tsbuildinfo +1 -1
- package/lib/package-integrity/handler/validate.bundle.js +11361 -9248
- package/lib/publishing/github/node_modules/.yarn-integrity +5 -5
- package/lib/publishing/github/node_modules/@types/aws-lambda/README.md +1 -1
- package/lib/publishing/github/node_modules/@types/aws-lambda/package.json +2 -2
- package/lib/publishing/github/node_modules/@types/aws-lambda/trigger/api-gateway-proxy.d.ts +2 -2
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/README.md +3 -3
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/assert/strict.d.ts +13 -56
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/assert.d.ts +189 -190
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/async_hooks.d.ts +151 -43
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/buffer.buffer.d.ts +12 -13
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/buffer.d.ts +103 -237
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/child_process.d.ts +40 -155
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/cluster.d.ts +238 -384
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/console.d.ts +45 -404
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/constants.d.ts +3 -10
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/crypto.d.ts +1019 -1600
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/dgram.d.ts +133 -81
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/diagnostics_channel.d.ts +277 -59
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/dns/promises.d.ts +9 -15
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/dns.d.ts +136 -183
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/domain.d.ts +12 -32
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/events.d.ts +872 -840
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/ffi.d.ts +500 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/fs/promises.d.ts +256 -85
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/fs.d.ts +865 -525
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/globals.d.ts +12 -34
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/globals.typedarray.d.ts +63 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/http.d.ts +433 -312
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/http2.d.ts +548 -893
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/https.d.ts +64 -243
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/index.d.ts +25 -7
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/inspector/promises.d.ts +35 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/inspector.d.ts +70 -58
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/inspector.generated.d.ts +764 -410
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/module.d.ts +54 -219
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/net.d.ts +224 -226
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/os.d.ts +41 -49
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/package.json +13 -18
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/path/posix.d.ts +8 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/path/win32.d.ts +8 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/path.d.ts +119 -141
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/perf_hooks.d.ts +339 -690
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/process.d.ts +390 -205
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/punycode.d.ts +3 -31
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/querystring.d.ts +3 -16
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/quic.d.ts +2191 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/readline/promises.d.ts +3 -6
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/readline.d.ts +66 -152
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/repl.d.ts +101 -109
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/sea.d.ts +1 -116
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/sqlite.d.ts +486 -68
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/stream/consumers.d.ts +91 -15
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/stream/iter.d.ts +449 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/stream/promises.d.ts +136 -15
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/stream/web.d.ts +197 -454
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/stream.d.ts +603 -491
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/string_decoder.d.ts +3 -43
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/test/reporters.d.ts +60 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/test.d.ts +585 -292
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/timers/promises.d.ts +3 -18
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/timers.d.ts +3 -141
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/tls.d.ts +180 -267
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/trace_events.d.ts +3 -97
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +7 -8
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +2 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/ts5.6/index.d.ts +26 -6
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/ts5.7/index.d.ts +118 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/tty.d.ts +61 -43
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/url.d.ts +156 -584
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/util/types.d.ts +558 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/util.d.ts +173 -1099
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/v8.d.ts +175 -36
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/vfs.d.ts +211 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/vm.d.ts +293 -209
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/wasi.d.ts +24 -74
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/abortcontroller.d.ts +27 -2
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/blob.d.ts +23 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/console.d.ts +9 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/domexception.d.ts +15 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/events.d.ts +9 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/fetch.d.ts +14 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/navigator.d.ts +3 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/performance.d.ts +45 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/streams.d.ts +97 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/timers.d.ts +44 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/web-globals/url.d.ts +24 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/worker_threads.d.ts +260 -407
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/zlib/iter.d.ts +131 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/zlib.d.ts +782 -165
- package/lib/publishing/github/node_modules/semver/classes/range.js +2 -2
- package/lib/publishing/github/node_modules/semver/internal/constants.js +30 -0
- package/lib/publishing/github/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
- package/lib/publishing/github/node_modules/semver/package.json +1 -1
- package/lib/publishing/github/node_modules/undici-types/agent.d.ts +12 -13
- package/lib/publishing/github/node_modules/undici-types/api.d.ts +26 -26
- package/lib/publishing/github/node_modules/undici-types/balanced-pool.d.ts +13 -12
- package/lib/publishing/github/node_modules/undici-types/cache-interceptor.d.ts +179 -0
- package/lib/publishing/github/node_modules/undici-types/client-stats.d.ts +15 -0
- package/lib/publishing/github/node_modules/undici-types/client.d.ts +63 -37
- package/lib/publishing/github/node_modules/undici-types/connector.d.ts +5 -2
- package/lib/publishing/github/node_modules/undici-types/cookies.d.ts +3 -1
- package/lib/publishing/github/node_modules/undici-types/diagnostics-channel.d.ts +18 -10
- package/lib/publishing/github/node_modules/undici-types/dispatcher.d.ts +136 -139
- package/lib/publishing/github/node_modules/undici-types/dispatcher1-wrapper.d.ts +7 -0
- package/lib/publishing/github/node_modules/undici-types/env-http-proxy-agent.d.ts +4 -3
- package/lib/publishing/github/node_modules/undici-types/errors.d.ts +92 -54
- package/lib/publishing/github/node_modules/undici-types/eventsource.d.ts +9 -4
- package/lib/publishing/github/node_modules/undici-types/fetch.d.ts +51 -25
- package/lib/publishing/github/node_modules/undici-types/formdata.d.ts +7 -7
- package/lib/publishing/github/node_modules/undici-types/global-dispatcher.d.ts +4 -4
- package/lib/publishing/github/node_modules/undici-types/global-origin.d.ts +5 -5
- package/lib/publishing/github/node_modules/undici-types/h2c-client.d.ts +73 -0
- package/lib/publishing/github/node_modules/undici-types/handlers.d.ts +10 -9
- package/lib/publishing/github/node_modules/undici-types/header.d.ts +162 -1
- package/lib/publishing/github/node_modules/undici-types/index.d.ts +69 -47
- package/lib/publishing/github/node_modules/undici-types/interceptors.d.ts +72 -9
- package/lib/publishing/github/node_modules/undici-types/mock-agent.d.ts +36 -18
- package/lib/publishing/github/node_modules/undici-types/mock-call-history.d.ts +111 -0
- package/lib/publishing/github/node_modules/undici-types/mock-client.d.ts +6 -4
- package/lib/publishing/github/node_modules/undici-types/mock-errors.d.ts +3 -3
- package/lib/publishing/github/node_modules/undici-types/mock-interceptor.d.ts +26 -21
- package/lib/publishing/github/node_modules/undici-types/mock-pool.d.ts +6 -4
- package/lib/publishing/github/node_modules/undici-types/package.json +1 -1
- package/lib/publishing/github/node_modules/undici-types/patch.d.ts +0 -4
- package/lib/publishing/github/node_modules/undici-types/pool-stats.d.ts +8 -8
- package/lib/publishing/github/node_modules/undici-types/pool.d.ts +14 -14
- package/lib/publishing/github/node_modules/undici-types/proxy-agent.d.ts +14 -6
- package/lib/publishing/github/node_modules/undici-types/readable.d.ts +19 -16
- package/lib/publishing/github/node_modules/undici-types/retry-agent.d.ts +1 -1
- package/lib/publishing/github/node_modules/undici-types/retry-handler.d.ts +19 -10
- package/lib/publishing/github/node_modules/undici-types/round-robin-pool.d.ts +39 -0
- package/lib/publishing/github/node_modules/undici-types/snapshot-agent.d.ts +113 -0
- package/lib/publishing/github/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
- package/lib/publishing/github/node_modules/undici-types/util.d.ts +3 -3
- package/lib/publishing/github/node_modules/undici-types/utility.d.ts +7 -0
- package/lib/publishing/github/node_modules/undici-types/webidl.d.ts +148 -30
- package/lib/publishing/github/node_modules/undici-types/websocket.d.ts +48 -10
- package/lib/shellable.d.ts +7 -3
- package/lib/shellable.js +44 -30
- package/package.json +11 -11
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/compatibility/disposable.d.ts +0 -14
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/compatibility/index.d.ts +0 -9
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/compatibility/iterators.d.ts +0 -20
- package/lib/publishing/github/node_modules/undici-types/file.d.ts +0 -39
- package/lib/publishing/github/node_modules/undici-types/filereader.d.ts +0 -54
package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/crypto.d.ts
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
* The `node:crypto` module provides cryptographic functionality that includes a
|
|
3
|
-
* set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify
|
|
4
|
-
* functions.
|
|
5
|
-
*
|
|
6
|
-
* ```js
|
|
7
|
-
* const { createHmac } = await import('node:crypto');
|
|
8
|
-
*
|
|
9
|
-
* const secret = 'abcdefg';
|
|
10
|
-
* const hash = createHmac('sha256', secret)
|
|
11
|
-
* .update('I love cupcakes')
|
|
12
|
-
* .digest('hex');
|
|
13
|
-
* console.log(hash);
|
|
14
|
-
* // Prints:
|
|
15
|
-
* // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
|
|
16
|
-
* ```
|
|
17
|
-
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/crypto.js)
|
|
18
|
-
*/
|
|
19
|
-
declare module "crypto" {
|
|
1
|
+
declare module "node:crypto" {
|
|
20
2
|
import { NonSharedBuffer } from "node:buffer";
|
|
21
|
-
import
|
|
3
|
+
import { Transform, TransformOptions, Writable, WritableOptions } from "node:stream";
|
|
22
4
|
import { PeerCertificate } from "node:tls";
|
|
23
5
|
/**
|
|
24
6
|
* SPKAC is a Certificate Signing Request mechanism originally implemented by
|
|
@@ -45,7 +27,7 @@ declare module "crypto" {
|
|
|
45
27
|
* @param encoding The `encoding` of the `spkac` string.
|
|
46
28
|
* @return The challenge component of the `spkac` data structure, which includes a public key and a challenge.
|
|
47
29
|
*/
|
|
48
|
-
static exportChallenge(spkac: BinaryLike): NonSharedBuffer;
|
|
30
|
+
static exportChallenge(spkac: BinaryLike, encoding?: BufferEncoding): NonSharedBuffer;
|
|
49
31
|
/**
|
|
50
32
|
* ```js
|
|
51
33
|
* const { Certificate } = await import('node:crypto');
|
|
@@ -58,7 +40,7 @@ declare module "crypto" {
|
|
|
58
40
|
* @param encoding The `encoding` of the `spkac` string.
|
|
59
41
|
* @return The public key component of the `spkac` data structure, which includes a public key and a challenge.
|
|
60
42
|
*/
|
|
61
|
-
static exportPublicKey(spkac: BinaryLike, encoding?:
|
|
43
|
+
static exportPublicKey(spkac: BinaryLike, encoding?: BufferEncoding): NonSharedBuffer;
|
|
62
44
|
/**
|
|
63
45
|
* ```js
|
|
64
46
|
* import { Buffer } from 'node:buffer';
|
|
@@ -72,128 +54,42 @@ declare module "crypto" {
|
|
|
72
54
|
* @param encoding The `encoding` of the `spkac` string.
|
|
73
55
|
* @return `true` if the given `spkac` data structure is valid, `false` otherwise.
|
|
74
56
|
*/
|
|
75
|
-
static verifySpkac(spkac:
|
|
57
|
+
static verifySpkac(spkac: BinaryLike, encoding?: BufferEncoding): boolean;
|
|
76
58
|
/**
|
|
77
59
|
* @deprecated
|
|
78
|
-
* @param spkac
|
|
60
|
+
* @param encoding The `encoding` of the `spkac` string.
|
|
79
61
|
* @returns The challenge component of the `spkac` data structure,
|
|
80
62
|
* which includes a public key and a challenge.
|
|
81
63
|
*/
|
|
82
|
-
exportChallenge(spkac: BinaryLike): NonSharedBuffer;
|
|
64
|
+
exportChallenge(spkac: BinaryLike, encoding?: BufferEncoding): NonSharedBuffer;
|
|
83
65
|
/**
|
|
84
66
|
* @deprecated
|
|
85
|
-
* @param spkac
|
|
86
67
|
* @param encoding The encoding of the spkac string.
|
|
87
68
|
* @returns The public key component of the `spkac` data structure,
|
|
88
69
|
* which includes a public key and a challenge.
|
|
89
70
|
*/
|
|
90
|
-
exportPublicKey(spkac: BinaryLike, encoding?:
|
|
71
|
+
exportPublicKey(spkac: BinaryLike, encoding?: BufferEncoding): NonSharedBuffer;
|
|
91
72
|
/**
|
|
92
73
|
* @deprecated
|
|
93
|
-
* @param spkac
|
|
74
|
+
* @param encoding The `encoding` of the `spkac` string.
|
|
94
75
|
* @returns `true` if the given `spkac` data structure is valid,
|
|
95
76
|
* `false` otherwise.
|
|
96
77
|
*/
|
|
97
|
-
verifySpkac(spkac:
|
|
98
|
-
}
|
|
99
|
-
namespace constants {
|
|
100
|
-
// https://nodejs.org/dist/latest-v22.x/docs/api/crypto.html#crypto-constants
|
|
101
|
-
const OPENSSL_VERSION_NUMBER: number;
|
|
102
|
-
/** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */
|
|
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;
|
|
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. */
|
|
107
|
-
const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
|
|
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. */
|
|
109
|
-
const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
|
|
110
|
-
/** Instructs OpenSSL to use Cisco's version identifier of DTLS_BAD_VER. */
|
|
111
|
-
const SSL_OP_CISCO_ANYCONNECT: number;
|
|
112
|
-
/** Instructs OpenSSL to turn on cookie exchange. */
|
|
113
|
-
const SSL_OP_COOKIE_EXCHANGE: number;
|
|
114
|
-
/** Instructs OpenSSL to add server-hello extension from an early version of the cryptopro draft. */
|
|
115
|
-
const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
|
|
116
|
-
/** Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround added in OpenSSL 0.9.6d. */
|
|
117
|
-
const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
|
|
118
|
-
/** Allows initial connection to servers that do not support RI. */
|
|
119
|
-
const SSL_OP_LEGACY_SERVER_CONNECT: number;
|
|
120
|
-
/** Instructs OpenSSL to disable support for SSL/TLS compression. */
|
|
121
|
-
const SSL_OP_NO_COMPRESSION: number;
|
|
122
|
-
/** Instructs OpenSSL to disable encrypt-then-MAC. */
|
|
123
|
-
const SSL_OP_NO_ENCRYPT_THEN_MAC: number;
|
|
124
|
-
const SSL_OP_NO_QUERY_MTU: number;
|
|
125
|
-
/** Instructs OpenSSL to disable renegotiation. */
|
|
126
|
-
const SSL_OP_NO_RENEGOTIATION: number;
|
|
127
|
-
/** Instructs OpenSSL to always start a new session when performing renegotiation. */
|
|
128
|
-
const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
|
|
129
|
-
/** Instructs OpenSSL to turn off SSL v2 */
|
|
130
|
-
const SSL_OP_NO_SSLv2: number;
|
|
131
|
-
/** Instructs OpenSSL to turn off SSL v3 */
|
|
132
|
-
const SSL_OP_NO_SSLv3: number;
|
|
133
|
-
/** Instructs OpenSSL to disable use of RFC4507bis tickets. */
|
|
134
|
-
const SSL_OP_NO_TICKET: number;
|
|
135
|
-
/** Instructs OpenSSL to turn off TLS v1 */
|
|
136
|
-
const SSL_OP_NO_TLSv1: number;
|
|
137
|
-
/** Instructs OpenSSL to turn off TLS v1.1 */
|
|
138
|
-
const SSL_OP_NO_TLSv1_1: number;
|
|
139
|
-
/** Instructs OpenSSL to turn off TLS v1.2 */
|
|
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;
|
|
145
|
-
/** Instructs OpenSSL to disable version rollback attack detection. */
|
|
146
|
-
const SSL_OP_TLS_ROLLBACK_BUG: number;
|
|
147
|
-
const ENGINE_METHOD_RSA: number;
|
|
148
|
-
const ENGINE_METHOD_DSA: number;
|
|
149
|
-
const ENGINE_METHOD_DH: number;
|
|
150
|
-
const ENGINE_METHOD_RAND: number;
|
|
151
|
-
const ENGINE_METHOD_EC: number;
|
|
152
|
-
const ENGINE_METHOD_CIPHERS: number;
|
|
153
|
-
const ENGINE_METHOD_DIGESTS: number;
|
|
154
|
-
const ENGINE_METHOD_PKEY_METHS: number;
|
|
155
|
-
const ENGINE_METHOD_PKEY_ASN1_METHS: number;
|
|
156
|
-
const ENGINE_METHOD_ALL: number;
|
|
157
|
-
const ENGINE_METHOD_NONE: number;
|
|
158
|
-
const DH_CHECK_P_NOT_SAFE_PRIME: number;
|
|
159
|
-
const DH_CHECK_P_NOT_PRIME: number;
|
|
160
|
-
const DH_UNABLE_TO_CHECK_GENERATOR: number;
|
|
161
|
-
const DH_NOT_SUITABLE_GENERATOR: number;
|
|
162
|
-
const RSA_PKCS1_PADDING: number;
|
|
163
|
-
const RSA_SSLV23_PADDING: number;
|
|
164
|
-
const RSA_NO_PADDING: number;
|
|
165
|
-
const RSA_PKCS1_OAEP_PADDING: number;
|
|
166
|
-
const RSA_X931_PADDING: number;
|
|
167
|
-
const RSA_PKCS1_PSS_PADDING: number;
|
|
168
|
-
/** Sets the salt length for RSA_PKCS1_PSS_PADDING to the digest size when signing or verifying. */
|
|
169
|
-
const RSA_PSS_SALTLEN_DIGEST: number;
|
|
170
|
-
/** Sets the salt length for RSA_PKCS1_PSS_PADDING to the maximum permissible value when signing data. */
|
|
171
|
-
const RSA_PSS_SALTLEN_MAX_SIGN: number;
|
|
172
|
-
/** Causes the salt length for RSA_PKCS1_PSS_PADDING to be determined automatically when verifying a signature. */
|
|
173
|
-
const RSA_PSS_SALTLEN_AUTO: number;
|
|
174
|
-
const POINT_CONVERSION_COMPRESSED: number;
|
|
175
|
-
const POINT_CONVERSION_UNCOMPRESSED: number;
|
|
176
|
-
const POINT_CONVERSION_HYBRID: number;
|
|
177
|
-
/** Specifies the built-in default cipher list used by Node.js (colon-separated values). */
|
|
178
|
-
const defaultCoreCipherList: string;
|
|
179
|
-
/** Specifies the active default cipher list used by the current Node.js process (colon-separated values). */
|
|
180
|
-
const defaultCipherList: string;
|
|
78
|
+
verifySpkac(spkac: BinaryLike, encoding?: BufferEncoding): boolean;
|
|
181
79
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
* outputLength option can be used to specify the desired output length in bytes.
|
|
186
|
-
*/
|
|
80
|
+
/** @deprecated This property is deprecated. Please use `crypto.setFips()` and `crypto.getFips()` instead. */
|
|
81
|
+
var fips: boolean;
|
|
82
|
+
interface HashOptions extends TransformOptions {
|
|
187
83
|
outputLength?: number | undefined;
|
|
188
84
|
}
|
|
189
|
-
/** @deprecated since v10.0.0 */
|
|
190
|
-
const fips: boolean;
|
|
191
85
|
/**
|
|
192
86
|
* Creates and returns a `Hash` object that can be used to generate hash digests
|
|
193
87
|
* using the given `algorithm`. Optional `options` argument controls stream
|
|
194
88
|
* behavior. For XOF hash functions such as `'shake256'`, the `outputLength` option
|
|
195
89
|
* can be used to specify the desired output length in bytes.
|
|
196
90
|
*
|
|
91
|
+
* When the data is small (< 5MB) and readily available, `crypto.hash()` is usually faster.
|
|
92
|
+
*
|
|
197
93
|
* The `algorithm` is dependent on the available algorithms supported by the
|
|
198
94
|
* version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
|
|
199
95
|
* On recent releases of OpenSSL, `openssl list -digest-algorithms` will
|
|
@@ -230,6 +126,9 @@ declare module "crypto" {
|
|
|
230
126
|
* @param options `stream.transform` options
|
|
231
127
|
*/
|
|
232
128
|
function createHash(algorithm: string, options?: HashOptions): Hash;
|
|
129
|
+
interface HmacOptions extends TransformOptions {
|
|
130
|
+
encoding?: BufferEncoding | undefined;
|
|
131
|
+
}
|
|
233
132
|
/**
|
|
234
133
|
* Creates and returns an `Hmac` object that uses the given `algorithm` and `key`.
|
|
235
134
|
* Optional `options` argument controls stream behavior.
|
|
@@ -274,13 +173,7 @@ declare module "crypto" {
|
|
|
274
173
|
* @since v0.1.94
|
|
275
174
|
* @param options `stream.transform` options
|
|
276
175
|
*/
|
|
277
|
-
function createHmac(algorithm: string, key:
|
|
278
|
-
// https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
|
|
279
|
-
type BinaryToTextEncoding = "base64" | "base64url" | "hex" | "binary";
|
|
280
|
-
type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "utf-16le" | "latin1";
|
|
281
|
-
type LegacyCharacterEncoding = "ascii" | "binary" | "ucs2" | "ucs-2";
|
|
282
|
-
type Encoding = BinaryToTextEncoding | CharacterEncoding | LegacyCharacterEncoding;
|
|
283
|
-
type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
|
|
176
|
+
function createHmac(algorithm: string, key: KeyLike, options?: HmacOptions): Hmac;
|
|
284
177
|
/**
|
|
285
178
|
* The `Hash` class is a utility for creating hash digests of data. It can be
|
|
286
179
|
* used in one of two ways:
|
|
@@ -345,7 +238,7 @@ declare module "crypto" {
|
|
|
345
238
|
* ```
|
|
346
239
|
* @since v0.1.92
|
|
347
240
|
*/
|
|
348
|
-
class Hash extends
|
|
241
|
+
class Hash extends Transform {
|
|
349
242
|
private constructor();
|
|
350
243
|
/**
|
|
351
244
|
* Creates a new `Hash` object that contains a deep copy of the internal state
|
|
@@ -391,8 +284,7 @@ declare module "crypto" {
|
|
|
391
284
|
* @since v0.1.92
|
|
392
285
|
* @param inputEncoding The `encoding` of the `data` string.
|
|
393
286
|
*/
|
|
394
|
-
update(data:
|
|
395
|
-
update(data: string, inputEncoding: Encoding): Hash;
|
|
287
|
+
update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): Hash;
|
|
396
288
|
/**
|
|
397
289
|
* Calculates the digest of all of the data passed to be hashed (using the `hash.update()` method).
|
|
398
290
|
* If `encoding` is provided a string will be returned; otherwise
|
|
@@ -404,7 +296,7 @@ declare module "crypto" {
|
|
|
404
296
|
* @param encoding The `encoding` of the return value.
|
|
405
297
|
*/
|
|
406
298
|
digest(): NonSharedBuffer;
|
|
407
|
-
digest(encoding:
|
|
299
|
+
digest(encoding: BufferEncoding): string;
|
|
408
300
|
}
|
|
409
301
|
/**
|
|
410
302
|
* The `Hmac` class is a utility for creating cryptographic HMAC digests. It can
|
|
@@ -471,9 +363,8 @@ declare module "crypto" {
|
|
|
471
363
|
* // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
|
|
472
364
|
* ```
|
|
473
365
|
* @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.
|
|
475
366
|
*/
|
|
476
|
-
class Hmac extends
|
|
367
|
+
class Hmac extends Transform {
|
|
477
368
|
private constructor();
|
|
478
369
|
/**
|
|
479
370
|
* Updates the `Hmac` content with the given `data`, the encoding of which
|
|
@@ -485,8 +376,7 @@ declare module "crypto" {
|
|
|
485
376
|
* @since v0.1.94
|
|
486
377
|
* @param inputEncoding The `encoding` of the `data` string.
|
|
487
378
|
*/
|
|
488
|
-
update(data:
|
|
489
|
-
update(data: string, inputEncoding: Encoding): Hmac;
|
|
379
|
+
update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): Hmac;
|
|
490
380
|
/**
|
|
491
381
|
* Calculates the HMAC digest of all of the data passed using `hmac.update()`.
|
|
492
382
|
* If `encoding` is
|
|
@@ -498,62 +388,97 @@ declare module "crypto" {
|
|
|
498
388
|
* @param encoding The `encoding` of the return value.
|
|
499
389
|
*/
|
|
500
390
|
digest(): NonSharedBuffer;
|
|
501
|
-
digest(encoding:
|
|
391
|
+
digest(encoding: BufferEncoding): string;
|
|
502
392
|
}
|
|
393
|
+
type KeyFormat = "pem" | "der" | "jwk" | "raw-public" | "raw-private" | "raw-seed";
|
|
503
394
|
type KeyObjectType = "secret" | "public" | "private";
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
395
|
+
type PublicKeyExportType = "pkcs1" | "spki";
|
|
396
|
+
type PrivateKeyExportType = "pkcs1" | "pkcs8" | "sec1";
|
|
397
|
+
type KeyExportOptions =
|
|
398
|
+
| SymmetricKeyExportOptions
|
|
399
|
+
| PublicKeyExportOptions
|
|
400
|
+
| PrivateKeyExportOptions
|
|
401
|
+
| JwkKeyExportOptions
|
|
402
|
+
| RawPublicKeyExportOptions
|
|
403
|
+
| RawPrivateKeyExportOptions;
|
|
404
|
+
interface SymmetricKeyExportOptions {
|
|
405
|
+
format?: "buffer" | undefined;
|
|
406
|
+
}
|
|
407
|
+
interface PublicKeyExportOptions<T extends PublicKeyExportType = PublicKeyExportType> {
|
|
408
|
+
type: T;
|
|
409
|
+
format: "pem" | "der";
|
|
410
|
+
}
|
|
411
|
+
interface PrivateKeyExportOptions<T extends PrivateKeyExportType = PrivateKeyExportType> {
|
|
412
|
+
type: T;
|
|
413
|
+
format: "pem" | "der";
|
|
507
414
|
cipher?: string | undefined;
|
|
508
|
-
passphrase?:
|
|
415
|
+
passphrase?: BinaryLike | undefined;
|
|
509
416
|
}
|
|
510
417
|
interface JwkKeyExportOptions {
|
|
511
418
|
format: "jwk";
|
|
512
419
|
}
|
|
513
|
-
interface
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
420
|
+
interface RawPublicKeyExportOptions {
|
|
421
|
+
format: "raw-public";
|
|
422
|
+
}
|
|
423
|
+
interface RawPrivateKeyExportOptions {
|
|
424
|
+
format: "raw-private" | "raw-seed";
|
|
425
|
+
}
|
|
426
|
+
interface KeyPairExportOptions<
|
|
427
|
+
TPublic extends PublicKeyExportType = PublicKeyExportType,
|
|
428
|
+
TPrivate extends PrivateKeyExportType = PrivateKeyExportType,
|
|
429
|
+
> {
|
|
430
|
+
publicKeyEncoding?:
|
|
431
|
+
| PublicKeyExportOptions<TPublic>
|
|
432
|
+
| RawPublicKeyExportOptions
|
|
433
|
+
| JwkKeyExportOptions
|
|
434
|
+
| undefined;
|
|
435
|
+
privateKeyEncoding?:
|
|
436
|
+
| PrivateKeyExportOptions<TPrivate>
|
|
437
|
+
| RawPrivateKeyExportOptions
|
|
438
|
+
| JwkKeyExportOptions
|
|
439
|
+
| undefined;
|
|
440
|
+
}
|
|
441
|
+
type KeyExportResult<T, Default> = T extends { format: infer F extends KeyFormat } ? {
|
|
442
|
+
"der": NonSharedBuffer;
|
|
443
|
+
"jwk": webcrypto.JsonWebKey;
|
|
444
|
+
"pem": string;
|
|
445
|
+
"raw-public": NonSharedBuffer;
|
|
446
|
+
"raw-private": NonSharedBuffer;
|
|
447
|
+
"raw-seed": NonSharedBuffer;
|
|
448
|
+
}[F]
|
|
449
|
+
: Default;
|
|
450
|
+
interface KeyPairExportResult<T extends KeyPairExportOptions> {
|
|
451
|
+
publicKey: KeyExportResult<T["publicKeyEncoding"], KeyObject>;
|
|
452
|
+
privateKey: KeyExportResult<T["privateKeyEncoding"], KeyObject>;
|
|
453
|
+
}
|
|
454
|
+
type KeyPairExportCallback<T extends KeyPairExportOptions = {}> = (
|
|
455
|
+
err: Error | null,
|
|
456
|
+
publicKey: KeyExportResult<T["publicKeyEncoding"], KeyObject>,
|
|
457
|
+
privateKey: KeyExportResult<T["privateKeyEncoding"], KeyObject>,
|
|
458
|
+
) => void;
|
|
459
|
+
type MLDSAKeyType = `ml-dsa-${44 | 65 | 87}`;
|
|
460
|
+
type MLKEMKeyType = `ml-kem-${1024 | 512 | 768}`;
|
|
461
|
+
type SLHDSAKeyType = `slh-dsa-${"sha2" | "shake"}-${128 | 192 | 256}${"f" | "s"}`;
|
|
462
|
+
type AsymmetricKeyType =
|
|
463
|
+
| "dh"
|
|
464
|
+
| "dsa"
|
|
465
|
+
| "ec"
|
|
466
|
+
| "ed25519"
|
|
467
|
+
| "ed448"
|
|
468
|
+
| MLDSAKeyType
|
|
469
|
+
| MLKEMKeyType
|
|
470
|
+
| "rsa-pss"
|
|
471
|
+
| "rsa"
|
|
472
|
+
| SLHDSAKeyType
|
|
473
|
+
| "x25519"
|
|
474
|
+
| "x448";
|
|
529
475
|
interface AsymmetricKeyDetails {
|
|
530
|
-
/**
|
|
531
|
-
* Key size in bits (RSA, DSA).
|
|
532
|
-
*/
|
|
533
476
|
modulusLength?: number;
|
|
534
|
-
/**
|
|
535
|
-
* Public exponent (RSA).
|
|
536
|
-
*/
|
|
537
477
|
publicExponent?: bigint;
|
|
538
|
-
/**
|
|
539
|
-
* Name of the message digest (RSA-PSS).
|
|
540
|
-
*/
|
|
541
478
|
hashAlgorithm?: string;
|
|
542
|
-
/**
|
|
543
|
-
* Name of the message digest used by MGF1 (RSA-PSS).
|
|
544
|
-
*/
|
|
545
479
|
mgf1HashAlgorithm?: string;
|
|
546
|
-
/**
|
|
547
|
-
* Minimal salt length in bytes (RSA-PSS).
|
|
548
|
-
*/
|
|
549
480
|
saltLength?: number;
|
|
550
|
-
/**
|
|
551
|
-
* Size of q in bits (DSA).
|
|
552
|
-
*/
|
|
553
481
|
divisorLength?: number;
|
|
554
|
-
/**
|
|
555
|
-
* Name of the curve (EC).
|
|
556
|
-
*/
|
|
557
482
|
namedCurve?: string;
|
|
558
483
|
}
|
|
559
484
|
/**
|
|
@@ -572,7 +497,11 @@ declare module "crypto" {
|
|
|
572
497
|
class KeyObject {
|
|
573
498
|
private constructor();
|
|
574
499
|
/**
|
|
575
|
-
*
|
|
500
|
+
* Returns the underlying `KeyObject` of a `CryptoKey`. The returned `KeyObject`
|
|
501
|
+
* does not retain any of the restrictions imposed by the Web Crypto API on the
|
|
502
|
+
* original `CryptoKey`, such as the allowed key usages, the algorithm or hash
|
|
503
|
+
* algorithm bindings, and the extractability flag. In particular, the underlying
|
|
504
|
+
* key material of the returned `KeyObject` can always be exported.
|
|
576
505
|
*
|
|
577
506
|
* ```js
|
|
578
507
|
* const { KeyObject } = await import('node:crypto');
|
|
@@ -592,24 +521,14 @@ declare module "crypto" {
|
|
|
592
521
|
*/
|
|
593
522
|
static from(key: webcrypto.CryptoKey): KeyObject;
|
|
594
523
|
/**
|
|
595
|
-
* For asymmetric keys, this property represents the type of the key.
|
|
596
|
-
* types
|
|
597
|
-
*
|
|
598
|
-
* * `'rsa'` (OID 1.2.840.113549.1.1.1)
|
|
599
|
-
* * `'rsa-pss'` (OID 1.2.840.113549.1.1.10)
|
|
600
|
-
* * `'dsa'` (OID 1.2.840.10040.4.1)
|
|
601
|
-
* * `'ec'` (OID 1.2.840.10045.2.1)
|
|
602
|
-
* * `'x25519'` (OID 1.3.101.110)
|
|
603
|
-
* * `'x448'` (OID 1.3.101.111)
|
|
604
|
-
* * `'ed25519'` (OID 1.3.101.112)
|
|
605
|
-
* * `'ed448'` (OID 1.3.101.113)
|
|
606
|
-
* * `'dh'` (OID 1.2.840.113549.1.3.1)
|
|
524
|
+
* For asymmetric keys, this property represents the type of the key. See the
|
|
525
|
+
* supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
|
|
607
526
|
*
|
|
608
527
|
* This property is `undefined` for unrecognized `KeyObject` types and symmetric
|
|
609
528
|
* keys.
|
|
610
529
|
* @since v11.6.0
|
|
611
530
|
*/
|
|
612
|
-
asymmetricKeyType?:
|
|
531
|
+
asymmetricKeyType?: AsymmetricKeyType;
|
|
613
532
|
/**
|
|
614
533
|
* This property exists only on asymmetric keys. Depending on the type of the key,
|
|
615
534
|
* this object contains information about the key. None of the information obtained
|
|
@@ -625,31 +544,21 @@ declare module "crypto" {
|
|
|
625
544
|
*/
|
|
626
545
|
asymmetricKeyDetails?: AsymmetricKeyDetails;
|
|
627
546
|
/**
|
|
628
|
-
* For symmetric keys, the following encoding options can be used:
|
|
629
|
-
*
|
|
630
|
-
* For public keys, the following encoding options can be used:
|
|
631
|
-
*
|
|
632
|
-
* For private keys, the following encoding options can be used:
|
|
633
|
-
*
|
|
634
547
|
* The result type depends on the selected encoding format, when PEM the
|
|
635
548
|
* result is a string, when DER it will be a buffer containing the data
|
|
636
|
-
* encoded as DER, when [JWK](https://tools.ietf.org/html/rfc7517) it will be an object.
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
* PKCS#1
|
|
642
|
-
*
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
* a PKCS#8 key. See [RFC 5208](https://www.rfc-editor.org/rfc/rfc5208.txt) for PKCS#8 encryption and [RFC 1421](https://www.rfc-editor.org/rfc/rfc1421.txt) for
|
|
647
|
-
* PKCS#1 and SEC1 encryption.
|
|
549
|
+
* encoded as DER, when [JWK](https://tools.ietf.org/html/rfc7517) it will be an object. Raw formats return a
|
|
550
|
+
* `Buffer` containing the raw key material.
|
|
551
|
+
*
|
|
552
|
+
* Private keys can be encrypted by specifying a `cipher` and `passphrase`.
|
|
553
|
+
* The PKCS#8 `type` supports encryption with both PEM and DER `format` for any
|
|
554
|
+
* key algorithm. PKCS#1 and SEC1 can only be encrypted when the PEM `format` is
|
|
555
|
+
* used. For maximum compatibility, use PKCS#8 for encrypted private keys. Since
|
|
556
|
+
* PKCS#8 defines its own encryption mechanism, PEM-level encryption is not
|
|
557
|
+
* supported when encrypting a PKCS#8 key. See [RFC 5208](https://www.rfc-editor.org/rfc/rfc5208.txt) for PKCS#8 encryption
|
|
558
|
+
* and [RFC 1421](https://www.rfc-editor.org/rfc/rfc1421.txt) for PKCS#1 and SEC1 encryption.
|
|
648
559
|
* @since v11.6.0
|
|
649
560
|
*/
|
|
650
|
-
export(options
|
|
651
|
-
export(options?: KeyExportOptions<"der">): NonSharedBuffer;
|
|
652
|
-
export(options?: JwkKeyExportOptions): JsonWebKey;
|
|
561
|
+
export<T extends KeyExportOptions = {}>(options?: T): KeyExportResult<T, NonSharedBuffer>;
|
|
653
562
|
/**
|
|
654
563
|
* Returns `true` or `false` depending on whether the keys have exactly the same
|
|
655
564
|
* type, value, and parameters. This method is not [constant time](https://en.wikipedia.org/wiki/Timing_attack).
|
|
@@ -687,19 +596,18 @@ declare module "crypto" {
|
|
|
687
596
|
type CipherGCMTypes = "aes-128-gcm" | "aes-192-gcm" | "aes-256-gcm";
|
|
688
597
|
type CipherOCBTypes = "aes-128-ocb" | "aes-192-ocb" | "aes-256-ocb";
|
|
689
598
|
type CipherChaCha20Poly1305Types = "chacha20-poly1305";
|
|
690
|
-
type BinaryLike = string | NodeJS.ArrayBufferView;
|
|
691
|
-
type
|
|
692
|
-
interface CipherCCMOptions extends
|
|
599
|
+
type BinaryLike = string | ArrayBufferLike | NodeJS.ArrayBufferView;
|
|
600
|
+
type KeyLike = BinaryLike | KeyObject;
|
|
601
|
+
interface CipherCCMOptions extends TransformOptions {
|
|
693
602
|
authTagLength: number;
|
|
694
603
|
}
|
|
695
|
-
interface CipherGCMOptions extends
|
|
604
|
+
interface CipherGCMOptions extends TransformOptions {
|
|
696
605
|
authTagLength?: number | undefined;
|
|
697
606
|
}
|
|
698
|
-
interface CipherOCBOptions extends
|
|
607
|
+
interface CipherOCBOptions extends TransformOptions {
|
|
699
608
|
authTagLength: number;
|
|
700
609
|
}
|
|
701
|
-
interface CipherChaCha20Poly1305Options extends
|
|
702
|
-
/** @default 16 */
|
|
610
|
+
interface CipherChaCha20Poly1305Options extends TransformOptions {
|
|
703
611
|
authTagLength?: number | undefined;
|
|
704
612
|
}
|
|
705
613
|
/**
|
|
@@ -734,36 +642,36 @@ declare module "crypto" {
|
|
|
734
642
|
*/
|
|
735
643
|
function createCipheriv(
|
|
736
644
|
algorithm: CipherCCMTypes,
|
|
737
|
-
key:
|
|
645
|
+
key: KeyLike,
|
|
738
646
|
iv: BinaryLike,
|
|
739
647
|
options: CipherCCMOptions,
|
|
740
648
|
): CipherCCM;
|
|
741
649
|
function createCipheriv(
|
|
742
650
|
algorithm: CipherOCBTypes,
|
|
743
|
-
key:
|
|
651
|
+
key: KeyLike,
|
|
744
652
|
iv: BinaryLike,
|
|
745
653
|
options: CipherOCBOptions,
|
|
746
654
|
): CipherOCB;
|
|
747
655
|
function createCipheriv(
|
|
748
656
|
algorithm: CipherGCMTypes,
|
|
749
|
-
key:
|
|
657
|
+
key: KeyLike,
|
|
750
658
|
iv: BinaryLike,
|
|
751
659
|
options?: CipherGCMOptions,
|
|
752
660
|
): CipherGCM;
|
|
753
661
|
function createCipheriv(
|
|
754
662
|
algorithm: CipherChaCha20Poly1305Types,
|
|
755
|
-
key:
|
|
663
|
+
key: KeyLike,
|
|
756
664
|
iv: BinaryLike,
|
|
757
665
|
options?: CipherChaCha20Poly1305Options,
|
|
758
666
|
): CipherChaCha20Poly1305;
|
|
759
667
|
function createCipheriv(
|
|
760
668
|
algorithm: string,
|
|
761
|
-
key:
|
|
669
|
+
key: KeyLike,
|
|
762
670
|
iv: BinaryLike | null,
|
|
763
|
-
options?:
|
|
764
|
-
):
|
|
671
|
+
options?: TransformOptions,
|
|
672
|
+
): Cipheriv;
|
|
765
673
|
/**
|
|
766
|
-
* Instances of the `
|
|
674
|
+
* Instances of the `Cipheriv` class are used to encrypt data. The class can be
|
|
767
675
|
* used in one of two ways:
|
|
768
676
|
*
|
|
769
677
|
* * As a `stream` that is both readable and writable, where plain unencrypted
|
|
@@ -772,10 +680,10 @@ declare module "crypto" {
|
|
|
772
680
|
* the encrypted data.
|
|
773
681
|
*
|
|
774
682
|
* The {@link createCipheriv} method is
|
|
775
|
-
* used to create `
|
|
683
|
+
* used to create `Cipheriv` instances. `Cipheriv` objects are not to be created
|
|
776
684
|
* directly using the `new` keyword.
|
|
777
685
|
*
|
|
778
|
-
* Example: Using `
|
|
686
|
+
* Example: Using `Cipheriv` objects as streams:
|
|
779
687
|
*
|
|
780
688
|
* ```js
|
|
781
689
|
* const {
|
|
@@ -810,7 +718,7 @@ declare module "crypto" {
|
|
|
810
718
|
* });
|
|
811
719
|
* ```
|
|
812
720
|
*
|
|
813
|
-
* Example: Using `
|
|
721
|
+
* Example: Using `Cipheriv` and piped streams:
|
|
814
722
|
*
|
|
815
723
|
* ```js
|
|
816
724
|
* import {
|
|
@@ -881,7 +789,7 @@ declare module "crypto" {
|
|
|
881
789
|
* ```
|
|
882
790
|
* @since v0.1.94
|
|
883
791
|
*/
|
|
884
|
-
class
|
|
792
|
+
class Cipheriv extends Transform {
|
|
885
793
|
private constructor();
|
|
886
794
|
/**
|
|
887
795
|
* Updates the cipher with `data`. If the `inputEncoding` argument is given,
|
|
@@ -897,12 +805,14 @@ declare module "crypto" {
|
|
|
897
805
|
* @param inputEncoding The `encoding` of the data.
|
|
898
806
|
* @param outputEncoding The `encoding` of the return value.
|
|
899
807
|
*/
|
|
900
|
-
update(data:
|
|
901
|
-
update(
|
|
902
|
-
|
|
903
|
-
|
|
808
|
+
update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): NonSharedBuffer;
|
|
809
|
+
update(
|
|
810
|
+
data: string | NodeJS.ArrayBufferView,
|
|
811
|
+
inputEncoding: BufferEncoding | null | undefined,
|
|
812
|
+
outputEncoding: BufferEncoding,
|
|
813
|
+
): string;
|
|
904
814
|
/**
|
|
905
|
-
* Once the `cipher.final()` method has been called, the `
|
|
815
|
+
* Once the `cipher.final()` method has been called, the `Cipheriv` object can no
|
|
906
816
|
* longer be used to encrypt data. Attempts to call `cipher.final()` more than
|
|
907
817
|
* once will result in an error being thrown.
|
|
908
818
|
* @since v0.1.94
|
|
@@ -912,7 +822,7 @@ declare module "crypto" {
|
|
|
912
822
|
final(): NonSharedBuffer;
|
|
913
823
|
final(outputEncoding: BufferEncoding): string;
|
|
914
824
|
/**
|
|
915
|
-
* When using block encryption algorithms, the `
|
|
825
|
+
* When using block encryption algorithms, the `Cipheriv` class will automatically
|
|
916
826
|
* add padding to the input data to the appropriate block size. To disable the
|
|
917
827
|
* default padding call `cipher.setAutoPadding(false)`.
|
|
918
828
|
*
|
|
@@ -928,50 +838,31 @@ declare module "crypto" {
|
|
|
928
838
|
*/
|
|
929
839
|
setAutoPadding(autoPadding?: boolean): this;
|
|
930
840
|
}
|
|
931
|
-
interface
|
|
932
|
-
setAAD(
|
|
933
|
-
buffer: NodeJS.ArrayBufferView,
|
|
934
|
-
options: {
|
|
935
|
-
plaintextLength: number;
|
|
936
|
-
},
|
|
937
|
-
): this;
|
|
938
|
-
getAuthTag(): NonSharedBuffer;
|
|
939
|
-
}
|
|
940
|
-
interface CipherGCM extends Cipher {
|
|
941
|
-
setAAD(
|
|
942
|
-
buffer: NodeJS.ArrayBufferView,
|
|
943
|
-
options?: {
|
|
944
|
-
plaintextLength: number;
|
|
945
|
-
},
|
|
946
|
-
): this;
|
|
947
|
-
getAuthTag(): NonSharedBuffer;
|
|
948
|
-
}
|
|
949
|
-
interface CipherOCB extends Cipher {
|
|
950
|
-
setAAD(
|
|
951
|
-
buffer: NodeJS.ArrayBufferView,
|
|
952
|
-
options?: {
|
|
953
|
-
plaintextLength: number;
|
|
954
|
-
},
|
|
955
|
-
): this;
|
|
841
|
+
interface CipherAEADMethods {
|
|
956
842
|
getAuthTag(): NonSharedBuffer;
|
|
843
|
+
setAAD(buffer: BinaryLike, options?: {
|
|
844
|
+
plaintextLength?: number | undefined;
|
|
845
|
+
encoding?: BufferEncoding | undefined;
|
|
846
|
+
}): this;
|
|
957
847
|
}
|
|
958
|
-
interface
|
|
959
|
-
setAAD(
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
},
|
|
964
|
-
): this;
|
|
965
|
-
getAuthTag(): NonSharedBuffer;
|
|
848
|
+
interface CipherCCM extends Cipheriv, CipherAEADMethods {
|
|
849
|
+
setAAD(buffer: BinaryLike, options: {
|
|
850
|
+
plaintextLength: number;
|
|
851
|
+
encoding?: BufferEncoding | undefined;
|
|
852
|
+
}): this;
|
|
966
853
|
}
|
|
854
|
+
interface CipherGCM extends Cipheriv, CipherAEADMethods {}
|
|
855
|
+
interface CipherOCB extends Cipheriv, CipherAEADMethods {}
|
|
856
|
+
interface CipherChaCha20Poly1305 extends Cipheriv, CipherAEADMethods {}
|
|
967
857
|
/**
|
|
968
|
-
* Creates and returns a `
|
|
858
|
+
* Creates and returns a `Decipheriv` object that uses the given `algorithm`, `key` and initialization vector (`iv`).
|
|
969
859
|
*
|
|
970
860
|
* The `options` argument controls stream behavior and is optional except when a
|
|
971
|
-
* cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the
|
|
972
|
-
*
|
|
973
|
-
*
|
|
974
|
-
* For `chacha20-poly1305`, the `authTagLength` option defaults to 16
|
|
861
|
+
* cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the
|
|
862
|
+
* `authTagLength` option is required and specifies the length of the
|
|
863
|
+
* authentication tag in bytes, see [CCM mode](https://nodejs.org/docs/latest-v26.x/api/crypto.html#ccm-mode).
|
|
864
|
+
* For AES-GCM and `chacha20-poly1305`, the `authTagLength` option defaults to 16
|
|
865
|
+
* bytes and must be set to a different value if a different length is used.
|
|
975
866
|
*
|
|
976
867
|
* The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
|
|
977
868
|
* recent OpenSSL releases, `openssl list -cipher-algorithms` will
|
|
@@ -995,36 +886,36 @@ declare module "crypto" {
|
|
|
995
886
|
*/
|
|
996
887
|
function createDecipheriv(
|
|
997
888
|
algorithm: CipherCCMTypes,
|
|
998
|
-
key:
|
|
889
|
+
key: KeyLike,
|
|
999
890
|
iv: BinaryLike,
|
|
1000
891
|
options: CipherCCMOptions,
|
|
1001
892
|
): DecipherCCM;
|
|
1002
893
|
function createDecipheriv(
|
|
1003
894
|
algorithm: CipherOCBTypes,
|
|
1004
|
-
key:
|
|
895
|
+
key: KeyLike,
|
|
1005
896
|
iv: BinaryLike,
|
|
1006
897
|
options: CipherOCBOptions,
|
|
1007
898
|
): DecipherOCB;
|
|
1008
899
|
function createDecipheriv(
|
|
1009
900
|
algorithm: CipherGCMTypes,
|
|
1010
|
-
key:
|
|
901
|
+
key: KeyLike,
|
|
1011
902
|
iv: BinaryLike,
|
|
1012
903
|
options?: CipherGCMOptions,
|
|
1013
904
|
): DecipherGCM;
|
|
1014
905
|
function createDecipheriv(
|
|
1015
906
|
algorithm: CipherChaCha20Poly1305Types,
|
|
1016
|
-
key:
|
|
907
|
+
key: KeyLike,
|
|
1017
908
|
iv: BinaryLike,
|
|
1018
909
|
options?: CipherChaCha20Poly1305Options,
|
|
1019
910
|
): DecipherChaCha20Poly1305;
|
|
1020
911
|
function createDecipheriv(
|
|
1021
912
|
algorithm: string,
|
|
1022
|
-
key:
|
|
913
|
+
key: KeyLike,
|
|
1023
914
|
iv: BinaryLike | null,
|
|
1024
|
-
options?:
|
|
1025
|
-
):
|
|
915
|
+
options?: TransformOptions,
|
|
916
|
+
): Decipheriv;
|
|
1026
917
|
/**
|
|
1027
|
-
* Instances of the `
|
|
918
|
+
* Instances of the `Decipheriv` class are used to decrypt data. The class can be
|
|
1028
919
|
* used in one of two ways:
|
|
1029
920
|
*
|
|
1030
921
|
* * As a `stream` that is both readable and writable, where plain encrypted
|
|
@@ -1033,10 +924,10 @@ declare module "crypto" {
|
|
|
1033
924
|
* produce the unencrypted data.
|
|
1034
925
|
*
|
|
1035
926
|
* The {@link createDecipheriv} method is
|
|
1036
|
-
* used to create `
|
|
927
|
+
* used to create `Decipheriv` instances. `Decipheriv` objects are not to be created
|
|
1037
928
|
* directly using the `new` keyword.
|
|
1038
929
|
*
|
|
1039
|
-
* Example: Using `
|
|
930
|
+
* Example: Using `Decipheriv` objects as streams:
|
|
1040
931
|
*
|
|
1041
932
|
* ```js
|
|
1042
933
|
* import { Buffer } from 'node:buffer';
|
|
@@ -1075,7 +966,7 @@ declare module "crypto" {
|
|
|
1075
966
|
* decipher.end();
|
|
1076
967
|
* ```
|
|
1077
968
|
*
|
|
1078
|
-
* Example: Using `
|
|
969
|
+
* Example: Using `Decipheriv` and piped streams:
|
|
1079
970
|
*
|
|
1080
971
|
* ```js
|
|
1081
972
|
* import {
|
|
@@ -1131,7 +1022,7 @@ declare module "crypto" {
|
|
|
1131
1022
|
* ```
|
|
1132
1023
|
* @since v0.1.94
|
|
1133
1024
|
*/
|
|
1134
|
-
class
|
|
1025
|
+
class Decipheriv extends Transform {
|
|
1135
1026
|
private constructor();
|
|
1136
1027
|
/**
|
|
1137
1028
|
* Updates the decipher with `data`. If the `inputEncoding` argument is given,
|
|
@@ -1147,12 +1038,14 @@ declare module "crypto" {
|
|
|
1147
1038
|
* @param inputEncoding The `encoding` of the `data` string.
|
|
1148
1039
|
* @param outputEncoding The `encoding` of the return value.
|
|
1149
1040
|
*/
|
|
1150
|
-
update(data: NodeJS.ArrayBufferView): NonSharedBuffer;
|
|
1151
|
-
update(
|
|
1152
|
-
|
|
1153
|
-
|
|
1041
|
+
update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): NonSharedBuffer;
|
|
1042
|
+
update(
|
|
1043
|
+
data: string | NodeJS.ArrayBufferView,
|
|
1044
|
+
inputEncoding: BufferEncoding | null | undefined,
|
|
1045
|
+
outputEncoding: BufferEncoding,
|
|
1046
|
+
): string;
|
|
1154
1047
|
/**
|
|
1155
|
-
* Once the `decipher.final()` method has been called, the `
|
|
1048
|
+
* Once the `decipher.final()` method has been called, the `Decipheriv` object can
|
|
1156
1049
|
* no longer be used to decrypt data. Attempts to call `decipher.final()` more
|
|
1157
1050
|
* than once will result in an error being thrown.
|
|
1158
1051
|
* @since v0.1.94
|
|
@@ -1175,54 +1068,59 @@ declare module "crypto" {
|
|
|
1175
1068
|
*/
|
|
1176
1069
|
setAutoPadding(auto_padding?: boolean): this;
|
|
1177
1070
|
}
|
|
1178
|
-
interface
|
|
1179
|
-
setAuthTag(buffer: NodeJS.ArrayBufferView): this;
|
|
1180
|
-
setAAD(
|
|
1181
|
-
buffer: NodeJS.ArrayBufferView,
|
|
1182
|
-
options: {
|
|
1183
|
-
plaintextLength: number;
|
|
1184
|
-
},
|
|
1185
|
-
): this;
|
|
1186
|
-
}
|
|
1187
|
-
interface DecipherGCM extends Decipher {
|
|
1188
|
-
setAuthTag(buffer: NodeJS.ArrayBufferView): this;
|
|
1189
|
-
setAAD(
|
|
1190
|
-
buffer: NodeJS.ArrayBufferView,
|
|
1191
|
-
options?: {
|
|
1192
|
-
plaintextLength: number;
|
|
1193
|
-
},
|
|
1194
|
-
): this;
|
|
1195
|
-
}
|
|
1196
|
-
interface DecipherOCB extends Decipher {
|
|
1197
|
-
setAuthTag(buffer: NodeJS.ArrayBufferView): this;
|
|
1071
|
+
interface DecipherAEADMethods {
|
|
1198
1072
|
setAAD(
|
|
1199
|
-
buffer:
|
|
1073
|
+
buffer: BinaryLike,
|
|
1200
1074
|
options?: {
|
|
1201
|
-
plaintextLength
|
|
1075
|
+
plaintextLength?: number | undefined;
|
|
1076
|
+
encoding?: BufferEncoding | undefined;
|
|
1202
1077
|
},
|
|
1203
1078
|
): this;
|
|
1079
|
+
setAuthTag(buffer: BinaryLike, encoding?: BufferEncoding): this;
|
|
1204
1080
|
}
|
|
1205
|
-
interface
|
|
1206
|
-
setAuthTag(buffer: NodeJS.ArrayBufferView): this;
|
|
1081
|
+
interface DecipherCCM extends Decipheriv, DecipherAEADMethods {
|
|
1207
1082
|
setAAD(
|
|
1208
|
-
buffer:
|
|
1083
|
+
buffer: BinaryLike,
|
|
1209
1084
|
options: {
|
|
1210
1085
|
plaintextLength: number;
|
|
1086
|
+
encoding?: BufferEncoding | undefined;
|
|
1211
1087
|
},
|
|
1212
1088
|
): this;
|
|
1213
1089
|
}
|
|
1090
|
+
interface DecipherGCM extends Decipheriv, DecipherAEADMethods {}
|
|
1091
|
+
interface DecipherOCB extends Decipheriv, DecipherAEADMethods {}
|
|
1092
|
+
interface DecipherChaCha20Poly1305 extends Decipheriv, DecipherAEADMethods {}
|
|
1214
1093
|
interface PrivateKeyInput {
|
|
1215
|
-
key:
|
|
1216
|
-
format?:
|
|
1217
|
-
type?:
|
|
1218
|
-
passphrase?:
|
|
1219
|
-
encoding?:
|
|
1094
|
+
key: BinaryLike;
|
|
1095
|
+
format?: "pem" | "der" | undefined;
|
|
1096
|
+
type?: PrivateKeyExportType | undefined;
|
|
1097
|
+
passphrase?: BinaryLike | undefined;
|
|
1098
|
+
encoding?: BufferEncoding | undefined;
|
|
1220
1099
|
}
|
|
1221
1100
|
interface PublicKeyInput {
|
|
1222
|
-
key:
|
|
1223
|
-
format?:
|
|
1224
|
-
type?:
|
|
1225
|
-
encoding?:
|
|
1101
|
+
key: BinaryLike;
|
|
1102
|
+
format?: "pem" | "der" | undefined;
|
|
1103
|
+
type?: PublicKeyExportType | undefined;
|
|
1104
|
+
encoding?: BufferEncoding | undefined;
|
|
1105
|
+
}
|
|
1106
|
+
interface RawPrivateKeyInput {
|
|
1107
|
+
key: ArrayBufferLike | NodeJS.ArrayBufferView;
|
|
1108
|
+
format: "raw-private" | "raw-seed";
|
|
1109
|
+
asymmetricKeyType: AsymmetricKeyType;
|
|
1110
|
+
namedCurve?: string | undefined;
|
|
1111
|
+
}
|
|
1112
|
+
interface RawPublicKeyInput {
|
|
1113
|
+
key: ArrayBufferLike | NodeJS.ArrayBufferView;
|
|
1114
|
+
format: "raw-public";
|
|
1115
|
+
asymmetricKeyType: AsymmetricKeyType;
|
|
1116
|
+
namedCurve?: string | undefined;
|
|
1117
|
+
}
|
|
1118
|
+
interface JsonWebKeyInput {
|
|
1119
|
+
key: webcrypto.JsonWebKey;
|
|
1120
|
+
format: "jwk";
|
|
1121
|
+
}
|
|
1122
|
+
interface SecretKeyOptions {
|
|
1123
|
+
length: number;
|
|
1226
1124
|
}
|
|
1227
1125
|
/**
|
|
1228
1126
|
* Asynchronously generates a new random secret key of the given `length`. The `type` will determine which validations will be performed on the `length`.
|
|
@@ -1245,9 +1143,7 @@ declare module "crypto" {
|
|
|
1245
1143
|
*/
|
|
1246
1144
|
function generateKey(
|
|
1247
1145
|
type: "hmac" | "aes",
|
|
1248
|
-
options:
|
|
1249
|
-
length: number;
|
|
1250
|
-
},
|
|
1146
|
+
options: SecretKeyOptions,
|
|
1251
1147
|
callback: (err: Error | null, key: KeyObject) => void,
|
|
1252
1148
|
): void;
|
|
1253
1149
|
/**
|
|
@@ -1267,16 +1163,7 @@ declare module "crypto" {
|
|
|
1267
1163
|
* @since v15.0.0
|
|
1268
1164
|
* @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`.
|
|
1269
1165
|
*/
|
|
1270
|
-
function generateKeySync(
|
|
1271
|
-
type: "hmac" | "aes",
|
|
1272
|
-
options: {
|
|
1273
|
-
length: number;
|
|
1274
|
-
},
|
|
1275
|
-
): KeyObject;
|
|
1276
|
-
interface JsonWebKeyInput {
|
|
1277
|
-
key: JsonWebKey;
|
|
1278
|
-
format: "jwk";
|
|
1279
|
-
}
|
|
1166
|
+
function generateKeySync(type: "hmac" | "aes", options: SecretKeyOptions): KeyObject;
|
|
1280
1167
|
/**
|
|
1281
1168
|
* Creates and returns a new key object containing a private key. If `key` is a
|
|
1282
1169
|
* string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key` must be an object with the properties described above.
|
|
@@ -1285,7 +1172,7 @@ declare module "crypto" {
|
|
|
1285
1172
|
* of the passphrase is limited to 1024 bytes.
|
|
1286
1173
|
* @since v11.6.0
|
|
1287
1174
|
*/
|
|
1288
|
-
function createPrivateKey(key: PrivateKeyInput |
|
|
1175
|
+
function createPrivateKey(key: PrivateKeyInput | RawPrivateKeyInput | JsonWebKeyInput | BinaryLike): KeyObject;
|
|
1289
1176
|
/**
|
|
1290
1177
|
* Creates and returns a new key object containing a public key. If `key` is a
|
|
1291
1178
|
* 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;
|
|
@@ -1300,15 +1187,14 @@ declare module "crypto" {
|
|
|
1300
1187
|
* and it will be impossible to extract the private key from the returned object.
|
|
1301
1188
|
* @since v11.6.0
|
|
1302
1189
|
*/
|
|
1303
|
-
function createPublicKey(key: PublicKeyInput |
|
|
1190
|
+
function createPublicKey(key: PublicKeyInput | RawPublicKeyInput | JsonWebKeyInput | KeyLike): KeyObject;
|
|
1304
1191
|
/**
|
|
1305
1192
|
* Creates and returns a new key object containing a secret key for symmetric
|
|
1306
1193
|
* encryption or `Hmac`.
|
|
1307
1194
|
* @since v11.6.0
|
|
1308
1195
|
* @param encoding The string encoding when `key` is a string.
|
|
1309
1196
|
*/
|
|
1310
|
-
function createSecretKey(key:
|
|
1311
|
-
function createSecretKey(key: string, encoding: BufferEncoding): KeyObject;
|
|
1197
|
+
function createSecretKey(key: BinaryLike, encoding?: BufferEncoding): KeyObject;
|
|
1312
1198
|
/**
|
|
1313
1199
|
* Creates and returns a `Sign` object that uses the given `algorithm`. Use {@link getHashes} to obtain the names of the available digest algorithms.
|
|
1314
1200
|
* Optional `options` argument controls the `stream.Writable` behavior.
|
|
@@ -1321,27 +1207,26 @@ declare module "crypto" {
|
|
|
1321
1207
|
* @since v0.1.92
|
|
1322
1208
|
* @param options `stream.Writable` options
|
|
1323
1209
|
*/
|
|
1324
|
-
function createSign(algorithm: string, options?:
|
|
1210
|
+
function createSign(algorithm: string, options?: WritableOptions): Sign;
|
|
1325
1211
|
type DSAEncoding = "der" | "ieee-p1363";
|
|
1326
1212
|
interface SigningOptions {
|
|
1327
|
-
/**
|
|
1328
|
-
* @see crypto.constants.RSA_PKCS1_PADDING
|
|
1329
|
-
*/
|
|
1330
1213
|
padding?: number | undefined;
|
|
1331
1214
|
saltLength?: number | undefined;
|
|
1332
1215
|
dsaEncoding?: DSAEncoding | undefined;
|
|
1216
|
+
context?: NodeJS.ArrayBufferView | undefined;
|
|
1333
1217
|
}
|
|
1334
1218
|
interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {}
|
|
1219
|
+
interface SignRawPrivateKeyInput extends RawPrivateKeyInput, SigningOptions {}
|
|
1220
|
+
interface SignJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
|
|
1335
1221
|
interface SignKeyObjectInput extends SigningOptions {
|
|
1336
1222
|
key: KeyObject;
|
|
1337
1223
|
}
|
|
1338
|
-
interface SignJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
|
|
1339
1224
|
interface VerifyPublicKeyInput extends PublicKeyInput, SigningOptions {}
|
|
1225
|
+
interface VerifyRawPublicKeyInput extends RawPublicKeyInput, SigningOptions {}
|
|
1226
|
+
interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
|
|
1340
1227
|
interface VerifyKeyObjectInput extends SigningOptions {
|
|
1341
1228
|
key: KeyObject;
|
|
1342
1229
|
}
|
|
1343
|
-
interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
|
|
1344
|
-
type KeyLike = string | Buffer | KeyObject;
|
|
1345
1230
|
/**
|
|
1346
1231
|
* The `Sign` class is a utility for generating signatures. It can be used in one
|
|
1347
1232
|
* of two ways:
|
|
@@ -1405,7 +1290,7 @@ declare module "crypto" {
|
|
|
1405
1290
|
* ```
|
|
1406
1291
|
* @since v0.1.92
|
|
1407
1292
|
*/
|
|
1408
|
-
class Sign extends
|
|
1293
|
+
class Sign extends Writable {
|
|
1409
1294
|
private constructor();
|
|
1410
1295
|
/**
|
|
1411
1296
|
* Updates the `Sign` content with the given `data`, the encoding of which
|
|
@@ -1417,13 +1302,15 @@ declare module "crypto" {
|
|
|
1417
1302
|
* @since v0.1.92
|
|
1418
1303
|
* @param inputEncoding The `encoding` of the `data` string.
|
|
1419
1304
|
*/
|
|
1420
|
-
update(data:
|
|
1421
|
-
update(data: string, inputEncoding: Encoding): this;
|
|
1305
|
+
update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): this;
|
|
1422
1306
|
/**
|
|
1423
1307
|
* Calculates the signature on all the data passed through using either `sign.update()` or `sign.write()`.
|
|
1424
1308
|
*
|
|
1425
|
-
* If `privateKey` is not a `KeyObject`, this function behaves as if
|
|
1426
|
-
*
|
|
1309
|
+
* If `privateKey` is not a `KeyObject`, this function behaves as if
|
|
1310
|
+
* `privateKey` had been passed to `crypto.createPrivateKey()`. When
|
|
1311
|
+
* `privateKey` is a string, `ArrayBuffer`, `Buffer`, `TypedArray`, or
|
|
1312
|
+
* `DataView`, it must contain PEM-encoded key material. If it is an object, the
|
|
1313
|
+
* following additional properties can be passed:
|
|
1427
1314
|
*
|
|
1428
1315
|
* If `outputEncoding` is provided a string is returned; otherwise a `Buffer` is returned.
|
|
1429
1316
|
*
|
|
@@ -1431,10 +1318,22 @@ declare module "crypto" {
|
|
|
1431
1318
|
* called. Multiple calls to `sign.sign()` will result in an error being thrown.
|
|
1432
1319
|
* @since v0.1.92
|
|
1433
1320
|
*/
|
|
1434
|
-
sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput): NonSharedBuffer;
|
|
1435
1321
|
sign(
|
|
1436
|
-
privateKey:
|
|
1437
|
-
|
|
1322
|
+
privateKey:
|
|
1323
|
+
| KeyLike
|
|
1324
|
+
| SignKeyObjectInput
|
|
1325
|
+
| SignPrivateKeyInput
|
|
1326
|
+
| SignRawPrivateKeyInput
|
|
1327
|
+
| SignJsonWebKeyInput,
|
|
1328
|
+
): NonSharedBuffer;
|
|
1329
|
+
sign(
|
|
1330
|
+
privateKey:
|
|
1331
|
+
| KeyLike
|
|
1332
|
+
| SignKeyObjectInput
|
|
1333
|
+
| SignPrivateKeyInput
|
|
1334
|
+
| SignRawPrivateKeyInput
|
|
1335
|
+
| SignJsonWebKeyInput,
|
|
1336
|
+
outputFormat: BufferEncoding,
|
|
1438
1337
|
): string;
|
|
1439
1338
|
}
|
|
1440
1339
|
/**
|
|
@@ -1450,7 +1349,7 @@ declare module "crypto" {
|
|
|
1450
1349
|
* @since v0.1.92
|
|
1451
1350
|
* @param options `stream.Writable` options
|
|
1452
1351
|
*/
|
|
1453
|
-
function createVerify(algorithm: string, options?:
|
|
1352
|
+
function createVerify(algorithm: string, options?: WritableOptions): Verify;
|
|
1454
1353
|
/**
|
|
1455
1354
|
* The `Verify` class is a utility for verifying signatures. It can be used in one
|
|
1456
1355
|
* of two ways:
|
|
@@ -1465,7 +1364,7 @@ declare module "crypto" {
|
|
|
1465
1364
|
* See `Sign` for examples.
|
|
1466
1365
|
* @since v0.1.92
|
|
1467
1366
|
*/
|
|
1468
|
-
class Verify extends
|
|
1367
|
+
class Verify extends Writable {
|
|
1469
1368
|
private constructor();
|
|
1470
1369
|
/**
|
|
1471
1370
|
* Updates the `Verify` content with the given `data`, the encoding of which
|
|
@@ -1477,13 +1376,15 @@ declare module "crypto" {
|
|
|
1477
1376
|
* @since v0.1.92
|
|
1478
1377
|
* @param inputEncoding The `encoding` of the `data` string.
|
|
1479
1378
|
*/
|
|
1480
|
-
update(data:
|
|
1481
|
-
update(data: string, inputEncoding: Encoding): Verify;
|
|
1379
|
+
update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): Verify;
|
|
1482
1380
|
/**
|
|
1483
|
-
* Verifies the provided data using the given `
|
|
1381
|
+
* Verifies the provided data using the given `key` and `signature`.
|
|
1484
1382
|
*
|
|
1485
|
-
* If `
|
|
1486
|
-
*
|
|
1383
|
+
* If `key` is not a `KeyObject`, this function behaves as if
|
|
1384
|
+
* `key` had been passed to `crypto.createPublicKey()`. When `key` is a string,
|
|
1385
|
+
* `ArrayBuffer`, `Buffer`, `TypedArray`, or `DataView`, it must contain
|
|
1386
|
+
* PEM-encoded key material. If it is an object, the following additional
|
|
1387
|
+
* properties can be passed:
|
|
1487
1388
|
*
|
|
1488
1389
|
* The `signature` argument is the previously calculated signature for the data, in
|
|
1489
1390
|
* the `signatureEncoding`.
|
|
@@ -1499,13 +1400,14 @@ declare module "crypto" {
|
|
|
1499
1400
|
* @since v0.1.92
|
|
1500
1401
|
*/
|
|
1501
1402
|
verify(
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1403
|
+
key:
|
|
1404
|
+
| KeyLike
|
|
1405
|
+
| VerifyKeyObjectInput
|
|
1406
|
+
| VerifyPublicKeyInput
|
|
1407
|
+
| VerifyRawPublicKeyInput
|
|
1408
|
+
| VerifyJsonWebKeyInput,
|
|
1409
|
+
signature: BinaryLike,
|
|
1410
|
+
signatureEncoding?: BufferEncoding,
|
|
1509
1411
|
): boolean;
|
|
1510
1412
|
}
|
|
1511
1413
|
/**
|
|
@@ -1526,24 +1428,15 @@ declare module "crypto" {
|
|
|
1526
1428
|
*/
|
|
1527
1429
|
function createDiffieHellman(primeLength: number, generator?: number): DiffieHellman;
|
|
1528
1430
|
function createDiffieHellman(
|
|
1529
|
-
prime:
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
prime: ArrayBuffer | NodeJS.ArrayBufferView,
|
|
1534
|
-
generator: string,
|
|
1535
|
-
generatorEncoding: BinaryToTextEncoding,
|
|
1536
|
-
): DiffieHellman;
|
|
1537
|
-
function createDiffieHellman(
|
|
1538
|
-
prime: string,
|
|
1539
|
-
primeEncoding: BinaryToTextEncoding,
|
|
1540
|
-
generator?: number | ArrayBuffer | NodeJS.ArrayBufferView,
|
|
1431
|
+
prime: BinaryLike,
|
|
1432
|
+
primeEncoding?: BufferEncoding,
|
|
1433
|
+
generator?: number | BinaryLike,
|
|
1434
|
+
generatorEncoding?: BufferEncoding,
|
|
1541
1435
|
): DiffieHellman;
|
|
1542
1436
|
function createDiffieHellman(
|
|
1543
|
-
prime:
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
generatorEncoding: BinaryToTextEncoding,
|
|
1437
|
+
prime: BinaryLike,
|
|
1438
|
+
generator: number | BinaryLike,
|
|
1439
|
+
generatorEncoding?: BufferEncoding,
|
|
1547
1440
|
): DiffieHellman;
|
|
1548
1441
|
/**
|
|
1549
1442
|
* The `DiffieHellman` class is a utility for creating Diffie-Hellman key
|
|
@@ -1585,13 +1478,15 @@ declare module "crypto" {
|
|
|
1585
1478
|
* If `encoding` is provided a string is returned; otherwise a `Buffer` is returned.
|
|
1586
1479
|
*
|
|
1587
1480
|
* This function is a thin wrapper around [`DH_generate_key()`](https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html). In particular,
|
|
1588
|
-
* once a private key has been generated or set, calling this function only
|
|
1589
|
-
* the public key
|
|
1481
|
+
* once a private key has been generated or set, calling this function only
|
|
1482
|
+
* recomputes the public key from the existing private key. Since the public key is
|
|
1483
|
+
* determined by the private key, the result will be the same unless the private key
|
|
1484
|
+
* has been changed via `diffieHellman.setPrivateKey()`.
|
|
1590
1485
|
* @since v0.5.0
|
|
1591
1486
|
* @param encoding The `encoding` of the return value.
|
|
1592
1487
|
*/
|
|
1593
1488
|
generateKeys(): NonSharedBuffer;
|
|
1594
|
-
generateKeys(encoding:
|
|
1489
|
+
generateKeys(encoding: BufferEncoding): string;
|
|
1595
1490
|
/**
|
|
1596
1491
|
* Computes the shared secret using `otherPublicKey` as the other
|
|
1597
1492
|
* party's public key and returns the computed shared secret. The supplied
|
|
@@ -1606,24 +1501,13 @@ declare module "crypto" {
|
|
|
1606
1501
|
* @param outputEncoding The `encoding` of the return value.
|
|
1607
1502
|
*/
|
|
1608
1503
|
computeSecret(
|
|
1609
|
-
otherPublicKey:
|
|
1610
|
-
inputEncoding?:
|
|
1611
|
-
outputEncoding?: null,
|
|
1612
|
-
): NonSharedBuffer;
|
|
1613
|
-
computeSecret(
|
|
1614
|
-
otherPublicKey: string,
|
|
1615
|
-
inputEncoding: BinaryToTextEncoding,
|
|
1616
|
-
outputEncoding?: null,
|
|
1504
|
+
otherPublicKey: BinaryLike,
|
|
1505
|
+
inputEncoding?: BufferEncoding,
|
|
1617
1506
|
): NonSharedBuffer;
|
|
1618
1507
|
computeSecret(
|
|
1619
|
-
otherPublicKey:
|
|
1620
|
-
inputEncoding: null,
|
|
1621
|
-
outputEncoding:
|
|
1622
|
-
): string;
|
|
1623
|
-
computeSecret(
|
|
1624
|
-
otherPublicKey: string,
|
|
1625
|
-
inputEncoding: BinaryToTextEncoding,
|
|
1626
|
-
outputEncoding: BinaryToTextEncoding,
|
|
1508
|
+
otherPublicKey: BinaryLike,
|
|
1509
|
+
inputEncoding: BufferEncoding | null | undefined,
|
|
1510
|
+
outputEncoding: BufferEncoding,
|
|
1627
1511
|
): string;
|
|
1628
1512
|
/**
|
|
1629
1513
|
* Returns the Diffie-Hellman prime in the specified `encoding`.
|
|
@@ -1633,7 +1517,7 @@ declare module "crypto" {
|
|
|
1633
1517
|
* @param encoding The `encoding` of the return value.
|
|
1634
1518
|
*/
|
|
1635
1519
|
getPrime(): NonSharedBuffer;
|
|
1636
|
-
getPrime(encoding:
|
|
1520
|
+
getPrime(encoding: BufferEncoding): string;
|
|
1637
1521
|
/**
|
|
1638
1522
|
* Returns the Diffie-Hellman generator in the specified `encoding`.
|
|
1639
1523
|
* If `encoding` is provided a string is
|
|
@@ -1642,7 +1526,7 @@ declare module "crypto" {
|
|
|
1642
1526
|
* @param encoding The `encoding` of the return value.
|
|
1643
1527
|
*/
|
|
1644
1528
|
getGenerator(): NonSharedBuffer;
|
|
1645
|
-
getGenerator(encoding:
|
|
1529
|
+
getGenerator(encoding: BufferEncoding): string;
|
|
1646
1530
|
/**
|
|
1647
1531
|
* Returns the Diffie-Hellman public key in the specified `encoding`.
|
|
1648
1532
|
* If `encoding` is provided a
|
|
@@ -1651,7 +1535,7 @@ declare module "crypto" {
|
|
|
1651
1535
|
* @param encoding The `encoding` of the return value.
|
|
1652
1536
|
*/
|
|
1653
1537
|
getPublicKey(): NonSharedBuffer;
|
|
1654
|
-
getPublicKey(encoding:
|
|
1538
|
+
getPublicKey(encoding: BufferEncoding): string;
|
|
1655
1539
|
/**
|
|
1656
1540
|
* Returns the Diffie-Hellman private key in the specified `encoding`.
|
|
1657
1541
|
* If `encoding` is provided a
|
|
@@ -1660,7 +1544,7 @@ declare module "crypto" {
|
|
|
1660
1544
|
* @param encoding The `encoding` of the return value.
|
|
1661
1545
|
*/
|
|
1662
1546
|
getPrivateKey(): NonSharedBuffer;
|
|
1663
|
-
getPrivateKey(encoding:
|
|
1547
|
+
getPrivateKey(encoding: BufferEncoding): string;
|
|
1664
1548
|
/**
|
|
1665
1549
|
* Sets the Diffie-Hellman public key. If the `encoding` argument is provided, `publicKey` is expected
|
|
1666
1550
|
* to be a string. If no `encoding` is provided, `publicKey` is expected
|
|
@@ -1668,8 +1552,7 @@ declare module "crypto" {
|
|
|
1668
1552
|
* @since v0.5.0
|
|
1669
1553
|
* @param encoding The `encoding` of the `publicKey` string.
|
|
1670
1554
|
*/
|
|
1671
|
-
setPublicKey(publicKey:
|
|
1672
|
-
setPublicKey(publicKey: string, encoding: BufferEncoding): void;
|
|
1555
|
+
setPublicKey(publicKey: BinaryLike, encoding?: BufferEncoding): void;
|
|
1673
1556
|
/**
|
|
1674
1557
|
* Sets the Diffie-Hellman private key. If the `encoding` argument is provided,`privateKey` is expected
|
|
1675
1558
|
* to be a string. If no `encoding` is provided, `privateKey` is expected
|
|
@@ -1680,8 +1563,7 @@ declare module "crypto" {
|
|
|
1680
1563
|
* @since v0.5.0
|
|
1681
1564
|
* @param encoding The `encoding` of the `privateKey` string.
|
|
1682
1565
|
*/
|
|
1683
|
-
setPrivateKey(privateKey:
|
|
1684
|
-
setPrivateKey(privateKey: string, encoding: BufferEncoding): void;
|
|
1566
|
+
setPrivateKey(privateKey: BinaryLike, encoding?: BufferEncoding): void;
|
|
1685
1567
|
/**
|
|
1686
1568
|
* A bit field containing any warnings and/or errors resulting from a check
|
|
1687
1569
|
* performed during initialization of the `DiffieHellman` object.
|
|
@@ -1719,13 +1601,10 @@ declare module "crypto" {
|
|
|
1719
1601
|
* ```
|
|
1720
1602
|
* @since v0.7.5
|
|
1721
1603
|
*/
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
new(name: string): DiffieHellmanGroup;
|
|
1725
|
-
(name: string): DiffieHellmanGroup;
|
|
1726
|
-
readonly prototype: DiffieHellmanGroup;
|
|
1604
|
+
class DiffieHellmanGroup {
|
|
1605
|
+
private constructor();
|
|
1727
1606
|
}
|
|
1728
|
-
|
|
1607
|
+
interface DiffieHellmanGroup extends Omit<DiffieHellman, "setPublicKey" | "setPrivateKey"> {}
|
|
1729
1608
|
/**
|
|
1730
1609
|
* Creates a predefined `DiffieHellmanGroup` key exchange object. The
|
|
1731
1610
|
* supported groups are listed in the documentation for `DiffieHellmanGroup`.
|
|
@@ -1939,9 +1818,8 @@ declare module "crypto" {
|
|
|
1939
1818
|
* console.log(`The dice rolled: ${n}`);
|
|
1940
1819
|
* ```
|
|
1941
1820
|
* @since v14.10.0, v12.19.0
|
|
1942
|
-
* @param
|
|
1821
|
+
* @param min Start of random range (inclusive).
|
|
1943
1822
|
* @param max End of random range (exclusive).
|
|
1944
|
-
* @param callback `function(err, n) {}`.
|
|
1945
1823
|
*/
|
|
1946
1824
|
function randomInt(max: number): number;
|
|
1947
1825
|
function randomInt(min: number, max: number): number;
|
|
@@ -1988,7 +1866,11 @@ declare module "crypto" {
|
|
|
1988
1866
|
* @param [size=buffer.length - offset]
|
|
1989
1867
|
* @return The object passed as `buffer` argument.
|
|
1990
1868
|
*/
|
|
1991
|
-
function randomFillSync<T extends NodeJS.ArrayBufferView>(
|
|
1869
|
+
function randomFillSync<T extends ArrayBufferLike | NodeJS.ArrayBufferView>(
|
|
1870
|
+
buffer: T,
|
|
1871
|
+
offset?: number,
|
|
1872
|
+
size?: number,
|
|
1873
|
+
): T;
|
|
1992
1874
|
/**
|
|
1993
1875
|
* This function is similar to {@link randomBytes} but requires the first
|
|
1994
1876
|
* argument to be a `Buffer` that will be filled. It also
|
|
@@ -2064,16 +1946,16 @@ declare module "crypto" {
|
|
|
2064
1946
|
* @param [size=buffer.length - offset]
|
|
2065
1947
|
* @param callback `function(err, buf) {}`.
|
|
2066
1948
|
*/
|
|
2067
|
-
function randomFill<T extends NodeJS.ArrayBufferView>(
|
|
1949
|
+
function randomFill<T extends ArrayBufferLike | NodeJS.ArrayBufferView>(
|
|
2068
1950
|
buffer: T,
|
|
2069
1951
|
callback: (err: Error | null, buf: T) => void,
|
|
2070
1952
|
): void;
|
|
2071
|
-
function randomFill<T extends NodeJS.ArrayBufferView>(
|
|
1953
|
+
function randomFill<T extends ArrayBufferLike | NodeJS.ArrayBufferView>(
|
|
2072
1954
|
buffer: T,
|
|
2073
1955
|
offset: number,
|
|
2074
1956
|
callback: (err: Error | null, buf: T) => void,
|
|
2075
1957
|
): void;
|
|
2076
|
-
function randomFill<T extends NodeJS.ArrayBufferView>(
|
|
1958
|
+
function randomFill<T extends ArrayBufferLike | NodeJS.ArrayBufferView>(
|
|
2077
1959
|
buffer: T,
|
|
2078
1960
|
offset: number,
|
|
2079
1961
|
size: number,
|
|
@@ -2171,19 +2053,25 @@ declare module "crypto" {
|
|
|
2171
2053
|
keylen: number,
|
|
2172
2054
|
options?: ScryptOptions,
|
|
2173
2055
|
): NonSharedBuffer;
|
|
2174
|
-
interface
|
|
2175
|
-
key: KeyLike;
|
|
2056
|
+
interface PublicDecryptOptions {
|
|
2176
2057
|
padding?: number | undefined;
|
|
2058
|
+
encoding?: BufferEncoding | undefined;
|
|
2177
2059
|
}
|
|
2178
|
-
interface
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2060
|
+
interface PublicDecryptPrivateKeyInput extends PrivateKeyInput, PublicDecryptOptions {}
|
|
2061
|
+
interface PublicDecryptPublicKeyInput extends PublicKeyInput, PublicDecryptOptions {}
|
|
2062
|
+
interface PublicDecryptJsonWebKeyInput extends JsonWebKeyInput, PublicDecryptOptions {}
|
|
2063
|
+
interface PublicDecryptKeyObjectInput extends PublicDecryptOptions {
|
|
2064
|
+
key: KeyObject;
|
|
2065
|
+
}
|
|
2066
|
+
interface PublicEncryptOptions extends PublicDecryptOptions {
|
|
2184
2067
|
oaepHash?: string | undefined;
|
|
2185
|
-
oaepLabel?:
|
|
2186
|
-
|
|
2068
|
+
oaepLabel?: BinaryLike | undefined;
|
|
2069
|
+
}
|
|
2070
|
+
interface PublicEncryptPrivateKeyInput extends PrivateKeyInput, PublicEncryptOptions {}
|
|
2071
|
+
interface PublicEncryptPublicKeyInput extends PublicKeyInput, PublicEncryptOptions {}
|
|
2072
|
+
interface PublicEncryptJsonWebKeyInput extends JsonWebKeyInput, PublicEncryptOptions {}
|
|
2073
|
+
interface PublicEncryptKeyObjectInput extends PublicEncryptOptions {
|
|
2074
|
+
key: KeyObject;
|
|
2187
2075
|
}
|
|
2188
2076
|
/**
|
|
2189
2077
|
* Encrypts the content of `buffer` with `key` and returns a new `Buffer` with encrypted content. The returned data can be decrypted using
|
|
@@ -2197,8 +2085,13 @@ declare module "crypto" {
|
|
|
2197
2085
|
* @since v0.11.14
|
|
2198
2086
|
*/
|
|
2199
2087
|
function publicEncrypt(
|
|
2200
|
-
key:
|
|
2201
|
-
|
|
2088
|
+
key:
|
|
2089
|
+
| KeyLike
|
|
2090
|
+
| PublicEncryptKeyObjectInput
|
|
2091
|
+
| PublicEncryptPrivateKeyInput
|
|
2092
|
+
| PublicEncryptPublicKeyInput
|
|
2093
|
+
| PublicEncryptJsonWebKeyInput,
|
|
2094
|
+
buffer: BinaryLike,
|
|
2202
2095
|
): NonSharedBuffer;
|
|
2203
2096
|
/**
|
|
2204
2097
|
* Decrypts `buffer` with `key`.`buffer` was previously encrypted using
|
|
@@ -2212,8 +2105,13 @@ declare module "crypto" {
|
|
|
2212
2105
|
* @since v1.1.0
|
|
2213
2106
|
*/
|
|
2214
2107
|
function publicDecrypt(
|
|
2215
|
-
key:
|
|
2216
|
-
|
|
2108
|
+
key:
|
|
2109
|
+
| KeyLike
|
|
2110
|
+
| PublicDecryptKeyObjectInput
|
|
2111
|
+
| PublicDecryptPrivateKeyInput
|
|
2112
|
+
| PublicDecryptPublicKeyInput
|
|
2113
|
+
| PublicDecryptJsonWebKeyInput,
|
|
2114
|
+
buffer: BinaryLike,
|
|
2217
2115
|
): NonSharedBuffer;
|
|
2218
2116
|
/**
|
|
2219
2117
|
* Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using
|
|
@@ -2224,8 +2122,12 @@ declare module "crypto" {
|
|
|
2224
2122
|
* @since v0.11.14
|
|
2225
2123
|
*/
|
|
2226
2124
|
function privateDecrypt(
|
|
2227
|
-
privateKey:
|
|
2228
|
-
|
|
2125
|
+
privateKey:
|
|
2126
|
+
| KeyLike
|
|
2127
|
+
| PublicEncryptKeyObjectInput
|
|
2128
|
+
| PublicEncryptPrivateKeyInput
|
|
2129
|
+
| PublicEncryptJsonWebKeyInput,
|
|
2130
|
+
buffer: BinaryLike,
|
|
2229
2131
|
): NonSharedBuffer;
|
|
2230
2132
|
/**
|
|
2231
2133
|
* Encrypts `buffer` with `privateKey`. The returned data can be decrypted using
|
|
@@ -2236,8 +2138,12 @@ declare module "crypto" {
|
|
|
2236
2138
|
* @since v1.1.0
|
|
2237
2139
|
*/
|
|
2238
2140
|
function privateEncrypt(
|
|
2239
|
-
privateKey:
|
|
2240
|
-
|
|
2141
|
+
privateKey:
|
|
2142
|
+
| KeyLike
|
|
2143
|
+
| PublicDecryptKeyObjectInput
|
|
2144
|
+
| PublicDecryptPrivateKeyInput
|
|
2145
|
+
| PublicDecryptJsonWebKeyInput,
|
|
2146
|
+
buffer: BinaryLike,
|
|
2241
2147
|
): NonSharedBuffer;
|
|
2242
2148
|
/**
|
|
2243
2149
|
* ```js
|
|
@@ -2287,6 +2193,7 @@ declare module "crypto" {
|
|
|
2287
2193
|
* @return An array of the names of the supported hash algorithms, such as `'RSA-SHA256'`. Hash algorithms are also called "digest" algorithms.
|
|
2288
2194
|
*/
|
|
2289
2195
|
function getHashes(): string[];
|
|
2196
|
+
type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
|
|
2290
2197
|
/**
|
|
2291
2198
|
* The `ECDH` class is a utility for creating Elliptic Curve Diffie-Hellman (ECDH)
|
|
2292
2199
|
* key exchanges.
|
|
@@ -2359,15 +2266,21 @@ declare module "crypto" {
|
|
|
2359
2266
|
* @since v10.0.0
|
|
2360
2267
|
* @param inputEncoding The `encoding` of the `key` string.
|
|
2361
2268
|
* @param outputEncoding The `encoding` of the return value.
|
|
2362
|
-
* @param [format='uncompressed']
|
|
2363
2269
|
*/
|
|
2364
2270
|
static convertKey(
|
|
2365
2271
|
key: BinaryLike,
|
|
2366
2272
|
curve: string,
|
|
2367
|
-
inputEncoding?:
|
|
2368
|
-
outputEncoding?:
|
|
2273
|
+
inputEncoding?: BufferEncoding,
|
|
2274
|
+
outputEncoding?: null,
|
|
2275
|
+
format?: "uncompressed" | "compressed" | "hybrid",
|
|
2276
|
+
): NonSharedBuffer;
|
|
2277
|
+
static convertKey(
|
|
2278
|
+
key: BinaryLike,
|
|
2279
|
+
curve: string,
|
|
2280
|
+
inputEncoding: BufferEncoding | null | undefined,
|
|
2281
|
+
outputEncoding: BufferEncoding,
|
|
2369
2282
|
format?: "uncompressed" | "compressed" | "hybrid",
|
|
2370
|
-
):
|
|
2283
|
+
): string;
|
|
2371
2284
|
/**
|
|
2372
2285
|
* Generates private and public EC Diffie-Hellman key values, and returns
|
|
2373
2286
|
* the public key in the specified `format` and `encoding`. This key should be
|
|
@@ -2380,8 +2293,8 @@ declare module "crypto" {
|
|
|
2380
2293
|
* @param encoding The `encoding` of the return value.
|
|
2381
2294
|
* @param [format='uncompressed']
|
|
2382
2295
|
*/
|
|
2383
|
-
generateKeys(): NonSharedBuffer;
|
|
2384
|
-
generateKeys(encoding:
|
|
2296
|
+
generateKeys(encoding?: null, format?: ECDHKeyFormat): NonSharedBuffer;
|
|
2297
|
+
generateKeys(encoding: BufferEncoding, format?: ECDHKeyFormat): string;
|
|
2385
2298
|
/**
|
|
2386
2299
|
* Computes the shared secret using `otherPublicKey` as the other
|
|
2387
2300
|
* party's public key and returns the computed shared secret. The supplied
|
|
@@ -2399,13 +2312,11 @@ declare module "crypto" {
|
|
|
2399
2312
|
* @param inputEncoding The `encoding` of the `otherPublicKey` string.
|
|
2400
2313
|
* @param outputEncoding The `encoding` of the return value.
|
|
2401
2314
|
*/
|
|
2402
|
-
computeSecret(otherPublicKey:
|
|
2403
|
-
computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding): NonSharedBuffer;
|
|
2404
|
-
computeSecret(otherPublicKey: NodeJS.ArrayBufferView, outputEncoding: BinaryToTextEncoding): string;
|
|
2315
|
+
computeSecret(otherPublicKey: BinaryLike, inputEncoding?: BufferEncoding): NonSharedBuffer;
|
|
2405
2316
|
computeSecret(
|
|
2406
|
-
otherPublicKey:
|
|
2407
|
-
inputEncoding:
|
|
2408
|
-
outputEncoding:
|
|
2317
|
+
otherPublicKey: BinaryLike,
|
|
2318
|
+
inputEncoding: BufferEncoding | null | undefined,
|
|
2319
|
+
outputEncoding: BufferEncoding,
|
|
2409
2320
|
): string;
|
|
2410
2321
|
/**
|
|
2411
2322
|
* If `encoding` is specified, a string is returned; otherwise a `Buffer` is
|
|
@@ -2415,7 +2326,7 @@ declare module "crypto" {
|
|
|
2415
2326
|
* @return The EC Diffie-Hellman in the specified `encoding`.
|
|
2416
2327
|
*/
|
|
2417
2328
|
getPrivateKey(): NonSharedBuffer;
|
|
2418
|
-
getPrivateKey(encoding:
|
|
2329
|
+
getPrivateKey(encoding: BufferEncoding): string;
|
|
2419
2330
|
/**
|
|
2420
2331
|
* 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.
|
|
2421
2332
|
*
|
|
@@ -2427,7 +2338,7 @@ declare module "crypto" {
|
|
|
2427
2338
|
* @return The EC Diffie-Hellman public key in the specified `encoding` and `format`.
|
|
2428
2339
|
*/
|
|
2429
2340
|
getPublicKey(encoding?: null, format?: ECDHKeyFormat): NonSharedBuffer;
|
|
2430
|
-
getPublicKey(encoding:
|
|
2341
|
+
getPublicKey(encoding: BufferEncoding, format?: ECDHKeyFormat): string;
|
|
2431
2342
|
/**
|
|
2432
2343
|
* Sets the EC Diffie-Hellman private key.
|
|
2433
2344
|
* If `encoding` is provided, `privateKey` is expected
|
|
@@ -2439,8 +2350,7 @@ declare module "crypto" {
|
|
|
2439
2350
|
* @since v0.11.14
|
|
2440
2351
|
* @param encoding The `encoding` of the `privateKey` string.
|
|
2441
2352
|
*/
|
|
2442
|
-
setPrivateKey(privateKey:
|
|
2443
|
-
setPrivateKey(privateKey: string, encoding: BinaryToTextEncoding): void;
|
|
2353
|
+
setPrivateKey(privateKey: BinaryLike, encoding?: BufferEncoding): void;
|
|
2444
2354
|
}
|
|
2445
2355
|
/**
|
|
2446
2356
|
* Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a
|
|
@@ -2475,193 +2385,45 @@ declare module "crypto" {
|
|
|
2475
2385
|
* not introduce timing vulnerabilities.
|
|
2476
2386
|
* @since v6.6.0
|
|
2477
2387
|
*/
|
|
2478
|
-
function timingSafeEqual(
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2388
|
+
function timingSafeEqual(
|
|
2389
|
+
a: ArrayBufferLike | NodeJS.ArrayBufferView,
|
|
2390
|
+
b: ArrayBufferLike | NodeJS.ArrayBufferView,
|
|
2391
|
+
): boolean;
|
|
2392
|
+
interface DHKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {
|
|
2393
|
+
prime?: NodeJS.ArrayBufferView | undefined;
|
|
2394
|
+
primeLength?: number | undefined;
|
|
2395
|
+
generator?: number | undefined;
|
|
2396
|
+
groupName?: string | undefined;
|
|
2485
2397
|
}
|
|
2486
|
-
interface
|
|
2487
|
-
|
|
2488
|
-
|
|
2398
|
+
interface DSAKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {
|
|
2399
|
+
modulusLength: number;
|
|
2400
|
+
divisorLength?: number | undefined;
|
|
2489
2401
|
}
|
|
2490
|
-
interface
|
|
2491
|
-
interface ED448KeyPairKeyObjectOptions {}
|
|
2492
|
-
interface X25519KeyPairKeyObjectOptions {}
|
|
2493
|
-
interface X448KeyPairKeyObjectOptions {}
|
|
2494
|
-
interface ECKeyPairKeyObjectOptions {
|
|
2495
|
-
/**
|
|
2496
|
-
* Name of the curve to use
|
|
2497
|
-
*/
|
|
2402
|
+
interface ECKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8" | "sec1"> {
|
|
2498
2403
|
namedCurve: string;
|
|
2499
|
-
/**
|
|
2500
|
-
* Must be `'named'` or `'explicit'`. Default: `'named'`.
|
|
2501
|
-
*/
|
|
2502
2404
|
paramEncoding?: "explicit" | "named" | undefined;
|
|
2503
2405
|
}
|
|
2504
|
-
interface
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
/**
|
|
2510
|
-
* Public exponent
|
|
2511
|
-
* @default 0x10001
|
|
2512
|
-
*/
|
|
2513
|
-
publicExponent?: number | undefined;
|
|
2514
|
-
}
|
|
2515
|
-
interface RSAPSSKeyPairKeyObjectOptions {
|
|
2516
|
-
/**
|
|
2517
|
-
* Key size in bits
|
|
2518
|
-
*/
|
|
2406
|
+
interface ED25519KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2407
|
+
interface ED448KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2408
|
+
interface MLDSAKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2409
|
+
interface MLKEMKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2410
|
+
interface RSAPSSKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {
|
|
2519
2411
|
modulusLength: number;
|
|
2520
|
-
/**
|
|
2521
|
-
* Public exponent
|
|
2522
|
-
* @default 0x10001
|
|
2523
|
-
*/
|
|
2524
2412
|
publicExponent?: number | undefined;
|
|
2525
|
-
/**
|
|
2526
|
-
* Name of the message digest
|
|
2527
|
-
*/
|
|
2528
2413
|
hashAlgorithm?: string | undefined;
|
|
2529
|
-
/**
|
|
2530
|
-
* Name of the message digest used by MGF1
|
|
2531
|
-
*/
|
|
2532
2414
|
mgf1HashAlgorithm?: string | undefined;
|
|
2533
|
-
/**
|
|
2534
|
-
* Minimal salt length in bytes
|
|
2535
|
-
*/
|
|
2536
2415
|
saltLength?: string | undefined;
|
|
2537
2416
|
}
|
|
2538
|
-
interface
|
|
2539
|
-
/**
|
|
2540
|
-
* Key size in bits
|
|
2541
|
-
*/
|
|
2542
|
-
modulusLength: number;
|
|
2543
|
-
/**
|
|
2544
|
-
* Size of q in bits
|
|
2545
|
-
*/
|
|
2546
|
-
divisorLength: number;
|
|
2547
|
-
}
|
|
2548
|
-
interface RSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
|
2549
|
-
/**
|
|
2550
|
-
* Key size in bits
|
|
2551
|
-
*/
|
|
2552
|
-
modulusLength: number;
|
|
2553
|
-
/**
|
|
2554
|
-
* Public exponent
|
|
2555
|
-
* @default 0x10001
|
|
2556
|
-
*/
|
|
2557
|
-
publicExponent?: number | undefined;
|
|
2558
|
-
publicKeyEncoding: {
|
|
2559
|
-
type: "pkcs1" | "spki";
|
|
2560
|
-
format: PubF;
|
|
2561
|
-
};
|
|
2562
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2563
|
-
type: "pkcs1" | "pkcs8";
|
|
2564
|
-
};
|
|
2565
|
-
}
|
|
2566
|
-
interface RSAPSSKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
|
2567
|
-
/**
|
|
2568
|
-
* Key size in bits
|
|
2569
|
-
*/
|
|
2417
|
+
interface RSAKeyPairOptions extends KeyPairExportOptions<"pkcs1" | "spki", "pkcs1" | "pkcs8"> {
|
|
2570
2418
|
modulusLength: number;
|
|
2571
|
-
/**
|
|
2572
|
-
* Public exponent
|
|
2573
|
-
* @default 0x10001
|
|
2574
|
-
*/
|
|
2575
2419
|
publicExponent?: number | undefined;
|
|
2576
|
-
/**
|
|
2577
|
-
* Name of the message digest
|
|
2578
|
-
*/
|
|
2579
|
-
hashAlgorithm?: string | undefined;
|
|
2580
|
-
/**
|
|
2581
|
-
* Name of the message digest used by MGF1
|
|
2582
|
-
*/
|
|
2583
|
-
mgf1HashAlgorithm?: string | undefined;
|
|
2584
|
-
/**
|
|
2585
|
-
* Minimal salt length in bytes
|
|
2586
|
-
*/
|
|
2587
|
-
saltLength?: string | undefined;
|
|
2588
|
-
publicKeyEncoding: {
|
|
2589
|
-
type: "spki";
|
|
2590
|
-
format: PubF;
|
|
2591
|
-
};
|
|
2592
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2593
|
-
type: "pkcs8";
|
|
2594
|
-
};
|
|
2595
|
-
}
|
|
2596
|
-
interface DSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
|
2597
|
-
/**
|
|
2598
|
-
* Key size in bits
|
|
2599
|
-
*/
|
|
2600
|
-
modulusLength: number;
|
|
2601
|
-
/**
|
|
2602
|
-
* Size of q in bits
|
|
2603
|
-
*/
|
|
2604
|
-
divisorLength: number;
|
|
2605
|
-
publicKeyEncoding: {
|
|
2606
|
-
type: "spki";
|
|
2607
|
-
format: PubF;
|
|
2608
|
-
};
|
|
2609
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2610
|
-
type: "pkcs8";
|
|
2611
|
-
};
|
|
2612
|
-
}
|
|
2613
|
-
interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> extends ECKeyPairKeyObjectOptions {
|
|
2614
|
-
publicKeyEncoding: {
|
|
2615
|
-
type: "pkcs1" | "spki";
|
|
2616
|
-
format: PubF;
|
|
2617
|
-
};
|
|
2618
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2619
|
-
type: "sec1" | "pkcs8";
|
|
2620
|
-
};
|
|
2621
|
-
}
|
|
2622
|
-
interface ED25519KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
|
2623
|
-
publicKeyEncoding: {
|
|
2624
|
-
type: "spki";
|
|
2625
|
-
format: PubF;
|
|
2626
|
-
};
|
|
2627
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2628
|
-
type: "pkcs8";
|
|
2629
|
-
};
|
|
2630
|
-
}
|
|
2631
|
-
interface ED448KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
|
2632
|
-
publicKeyEncoding: {
|
|
2633
|
-
type: "spki";
|
|
2634
|
-
format: PubF;
|
|
2635
|
-
};
|
|
2636
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2637
|
-
type: "pkcs8";
|
|
2638
|
-
};
|
|
2639
|
-
}
|
|
2640
|
-
interface X25519KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
|
2641
|
-
publicKeyEncoding: {
|
|
2642
|
-
type: "spki";
|
|
2643
|
-
format: PubF;
|
|
2644
|
-
};
|
|
2645
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2646
|
-
type: "pkcs8";
|
|
2647
|
-
};
|
|
2648
|
-
}
|
|
2649
|
-
interface X448KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
|
2650
|
-
publicKeyEncoding: {
|
|
2651
|
-
type: "spki";
|
|
2652
|
-
format: PubF;
|
|
2653
|
-
};
|
|
2654
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2655
|
-
type: "pkcs8";
|
|
2656
|
-
};
|
|
2657
|
-
}
|
|
2658
|
-
interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
|
|
2659
|
-
publicKey: T1;
|
|
2660
|
-
privateKey: T2;
|
|
2661
2420
|
}
|
|
2421
|
+
interface SLHDSAKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2422
|
+
interface X25519KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2423
|
+
interface X448KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2662
2424
|
/**
|
|
2663
|
-
* Generates a new asymmetric key pair of the given `type`.
|
|
2664
|
-
*
|
|
2425
|
+
* Generates a new asymmetric key pair of the given `type`. See the
|
|
2426
|
+
* supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
|
|
2665
2427
|
*
|
|
2666
2428
|
* If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
|
|
2667
2429
|
* behaves as if `keyObject.export()` had been called on its result. Otherwise,
|
|
@@ -2698,147 +2460,60 @@ declare module "crypto" {
|
|
|
2698
2460
|
* When PEM encoding was selected, the respective key will be a string, otherwise
|
|
2699
2461
|
* it will be a buffer containing the data encoded as DER.
|
|
2700
2462
|
* @since v10.12.0
|
|
2701
|
-
* @param type
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
options: RSAKeyPairOptions<"pem", "der">,
|
|
2710
|
-
): KeyPairSyncResult<string, NonSharedBuffer>;
|
|
2711
|
-
function generateKeyPairSync(
|
|
2712
|
-
type: "rsa",
|
|
2713
|
-
options: RSAKeyPairOptions<"der", "pem">,
|
|
2714
|
-
): KeyPairSyncResult<NonSharedBuffer, string>;
|
|
2715
|
-
function generateKeyPairSync(
|
|
2716
|
-
type: "rsa",
|
|
2717
|
-
options: RSAKeyPairOptions<"der", "der">,
|
|
2718
|
-
): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
|
|
2719
|
-
function generateKeyPairSync(type: "rsa", options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
|
2720
|
-
function generateKeyPairSync(
|
|
2721
|
-
type: "rsa-pss",
|
|
2722
|
-
options: RSAPSSKeyPairOptions<"pem", "pem">,
|
|
2723
|
-
): KeyPairSyncResult<string, string>;
|
|
2724
|
-
function generateKeyPairSync(
|
|
2725
|
-
type: "rsa-pss",
|
|
2726
|
-
options: RSAPSSKeyPairOptions<"pem", "der">,
|
|
2727
|
-
): KeyPairSyncResult<string, NonSharedBuffer>;
|
|
2728
|
-
function generateKeyPairSync(
|
|
2729
|
-
type: "rsa-pss",
|
|
2730
|
-
options: RSAPSSKeyPairOptions<"der", "pem">,
|
|
2731
|
-
): KeyPairSyncResult<NonSharedBuffer, string>;
|
|
2732
|
-
function generateKeyPairSync(
|
|
2733
|
-
type: "rsa-pss",
|
|
2734
|
-
options: RSAPSSKeyPairOptions<"der", "der">,
|
|
2735
|
-
): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
|
|
2736
|
-
function generateKeyPairSync(type: "rsa-pss", options: RSAPSSKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
|
2737
|
-
function generateKeyPairSync(
|
|
2463
|
+
* @param type The asymmetric key type to generate. See the
|
|
2464
|
+
* supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
|
|
2465
|
+
*/
|
|
2466
|
+
function generateKeyPairSync<T extends DHKeyPairOptions>(
|
|
2467
|
+
type: "dh",
|
|
2468
|
+
options: T,
|
|
2469
|
+
): KeyPairExportResult<T>;
|
|
2470
|
+
function generateKeyPairSync<T extends DSAKeyPairOptions>(
|
|
2738
2471
|
type: "dsa",
|
|
2739
|
-
options:
|
|
2740
|
-
):
|
|
2741
|
-
function generateKeyPairSync(
|
|
2742
|
-
type: "dsa",
|
|
2743
|
-
options: DSAKeyPairOptions<"pem", "der">,
|
|
2744
|
-
): KeyPairSyncResult<string, NonSharedBuffer>;
|
|
2745
|
-
function generateKeyPairSync(
|
|
2746
|
-
type: "dsa",
|
|
2747
|
-
options: DSAKeyPairOptions<"der", "pem">,
|
|
2748
|
-
): KeyPairSyncResult<NonSharedBuffer, string>;
|
|
2749
|
-
function generateKeyPairSync(
|
|
2750
|
-
type: "dsa",
|
|
2751
|
-
options: DSAKeyPairOptions<"der", "der">,
|
|
2752
|
-
): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
|
|
2753
|
-
function generateKeyPairSync(type: "dsa", options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
|
2754
|
-
function generateKeyPairSync(
|
|
2755
|
-
type: "ec",
|
|
2756
|
-
options: ECKeyPairOptions<"pem", "pem">,
|
|
2757
|
-
): KeyPairSyncResult<string, string>;
|
|
2758
|
-
function generateKeyPairSync(
|
|
2472
|
+
options: T,
|
|
2473
|
+
): KeyPairExportResult<T>;
|
|
2474
|
+
function generateKeyPairSync<T extends ECKeyPairOptions>(
|
|
2759
2475
|
type: "ec",
|
|
2760
|
-
options:
|
|
2761
|
-
):
|
|
2762
|
-
function generateKeyPairSync(
|
|
2763
|
-
type: "ec",
|
|
2764
|
-
options: ECKeyPairOptions<"der", "pem">,
|
|
2765
|
-
): KeyPairSyncResult<NonSharedBuffer, string>;
|
|
2766
|
-
function generateKeyPairSync(
|
|
2767
|
-
type: "ec",
|
|
2768
|
-
options: ECKeyPairOptions<"der", "der">,
|
|
2769
|
-
): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
|
|
2770
|
-
function generateKeyPairSync(type: "ec", options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
|
2771
|
-
function generateKeyPairSync(
|
|
2772
|
-
type: "ed25519",
|
|
2773
|
-
options: ED25519KeyPairOptions<"pem", "pem">,
|
|
2774
|
-
): KeyPairSyncResult<string, string>;
|
|
2775
|
-
function generateKeyPairSync(
|
|
2476
|
+
options: T,
|
|
2477
|
+
): KeyPairExportResult<T>;
|
|
2478
|
+
function generateKeyPairSync<T extends ED25519KeyPairOptions = {}>(
|
|
2776
2479
|
type: "ed25519",
|
|
2777
|
-
options
|
|
2778
|
-
):
|
|
2779
|
-
function generateKeyPairSync(
|
|
2780
|
-
type: "ed25519",
|
|
2781
|
-
options: ED25519KeyPairOptions<"der", "pem">,
|
|
2782
|
-
): KeyPairSyncResult<NonSharedBuffer, string>;
|
|
2783
|
-
function generateKeyPairSync(
|
|
2784
|
-
type: "ed25519",
|
|
2785
|
-
options: ED25519KeyPairOptions<"der", "der">,
|
|
2786
|
-
): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
|
|
2787
|
-
function generateKeyPairSync(type: "ed25519", options?: ED25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
|
2788
|
-
function generateKeyPairSync(
|
|
2789
|
-
type: "ed448",
|
|
2790
|
-
options: ED448KeyPairOptions<"pem", "pem">,
|
|
2791
|
-
): KeyPairSyncResult<string, string>;
|
|
2792
|
-
function generateKeyPairSync(
|
|
2480
|
+
options?: T,
|
|
2481
|
+
): KeyPairExportResult<T>;
|
|
2482
|
+
function generateKeyPairSync<T extends ED448KeyPairOptions = {}>(
|
|
2793
2483
|
type: "ed448",
|
|
2794
|
-
options
|
|
2795
|
-
):
|
|
2796
|
-
function generateKeyPairSync(
|
|
2797
|
-
type:
|
|
2798
|
-
options
|
|
2799
|
-
):
|
|
2800
|
-
function generateKeyPairSync(
|
|
2801
|
-
type:
|
|
2802
|
-
options
|
|
2803
|
-
):
|
|
2804
|
-
function generateKeyPairSync
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
function generateKeyPairSync(
|
|
2484
|
+
options?: T,
|
|
2485
|
+
): KeyPairExportResult<T>;
|
|
2486
|
+
function generateKeyPairSync<T extends MLDSAKeyPairOptions = {}>(
|
|
2487
|
+
type: MLDSAKeyType,
|
|
2488
|
+
options?: T,
|
|
2489
|
+
): KeyPairExportResult<T>;
|
|
2490
|
+
function generateKeyPairSync<T extends MLKEMKeyPairOptions = {}>(
|
|
2491
|
+
type: MLKEMKeyType,
|
|
2492
|
+
options?: T,
|
|
2493
|
+
): KeyPairExportResult<T>;
|
|
2494
|
+
function generateKeyPairSync<T extends RSAPSSKeyPairOptions>(
|
|
2495
|
+
type: "rsa-pss",
|
|
2496
|
+
options: T,
|
|
2497
|
+
): KeyPairExportResult<T>;
|
|
2498
|
+
function generateKeyPairSync<T extends RSAKeyPairOptions>(
|
|
2499
|
+
type: "rsa",
|
|
2500
|
+
options: T,
|
|
2501
|
+
): KeyPairExportResult<T>;
|
|
2502
|
+
function generateKeyPairSync<T extends SLHDSAKeyPairOptions = {}>(
|
|
2503
|
+
type: SLHDSAKeyType,
|
|
2504
|
+
options?: T,
|
|
2505
|
+
): KeyPairExportResult<T>;
|
|
2506
|
+
function generateKeyPairSync<T extends X25519KeyPairOptions = {}>(
|
|
2818
2507
|
type: "x25519",
|
|
2819
|
-
options
|
|
2820
|
-
):
|
|
2821
|
-
function generateKeyPairSync
|
|
2822
|
-
function generateKeyPairSync(
|
|
2823
|
-
type: "x448",
|
|
2824
|
-
options: X448KeyPairOptions<"pem", "pem">,
|
|
2825
|
-
): KeyPairSyncResult<string, string>;
|
|
2826
|
-
function generateKeyPairSync(
|
|
2827
|
-
type: "x448",
|
|
2828
|
-
options: X448KeyPairOptions<"pem", "der">,
|
|
2829
|
-
): KeyPairSyncResult<string, NonSharedBuffer>;
|
|
2830
|
-
function generateKeyPairSync(
|
|
2508
|
+
options?: T,
|
|
2509
|
+
): KeyPairExportResult<T>;
|
|
2510
|
+
function generateKeyPairSync<T extends X448KeyPairOptions = {}>(
|
|
2831
2511
|
type: "x448",
|
|
2832
|
-
options
|
|
2833
|
-
):
|
|
2834
|
-
function generateKeyPairSync(
|
|
2835
|
-
type: "x448",
|
|
2836
|
-
options: X448KeyPairOptions<"der", "der">,
|
|
2837
|
-
): KeyPairSyncResult<NonSharedBuffer, NonSharedBuffer>;
|
|
2838
|
-
function generateKeyPairSync(type: "x448", options?: X448KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
|
2512
|
+
options?: T,
|
|
2513
|
+
): KeyPairExportResult<T>;
|
|
2839
2514
|
/**
|
|
2840
|
-
* Generates a new asymmetric key pair of the given `type`.
|
|
2841
|
-
*
|
|
2515
|
+
* Generates a new asymmetric key pair of the given `type`. See the
|
|
2516
|
+
* supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
|
|
2842
2517
|
*
|
|
2843
2518
|
* If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
|
|
2844
2519
|
* behaves as if `keyObject.export()` had been called on its result. Otherwise,
|
|
@@ -2873,481 +2548,188 @@ declare module "crypto" {
|
|
|
2873
2548
|
* If this method is invoked as its `util.promisify()` ed version, it returns
|
|
2874
2549
|
* a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
|
|
2875
2550
|
* @since v10.12.0
|
|
2876
|
-
* @param type
|
|
2551
|
+
* @param type The asymmetric key type to generate. See the
|
|
2552
|
+
* supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
|
|
2877
2553
|
*/
|
|
2878
|
-
function generateKeyPair(
|
|
2879
|
-
type: "
|
|
2880
|
-
options:
|
|
2881
|
-
callback:
|
|
2882
|
-
): void;
|
|
2883
|
-
function generateKeyPair(
|
|
2884
|
-
type: "rsa",
|
|
2885
|
-
options: RSAKeyPairOptions<"pem", "der">,
|
|
2886
|
-
callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
|
|
2887
|
-
): void;
|
|
2888
|
-
function generateKeyPair(
|
|
2889
|
-
type: "rsa",
|
|
2890
|
-
options: RSAKeyPairOptions<"der", "pem">,
|
|
2891
|
-
callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
|
|
2892
|
-
): void;
|
|
2893
|
-
function generateKeyPair(
|
|
2894
|
-
type: "rsa",
|
|
2895
|
-
options: RSAKeyPairOptions<"der", "der">,
|
|
2896
|
-
callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
|
|
2897
|
-
): void;
|
|
2898
|
-
function generateKeyPair(
|
|
2899
|
-
type: "rsa",
|
|
2900
|
-
options: RSAKeyPairKeyObjectOptions,
|
|
2901
|
-
callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
|
|
2902
|
-
): void;
|
|
2903
|
-
function generateKeyPair(
|
|
2904
|
-
type: "rsa-pss",
|
|
2905
|
-
options: RSAPSSKeyPairOptions<"pem", "pem">,
|
|
2906
|
-
callback: (err: Error | null, publicKey: string, privateKey: string) => void,
|
|
2907
|
-
): void;
|
|
2908
|
-
function generateKeyPair(
|
|
2909
|
-
type: "rsa-pss",
|
|
2910
|
-
options: RSAPSSKeyPairOptions<"pem", "der">,
|
|
2911
|
-
callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
|
|
2912
|
-
): void;
|
|
2913
|
-
function generateKeyPair(
|
|
2914
|
-
type: "rsa-pss",
|
|
2915
|
-
options: RSAPSSKeyPairOptions<"der", "pem">,
|
|
2916
|
-
callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
|
|
2917
|
-
): void;
|
|
2918
|
-
function generateKeyPair(
|
|
2919
|
-
type: "rsa-pss",
|
|
2920
|
-
options: RSAPSSKeyPairOptions<"der", "der">,
|
|
2921
|
-
callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
|
|
2922
|
-
): void;
|
|
2923
|
-
function generateKeyPair(
|
|
2924
|
-
type: "rsa-pss",
|
|
2925
|
-
options: RSAPSSKeyPairKeyObjectOptions,
|
|
2926
|
-
callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
|
|
2554
|
+
function generateKeyPair<T extends DHKeyPairOptions>(
|
|
2555
|
+
type: "dh",
|
|
2556
|
+
options: T,
|
|
2557
|
+
callback: KeyPairExportCallback<T>,
|
|
2927
2558
|
): void;
|
|
2928
|
-
function generateKeyPair(
|
|
2929
|
-
type: "dsa",
|
|
2930
|
-
options: DSAKeyPairOptions<"pem", "pem">,
|
|
2931
|
-
callback: (err: Error | null, publicKey: string, privateKey: string) => void,
|
|
2932
|
-
): void;
|
|
2933
|
-
function generateKeyPair(
|
|
2934
|
-
type: "dsa",
|
|
2935
|
-
options: DSAKeyPairOptions<"pem", "der">,
|
|
2936
|
-
callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
|
|
2937
|
-
): void;
|
|
2938
|
-
function generateKeyPair(
|
|
2939
|
-
type: "dsa",
|
|
2940
|
-
options: DSAKeyPairOptions<"der", "pem">,
|
|
2941
|
-
callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
|
|
2942
|
-
): void;
|
|
2943
|
-
function generateKeyPair(
|
|
2944
|
-
type: "dsa",
|
|
2945
|
-
options: DSAKeyPairOptions<"der", "der">,
|
|
2946
|
-
callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
|
|
2947
|
-
): void;
|
|
2948
|
-
function generateKeyPair(
|
|
2559
|
+
function generateKeyPair<T extends DSAKeyPairOptions>(
|
|
2949
2560
|
type: "dsa",
|
|
2950
|
-
options:
|
|
2951
|
-
callback:
|
|
2561
|
+
options: T,
|
|
2562
|
+
callback: KeyPairExportCallback<T>,
|
|
2952
2563
|
): void;
|
|
2953
|
-
function generateKeyPair(
|
|
2954
|
-
type: "ec",
|
|
2955
|
-
options: ECKeyPairOptions<"pem", "pem">,
|
|
2956
|
-
callback: (err: Error | null, publicKey: string, privateKey: string) => void,
|
|
2957
|
-
): void;
|
|
2958
|
-
function generateKeyPair(
|
|
2959
|
-
type: "ec",
|
|
2960
|
-
options: ECKeyPairOptions<"pem", "der">,
|
|
2961
|
-
callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
|
|
2962
|
-
): void;
|
|
2963
|
-
function generateKeyPair(
|
|
2964
|
-
type: "ec",
|
|
2965
|
-
options: ECKeyPairOptions<"der", "pem">,
|
|
2966
|
-
callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
|
|
2967
|
-
): void;
|
|
2968
|
-
function generateKeyPair(
|
|
2564
|
+
function generateKeyPair<T extends ECKeyPairOptions>(
|
|
2969
2565
|
type: "ec",
|
|
2970
|
-
options:
|
|
2971
|
-
callback:
|
|
2972
|
-
): void;
|
|
2973
|
-
function generateKeyPair(
|
|
2974
|
-
type: "ec",
|
|
2975
|
-
options: ECKeyPairKeyObjectOptions,
|
|
2976
|
-
callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
|
|
2977
|
-
): void;
|
|
2978
|
-
function generateKeyPair(
|
|
2979
|
-
type: "ed25519",
|
|
2980
|
-
options: ED25519KeyPairOptions<"pem", "pem">,
|
|
2981
|
-
callback: (err: Error | null, publicKey: string, privateKey: string) => void,
|
|
2982
|
-
): void;
|
|
2983
|
-
function generateKeyPair(
|
|
2984
|
-
type: "ed25519",
|
|
2985
|
-
options: ED25519KeyPairOptions<"pem", "der">,
|
|
2986
|
-
callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
|
|
2987
|
-
): void;
|
|
2988
|
-
function generateKeyPair(
|
|
2989
|
-
type: "ed25519",
|
|
2990
|
-
options: ED25519KeyPairOptions<"der", "pem">,
|
|
2991
|
-
callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: string) => void,
|
|
2566
|
+
options: T,
|
|
2567
|
+
callback: KeyPairExportCallback<T>,
|
|
2992
2568
|
): void;
|
|
2993
2569
|
function generateKeyPair(
|
|
2994
2570
|
type: "ed25519",
|
|
2995
|
-
|
|
2996
|
-
callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
|
|
2571
|
+
callback: KeyPairExportCallback,
|
|
2997
2572
|
): void;
|
|
2998
|
-
function generateKeyPair(
|
|
2573
|
+
function generateKeyPair<T extends ED25519KeyPairOptions = {}>(
|
|
2999
2574
|
type: "ed25519",
|
|
3000
|
-
options:
|
|
3001
|
-
callback:
|
|
3002
|
-
): void;
|
|
3003
|
-
function generateKeyPair(
|
|
3004
|
-
type: "ed448",
|
|
3005
|
-
options: ED448KeyPairOptions<"pem", "pem">,
|
|
3006
|
-
callback: (err: Error | null, publicKey: string, privateKey: string) => void,
|
|
2575
|
+
options: T | undefined,
|
|
2576
|
+
callback: KeyPairExportCallback<T>,
|
|
3007
2577
|
): void;
|
|
3008
2578
|
function generateKeyPair(
|
|
3009
2579
|
type: "ed448",
|
|
3010
|
-
|
|
3011
|
-
callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
|
|
2580
|
+
callback: KeyPairExportCallback,
|
|
3012
2581
|
): void;
|
|
3013
|
-
function generateKeyPair(
|
|
2582
|
+
function generateKeyPair<T extends ED448KeyPairOptions = {}>(
|
|
3014
2583
|
type: "ed448",
|
|
3015
|
-
options:
|
|
3016
|
-
callback:
|
|
2584
|
+
options: T | undefined,
|
|
2585
|
+
callback: KeyPairExportCallback<T>,
|
|
3017
2586
|
): void;
|
|
3018
2587
|
function generateKeyPair(
|
|
3019
|
-
type:
|
|
3020
|
-
|
|
3021
|
-
callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
|
|
2588
|
+
type: MLDSAKeyType,
|
|
2589
|
+
callback: KeyPairExportCallback,
|
|
3022
2590
|
): void;
|
|
3023
|
-
function generateKeyPair(
|
|
3024
|
-
type:
|
|
3025
|
-
options:
|
|
3026
|
-
callback:
|
|
2591
|
+
function generateKeyPair<T extends MLDSAKeyPairOptions = {}>(
|
|
2592
|
+
type: MLDSAKeyType,
|
|
2593
|
+
options: T | undefined,
|
|
2594
|
+
callback: KeyPairExportCallback<T>,
|
|
3027
2595
|
): void;
|
|
3028
2596
|
function generateKeyPair(
|
|
3029
|
-
type:
|
|
3030
|
-
|
|
3031
|
-
callback: (err: Error | null, publicKey: string, privateKey: string) => void,
|
|
2597
|
+
type: MLKEMKeyType,
|
|
2598
|
+
callback: KeyPairExportCallback,
|
|
3032
2599
|
): void;
|
|
3033
|
-
function generateKeyPair(
|
|
3034
|
-
type:
|
|
3035
|
-
options:
|
|
3036
|
-
callback:
|
|
2600
|
+
function generateKeyPair<T extends MLKEMKeyPairOptions = {}>(
|
|
2601
|
+
type: MLKEMKeyType,
|
|
2602
|
+
options: T | undefined,
|
|
2603
|
+
callback: KeyPairExportCallback<T>,
|
|
3037
2604
|
): void;
|
|
3038
|
-
function generateKeyPair(
|
|
3039
|
-
type: "
|
|
3040
|
-
options:
|
|
3041
|
-
callback:
|
|
2605
|
+
function generateKeyPair<T extends RSAPSSKeyPairOptions>(
|
|
2606
|
+
type: "rsa-pss",
|
|
2607
|
+
options: T,
|
|
2608
|
+
callback: KeyPairExportCallback<T>,
|
|
3042
2609
|
): void;
|
|
3043
|
-
function generateKeyPair(
|
|
3044
|
-
type: "
|
|
3045
|
-
options:
|
|
3046
|
-
callback:
|
|
2610
|
+
function generateKeyPair<T extends RSAKeyPairOptions>(
|
|
2611
|
+
type: "rsa",
|
|
2612
|
+
options: T,
|
|
2613
|
+
callback: KeyPairExportCallback<T>,
|
|
3047
2614
|
): void;
|
|
3048
2615
|
function generateKeyPair(
|
|
3049
|
-
type:
|
|
3050
|
-
|
|
3051
|
-
callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
|
|
2616
|
+
type: SLHDSAKeyType,
|
|
2617
|
+
callback: KeyPairExportCallback,
|
|
3052
2618
|
): void;
|
|
3053
|
-
function generateKeyPair(
|
|
3054
|
-
type:
|
|
3055
|
-
options:
|
|
3056
|
-
callback:
|
|
2619
|
+
function generateKeyPair<T extends SLHDSAKeyPairOptions = {}>(
|
|
2620
|
+
type: SLHDSAKeyType,
|
|
2621
|
+
options: T | undefined,
|
|
2622
|
+
callback: KeyPairExportCallback<T>,
|
|
3057
2623
|
): void;
|
|
3058
2624
|
function generateKeyPair(
|
|
3059
|
-
type: "
|
|
3060
|
-
|
|
3061
|
-
callback: (err: Error | null, publicKey: string, privateKey: NonSharedBuffer) => void,
|
|
2625
|
+
type: "x25519",
|
|
2626
|
+
callback: KeyPairExportCallback,
|
|
3062
2627
|
): void;
|
|
3063
|
-
function generateKeyPair(
|
|
3064
|
-
type: "
|
|
3065
|
-
options:
|
|
3066
|
-
callback:
|
|
2628
|
+
function generateKeyPair<T extends X25519KeyPairOptions = {}>(
|
|
2629
|
+
type: "x25519",
|
|
2630
|
+
options: T | undefined,
|
|
2631
|
+
callback: KeyPairExportCallback<T>,
|
|
3067
2632
|
): void;
|
|
3068
2633
|
function generateKeyPair(
|
|
3069
2634
|
type: "x448",
|
|
3070
|
-
|
|
3071
|
-
callback: (err: Error | null, publicKey: NonSharedBuffer, privateKey: NonSharedBuffer) => void,
|
|
2635
|
+
callback: KeyPairExportCallback,
|
|
3072
2636
|
): void;
|
|
3073
|
-
function generateKeyPair(
|
|
2637
|
+
function generateKeyPair<T extends X448KeyPairOptions = {}>(
|
|
3074
2638
|
type: "x448",
|
|
3075
|
-
options:
|
|
3076
|
-
callback:
|
|
2639
|
+
options: T | undefined,
|
|
2640
|
+
callback: KeyPairExportCallback<T>,
|
|
3077
2641
|
): void;
|
|
3078
2642
|
namespace generateKeyPair {
|
|
3079
|
-
function __promisify__(
|
|
3080
|
-
type: "
|
|
3081
|
-
options:
|
|
3082
|
-
): Promise<
|
|
3083
|
-
|
|
3084
|
-
privateKey: string;
|
|
3085
|
-
}>;
|
|
3086
|
-
function __promisify__(
|
|
3087
|
-
type: "rsa",
|
|
3088
|
-
options: RSAKeyPairOptions<"pem", "der">,
|
|
3089
|
-
): Promise<{
|
|
3090
|
-
publicKey: string;
|
|
3091
|
-
privateKey: NonSharedBuffer;
|
|
3092
|
-
}>;
|
|
3093
|
-
function __promisify__(
|
|
3094
|
-
type: "rsa",
|
|
3095
|
-
options: RSAKeyPairOptions<"der", "pem">,
|
|
3096
|
-
): Promise<{
|
|
3097
|
-
publicKey: NonSharedBuffer;
|
|
3098
|
-
privateKey: string;
|
|
3099
|
-
}>;
|
|
3100
|
-
function __promisify__(
|
|
3101
|
-
type: "rsa",
|
|
3102
|
-
options: RSAKeyPairOptions<"der", "der">,
|
|
3103
|
-
): Promise<{
|
|
3104
|
-
publicKey: NonSharedBuffer;
|
|
3105
|
-
privateKey: NonSharedBuffer;
|
|
3106
|
-
}>;
|
|
3107
|
-
function __promisify__(type: "rsa", options: RSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
|
|
3108
|
-
function __promisify__(
|
|
3109
|
-
type: "rsa-pss",
|
|
3110
|
-
options: RSAPSSKeyPairOptions<"pem", "pem">,
|
|
3111
|
-
): Promise<{
|
|
3112
|
-
publicKey: string;
|
|
3113
|
-
privateKey: string;
|
|
3114
|
-
}>;
|
|
3115
|
-
function __promisify__(
|
|
3116
|
-
type: "rsa-pss",
|
|
3117
|
-
options: RSAPSSKeyPairOptions<"pem", "der">,
|
|
3118
|
-
): Promise<{
|
|
3119
|
-
publicKey: string;
|
|
3120
|
-
privateKey: NonSharedBuffer;
|
|
3121
|
-
}>;
|
|
3122
|
-
function __promisify__(
|
|
3123
|
-
type: "rsa-pss",
|
|
3124
|
-
options: RSAPSSKeyPairOptions<"der", "pem">,
|
|
3125
|
-
): Promise<{
|
|
3126
|
-
publicKey: NonSharedBuffer;
|
|
3127
|
-
privateKey: string;
|
|
3128
|
-
}>;
|
|
3129
|
-
function __promisify__(
|
|
3130
|
-
type: "rsa-pss",
|
|
3131
|
-
options: RSAPSSKeyPairOptions<"der", "der">,
|
|
3132
|
-
): Promise<{
|
|
3133
|
-
publicKey: NonSharedBuffer;
|
|
3134
|
-
privateKey: NonSharedBuffer;
|
|
3135
|
-
}>;
|
|
3136
|
-
function __promisify__(
|
|
3137
|
-
type: "rsa-pss",
|
|
3138
|
-
options: RSAPSSKeyPairKeyObjectOptions,
|
|
3139
|
-
): Promise<KeyPairKeyObjectResult>;
|
|
3140
|
-
function __promisify__(
|
|
3141
|
-
type: "dsa",
|
|
3142
|
-
options: DSAKeyPairOptions<"pem", "pem">,
|
|
3143
|
-
): Promise<{
|
|
3144
|
-
publicKey: string;
|
|
3145
|
-
privateKey: string;
|
|
3146
|
-
}>;
|
|
3147
|
-
function __promisify__(
|
|
2643
|
+
function __promisify__<T extends DHKeyPairOptions>(
|
|
2644
|
+
type: "dh",
|
|
2645
|
+
options: T,
|
|
2646
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2647
|
+
function __promisify__<T extends DSAKeyPairOptions>(
|
|
3148
2648
|
type: "dsa",
|
|
3149
|
-
options:
|
|
3150
|
-
): Promise<
|
|
3151
|
-
|
|
3152
|
-
privateKey: NonSharedBuffer;
|
|
3153
|
-
}>;
|
|
3154
|
-
function __promisify__(
|
|
3155
|
-
type: "dsa",
|
|
3156
|
-
options: DSAKeyPairOptions<"der", "pem">,
|
|
3157
|
-
): Promise<{
|
|
3158
|
-
publicKey: NonSharedBuffer;
|
|
3159
|
-
privateKey: string;
|
|
3160
|
-
}>;
|
|
3161
|
-
function __promisify__(
|
|
3162
|
-
type: "dsa",
|
|
3163
|
-
options: DSAKeyPairOptions<"der", "der">,
|
|
3164
|
-
): Promise<{
|
|
3165
|
-
publicKey: NonSharedBuffer;
|
|
3166
|
-
privateKey: NonSharedBuffer;
|
|
3167
|
-
}>;
|
|
3168
|
-
function __promisify__(type: "dsa", options: DSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
|
|
3169
|
-
function __promisify__(
|
|
3170
|
-
type: "ec",
|
|
3171
|
-
options: ECKeyPairOptions<"pem", "pem">,
|
|
3172
|
-
): Promise<{
|
|
3173
|
-
publicKey: string;
|
|
3174
|
-
privateKey: string;
|
|
3175
|
-
}>;
|
|
3176
|
-
function __promisify__(
|
|
2649
|
+
options: T,
|
|
2650
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2651
|
+
function __promisify__<T extends ECKeyPairOptions>(
|
|
3177
2652
|
type: "ec",
|
|
3178
|
-
options:
|
|
3179
|
-
): Promise<
|
|
3180
|
-
|
|
3181
|
-
privateKey: NonSharedBuffer;
|
|
3182
|
-
}>;
|
|
3183
|
-
function __promisify__(
|
|
3184
|
-
type: "ec",
|
|
3185
|
-
options: ECKeyPairOptions<"der", "pem">,
|
|
3186
|
-
): Promise<{
|
|
3187
|
-
publicKey: NonSharedBuffer;
|
|
3188
|
-
privateKey: string;
|
|
3189
|
-
}>;
|
|
3190
|
-
function __promisify__(
|
|
3191
|
-
type: "ec",
|
|
3192
|
-
options: ECKeyPairOptions<"der", "der">,
|
|
3193
|
-
): Promise<{
|
|
3194
|
-
publicKey: NonSharedBuffer;
|
|
3195
|
-
privateKey: NonSharedBuffer;
|
|
3196
|
-
}>;
|
|
3197
|
-
function __promisify__(type: "ec", options: ECKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
|
|
3198
|
-
function __promisify__(
|
|
3199
|
-
type: "ed25519",
|
|
3200
|
-
options: ED25519KeyPairOptions<"pem", "pem">,
|
|
3201
|
-
): Promise<{
|
|
3202
|
-
publicKey: string;
|
|
3203
|
-
privateKey: string;
|
|
3204
|
-
}>;
|
|
3205
|
-
function __promisify__(
|
|
3206
|
-
type: "ed25519",
|
|
3207
|
-
options: ED25519KeyPairOptions<"pem", "der">,
|
|
3208
|
-
): Promise<{
|
|
3209
|
-
publicKey: string;
|
|
3210
|
-
privateKey: NonSharedBuffer;
|
|
3211
|
-
}>;
|
|
3212
|
-
function __promisify__(
|
|
3213
|
-
type: "ed25519",
|
|
3214
|
-
options: ED25519KeyPairOptions<"der", "pem">,
|
|
3215
|
-
): Promise<{
|
|
3216
|
-
publicKey: NonSharedBuffer;
|
|
3217
|
-
privateKey: string;
|
|
3218
|
-
}>;
|
|
3219
|
-
function __promisify__(
|
|
3220
|
-
type: "ed25519",
|
|
3221
|
-
options: ED25519KeyPairOptions<"der", "der">,
|
|
3222
|
-
): Promise<{
|
|
3223
|
-
publicKey: NonSharedBuffer;
|
|
3224
|
-
privateKey: NonSharedBuffer;
|
|
3225
|
-
}>;
|
|
3226
|
-
function __promisify__(
|
|
2653
|
+
options: T,
|
|
2654
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2655
|
+
function __promisify__<T extends ED25519KeyPairOptions = {}>(
|
|
3227
2656
|
type: "ed25519",
|
|
3228
|
-
options?:
|
|
3229
|
-
): Promise<
|
|
3230
|
-
function __promisify__(
|
|
2657
|
+
options?: T,
|
|
2658
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2659
|
+
function __promisify__<T extends ED448KeyPairOptions = {}>(
|
|
3231
2660
|
type: "ed448",
|
|
3232
|
-
options
|
|
3233
|
-
): Promise<
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
}
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
publicKey: NonSharedBuffer;
|
|
3256
|
-
privateKey: NonSharedBuffer;
|
|
3257
|
-
}>;
|
|
3258
|
-
function __promisify__(type: "ed448", options?: ED448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
|
|
3259
|
-
function __promisify__(
|
|
3260
|
-
type: "x25519",
|
|
3261
|
-
options: X25519KeyPairOptions<"pem", "pem">,
|
|
3262
|
-
): Promise<{
|
|
3263
|
-
publicKey: string;
|
|
3264
|
-
privateKey: string;
|
|
3265
|
-
}>;
|
|
3266
|
-
function __promisify__(
|
|
3267
|
-
type: "x25519",
|
|
3268
|
-
options: X25519KeyPairOptions<"pem", "der">,
|
|
3269
|
-
): Promise<{
|
|
3270
|
-
publicKey: string;
|
|
3271
|
-
privateKey: NonSharedBuffer;
|
|
3272
|
-
}>;
|
|
3273
|
-
function __promisify__(
|
|
3274
|
-
type: "x25519",
|
|
3275
|
-
options: X25519KeyPairOptions<"der", "pem">,
|
|
3276
|
-
): Promise<{
|
|
3277
|
-
publicKey: NonSharedBuffer;
|
|
3278
|
-
privateKey: string;
|
|
3279
|
-
}>;
|
|
3280
|
-
function __promisify__(
|
|
3281
|
-
type: "x25519",
|
|
3282
|
-
options: X25519KeyPairOptions<"der", "der">,
|
|
3283
|
-
): Promise<{
|
|
3284
|
-
publicKey: NonSharedBuffer;
|
|
3285
|
-
privateKey: NonSharedBuffer;
|
|
3286
|
-
}>;
|
|
3287
|
-
function __promisify__(
|
|
2661
|
+
options?: T,
|
|
2662
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2663
|
+
function __promisify__<T extends MLDSAKeyPairOptions = {}>(
|
|
2664
|
+
type: MLDSAKeyType,
|
|
2665
|
+
options?: T,
|
|
2666
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2667
|
+
function __promisify__<T extends MLKEMKeyPairOptions = {}>(
|
|
2668
|
+
type: MLKEMKeyType,
|
|
2669
|
+
options?: T,
|
|
2670
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2671
|
+
function __promisify__<T extends RSAPSSKeyPairOptions>(
|
|
2672
|
+
type: "rsa-pss",
|
|
2673
|
+
options: T,
|
|
2674
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2675
|
+
function __promisify__<T extends RSAKeyPairOptions>(
|
|
2676
|
+
type: "rsa",
|
|
2677
|
+
options: T,
|
|
2678
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2679
|
+
function __promisify__<T extends SLHDSAKeyPairOptions = {}>(
|
|
2680
|
+
type: SLHDSAKeyType,
|
|
2681
|
+
options?: T,
|
|
2682
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2683
|
+
function __promisify__<T extends X25519KeyPairOptions = {}>(
|
|
3288
2684
|
type: "x25519",
|
|
3289
|
-
options?:
|
|
3290
|
-
): Promise<
|
|
3291
|
-
function __promisify__(
|
|
3292
|
-
type: "x448",
|
|
3293
|
-
options: X448KeyPairOptions<"pem", "pem">,
|
|
3294
|
-
): Promise<{
|
|
3295
|
-
publicKey: string;
|
|
3296
|
-
privateKey: string;
|
|
3297
|
-
}>;
|
|
3298
|
-
function __promisify__(
|
|
3299
|
-
type: "x448",
|
|
3300
|
-
options: X448KeyPairOptions<"pem", "der">,
|
|
3301
|
-
): Promise<{
|
|
3302
|
-
publicKey: string;
|
|
3303
|
-
privateKey: NonSharedBuffer;
|
|
3304
|
-
}>;
|
|
3305
|
-
function __promisify__(
|
|
3306
|
-
type: "x448",
|
|
3307
|
-
options: X448KeyPairOptions<"der", "pem">,
|
|
3308
|
-
): Promise<{
|
|
3309
|
-
publicKey: NonSharedBuffer;
|
|
3310
|
-
privateKey: string;
|
|
3311
|
-
}>;
|
|
3312
|
-
function __promisify__(
|
|
2685
|
+
options?: T,
|
|
2686
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2687
|
+
function __promisify__<T extends X448KeyPairOptions = {}>(
|
|
3313
2688
|
type: "x448",
|
|
3314
|
-
options
|
|
3315
|
-
): Promise<
|
|
3316
|
-
publicKey: NonSharedBuffer;
|
|
3317
|
-
privateKey: NonSharedBuffer;
|
|
3318
|
-
}>;
|
|
3319
|
-
function __promisify__(type: "x448", options?: X448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
|
|
2689
|
+
options?: T,
|
|
2690
|
+
): Promise<KeyPairExportResult<T>>;
|
|
3320
2691
|
}
|
|
3321
2692
|
/**
|
|
3322
2693
|
* Calculates and returns the signature for `data` using the given private key and
|
|
3323
2694
|
* algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
|
|
3324
|
-
* dependent upon the key type
|
|
2695
|
+
* dependent upon the key type.
|
|
2696
|
+
*
|
|
2697
|
+
* `algorithm` is required to be `null` or `undefined` for Ed25519, Ed448, and
|
|
2698
|
+
* ML-DSA.
|
|
3325
2699
|
*
|
|
3326
2700
|
* If `key` is not a `KeyObject`, this function behaves as if `key` had been
|
|
3327
|
-
* passed to
|
|
3328
|
-
*
|
|
2701
|
+
* passed to `crypto.createPrivateKey()`. When `key` is a string, `ArrayBuffer`,
|
|
2702
|
+
* `Buffer`, `TypedArray`, or `DataView`, it must contain PEM-encoded key
|
|
2703
|
+
* material. If it is an object, the following additional properties can be
|
|
2704
|
+
* passed:
|
|
3329
2705
|
*
|
|
3330
2706
|
* If the `callback` function is provided this function uses libuv's threadpool.
|
|
3331
2707
|
* @since v12.0.0
|
|
3332
2708
|
*/
|
|
3333
2709
|
function sign(
|
|
3334
2710
|
algorithm: string | null | undefined,
|
|
3335
|
-
data:
|
|
2711
|
+
data: BinaryLike,
|
|
3336
2712
|
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
|
|
3337
2713
|
): NonSharedBuffer;
|
|
3338
2714
|
function sign(
|
|
3339
2715
|
algorithm: string | null | undefined,
|
|
3340
|
-
data:
|
|
2716
|
+
data: BinaryLike,
|
|
3341
2717
|
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
|
|
3342
2718
|
callback: (error: Error | null, data: NonSharedBuffer) => void,
|
|
3343
2719
|
): void;
|
|
3344
2720
|
/**
|
|
3345
|
-
* Verifies the given signature for `data` using the given key and algorithm. If
|
|
3346
|
-
*
|
|
2721
|
+
* Verifies the given signature for `data` using the given key and algorithm. If
|
|
2722
|
+
* `algorithm` is `null` or `undefined`, then the algorithm is dependent upon the
|
|
2723
|
+
* key type.
|
|
2724
|
+
*
|
|
2725
|
+
* `algorithm` is required to be `null` or `undefined` for Ed25519, Ed448, and
|
|
2726
|
+
* ML-DSA.
|
|
3347
2727
|
*
|
|
3348
2728
|
* If `key` is not a `KeyObject`, this function behaves as if `key` had been
|
|
3349
|
-
* passed to
|
|
3350
|
-
*
|
|
2729
|
+
* passed to `crypto.createPublicKey()`. When `key` is a string, `ArrayBuffer`,
|
|
2730
|
+
* `Buffer`, `TypedArray`, or `DataView`, it must contain PEM-encoded key
|
|
2731
|
+
* material. If it is an object, the following additional properties can be
|
|
2732
|
+
* passed:
|
|
3351
2733
|
*
|
|
3352
2734
|
* The `signature` argument is the previously calculated signature for the `data`.
|
|
3353
2735
|
*
|
|
@@ -3359,28 +2741,118 @@ declare module "crypto" {
|
|
|
3359
2741
|
*/
|
|
3360
2742
|
function verify(
|
|
3361
2743
|
algorithm: string | null | undefined,
|
|
3362
|
-
data:
|
|
2744
|
+
data: BinaryLike,
|
|
3363
2745
|
key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
|
|
3364
|
-
signature:
|
|
2746
|
+
signature: BinaryLike,
|
|
3365
2747
|
): boolean;
|
|
3366
2748
|
function verify(
|
|
3367
2749
|
algorithm: string | null | undefined,
|
|
3368
|
-
data:
|
|
2750
|
+
data: BinaryLike,
|
|
3369
2751
|
key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
|
|
3370
|
-
signature:
|
|
2752
|
+
signature: BinaryLike,
|
|
3371
2753
|
callback: (error: Error | null, result: boolean) => void,
|
|
3372
2754
|
): void;
|
|
3373
2755
|
/**
|
|
3374
|
-
*
|
|
3375
|
-
*
|
|
2756
|
+
* Key decapsulation using a KEM algorithm with a private key.
|
|
2757
|
+
*
|
|
2758
|
+
* Supported key types and their KEM algorithms are:
|
|
2759
|
+
*
|
|
2760
|
+
* * `'rsa'` RSA Secret Value Encapsulation
|
|
2761
|
+
* * `'ec'` DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)
|
|
2762
|
+
* * `'x25519'` DHKEM(X25519, HKDF-SHA256)
|
|
2763
|
+
* * `'x448'` DHKEM(X448, HKDF-SHA512)
|
|
2764
|
+
* * `'ml-kem-512'` ML-KEM
|
|
2765
|
+
* * `'ml-kem-768'` ML-KEM
|
|
2766
|
+
* * `'ml-kem-1024'` ML-KEM
|
|
2767
|
+
*
|
|
2768
|
+
* If `key` is not a {@link KeyObject}, this function behaves as if `key` had been
|
|
2769
|
+
* passed to `crypto.createPrivateKey()`.
|
|
2770
|
+
*
|
|
2771
|
+
* If the `callback` function is provided this function uses libuv's threadpool.
|
|
2772
|
+
* @since v24.7.0
|
|
2773
|
+
*/
|
|
2774
|
+
function decapsulate(
|
|
2775
|
+
key: KeyLike | PrivateKeyInput | RawPrivateKeyInput | JsonWebKeyInput,
|
|
2776
|
+
ciphertext: ArrayBufferLike | NodeJS.ArrayBufferView,
|
|
2777
|
+
): NonSharedBuffer;
|
|
2778
|
+
function decapsulate(
|
|
2779
|
+
key: KeyLike | PrivateKeyInput | RawPrivateKeyInput | JsonWebKeyInput,
|
|
2780
|
+
ciphertext: ArrayBufferLike | NodeJS.ArrayBufferView,
|
|
2781
|
+
callback: (err: Error, sharedKey: NonSharedBuffer) => void,
|
|
2782
|
+
): void;
|
|
2783
|
+
interface DiffieHellmanOptions {
|
|
2784
|
+
privateKey: KeyLike | PrivateKeyInput;
|
|
2785
|
+
publicKey: KeyLike | PublicKeyInput;
|
|
2786
|
+
}
|
|
2787
|
+
/**
|
|
2788
|
+
* Computes the Diffie-Hellman shared secret based on a `privateKey` and a `publicKey`.
|
|
2789
|
+
* Both keys must have the same `asymmetricKeyType` and must support either the DH or
|
|
2790
|
+
* ECDH operation.
|
|
2791
|
+
*
|
|
2792
|
+
* If the `callback` function is provided this function uses libuv's threadpool.
|
|
3376
2793
|
* @since v13.9.0, v12.17.0
|
|
3377
2794
|
*/
|
|
3378
|
-
function diffieHellman(options:
|
|
2795
|
+
function diffieHellman(options: DiffieHellmanOptions): NonSharedBuffer;
|
|
2796
|
+
function diffieHellman(
|
|
2797
|
+
options: DiffieHellmanOptions,
|
|
2798
|
+
callback: (err: Error | null, secret: NonSharedBuffer) => void,
|
|
2799
|
+
): void;
|
|
3379
2800
|
/**
|
|
3380
|
-
*
|
|
3381
|
-
*
|
|
3382
|
-
*
|
|
3383
|
-
*
|
|
2801
|
+
* Key encapsulation using a KEM algorithm with a public key.
|
|
2802
|
+
*
|
|
2803
|
+
* Supported key types and their KEM algorithms are:
|
|
2804
|
+
*
|
|
2805
|
+
* * `'rsa'` RSA Secret Value Encapsulation
|
|
2806
|
+
* * `'ec'` DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)
|
|
2807
|
+
* * `'x25519'` DHKEM(X25519, HKDF-SHA256)
|
|
2808
|
+
* * `'x448'` DHKEM(X448, HKDF-SHA512)
|
|
2809
|
+
* * `'ml-kem-512'` ML-KEM
|
|
2810
|
+
* * `'ml-kem-768'` ML-KEM
|
|
2811
|
+
* * `'ml-kem-1024'` ML-KEM
|
|
2812
|
+
*
|
|
2813
|
+
* If `key` is not a {@link KeyObject}, this function behaves as if `key` had been
|
|
2814
|
+
* passed to `crypto.createPublicKey()`.
|
|
2815
|
+
*
|
|
2816
|
+
* If the `callback` function is provided this function uses libuv's threadpool.
|
|
2817
|
+
* @since v24.7.0
|
|
2818
|
+
*/
|
|
2819
|
+
function encapsulate(
|
|
2820
|
+
key: KeyLike | PublicKeyInput | RawPublicKeyInput | JsonWebKeyInput,
|
|
2821
|
+
): { sharedKey: NonSharedBuffer; ciphertext: NonSharedBuffer };
|
|
2822
|
+
function encapsulate(
|
|
2823
|
+
key: KeyLike | PublicKeyInput | RawPublicKeyInput | JsonWebKeyInput,
|
|
2824
|
+
callback: (err: Error, result: { sharedKey: NonSharedBuffer; ciphertext: NonSharedBuffer }) => void,
|
|
2825
|
+
): void;
|
|
2826
|
+
interface OneShotDigestOptions {
|
|
2827
|
+
/**
|
|
2828
|
+
* Encoding used to encode the returned digest.
|
|
2829
|
+
* @default 'hex'
|
|
2830
|
+
*/
|
|
2831
|
+
outputEncoding?: BufferEncoding | "buffer" | undefined;
|
|
2832
|
+
/**
|
|
2833
|
+
* For XOF hash functions such as 'shake256', the outputLength option
|
|
2834
|
+
* can be used to specify the desired output length in bytes.
|
|
2835
|
+
*/
|
|
2836
|
+
outputLength?: number | undefined;
|
|
2837
|
+
}
|
|
2838
|
+
interface OneShotDigestOptionsWithStringEncoding extends OneShotDigestOptions {
|
|
2839
|
+
outputEncoding?: BufferEncoding | undefined;
|
|
2840
|
+
}
|
|
2841
|
+
interface OneShotDigestOptionsWithBufferEncoding extends OneShotDigestOptions {
|
|
2842
|
+
outputEncoding: "buffer";
|
|
2843
|
+
}
|
|
2844
|
+
/**
|
|
2845
|
+
* A utility for creating one-shot hash digests of data. It can be faster than
|
|
2846
|
+
* the object-based `crypto.createHash()` when hashing a smaller amount of data
|
|
2847
|
+
* (<= 5MB) that's readily available. If the data can be big or if it is streamed,
|
|
2848
|
+
* it's still recommended to use `crypto.createHash()` instead.
|
|
2849
|
+
*
|
|
2850
|
+
* The `algorithm` is dependent on the available algorithms supported by the
|
|
2851
|
+
* version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
|
|
2852
|
+
* On recent releases of OpenSSL, `openssl list -digest-algorithms` will
|
|
2853
|
+
* display the available digest algorithms.
|
|
2854
|
+
*
|
|
2855
|
+
* If `options` is a string, then it specifies the `outputEncoding`.
|
|
3384
2856
|
*
|
|
3385
2857
|
* Example:
|
|
3386
2858
|
*
|
|
@@ -3400,16 +2872,25 @@ declare module "crypto" {
|
|
|
3400
2872
|
* console.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));
|
|
3401
2873
|
* ```
|
|
3402
2874
|
* @since v21.7.0, v20.12.0
|
|
3403
|
-
* @param data When `data` is a string, it will be encoded as UTF-8 before being hashed. If a different
|
|
3404
|
-
*
|
|
3405
|
-
*
|
|
2875
|
+
* @param data When `data` is a string, it will be encoded as UTF-8 before being hashed. If a different
|
|
2876
|
+
* input encoding is desired for a string input, user could encode the string
|
|
2877
|
+
* into a `TypedArray` using either `TextEncoder` or `Buffer.from()` and passing
|
|
2878
|
+
* the encoded `TypedArray` into this API instead.
|
|
3406
2879
|
*/
|
|
3407
|
-
function hash(algorithm: string, data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
|
|
3408
|
-
function hash(algorithm: string, data: BinaryLike, outputEncoding: "buffer"): NonSharedBuffer;
|
|
3409
2880
|
function hash(
|
|
3410
2881
|
algorithm: string,
|
|
3411
2882
|
data: BinaryLike,
|
|
3412
|
-
|
|
2883
|
+
options?: OneShotDigestOptionsWithStringEncoding | BufferEncoding,
|
|
2884
|
+
): string;
|
|
2885
|
+
function hash(
|
|
2886
|
+
algorithm: string,
|
|
2887
|
+
data: BinaryLike,
|
|
2888
|
+
options: OneShotDigestOptionsWithBufferEncoding | "buffer",
|
|
2889
|
+
): NonSharedBuffer;
|
|
2890
|
+
function hash(
|
|
2891
|
+
algorithm: string,
|
|
2892
|
+
data: BinaryLike,
|
|
2893
|
+
options: OneShotDigestOptions | BufferEncoding | "buffer",
|
|
3413
2894
|
): string | NonSharedBuffer;
|
|
3414
2895
|
type CipherMode = "cbc" | "ccm" | "cfb" | "ctr" | "ecb" | "gcm" | "ocb" | "ofb" | "stream" | "wrap" | "xts";
|
|
3415
2896
|
interface CipherInfoOptions {
|
|
@@ -3423,31 +2904,11 @@ declare module "crypto" {
|
|
|
3423
2904
|
ivLength?: number | undefined;
|
|
3424
2905
|
}
|
|
3425
2906
|
interface CipherInfo {
|
|
3426
|
-
/**
|
|
3427
|
-
* The name of the cipher.
|
|
3428
|
-
*/
|
|
3429
2907
|
name: string;
|
|
3430
|
-
/**
|
|
3431
|
-
* The nid of the cipher.
|
|
3432
|
-
*/
|
|
3433
2908
|
nid: number;
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
* This property is omitted when mode is 'stream'.
|
|
3437
|
-
*/
|
|
3438
|
-
blockSize?: number | undefined;
|
|
3439
|
-
/**
|
|
3440
|
-
* The expected or default initialization vector length in bytes.
|
|
3441
|
-
* This property is omitted if the cipher does not use an initialization vector.
|
|
3442
|
-
*/
|
|
3443
|
-
ivLength?: number | undefined;
|
|
3444
|
-
/**
|
|
3445
|
-
* The expected or default key length in bytes.
|
|
3446
|
-
*/
|
|
2909
|
+
blockSize?: number;
|
|
2910
|
+
ivLength?: number;
|
|
3447
2911
|
keyLength: number;
|
|
3448
|
-
/**
|
|
3449
|
-
* The cipher mode.
|
|
3450
|
-
*/
|
|
3451
2912
|
mode: CipherMode;
|
|
3452
2913
|
}
|
|
3453
2914
|
/**
|
|
@@ -3491,7 +2952,7 @@ declare module "crypto" {
|
|
|
3491
2952
|
*/
|
|
3492
2953
|
function hkdf(
|
|
3493
2954
|
digest: string,
|
|
3494
|
-
|
|
2955
|
+
ikm: KeyLike,
|
|
3495
2956
|
salt: BinaryLike,
|
|
3496
2957
|
info: BinaryLike,
|
|
3497
2958
|
keylen: number,
|
|
@@ -3525,27 +2986,15 @@ declare module "crypto" {
|
|
|
3525
2986
|
*/
|
|
3526
2987
|
function hkdfSync(
|
|
3527
2988
|
digest: string,
|
|
3528
|
-
ikm:
|
|
2989
|
+
ikm: KeyLike,
|
|
3529
2990
|
salt: BinaryLike,
|
|
3530
2991
|
info: BinaryLike,
|
|
3531
2992
|
keylen: number,
|
|
3532
2993
|
): ArrayBuffer;
|
|
3533
2994
|
interface SecureHeapUsage {
|
|
3534
|
-
/**
|
|
3535
|
-
* The total allocated secure heap size as specified using the `--secure-heap=n` command-line flag.
|
|
3536
|
-
*/
|
|
3537
2995
|
total: number;
|
|
3538
|
-
/**
|
|
3539
|
-
* The minimum allocation from the secure heap as specified using the `--secure-heap-min` command-line flag.
|
|
3540
|
-
*/
|
|
3541
2996
|
min: number;
|
|
3542
|
-
/**
|
|
3543
|
-
* The total number of bytes currently allocated from the secure heap.
|
|
3544
|
-
*/
|
|
3545
2997
|
used: number;
|
|
3546
|
-
/**
|
|
3547
|
-
* The calculated ratio of `used` to `total` allocated bytes.
|
|
3548
|
-
*/
|
|
3549
2998
|
utilization: number;
|
|
3550
2999
|
}
|
|
3551
3000
|
/**
|
|
@@ -3558,11 +3007,11 @@ declare module "crypto" {
|
|
|
3558
3007
|
* Node.js will pre-emptively generate and persistently cache enough
|
|
3559
3008
|
* random data to generate up to 128 random UUIDs. To generate a UUID
|
|
3560
3009
|
* without using the cache, set `disableEntropyCache` to `true`.
|
|
3561
|
-
*
|
|
3562
3010
|
* @default `false`
|
|
3563
3011
|
*/
|
|
3564
3012
|
disableEntropyCache?: boolean | undefined;
|
|
3565
3013
|
}
|
|
3014
|
+
interface RandomUUIDV7Options extends RandomUUIDOptions {}
|
|
3566
3015
|
type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
3567
3016
|
/**
|
|
3568
3017
|
* Generates a random [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) version 4 UUID. The UUID is generated using a
|
|
@@ -3570,26 +3019,21 @@ declare module "crypto" {
|
|
|
3570
3019
|
* @since v15.6.0, v14.17.0
|
|
3571
3020
|
*/
|
|
3572
3021
|
function randomUUID(options?: RandomUUIDOptions): UUID;
|
|
3022
|
+
/**
|
|
3023
|
+
* Generates a random [RFC 9562](https://www.rfc-editor.org/rfc/rfc9562.txt) version 7 UUID. The UUID contains a millisecond
|
|
3024
|
+
* precision Unix timestamp in the most significant 48 bits, followed by
|
|
3025
|
+
* cryptographically secure random bits for the remaining fields, making it
|
|
3026
|
+
* suitable for use as a database key with time-based sorting. The embedded
|
|
3027
|
+
* timestamp relies on a non-monotonic clock and is not guaranteed to be strictly
|
|
3028
|
+
* increasing.
|
|
3029
|
+
* @since v26.1.0
|
|
3030
|
+
*/
|
|
3031
|
+
function randomUUIDv7(options?: RandomUUIDV7Options): UUID;
|
|
3573
3032
|
interface X509CheckOptions {
|
|
3574
|
-
/**
|
|
3575
|
-
* @default 'always'
|
|
3576
|
-
*/
|
|
3577
3033
|
subject?: "always" | "default" | "never" | undefined;
|
|
3578
|
-
/**
|
|
3579
|
-
* @default true
|
|
3580
|
-
*/
|
|
3581
3034
|
wildcards?: boolean | undefined;
|
|
3582
|
-
/**
|
|
3583
|
-
* @default true
|
|
3584
|
-
*/
|
|
3585
3035
|
partialWildcards?: boolean | undefined;
|
|
3586
|
-
/**
|
|
3587
|
-
* @default false
|
|
3588
|
-
*/
|
|
3589
3036
|
multiLabelWildcards?: boolean | undefined;
|
|
3590
|
-
/**
|
|
3591
|
-
* @default false
|
|
3592
|
-
*/
|
|
3593
3037
|
singleLabelSubdomains?: boolean | undefined;
|
|
3594
3038
|
}
|
|
3595
3039
|
/**
|
|
@@ -3712,6 +3156,16 @@ declare module "crypto" {
|
|
|
3712
3156
|
* @since v15.6.0
|
|
3713
3157
|
*/
|
|
3714
3158
|
readonly serialNumber: string;
|
|
3159
|
+
/**
|
|
3160
|
+
* The algorithm used to sign the certificate or `undefined` if the signature algorithm is unknown by OpenSSL.
|
|
3161
|
+
* @since v24.9.0
|
|
3162
|
+
*/
|
|
3163
|
+
readonly signatureAlgorithm: string | undefined;
|
|
3164
|
+
/**
|
|
3165
|
+
* The OID of the algorithm used to sign the certificate.
|
|
3166
|
+
* @since v24.9.0
|
|
3167
|
+
*/
|
|
3168
|
+
readonly signatureAlgorithmOid: string;
|
|
3715
3169
|
/**
|
|
3716
3170
|
* The date/time from which this certificate is considered valid.
|
|
3717
3171
|
* @since v15.6.0
|
|
@@ -3732,7 +3186,7 @@ declare module "crypto" {
|
|
|
3732
3186
|
* @since v22.10.0
|
|
3733
3187
|
*/
|
|
3734
3188
|
readonly validToDate: Date;
|
|
3735
|
-
constructor(buffer:
|
|
3189
|
+
constructor(buffer: string | NodeJS.ArrayBufferView);
|
|
3736
3190
|
/**
|
|
3737
3191
|
* Checks whether the certificate matches the given email address.
|
|
3738
3192
|
*
|
|
@@ -3835,13 +3289,10 @@ declare module "crypto" {
|
|
|
3835
3289
|
*/
|
|
3836
3290
|
verify(publicKey: KeyObject): boolean;
|
|
3837
3291
|
}
|
|
3838
|
-
type LargeNumberLike = NodeJS.ArrayBufferView |
|
|
3292
|
+
type LargeNumberLike = ArrayBufferLike | NodeJS.ArrayBufferView | bigint;
|
|
3839
3293
|
interface GeneratePrimeOptions {
|
|
3840
3294
|
add?: LargeNumberLike | undefined;
|
|
3841
3295
|
rem?: LargeNumberLike | undefined;
|
|
3842
|
-
/**
|
|
3843
|
-
* @default false
|
|
3844
|
-
*/
|
|
3845
3296
|
safe?: boolean | undefined;
|
|
3846
3297
|
bigint?: boolean | undefined;
|
|
3847
3298
|
}
|
|
@@ -3881,13 +3332,13 @@ declare module "crypto" {
|
|
|
3881
3332
|
function generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
|
|
3882
3333
|
function generatePrime(
|
|
3883
3334
|
size: number,
|
|
3884
|
-
options:
|
|
3885
|
-
callback: (err: Error | null, prime:
|
|
3335
|
+
options: GeneratePrimeOptionsArrayBuffer,
|
|
3336
|
+
callback: (err: Error | null, prime: ArrayBuffer) => void,
|
|
3886
3337
|
): void;
|
|
3887
3338
|
function generatePrime(
|
|
3888
3339
|
size: number,
|
|
3889
|
-
options:
|
|
3890
|
-
callback: (err: Error | null, prime:
|
|
3340
|
+
options: GeneratePrimeOptionsBigInt,
|
|
3341
|
+
callback: (err: Error | null, prime: bigint) => void,
|
|
3891
3342
|
): void;
|
|
3892
3343
|
function generatePrime(
|
|
3893
3344
|
size: number,
|
|
@@ -3922,8 +3373,8 @@ declare module "crypto" {
|
|
|
3922
3373
|
* @param size The size (in bits) of the prime to generate.
|
|
3923
3374
|
*/
|
|
3924
3375
|
function generatePrimeSync(size: number): ArrayBuffer;
|
|
3925
|
-
function generatePrimeSync(size: number, options: GeneratePrimeOptionsBigInt): bigint;
|
|
3926
3376
|
function generatePrimeSync(size: number, options: GeneratePrimeOptionsArrayBuffer): ArrayBuffer;
|
|
3377
|
+
function generatePrimeSync(size: number, options: GeneratePrimeOptionsBigInt): bigint;
|
|
3927
3378
|
function generatePrimeSync(size: number, options: GeneratePrimeOptions): ArrayBuffer | bigint;
|
|
3928
3379
|
interface CheckPrimeOptions {
|
|
3929
3380
|
/**
|
|
@@ -3931,7 +3382,6 @@ declare module "crypto" {
|
|
|
3931
3382
|
* When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most `2**-64` for random input.
|
|
3932
3383
|
* Care must be used when selecting a number of checks.
|
|
3933
3384
|
* Refer to the OpenSSL documentation for the BN_is_prime_ex function nchecks options for more details.
|
|
3934
|
-
*
|
|
3935
3385
|
* @default 0
|
|
3936
3386
|
*/
|
|
3937
3387
|
checks?: number | undefined;
|
|
@@ -3983,7 +3433,101 @@ declare module "crypto" {
|
|
|
3983
3433
|
* @since v17.4.0
|
|
3984
3434
|
* @return Returns `typedArray`.
|
|
3985
3435
|
*/
|
|
3986
|
-
function getRandomValues<
|
|
3436
|
+
function getRandomValues<
|
|
3437
|
+
T extends Exclude<
|
|
3438
|
+
NodeJS.NonSharedTypedArray,
|
|
3439
|
+
NodeJS.NonSharedFloat16Array | NodeJS.NonSharedFloat32Array | NodeJS.NonSharedFloat64Array
|
|
3440
|
+
>,
|
|
3441
|
+
>(typedArray: T): T;
|
|
3442
|
+
type Argon2Algorithm = "argon2d" | "argon2i" | "argon2id";
|
|
3443
|
+
interface Argon2Parameters {
|
|
3444
|
+
message: BinaryLike;
|
|
3445
|
+
nonce: BinaryLike;
|
|
3446
|
+
parallelism: number;
|
|
3447
|
+
tagLength: number;
|
|
3448
|
+
memory: number;
|
|
3449
|
+
passes: number;
|
|
3450
|
+
secret?: BinaryLike | undefined;
|
|
3451
|
+
associatedData?: BinaryLike | undefined;
|
|
3452
|
+
}
|
|
3453
|
+
/**
|
|
3454
|
+
* Provides an asynchronous [Argon2](https://www.rfc-editor.org/rfc/rfc9106.html) implementation. Argon2 is a password-based
|
|
3455
|
+
* key derivation function that is designed to be expensive computationally and
|
|
3456
|
+
* memory-wise in order to make brute-force attacks unrewarding.
|
|
3457
|
+
*
|
|
3458
|
+
* The `nonce` should be as unique as possible. It is recommended that a nonce is
|
|
3459
|
+
* random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
|
|
3460
|
+
*
|
|
3461
|
+
* When passing strings for `message`, `nonce`, `secret` or `associatedData`, please
|
|
3462
|
+
* consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v26.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
|
|
3463
|
+
*
|
|
3464
|
+
* The `callback` function is called with two arguments: `err` and `derivedKey`.
|
|
3465
|
+
* `err` is an exception object when key derivation fails, otherwise `err` is
|
|
3466
|
+
* `null`. `derivedKey` is passed to the callback as a `Buffer`.
|
|
3467
|
+
*
|
|
3468
|
+
* An exception is thrown when any of the input arguments specify invalid values
|
|
3469
|
+
* or types.
|
|
3470
|
+
*
|
|
3471
|
+
* ```js
|
|
3472
|
+
* const { argon2, randomBytes } = await import('node:crypto');
|
|
3473
|
+
*
|
|
3474
|
+
* const parameters = {
|
|
3475
|
+
* message: 'password',
|
|
3476
|
+
* nonce: randomBytes(16),
|
|
3477
|
+
* parallelism: 4,
|
|
3478
|
+
* tagLength: 64,
|
|
3479
|
+
* memory: 65536,
|
|
3480
|
+
* passes: 3,
|
|
3481
|
+
* };
|
|
3482
|
+
*
|
|
3483
|
+
* argon2('argon2id', parameters, (err, derivedKey) => {
|
|
3484
|
+
* if (err) throw err;
|
|
3485
|
+
* console.log(derivedKey.toString('hex')); // 'af91dad...9520f15'
|
|
3486
|
+
* });
|
|
3487
|
+
* ```
|
|
3488
|
+
* @since v24.7.0
|
|
3489
|
+
* @param algorithm Variant of Argon2, one of `"argon2d"`, `"argon2i"` or `"argon2id"`.
|
|
3490
|
+
*/
|
|
3491
|
+
function argon2(
|
|
3492
|
+
algorithm: Argon2Algorithm,
|
|
3493
|
+
parameters: Argon2Parameters,
|
|
3494
|
+
callback: (err: Error | null, derivedKey: NonSharedBuffer) => void,
|
|
3495
|
+
): void;
|
|
3496
|
+
/**
|
|
3497
|
+
* Provides a synchronous [Argon2][] implementation. Argon2 is a password-based
|
|
3498
|
+
* key derivation function that is designed to be expensive computationally and
|
|
3499
|
+
* memory-wise in order to make brute-force attacks unrewarding.
|
|
3500
|
+
*
|
|
3501
|
+
* The `nonce` should be as unique as possible. It is recommended that a nonce is
|
|
3502
|
+
* random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
|
|
3503
|
+
*
|
|
3504
|
+
* When passing strings for `message`, `nonce`, `secret` or `associatedData`, please
|
|
3505
|
+
* consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v26.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
|
|
3506
|
+
*
|
|
3507
|
+
* An exception is thrown when key derivation fails, otherwise the derived key is
|
|
3508
|
+
* returned as a `Buffer`.
|
|
3509
|
+
*
|
|
3510
|
+
* An exception is thrown when any of the input arguments specify invalid values
|
|
3511
|
+
* or types.
|
|
3512
|
+
*
|
|
3513
|
+
* ```js
|
|
3514
|
+
* const { argon2Sync, randomBytes } = await import('node:crypto');
|
|
3515
|
+
*
|
|
3516
|
+
* const parameters = {
|
|
3517
|
+
* message: 'password',
|
|
3518
|
+
* nonce: randomBytes(16),
|
|
3519
|
+
* parallelism: 4,
|
|
3520
|
+
* tagLength: 64,
|
|
3521
|
+
* memory: 65536,
|
|
3522
|
+
* passes: 3,
|
|
3523
|
+
* };
|
|
3524
|
+
*
|
|
3525
|
+
* const derivedKey = argon2Sync('argon2id', parameters);
|
|
3526
|
+
* console.log(derivedKey.toString('hex')); // 'af91dad...9520f15'
|
|
3527
|
+
* ```
|
|
3528
|
+
* @since v24.7.0
|
|
3529
|
+
*/
|
|
3530
|
+
function argon2Sync(algorithm: Argon2Algorithm, parameters: Argon2Parameters): NonSharedBuffer;
|
|
3987
3531
|
/**
|
|
3988
3532
|
* A convenient alias for `crypto.webcrypto.subtle`.
|
|
3989
3533
|
* @since v17.4.0
|
|
@@ -3997,37 +3541,40 @@ declare module "crypto" {
|
|
|
3997
3541
|
*/
|
|
3998
3542
|
const webcrypto: webcrypto.Crypto;
|
|
3999
3543
|
namespace webcrypto {
|
|
4000
|
-
type
|
|
4001
|
-
type
|
|
3544
|
+
type AlgorithmIdentifier = Algorithm | string;
|
|
3545
|
+
type BigInteger = NodeJS.NonSharedUint8Array;
|
|
3546
|
+
type KeyFormat = "jwk" | "pkcs8" | "raw" | "raw-public" | "raw-secret" | "raw-seed" | "spki";
|
|
4002
3547
|
type KeyType = "private" | "public" | "secret";
|
|
4003
3548
|
type KeyUsage =
|
|
3549
|
+
| "decapsulateBits"
|
|
3550
|
+
| "decapsulateKey"
|
|
4004
3551
|
| "decrypt"
|
|
4005
3552
|
| "deriveBits"
|
|
4006
3553
|
| "deriveKey"
|
|
3554
|
+
| "encapsulateBits"
|
|
3555
|
+
| "encapsulateKey"
|
|
4007
3556
|
| "encrypt"
|
|
4008
3557
|
| "sign"
|
|
4009
3558
|
| "unwrapKey"
|
|
4010
3559
|
| "verify"
|
|
4011
3560
|
| "wrapKey";
|
|
4012
|
-
type AlgorithmIdentifier = Algorithm | string;
|
|
4013
3561
|
type HashAlgorithmIdentifier = AlgorithmIdentifier;
|
|
4014
3562
|
type NamedCurve = string;
|
|
4015
|
-
|
|
3563
|
+
interface AeadParams extends Algorithm {
|
|
3564
|
+
additionalData?: NodeJS.BufferSource;
|
|
3565
|
+
iv: NodeJS.BufferSource;
|
|
3566
|
+
tagLength: number;
|
|
3567
|
+
}
|
|
4016
3568
|
interface AesCbcParams extends Algorithm {
|
|
4017
|
-
iv: BufferSource;
|
|
3569
|
+
iv: NodeJS.BufferSource;
|
|
4018
3570
|
}
|
|
4019
3571
|
interface AesCtrParams extends Algorithm {
|
|
4020
|
-
counter: BufferSource;
|
|
3572
|
+
counter: NodeJS.BufferSource;
|
|
4021
3573
|
length: number;
|
|
4022
3574
|
}
|
|
4023
3575
|
interface AesDerivedKeyParams extends Algorithm {
|
|
4024
3576
|
length: number;
|
|
4025
3577
|
}
|
|
4026
|
-
interface AesGcmParams extends Algorithm {
|
|
4027
|
-
additionalData?: BufferSource;
|
|
4028
|
-
iv: BufferSource;
|
|
4029
|
-
tagLength?: number;
|
|
4030
|
-
}
|
|
4031
3578
|
interface AesKeyAlgorithm extends KeyAlgorithm {
|
|
4032
3579
|
length: number;
|
|
4033
3580
|
}
|
|
@@ -4037,6 +3584,23 @@ declare module "crypto" {
|
|
|
4037
3584
|
interface Algorithm {
|
|
4038
3585
|
name: string;
|
|
4039
3586
|
}
|
|
3587
|
+
interface Argon2Params extends Algorithm {
|
|
3588
|
+
associatedData?: NodeJS.BufferSource;
|
|
3589
|
+
memory: number;
|
|
3590
|
+
nonce: NodeJS.BufferSource;
|
|
3591
|
+
parallelism: number;
|
|
3592
|
+
passes: number;
|
|
3593
|
+
secretValue?: NodeJS.BufferSource;
|
|
3594
|
+
version?: number;
|
|
3595
|
+
}
|
|
3596
|
+
interface CShakeParams extends Algorithm {
|
|
3597
|
+
customization?: NodeJS.BufferSource;
|
|
3598
|
+
functionName?: NodeJS.BufferSource;
|
|
3599
|
+
outputLength: number;
|
|
3600
|
+
}
|
|
3601
|
+
interface ContextParams extends Algorithm {
|
|
3602
|
+
context?: NodeJS.BufferSource;
|
|
3603
|
+
}
|
|
4040
3604
|
interface EcKeyAlgorithm extends KeyAlgorithm {
|
|
4041
3605
|
namedCurve: NamedCurve;
|
|
4042
3606
|
}
|
|
@@ -4052,13 +3616,10 @@ declare module "crypto" {
|
|
|
4052
3616
|
interface EcdsaParams extends Algorithm {
|
|
4053
3617
|
hash: HashAlgorithmIdentifier;
|
|
4054
3618
|
}
|
|
4055
|
-
interface Ed448Params extends Algorithm {
|
|
4056
|
-
context?: BufferSource;
|
|
4057
|
-
}
|
|
4058
3619
|
interface HkdfParams extends Algorithm {
|
|
4059
3620
|
hash: HashAlgorithmIdentifier;
|
|
4060
|
-
info: BufferSource;
|
|
4061
|
-
salt: BufferSource;
|
|
3621
|
+
info: NodeJS.BufferSource;
|
|
3622
|
+
salt: NodeJS.BufferSource;
|
|
4062
3623
|
}
|
|
4063
3624
|
interface HmacImportParams extends Algorithm {
|
|
4064
3625
|
hash: HashAlgorithmIdentifier;
|
|
@@ -4072,6 +3633,10 @@ declare module "crypto" {
|
|
|
4072
3633
|
hash: HashAlgorithmIdentifier;
|
|
4073
3634
|
length?: number;
|
|
4074
3635
|
}
|
|
3636
|
+
interface KangarooTwelveParams extends Algorithm {
|
|
3637
|
+
customization?: NodeJS.BufferSource;
|
|
3638
|
+
outputLength: number;
|
|
3639
|
+
}
|
|
4075
3640
|
interface JsonWebKey {
|
|
4076
3641
|
alg?: string;
|
|
4077
3642
|
crv?: string;
|
|
@@ -4095,10 +3660,23 @@ declare module "crypto" {
|
|
|
4095
3660
|
interface KeyAlgorithm {
|
|
4096
3661
|
name: string;
|
|
4097
3662
|
}
|
|
3663
|
+
interface KmacImportParams extends Algorithm {
|
|
3664
|
+
length?: number;
|
|
3665
|
+
}
|
|
3666
|
+
interface KmacKeyAlgorithm extends KeyAlgorithm {
|
|
3667
|
+
length: number;
|
|
3668
|
+
}
|
|
3669
|
+
interface KmacKeyGenParams extends Algorithm {
|
|
3670
|
+
length?: number;
|
|
3671
|
+
}
|
|
3672
|
+
interface KmacParams extends Algorithm {
|
|
3673
|
+
customization?: NodeJS.BufferSource;
|
|
3674
|
+
outputLength: number;
|
|
3675
|
+
}
|
|
4098
3676
|
interface Pbkdf2Params extends Algorithm {
|
|
4099
3677
|
hash: HashAlgorithmIdentifier;
|
|
4100
3678
|
iterations: number;
|
|
4101
|
-
salt: BufferSource;
|
|
3679
|
+
salt: NodeJS.BufferSource;
|
|
4102
3680
|
}
|
|
4103
3681
|
interface RsaHashedImportParams extends Algorithm {
|
|
4104
3682
|
hash: HashAlgorithmIdentifier;
|
|
@@ -4118,7 +3696,7 @@ declare module "crypto" {
|
|
|
4118
3696
|
publicExponent: BigInteger;
|
|
4119
3697
|
}
|
|
4120
3698
|
interface RsaOaepParams extends Algorithm {
|
|
4121
|
-
label?: BufferSource;
|
|
3699
|
+
label?: NodeJS.BufferSource;
|
|
4122
3700
|
}
|
|
4123
3701
|
interface RsaOtherPrimesInfo {
|
|
4124
3702
|
d?: string;
|
|
@@ -4128,269 +3706,110 @@ declare module "crypto" {
|
|
|
4128
3706
|
interface RsaPssParams extends Algorithm {
|
|
4129
3707
|
saltLength: number;
|
|
4130
3708
|
}
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
*/
|
|
3709
|
+
interface TurboShakeParams extends Algorithm {
|
|
3710
|
+
domainSeparation?: number;
|
|
3711
|
+
outputLength: number;
|
|
3712
|
+
}
|
|
4136
3713
|
interface Crypto {
|
|
4137
|
-
/**
|
|
4138
|
-
* Provides access to the `SubtleCrypto` API.
|
|
4139
|
-
* @since v15.0.0
|
|
4140
|
-
*/
|
|
4141
3714
|
readonly subtle: SubtleCrypto;
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
*/
|
|
4151
|
-
getRandomValues<T extends Exclude<NodeJS.TypedArray, Float32Array | Float64Array>>(typedArray: T): T;
|
|
4152
|
-
/**
|
|
4153
|
-
* Generates a random {@link https://www.rfc-editor.org/rfc/rfc4122.txt RFC 4122} version 4 UUID.
|
|
4154
|
-
* The UUID is generated using a cryptographic pseudorandom number generator.
|
|
4155
|
-
* @since v16.7.0
|
|
4156
|
-
*/
|
|
3715
|
+
getRandomValues<
|
|
3716
|
+
T extends Exclude<
|
|
3717
|
+
NodeJS.NonSharedTypedArray,
|
|
3718
|
+
NodeJS.NonSharedFloat16Array | NodeJS.NonSharedFloat32Array | NodeJS.NonSharedFloat64Array
|
|
3719
|
+
>,
|
|
3720
|
+
>(
|
|
3721
|
+
typedArray: T,
|
|
3722
|
+
): T;
|
|
4157
3723
|
randomUUID(): UUID;
|
|
4158
|
-
CryptoKey: CryptoKeyConstructor;
|
|
4159
|
-
}
|
|
4160
|
-
// This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable.
|
|
4161
|
-
interface CryptoKeyConstructor {
|
|
4162
|
-
/** Illegal constructor */
|
|
4163
|
-
(_: { readonly _: unique symbol }): never; // Allows instanceof to work but not be callable by the user.
|
|
4164
|
-
readonly length: 0;
|
|
4165
|
-
readonly name: "CryptoKey";
|
|
4166
|
-
readonly prototype: CryptoKey;
|
|
4167
3724
|
}
|
|
4168
|
-
/**
|
|
4169
|
-
* @since v15.0.0
|
|
4170
|
-
*/
|
|
4171
3725
|
interface CryptoKey {
|
|
4172
|
-
/**
|
|
4173
|
-
* An object detailing the algorithm for which the key can be used along with additional algorithm-specific parameters.
|
|
4174
|
-
* @since v15.0.0
|
|
4175
|
-
*/
|
|
4176
3726
|
readonly algorithm: KeyAlgorithm;
|
|
4177
|
-
/**
|
|
4178
|
-
* When `true`, the {@link CryptoKey} can be extracted using either `subtleCrypto.exportKey()` or `subtleCrypto.wrapKey()`.
|
|
4179
|
-
* @since v15.0.0
|
|
4180
|
-
*/
|
|
4181
3727
|
readonly extractable: boolean;
|
|
4182
|
-
/**
|
|
4183
|
-
* A string identifying whether the key is a symmetric (`'secret'`) or asymmetric (`'private'` or `'public'`) key.
|
|
4184
|
-
* @since v15.0.0
|
|
4185
|
-
*/
|
|
4186
3728
|
readonly type: KeyType;
|
|
4187
|
-
/**
|
|
4188
|
-
* An array of strings identifying the operations for which the key may be used.
|
|
4189
|
-
*
|
|
4190
|
-
* The possible usages are:
|
|
4191
|
-
* - `'encrypt'` - The key may be used to encrypt data.
|
|
4192
|
-
* - `'decrypt'` - The key may be used to decrypt data.
|
|
4193
|
-
* - `'sign'` - The key may be used to generate digital signatures.
|
|
4194
|
-
* - `'verify'` - The key may be used to verify digital signatures.
|
|
4195
|
-
* - `'deriveKey'` - The key may be used to derive a new key.
|
|
4196
|
-
* - `'deriveBits'` - The key may be used to derive bits.
|
|
4197
|
-
* - `'wrapKey'` - The key may be used to wrap another key.
|
|
4198
|
-
* - `'unwrapKey'` - The key may be used to unwrap another key.
|
|
4199
|
-
*
|
|
4200
|
-
* Valid key usages depend on the key algorithm (identified by `cryptokey.algorithm.name`).
|
|
4201
|
-
* @since v15.0.0
|
|
4202
|
-
*/
|
|
4203
3729
|
readonly usages: KeyUsage[];
|
|
4204
3730
|
}
|
|
4205
|
-
/**
|
|
4206
|
-
* The `CryptoKeyPair` is a simple dictionary object with `publicKey` and `privateKey` properties, representing an asymmetric key pair.
|
|
4207
|
-
* @since v15.0.0
|
|
4208
|
-
*/
|
|
4209
3731
|
interface CryptoKeyPair {
|
|
4210
|
-
/**
|
|
4211
|
-
* A {@link CryptoKey} whose type will be `'private'`.
|
|
4212
|
-
* @since v15.0.0
|
|
4213
|
-
*/
|
|
4214
3732
|
privateKey: CryptoKey;
|
|
4215
|
-
/**
|
|
4216
|
-
* A {@link CryptoKey} whose type will be `'public'`.
|
|
4217
|
-
* @since v15.0.0
|
|
4218
|
-
*/
|
|
4219
3733
|
publicKey: CryptoKey;
|
|
4220
3734
|
}
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
3735
|
+
interface EncapsulatedBits {
|
|
3736
|
+
sharedKey: ArrayBuffer;
|
|
3737
|
+
ciphertext: ArrayBuffer;
|
|
3738
|
+
}
|
|
3739
|
+
interface EncapsulatedKey {
|
|
3740
|
+
sharedKey: CryptoKey;
|
|
3741
|
+
ciphertext: ArrayBuffer;
|
|
3742
|
+
}
|
|
4224
3743
|
interface SubtleCrypto {
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
3744
|
+
decapsulateBits(
|
|
3745
|
+
decapsulationAlgorithm: AlgorithmIdentifier,
|
|
3746
|
+
decapsulationKey: CryptoKey,
|
|
3747
|
+
ciphertext: NodeJS.BufferSource,
|
|
3748
|
+
): Promise<ArrayBuffer>;
|
|
3749
|
+
decapsulateKey(
|
|
3750
|
+
decapsulationAlgorithm: AlgorithmIdentifier,
|
|
3751
|
+
decapsulationKey: CryptoKey,
|
|
3752
|
+
ciphertext: NodeJS.BufferSource,
|
|
3753
|
+
sharedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | AesDerivedKeyParams | KmacImportParams,
|
|
3754
|
+
extractable: boolean,
|
|
3755
|
+
keyUsages: KeyUsage[],
|
|
3756
|
+
): Promise<CryptoKey>;
|
|
4238
3757
|
decrypt(
|
|
4239
|
-
algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams |
|
|
3758
|
+
algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
|
|
4240
3759
|
key: CryptoKey,
|
|
4241
|
-
data: BufferSource,
|
|
3760
|
+
data: NodeJS.BufferSource,
|
|
4242
3761
|
): Promise<ArrayBuffer>;
|
|
4243
|
-
/**
|
|
4244
|
-
* Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`,
|
|
4245
|
-
* `subtle.deriveBits()` attempts to generate `length` bits.
|
|
4246
|
-
* The Node.js implementation requires that when `length` is a number it must be multiple of `8`.
|
|
4247
|
-
* When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed
|
|
4248
|
-
* for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms.
|
|
4249
|
-
* If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the generated data.
|
|
4250
|
-
*
|
|
4251
|
-
* The algorithms currently supported include:
|
|
4252
|
-
*
|
|
4253
|
-
* - `'ECDH'`
|
|
4254
|
-
* - `'X25519'`
|
|
4255
|
-
* - `'X448'`
|
|
4256
|
-
* - `'HKDF'`
|
|
4257
|
-
* - `'PBKDF2'`
|
|
4258
|
-
* @since v15.0.0
|
|
4259
|
-
*/
|
|
4260
3762
|
deriveBits(
|
|
4261
|
-
algorithm: EcdhKeyDeriveParams,
|
|
3763
|
+
algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params | Argon2Params,
|
|
4262
3764
|
baseKey: CryptoKey,
|
|
4263
3765
|
length?: number | null,
|
|
4264
3766
|
): Promise<ArrayBuffer>;
|
|
4265
|
-
deriveBits(
|
|
4266
|
-
algorithm: EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
|
|
4267
|
-
baseKey: CryptoKey,
|
|
4268
|
-
length: number,
|
|
4269
|
-
): Promise<ArrayBuffer>;
|
|
4270
|
-
/**
|
|
4271
|
-
* Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`,
|
|
4272
|
-
* `subtle.deriveKey()` attempts to generate a new <CryptoKey>` based on the method and parameters in `derivedKeyAlgorithm`.
|
|
4273
|
-
*
|
|
4274
|
-
* Calling `subtle.deriveKey()` is equivalent to calling `subtle.deriveBits()` to generate raw keying material,
|
|
4275
|
-
* then passing the result into the `subtle.importKey()` method using the `deriveKeyAlgorithm`, `extractable`, and `keyUsages` parameters as input.
|
|
4276
|
-
*
|
|
4277
|
-
* The algorithms currently supported include:
|
|
4278
|
-
*
|
|
4279
|
-
* - `'ECDH'`
|
|
4280
|
-
* - `'X25519'`
|
|
4281
|
-
* - `'X448'`
|
|
4282
|
-
* - `'HKDF'`
|
|
4283
|
-
* - `'PBKDF2'`
|
|
4284
|
-
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
4285
|
-
* @since v15.0.0
|
|
4286
|
-
*/
|
|
4287
3767
|
deriveKey(
|
|
4288
|
-
algorithm: EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
|
|
3768
|
+
algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params | Argon2Params,
|
|
4289
3769
|
baseKey: CryptoKey,
|
|
4290
|
-
|
|
3770
|
+
derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | KmacImportParams,
|
|
4291
3771
|
extractable: boolean,
|
|
4292
3772
|
keyUsages: readonly KeyUsage[],
|
|
4293
3773
|
): Promise<CryptoKey>;
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
/**
|
|
4310
|
-
* Using the method and parameters specified by `algorithm` and the keying material provided by `key`,
|
|
4311
|
-
* `subtle.encrypt()` attempts to encipher `data`. If successful,
|
|
4312
|
-
* the returned promise is resolved with an `<ArrayBuffer>` containing the encrypted result.
|
|
4313
|
-
*
|
|
4314
|
-
* The algorithms currently supported include:
|
|
4315
|
-
*
|
|
4316
|
-
* - `'RSA-OAEP'`
|
|
4317
|
-
* - `'AES-CTR'`
|
|
4318
|
-
* - `'AES-CBC'`
|
|
4319
|
-
* - `'AES-GCM'`
|
|
4320
|
-
* @since v15.0.0
|
|
4321
|
-
*/
|
|
3774
|
+
digest(
|
|
3775
|
+
algorithm: AlgorithmIdentifier | CShakeParams | TurboShakeParams | KangarooTwelveParams,
|
|
3776
|
+
data: NodeJS.BufferSource,
|
|
3777
|
+
): Promise<ArrayBuffer>;
|
|
3778
|
+
encapsulateBits(
|
|
3779
|
+
encapsulationAlgorithm: AlgorithmIdentifier,
|
|
3780
|
+
encapsulationKey: CryptoKey,
|
|
3781
|
+
): Promise<EncapsulatedBits>;
|
|
3782
|
+
encapsulateKey(
|
|
3783
|
+
encapsulationAlgorithm: AlgorithmIdentifier,
|
|
3784
|
+
encapsulationKey: CryptoKey,
|
|
3785
|
+
sharedKeyAlgorithm: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | KmacImportParams,
|
|
3786
|
+
extractable: boolean,
|
|
3787
|
+
keyUsages: KeyUsage[],
|
|
3788
|
+
): Promise<EncapsulatedKey>;
|
|
4322
3789
|
encrypt(
|
|
4323
|
-
algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams |
|
|
3790
|
+
algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
|
|
4324
3791
|
key: CryptoKey,
|
|
4325
|
-
data: BufferSource,
|
|
3792
|
+
data: NodeJS.BufferSource,
|
|
4326
3793
|
): Promise<ArrayBuffer>;
|
|
4327
|
-
/**
|
|
4328
|
-
* Exports the given key into the specified format, if supported.
|
|
4329
|
-
*
|
|
4330
|
-
* If the `<CryptoKey>` is not extractable, the returned promise will reject.
|
|
4331
|
-
*
|
|
4332
|
-
* When `format` is either `'pkcs8'` or `'spki'` and the export is successful,
|
|
4333
|
-
* the returned promise will be resolved with an `<ArrayBuffer>` containing the exported key data.
|
|
4334
|
-
*
|
|
4335
|
-
* When `format` is `'jwk'` and the export is successful, the returned promise will be resolved with a
|
|
4336
|
-
* JavaScript object conforming to the {@link https://tools.ietf.org/html/rfc7517 JSON Web Key} specification.
|
|
4337
|
-
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
4338
|
-
* @returns `<Promise>` containing `<ArrayBuffer>`.
|
|
4339
|
-
* @since v15.0.0
|
|
4340
|
-
*/
|
|
4341
3794
|
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
|
|
4342
3795
|
exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
|
|
4343
|
-
|
|
4344
|
-
* Using the method and parameters provided in `algorithm`,
|
|
4345
|
-
* `subtle.generateKey()` attempts to generate new keying material.
|
|
4346
|
-
* Depending the method used, the method may generate either a single `<CryptoKey>` or a `<CryptoKeyPair>`.
|
|
4347
|
-
*
|
|
4348
|
-
* The `<CryptoKeyPair>` (public and private key) generating algorithms supported include:
|
|
4349
|
-
*
|
|
4350
|
-
* - `'RSASSA-PKCS1-v1_5'`
|
|
4351
|
-
* - `'RSA-PSS'`
|
|
4352
|
-
* - `'RSA-OAEP'`
|
|
4353
|
-
* - `'ECDSA'`
|
|
4354
|
-
* - `'Ed25519'`
|
|
4355
|
-
* - `'Ed448'`
|
|
4356
|
-
* - `'ECDH'`
|
|
4357
|
-
* - `'X25519'`
|
|
4358
|
-
* - `'X448'`
|
|
4359
|
-
* The `<CryptoKey>` (secret key) generating algorithms supported include:
|
|
4360
|
-
*
|
|
4361
|
-
* - `'HMAC'`
|
|
4362
|
-
* - `'AES-CTR'`
|
|
4363
|
-
* - `'AES-CBC'`
|
|
4364
|
-
* - `'AES-GCM'`
|
|
4365
|
-
* - `'AES-KW'`
|
|
4366
|
-
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
4367
|
-
* @since v15.0.0
|
|
4368
|
-
*/
|
|
3796
|
+
exportKey(format: KeyFormat, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
|
|
4369
3797
|
generateKey(
|
|
4370
3798
|
algorithm: RsaHashedKeyGenParams | EcKeyGenParams,
|
|
4371
3799
|
extractable: boolean,
|
|
4372
|
-
keyUsages:
|
|
3800
|
+
keyUsages: KeyUsage[],
|
|
4373
3801
|
): Promise<CryptoKeyPair>;
|
|
4374
3802
|
generateKey(
|
|
4375
|
-
algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params,
|
|
3803
|
+
algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params | KmacKeyGenParams,
|
|
4376
3804
|
extractable: boolean,
|
|
4377
|
-
keyUsages:
|
|
3805
|
+
keyUsages: KeyUsage[],
|
|
4378
3806
|
): Promise<CryptoKey>;
|
|
4379
3807
|
generateKey(
|
|
4380
3808
|
algorithm: AlgorithmIdentifier,
|
|
4381
3809
|
extractable: boolean,
|
|
4382
3810
|
keyUsages: KeyUsage[],
|
|
4383
3811
|
): Promise<CryptoKeyPair | CryptoKey>;
|
|
4384
|
-
|
|
4385
|
-
* The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format`
|
|
4386
|
-
* to create a `<CryptoKey>` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments.
|
|
4387
|
-
* If the import is successful, the returned promise will be resolved with the created `<CryptoKey>`.
|
|
4388
|
-
*
|
|
4389
|
-
* If importing a `'PBKDF2'` key, `extractable` must be `false`.
|
|
4390
|
-
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
4391
|
-
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
4392
|
-
* @since v15.0.0
|
|
4393
|
-
*/
|
|
3812
|
+
getPublicKey(key: CryptoKey, keyUsages: KeyUsage[]): Promise<CryptoKey>;
|
|
4394
3813
|
importKey(
|
|
4395
3814
|
format: "jwk",
|
|
4396
3815
|
keyData: JsonWebKey,
|
|
@@ -4399,147 +3818,147 @@ declare module "crypto" {
|
|
|
4399
3818
|
| RsaHashedImportParams
|
|
4400
3819
|
| EcKeyImportParams
|
|
4401
3820
|
| HmacImportParams
|
|
4402
|
-
| AesKeyAlgorithm
|
|
3821
|
+
| AesKeyAlgorithm
|
|
3822
|
+
| KmacImportParams,
|
|
4403
3823
|
extractable: boolean,
|
|
4404
|
-
keyUsages:
|
|
3824
|
+
keyUsages: KeyUsage[],
|
|
4405
3825
|
): Promise<CryptoKey>;
|
|
4406
3826
|
importKey(
|
|
4407
3827
|
format: Exclude<KeyFormat, "jwk">,
|
|
4408
|
-
keyData: BufferSource,
|
|
3828
|
+
keyData: NodeJS.BufferSource,
|
|
4409
3829
|
algorithm:
|
|
4410
3830
|
| AlgorithmIdentifier
|
|
4411
3831
|
| RsaHashedImportParams
|
|
4412
3832
|
| EcKeyImportParams
|
|
4413
3833
|
| HmacImportParams
|
|
4414
|
-
| AesKeyAlgorithm
|
|
3834
|
+
| AesKeyAlgorithm
|
|
3835
|
+
| KmacImportParams,
|
|
4415
3836
|
extractable: boolean,
|
|
4416
3837
|
keyUsages: KeyUsage[],
|
|
4417
3838
|
): Promise<CryptoKey>;
|
|
4418
|
-
/**
|
|
4419
|
-
* Using the method and parameters given by `algorithm` and the keying material provided by `key`,
|
|
4420
|
-
* `subtle.sign()` attempts to generate a cryptographic signature of `data`. If successful,
|
|
4421
|
-
* the returned promise is resolved with an `<ArrayBuffer>` containing the generated signature.
|
|
4422
|
-
*
|
|
4423
|
-
* The algorithms currently supported include:
|
|
4424
|
-
*
|
|
4425
|
-
* - `'RSASSA-PKCS1-v1_5'`
|
|
4426
|
-
* - `'RSA-PSS'`
|
|
4427
|
-
* - `'ECDSA'`
|
|
4428
|
-
* - `'Ed25519'`
|
|
4429
|
-
* - `'Ed448'`
|
|
4430
|
-
* - `'HMAC'`
|
|
4431
|
-
* @since v15.0.0
|
|
4432
|
-
*/
|
|
4433
3839
|
sign(
|
|
4434
|
-
algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams |
|
|
3840
|
+
algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | ContextParams | KmacParams,
|
|
4435
3841
|
key: CryptoKey,
|
|
4436
|
-
data: BufferSource,
|
|
3842
|
+
data: NodeJS.BufferSource,
|
|
4437
3843
|
): Promise<ArrayBuffer>;
|
|
4438
|
-
/**
|
|
4439
|
-
* In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
|
|
4440
|
-
* The `subtle.unwrapKey()` method attempts to decrypt a wrapped key and create a `<CryptoKey>` instance.
|
|
4441
|
-
* It is equivalent to calling `subtle.decrypt()` first on the encrypted key data (using the `wrappedKey`, `unwrapAlgo`, and `unwrappingKey` arguments as input)
|
|
4442
|
-
* then passing the results in to the `subtle.importKey()` method using the `unwrappedKeyAlgo`, `extractable`, and `keyUsages` arguments as inputs.
|
|
4443
|
-
* If successful, the returned promise is resolved with a `<CryptoKey>` object.
|
|
4444
|
-
*
|
|
4445
|
-
* The wrapping algorithms currently supported include:
|
|
4446
|
-
*
|
|
4447
|
-
* - `'RSA-OAEP'`
|
|
4448
|
-
* - `'AES-CTR'`
|
|
4449
|
-
* - `'AES-CBC'`
|
|
4450
|
-
* - `'AES-GCM'`
|
|
4451
|
-
* - `'AES-KW'`
|
|
4452
|
-
*
|
|
4453
|
-
* The unwrapped key algorithms supported include:
|
|
4454
|
-
*
|
|
4455
|
-
* - `'RSASSA-PKCS1-v1_5'`
|
|
4456
|
-
* - `'RSA-PSS'`
|
|
4457
|
-
* - `'RSA-OAEP'`
|
|
4458
|
-
* - `'ECDSA'`
|
|
4459
|
-
* - `'Ed25519'`
|
|
4460
|
-
* - `'Ed448'`
|
|
4461
|
-
* - `'ECDH'`
|
|
4462
|
-
* - `'X25519'`
|
|
4463
|
-
* - `'X448'`
|
|
4464
|
-
* - `'HMAC'`
|
|
4465
|
-
* - `'AES-CTR'`
|
|
4466
|
-
* - `'AES-CBC'`
|
|
4467
|
-
* - `'AES-GCM'`
|
|
4468
|
-
* - `'AES-KW'`
|
|
4469
|
-
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
4470
|
-
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
4471
|
-
* @since v15.0.0
|
|
4472
|
-
*/
|
|
4473
3844
|
unwrapKey(
|
|
4474
3845
|
format: KeyFormat,
|
|
4475
|
-
wrappedKey: BufferSource,
|
|
3846
|
+
wrappedKey: NodeJS.BufferSource,
|
|
4476
3847
|
unwrappingKey: CryptoKey,
|
|
4477
|
-
unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams |
|
|
3848
|
+
unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
|
|
4478
3849
|
unwrappedKeyAlgorithm:
|
|
4479
3850
|
| AlgorithmIdentifier
|
|
4480
3851
|
| RsaHashedImportParams
|
|
4481
3852
|
| EcKeyImportParams
|
|
4482
3853
|
| HmacImportParams
|
|
4483
|
-
| AesKeyAlgorithm
|
|
3854
|
+
| AesKeyAlgorithm
|
|
3855
|
+
| KmacImportParams,
|
|
4484
3856
|
extractable: boolean,
|
|
4485
3857
|
keyUsages: KeyUsage[],
|
|
4486
3858
|
): Promise<CryptoKey>;
|
|
4487
|
-
/**
|
|
4488
|
-
* Using the method and parameters given in `algorithm` and the keying material provided by `key`,
|
|
4489
|
-
* `subtle.verify()` attempts to verify that `signature` is a valid cryptographic signature of `data`.
|
|
4490
|
-
* The returned promise is resolved with either `true` or `false`.
|
|
4491
|
-
*
|
|
4492
|
-
* The algorithms currently supported include:
|
|
4493
|
-
*
|
|
4494
|
-
* - `'RSASSA-PKCS1-v1_5'`
|
|
4495
|
-
* - `'RSA-PSS'`
|
|
4496
|
-
* - `'ECDSA'`
|
|
4497
|
-
* - `'Ed25519'`
|
|
4498
|
-
* - `'Ed448'`
|
|
4499
|
-
* - `'HMAC'`
|
|
4500
|
-
* @since v15.0.0
|
|
4501
|
-
*/
|
|
4502
3859
|
verify(
|
|
4503
|
-
algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams |
|
|
3860
|
+
algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | ContextParams | KmacParams,
|
|
4504
3861
|
key: CryptoKey,
|
|
4505
|
-
signature: BufferSource,
|
|
4506
|
-
data: BufferSource,
|
|
3862
|
+
signature: NodeJS.BufferSource,
|
|
3863
|
+
data: NodeJS.BufferSource,
|
|
4507
3864
|
): Promise<boolean>;
|
|
4508
|
-
/**
|
|
4509
|
-
* In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
|
|
4510
|
-
* The `subtle.wrapKey()` method exports the keying material into the format identified by `format`,
|
|
4511
|
-
* then encrypts it using the method and parameters specified by `wrapAlgo` and the keying material provided by `wrappingKey`.
|
|
4512
|
-
* It is the equivalent to calling `subtle.exportKey()` using `format` and `key` as the arguments,
|
|
4513
|
-
* then passing the result to the `subtle.encrypt()` method using `wrappingKey` and `wrapAlgo` as inputs.
|
|
4514
|
-
* If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the encrypted key data.
|
|
4515
|
-
*
|
|
4516
|
-
* The wrapping algorithms currently supported include:
|
|
4517
|
-
*
|
|
4518
|
-
* - `'RSA-OAEP'`
|
|
4519
|
-
* - `'AES-CTR'`
|
|
4520
|
-
* - `'AES-CBC'`
|
|
4521
|
-
* - `'AES-GCM'`
|
|
4522
|
-
* - `'AES-KW'`
|
|
4523
|
-
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
4524
|
-
* @since v15.0.0
|
|
4525
|
-
*/
|
|
4526
3865
|
wrapKey(
|
|
4527
3866
|
format: KeyFormat,
|
|
4528
3867
|
key: CryptoKey,
|
|
4529
3868
|
wrappingKey: CryptoKey,
|
|
4530
|
-
wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams |
|
|
3869
|
+
wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
|
|
4531
3870
|
): Promise<ArrayBuffer>;
|
|
4532
3871
|
}
|
|
4533
3872
|
}
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
3873
|
+
/**
|
|
3874
|
+
* An object containing commonly used constants for crypto and security related
|
|
3875
|
+
* operations. The specific constants currently defined are described in
|
|
3876
|
+
* [Crypto constants](https://nodejs.org/docs/latest-v26.x/api/crypto.html#crypto-constants).
|
|
3877
|
+
* @since v6.3.0
|
|
3878
|
+
*/
|
|
3879
|
+
namespace constants {
|
|
3880
|
+
const OPENSSL_VERSION_NUMBER: number;
|
|
3881
|
+
const SSL_OP_ALL: number;
|
|
3882
|
+
const SSL_OP_ALLOW_NO_DHE_KEX: number;
|
|
3883
|
+
const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
|
|
3884
|
+
const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
|
|
3885
|
+
const SSL_OP_CISCO_ANYCONNECT: number;
|
|
3886
|
+
const SSL_OP_COOKIE_EXCHANGE: number;
|
|
3887
|
+
const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
|
|
3888
|
+
const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
|
|
3889
|
+
const SSL_OP_LEGACY_SERVER_CONNECT: number;
|
|
3890
|
+
const SSL_OP_NO_COMPRESSION: number;
|
|
3891
|
+
const SSL_OP_NO_ENCRYPT_THEN_MAC: number;
|
|
3892
|
+
const SSL_OP_NO_QUERY_MTU: number;
|
|
3893
|
+
const SSL_OP_NO_RENEGOTIATION: number;
|
|
3894
|
+
const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
|
|
3895
|
+
const SSL_OP_NO_SSLv2: number;
|
|
3896
|
+
const SSL_OP_NO_SSLv3: number;
|
|
3897
|
+
const SSL_OP_NO_TICKET: number;
|
|
3898
|
+
const SSL_OP_NO_TLSv1: number;
|
|
3899
|
+
const SSL_OP_NO_TLSv1_1: number;
|
|
3900
|
+
const SSL_OP_NO_TLSv1_2: number;
|
|
3901
|
+
const SSL_OP_NO_TLSv1_3: number;
|
|
3902
|
+
const SSL_OP_PRIORITIZE_CHACHA: number;
|
|
3903
|
+
const SSL_OP_TLS_ROLLBACK_BUG: number;
|
|
3904
|
+
const ENGINE_METHOD_RSA: number;
|
|
3905
|
+
const ENGINE_METHOD_DSA: number;
|
|
3906
|
+
const ENGINE_METHOD_DH: number;
|
|
3907
|
+
const ENGINE_METHOD_RAND: number;
|
|
3908
|
+
const ENGINE_METHOD_EC: number;
|
|
3909
|
+
const ENGINE_METHOD_CIPHERS: number;
|
|
3910
|
+
const ENGINE_METHOD_DIGESTS: number;
|
|
3911
|
+
const ENGINE_METHOD_PKEY_METHS: number;
|
|
3912
|
+
const ENGINE_METHOD_PKEY_ASN1_METHS: number;
|
|
3913
|
+
const ENGINE_METHOD_ALL: number;
|
|
3914
|
+
const ENGINE_METHOD_NONE: number;
|
|
3915
|
+
const DH_CHECK_P_NOT_SAFE_PRIME: number;
|
|
3916
|
+
const DH_CHECK_P_NOT_PRIME: number;
|
|
3917
|
+
const DH_UNABLE_TO_CHECK_GENERATOR: number;
|
|
3918
|
+
const DH_NOT_SUITABLE_GENERATOR: number;
|
|
3919
|
+
const RSA_PKCS1_PADDING: number;
|
|
3920
|
+
const RSA_NO_PADDING: number;
|
|
3921
|
+
const RSA_PKCS1_OAEP_PADDING: number;
|
|
3922
|
+
const RSA_X931_PADDING: number;
|
|
3923
|
+
const RSA_PKCS1_PSS_PADDING: number;
|
|
3924
|
+
const RSA_PSS_SALTLEN_DIGEST: number;
|
|
3925
|
+
const RSA_PSS_SALTLEN_MAX_SIGN: number;
|
|
3926
|
+
const RSA_PSS_SALTLEN_AUTO: number;
|
|
3927
|
+
const TLS1_VERSION: number;
|
|
3928
|
+
const TLS1_1_VERSION: number;
|
|
3929
|
+
const TLS1_2_VERSION: number;
|
|
3930
|
+
const TLS1_3_VERSION: number;
|
|
3931
|
+
const POINT_CONVERSION_COMPRESSED: number;
|
|
3932
|
+
const POINT_CONVERSION_UNCOMPRESSED: number;
|
|
3933
|
+
const POINT_CONVERSION_HYBRID: number;
|
|
3934
|
+
const defaultCipherList: string;
|
|
3935
|
+
const defaultCoreCipherList: string;
|
|
3936
|
+
}
|
|
3937
|
+
// TODO: remove in future major version
|
|
3938
|
+
/** @deprecated This type will be removed in a future version. Use `BufferEncoding` instead. */
|
|
3939
|
+
type BinaryToTextEncoding = "base64" | "base64url" | "hex" | "binary";
|
|
3940
|
+
/** @deprecated This type will be removed in a future version. Use `BufferEncoding` instead. */
|
|
3941
|
+
type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "utf-16le" | "latin1";
|
|
3942
|
+
/** @deprecated This type will be removed in a future version. Use `BufferEncoding` instead. */
|
|
3943
|
+
type LegacyCharacterEncoding = "ascii" | "binary" | "ucs2" | "ucs-2";
|
|
3944
|
+
/** @deprecated This type will be removed in a future version. Use `BufferEncoding` instead. */
|
|
3945
|
+
type Encoding = BufferEncoding;
|
|
3946
|
+
/** @deprecated This type will be removed in a future version. Use `KeyLike` instead. */
|
|
3947
|
+
type CipherKey = KeyLike;
|
|
3948
|
+
/** @deprecated This type will be removed in a future version. */
|
|
3949
|
+
interface RsaPrivateKey {
|
|
3950
|
+
key: KeyLike;
|
|
3951
|
+
passphrase?: string | undefined;
|
|
3952
|
+
oaepHash?: string | undefined;
|
|
3953
|
+
oaepLabel?: NodeJS.TypedArray | undefined;
|
|
3954
|
+
padding?: number | undefined;
|
|
3955
|
+
}
|
|
3956
|
+
/** @deprecated This type will be removed in a future version. */
|
|
3957
|
+
interface RsaPublicKey {
|
|
3958
|
+
key: KeyLike;
|
|
3959
|
+
padding?: number | undefined;
|
|
4541
3960
|
}
|
|
4542
3961
|
}
|
|
4543
|
-
declare module "
|
|
4544
|
-
export * from "crypto";
|
|
3962
|
+
declare module "crypto" {
|
|
3963
|
+
export * from "node:crypto";
|
|
4545
3964
|
}
|