summaryrefslogtreecommitdiff
path: root/doc/api/crypto.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/api/crypto.md')
-rw-r--r--doc/api/crypto.md75
1 files changed, 75 insertions, 0 deletions
diff --git a/doc/api/crypto.md b/doc/api/crypto.md
index dbef108f89..137d6e0508 100644
--- a/doc/api/crypto.md
+++ b/doc/api/crypto.md
@@ -55,6 +55,7 @@ data. The most common usage is handling output generated by the HTML5
<!-- YAML
added: v9.0.0
-->
+
* `spkac` {string | Buffer | TypedArray | DataView}
* Returns: {Buffer} The challenge component of the `spkac` data structure, which
includes a public key and a challenge.
@@ -71,6 +72,7 @@ console.log(challenge.toString('utf8'));
<!-- YAML
added: v9.0.0
-->
+
* `spkac` {string | Buffer | TypedArray | DataView}
* `encoding` {string} The [encoding][] of the `spkac` string.
* Returns: {Buffer} The public key component of the `spkac` data structure,
@@ -88,6 +90,7 @@ console.log(publicKey);
<!-- YAML
added: v9.0.0
-->
+
* `spkac` {Buffer | TypedArray | DataView}
* Returns: {boolean} `true` if the given `spkac` data structure is valid,
`false` otherwise.
@@ -121,6 +124,7 @@ const cert2 = crypto.Certificate();
<!-- YAML
added: v0.11.8
-->
+
* `spkac` {string | Buffer | TypedArray | DataView}
* Returns: {Buffer} The challenge component of the `spkac` data structure, which
includes a public key and a challenge.
@@ -137,6 +141,7 @@ console.log(challenge.toString('utf8'));
<!-- YAML
added: v0.11.8
-->
+
* `spkac` {string | Buffer | TypedArray | DataView}
* Returns: {Buffer} The public key component of the `spkac` data structure,
which includes a public key and a challenge.
@@ -153,6 +158,7 @@ console.log(publicKey);
<!-- YAML
added: v0.11.8
-->
+
* `spkac` {Buffer | TypedArray | DataView}
* Returns: {boolean} `true` if the given `spkac` data structure is valid,
`false` otherwise.
@@ -263,6 +269,7 @@ console.log(encrypted);
<!-- YAML
added: v0.1.94
-->
+
* `outputEncoding` {string} The [encoding][] of the return value.
* Returns: {Buffer | string} Any remaining enciphered contents.
If `outputEncoding` is specified, a string is
@@ -276,6 +283,7 @@ once will result in an error being thrown.
<!-- YAML
added: v1.0.0
-->
+
* `buffer` {Buffer}
* `options` {Object} [`stream.transform` options][]
- `plaintextLength` {number}
@@ -295,6 +303,7 @@ The `cipher.setAAD()` method must be called before [`cipher.update()`][].
<!-- YAML
added: v1.0.0
-->
+
* Returns: {Buffer} When using an authenticated encryption mode (`GCM`, `CCM`
and `OCB` are currently supported), the `cipher.getAuthTag()` method returns a
[`Buffer`][] containing the _authentication tag_ that has been computed from
@@ -307,6 +316,7 @@ been completed using the [`cipher.final()`][] method.
<!-- YAML
added: v0.7.1
-->
+
* `autoPadding` {boolean} **Default:** `true`
* Returns: {Cipher} for method chaining.
@@ -330,6 +340,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `inputEncoding` changed from `binary` to `utf8`.
-->
+
* `data` {string | Buffer | TypedArray | DataView}
* `inputEncoding` {string} The [encoding][] of the data.
* `outputEncoding` {string} The [encoding][] of the return value.
@@ -452,6 +463,7 @@ console.log(decrypted);
<!-- YAML
added: v0.1.94
-->
+
* `outputEncoding` {string} The [encoding][] of the return value.
* Returns: {Buffer | string} Any remaining deciphered contents.
If `outputEncoding` is specified, a string is
@@ -469,6 +481,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/9398
description: This method now returns a reference to `decipher`.
-->
+
* `buffer` {Buffer | TypedArray | DataView}
* `options` {Object} [`stream.transform` options][]
- `plaintextLength` {number}
@@ -495,6 +508,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/9398
description: This method now returns a reference to `decipher`.
-->
+
* `buffer` {Buffer | TypedArray | DataView}
* Returns: {Decipher} for method chaining.
@@ -513,6 +527,7 @@ The `decipher.setAuthTag()` method must be called before
<!-- YAML
added: v0.7.1
-->
+
* `autoPadding` {boolean} **Default:** `true`
* Returns: {Decipher} for method chaining.
@@ -534,6 +549,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `inputEncoding` changed from `binary` to `utf8`.
-->
+
* `data` {string | Buffer | TypedArray | DataView}
* `inputEncoding` {string} The [encoding][] of the `data` string.
* `outputEncoding` {string} The [encoding][] of the return value.
@@ -589,6 +605,7 @@ assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
<!-- YAML
added: v0.5.0
-->
+
* `otherPublicKey` {string | Buffer | TypedArray | DataView}
* `inputEncoding` {string} The [encoding][] of an `otherPublicKey` string.
* `outputEncoding` {string} The [encoding][] of the return value.
@@ -609,6 +626,7 @@ If `outputEncoding` is given a string is returned; otherwise, a
<!-- YAML
added: v0.5.0
-->
+
* `encoding` {string} The [encoding][] of the return value.
* Returns: {Buffer | string}
@@ -622,6 +640,7 @@ If `encoding` is provided a string is returned; otherwise a
<!-- YAML
added: v0.5.0
-->
+
* `encoding` {string} The [encoding][] of the return value.
* Returns: {Buffer | string}
@@ -633,6 +652,7 @@ returned; otherwise a [`Buffer`][] is returned.
<!-- YAML
added: v0.5.0
-->
+
* `encoding` {string} The [encoding][] of the return value.
* Returns: {Buffer | string}
@@ -644,6 +664,7 @@ returned; otherwise a [`Buffer`][] is returned.
<!-- YAML
added: v0.5.0
-->
+
* `encoding` {string} The [encoding][] of the return value.
* Returns: {Buffer | string}
@@ -655,6 +676,7 @@ string is returned; otherwise a [`Buffer`][] is returned.
<!-- YAML
added: v0.5.0
-->
+
* `encoding` {string} The [encoding][] of the return value.
* Returns: {Buffer | string}
@@ -666,6 +688,7 @@ string is returned; otherwise a [`Buffer`][] is returned.
<!-- YAML
added: v0.5.0
-->
+
* `privateKey` {string | Buffer | TypedArray | DataView}
* `encoding` {string} The [encoding][] of the `privateKey` string.
@@ -678,6 +701,7 @@ to be a [`Buffer`][], `TypedArray`, or `DataView`.
<!-- YAML
added: v0.5.0
-->
+
* `publicKey` {string | Buffer | TypedArray | DataView}
* `encoding` {string} The [encoding][] of the `publicKey` string.
@@ -820,6 +844,7 @@ changes:
description: Changed error format to better support invalid public key
error
-->
+
* `otherPublicKey` {string | Buffer | TypedArray | DataView}
* `inputEncoding` {string} The [encoding][] of the `otherPublicKey` string.
* `outputEncoding` {string} The [encoding][] of the return value.
@@ -846,6 +871,7 @@ its recommended for developers to handle this exception accordingly.
<!-- YAML
added: v0.11.14
-->
+
* `encoding` {string} The [encoding][] of the return value.
* `format` {string} **Default:** `'uncompressed'`
* Returns: {Buffer | string}
@@ -865,6 +891,7 @@ is returned.
<!-- YAML
added: v0.11.14
-->
+
* `encoding` {string} The [encoding][] of the return value.
* Returns: {Buffer | string} The EC Diffie-Hellman in the specified `encoding`.
@@ -875,6 +902,7 @@ returned.
<!-- YAML
added: v0.11.14
-->
+
* `encoding` {string} The [encoding][] of the return value.
* `format` {string} **Default:** `'uncompressed'`
* Returns: {Buffer | string} The EC Diffie-Hellman public key in the specified
@@ -891,6 +919,7 @@ returned.
<!-- YAML
added: v0.11.14
-->
+
* `privateKey` {string | Buffer | TypedArray | DataView}
* `encoding` {string} The [encoding][] of the `privateKey` string.
@@ -1016,6 +1045,7 @@ console.log(hash.digest('hex'));
<!-- YAML
added: v0.1.92
-->
+
* `encoding` {string} The [encoding][] of the return value.
* Returns: {Buffer | string}
@@ -1035,6 +1065,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `inputEncoding` changed from `binary` to `utf8`.
-->
+
* `data` {string | Buffer | TypedArray | DataView}
* `inputEncoding` {string} The [encoding][] of the `data` string.
@@ -1112,6 +1143,7 @@ console.log(hmac.digest('hex'));
<!-- YAML
added: v0.1.94
-->
+
* `encoding` {string} The [encoding][] of the return value.
* Returns: {Buffer | string}
@@ -1130,6 +1162,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `inputEncoding` changed from `binary` to `utf8`.
-->
+
* `data` {string | Buffer | TypedArray | DataView}
* `inputEncoding` {string} The [encoding][] of the `data` string.
@@ -1178,6 +1211,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/26319
description: Added support for `'ed25519'` and `'ed448'`.
-->
+
* {string}
For asymmetric keys, this property represents the type of the key. Supported key
@@ -1199,6 +1233,7 @@ keys.
<!-- YAML
added: v11.6.0
-->
+
* `options`: {Object}
* Returns: {string | Buffer}
@@ -1241,6 +1276,7 @@ PKCS#1 and SEC1 encryption.
<!-- YAML
added: v11.6.0
-->
+
* {number}
For secret keys, this property represents the size of the key in bytes. This
@@ -1250,6 +1286,7 @@ property is `undefined` for asymmetric keys.
<!-- YAML
added: v11.6.0
-->
+
* {string}
Depending on the type of this `KeyObject`, this property is either
@@ -1331,6 +1368,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/11705
description: Support for RSASSA-PSS and additional options was added.
-->
+
* `privateKey` {Object | string | Buffer | KeyObject}
- `padding` {integer}
- `saltLength` {integer}
@@ -1372,6 +1410,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `inputEncoding` changed from `binary` to `utf8`.
-->
+
* `data` {string | Buffer | TypedArray | DataView}
* `inputEncoding` {string} The [encoding][] of the `data` string.
@@ -1411,6 +1450,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/5522
description: The default `inputEncoding` changed from `binary` to `utf8`.
-->
+
* `data` {string | Buffer | TypedArray | DataView}
* `inputEncoding` {string} The [encoding][] of the `data` string.
@@ -1436,6 +1476,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/11705
description: Support for RSASSA-PSS and additional options was added.
-->
+
* `object` {Object | string | Buffer | KeyObject}
- `padding` {integer}
- `saltLength` {integer}
@@ -1483,6 +1524,7 @@ be passed instead of a public key.
<!-- YAML
added: v6.3.0
-->
+
* Returns: {Object} An object containing commonly used constants for crypto and
security related operations. The specific constants currently defined are
described in [Crypto Constants][].
@@ -1598,6 +1640,7 @@ changes:
description: The `iv` parameter may now be `null` for ciphers which do not
need an initialization vector.
-->
+
* `algorithm` {string}
* `key` {string | Buffer | TypedArray | DataView | KeyObject}
* `iv` {string | Buffer | TypedArray | DataView}
@@ -1691,6 +1734,7 @@ changes:
description: The `iv` parameter may now be `null` for ciphers which do not
need an initialization vector.
-->
+
* `algorithm` {string}
* `key` {string | Buffer | TypedArray | DataView}
* `iv` {string | Buffer | TypedArray | DataView}
@@ -1740,6 +1784,7 @@ changes:
description: The default for the encoding parameters changed
from `binary` to `utf8`.
-->
+
* `prime` {string | Buffer | TypedArray | DataView}
* `primeEncoding` {string} The [encoding][] of the `prime` string.
* `generator` {number | string | Buffer | TypedArray | DataView} **Default:**
@@ -1763,6 +1808,7 @@ otherwise a number, [`Buffer`][], `TypedArray`, or `DataView` is expected.
<!-- YAML
added: v0.5.0
-->
+
* `primeLength` {number}
* `generator` {number | string | Buffer | TypedArray | DataView} **Default:**
`2`
@@ -1786,6 +1832,7 @@ An alias for [`crypto.getDiffieHellman()`][]
<!-- YAML
added: v0.11.14
-->
+
* `curveName` {string}
* Returns: {ECDH}
@@ -1803,6 +1850,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/28805
description: The `outputLength` option was added for XOF hash functions.
-->
+
* `algorithm` {string}
* `options` {Object} [`stream.transform` options][]
* Returns: {Hash}
@@ -1848,6 +1896,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/24234
description: The `key` argument can now be a `KeyObject`.
-->
+
* `algorithm` {string}
* `key` {string | Buffer | TypedArray | DataView | KeyObject}
* `options` {Object} [`stream.transform` options][]
@@ -1891,6 +1940,7 @@ input.on('readable', () => {
<!-- YAML
added: v11.6.0
-->
+
* `key` {Object | string | Buffer}
- `key`: {string | Buffer} The key material, either in PEM or DER format.
- `format`: {string} Must be `'pem'` or `'der'`. **Default:** `'pem'`.
@@ -1918,6 +1968,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/25217
description: The `key` argument can now be a private key.
-->
+
* `key` {Object | string | Buffer | KeyObject}
- `key`: {string | Buffer}
- `format`: {string} Must be `'pem'` or `'der'`. **Default:** `'pem'`.
@@ -1944,6 +1995,7 @@ and it will be impossible to extract the private key from the returned object.
<!-- YAML
added: v11.6.0
-->
+
* `key` {Buffer}
* Returns: {KeyObject}
@@ -1954,6 +2006,7 @@ encryption or `Hmac`.
<!-- YAML
added: v0.1.92
-->
+
* `algorithm` {string}
* `options` {Object} [`stream.Writable` options][]
* Returns: {Sign}
@@ -1972,6 +2025,7 @@ algorithm names.
<!-- YAML
added: v0.1.92
-->
+
* `algorithm` {string}
* `options` {Object} [`stream.Writable` options][]
* Returns: {Verify}
@@ -2002,6 +2056,7 @@ changes:
description: The `generateKeyPair` and `generateKeyPairSync` functions now
produce key objects if no encoding was specified.
-->
+
* `type`: {string} Must be `'rsa'`, `'dsa'`, `'ec'`, `'ed25519'`, `'ed448'`,
`'x25519'`, or `'x448'`.
* `options`: {Object}
@@ -2063,6 +2118,7 @@ changes:
description: The `generateKeyPair` and `generateKeyPairSync` functions now
produce key objects if no encoding was specified.
-->
+
* `type`: {string} Must be `'rsa'`, `'dsa'`, `'ec'`, `'ed25519'`, or `'ed448'`.
* `options`: {Object}
- `modulusLength`: {number} Key size in bits (RSA, DSA).
@@ -2111,6 +2167,7 @@ it will be a buffer containing the data encoded as DER.
<!-- YAML
added: v0.9.3
-->
+
* Returns: {string[]} An array with the names of the supported cipher
algorithms.
@@ -2123,6 +2180,7 @@ console.log(ciphers); // ['aes-128-cbc', 'aes-128-ccm', ...]
<!-- YAML
added: v2.3.0
-->
+
* Returns: {string[]} An array with the names of the supported elliptic curves.
```js
@@ -2134,6 +2192,7 @@ console.log(curves); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]
<!-- YAML
added: v0.7.5
-->
+
* `groupName` {string}
* Returns: {DiffieHellman}
@@ -2169,6 +2228,7 @@ console.log(aliceSecret === bobSecret);
<!-- YAML
added: v10.0.0
-->
+
* Returns: {boolean} `true` if and only if a FIPS compliant crypto provider is
currently in use.
@@ -2176,6 +2236,7 @@ added: v10.0.0
<!-- YAML
added: v0.9.3
-->
+
* Returns: {string[]} An array of the names of the supported hash algorithms,
such as `'RSA-SHA256'`. Hash algorithms are also called "digest" algorithms.
@@ -2200,6 +2261,7 @@ changes:
description: The default encoding for `password` if it is a string changed
from `binary` to `utf8`.
-->
+
* `password` {string|Buffer|TypedArray|DataView}
* `salt` {string|Buffer|TypedArray|DataView}
* `iterations` {number}
@@ -2271,6 +2333,7 @@ changes:
description: The default encoding for `password` if it is a string changed
from `binary` to `utf8`.
-->
+
* `password` {string|Buffer|TypedArray|DataView}
* `salt` {string|Buffer|TypedArray|DataView}
* `iterations` {number}
@@ -2327,6 +2390,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/24234
description: This function now supports key objects.
-->
+
* `privateKey` {Object | string | Buffer | KeyObject}
- `oaepHash` {string} The hash function to use for OAEP padding.
**Default:** `'sha1'`
@@ -2353,6 +2417,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/24234
description: This function now supports key objects.
-->
+
* `privateKey` {Object | string | Buffer | KeyObject}
- `key` {string | Buffer | KeyObject} A PEM encoded private key.
- `passphrase` {string | Buffer} An optional passphrase for the private key.
@@ -2378,6 +2443,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/24234
description: This function now supports key objects.
-->
+
* `key` {Object | string | Buffer | KeyObject}
- `passphrase` {string | Buffer} An optional passphrase for the private key.
- `padding` {crypto.constants} An optional padding value defined in
@@ -2408,6 +2474,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/24234
description: This function now supports key objects.
-->
+
* `key` {Object | string | Buffer | KeyObject}
- `key` {string | Buffer | KeyObject} A PEM encoded public or private key.
- `oaepHash` {string} The hash function to use for OAEP padding.
@@ -2441,6 +2508,7 @@ changes:
description: Passing `null` as the `callback` argument now throws
`ERR_INVALID_CALLBACK`.
-->
+
* `size` {number}
* `callback` {Function}
- `err` {Error}
@@ -2623,6 +2691,7 @@ changes:
description: The `cost`, `blockSize` and `parallelization` option names
have been added.
-->
+
* `password` {string|Buffer|TypedArray|DataView}
* `salt` {string|Buffer|TypedArray|DataView}
* `keylen` {number}
@@ -2680,6 +2749,7 @@ changes:
description: The `cost`, `blockSize` and `parallelization` option names
have been added.
-->
+
* `password` {string|Buffer|TypedArray|DataView}
* `salt` {string|Buffer|TypedArray|DataView}
* `keylen` {number}
@@ -2722,6 +2792,7 @@ console.log(key2.toString('hex')); // '3745e48...aa39b34'
<!-- YAML
added: v0.11.11
-->
+
* `engine` {string}
* `flags` {crypto.constants} **Default:** `crypto.constants.ENGINE_METHOD_ALL`
@@ -2755,6 +2826,7 @@ The flags below are deprecated in OpenSSL-1.1.0.
<!-- YAML
added: v10.0.0
-->
+
* `bool` {boolean} `true` to enable FIPS mode.
Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
@@ -2764,6 +2836,7 @@ Throws an error if FIPS mode is not available.
<!-- YAML
added: v12.0.0
-->
+
* `algorithm` {string | null | undefined}
* `data` {Buffer | TypedArray | DataView}
* `key` {Object | string | Buffer | KeyObject}
@@ -2793,6 +2866,7 @@ additional properties can be passed:
<!-- YAML
added: v6.6.0
-->
+
* `a` {Buffer | TypedArray | DataView}
* `b` {Buffer | TypedArray | DataView}
* Returns: {boolean}
@@ -2814,6 +2888,7 @@ not introduce timing vulnerabilities.
<!-- YAML
added: v12.0.0
-->
+
* `algorithm` {string | null | undefined}
* `data` {Buffer | TypedArray | DataView}
* `key` {Object | string | Buffer | KeyObject}