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: Binary): boolean;
|
8 | }
|
9 | const Certificate: {
|
10 | new(): Certificate;
|
11 | (): Certificate;
|
12 | };
|
13 |
|
14 | namespace constants {
|
15 | const OPENSSL_VERSION_NUMBER: number;
|
16 |
|
17 |
|
18 | const SSL_OP_ALL: number;
|
19 |
|
20 | const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
|
21 |
|
22 | const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
|
23 |
|
24 | const SSL_OP_CISCO_ANYCONNECT: number;
|
25 |
|
26 | const SSL_OP_COOKIE_EXCHANGE: number;
|
27 |
|
28 | const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
|
29 |
|
30 | const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
|
31 |
|
32 | const SSL_OP_EPHEMERAL_RSA: number;
|
33 |
|
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 |
|
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 |
|
44 | const SSL_OP_NO_COMPRESSION: number;
|
45 | const SSL_OP_NO_QUERY_MTU: number;
|
46 |
|
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 |
|
57 | const SSL_OP_SINGLE_DH_USE: number;
|
58 |
|
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 |
|
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 |
|
93 | const RSA_PSS_SALTLEN_DIGEST: number;
|
94 |
|
95 | const RSA_PSS_SALTLEN_MAX_SIGN: number;
|
96 |
|
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 |
|
104 | const defaultCoreCipherList: string;
|
105 |
|
106 | const defaultCipherList: string;
|
107 | }
|
108 |
|
109 |
|
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 | /**
|
149 | * For asymmetric keys, this property represents the size of the embedded key in
|
150 | * bytes. This property is `undefined` for symmetric keys.
|
151 | */
|
152 | asymmetricKeySize?: number;
|
153 | export(options: KeyExportOptions<'pem'>): string | Buffer;
|
154 | export(options?: KeyExportOptions<'der'>): Buffer;
|
155 | symmetricSize?: number;
|
156 | type: KeyObjectType;
|
157 | }
|
158 |
|
159 | type CipherCCMTypes = 'aes-128-ccm' | 'aes-192-ccm' | 'aes-256-ccm';
|
160 | type CipherGCMTypes = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
|
161 |
|
162 | type Binary = Buffer | NodeJS.TypedArray | DataView;
|
163 | type BinaryLike = string | Binary;
|
164 |
|
165 | type CipherKey = BinaryLike | KeyObject;
|
166 |
|
167 | interface CipherCCMOptions extends stream.TransformOptions {
|
168 | authTagLength: number;
|
169 | }
|
170 | interface CipherGCMOptions extends stream.TransformOptions {
|
171 | authTagLength?: number;
|
172 | }
|
173 |
|
174 | function createCipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): CipherCCM;
|
175 |
|
176 | function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM;
|
177 |
|
178 | function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher;
|
179 |
|
180 | function createCipheriv(
|
181 | algorithm: CipherCCMTypes,
|
182 | key: CipherKey,
|
183 | iv: BinaryLike | null,
|
184 | options: CipherCCMOptions
|
185 | ): CipherCCM;
|
186 | function createCipheriv(
|
187 | algorithm: CipherGCMTypes,
|
188 | key: CipherKey,
|
189 | iv: BinaryLike | null,
|
190 | options?: CipherGCMOptions
|
191 | ): CipherGCM;
|
192 | function createCipheriv(
|
193 | algorithm: string, key: CipherKey, iv: BinaryLike | null, options?: stream.TransformOptions
|
194 | ): Cipher;
|
195 |
|
196 | class Cipher extends stream.Duplex {
|
197 | private constructor();
|
198 | update(data: BinaryLike): Buffer;
|
199 | update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer;
|
200 | update(data: Binary, input_encoding: undefined, output_encoding: HexBase64BinaryEncoding): string;
|
201 | update(data: string, input_encoding: Utf8AsciiBinaryEncoding | undefined, output_encoding: HexBase64BinaryEncoding): string;
|
202 | final(): Buffer;
|
203 | final(output_encoding: string): string;
|
204 | setAutoPadding(auto_padding?: boolean): this;
|
205 | // getAuthTag(): Buffer;
|
206 | // setAAD(buffer: Buffer): this; // docs only say buffer
|
207 | }
|
208 | interface CipherCCM extends Cipher {
|
209 | setAAD(buffer: Buffer, options: { plaintextLength: number }): this;
|
210 | getAuthTag(): Buffer;
|
211 | }
|
212 | interface CipherGCM extends Cipher {
|
213 | setAAD(buffer: Buffer, options?: { plaintextLength: number }): this;
|
214 | getAuthTag(): Buffer;
|
215 | }
|
216 |
|
217 | function createDecipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): DecipherCCM;
|
218 |
|
219 | function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM;
|
220 |
|
221 | function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher;
|
222 |
|
223 | function createDecipheriv(
|
224 | algorithm: CipherCCMTypes,
|
225 | key: BinaryLike,
|
226 | iv: BinaryLike | null,
|
227 | options: CipherCCMOptions,
|
228 | ): DecipherCCM;
|
229 | function createDecipheriv(
|
230 | algorithm: CipherGCMTypes,
|
231 | key: BinaryLike,
|
232 | iv: BinaryLike | null,
|
233 | options?: CipherGCMOptions,
|
234 | ): DecipherGCM;
|
235 | function createDecipheriv(algorithm: string, key: BinaryLike, iv: BinaryLike | null, options?: stream.TransformOptions): Decipher;
|
236 |
|
237 | class Decipher extends stream.Duplex {
|
238 | private constructor();
|
239 | update(data: Binary): Buffer;
|
240 | update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer;
|
241 | update(data: Binary, input_encoding: undefined, output_encoding: Utf8AsciiBinaryEncoding): string;
|
242 | update(data: string, input_encoding: HexBase64BinaryEncoding | undefined, output_encoding: Utf8AsciiBinaryEncoding): string;
|
243 | final(): Buffer;
|
244 | final(output_encoding: string): string;
|
245 | setAutoPadding(auto_padding?: boolean): this;
|
246 | // setAuthTag(tag: Binary): this;
|
247 | // setAAD(buffer: Binary): this;
|
248 | }
|
249 | interface DecipherCCM extends Decipher {
|
250 | setAuthTag(buffer: Binary): this;
|
251 | setAAD(buffer: Binary, options: { plaintextLength: number }): this;
|
252 | }
|
253 | interface DecipherGCM extends Decipher {
|
254 | setAuthTag(buffer: Binary): this;
|
255 | setAAD(buffer: Binary, options?: { plaintextLength: number }): this;
|
256 | }
|
257 |
|
258 | interface PrivateKeyInput {
|
259 | key: string | Buffer;
|
260 | format?: KeyFormat;
|
261 | type?: 'pkcs1' | 'pkcs8' | 'sec1';
|
262 | passphrase?: string | Buffer;
|
263 | }
|
264 |
|
265 | interface PublicKeyInput {
|
266 | key: string | Buffer;
|
267 | format?: KeyFormat;
|
268 | type?: 'pkcs1' | 'spki';
|
269 | }
|
270 |
|
271 | function createPrivateKey(key: PrivateKeyInput | string | Buffer): KeyObject;
|
272 | function createPublicKey(key: PublicKeyInput | string | Buffer | KeyObject): KeyObject;
|
273 | function createSecretKey(key: Buffer): KeyObject;
|
274 |
|
275 | function createSign(algorithm: string, options?: stream.WritableOptions): Signer;
|
276 |
|
277 | interface SigningOptions {
|
278 | |
279 |
|
280 |
|
281 | padding?: number;
|
282 | saltLength?: number;
|
283 | }
|
284 |
|
285 | interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {
|
286 | }
|
287 |
|
288 | type KeyLike = string | Buffer | KeyObject;
|
289 |
|
290 | class Signer extends stream.Writable {
|
291 | private constructor();
|
292 |
|
293 | update(data: BinaryLike): Signer;
|
294 | update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Signer;
|
295 | sign(private_key: SignPrivateKeyInput | KeyLike): Buffer;
|
296 | sign(private_key: SignPrivateKeyInput | KeyLike, output_format: HexBase64Latin1Encoding): string;
|
297 | }
|
298 |
|
299 | function createVerify(algorith: string, options?: stream.WritableOptions): Verify;
|
300 | class Verify extends stream.Writable {
|
301 | private constructor();
|
302 |
|
303 | update(data: BinaryLike): Verify;
|
304 | update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Verify;
|
305 | verify(object: Object | KeyLike, signature: Binary): boolean;
|
306 | verify(object: Object | KeyLike, signature: string, signature_format?: HexBase64Latin1Encoding): boolean;
|
307 | // https://nodejs.org/api/crypto.html#crypto_verifier_verify_object_signature_signature_format
|
308 | // The signature field accepts a TypedArray type, but it is only available starting ES2017
|
309 | }
|
310 | function createDiffieHellman(prime_length: number, generator?: number | Binary): DiffieHellman;
|
311 | function createDiffieHellman(prime: Binary): DiffieHellman;
|
312 | function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman;
|
313 | function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | Binary): DiffieHellman;
|
314 | function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman;
|
315 | class DiffieHellman {
|
316 | private constructor();
|
317 | generateKeys(): Buffer;
|
318 | generateKeys(encoding: HexBase64Latin1Encoding): string;
|
319 | computeSecret(other_public_key: Binary): Buffer;
|
320 | computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
|
321 | computeSecret(other_public_key: Binary, output_encoding: HexBase64Latin1Encoding): string;
|
322 | computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
|
323 | getPrime(): Buffer;
|
324 | getPrime(encoding: HexBase64Latin1Encoding): string;
|
325 | getGenerator(): Buffer;
|
326 | getGenerator(encoding: HexBase64Latin1Encoding): string;
|
327 | getPublicKey(): Buffer;
|
328 | getPublicKey(encoding: HexBase64Latin1Encoding): string;
|
329 | getPrivateKey(): Buffer;
|
330 | getPrivateKey(encoding: HexBase64Latin1Encoding): string;
|
331 | setPublicKey(public_key: Binary): void;
|
332 | setPublicKey(public_key: string, encoding: string): void;
|
333 | setPrivateKey(private_key: Binary): void;
|
334 | setPrivateKey(private_key: string, encoding: string): void;
|
335 | verifyError: number;
|
336 | }
|
337 | function getDiffieHellman(group_name: string): DiffieHellman;
|
338 | function pbkdf2(
|
339 | password: BinaryLike,
|
340 | salt: BinaryLike,
|
341 | iterations: number,
|
342 | keylen: number,
|
343 | digest: string,
|
344 | callback: (err: Error | null, derivedKey: Buffer) => any,
|
345 | ): void;
|
346 | function pbkdf2Sync(password: BinaryLike, salt: BinaryLike, iterations: number, keylen: number, digest: string): Buffer;
|
347 |
|
348 | function randomBytes(size: number): Buffer;
|
349 | function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
|
350 | function pseudoRandomBytes(size: number): Buffer;
|
351 | function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
|
352 |
|
353 | function randomFillSync<T extends Binary>(buffer: T, offset?: number, size?: number): T;
|
354 | function randomFill<T extends Binary>(buffer: T, callback: (err: Error | null, buf: T) => void): void;
|
355 | function randomFill<T extends Binary>(buffer: T, offset: number, callback: (err: Error | null, buf: T) => void): void;
|
356 | function randomFill<T extends Binary>(buffer: T, offset: number, size: number, callback: (err: Error | null, buf: T) => void): void;
|
357 |
|
358 | interface ScryptOptions {
|
359 | N?: number;
|
360 | r?: number;
|
361 | p?: number;
|
362 | maxmem?: number;
|
363 | }
|
364 | function scrypt(
|
365 | password: BinaryLike,
|
366 | salt: BinaryLike,
|
367 | keylen: number, callback: (err: Error | null, derivedKey: Buffer) => void,
|
368 | ): void;
|
369 | function scrypt(
|
370 | password: BinaryLike,
|
371 | salt: BinaryLike,
|
372 | keylen: number,
|
373 | options: ScryptOptions,
|
374 | callback: (err: Error | null, derivedKey: Buffer) => void,
|
375 | ): void;
|
376 | function scryptSync(password: BinaryLike, salt: BinaryLike, keylen: number, options?: ScryptOptions): Buffer;
|
377 |
|
378 | interface RsaPublicKey {
|
379 | key: KeyLike;
|
380 | padding?: number;
|
381 | }
|
382 | interface RsaPrivateKey {
|
383 | key: KeyLike;
|
384 | passphrase?: string;
|
385 | padding?: number;
|
386 | }
|
387 | function publicEncrypt(public_key: RsaPublicKey | KeyLike, buffer: Binary): Buffer;
|
388 | function privateDecrypt(private_key: RsaPrivateKey | KeyLike, buffer: Binary): Buffer;
|
389 | function privateEncrypt(private_key: RsaPrivateKey | KeyLike, buffer: Binary): Buffer;
|
390 | function publicDecrypt(public_key: RsaPublicKey | KeyLike, buffer: Binary): Buffer;
|
391 | function getCiphers(): string[];
|
392 | function getCurves(): string[];
|
393 | function getHashes(): string[];
|
394 | class ECDH {
|
395 | private constructor();
|
396 | static convertKey(
|
397 | key: BinaryLike,
|
398 | curve: string,
|
399 | inputEncoding?: HexBase64Latin1Encoding,
|
400 | outputEncoding?: "latin1" | "hex" | "base64",
|
401 | format?: "uncompressed" | "compressed" | "hybrid",
|
402 | ): Buffer | string;
|
403 | generateKeys(): Buffer;
|
404 | generateKeys(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
|
405 | computeSecret(other_public_key: Binary): Buffer;
|
406 | computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
|
407 | computeSecret(other_public_key: Binary, output_encoding: HexBase64Latin1Encoding): string;
|
408 | computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
|
409 | getPrivateKey(): Buffer;
|
410 | getPrivateKey(encoding: HexBase64Latin1Encoding): string;
|
411 | getPublicKey(): Buffer;
|
412 | getPublicKey(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
|
413 | setPrivateKey(private_key: Binary): void;
|
414 | setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void;
|
415 | }
|
416 | function createECDH(curve_name: string): ECDH;
|
417 | function timingSafeEqual(a: Binary, b: Binary): boolean;
|
418 | /** @deprecated since v10.0.0 */
|
419 | const DEFAULT_ENCODING: string;
|
420 |
|
421 | export type KeyType = 'rsa' | 'dsa' | 'ec';
|
422 | export type KeyFormat = 'pem' | 'der';
|
423 |
|
424 | interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
|
425 | format: T;
|
426 | cipher?: string;
|
427 | passphrase?: string;
|
428 | }
|
429 |
|
430 | interface KeyPairKeyObjectResult {
|
431 | publicKey: KeyObject;
|
432 | privateKey: KeyObject;
|
433 | }
|
434 |
|
435 | interface ECKeyPairKeyObjectOptions {
|
436 | |
437 |
|
438 |
|
439 | namedCurve: string;
|
440 | }
|
441 |
|
442 | interface RSAKeyPairKeyObjectOptions {
|
443 | |
444 |
|
445 |
|
446 | modulusLength: number;
|
447 |
|
448 | |
449 |
|
450 |
|
451 | publicExponent?: number;
|
452 | }
|
453 |
|
454 | interface DSAKeyPairKeyObjectOptions {
|
455 | |
456 |
|
457 |
|
458 | modulusLength: number;
|
459 |
|
460 | |
461 |
|
462 |
|
463 | divisorLength: number;
|
464 | }
|
465 |
|
466 | interface RSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
467 | |
468 |
|
469 |
|
470 | modulusLength: number;
|
471 | |
472 |
|
473 |
|
474 | publicExponent?: number;
|
475 |
|
476 | publicKeyEncoding: {
|
477 | type: 'pkcs1' | 'spki';
|
478 | format: PubF;
|
479 | };
|
480 | privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
481 | type: 'pkcs1' | 'pkcs8';
|
482 | };
|
483 | }
|
484 |
|
485 | interface DSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
486 | |
487 |
|
488 |
|
489 | modulusLength: number;
|
490 | |
491 |
|
492 |
|
493 | divisorLength: number;
|
494 |
|
495 | publicKeyEncoding: {
|
496 | type: 'spki';
|
497 | format: PubF;
|
498 | };
|
499 | privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
500 | type: 'pkcs8';
|
501 | };
|
502 | }
|
503 |
|
504 | interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
505 | |
506 |
|
507 |
|
508 | namedCurve: string;
|
509 |
|
510 | publicKeyEncoding: {
|
511 | type: 'pkcs1' | 'spki';
|
512 | format: PubF;
|
513 | };
|
514 | privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
515 | type: 'sec1' | 'pkcs8';
|
516 | };
|
517 | }
|
518 |
|
519 | interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
|
520 | publicKey: T1;
|
521 | privateKey: T2;
|
522 | }
|
523 |
|
524 | function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
|
525 | function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
|
526 | function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
|
527 | function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
|
528 | function generateKeyPairSync(type: 'rsa', options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
529 |
|
530 | function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
|
531 | function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
|
532 | function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
|
533 | function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
|
534 | function generateKeyPairSync(type: 'dsa', options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
535 |
|
536 | function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
|
537 | function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
|
538 | function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
|
539 | function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
|
540 | function generateKeyPairSync(type: 'ec', options: ECKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
541 |
|
542 | function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
|
543 | function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
|
544 | function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
|
545 | function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
|
546 | function generateKeyPair(type: 'rsa', options: RSAKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
|
547 |
|
548 | function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
|
549 | function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
|
550 | function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
|
551 | function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
|
552 | function generateKeyPair(type: 'dsa', options: DSAKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
|
553 |
|
554 | function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
|
555 | function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
|
556 | function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
|
557 | function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
|
558 | function generateKeyPair(type: 'ec', options: ECKeyPairKeyObjectOptions, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void): void;
|
559 |
|
560 | namespace generateKeyPair {
|
561 | function __promisify__(type: "rsa", options: RSAKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
|
562 | function __promisify__(type: "rsa", options: RSAKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
|
563 | function __promisify__(type: "rsa", options: RSAKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
|
564 | function __promisify__(type: "rsa", options: RSAKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
|
565 | function __promisify__(type: "rsa", options: RSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
|
566 |
|
567 | function __promisify__(type: "dsa", options: DSAKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
|
568 | function __promisify__(type: "dsa", options: DSAKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
|
569 | function __promisify__(type: "dsa", options: DSAKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
|
570 | function __promisify__(type: "dsa", options: DSAKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
|
571 | function __promisify__(type: "dsa", options: DSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
|
572 |
|
573 | function __promisify__(type: "ec", options: ECKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
|
574 | function __promisify__(type: "ec", options: ECKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
|
575 | function __promisify__(type: "ec", options: ECKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
|
576 | function __promisify__(type: "ec", options: ECKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
|
577 | function __promisify__(type: "ec", options: ECKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
|
578 | }
|
579 |
|
580 | |
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 | function sign(algorithm: string | null | undefined, data: Binary, key: KeyLike | SignPrivateKeyInput): Buffer;
|
589 |
|
590 | interface VerifyKeyWithOptions extends KeyObject, SigningOptions {
|
591 | }
|
592 |
|
593 | |
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 | function verify(algorithm: string | null | undefined, data: Binary, key: KeyLike | VerifyKeyWithOptions, signature: Binary): Buffer;
|
602 | }
|