1 declare module 'crypto' {
2 import * as stream from 'stream';
4 interface Certificate {
5 exportChallenge(spkac: BinaryLike): Buffer;
6 exportPublicKey(spkac: BinaryLike): Buffer;
7 verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
15 // https://nodejs.org/dist/latest-v10.x/docs/api/crypto.html#crypto_crypto_constants
16 const OPENSSL_VERSION_NUMBER: number;
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;
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;
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;
85 const ALPN_ENABLED: number;
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;
100 const POINT_CONVERSION_COMPRESSED: number;
101 const POINT_CONVERSION_UNCOMPRESSED: number;
102 const POINT_CONVERSION_HYBRID: number;
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;
110 interface HashOptions extends stream.TransformOptions {
112 * For XOF hash functions such as `shake256`, the
113 * outputLength option can be used to specify the desired output length in bytes.
115 outputLength?: number;
118 /** @deprecated since v10.0.0 */
121 function createHash(algorithm: string, options?: HashOptions): Hash;
122 function createHmac(algorithm: string, key: BinaryLike | KeyObject, options?: stream.TransformOptions): Hmac;
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';
130 class Hash extends stream.Transform {
131 private constructor();
133 update(data: BinaryLike): Hash;
134 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hash;
136 digest(encoding: HexBase64Latin1Encoding): string;
138 class Hmac extends stream.Transform {
139 private constructor();
140 update(data: BinaryLike): Hmac;
141 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hmac;
143 digest(encoding: HexBase64Latin1Encoding): string;
146 type KeyObjectType = 'secret' | 'public' | 'private';
148 interface KeyExportOptions<T extends KeyFormat> {
149 type: 'pkcs1' | 'spki' | 'pkcs8' | 'sec1';
152 passphrase?: string | Buffer;
156 private constructor();
157 asymmetricKeyType?: KeyType;
159 * For asymmetric keys, this property represents the size of the embedded key in
160 * bytes. This property is `undefined` for symmetric keys.
162 asymmetricKeySize?: number;
163 export(options: KeyExportOptions<'pem'>): string | Buffer;
164 export(options?: KeyExportOptions<'der'>): Buffer;
165 symmetricKeySize?: number;
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';
172 type BinaryLike = string | NodeJS.ArrayBufferView;
174 type CipherKey = BinaryLike | KeyObject;
176 interface CipherCCMOptions extends stream.TransformOptions {
177 authTagLength: number;
179 interface CipherGCMOptions extends stream.TransformOptions {
180 authTagLength?: number;
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;
189 function createCipheriv(
190 algorithm: CipherCCMTypes,
192 iv: BinaryLike | null,
193 options: CipherCCMOptions,
195 function createCipheriv(
196 algorithm: CipherGCMTypes,
198 iv: BinaryLike | null,
199 options?: CipherGCMOptions,
201 function createCipheriv(
204 iv: BinaryLike | null,
205 options?: stream.TransformOptions,
208 class Cipher extends stream.Transform {
209 private constructor();
210 update(data: BinaryLike): Buffer;
211 update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer;
213 data: NodeJS.ArrayBufferView,
214 input_encoding: undefined,
215 output_encoding: HexBase64BinaryEncoding,
219 input_encoding: Utf8AsciiBinaryEncoding | undefined,
220 output_encoding: HexBase64BinaryEncoding,
223 final(output_encoding: string): string;
224 setAutoPadding(auto_padding?: boolean): this;
225 // getAuthTag(): Buffer;
226 // setAAD(buffer: Buffer): this; // docs only say buffer
228 interface CipherCCM extends Cipher {
229 setAAD(buffer: Buffer, options: { plaintextLength: number }): this;
230 getAuthTag(): Buffer;
232 interface CipherGCM extends Cipher {
233 setAAD(buffer: Buffer, options?: { plaintextLength: number }): this;
234 getAuthTag(): Buffer;
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;
243 function createDecipheriv(
244 algorithm: CipherCCMTypes,
246 iv: BinaryLike | null,
247 options: CipherCCMOptions,
249 function createDecipheriv(
250 algorithm: CipherGCMTypes,
252 iv: BinaryLike | null,
253 options?: CipherGCMOptions,
255 function createDecipheriv(
258 iv: BinaryLike | null,
259 options?: stream.TransformOptions,
262 class Decipher extends stream.Transform {
263 private constructor();
264 update(data: NodeJS.ArrayBufferView): Buffer;
265 update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer;
267 data: NodeJS.ArrayBufferView,
268 input_encoding: HexBase64BinaryEncoding | undefined,
269 output_encoding: Utf8AsciiBinaryEncoding,
273 input_encoding: HexBase64BinaryEncoding | undefined,
274 output_encoding: Utf8AsciiBinaryEncoding,
277 final(output_encoding: string): string;
278 setAutoPadding(auto_padding?: boolean): this;
279 // setAuthTag(tag: NodeJS.ArrayBufferView): this;
280 // setAAD(buffer: NodeJS.ArrayBufferView): this;
282 interface DecipherCCM extends Decipher {
283 setAuthTag(buffer: NodeJS.ArrayBufferView): this;
284 setAAD(buffer: NodeJS.ArrayBufferView, options: { plaintextLength: number }): this;
286 interface DecipherGCM extends Decipher {
287 setAuthTag(buffer: NodeJS.ArrayBufferView): this;
288 setAAD(buffer: NodeJS.ArrayBufferView, options?: { plaintextLength: number }): this;
291 interface PrivateKeyInput {
292 key: string | Buffer;
294 type?: 'pkcs1' | 'pkcs8' | 'sec1';
295 passphrase?: string | Buffer;
298 interface PublicKeyInput {
299 key: string | Buffer;
301 type?: 'pkcs1' | 'spki';
304 function createPrivateKey(key: PrivateKeyInput | string | Buffer): KeyObject;
305 function createPublicKey(key: PublicKeyInput | string | Buffer | KeyObject): KeyObject;
306 function createSecretKey(key: Buffer): KeyObject;
308 function createSign(algorithm: string, options?: stream.WritableOptions): Signer;
310 interface SigningOptions {
312 * @See crypto.constants.RSA_PKCS1_PADDING
318 interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {}
320 type KeyLike = string | Buffer | KeyObject;
322 class Signer extends stream.Writable {
323 private constructor();
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;
331 function createVerify(algorithm: string, options?: stream.WritableOptions): Verify;
332 class Verify extends stream.Writable {
333 private constructor();
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
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(
347 prime_encoding: HexBase64Latin1Encoding,
348 generator: number | NodeJS.ArrayBufferView,
350 function createDiffieHellman(
352 prime_encoding: HexBase64Latin1Encoding,
354 generator_encoding: HexBase64Latin1Encoding,
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;
364 other_public_key: string,
365 input_encoding: HexBase64Latin1Encoding,
366 output_encoding: HexBase64Latin1Encoding,
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;
382 function getDiffieHellman(group_name: string): DiffieHellman;
384 password: BinaryLike,
389 callback: (err: Error | null, derivedKey: Buffer) => any,
392 password: BinaryLike,
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;
404 function randomFillSync<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number, size?: number): T;
405 function randomFill<T extends NodeJS.ArrayBufferView>(
407 callback: (err: Error | null, buf: T) => void,
409 function randomFill<T extends NodeJS.ArrayBufferView>(
412 callback: (err: Error | null, buf: T) => void,
414 function randomFill<T extends NodeJS.ArrayBufferView>(
418 callback: (err: Error | null, buf: T) => void,
421 interface ScryptOptions {
424 parallelization?: number;
431 password: BinaryLike,
434 callback: (err: Error | null, derivedKey: Buffer) => void,
437 password: BinaryLike,
440 options: ScryptOptions,
441 callback: (err: Error | null, derivedKey: Buffer) => void,
443 function scryptSync(password: BinaryLike, salt: BinaryLike, keylen: number, options?: ScryptOptions): Buffer;
445 interface RsaPublicKey {
449 interface RsaPrivateKey {
456 oaepLabel?: NodeJS.TypedArray;
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[];
468 private constructor();
472 inputEncoding?: HexBase64Latin1Encoding,
473 outputEncoding?: 'latin1' | 'hex' | 'base64',
474 format?: 'uncompressed' | 'compressed' | 'hybrid',
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;
482 other_public_key: string,
483 input_encoding: HexBase64Latin1Encoding,
484 output_encoding: HexBase64Latin1Encoding,
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;
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;
498 type KeyType = 'rsa' | 'dsa' | 'ec';
499 type KeyFormat = 'pem' | 'der';
501 interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
507 interface KeyPairKeyObjectResult {
508 publicKey: KeyObject;
509 privateKey: KeyObject;
512 interface ECKeyPairKeyObjectOptions {
514 * Name of the curve to use.
519 interface RSAKeyPairKeyObjectOptions {
523 modulusLength: number;
528 publicExponent?: number;
531 interface DSAKeyPairKeyObjectOptions {
535 modulusLength: number;
540 divisorLength: number;
543 interface RSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
547 modulusLength: number;
551 publicExponent?: number;
554 type: 'pkcs1' | 'spki';
557 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
558 type: 'pkcs1' | 'pkcs8';
562 interface DSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
566 modulusLength: number;
570 divisorLength: number;
576 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
581 interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
583 * Name of the curve to use.
588 type: 'pkcs1' | 'spki';
591 privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
592 type: 'sec1' | 'pkcs8';
596 interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
601 function generateKeyPairSync(
603 options: RSAKeyPairOptions<'pem', 'pem'>,
604 ): KeyPairSyncResult<string, string>;
605 function generateKeyPairSync(
607 options: RSAKeyPairOptions<'pem', 'der'>,
608 ): KeyPairSyncResult<string, Buffer>;
609 function generateKeyPairSync(
611 options: RSAKeyPairOptions<'der', 'pem'>,
612 ): KeyPairSyncResult<Buffer, string>;
613 function generateKeyPairSync(
615 options: RSAKeyPairOptions<'der', 'der'>,
616 ): KeyPairSyncResult<Buffer, Buffer>;
617 function generateKeyPairSync(type: 'rsa', options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
619 function generateKeyPairSync(
621 options: DSAKeyPairOptions<'pem', 'pem'>,
622 ): KeyPairSyncResult<string, string>;
623 function generateKeyPairSync(
625 options: DSAKeyPairOptions<'pem', 'der'>,
626 ): KeyPairSyncResult<string, Buffer>;
627 function generateKeyPairSync(
629 options: DSAKeyPairOptions<'der', 'pem'>,
630 ): KeyPairSyncResult<Buffer, string>;
631 function generateKeyPairSync(
633 options: DSAKeyPairOptions<'der', 'der'>,
634 ): KeyPairSyncResult<Buffer, Buffer>;
635 function generateKeyPairSync(type: 'dsa', options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
637 function generateKeyPairSync(
639 options: ECKeyPairOptions<'pem', 'pem'>,
640 ): KeyPairSyncResult<string, string>;
641 function generateKeyPairSync(
643 options: ECKeyPairOptions<'pem', 'der'>,
644 ): KeyPairSyncResult<string, Buffer>;
645 function generateKeyPairSync(
647 options: ECKeyPairOptions<'der', 'pem'>,
648 ): KeyPairSyncResult<Buffer, string>;
649 function generateKeyPairSync(
651 options: ECKeyPairOptions<'der', 'der'>,
652 ): KeyPairSyncResult<Buffer, Buffer>;
653 function generateKeyPairSync(type: 'ec', options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
655 function generateKeyPair(
657 options: RSAKeyPairOptions<'pem', 'pem'>,
658 callback: (err: Error | null, publicKey: string, privateKey: string) => void,
660 function generateKeyPair(
662 options: RSAKeyPairOptions<'pem', 'der'>,
663 callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
665 function generateKeyPair(
667 options: RSAKeyPairOptions<'der', 'pem'>,
668 callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
670 function generateKeyPair(
672 options: RSAKeyPairOptions<'der', 'der'>,
673 callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
675 function generateKeyPair(
677 options: RSAKeyPairKeyObjectOptions,
678 callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
681 function generateKeyPair(
683 options: DSAKeyPairOptions<'pem', 'pem'>,
684 callback: (err: Error | null, publicKey: string, privateKey: string) => void,
686 function generateKeyPair(
688 options: DSAKeyPairOptions<'pem', 'der'>,
689 callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
691 function generateKeyPair(
693 options: DSAKeyPairOptions<'der', 'pem'>,
694 callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
696 function generateKeyPair(
698 options: DSAKeyPairOptions<'der', 'der'>,
699 callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
701 function generateKeyPair(
703 options: DSAKeyPairKeyObjectOptions,
704 callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
707 function generateKeyPair(
709 options: ECKeyPairOptions<'pem', 'pem'>,
710 callback: (err: Error | null, publicKey: string, privateKey: string) => void,
712 function generateKeyPair(
714 options: ECKeyPairOptions<'pem', 'der'>,
715 callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
717 function generateKeyPair(
719 options: ECKeyPairOptions<'der', 'pem'>,
720 callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
722 function generateKeyPair(
724 options: ECKeyPairOptions<'der', 'der'>,
725 callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
727 function generateKeyPair(
729 options: ECKeyPairKeyObjectOptions,
730 callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
733 namespace generateKeyPair {
734 function __promisify__(
736 options: RSAKeyPairOptions<'pem', 'pem'>,
737 ): Promise<{ publicKey: string; privateKey: string }>;
738 function __promisify__(
740 options: RSAKeyPairOptions<'pem', 'der'>,
741 ): Promise<{ publicKey: string; privateKey: Buffer }>;
742 function __promisify__(
744 options: RSAKeyPairOptions<'der', 'pem'>,
745 ): Promise<{ publicKey: Buffer; privateKey: string }>;
746 function __promisify__(
748 options: RSAKeyPairOptions<'der', 'der'>,
749 ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
750 function __promisify__(type: 'rsa', options: RSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
752 function __promisify__(
754 options: DSAKeyPairOptions<'pem', 'pem'>,
755 ): Promise<{ publicKey: string; privateKey: string }>;
756 function __promisify__(
758 options: DSAKeyPairOptions<'pem', 'der'>,
759 ): Promise<{ publicKey: string; privateKey: Buffer }>;
760 function __promisify__(
762 options: DSAKeyPairOptions<'der', 'pem'>,
763 ): Promise<{ publicKey: Buffer; privateKey: string }>;
764 function __promisify__(
766 options: DSAKeyPairOptions<'der', 'der'>,
767 ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
768 function __promisify__(type: 'dsa', options: DSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
770 function __promisify__(
772 options: ECKeyPairOptions<'pem', 'pem'>,
773 ): Promise<{ publicKey: string; privateKey: string }>;
774 function __promisify__(
776 options: ECKeyPairOptions<'pem', 'der'>,
777 ): Promise<{ publicKey: string; privateKey: Buffer }>;
778 function __promisify__(
780 options: ECKeyPairOptions<'der', 'pem'>,
781 ): Promise<{ publicKey: Buffer; privateKey: string }>;
782 function __promisify__(
784 options: ECKeyPairOptions<'der', 'der'>,
785 ): Promise<{ publicKey: Buffer; privateKey: Buffer }>;
786 function __promisify__(type: 'ec', options: ECKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
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).
794 * If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
795 * passed to [`crypto.createPrivateKey()`][].
798 algorithm: string | null | undefined,
799 data: NodeJS.ArrayBufferView,
800 key: KeyLike | SignPrivateKeyInput,
803 interface VerifyKeyWithOptions extends KeyObject, SigningOptions {}
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).
810 * If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
811 * passed to [`crypto.createPublicKey()`][].
814 algorithm: string | null | undefined,
815 data: NodeJS.ArrayBufferView,
816 key: KeyLike | VerifyKeyWithOptions,
817 signature: NodeJS.ArrayBufferView,