Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
crypto: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
thinred committed Jun 18, 2015
1 parent 14ca27e commit 66d5133
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions doc/api/crypto.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -502,21 +502,29 @@ expected.
## crypto.getDiffieHellman(group_name)

Creates a predefined Diffie-Hellman key exchange object. The
supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in [RFC
2412][]) and `'modp14'`, `'modp15'`, `'modp16'`, `'modp17'`,
`'modp18'` (defined in [RFC 3526][]). The returned object mimics the
interface of objects created by [crypto.createDiffieHellman()][]
above, but will not allow to change the keys (with
[diffieHellman.setPublicKey()][] for example). The advantage of using
this routine is that the parties don't have to generate nor exchange
group modulus beforehand, saving both processor and communication
time.
supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in
[RFC 2412][]) and `'modp14'`, `'modp15'`, `'modp16'`, `'modp17'`,
`'modp18'` (defined in [RFC 3526][]).

The returned object mimics the interface of objects created by
[crypto.createDiffieHellman()][] above, but will not allow to change
the keys (with [diffieHellman.setPublicKey()][] for example). The
advantage of using this routine is that the parties do not have to
generate nor exchange group modulus beforehand, saving both processor
and communication time.

The groups `'modp1'`, `'modp2'` and `'modp5'` (i.e., the groups with
size smaller than 2048 bits) are considered **deprecated** and should
not be used in new code. Moreover, the use of the `'modp1'` group must
be explicitly enabled: either via `'--enable-small-groups'` switch to
node, or by setting the `'ENABLE_SMALL_GROUPS'` environment variable
to a non-empty value.

Example (obtaining a shared secret):

var crypto = require('crypto');
var alice = crypto.getDiffieHellman('modp5');
var bob = crypto.getDiffieHellman('modp5');
var alice = crypto.getDiffieHellman('modp14');
var bob = crypto.getDiffieHellman('modp14');

alice.generateKeys();
bob.generateKeys();
Expand Down

0 comments on commit 66d5133

Please sign in to comment.