Skip to content

Commit

Permalink
lib,readme: add new key exchange algos
Browse files Browse the repository at this point in the history
  • Loading branch information
mscdex committed Feb 24, 2020
1 parent 5156dcd commit b290c27
Show file tree
Hide file tree
Showing 3 changed files with 397 additions and 301 deletions.
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,21 +342,31 @@ SSH2Stream methods

* Default values:

1. ecdh-sha2-nistp256 **(node v0.11.14 or newer)**
2. ecdh-sha2-nistp384 **(node v0.11.14 or newer)**
3. ecdh-sha2-nistp521 **(node v0.11.14 or newer)**
4. diffie-hellman-group-exchange-sha256 **(node v0.11.12 or newer)**
5. diffie-hellman-group14-sha1
1. curve25519-sha256 **(node v13.9.0 or newer)**
2. curve25519-sha256@libssh.org **(node v13.9.0 or newer)**
3. ecdh-sha2-nistp256 **(node v0.11.14 or newer)**
4. ecdh-sha2-nistp384 **(node v0.11.14 or newer)**
5. ecdh-sha2-nistp521 **(node v0.11.14 or newer)**
6. diffie-hellman-group-exchange-sha256 **(node v0.11.12 or newer)**
7. diffie-hellman-group14-sha256
8. diffie-hellman-group16-sha512
9. diffie-hellman-group18-sha512
10. diffie-hellman-group14-sha1

* Supported values:

* curve25519-sha256 **(node v13.9.0 or newer)**
* curve25519-sha256@libssh.org **(node v13.9.0 or newer)**
* ecdh-sha2-nistp256 **(node v0.11.14 or newer)**
* ecdh-sha2-nistp384 **(node v0.11.14 or newer)**
* ecdh-sha2-nistp521 **(node v0.11.14 or newer)**
* diffie-hellman-group-exchange-sha256 **(node v0.11.12 or newer)**
* diffie-hellman-group14-sha1
* diffie-hellman-group-exchange-sha1 **(node v0.11.12 or newer)**
* diffie-hellman-group-exchange-sha256 **(node v0.11.12 or newer)**
* diffie-hellman-group1-sha1
* diffie-hellman-group14-sha1
* diffie-hellman-group14-sha256
* diffie-hellman-group16-sha512
* diffie-hellman-group18-sha512

* **cipher** - _array_ - Ciphers.

Expand Down
17 changes: 15 additions & 2 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ var i;
var keys;
var len;

var crypto = require('crypto');
var eddsaSupported = (function() {
var crypto = require('crypto');
if (typeof crypto.sign === 'function'
&& typeof crypto.verify === 'function') {
var key = '-----BEGIN PRIVATE KEY-----\r\nMC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD'
Expand All @@ -21,6 +21,10 @@ var eddsaSupported = (function() {
return false;
})();

var curve25519Supported = (typeof crypto.diffieHellman === 'function'
&& typeof crypto.generateKeyPairSync === 'function'
&& typeof crypto.createPublicKey === 'function');

var MESSAGE = exports.MESSAGE = {
// Transport layer protocol -- generic (1-19)
DISCONNECT: 1,
Expand Down Expand Up @@ -216,8 +220,16 @@ var DEFAULT_KEX = [
// https://tools.ietf.org/html/rfc4419#section-4
'diffie-hellman-group-exchange-sha256',

'diffie-hellman-group14-sha1' // REQUIRED
'diffie-hellman-group14-sha256',
'diffie-hellman-group16-sha512',
'diffie-hellman-group18-sha512',

'diffie-hellman-group14-sha1', // REQUIRED
];
if (curve25519Supported) {
DEFAULT_KEX.unshift('curve25519-sha256');
DEFAULT_KEX.unshift('curve25519-sha256@libssh.org');
}
var SUPPORTED_KEX = [
// https://tools.ietf.org/html/rfc4419#section-4
'diffie-hellman-group-exchange-sha1',
Expand Down Expand Up @@ -458,3 +470,4 @@ exports.BUGGY_IMPLS = [
];

exports.EDDSA_SUPPORTED = eddsaSupported;
exports.CURVE25519_SUPPORTED = curve25519Supported;
Loading

0 comments on commit b290c27

Please sign in to comment.