sendKeyExchangeInit method

void sendKeyExchangeInit(
  1. bool guess
)

Key exchange begins by each side sending SSH_MSG_KEXINIT.

Implementation

void sendKeyExchangeInit(bool guess) {
  String keyPref = Key.preferenceCsv(),
      kexPref = KEX.preferenceCsv(),
      cipherPref = Cipher.preferenceCsv(),
      macPref = MAC.preferenceCsv(),
      compressPref = Compression.preferenceCsv(compress ? 0 : 1);
  sequenceNumberC2s++;
  Uint8List kexInit = MSG_KEXINIT(
          randBytes(random, 16),
          kexPref,
          keyPref,
          cipherPref,
          cipherPref,
          macPref,
          macPref,
          compressPref,
          compressPref,
          '',
          '',
          guess)
      .toBytes(null, random, 8);
  if (client) {
    kexInitC = kexInit;
  } else {
    kexInitS = kexInit;
  }
  socket.sendRaw(kexInit);
  if (debugPrint != null) {
    debugPrint(
        '$hostport wrote KEXINIT { kex=$kexPref key=$keyPref, cipher=$cipherPref, mac=$macPref, compress=$compressPref }');
  }
}