(self)
| 56 | |
| 57 | // Client/Server |
| 58 | function kexinit(self) { |
| 59 | /* |
| 60 | byte SSH_MSG_KEXINIT |
| 61 | byte[16] cookie (random bytes) |
| 62 | name-list kex_algorithms |
| 63 | name-list server_host_key_algorithms |
| 64 | name-list encryption_algorithms_client_to_server |
| 65 | name-list encryption_algorithms_server_to_client |
| 66 | name-list mac_algorithms_client_to_server |
| 67 | name-list mac_algorithms_server_to_client |
| 68 | name-list compression_algorithms_client_to_server |
| 69 | name-list compression_algorithms_server_to_client |
| 70 | name-list languages_client_to_server |
| 71 | name-list languages_server_to_client |
| 72 | boolean first_kex_packet_follows |
| 73 | uint32 0 (reserved for future extension) |
| 74 | */ |
| 75 | |
| 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 | |
| 115 | self._debug && self._debug('Outbound: Sending KEXINIT'); |
no test coverage detected
searching dependent graphs…