Skip to content

Commit 64e4948

Browse files
Merge pull request #1 from waylayio/fix/remove-BAD_DHGEX-compatibility-flag
fix: remove BAD_DHGEX compatibility flag
2 parents f96c43e + db89f42 commit 64e4948

File tree

4 files changed

+10
-58
lines changed

4 files changed

+10
-58
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
.eslintcache
3+
package-lock.json
4+
lib/protocol/crypto/**

lib/protocol/constants.js

-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ const SUPPORTED_COMPRESSION = DEFAULT_COMPRESSION.concat([
155155

156156

157157
const COMPAT = {
158-
BAD_DHGEX: 1 << 0,
159158
OLD_EXIT: 1 << 1,
160159
DYN_RPORT_BUG: 1 << 2,
161160
BUG_DHGEX_LARGE: 1 << 3,
@@ -328,7 +327,6 @@ module.exports = {
328327

329328
COMPAT,
330329
COMPAT_CHECKS: [
331-
[ 'Cisco-1.25', COMPAT.BAD_DHGEX ],
332330
[ /^Cisco-1[.]/, COMPAT.BUG_DHGEX_LARGE ],
333331
[ /^[0-9.]+$/, COMPAT.OLD_EXIT ], // old SSH.com implementations
334332
[ /^OpenSSH_5[.][0-9]+/, COMPAT.DYN_RPORT_BUG ],

lib/protocol/kex.js

+3-53
Original file line numberDiff line numberDiff line change
@@ -73,45 +73,8 @@ function kexinit(self) {
7373
uint32 0 (reserved for future extension)
7474
*/
7575

76-
let payload;
77-
if (self._compatFlags & COMPAT.BAD_DHGEX) {
78-
const entry = self._offer.lists.kex;
79-
let kex = entry.array;
80-
let found = false;
81-
for (let i = 0; i < kex.length; ++i) {
82-
if (kex[i].includes('group-exchange')) {
83-
if (!found) {
84-
found = true;
85-
// Copy array lazily
86-
kex = kex.slice();
87-
}
88-
kex.splice(i--, 1);
89-
}
90-
}
91-
if (found) {
92-
let len = 1 + 16 + self._offer.totalSize + 1 + 4;
93-
const newKexBuf = Buffer.from(kex.join(','));
94-
len -= (entry.buffer.length - newKexBuf.length);
95-
96-
const all = self._offer.lists.all;
97-
const rest = new Uint8Array(
98-
all.buffer,
99-
all.byteOffset + 4 + entry.buffer.length,
100-
all.length - (4 + entry.buffer.length)
101-
);
102-
103-
payload = Buffer.allocUnsafe(len);
104-
writeUInt32BE(payload, newKexBuf.length, 17);
105-
payload.set(newKexBuf, 17 + 4);
106-
payload.set(rest, 17 + 4 + newKexBuf.length);
107-
}
108-
}
109-
110-
if (payload === undefined) {
111-
payload = Buffer.allocUnsafe(1 + 16 + self._offer.totalSize + 1 + 4);
112-
self._offer.copyAllTo(payload, 17);
113-
}
114-
76+
const payload = Buffer.allocUnsafe(1 + 16 + self._offer.totalSize + 1 + 4);
77+
self._offer.copyAllTo(payload, 17);
11578
self._debug && self._debug('Outbound: Sending KEXINIT');
11679

11780
payload[0] = MESSAGE.KEXINIT;
@@ -197,20 +160,7 @@ function handleKexInit(self, payload) {
197160
const local = self._offer;
198161
const remote = init;
199162

200-
let localKex = local.lists.kex.array;
201-
if (self._compatFlags & COMPAT.BAD_DHGEX) {
202-
let found = false;
203-
for (let i = 0; i < localKex.length; ++i) {
204-
if (localKex[i].indexOf('group-exchange') !== -1) {
205-
if (!found) {
206-
found = true;
207-
// Copy array lazily
208-
localKex = localKex.slice();
209-
}
210-
localKex.splice(i--, 1);
211-
}
212-
}
213-
}
163+
const localKex = local.lists.kex.array;
214164

215165
let clientList;
216166
let serverList;

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "ssh2",
2+
"name": "@waylay/ssh2",
33
"version": "1.15.0",
44
"author": "Brian White <[email protected]>",
55
"description": "SSH2 client and server modules written in pure JavaScript for node.js",
@@ -39,11 +39,11 @@
3939
"licenses": [
4040
{
4141
"type": "MIT",
42-
"url": "http://github.com/mscdex/ssh2/raw/master/LICENSE"
42+
"url": "http://github.com/@waylay/ssh2/raw/master/LICENSE"
4343
}
4444
],
4545
"repository": {
4646
"type": "git",
47-
"url": "http://github.com/mscdex/ssh2.git"
47+
"url": "http://github.com/@waylay/ssh2.git"
4848
}
4949
}

0 commit comments

Comments
 (0)