UNPKG

28.1 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: Binary): boolean;
8 }
9 const Certificate: {
10 new(): Certificate;
11 (): Certificate;
12 };
13
14 namespace constants { // https://nodejs.org/dist/latest-v10.x/docs/api/crypto.html#crypto_crypto_constants
15 const OPENSSL_VERSION_NUMBER: number;
16
17 /** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */
18 const SSL_OP_ALL: number;
19 /** 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. */
20 const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
21 /** 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. */
22 const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
23 /** Instructs OpenSSL to use Cisco's "speshul" version of DTLS_BAD_VER. */
24 const SSL_OP_CISCO_ANYCONNECT: number;
25 /** Instructs OpenSSL to turn on cookie exchange. */
26 const SSL_OP_COOKIE_EXCHANGE: number;
27 /** Instructs OpenSSL to add server-hello extension from an early version of the cryptopro draft. */
28 const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
29 /** Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround added in OpenSSL 0.9.6d. */
30 const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
31 /** Instructs OpenSSL to always use the tmp_rsa key when performing RSA operations. */
32 const SSL_OP_EPHEMERAL_RSA: number;
33 /** Allows initial connection to servers that do not support RI. */
34 const SSL_OP_LEGACY_SERVER_CONNECT: number;
35 const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
36 const SSL_OP_MICROSOFT_SESS_ID_BUG: number;
37 /** Instructs OpenSSL to disable the workaround for a man-in-the-middle protocol-version vulnerability in the SSL 2.0 server implementation. */
38 const SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
39 const SSL_OP_NETSCAPE_CA_DN_BUG: number;
40 const SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
41 const SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
42 const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
43 /** Instructs OpenSSL to disable support for SSL/TLS compression. */
44 const SSL_OP_NO_COMPRESSION: number;
45 const SSL_OP_NO_QUERY_MTU: number;
46 /** Instructs OpenSSL to always start a new session when performing renegotiation. */
47 const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
48 const SSL_OP_NO_SSLv2: number;
49 const SSL_OP_NO_SSLv3: number;
50 const SSL_OP_NO_TICKET: number;
51 const SSL_OP_NO_TLSv1: number;
52 const SSL_OP_NO_TLSv1_1: number;
53 const SSL_OP_NO_TLSv1_2: number;
54 const SSL_OP_PKCS1_CHECK_1: number;
55 const SSL_OP_PKCS1_CHECK_2: number;
56 /** Instructs OpenSSL to always create a new key when using temporary/ephemeral DH parameters. */
57 const SSL_OP_SINGLE_DH_USE: number;
58 /** Instructs OpenSSL to always create a new key when using temporary/ephemeral ECDH parameters. */
59 const SSL_OP_SINGLE_ECDH_USE: number;
60 const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
61 const SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
62 const SSL_OP_TLS_BLOCK_PADDING_BUG: number;
63 const SSL_OP_TLS_D5_BUG: number;
64 /** Instructs OpenSSL to disable version rollback attack detection. */
65 const SSL_OP_TLS_ROLLBACK_BUG: number;
66
67 const ENGINE_METHOD_RSA: number;
68 const ENGINE_METHOD_DSA: number;
69 const ENGINE_METHOD_DH: number;
70 const ENGINE_METHOD_RAND: number;
71 const ENGINE_METHOD_EC: number;
72 const ENGINE_METHOD_CIPHERS: number;
73 const ENGINE_METHOD_DIGESTS: number;
74 const ENGINE_METHOD_PKEY_METHS: number;
75 const ENGINE_METHOD_PKEY_ASN1_METHS: number;
76 const ENGINE_METHOD_ALL: number;
77 const ENGINE_METHOD_NONE: number;
78
79 const DH_CHECK_P_NOT_SAFE_PRIME: number;
80 const DH_CHECK_P_NOT_PRIME: number;
81 const DH_UNABLE_TO_CHECK_GENERATOR: number;
82 const DH_NOT_SUITABLE_GENERATOR: number;
83
84 const ALPN_ENABLED: number;
85
86 const RSA_PKCS1_PADDING: number;
87 const RSA_SSLV23_PADDING: number;
88 const RSA_NO_PADDING: number;
89 const RSA_PKCS1_OAEP_PADDING: number;
90 const RSA_X931_PADDING: number;
91 const RSA_PKCS1_PSS_PADDING: number;
92 /** Sets the salt length for RSA_PKCS1_PSS_PADDING to the digest size when signing or verifying. */
93 const RSA_PSS_SALTLEN_DIGEST: number;
94 /** Sets the salt length for RSA_PKCS1_PSS_PADDING to the maximum permissible value when signing data. */
95 const RSA_PSS_SALTLEN_MAX_SIGN: number;
96 /** Causes the salt length for RSA_PKCS1_PSS_PADDING to be determined automatically when verifying a signature. */
97 const RSA_PSS_SALTLEN_AUTO: number;
98
99 const POINT_CONVERSION_COMPRESSED: number;
100 const POINT_CONVERSION_UNCOMPRESSED: number;
101 const POINT_CONVERSION_HYBRID: number;
102
103 /** Specifies the built-in default cipher list used by Node.js (colon-separated values). */
104 const defaultCoreCipherList: string;
105 /** Specifies the active default cipher list used by the current Node.js process (colon-separated values). */
106 const defaultCipherList: string;
107 }
108
109 /** @deprecated since v10.0.0 */
110 const fips: boolean;
111
112 function createHash(algorithm: string, options?: stream.TransformOptions): Hash;
113 function createHmac(algorithm: string, key: BinaryLike, options?: stream.TransformOptions): Hmac;
114
115 type Utf8AsciiLatin1Encoding = "utf8" | "ascii" | "latin1";
116 type HexBase64Latin1Encoding = "latin1" | "hex" | "base64";
117 type Utf8AsciiBinaryEncoding = "utf8" | "ascii" | "binary";
118 type HexBase64BinaryEncoding = "binary" | "base64" | "hex";
119 type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
120
121 class Hash extends stream.Duplex {
122 private constructor();
123 update(data: BinaryLike): Hash;
124 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hash;
125 digest(): Buffer;
126 digest(encoding: HexBase64Latin1Encoding): string;
127 }
128 class Hmac extends stream.Duplex {
129 private constructor();
130 update(data: BinaryLike): Hmac;
131 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hmac;
132 digest(): Buffer;
133 digest(encoding: HexBase64Latin1Encoding): string;
134 }
135
136 export type KeyObjectType = 'secret' | 'public' | 'private';
137
138 interface KeyExportOptions<T extends KeyFormat> {
139 type: 'pkcs1' | 'spki' | 'pkcs8' | 'sec1';
140 format: T;
141 cipher?: string;
142 passphrase?: string | Buffer;
143 }
144
145 class KeyObject {
146 private constructor();
147 asymmetricKeyType?: KeyType;
148 export(options: KeyExportOptions<'pem'>): string | Buffer;
149 export(options?: KeyExportOptions<'der'>): Buffer;
150 symmetricSize?: number;
151 type: KeyObjectType;
152 }
153
154 type CipherCCMTypes = 'aes-128-ccm' | 'aes-192-ccm' | 'aes-256-ccm';
155 type CipherGCMTypes = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
156
157 type Binary = Buffer | NodeJS.TypedArray | DataView;
158 type BinaryLike = string | Binary;
159
160 type CipherKey = BinaryLike | KeyObject;
161
162 interface CipherCCMOptions extends stream.TransformOptions {
163 authTagLength: number;
164 }
165 interface CipherGCMOptions extends stream.TransformOptions {
166 authTagLength?: number;
167 }
168 /** @deprecated since v10.0.0 use createCipheriv() */
169 function createCipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): CipherCCM;
170 /** @deprecated since v10.0.0 use createCipheriv() */
171 function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM;
172 /** @deprecated since v10.0.0 use createCipheriv() */
173 function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher;
174
175 function createCipheriv(
176 algorithm: CipherCCMTypes,
177 key: CipherKey,
178 iv: BinaryLike | null,
179 options: CipherCCMOptions
180 ): CipherCCM;
181 function createCipheriv(
182 algorithm: CipherGCMTypes,
183 key: CipherKey,
184 iv: BinaryLike | null,
185 options?: CipherGCMOptions
186 ): CipherGCM;
187 function createCipheriv(
188 algorithm: string, key: CipherKey, iv: BinaryLike | null, options?: stream.TransformOptions
189 ): Cipher;
190
191 class Cipher extends stream.Duplex {
192 private constructor();
193 update(data: BinaryLike): Buffer;
194 update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer;
195 update(data: Binary, input_encoding: undefined, output_encoding: HexBase64BinaryEncoding): string;
196 update(data: string, input_encoding: Utf8AsciiBinaryEncoding | undefined, output_encoding: HexBase64BinaryEncoding): string;
197 final(): Buffer;
198 final(output_encoding: string): string;
199 setAutoPadding(auto_padding?: boolean): this;
200 // getAuthTag(): Buffer;
201 // setAAD(buffer: Buffer): this; // docs only say buffer
202 }
203 interface CipherCCM extends Cipher {
204 setAAD(buffer: Buffer, options: { plaintextLength: number }): this;
205 getAuthTag(): Buffer;
206 }
207 interface CipherGCM extends Cipher {
208 setAAD(buffer: Buffer, options?: { plaintextLength: number }): this;
209 getAuthTag(): Buffer;
210 }
211 /** @deprecated since v10.0.0 use createCipheriv() */
212 function createDecipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): DecipherCCM;
213 /** @deprecated since v10.0.0 use createCipheriv() */
214 function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM;
215 /** @deprecated since v10.0.0 use createCipheriv() */
216 function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher;
217
218 function createDecipheriv(
219 algorithm: CipherCCMTypes,
220 key: BinaryLike,
221 iv: BinaryLike | null,
222 options: CipherCCMOptions,
223 ): DecipherCCM;
224 function createDecipheriv(
225 algorithm: CipherGCMTypes,
226 key: BinaryLike,
227 iv: BinaryLike | null,
228 options?: CipherGCMOptions,
229 ): DecipherGCM;
230 function createDecipheriv(algorithm: string, key: BinaryLike, iv: BinaryLike | null, options?: stream.TransformOptions): Decipher;
231
232 class Decipher extends stream.Duplex {
233 private constructor();
234 update(data: Binary): Buffer;
235 update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer;
236 update(data: Binary, input_encoding: undefined, output_encoding: Utf8AsciiBinaryEncoding): string;
237 update(data: string, input_encoding: HexBase64BinaryEncoding | undefined, output_encoding: Utf8AsciiBinaryEncoding): string;
238 final(): Buffer;
239 final(output_encoding: string): string;
240 setAutoPadding(auto_padding?: boolean): this;
241 // setAuthTag(tag: Binary): this;
242 // setAAD(buffer: Binary): this;
243 }
244 interface DecipherCCM extends Decipher {
245 setAuthTag(buffer: Binary): this;
246 setAAD(buffer: Binary, options: { plaintextLength: number }): this;
247 }
248 interface DecipherGCM extends Decipher {
249 setAuthTag(buffer: Binary): this;
250 setAAD(buffer: Binary, options?: { plaintextLength: number }): this;
251 }
252
253 interface PrivateKeyInput {
254 key: string | Buffer;
255 format?: KeyFormat;
256 type?: 'pkcs1' | 'pkcs8' | 'sec1';
257 passphrase?: string | Buffer;
258 }
259
260 interface PublicKeyInput {
261 key: string | Buffer;
262 format?: KeyFormat;
263 type?: 'pkcs1' | 'spki';
264 }
265
266 function createPrivateKey(key: PrivateKeyInput | string | Buffer): KeyObject;
267 function createPublicKey(key: PublicKeyInput | string | Buffer | KeyObject): KeyObject;
268 function createSecretKey(key: Buffer): KeyObject;
269
270 function createSign(algorithm: string, options?: stream.WritableOptions): Signer;
271
272 interface SignPrivateKeyInput extends PrivateKeyInput {
273 padding?: number;
274 saltLength?: number;
275 }
276
277 type KeyLike = string | Buffer | KeyObject;
278
279 class Signer extends stream.Writable {
280 private constructor();
281
282 update(data: BinaryLike): Signer;
283 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Signer;
284 sign(private_key: SignPrivateKeyInput | KeyLike): Buffer;
285 sign(private_key: SignPrivateKeyInput | KeyLike, output_format: HexBase64Latin1Encoding): string;
286 }
287
288 function createVerify(algorith: string, options?: stream.WritableOptions): Verify;
289 class Verify extends stream.Writable {
290 private constructor();
291
292 update(data: BinaryLike): Verify;
293 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Verify;
294 verify(object: Object | KeyLike, signature: Binary): boolean;
295 verify(object: Object | KeyLike, signature: string, signature_format?: HexBase64Latin1Encoding): boolean;
296 // https://nodejs.org/api/crypto.html#crypto_verifier_verify_object_signature_signature_format
297 // The signature field accepts a TypedArray type, but it is only available starting ES2017
298 }
299 function createDiffieHellman(prime_length: number, generator?: number | Binary): DiffieHellman;
300 function createDiffieHellman(prime: Binary): DiffieHellman;
301 function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman;
302 function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | Binary): DiffieHellman;
303 function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman;
304 class DiffieHellman {
305 private constructor();
306 generateKeys(): Buffer;
307 generateKeys(encoding: HexBase64Latin1Encoding): string;
308 computeSecret(other_public_key: Binary): Buffer;
309 computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
310 computeSecret(other_public_key: Binary, output_encoding: HexBase64Latin1Encoding): string;
311 computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
312 getPrime(): Buffer;
313 getPrime(encoding: HexBase64Latin1Encoding): string;
314 getGenerator(): Buffer;
315 getGenerator(encoding: HexBase64Latin1Encoding): string;
316 getPublicKey(): Buffer;
317 getPublicKey(encoding: HexBase64Latin1Encoding): string;
318 getPrivateKey(): Buffer;
319 getPrivateKey(encoding: HexBase64Latin1Encoding): string;
320 setPublicKey(public_key: Binary): void;
321 setPublicKey(public_key: string, encoding: string): void;
322 setPrivateKey(private_key: Binary): void;
323 setPrivateKey(private_key: string, encoding: string): void;
324 verifyError: number;
325 }
326 function getDiffieHellman(group_name: string): DiffieHellman;
327 function pbkdf2(
328 password: BinaryLike,
329 salt: BinaryLike,
330 iterations: number,
331 keylen: number,
332 digest: string,
333 callback: (err: Error | null, derivedKey: Buffer) => any,
334 ): void;
335 function pbkdf2Sync(password: BinaryLike, salt: BinaryLike, iterations: number, keylen: number, digest: string): Buffer;
336
337 function randomBytes(size: number): Buffer;
338 function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
339 function pseudoRandomBytes(size: number): Buffer;
340 function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
341
342 function randomFillSync<T extends Binary>(buffer: T, offset?: number, size?: number): T;
343 function randomFill<T extends Binary>(buffer: T, callback: (err: Error | null, buf: T) => void): void;
344 function randomFill<T extends Binary>(buffer: T, offset: number, callback: (err: Error | null, buf: T) => void): void;
345 function randomFill<T extends Binary>(buffer: T, offset: number, size: number, callback: (err: Error | null, buf: T) => void): void;
346
347 interface ScryptOptions {
348 N?: number;
349 r?: number;
350 p?: number;
351 maxmem?: number;
352 }
353 function scrypt(
354 password: BinaryLike,
355 salt: BinaryLike,
356 keylen: number, callback: (err: Error | null, derivedKey: Buffer) => void,
357 ): void;
358 function scrypt(
359 password: BinaryLike,
360 salt: BinaryLike,
361 keylen: number,
362 options: ScryptOptions,
363 callback: (err: Error | null, derivedKey: Buffer) => void,
364 ): void;
365 function scryptSync(password: BinaryLike, salt: BinaryLike, keylen: number, options?: ScryptOptions): Buffer;
366
367 interface RsaPublicKey {
368 key: KeyLike;
369 padding?: number;
370 }
371 interface RsaPrivateKey {
372 key: KeyLike;
373 passphrase?: string;
374 padding?: number;
375 }
376 function publicEncrypt(public_key: RsaPublicKey | KeyLike, buffer: Binary): Buffer;
377 function privateDecrypt(private_key: RsaPrivateKey | KeyLike, buffer: Binary): Buffer;
378 function privateEncrypt(private_key: RsaPrivateKey | KeyLike, buffer: Binary): Buffer;
379 function publicDecrypt(public_key: RsaPublicKey | KeyLike, buffer: Binary): Buffer;
380 function getCiphers(): string[];
381 function getCurves(): string[];
382 function getHashes(): string[];
383 class ECDH {
384 private constructor();
385 static convertKey(
386 key: BinaryLike,
387 curve: string,
388 inputEncoding?: HexBase64Latin1Encoding,
389 outputEncoding?: "latin1" | "hex" | "base64",
390 format?: "uncompressed" | "compressed" | "hybrid",
391 ): Buffer | string;
392 generateKeys(): Buffer;
393 generateKeys(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
394 computeSecret(other_public_key: Binary): Buffer;
395 computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
396 computeSecret(other_public_key: Binary, output_encoding: HexBase64Latin1Encoding): string;
397 computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
398 getPrivateKey(): Buffer;
399 getPrivateKey(encoding: HexBase64Latin1Encoding): string;
400 getPublicKey(): Buffer;
401 getPublicKey(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
402 setPrivateKey(private_key: Binary): void;
403 setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void;
404 }
405 function createECDH(curve_name: string): ECDH;
406 function timingSafeEqual(a: Binary, b: Binary): boolean;
407 /** @deprecated since v10.0.0 */
408 const DEFAULT_ENCODING: string;
409
410 export type KeyType = 'rsa' | 'dsa' | 'ec';
411 export type KeyFormat = 'pem' | 'der';
412
413 interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
414 format: T;
415 cipher: string;
416 passphrase: string;
417 }
418
419 interface KeyPairKeyObjectResult {
420 publicKey: KeyObject;
421 privateKey: KeyObject;
422 }
423
424 interface ECKeyPairKeyObjectOptions {
425 /**
426 * Name of the curve to use.
427 */
428 namedCurve: string;
429 }
430
431 interface RSAKeyPairKeyObjectOptions {
432 /**
433 * Key size in bits
434 */
435 modulusLength: number;
436
437 /**
438 * @default 0x10001
439 */
440 publicExponent?: number;
441 }
442
443 interface DSAKeyPairKeyObjectOptions {
444 /**
445 * Key size in bits
446 */
447 modulusLength: number;
448
449 /**
450 * Size of q in bits
451 */
452 divisorLength: number;
453 }
454
455 interface RSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
456 /**
457 * Key size in bits
458 */
459 modulusLength: number;
460 /**
461 * @default 0x10001
462 */
463 publicExponent?: number;
464
465 publicKeyEncoding: {
466 type: 'pkcs1' | 'spki';
467 format: PubF;
468 };
469 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
470 type: 'pkcs1' | 'pkcs8';
471 };
472 }
473
474 interface DSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
475 /**
476 * Key size in bits
477 */
478 modulusLength: number;
479 /**
480 * Size of q in bits
481 */
482 divisorLength: number;
483
484 publicKeyEncoding: {
485 type: 'spki';
486 format: PubF;
487 };
488 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
489 type: 'pkcs8';
490 };
491 }
492
493 interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
494 /**
495 * Name of the curve to use.
496 */
497 namedCurve: string;
498
499 publicKeyEncoding: {
500 type: 'pkcs1' | 'spki';
501 format: PubF;
502 };
503 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
504 type: 'sec1' | 'pkcs8';
505 };
506 }
507
508 interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
509 publicKey: T1;
510 privateKey: T2;
511 }
512
513 function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
514 function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
515 function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
516 function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
517 function generateKeyPairSync(type: 'rsa', options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
518
519 function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
520 function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
521 function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
522 function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
523 function generateKeyPairSync(type: 'dsa', options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
524
525 function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
526 function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
527 function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
528 function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
529 function generateKeyPairSync(type: 'ec', options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
530
531 function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
532 function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
533 function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
534 function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
535 function generateKeyPair(type: 'rsa', options: RSAKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
536
537 function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
538 function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
539 function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
540 function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
541 function generateKeyPair(type: 'dsa', options: DSAKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
542
543 function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
544 function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
545 function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
546 function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
547 function generateKeyPair(type: 'ec', options: ECKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
548
549 namespace generateKeyPair {
550 function __promisify__(type: "rsa", options: RSAKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
551 function __promisify__(type: "rsa", options: RSAKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
552 function __promisify__(type: "rsa", options: RSAKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
553 function __promisify__(type: "rsa", options: RSAKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
554 function __promisify__(type: "rsa", options: RSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
555
556 function __promisify__(type: "dsa", options: DSAKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
557 function __promisify__(type: "dsa", options: DSAKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
558 function __promisify__(type: "dsa", options: DSAKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
559 function __promisify__(type: "dsa", options: DSAKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
560 function __promisify__(type: "dsa", options: DSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
561
562 function __promisify__(type: "ec", options: ECKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
563 function __promisify__(type: "ec", options: ECKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
564 function __promisify__(type: "ec", options: ECKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
565 function __promisify__(type: "ec", options: ECKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
566 function __promisify__(type: "ec", options: ECKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
567 }
568}