node/doc/api
Bill Automata e136c179c1 doc: update crypto docs to use good defaults
[Diffie-Hellman](https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange#Cryptographic_explanation)
keys are composed of a `generator` a `prime` a `secret_key`
and the `public_key` resulting from the math operation:

```
(generator ^ secret_key) mod prime = public_key
```

Diffie-Hellman keypairs will compute a matching shared secret
if and only if the generator and prime match for both
recipients.  The generator is usually **2** and the prime is
what is called a [Safe Prime](https://en.wikipedia.org/wiki/Safe_prime).

Usually this matching is accomplished by using
[standard published groups](http://tools.ietf.org/html/rfc3526).
We expose access those groups with the `crypto.getDiffieHellman`
function.

`createDiffieHellman` is trickier to use.  The original example
had the user creating 11 bit keys, and creating random groups of
generators and primes. 11 bit keys are very very small, can be
cracked by a single person on a single sheet of paper.  A
byproduct of using such small keys were that it was a high
likelihood that two calls of `createDiffieHellman(11)` would
result in using the same 11 bit safe prime.

The original example code would fail when the safe primes generated
at 11 bit lengths did not match for alice and bob.

If you want to use your own generated safe `prime` then the proper
use of `createDiffieHellman` is to pass the `prime` and `generator`
to the recipient's constructor, so that when they compute the shared
secret their `prime` and `generator` match, which is fundamental to
the algorithm.

PR-URL: https://github.com/nodejs/node/pull/5505
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-21 16:49:46 -07:00
..
_toc.markdown doc: add a cli options doc page 2016-03-21 17:33:42 -04:00
addons.markdown doc: fix typo in api/addons 2016-03-14 08:48:08 -07:00
all.markdown deps: update v8 to 4.4.63.9 2015-08-04 11:56:14 -07:00
assert.markdown doc: mention prototype check in deepStrictEqual() 2016-02-23 09:17:11 -05:00
buffer.markdown doc: fix return value of write methods 2016-03-16 12:40:19 -07:00
child_process.markdown doc: Add note about use of JSON.stringify() 2016-03-15 09:38:28 -07:00
cli.markdown doc: add a cli options doc page 2016-03-21 17:33:42 -04:00
cluster.markdown doc: add missing property in cluster example 2016-02-27 14:04:51 +01:00
console.markdown console: check that stderr is writable 2016-03-15 19:10:55 -07:00
crypto.markdown doc: update crypto docs to use good defaults 2016-03-21 16:49:46 -07:00
debugger.markdown doc: replace function expressions with arrows 2016-01-27 23:00:20 +01:00
dgram.markdown doc: fix typo in api/dgram 2016-03-14 08:48:03 -07:00
dns.markdown doc: fix dns.resolveCname description typo 2016-03-10 02:16:36 +01:00
documentation.markdown doc: add info to docs on how to submit docs patch 2016-03-07 11:25:15 -08:00
domain.markdown doc: fix type references for link gen, link css 2016-02-09 13:12:21 +01:00
errors.markdown doc: fix markdown links 2016-03-10 14:09:26 +01:00
events.markdown events: add eventNames() method 2016-03-15 09:25:35 -07:00
fs.markdown fs: add the fs.mkdtemp() function. 2016-03-20 11:49:02 +02:00
globals.markdown doc: proper markdown escaping -> \_\_, \*, \_ 2016-01-22 21:32:50 -08:00
http.markdown doc: fix markdown links 2016-03-10 14:09:26 +01:00
https.markdown doc: minor improvement to HTTPS doc 2016-02-01 09:14:42 -08:00
index.markdown Remove util.print from docs 2010-11-07 17:22:56 -08:00
modules.markdown doc: explain error message on missing main file 2016-03-21 14:59:13 -07:00
net.markdown net: emit host in lookup event 2016-03-18 11:04:02 -05:00
os.markdown doc: minor improvement in OS docs 2016-02-04 19:25:07 +01:00
path.markdown doc: Add windows example for Path.format 2016-03-21 09:11:56 -07:00
process.markdown doc: Add note about use of JSON.stringify() 2016-03-15 09:38:28 -07:00
punycode.markdown doc: fenced all code blocks, typo fixes 2016-01-21 20:55:09 +01:00
querystring.markdown doc: fix multiline return comments in querystring 2016-03-17 17:15:06 -03:00
readline.markdown doc: don't use "interface" as a variable name 2016-01-30 00:33:14 +01:00
repl.markdown repl: Assignment of _ allowed with warning 2016-03-18 21:03:40 +01:00
stream.markdown lib: reduce usage of `self = this` 2016-03-21 15:48:51 -07:00
string_decoder.markdown doc: fenced all code blocks, typo fixes 2016-01-21 20:55:09 +01:00
synopsis.markdown doc: harmonize $ node command line notation 2016-01-22 19:57:19 +01:00
timers.markdown doc: grammar, clarity and links in timers doc 2016-03-21 09:48:54 +02:00
tls.markdown doc: align doc/api/tls.markdown with style guide 2016-03-20 10:42:04 +02:00
tty.markdown doc: fenced all code blocks, typo fixes 2016-01-21 20:55:09 +01:00
url.markdown doc: fenced all code blocks, typo fixes 2016-01-21 20:55:09 +01:00
util.markdown doc: document deprecation of util._extend 2016-03-16 12:55:55 -07:00
v8.markdown doc: update V8 URL 2016-03-02 23:22:29 +01:00
vm.markdown vm: fix `produceCachedData` 2016-02-21 14:59:35 -05:00
zlib.markdown doc: clarify type of first argument in zlib 2016-03-15 12:09:38 -03:00