UNPKG

45.8 kBTypeScriptView Raw
1declare module 'crypto' {
2 import * as stream from 'stream';
3
4 interface Certificate {
5 exportChallenge(spkac: BinaryLike): Buffer;
6 exportPublicKey(spkac: BinaryLike): Buffer;
7 verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
8 }
9 const Certificate: {
10 new (): Certificate;
11 (): Certificate;
12 };
13
14 namespace constants {
15 // https://nodejs.org/dist/latest-v10.x/docs/api/crypto.html#crypto_crypto_constants
16 const OPENSSL_VERSION_NUMBER: number;
17
18 /** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */
19 const SSL_OP_ALL: number;
20 /** 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. */
21 const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
22 /** 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. */
23 const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
24 /** Instructs OpenSSL to use Cisco's "speshul" version of DTLS_BAD_VER. */
25 const SSL_OP_CISCO_ANYCONNECT: number;
26 /** Instructs OpenSSL to turn on cookie exchange. */
27 const SSL_OP_COOKIE_EXCHANGE: number;
28 /** Instructs OpenSSL to add server-hello extension from an early version of the cryptopro draft. */
29 const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
30 /** Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround added in OpenSSL 0.9.6d. */
31 const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
32 /** Instructs OpenSSL to always use the tmp_rsa key when performing RSA operations. */
33 const SSL_OP_EPHEMERAL_RSA: number;
34 /** Allows initial connection to servers that do not support RI. */
35 const SSL_OP_LEGACY_SERVER_CONNECT: number;
36 const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
37 const SSL_OP_MICROSOFT_SESS_ID_BUG: number;
38 /** Instructs OpenSSL to disable the workaround for a man-in-the-middle protocol-version vulnerability in the SSL 2.0 server implementation. */
39 const SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
40 const SSL_OP_NETSCAPE_CA_DN_BUG: number;
41 const SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
42 const SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
43 const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
44 /** Instructs OpenSSL to disable support for SSL/TLS compression. */
45 const SSL_OP_NO_COMPRESSION: number;
46 const SSL_OP_NO_QUERY_MTU: number;
47 /** Instructs OpenSSL to always start a new session when performing renegotiation. */
48 const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
49 const SSL_OP_NO_SSLv2: number;
50 const SSL_OP_NO_SSLv3: number;
51 const SSL_OP_NO_TICKET: number;
52 const SSL_OP_NO_TLSv1: number;
53 const SSL_OP_NO_TLSv1_1: number;
54 const SSL_OP_NO_TLSv1_2: number;
55 const SSL_OP_PKCS1_CHECK_1: number;
56 const SSL_OP_PKCS1_CHECK_2: number;
57 /** Instructs OpenSSL to always create a new key when using temporary/ephemeral DH parameters. */
58 const SSL_OP_SINGLE_DH_USE: number;
59 /** Instructs OpenSSL to always create a new key when using temporary/ephemeral ECDH parameters. */
60 const SSL_OP_SINGLE_ECDH_USE: number;
61 const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
62 const SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
63 const SSL_OP_TLS_BLOCK_PADDING_BUG: number;
64 const SSL_OP_TLS_D5_BUG: number;
65 /** Instructs OpenSSL to disable version rollback attack detection. */
66 const SSL_OP_TLS_ROLLBACK_BUG: number;
67
68 const ENGINE_METHOD_RSA: number;
69 const ENGINE_METHOD_DSA: number;
70 const ENGINE_METHOD_DH: number;
71 const ENGINE_METHOD_RAND: number;
72 const ENGINE_METHOD_EC: number;
73 const ENGINE_METHOD_CIPHERS: number;
74 const ENGINE_METHOD_DIGESTS: number;
75 const ENGINE_METHOD_PKEY_METHS: number;
76 const ENGINE_METHOD_PKEY_ASN1_METHS: number;
77 const ENGINE_METHOD_ALL: number;
78 const ENGINE_METHOD_NONE: number;
79
80 const DH_CHECK_P_NOT_SAFE_PRIME: number;
81 const DH_CHECK_P_NOT_PRIME: number;
82 const DH_UNABLE_TO_CHECK_GENERATOR: number;
83 const DH_NOT_SUITABLE_GENERATOR: number;
84
85 const ALPN_ENABLED: number;
86
87 const RSA_PKCS1_PADDING: number;
88 const RSA_SSLV23_PADDING: number;
89 const RSA_NO_PADDING: number;
90 const RSA_PKCS1_OAEP_PADDING: number;
91 const RSA_X931_PADDING: number;
92 const RSA_PKCS1_PSS_PADDING: number;
93 /** Sets the salt length for RSA_PKCS1_PSS_PADDING to the digest size when signing or verifying. */
94 const RSA_PSS_SALTLEN_DIGEST: number;
95 /** Sets the salt length for RSA_PKCS1_PSS_PADDING to the maximum permissible value when signing data. */
96 const RSA_PSS_SALTLEN_MAX_SIGN: number;
97 /** Causes the salt length for RSA_PKCS1_PSS_PADDING to be determined automatically when verifying a signature. */
98 const RSA_PSS_SALTLEN_AUTO: number;
99
100 const POINT_CONVERSION_COMPRESSED: number;
101 const POINT_CONVERSION_UNCOMPRESSED: number;
102 const POINT_CONVERSION_HYBRID: number;
103
104 /** Specifies the built-in default cipher list used by Node.js (colon-separated values). */
105 const defaultCoreCipherList: string;
106 /** Specifies the active default cipher list used by the current Node.js process (colon-separated values). */
107 const defaultCipherList: string;
108 }
109
110 interface HashOptions extends stream.TransformOptions {
111 /**
112 * For XOF hash functions such as `shake256`, the
113 * outputLength option can be used to specify the desired output length in bytes.
114 */
115 outputLength?: number | undefined;
116 }
117
118 /** @deprecated since v10.0.0 */
119 const fips: boolean;
120
121 function createHash(algorithm: string, options?: HashOptions): Hash;
122 function createHmac(algorithm: string, key: BinaryLike, options?: stream.TransformOptions): Hmac;
123
124 type Utf8AsciiLatin1Encoding = 'utf8' | 'ascii' | 'latin1';
125 type HexBase64Latin1Encoding = 'latin1' | 'hex' | 'base64';
126 type Utf8AsciiBinaryEncoding = 'utf8' | 'ascii' | 'binary';
127 type HexBase64BinaryEncoding = 'binary' | 'base64' | 'hex';
128 type ECDHKeyFormat = 'compressed' | 'uncompressed' | 'hybrid';
129
130 class Hash extends stream.Transform {
131 private constructor();
132 update(data: BinaryLike): Hash;
133 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hash;
134 digest(): Buffer;
135 digest(encoding: HexBase64Latin1Encoding): string;
136 }
137 class Hmac extends stream.Transform {
138 private constructor();
139 update(data: BinaryLike): Hmac;
140 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hmac;
141 digest(): Buffer;
142 digest(encoding: HexBase64Latin1Encoding): string;
143 }
144
145 type KeyObjectType = 'secret' | 'public' | 'private';
146
147 interface KeyExportOptions<T extends KeyFormat> {
148 type: 'pkcs1' | 'spki' | 'pkcs8' | 'sec1';
149 format: T;
150 cipher?: string | undefined;
151 passphrase?: string | Buffer | undefined;
152 }
153
154 class KeyObject {
155 private constructor();
156 asymmetricKeyType?: KeyType | undefined;
157 /**
158 * For asymmetric keys, this property represents the size of the embedded key in
159 * bytes. This property is `undefined` for symmetric keys.
160 */
161 asymmetricKeySize?: number | undefined;
162 export(options: KeyExportOptions<'pem'>): string | Buffer;
163 export(options?: KeyExportOptions<'der'>): Buffer;
164 symmetricKeySize?: number | undefined;
165 type: KeyObjectType;
166 }
167
168 type CipherCCMTypes = 'aes-128-ccm' | 'aes-192-ccm' | 'aes-256-ccm';
169 type CipherGCMTypes = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
170
171 type BinaryLike = string | NodeJS.ArrayBufferView;
172
173 type CipherKey = BinaryLike | KeyObject;
174
175 interface CipherCCMOptions extends stream.TransformOptions {
176 authTagLength: number;
177 }
178 interface CipherGCMOptions extends stream.TransformOptions {
179 authTagLength?: number | undefined;
180 }
181 /** @deprecated since v10.0.0 use createCipheriv() */
182 function createCipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): CipherCCM;
183 /** @deprecated since v10.0.0 use createCipheriv() */
184 function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM;
185 /** @deprecated since v10.0.0 use createCipheriv() */
186 function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher;
187
188 function createCipheriv(
189 algorithm: CipherCCMTypes,
190 key: CipherKey,
191 iv: BinaryLike | null,
192 options: CipherCCMOptions,
193 ): CipherCCM;
194 function createCipheriv(
195 algorithm: CipherGCMTypes,
196 key: CipherKey,
197 iv: BinaryLike | null,
198 options?: CipherGCMOptions,
199 ): CipherGCM;
200 function createCipheriv(
201 algorithm: string,
202 key: CipherKey,
203 iv: BinaryLike | null,
204 options?: stream.TransformOptions,
205 ): Cipher;
206
207 class Cipher extends stream.Transform {
208 private constructor();
209 update(data: BinaryLike): Buffer;
210 update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer;
211 update(
212 data: NodeJS.ArrayBufferView,
213 input_encoding: undefined,
214 output_encoding: HexBase64BinaryEncoding,
215 ): string;
216 update(
217 data: string,
218 input_encoding: Utf8AsciiBinaryEncoding | undefined,
219 output_encoding: HexBase64BinaryEncoding,
220 ): string;
221 final(): Buffer;
222 final(output_encoding: string): string;
223 setAutoPadding(auto_padding?: boolean): this;
224 // getAuthTag(): Buffer;
225 // setAAD(buffer: NodeJS.ArrayBufferView): this;
226 }
227 interface CipherCCM extends Cipher {
228 setAAD(buffer: NodeJS.ArrayBufferView, options: { plaintextLength: number }): this;
229 getAuthTag(): Buffer;
230 }
231 interface CipherGCM extends Cipher {
232 setAAD(buffer: NodeJS.ArrayBufferView, options?: { plaintextLength: number }): this;
233 getAuthTag(): Buffer;
234 }
235 /** @deprecated since v10.0.0 use createDecipheriv() */
236 function createDecipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): DecipherCCM;
237 /** @deprecated since v10.0.0 use createDecipheriv() */
238 function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM;
239 /** @deprecated since v10.0.0 use createDecipheriv() */
240 function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher;
241
242 function createDecipheriv(
243 algorithm: CipherCCMTypes,
244 key: BinaryLike,
245 iv: BinaryLike | null,
246 options: CipherCCMOptions,
247 ): DecipherCCM;
248 function createDecipheriv(
249 algorithm: CipherGCMTypes,
250 key: BinaryLike,
251 iv: BinaryLike | null,
252 options?: CipherGCMOptions,
253 ): DecipherGCM;
254 function createDecipheriv(
255 algorithm: string,
256 key: BinaryLike,
257 iv: BinaryLike | null,
258 options?: stream.TransformOptions,
259 ): Decipher;
260
261 class Decipher extends stream.Transform {
262 private constructor();
263 update(data: NodeJS.ArrayBufferView): Buffer;
264 update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer;
265 update(
266 data: NodeJS.ArrayBufferView,
267 input_encoding: HexBase64BinaryEncoding | undefined,
268 output_encoding: Utf8AsciiBinaryEncoding,
269 ): string;
270 update(
271 data: string,
272 input_encoding: HexBase64BinaryEncoding | undefined,
273 output_encoding: Utf8AsciiBinaryEncoding,
274 ): string;
275 final(): Buffer;
276 final(output_encoding: string): string;
277 setAutoPadding(auto_padding?: boolean): this;
278 // setAuthTag(tag: NodeJS.ArrayBufferView): this;
279 // setAAD(buffer: NodeJS.ArrayBufferView): this;
280 }
281 interface DecipherCCM extends Decipher {
282 setAuthTag(buffer: NodeJS.ArrayBufferView): this;
283 setAAD(buffer: NodeJS.ArrayBufferView, options: { plaintextLength: number }): this;
284 }
285 interface DecipherGCM extends Decipher {
286 setAuthTag(buffer: NodeJS.ArrayBufferView): this;
287 setAAD(buffer: NodeJS.ArrayBufferView, options?: { plaintextLength: number }): this;
288 }
289
290 interface PrivateKeyInput {
291 key: string | Buffer;
292 format?: KeyFormat | undefined;
293 type?: 'pkcs1' | 'pkcs8' | 'sec1' | undefined;
294 passphrase?: string | Buffer | undefined;
295 }
296
297 interface PublicKeyInput {
298 key: string | Buffer;
299 format?: KeyFormat | undefined;
300 type?: 'pkcs1' | 'spki' | undefined;
301 }
302
303 function createPrivateKey(key: PrivateKeyInput | string | Buffer): KeyObject;
304 function createPublicKey(key: PublicKeyInput | string | Buffer | KeyObject): KeyObject;
305 function createSecretKey(key: NodeJS.ArrayBufferView): KeyObject;
306
307 function createSign(algorithm: string, options?: stream.WritableOptions): Signer;
308
309 type DSAEncoding = 'der' | 'ieee-p1363';
310
311 interface SigningOptions {
312 /**
313 * @See crypto.constants.RSA_PKCS1_PADDING
314 */
315 padding?: number | undefined;
316 saltLength?: number | undefined;
317 dsaEncoding?: DSAEncoding | undefined;
318 }
319
320 interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {}
321 interface SignKeyObjectInput extends SigningOptions {
322 key: KeyObject;
323 }
324 interface VerifyPublicKeyInput extends PublicKeyInput, SigningOptions {}
325 interface VerifyKeyObjectInput extends SigningOptions {
326 key: KeyObject;
327 }
328
329 type KeyLike = string | Buffer | KeyObject;
330
331 class Signer extends stream.Writable {
332 private constructor();
333
334 update(data: BinaryLike): Signer;
335 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Signer;
336 sign(private_key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput): Buffer;
337 sign(
338 private_key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
339 output_format: HexBase64Latin1Encoding,
340 ): string;
341 }
342
343 function createVerify(algorithm: string, options?: stream.WritableOptions): Verify;
344 class Verify extends stream.Writable {
345 private constructor();
346
347 update(data: BinaryLike): Verify;
348 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Verify;
349 verify(
350 object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput,
351 signature: NodeJS.ArrayBufferView,
352 ): boolean;
353 verify(
354 object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput,
355 signature: string,
356 signature_format?: HexBase64Latin1Encoding,
357 ): boolean;
358 // https://nodejs.org/api/crypto.html#crypto_verifier_verify_object_signature_signature_format
359 // The signature field accepts a TypedArray type, but it is only available starting ES2017
360 }
361 function createDiffieHellman(prime_length: number, generator?: number | NodeJS.ArrayBufferView): DiffieHellman;
362 function createDiffieHellman(prime: NodeJS.ArrayBufferView): DiffieHellman;
363 function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman;
364 function createDiffieHellman(
365 prime: string,
366 prime_encoding: HexBase64Latin1Encoding,
367 generator: number | NodeJS.ArrayBufferView,
368 ): DiffieHellman;
369 function createDiffieHellman(
370 prime: string,
371 prime_encoding: HexBase64Latin1Encoding,
372 generator: string,
373 generator_encoding: HexBase64Latin1Encoding,
374 ): DiffieHellman;
375 class DiffieHellman {
376 private constructor();
377 generateKeys(): Buffer;
378 generateKeys(encoding: HexBase64Latin1Encoding): string;
379 computeSecret(other_public_key: NodeJS.ArrayBufferView): Buffer;
380 computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
381 computeSecret(other_public_key: NodeJS.ArrayBufferView, output_encoding: HexBase64Latin1Encoding): string;
382 computeSecret(
383 other_public_key: string,
384 input_encoding: HexBase64Latin1Encoding,
385 output_encoding: HexBase64Latin1Encoding,
386 ): string;
387 getPrime(): Buffer;
388 getPrime(encoding: HexBase64Latin1Encoding): string;
389 getGenerator(): Buffer;
390 getGenerator(encoding: HexBase64Latin1Encoding): string;
391 getPublicKey(): Buffer;
392 getPublicKey(encoding: HexBase64Latin1Encoding): string;
393 getPrivateKey(): Buffer;
394 getPrivateKey(encoding: HexBase64Latin1Encoding): string;
395 setPublicKey(public_key: NodeJS.ArrayBufferView): void;
396 setPublicKey(public_key: string, encoding: string): void;
397 setPrivateKey(private_key: NodeJS.ArrayBufferView): void;
398 setPrivateKey(private_key: string, encoding: string): void;
399 verifyError: number;
400 }
401 function getDiffieHellman(group_name: string): DiffieHellman;
402 function pbkdf2(
403 password: BinaryLike,
404 salt: BinaryLike,
405 iterations: number,
406 keylen: number,
407 digest: string,
408 callback: (err: Error | null, derivedKey: Buffer) => any,
409 ): void;
410 function pbkdf2Sync(
411 password: BinaryLike,
412 salt: BinaryLike,
413 iterations: number,
414 keylen: number,
415 digest: string,
416 ): Buffer;
417
418 function randomBytes(size: number): Buffer;
419 function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
420 function pseudoRandomBytes(size: number): Buffer;
421 function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
422
423 function randomInt(max: number): number;
424 function randomInt(min: number, max: number): number;
425 function randomInt(max: number, callback: (err: Error | null, value: number) => void): void;
426 function randomInt(min: number, max: number, callback: (err: Error | null, value: number) => void): void;
427
428 function randomFillSync<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number, size?: number): T;
429 function randomFill<T extends NodeJS.ArrayBufferView>(
430 buffer: T,
431 callback: (err: Error | null, buf: T) => void,
432 ): void;
433 function randomFill<T extends NodeJS.ArrayBufferView>(
434 buffer: T,
435 offset: number,
436 callback: (err: Error | null, buf: T) => void,
437 ): void;
438 function randomFill<T extends NodeJS.ArrayBufferView>(
439 buffer: T,
440 offset: number,
441 size: number,
442 callback: (err: Error | null, buf: T) => void,
443 ): void;
444
445 interface ScryptOptions {
446 cost?: number | undefined;
447 blockSize?: number | undefined;
448 parallelization?: number | undefined;
449 N?: number | undefined;
450 r?: number | undefined;
451 p?: number | undefined;
452 maxmem?: number | undefined;
453 }
454 function scrypt(
455 password: BinaryLike,
456 salt: BinaryLike,
457 keylen: number,
458 callback: (err: Error | null, derivedKey: Buffer) => void,
459 ): void;
460 function scrypt(
461 password: BinaryLike,
462 salt: BinaryLike,
463 keylen: number,
464 options: ScryptOptions,
465 callback: (err: Error | null, derivedKey: Buffer) => void,
466 ): void;
467 function scryptSync(password: BinaryLike, salt: BinaryLike, keylen: number, options?: ScryptOptions): Buffer;
468
469 interface RsaPublicKey {
470 key: KeyLike;
471 padding?: number | undefined;
472 }
473 interface RsaPrivateKey {
474 key: KeyLike;
475 passphrase?: string | undefined;
476 /**
477 * @default 'sha1'
478 */
479 oaepHash?: string | undefined;
480 oaepLabel?: NodeJS.TypedArray | undefined;
481 padding?: number | undefined;
482 }
483 function publicEncrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
484 function publicDecrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
485 function privateDecrypt(private_key: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
486 function privateEncrypt(private_key: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
487 function getCiphers(): string[];
488 function getCurves(): string[];
489 function getFips(): 1 | 0;
490 function getHashes(): string[];
491 class ECDH {
492 private constructor();
493 static convertKey(
494 key: BinaryLike,
495 curve: string,
496 inputEncoding?: HexBase64Latin1Encoding,
497 outputEncoding?: 'latin1' | 'hex' | 'base64',
498 format?: 'uncompressed' | 'compressed' | 'hybrid',
499 ): Buffer | string;
500 generateKeys(): Buffer;
501 generateKeys(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
502 computeSecret(other_public_key: NodeJS.ArrayBufferView): Buffer;
503 computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
504 computeSecret(other_public_key: NodeJS.ArrayBufferView, output_encoding: HexBase64Latin1Encoding): string;
505 computeSecret(
506 other_public_key: string,
507 input_encoding: HexBase64Latin1Encoding,
508 output_encoding: HexBase64Latin1Encoding,
509 ): string;
510 getPrivateKey(): Buffer;
511 getPrivateKey(encoding: HexBase64Latin1Encoding): string;
512 getPublicKey(): Buffer;
513 getPublicKey(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
514 setPrivateKey(private_key: NodeJS.ArrayBufferView): void;
515 setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void;
516 }
517 function createECDH(curve_name: string): ECDH;
518 function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
519 /** @deprecated since v10.0.0 */
520 const DEFAULT_ENCODING: string;
521
522 type KeyType = 'rsa' | 'dsa' | 'ec' | 'ed25519' | 'ed448' | 'x25519' | 'x448';
523 type KeyFormat = 'pem' | 'der';
524
525 interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
526 format: T;
527 cipher?: string | undefined;
528 passphrase?: string | undefined;
529 }
530
531 interface KeyPairKeyObjectResult {
532 publicKey: KeyObject;
533 privateKey: KeyObject;
534 }
535
536 interface ED25519KeyPairKeyObjectOptions {
537 /**
538 * No options.
539 */
540 }
541
542 interface ED448KeyPairKeyObjectOptions {
543 /**
544 * No options.
545 */
546 }
547
548 interface X25519KeyPairKeyObjectOptions {
549 /**
550 * No options.
551 */
552 }
553
554 interface X448KeyPairKeyObjectOptions {
555 /**
556 * No options.
557 */
558 }
559
560 interface ECKeyPairKeyObjectOptions {
561 /**
562 * Name of the curve to use.
563 */
564 namedCurve: string;
565 }
566
567 interface RSAKeyPairKeyObjectOptions {
568 /**
569 * Key size in bits
570 */
571 modulusLength: number;
572
573 /**
574 * @default 0x10001
575 */
576 publicExponent?: number | undefined;
577 }
578
579 interface DSAKeyPairKeyObjectOptions {
580 /**
581 * Key size in bits
582 */
583 modulusLength: number;
584
585 /**
586 * Size of q in bits
587 */
588 divisorLength: number;
589 }
590
591 interface RSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
592 /**
593 * Key size in bits
594 */
595 modulusLength: number;
596 /**
597 * @default 0x10001
598 */
599 publicExponent?: number | undefined;
600
601 publicKeyEncoding: {
602 type: 'pkcs1' | 'spki';
603 format: PubF;
604 };
605 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
606 type: 'pkcs1' | 'pkcs8';
607 };
608 }
609
610 interface DSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
611 /**
612 * Key size in bits
613 */
614 modulusLength: number;
615 /**
616 * Size of q in bits
617 */
618 divisorLength: number;
619
620 publicKeyEncoding: {
621 type: 'spki';
622 format: PubF;
623 };
624 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
625 type: 'pkcs8';
626 };
627 }
628
629 interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
630 /**
631 * Name of the curve to use.
632 */
633 namedCurve: string;
634
635 publicKeyEncoding: {
636 type: 'pkcs1' | 'spki';
637 format: PubF;
638 };
639 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
640 type: 'sec1' | 'pkcs8';
641 };
642 }
643
644 interface ED25519KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
645 publicKeyEncoding: {
646 type: 'spki';
647 format: PubF;
648 };
649 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
650 type: 'pkcs8';
651 };
652 }
653
654 interface ED448KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
655 publicKeyEncoding: {
656 type: 'spki';
657 format: PubF;
658 };
659 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
660 type: 'pkcs8';
661 };
662 }
663
664 interface X25519KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
665 publicKeyEncoding: {
666 type: 'spki';
667 format: PubF;
668 };
669 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
670 type: 'pkcs8';
671 };
672 }
673
674 interface X448KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
675 publicKeyEncoding: {
676 type: 'spki';
677 format: PubF;
678 };
679 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
680 type: 'pkcs8';
681 };
682 }
683
684 interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
685 publicKey: T1;
686 privateKey: T2;
687 }
688
689 function generateKeyPairSync(
690 type: 'rsa',
691 options: RSAKeyPairOptions<'pem', 'pem'>,
692 ): KeyPairSyncResult<string, string>;
693 function generateKeyPairSync(
694 type: 'rsa',
695 options: RSAKeyPairOptions<'pem', 'der'>,
696 ): KeyPairSyncResult<string, Buffer>;
697 function generateKeyPairSync(
698 type: 'rsa',
699 options: RSAKeyPairOptions<'der', 'pem'>,
700 ): KeyPairSyncResult<Buffer, string>;
701 function generateKeyPairSync(
702 type: 'rsa',
703 options: RSAKeyPairOptions<'der', 'der'>,
704 ): KeyPairSyncResult<Buffer, Buffer>;
705 function generateKeyPairSync(type: 'rsa', options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
706
707 function generateKeyPairSync(
708 type: 'dsa',
709 options: DSAKeyPairOptions<'pem', 'pem'>,
710 ): KeyPairSyncResult<string, string>;
711 function generateKeyPairSync(
712 type: 'dsa',
713 options: DSAKeyPairOptions<'pem', 'der'>,
714 ): KeyPairSyncResult<string, Buffer>;
715 function generateKeyPairSync(
716 type: 'dsa',
717 options: DSAKeyPairOptions<'der', 'pem'>,
718 ): KeyPairSyncResult<Buffer, string>;
719 function generateKeyPairSync(
720 type: 'dsa',
721 options: DSAKeyPairOptions<'der', 'der'>,
722 ): KeyPairSyncResult<Buffer, Buffer>;
723 function generateKeyPairSync(type: 'dsa', options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
724
725 function generateKeyPairSync(
726 type: 'ec',
727 options: ECKeyPairOptions<'pem', 'pem'>,
728 ): KeyPairSyncResult<string, string>;
729 function generateKeyPairSync(
730 type: 'ec',
731 options: ECKeyPairOptions<'pem', 'der'>,
732 ): KeyPairSyncResult<string, Buffer>;
733 function generateKeyPairSync(
734 type: 'ec',
735 options: ECKeyPairOptions<'der', 'pem'>,
736 ): KeyPairSyncResult<Buffer, string>;
737 function generateKeyPairSync(
738 type: 'ec',
739 options: ECKeyPairOptions<'der', 'der'>,
740 ): KeyPairSyncResult<Buffer, Buffer>;
741 function generateKeyPairSync(type: 'ec', options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
742
743 function generateKeyPairSync(
744 type: 'ed25519',
745 options: ED25519KeyPairOptions<'pem', 'pem'>,
746 ): KeyPairSyncResult<string, string>;
747 function generateKeyPairSync(
748 type: 'ed25519',
749 options: ED25519KeyPairOptions<'pem', 'der'>,
750 ): KeyPairSyncResult<string, Buffer>;
751 function generateKeyPairSync(
752 type: 'ed25519',
753 options: ED25519KeyPairOptions<'der', 'pem'>,
754 ): KeyPairSyncResult<Buffer, string>;
755 function generateKeyPairSync(
756 type: 'ed25519',
757 options: ED25519KeyPairOptions<'der', 'der'>,
758 ): KeyPairSyncResult<Buffer, Buffer>;
759 function generateKeyPairSync(type: 'ed25519', options?: ED25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
760
761 function generateKeyPairSync(
762 type: 'ed448',
763 options: ED448KeyPairOptions<'pem', 'pem'>,
764 ): KeyPairSyncResult<string, string>;
765 function generateKeyPairSync(
766 type: 'ed448',
767 options: ED448KeyPairOptions<'pem', 'der'>,
768 ): KeyPairSyncResult<string, Buffer>;
769 function generateKeyPairSync(
770 type: 'ed448',
771 options: ED448KeyPairOptions<'der', 'pem'>,
772 ): KeyPairSyncResult<Buffer, string>;
773 function generateKeyPairSync(
774 type: 'ed448',
775 options: ED448KeyPairOptions<'der', 'der'>,
776 ): KeyPairSyncResult<Buffer, Buffer>;
777 function generateKeyPairSync(type: 'ed448', options?: ED448KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
778
779 function generateKeyPairSync(
780 type: 'x25519',
781 options: X25519KeyPairOptions<'pem', 'pem'>,
782 ): KeyPairSyncResult<string, string>;
783 function generateKeyPairSync(
784 type: 'x25519',
785 options: X25519KeyPairOptions<'pem', 'der'>,
786 ): KeyPairSyncResult<string, Buffer>;
787 function generateKeyPairSync(
788 type: 'x25519',
789 options: X25519KeyPairOptions<'der', 'pem'>,
790 ): KeyPairSyncResult<Buffer, string>;
791 function generateKeyPairSync(
792 type: 'x25519',
793 options: X25519KeyPairOptions<'der', 'der'>,
794 ): KeyPairSyncResult<Buffer, Buffer>;
795 function generateKeyPairSync(type: 'x25519', options?: X25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
796
797 function generateKeyPairSync(
798 type: 'x448',
799 options: X448KeyPairOptions<'pem', 'pem'>,
800 ): KeyPairSyncResult<string, string>;
801 function generateKeyPairSync(
802 type: 'x448',
803 options: X448KeyPairOptions<'pem', 'der'>,
804 ): KeyPairSyncResult<string, Buffer>;
805 function generateKeyPairSync(
806 type: 'x448',
807 options: X448KeyPairOptions<'der', 'pem'>,
808 ): KeyPairSyncResult<Buffer, string>;
809 function generateKeyPairSync(
810 type: 'x448',
811 options: X448KeyPairOptions<'der', 'der'>,
812 ): KeyPairSyncResult<Buffer, Buffer>;
813 function generateKeyPairSync(type: 'x448', options?: X448KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
814
815 function generateKeyPair(
816 type: 'rsa',
817 options: RSAKeyPairOptions<'pem', 'pem'>,
818 callback: (err: Error | null, publicKey: string, privateKey: string) => void,
819 ): void;
820 function generateKeyPair(
821 type: 'rsa',
822 options: RSAKeyPairOptions<'pem', 'der'>,
823 callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
824 ): void;
825 function generateKeyPair(
826 type: 'rsa',
827 options: RSAKeyPairOptions<'der', 'pem'>,
828 callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
829 ): void;
830 function generateKeyPair(
831 type: 'rsa',
832 options: RSAKeyPairOptions<'der', 'der'>,
833 callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
834 ): void;
835 function generateKeyPair(
836 type: 'rsa',
837 options: RSAKeyPairKeyObjectOptions,
838 callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
839 ): void;
840
841 function generateKeyPair(
842 type: 'dsa',
843 options: DSAKeyPairOptions<'pem', 'pem'>,
844 callback: (err: Error | null, publicKey: string, privateKey: string) => void,
845 ): void;
846 function generateKeyPair(
847 type: 'dsa',
848 options: DSAKeyPairOptions<'pem', 'der'>,
849 callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
850 ): void;
851 function generateKeyPair(
852 type: 'dsa',
853 options: DSAKeyPairOptions<'der', 'pem'>,
854 callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
855 ): void;
856 function generateKeyPair(
857 type: 'dsa',
858 options: DSAKeyPairOptions<'der', 'der'>,
859 callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
860 ): void;
861 function generateKeyPair(
862 type: 'dsa',
863 options: DSAKeyPairKeyObjectOptions,
864 callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
865 ): void;
866
867 function generateKeyPair(
868 type: 'ec',
869 options: ECKeyPairOptions<'pem', 'pem'>,
870 callback: (err: Error | null, publicKey: string, privateKey: string) => void,
871 ): void;
872 function generateKeyPair(
873 type: 'ec',
874 options: ECKeyPairOptions<'pem', 'der'>,
875 callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
876 ): void;
877 function generateKeyPair(
878 type: 'ec',
879 options: ECKeyPairOptions<'der', 'pem'>,
880 callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
881 ): void;
882 function generateKeyPair(
883 type: 'ec',
884 options: ECKeyPairOptions<'der', 'der'>,
885 callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
886 ): void;
887 function generateKeyPair(
888 type: 'ec',
889 options: ECKeyPairKeyObjectOptions,
890 callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
891 ): void;
892
893 function generateKeyPair(
894 type: 'ed25519',
895 options: ED25519KeyPairOptions<'pem', 'pem'>,
896 callback: (err: Error | null, publicKey: string, privateKey: string) => void,
897 ): void;
898 function generateKeyPair(
899 type: 'ed25519',
900 options: ED25519KeyPairOptions<'pem', 'der'>,
901 callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
902 ): void;
903 function generateKeyPair(
904 type: 'ed25519',
905 options: ED25519KeyPairOptions<'der', 'pem'>,
906 callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
907 ): void;
908 function generateKeyPair(
909 type: 'ed25519',
910 options: ED25519KeyPairOptions<'der', 'der'>,
911 callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
912 ): void;
913 function generateKeyPair(
914 type: 'ed25519',
915 options: ED25519KeyPairKeyObjectOptions | undefined,
916 callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
917 ): void;
918
919 function generateKeyPair(
920 type: 'ed448',
921 options: ED448KeyPairOptions<'pem', 'pem'>,
922 callback: (err: Error | null, publicKey: string, privateKey: string) => void,
923 ): void;
924 function generateKeyPair(
925 type: 'ed448',
926 options: ED448KeyPairOptions<'pem', 'der'>,
927 callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
928 ): void;
929 function generateKeyPair(
930 type: 'ed448',
931 options: ED448KeyPairOptions<'der', 'pem'>,
932 callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
933 ): void;
934 function generateKeyPair(
935 type: 'ed448',
936 options: ED448KeyPairOptions<'der', 'der'>,
937 callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
938 ): void;
939 function generateKeyPair(
940 type: 'ed448',
941 options: ED448KeyPairKeyObjectOptions | undefined,
942 callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
943 ): void;
944
945 function generateKeyPair(
946 type: 'x25519',
947 options: X25519KeyPairOptions<'pem', 'pem'>,
948 callback: (err: Error | null, publicKey: string, privateKey: string) => void,
949 ): void;
950 function generateKeyPair(
951 type: 'x25519',
952 options: X25519KeyPairOptions<'pem', 'der'>,
953 callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
954 ): void;
955 function generateKeyPair(
956 type: 'x25519',
957 options: X25519KeyPairOptions<'der', 'pem'>,
958 callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
959 ): void;
960 function generateKeyPair(
961 type: 'x25519',
962 options: X25519KeyPairOptions<'der', 'der'>,
963 callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
964 ): void;
965 function generateKeyPair(
966 type: 'x25519',
967 options: X25519KeyPairKeyObjectOptions | undefined,
968 callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
969 ): void;
970
971 function generateKeyPair(
972 type: 'x448',
973 options: X448KeyPairOptions<'pem', 'pem'>,
974 callback: (err: Error | null, publicKey: string, privateKey: string) => void,
975 ): void;
976 function generateKeyPair(
977 type: 'x448',
978 options: X448KeyPairOptions<'pem', 'der'>,
979 callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
980 ): void;
981 function generateKeyPair(
982 type: 'x448',
983 options: X448KeyPairOptions<'der', 'pem'>,
984 callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
985 ): void;
986 function generateKeyPair(
987 type: 'x448',
988 options: X448KeyPairOptions<'der', 'der'>,
989 callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
990 ): void;
991 function generateKeyPair(
992 type: 'x448',
993 options: X448KeyPairKeyObjectOptions | undefined,
994 callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
995 ): void;
996
997 namespace generateKeyPair {
998 function __promisify__(
999 type: 'rsa',
1000 options: RSAKeyPairOptions<'pem', 'pem'>,
1001 ): Promise<{ publicKey: string; privateKey: string }>;
1002 function __promisify__(
1003 type: 'rsa',
1004 options: RSAKeyPairOptions<'pem', 'der'>,
1005 ): Promise<{ publicKey: string; privateKey: Buffer }>;
1006 function __promisify__(
1007 type: 'rsa',
1008 options: RSAKeyPairOptions<'der', 'pem'>,
1009 ): Promise<{ publicKey: Buffer; privateKey: string }>;
1010 function __promisify__(
1011 type: 'rsa',
1012 options: RSAKeyPairOptions<'der', 'der'>,
1013 ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
1014 function __promisify__(type: 'rsa', options: RSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1015
1016 function __promisify__(
1017 type: 'dsa',
1018 options: DSAKeyPairOptions<'pem', 'pem'>,
1019 ): Promise<{ publicKey: string; privateKey: string }>;
1020 function __promisify__(
1021 type: 'dsa',
1022 options: DSAKeyPairOptions<'pem', 'der'>,
1023 ): Promise<{ publicKey: string; privateKey: Buffer }>;
1024 function __promisify__(
1025 type: 'dsa',
1026 options: DSAKeyPairOptions<'der', 'pem'>,
1027 ): Promise<{ publicKey: Buffer; privateKey: string }>;
1028 function __promisify__(
1029 type: 'dsa',
1030 options: DSAKeyPairOptions<'der', 'der'>,
1031 ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
1032 function __promisify__(type: 'dsa', options: DSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1033
1034 function __promisify__(
1035 type: 'ec',
1036 options: ECKeyPairOptions<'pem', 'pem'>,
1037 ): Promise<{ publicKey: string; privateKey: string }>;
1038 function __promisify__(
1039 type: 'ec',
1040 options: ECKeyPairOptions<'pem', 'der'>,
1041 ): Promise<{ publicKey: string; privateKey: Buffer }>;
1042 function __promisify__(
1043 type: 'ec',
1044 options: ECKeyPairOptions<'der', 'pem'>,
1045 ): Promise<{ publicKey: Buffer; privateKey: string }>;
1046 function __promisify__(
1047 type: 'ec',
1048 options: ECKeyPairOptions<'der', 'der'>,
1049 ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
1050 function __promisify__(type: 'ec', options: ECKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1051
1052 function __promisify__(
1053 type: 'ed25519',
1054 options: ED25519KeyPairOptions<'pem', 'pem'>,
1055 ): Promise<{ publicKey: string; privateKey: string }>;
1056 function __promisify__(
1057 type: 'ed25519',
1058 options: ED25519KeyPairOptions<'pem', 'der'>,
1059 ): Promise<{ publicKey: string; privateKey: Buffer }>;
1060 function __promisify__(
1061 type: 'ed25519',
1062 options: ED25519KeyPairOptions<'der', 'pem'>,
1063 ): Promise<{ publicKey: Buffer; privateKey: string }>;
1064 function __promisify__(
1065 type: 'ed25519',
1066 options: ED25519KeyPairOptions<'der', 'der'>,
1067 ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
1068 function __promisify__(
1069 type: 'ed25519',
1070 options?: ED25519KeyPairKeyObjectOptions,
1071 ): Promise<KeyPairKeyObjectResult>;
1072
1073 function __promisify__(
1074 type: 'ed448',
1075 options: ED448KeyPairOptions<'pem', 'pem'>,
1076 ): Promise<{ publicKey: string; privateKey: string }>;
1077 function __promisify__(
1078 type: 'ed448',
1079 options: ED448KeyPairOptions<'pem', 'der'>,
1080 ): Promise<{ publicKey: string; privateKey: Buffer }>;
1081 function __promisify__(
1082 type: 'ed448',
1083 options: ED448KeyPairOptions<'der', 'pem'>,
1084 ): Promise<{ publicKey: Buffer; privateKey: string }>;
1085 function __promisify__(
1086 type: 'ed448',
1087 options: ED448KeyPairOptions<'der', 'der'>,
1088 ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
1089 function __promisify__(type: 'ed448', options?: ED448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1090
1091 function __promisify__(
1092 type: 'x25519',
1093 options: X25519KeyPairOptions<'pem', 'pem'>,
1094 ): Promise<{ publicKey: string; privateKey: string }>;
1095 function __promisify__(
1096 type: 'x25519',
1097 options: X25519KeyPairOptions<'pem', 'der'>,
1098 ): Promise<{ publicKey: string; privateKey: Buffer }>;
1099 function __promisify__(
1100 type: 'x25519',
1101 options: X25519KeyPairOptions<'der', 'pem'>,
1102 ): Promise<{ publicKey: Buffer; privateKey: string }>;
1103 function __promisify__(
1104 type: 'x25519',
1105 options: X25519KeyPairOptions<'der', 'der'>,
1106 ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
1107 function __promisify__(
1108 type: 'x25519',
1109 options?: X25519KeyPairKeyObjectOptions,
1110 ): Promise<KeyPairKeyObjectResult>;
1111
1112 function __promisify__(
1113 type: 'x448',
1114 options: X448KeyPairOptions<'pem', 'pem'>,
1115 ): Promise<{ publicKey: string; privateKey: string }>;
1116 function __promisify__(
1117 type: 'x448',
1118 options: X448KeyPairOptions<'pem', 'der'>,
1119 ): Promise<{ publicKey: string; privateKey: Buffer }>;
1120 function __promisify__(
1121 type: 'x448',
1122 options: X448KeyPairOptions<'der', 'pem'>,
1123 ): Promise<{ publicKey: Buffer; privateKey: string }>;
1124 function __promisify__(
1125 type: 'x448',
1126 options: X448KeyPairOptions<'der', 'der'>,
1127 ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
1128 function __promisify__(type: 'x448', options?: X448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
1129 }
1130
1131 /**
1132 * Calculates and returns the signature for `data` using the given private key and
1133 * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
1134 * dependent upon the key type (especially Ed25519 and Ed448).
1135 *
1136 * If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
1137 * passed to [`crypto.createPrivateKey()`][].
1138 */
1139 function sign(
1140 algorithm: string | null | undefined,
1141 data: NodeJS.ArrayBufferView,
1142 key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput,
1143 ): Buffer;
1144
1145 /**
1146 * Calculates and returns the signature for `data` using the given private key and
1147 * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
1148 * dependent upon the key type (especially Ed25519 and Ed448).
1149 *
1150 * If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
1151 * passed to [`crypto.createPublicKey()`][].
1152 */
1153 function verify(
1154 algorithm: string | null | undefined,
1155 data: NodeJS.ArrayBufferView,
1156 key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput,
1157 signature: NodeJS.ArrayBufferView,
1158 ): Buffer;
1159}