Built motion from commit 44377920.|2.6.11
[motion2.git] / legacy-libs / protobufjs / node_modules / @types / node / crypto.d.ts
1 declare 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;
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 | KeyObject, 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         copy(): Hash;
133         update(data: BinaryLike): Hash;
134         update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hash;
135         digest(): Buffer;
136         digest(encoding: HexBase64Latin1Encoding): string;
137     }
138     class Hmac extends stream.Transform {
139         private constructor();
140         update(data: BinaryLike): Hmac;
141         update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hmac;
142         digest(): Buffer;
143         digest(encoding: HexBase64Latin1Encoding): string;
144     }
145
146     type KeyObjectType = 'secret' | 'public' | 'private';
147
148     interface KeyExportOptions<T extends KeyFormat> {
149         type: 'pkcs1' | 'spki' | 'pkcs8' | 'sec1';
150         format: T;
151         cipher?: string;
152         passphrase?: string | Buffer;
153     }
154
155     class KeyObject {
156         private constructor();
157         asymmetricKeyType?: KeyType;
158         /**
159          * For asymmetric keys, this property represents the size of the embedded key in
160          * bytes. This property is `undefined` for symmetric keys.
161          */
162         asymmetricKeySize?: number;
163         export(options: KeyExportOptions<'pem'>): string | Buffer;
164         export(options?: KeyExportOptions<'der'>): Buffer;
165         symmetricKeySize?: number;
166         type: KeyObjectType;
167     }
168
169     type CipherCCMTypes = 'aes-128-ccm' | 'aes-192-ccm' | 'aes-256-ccm' | 'chacha20-poly1305';
170     type CipherGCMTypes = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
171
172     type BinaryLike = string | NodeJS.ArrayBufferView;
173
174     type CipherKey = BinaryLike | KeyObject;
175
176     interface CipherCCMOptions extends stream.TransformOptions {
177         authTagLength: number;
178     }
179     interface CipherGCMOptions extends stream.TransformOptions {
180         authTagLength?: number;
181     }
182     /** @deprecated since v10.0.0 use createCipheriv() */
183     function createCipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): CipherCCM;
184     /** @deprecated since v10.0.0 use createCipheriv() */
185     function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM;
186     /** @deprecated since v10.0.0 use createCipheriv() */
187     function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher;
188
189     function createCipheriv(
190         algorithm: CipherCCMTypes,
191         key: CipherKey,
192         iv: BinaryLike | null,
193         options: CipherCCMOptions,
194     ): CipherCCM;
195     function createCipheriv(
196         algorithm: CipherGCMTypes,
197         key: CipherKey,
198         iv: BinaryLike | null,
199         options?: CipherGCMOptions,
200     ): CipherGCM;
201     function createCipheriv(
202         algorithm: string,
203         key: CipherKey,
204         iv: BinaryLike | null,
205         options?: stream.TransformOptions,
206     ): Cipher;
207
208     class Cipher extends stream.Transform {
209         private constructor();
210         update(data: BinaryLike): Buffer;
211         update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer;
212         update(
213             data: NodeJS.ArrayBufferView,
214             input_encoding: undefined,
215             output_encoding: HexBase64BinaryEncoding,
216         ): string;
217         update(
218             data: string,
219             input_encoding: Utf8AsciiBinaryEncoding | undefined,
220             output_encoding: HexBase64BinaryEncoding,
221         ): string;
222         final(): Buffer;
223         final(output_encoding: string): string;
224         setAutoPadding(auto_padding?: boolean): this;
225         // getAuthTag(): Buffer;
226         // setAAD(buffer: Buffer): this; // docs only say buffer
227     }
228     interface CipherCCM extends Cipher {
229         setAAD(buffer: Buffer, options: { plaintextLength: number }): this;
230         getAuthTag(): Buffer;
231     }
232     interface CipherGCM extends Cipher {
233         setAAD(buffer: Buffer, options?: { plaintextLength: number }): this;
234         getAuthTag(): Buffer;
235     }
236     /** @deprecated since v10.0.0 use createDecipheriv() */
237     function createDecipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): DecipherCCM;
238     /** @deprecated since v10.0.0 use createDecipheriv() */
239     function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM;
240     /** @deprecated since v10.0.0 use createDecipheriv() */
241     function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher;
242
243     function createDecipheriv(
244         algorithm: CipherCCMTypes,
245         key: CipherKey,
246         iv: BinaryLike | null,
247         options: CipherCCMOptions,
248     ): DecipherCCM;
249     function createDecipheriv(
250         algorithm: CipherGCMTypes,
251         key: CipherKey,
252         iv: BinaryLike | null,
253         options?: CipherGCMOptions,
254     ): DecipherGCM;
255     function createDecipheriv(
256         algorithm: string,
257         key: CipherKey,
258         iv: BinaryLike | null,
259         options?: stream.TransformOptions,
260     ): Decipher;
261
262     class Decipher extends stream.Transform {
263         private constructor();
264         update(data: NodeJS.ArrayBufferView): Buffer;
265         update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer;
266         update(
267             data: NodeJS.ArrayBufferView,
268             input_encoding: HexBase64BinaryEncoding | undefined,
269             output_encoding: Utf8AsciiBinaryEncoding,
270         ): string;
271         update(
272             data: string,
273             input_encoding: HexBase64BinaryEncoding | undefined,
274             output_encoding: Utf8AsciiBinaryEncoding,
275         ): string;
276         final(): Buffer;
277         final(output_encoding: string): string;
278         setAutoPadding(auto_padding?: boolean): this;
279         // setAuthTag(tag: NodeJS.ArrayBufferView): this;
280         // setAAD(buffer: NodeJS.ArrayBufferView): this;
281     }
282     interface DecipherCCM extends Decipher {
283         setAuthTag(buffer: NodeJS.ArrayBufferView): this;
284         setAAD(buffer: NodeJS.ArrayBufferView, options: { plaintextLength: number }): this;
285     }
286     interface DecipherGCM extends Decipher {
287         setAuthTag(buffer: NodeJS.ArrayBufferView): this;
288         setAAD(buffer: NodeJS.ArrayBufferView, options?: { plaintextLength: number }): this;
289     }
290
291     interface PrivateKeyInput {
292         key: string | Buffer;
293         format?: KeyFormat;
294         type?: 'pkcs1' | 'pkcs8' | 'sec1';
295         passphrase?: string | Buffer;
296     }
297
298     interface PublicKeyInput {
299         key: string | Buffer;
300         format?: KeyFormat;
301         type?: 'pkcs1' | 'spki';
302     }
303
304     function createPrivateKey(key: PrivateKeyInput | string | Buffer): KeyObject;
305     function createPublicKey(key: PublicKeyInput | string | Buffer | KeyObject): KeyObject;
306     function createSecretKey(key: Buffer): KeyObject;
307
308     function createSign(algorithm: string, options?: stream.WritableOptions): Signer;
309
310     interface SigningOptions {
311         /**
312          * @See crypto.constants.RSA_PKCS1_PADDING
313          */
314         padding?: number;
315         saltLength?: number;
316     }
317
318     interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {}
319
320     type KeyLike = string | Buffer | KeyObject;
321
322     class Signer extends stream.Writable {
323         private constructor();
324
325         update(data: BinaryLike): Signer;
326         update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Signer;
327         sign(private_key: SignPrivateKeyInput | KeyLike): Buffer;
328         sign(private_key: SignPrivateKeyInput | KeyLike, output_format: HexBase64Latin1Encoding): string;
329     }
330
331     function createVerify(algorithm: string, options?: stream.WritableOptions): Verify;
332     class Verify extends stream.Writable {
333         private constructor();
334
335         update(data: BinaryLike): Verify;
336         update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Verify;
337         verify(object: object | KeyLike, signature: NodeJS.ArrayBufferView): boolean;
338         verify(object: object | KeyLike, signature: string, signature_format?: HexBase64Latin1Encoding): boolean;
339         // https://nodejs.org/api/crypto.html#crypto_verifier_verify_object_signature_signature_format
340         // The signature field accepts a TypedArray type, but it is only available starting ES2017
341     }
342     function createDiffieHellman(prime_length: number, generator?: number | NodeJS.ArrayBufferView): DiffieHellman;
343     function createDiffieHellman(prime: NodeJS.ArrayBufferView): DiffieHellman;
344     function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman;
345     function createDiffieHellman(
346         prime: string,
347         prime_encoding: HexBase64Latin1Encoding,
348         generator: number | NodeJS.ArrayBufferView,
349     ): DiffieHellman;
350     function createDiffieHellman(
351         prime: string,
352         prime_encoding: HexBase64Latin1Encoding,
353         generator: string,
354         generator_encoding: HexBase64Latin1Encoding,
355     ): DiffieHellman;
356     class DiffieHellman {
357         private constructor();
358         generateKeys(): Buffer;
359         generateKeys(encoding: HexBase64Latin1Encoding): string;
360         computeSecret(other_public_key: NodeJS.ArrayBufferView): Buffer;
361         computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
362         computeSecret(other_public_key: NodeJS.ArrayBufferView, output_encoding: HexBase64Latin1Encoding): string;
363         computeSecret(
364             other_public_key: string,
365             input_encoding: HexBase64Latin1Encoding,
366             output_encoding: HexBase64Latin1Encoding,
367         ): string;
368         getPrime(): Buffer;
369         getPrime(encoding: HexBase64Latin1Encoding): string;
370         getGenerator(): Buffer;
371         getGenerator(encoding: HexBase64Latin1Encoding): string;
372         getPublicKey(): Buffer;
373         getPublicKey(encoding: HexBase64Latin1Encoding): string;
374         getPrivateKey(): Buffer;
375         getPrivateKey(encoding: HexBase64Latin1Encoding): string;
376         setPublicKey(public_key: NodeJS.ArrayBufferView): void;
377         setPublicKey(public_key: string, encoding: string): void;
378         setPrivateKey(private_key: NodeJS.ArrayBufferView): void;
379         setPrivateKey(private_key: string, encoding: string): void;
380         verifyError: number;
381     }
382     function getDiffieHellman(group_name: string): DiffieHellman;
383     function pbkdf2(
384         password: BinaryLike,
385         salt: BinaryLike,
386         iterations: number,
387         keylen: number,
388         digest: string,
389         callback: (err: Error | null, derivedKey: Buffer) => any,
390     ): void;
391     function pbkdf2Sync(
392         password: BinaryLike,
393         salt: BinaryLike,
394         iterations: number,
395         keylen: number,
396         digest: string,
397     ): Buffer;
398
399     function randomBytes(size: number): Buffer;
400     function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
401     function pseudoRandomBytes(size: number): Buffer;
402     function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
403
404     function randomFillSync<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number, size?: number): T;
405     function randomFill<T extends NodeJS.ArrayBufferView>(
406         buffer: T,
407         callback: (err: Error | null, buf: T) => void,
408     ): void;
409     function randomFill<T extends NodeJS.ArrayBufferView>(
410         buffer: T,
411         offset: number,
412         callback: (err: Error | null, buf: T) => void,
413     ): void;
414     function randomFill<T extends NodeJS.ArrayBufferView>(
415         buffer: T,
416         offset: number,
417         size: number,
418         callback: (err: Error | null, buf: T) => void,
419     ): void;
420
421     interface ScryptOptions {
422         cost?: number;
423         blockSize?: number;
424         parallelization?: number;
425         N?: number;
426         r?: number;
427         p?: number;
428         maxmem?: number;
429     }
430     function scrypt(
431         password: BinaryLike,
432         salt: BinaryLike,
433         keylen: number,
434         callback: (err: Error | null, derivedKey: Buffer) => void,
435     ): void;
436     function scrypt(
437         password: BinaryLike,
438         salt: BinaryLike,
439         keylen: number,
440         options: ScryptOptions,
441         callback: (err: Error | null, derivedKey: Buffer) => void,
442     ): void;
443     function scryptSync(password: BinaryLike, salt: BinaryLike, keylen: number, options?: ScryptOptions): Buffer;
444
445     interface RsaPublicKey {
446         key: KeyLike;
447         padding?: number;
448     }
449     interface RsaPrivateKey {
450         key: KeyLike;
451         passphrase?: string;
452         /**
453          * @default 'sha1'
454          */
455         oaepHash?: string;
456         oaepLabel?: NodeJS.TypedArray;
457         padding?: number;
458     }
459     function publicEncrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
460     function publicDecrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
461     function privateDecrypt(private_key: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
462     function privateEncrypt(private_key: RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
463     function getCiphers(): string[];
464     function getCurves(): string[];
465     function getFips(): 1 | 0;
466     function getHashes(): string[];
467     class ECDH {
468         private constructor();
469         static convertKey(
470             key: BinaryLike,
471             curve: string,
472             inputEncoding?: HexBase64Latin1Encoding,
473             outputEncoding?: 'latin1' | 'hex' | 'base64',
474             format?: 'uncompressed' | 'compressed' | 'hybrid',
475         ): Buffer | string;
476         generateKeys(): Buffer;
477         generateKeys(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
478         computeSecret(other_public_key: NodeJS.ArrayBufferView): Buffer;
479         computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
480         computeSecret(other_public_key: NodeJS.ArrayBufferView, output_encoding: HexBase64Latin1Encoding): string;
481         computeSecret(
482             other_public_key: string,
483             input_encoding: HexBase64Latin1Encoding,
484             output_encoding: HexBase64Latin1Encoding,
485         ): string;
486         getPrivateKey(): Buffer;
487         getPrivateKey(encoding: HexBase64Latin1Encoding): string;
488         getPublicKey(): Buffer;
489         getPublicKey(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
490         setPrivateKey(private_key: NodeJS.ArrayBufferView): void;
491         setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void;
492     }
493     function createECDH(curve_name: string): ECDH;
494     function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
495     /** @deprecated since v10.0.0 */
496     const DEFAULT_ENCODING: string;
497
498     type KeyType = 'rsa' | 'dsa' | 'ec';
499     type KeyFormat = 'pem' | 'der';
500
501     interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
502         format: T;
503         cipher?: string;
504         passphrase?: string;
505     }
506
507     interface KeyPairKeyObjectResult {
508         publicKey: KeyObject;
509         privateKey: KeyObject;
510     }
511
512     interface ECKeyPairKeyObjectOptions {
513         /**
514          * Name of the curve to use.
515          */
516         namedCurve: string;
517     }
518
519     interface RSAKeyPairKeyObjectOptions {
520         /**
521          * Key size in bits
522          */
523         modulusLength: number;
524
525         /**
526          * @default 0x10001
527          */
528         publicExponent?: number;
529     }
530
531     interface DSAKeyPairKeyObjectOptions {
532         /**
533          * Key size in bits
534          */
535         modulusLength: number;
536
537         /**
538          * Size of q in bits
539          */
540         divisorLength: number;
541     }
542
543     interface RSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
544         /**
545          * Key size in bits
546          */
547         modulusLength: number;
548         /**
549          * @default 0x10001
550          */
551         publicExponent?: number;
552
553         publicKeyEncoding: {
554             type: 'pkcs1' | 'spki';
555             format: PubF;
556         };
557         privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
558             type: 'pkcs1' | 'pkcs8';
559         };
560     }
561
562     interface DSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
563         /**
564          * Key size in bits
565          */
566         modulusLength: number;
567         /**
568          * Size of q in bits
569          */
570         divisorLength: number;
571
572         publicKeyEncoding: {
573             type: 'spki';
574             format: PubF;
575         };
576         privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
577             type: 'pkcs8';
578         };
579     }
580
581     interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
582         /**
583          * Name of the curve to use.
584          */
585         namedCurve: string;
586
587         publicKeyEncoding: {
588             type: 'pkcs1' | 'spki';
589             format: PubF;
590         };
591         privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
592             type: 'sec1' | 'pkcs8';
593         };
594     }
595
596     interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
597         publicKey: T1;
598         privateKey: T2;
599     }
600
601     function generateKeyPairSync(
602         type: 'rsa',
603         options: RSAKeyPairOptions<'pem', 'pem'>,
604     ): KeyPairSyncResult<string, string>;
605     function generateKeyPairSync(
606         type: 'rsa',
607         options: RSAKeyPairOptions<'pem', 'der'>,
608     ): KeyPairSyncResult<string, Buffer>;
609     function generateKeyPairSync(
610         type: 'rsa',
611         options: RSAKeyPairOptions<'der', 'pem'>,
612     ): KeyPairSyncResult<Buffer, string>;
613     function generateKeyPairSync(
614         type: 'rsa',
615         options: RSAKeyPairOptions<'der', 'der'>,
616     ): KeyPairSyncResult<Buffer, Buffer>;
617     function generateKeyPairSync(type: 'rsa', options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
618
619     function generateKeyPairSync(
620         type: 'dsa',
621         options: DSAKeyPairOptions<'pem', 'pem'>,
622     ): KeyPairSyncResult<string, string>;
623     function generateKeyPairSync(
624         type: 'dsa',
625         options: DSAKeyPairOptions<'pem', 'der'>,
626     ): KeyPairSyncResult<string, Buffer>;
627     function generateKeyPairSync(
628         type: 'dsa',
629         options: DSAKeyPairOptions<'der', 'pem'>,
630     ): KeyPairSyncResult<Buffer, string>;
631     function generateKeyPairSync(
632         type: 'dsa',
633         options: DSAKeyPairOptions<'der', 'der'>,
634     ): KeyPairSyncResult<Buffer, Buffer>;
635     function generateKeyPairSync(type: 'dsa', options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
636
637     function generateKeyPairSync(
638         type: 'ec',
639         options: ECKeyPairOptions<'pem', 'pem'>,
640     ): KeyPairSyncResult<string, string>;
641     function generateKeyPairSync(
642         type: 'ec',
643         options: ECKeyPairOptions<'pem', 'der'>,
644     ): KeyPairSyncResult<string, Buffer>;
645     function generateKeyPairSync(
646         type: 'ec',
647         options: ECKeyPairOptions<'der', 'pem'>,
648     ): KeyPairSyncResult<Buffer, string>;
649     function generateKeyPairSync(
650         type: 'ec',
651         options: ECKeyPairOptions<'der', 'der'>,
652     ): KeyPairSyncResult<Buffer, Buffer>;
653     function generateKeyPairSync(type: 'ec', options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
654
655     function generateKeyPair(
656         type: 'rsa',
657         options: RSAKeyPairOptions<'pem', 'pem'>,
658         callback: (err: Error | null, publicKey: string, privateKey: string) => void,
659     ): void;
660     function generateKeyPair(
661         type: 'rsa',
662         options: RSAKeyPairOptions<'pem', 'der'>,
663         callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
664     ): void;
665     function generateKeyPair(
666         type: 'rsa',
667         options: RSAKeyPairOptions<'der', 'pem'>,
668         callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
669     ): void;
670     function generateKeyPair(
671         type: 'rsa',
672         options: RSAKeyPairOptions<'der', 'der'>,
673         callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
674     ): void;
675     function generateKeyPair(
676         type: 'rsa',
677         options: RSAKeyPairKeyObjectOptions,
678         callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
679     ): void;
680
681     function generateKeyPair(
682         type: 'dsa',
683         options: DSAKeyPairOptions<'pem', 'pem'>,
684         callback: (err: Error | null, publicKey: string, privateKey: string) => void,
685     ): void;
686     function generateKeyPair(
687         type: 'dsa',
688         options: DSAKeyPairOptions<'pem', 'der'>,
689         callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
690     ): void;
691     function generateKeyPair(
692         type: 'dsa',
693         options: DSAKeyPairOptions<'der', 'pem'>,
694         callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
695     ): void;
696     function generateKeyPair(
697         type: 'dsa',
698         options: DSAKeyPairOptions<'der', 'der'>,
699         callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
700     ): void;
701     function generateKeyPair(
702         type: 'dsa',
703         options: DSAKeyPairKeyObjectOptions,
704         callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
705     ): void;
706
707     function generateKeyPair(
708         type: 'ec',
709         options: ECKeyPairOptions<'pem', 'pem'>,
710         callback: (err: Error | null, publicKey: string, privateKey: string) => void,
711     ): void;
712     function generateKeyPair(
713         type: 'ec',
714         options: ECKeyPairOptions<'pem', 'der'>,
715         callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
716     ): void;
717     function generateKeyPair(
718         type: 'ec',
719         options: ECKeyPairOptions<'der', 'pem'>,
720         callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
721     ): void;
722     function generateKeyPair(
723         type: 'ec',
724         options: ECKeyPairOptions<'der', 'der'>,
725         callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
726     ): void;
727     function generateKeyPair(
728         type: 'ec',
729         options: ECKeyPairKeyObjectOptions,
730         callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
731     ): void;
732
733     namespace generateKeyPair {
734         function __promisify__(
735             type: 'rsa',
736             options: RSAKeyPairOptions<'pem', 'pem'>,
737         ): Promise<{ publicKey: string; privateKey: string }>;
738         function __promisify__(
739             type: 'rsa',
740             options: RSAKeyPairOptions<'pem', 'der'>,
741         ): Promise<{ publicKey: string; privateKey: Buffer }>;
742         function __promisify__(
743             type: 'rsa',
744             options: RSAKeyPairOptions<'der', 'pem'>,
745         ): Promise<{ publicKey: Buffer; privateKey: string }>;
746         function __promisify__(
747             type: 'rsa',
748             options: RSAKeyPairOptions<'der', 'der'>,
749         ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
750         function __promisify__(type: 'rsa', options: RSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
751
752         function __promisify__(
753             type: 'dsa',
754             options: DSAKeyPairOptions<'pem', 'pem'>,
755         ): Promise<{ publicKey: string; privateKey: string }>;
756         function __promisify__(
757             type: 'dsa',
758             options: DSAKeyPairOptions<'pem', 'der'>,
759         ): Promise<{ publicKey: string; privateKey: Buffer }>;
760         function __promisify__(
761             type: 'dsa',
762             options: DSAKeyPairOptions<'der', 'pem'>,
763         ): Promise<{ publicKey: Buffer; privateKey: string }>;
764         function __promisify__(
765             type: 'dsa',
766             options: DSAKeyPairOptions<'der', 'der'>,
767         ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
768         function __promisify__(type: 'dsa', options: DSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
769
770         function __promisify__(
771             type: 'ec',
772             options: ECKeyPairOptions<'pem', 'pem'>,
773         ): Promise<{ publicKey: string; privateKey: string }>;
774         function __promisify__(
775             type: 'ec',
776             options: ECKeyPairOptions<'pem', 'der'>,
777         ): Promise<{ publicKey: string; privateKey: Buffer }>;
778         function __promisify__(
779             type: 'ec',
780             options: ECKeyPairOptions<'der', 'pem'>,
781         ): Promise<{ publicKey: Buffer; privateKey: string }>;
782         function __promisify__(
783             type: 'ec',
784             options: ECKeyPairOptions<'der', 'der'>,
785         ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
786         function __promisify__(type: 'ec', options: ECKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
787     }
788
789     /**
790      * Calculates and returns the signature for `data` using the given private key and
791      * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
792      * dependent upon the key type (especially Ed25519 and Ed448).
793      *
794      * If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
795      * passed to [`crypto.createPrivateKey()`][].
796      */
797     function sign(
798         algorithm: string | null | undefined,
799         data: NodeJS.ArrayBufferView,
800         key: KeyLike | SignPrivateKeyInput,
801     ): Buffer;
802
803     interface VerifyKeyWithOptions extends KeyObject, SigningOptions {}
804
805     /**
806      * Calculates and returns the signature for `data` using the given private key and
807      * algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
808      * dependent upon the key type (especially Ed25519 and Ed448).
809      *
810      * If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
811      * passed to [`crypto.createPublicKey()`][].
812      */
813     function verify(
814         algorithm: string | null | undefined,
815         data: NodeJS.ArrayBufferView,
816         key: KeyLike | VerifyKeyWithOptions,
817         signature: NodeJS.ArrayBufferView,
818     ): boolean;
819 }