diff options
author | Tobias Nießen <tniessen@tnie.de> | 2020-01-03 14:01:34 +0300 |
---|---|---|
committer | Tobias Nießen <tniessen@tnie.de> | 2020-01-21 17:49:20 +0300 |
commit | b4f8537cdc6f894c5e90bb8bf29a90a2db1438ca (patch) | |
tree | 41c24bf11d787366304cb64239344bdc1c55230b /doc/api/crypto.md | |
parent | c6f8ea8d6578fd1f167bc943272eca5806224d2f (diff) |
crypto: add crypto.diffieHellman
Currently, Node.js has separate (stateful) APIs for DH/ECDH, and no
support for ECDH-ES. This commit adds a single stateless function to
compute the DH/ECDH/ECDH-ES secret based on two KeyObjects.
PR-URL: https://github.com/nodejs/node/pull/31178
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Diffstat (limited to 'doc/api/crypto.md')
-rw-r--r-- | doc/api/crypto.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 71b83a47db0..d924c8643cf 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -2089,6 +2089,20 @@ the corresponding digest algorithm. This does not work for all signature algorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest algorithm names. +### `crypto.diffieHellman(options)` +<!-- YAML +added: REPLACEME +--> + +* `options`: {Object} + * `privateKey`: {KeyObject} + * `publicKey`: {KeyObject} +* Returns: {Buffer} + +Computes the Diffie-Hellman secret based on a `privateKey` and a `publicKey`. +Both keys must have the same `asymmetricKeyType`, which must be one of `'dh'` +(for Diffie-Hellman), `'ec'` (for ECDH), `'x448'`, or `'x25519'` (for ECDH-ES). + ### `crypto.generateKeyPair(type, options, callback)` <!-- YAML added: v10.12.0 |