Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update crypto.md #28585

Closed
wants to merge 8 commits into from
Closed
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,32 @@ module):
* `DH_UNABLE_TO_CHECK_GENERATOR`
* `DH_NOT_SUITABLE_GENERATOR`

## Class: DiffieHellmanGroup
<!-- YAML
added: v0.7.5
-->

The `DiffieHellmanGroup` class takes a well-known modp group as its argument but
otherwise works the same as `DiffieHellman`.

```js
const name = 'modp1';
const dh = crypto.createDiffieHellmanGroup(name);
```

`name` is taken from [RFC 2412][] (modp1 and 2) and [RFC 3526][]:
```bash
joe9111 marked this conversation as resolved.
Show resolved Hide resolved
$ perl -ne 'print "$1\n" if /"(modp\d+)"/' src/node_crypto_groups.h
modp1 # 768 bits
modp2 # 1024 bits
modp5 # 1536 bits
modp14 # 2048 bits
modp15 # etc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would have been nice to fill this out completely but I guess anyone who needs this functionality already knows what modp group they should be using.

modp16
modp17
modp18
```

## Class: ECDH
<!-- YAML
added: v0.11.14
Expand Down Expand Up @@ -1733,6 +1759,16 @@ Creates a `DiffieHellman` key exchange object and generates a prime of
`primeLength` bits using an optional specific numeric `generator`.
If `generator` is not specified, the value `2` is used.

### crypto.createDiffieHellmanGroup(name)
<!-- YAML
added: v0.9.3
-->

* `name` {string}
* Returns: {DiffieHellman}

joe9111 marked this conversation as resolved.
Show resolved Hide resolved
An alias for [`crypto.getDiffieHellman()`][]

### crypto.createECDH(curveName)
<!-- YAML
added: v0.11.14
Expand Down Expand Up @@ -3226,6 +3262,7 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL.
[`crypto.createSign()`]: #crypto_crypto_createsign_algorithm_options
[`crypto.createVerify()`]: #crypto_crypto_createverify_algorithm_options
[`crypto.getCurves()`]: #crypto_crypto_getcurves
[`crypto.getDiffieHellman()`]: #crypto_crypto_getdiffiehellman_groupname
[`crypto.getHashes()`]: #crypto_crypto_gethashes
[`crypto.privateDecrypt()`]: #crypto_crypto_privatedecrypt_privatekey_buffer
[`crypto.privateEncrypt()`]: #crypto_crypto_privateencrypt_privatekey_buffer
Expand Down