From 2b12b37fc8bf9eca5128536e0b50c7a89d7ceb20 Mon Sep 17 00:00:00 2001 From: Ojasvi Monga Date: Sun, 7 Jul 2019 16:33:18 +0900 Subject: [PATCH 1/8] doc: add documentation for createDiffieHellmanGroup --- doc/api/crypto.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 93098a6f3edc2b..925a7a3df1b69a 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1733,6 +1733,13 @@ 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() + + +An alias for [`crypto.getDiffieHellman()`][] + ### crypto.createECDH(curveName) + +Usage: + +```js +const name = 'modp1'; +const dh = crypto.createDiffieHellmanGroup(name); +``` +It takes a well-known modp group as its argument but + otherwise works the same as `DiffieHellman`. + +`name` is taken from [RFC 2412][] (modp1 and 2) and [RFC 3526][]: +```bash +$ 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. +modp16 +modp17 +modp18 +``` + ### diffieHellman.computeSecret(otherPublicKey[, inputEncoding][, outputEncoding]) An alias for [`crypto.getDiffieHellman()`][] From f9b1600cda30df9d8aae17aa713d61258ddf50cc Mon Sep 17 00:00:00 2001 From: x Date: Tue, 9 Jul 2019 14:24:11 +0900 Subject: [PATCH 3/8] Apply suggestions from code review Co-Authored-By: Vse Mozhet Byt --- doc/api/crypto.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 6e8907bd394dde..06efec6d39cb8b 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1760,7 +1760,7 @@ 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() +### crypto.createDiffieHellmanGroup(groupName) @@ -3260,7 +3260,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 +[`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 From 23ee1b893228c0da48d617350cb5e760b18725ae Mon Sep 17 00:00:00 2001 From: Ojasvi Monga Date: Tue, 9 Jul 2019 22:35:31 +0900 Subject: [PATCH 4/8] move section to correct place --- doc/api/crypto.md | 54 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 06efec6d39cb8b..e2ff9687eb5d70 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -581,33 +581,6 @@ const bobSecret = bob.computeSecret(aliceKey); assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex')); ``` -## Class: DiffieHellmanGroup - - -Usage: - -```js -const name = 'modp1'; -const dh = crypto.createDiffieHellmanGroup(name); -``` -It takes a well-known modp group as its argument but - otherwise works the same as `DiffieHellman`. - -`name` is taken from [RFC 2412][] (modp1 and 2) and [RFC 3526][]: -```bash -$ 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. -modp16 -modp17 -modp18 -``` - ### diffieHellman.computeSecret(otherPublicKey[, inputEncoding][, outputEncoding]) + +Usage: + +```js +const name = 'modp1'; +const dh = crypto.createDiffieHellmanGroup(name); +``` +It takes a well-known modp group as its argument but + otherwise works the same as `DiffieHellman`. + +`name` is taken from [RFC 2412][] (modp1 and 2) and [RFC 3526][]: +```bash +$ 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. +modp16 +modp17 +modp18 +``` + ## Class: ECDH +* name {string} + An alias for [`crypto.getDiffieHellman()`][] ### crypto.createECDH(curveName) From a04b890557281bace752dd02227e7df37c41912c Mon Sep 17 00:00:00 2001 From: x Date: Thu, 11 Jul 2019 00:10:14 +0900 Subject: [PATCH 6/8] Apply suggestions from code review Co-Authored-By: Vse Mozhet Byt --- doc/api/crypto.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index d8521848bdbe3d..b5450c12e2187d 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1765,7 +1765,8 @@ If `generator` is not specified, the value `2` is used. added: v0.9.3 --> -* name {string} +* `name` {string} +* Returns: {DiffieHellman} An alias for [`crypto.getDiffieHellman()`][] From d2a0636b44f75ceacd05663dea284406e3d1e772 Mon Sep 17 00:00:00 2001 From: Ojasvi Monga Date: Fri, 12 Jul 2019 17:24:06 +0900 Subject: [PATCH 7/8] move text above code --- doc/api/crypto.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index b5450c12e2187d..c19973faf37d9f 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -703,14 +703,13 @@ module): added: v0.7.5 --> -Usage: +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); ``` -It takes a well-known modp group as its argument but - otherwise works the same as `DiffieHellman`. `name` is taken from [RFC 2412][] (modp1 and 2) and [RFC 3526][]: ```bash From e9fb832d407736144811124a2945ac9569938256 Mon Sep 17 00:00:00 2001 From: x Date: Mon, 15 Jul 2019 15:03:35 +0900 Subject: [PATCH 8/8] Update doc/api/crypto.md Co-Authored-By: Rich Trott --- doc/api/crypto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index c19973faf37d9f..0b86f2b0d63cf1 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -712,7 +712,7 @@ const dh = crypto.createDiffieHellmanGroup(name); ``` `name` is taken from [RFC 2412][] (modp1 and 2) and [RFC 3526][]: -```bash +```console $ perl -ne 'print "$1\n" if /"(modp\d+)"/' src/node_crypto_groups.h modp1 # 768 bits modp2 # 1024 bits