Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2020-09-27 05:20:03 +0300
committerJames M Snell <jasnell@gmail.com>2020-10-13 19:30:53 +0300
commit095be6a01f57d5b730a01f131bab4968d3b3b0ba (patch)
tree3bd7569dffc677b1cf64a501c0edfdecc4e5b211 /doc/api/crypto.md
parentadf8f3d1fee3850b2eaa227a74e45a6a27af61ac (diff)
crypto: add getCipherInfo method
Simple method for retrieving basic information about a cipher (such as block length, expected or default iv length, key length, etc) Signed-off-by: James M Snell <jasnell@gmail.com> Fixes: https://github.com/nodejs/node/issues/22304 PR-URL: https://github.com/nodejs/node/pull/35368 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'doc/api/crypto.md')
-rw-r--r--doc/api/crypto.md29
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/api/crypto.md b/doc/api/crypto.md
index 32e90ca030b..2e1744910b9 100644
--- a/doc/api/crypto.md
+++ b/doc/api/crypto.md
@@ -2424,6 +2424,35 @@ const ciphers = crypto.getCiphers();
console.log(ciphers); // ['aes-128-cbc', 'aes-128-ccm', ...]
```
+### `crypto.getCipherInfo(nameOrNid[, options])`
+<!-- YAML
+added: REPLACEME
+-->
+
+* `nameOrNid`: {string|number} The name or nid of the cipher to query.
+* `options`: {Object}
+ * `keyLength`: {number} A test key length.
+ * `ivLength`: {number} A test IV length.
+* Returns: {Object}
+ * `name` {string} The name of the cipher
+ * `nid` {number} The nid of the cipher
+ * `blockSize` {number} The block size of the cipher in bytes. This property
+ is omitted when `mode` is `'stream'`.
+ * `ivLength` {number} The expected or default initialization vector length in
+ bytes. This property is omitted if the cipher does not use an initialization
+ vector.
+ * `keyLength` {number} The expected or default key length in bytes.
+ * `mode` {string} The cipher mode. One of `'cbc'`, `'ccm'`, `'cfb'`, `'ctr'`,
+ `'ecb'`, `'gcm'`, `'ocb'`, `'ofb'`, `'stream'`, `'wrap'`, `'xts'`.
+
+Returns information about a given cipher.
+
+Some ciphers accept variable length keys and initialization vectors. By default,
+the `crypto.getCipherInfo()` method will return the default values for these
+ciphers. To test if a given key length or iv length is acceptable for given
+cipher, use the `keyLenth` and `ivLenth` options. If the given values are
+unacceptable, `undefined` will be returned.
+
### `crypto.getCurves()`
<!-- YAML
added: v2.3.0