forked from mscdex/ssh2-streams
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib,test: update code for modern node versions
* Replace `new Buffer()` * Replace Buffer read and write integer methods with custom functions because offset and value assertions will be forced in a future major version of node
- Loading branch information
Showing
14 changed files
with
905 additions
and
800 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
readUInt32BE: function readUInt32BE(buf, offset) { | ||
return buf[offset++] * 16777216 | ||
+ buf[offset++] * 65536 | ||
+ buf[offset++] * 256 | ||
+ buf[offset]; | ||
}, | ||
writeUInt32BE: function writeUInt32BE(buf, value, offset) { | ||
buf[offset++] = (value >>> 24); | ||
buf[offset++] = (value >>> 16); | ||
buf[offset++] = (value >>> 8); | ||
buf[offset++] = value; | ||
return offset; | ||
}, | ||
writeUInt32LE: function writeUInt32LE(buf, value, offset) { | ||
buf[offset++] = value; | ||
buf[offset++] = (value >>> 8); | ||
buf[offset++] = (value >>> 16); | ||
buf[offset++] = (value >>> 24); | ||
return offset; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,29 +191,23 @@ exports.SIGNALS = ['ABRT', 'ALRM', 'FPE', 'HUP', 'ILL', 'INT', | |
'PIPE']; | ||
|
||
var DEFAULT_KEX = [ | ||
// https://tools.ietf.org/html/rfc5656#section-10.1 | ||
'ecdh-sha2-nistp256', | ||
'ecdh-sha2-nistp384', | ||
'ecdh-sha2-nistp521', | ||
|
||
// https://tools.ietf.org/html/rfc4419#section-4 | ||
'diffie-hellman-group-exchange-sha256', | ||
|
||
'diffie-hellman-group14-sha1' // REQUIRED | ||
]; | ||
var SUPPORTED_KEX = [ | ||
// https://tools.ietf.org/html/rfc4419#section-4 | ||
'diffie-hellman-group-exchange-sha1', | ||
|
||
'diffie-hellman-group1-sha1' // REQUIRED | ||
]; | ||
if (semver.gte(process.version, '0.11.12')) { | ||
// https://tools.ietf.org/html/rfc4419#section-4 | ||
DEFAULT_KEX = [ | ||
'diffie-hellman-group-exchange-sha256' | ||
].concat(DEFAULT_KEX); | ||
SUPPORTED_KEX = [ | ||
'diffie-hellman-group-exchange-sha1' | ||
].concat(SUPPORTED_KEX); | ||
} | ||
if (semver.gte(process.version, '0.11.14')) { | ||
// https://tools.ietf.org/html/rfc5656#section-10.1 | ||
DEFAULT_KEX = [ | ||
'ecdh-sha2-nistp256', | ||
'ecdh-sha2-nistp384', | ||
'ecdh-sha2-nistp521' | ||
].concat(DEFAULT_KEX); | ||
} | ||
var KEX_BUF = new Buffer(DEFAULT_KEX.join(','), 'ascii'); | ||
var KEX_BUF = Buffer.from(DEFAULT_KEX.join(','), 'ascii'); | ||
SUPPORTED_KEX = DEFAULT_KEX.concat(SUPPORTED_KEX); | ||
|
||
var DEFAULT_SERVER_HOST_KEY = [ | ||
|
@@ -232,13 +226,24 @@ if (semver.gte(process.version, '5.2.0')) { | |
'ecdsa-sha2-nistp521' | ||
); | ||
} | ||
var SERVER_HOST_KEY_BUF = new Buffer(DEFAULT_SERVER_HOST_KEY.join(','), | ||
'ascii'); | ||
var SERVER_HOST_KEY_BUF = Buffer.from(DEFAULT_SERVER_HOST_KEY.join(','), | ||
'ascii'); | ||
SUPPORTED_SERVER_HOST_KEY = DEFAULT_SERVER_HOST_KEY.concat( | ||
SUPPORTED_SERVER_HOST_KEY | ||
); | ||
|
||
var DEFAULT_CIPHER = []; | ||
var DEFAULT_CIPHER = [ | ||
// http://tools.ietf.org/html/rfc4344#section-4 | ||
'aes128-ctr', | ||
'aes192-ctr', | ||
'aes256-ctr', | ||
|
||
// http://tools.ietf.org/html/rfc5647 | ||
'aes128-gcm', | ||
'[email protected]', | ||
'aes256-gcm', | ||
'[email protected]' | ||
]; | ||
var SUPPORTED_CIPHER = [ | ||
'aes256-cbc', | ||
'aes192-cbc', | ||
|
@@ -253,24 +258,7 @@ var SUPPORTED_CIPHER = [ | |
'cast128-cbc', | ||
'arcfour' | ||
]; | ||
if (semver.gte(process.version, '0.11.12')) { | ||
// node v0.11.12 introduced support for setting AAD, which is needed for | ||
// AES-GCM in SSH2 | ||
DEFAULT_CIPHER = [ | ||
// http://tools.ietf.org/html/rfc5647 | ||
'aes128-gcm', | ||
'[email protected]', | ||
'aes256-gcm', | ||
'[email protected]' | ||
].concat(DEFAULT_CIPHER); | ||
} | ||
DEFAULT_CIPHER = [ | ||
// http://tools.ietf.org/html/rfc4344#section-4 | ||
'aes128-ctr', | ||
'aes192-ctr', | ||
'aes256-ctr' | ||
].concat(DEFAULT_CIPHER); | ||
var CIPHER_BUF = new Buffer(DEFAULT_CIPHER.join(','), 'ascii'); | ||
var CIPHER_BUF = Buffer.from(DEFAULT_CIPHER.join(','), 'ascii'); | ||
SUPPORTED_CIPHER = DEFAULT_CIPHER.concat(SUPPORTED_CIPHER); | ||
|
||
var DEFAULT_HMAC = [ | ||
|
@@ -286,7 +274,7 @@ var SUPPORTED_HMAC = [ | |
'hmac-sha1-96', // first 96 bits of HMAC-SHA1 | ||
'hmac-md5-96' // first 96 bits of HMAC-MD5 | ||
]; | ||
var HMAC_BUF = new Buffer(DEFAULT_HMAC.join(','), 'ascii'); | ||
var HMAC_BUF = Buffer.from(DEFAULT_HMAC.join(','), 'ascii'); | ||
SUPPORTED_HMAC = DEFAULT_HMAC.concat(SUPPORTED_HMAC); | ||
|
||
var DEFAULT_COMPRESS = [ | ||
|
@@ -297,7 +285,7 @@ var DEFAULT_COMPRESS = [ | |
'zlib' // ZLIB (LZ77) compression | ||
]; | ||
var SUPPORTED_COMPRESS = []; | ||
var COMPRESS_BUF = new Buffer(DEFAULT_COMPRESS.join(','), 'ascii'); | ||
var COMPRESS_BUF = Buffer.from(DEFAULT_COMPRESS.join(','), 'ascii'); | ||
SUPPORTED_COMPRESS = DEFAULT_COMPRESS.concat(SUPPORTED_COMPRESS); | ||
|
||
exports.ALGORITHMS = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.