Skip to content

remove BAD_DHGEX compatibility flag #1243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/protocol/constants.js
Original file line number Diff line number Diff line change
@@ -155,7 +155,6 @@ const SUPPORTED_COMPRESSION = DEFAULT_COMPRESSION.concat([


const COMPAT = {
BAD_DHGEX: 1 << 0,
OLD_EXIT: 1 << 1,
DYN_RPORT_BUG: 1 << 2,
BUG_DHGEX_LARGE: 1 << 3,
@@ -326,7 +325,6 @@ module.exports = {

COMPAT,
COMPAT_CHECKS: [
[ 'Cisco-1.25', COMPAT.BAD_DHGEX ],
[ /^Cisco-1\./, COMPAT.BUG_DHGEX_LARGE ],
[ /^[0-9.]+$/, COMPAT.OLD_EXIT ], // old SSH.com implementations
[ /^OpenSSH_5\.\d+/, COMPAT.DYN_RPORT_BUG ],
53 changes: 2 additions & 51 deletions lib/protocol/kex.js
Original file line number Diff line number Diff line change
@@ -73,44 +73,8 @@ function kexinit(self) {
uint32 0 (reserved for future extension)
*/

let payload;
if (self._compatFlags & COMPAT.BAD_DHGEX) {
const entry = self._offer.lists.kex;
let kex = entry.array;
let found = false;
for (let i = 0; i < kex.length; ++i) {
if (kex[i].includes('group-exchange')) {
if (!found) {
found = true;
// Copy array lazily
kex = kex.slice();
}
kex.splice(i--, 1);
}
}
if (found) {
let len = 1 + 16 + self._offer.totalSize + 1 + 4;
const newKexBuf = Buffer.from(kex.join(','));
len -= (entry.buffer.length - newKexBuf.length);

const all = self._offer.lists.all;
const rest = new Uint8Array(
all.buffer,
all.byteOffset + 4 + entry.buffer.length,
all.length - (4 + entry.buffer.length)
);

payload = Buffer.allocUnsafe(len);
writeUInt32BE(payload, newKexBuf.length, 17);
payload.set(newKexBuf, 17 + 4);
payload.set(rest, 17 + 4 + newKexBuf.length);
}
}

if (payload === undefined) {
payload = Buffer.allocUnsafe(1 + 16 + self._offer.totalSize + 1 + 4);
self._offer.copyAllTo(payload, 17);
}
const payload = Buffer.allocUnsafe(1 + 16 + self._offer.totalSize + 1 + 4);
self._offer.copyAllTo(payload, 17);

self._debug && self._debug('Outbound: Sending KEXINIT');

@@ -198,19 +162,6 @@ function handleKexInit(self, payload) {
const remote = init;

let localKex = local.lists.kex.array;
if (self._compatFlags & COMPAT.BAD_DHGEX) {
let found = false;
for (let i = 0; i < localKex.length; ++i) {
if (localKex[i].indexOf('group-exchange') !== -1) {
if (!found) {
found = true;
// Copy array lazily
localKex = localKex.slice();
}
localKex.splice(i--, 1);
}
}
}

let clientList;
let serverList;