writeCipher method

void writeCipher(
  1. SSHMessage msg
)

Encrypt Binary Packet data using the negotiated block cipher and MAC.

Implementation

void writeCipher(SSHMessage msg) {
  sequenceNumberC2s++;
  Uint8List m = msg.toBytes(zwriter, random, encryptBlockSize);
  Uint8List encM = applyBlockCipher(encrypt, m);
  Uint8List mac = computeMAC(MAC.mac(macIdC2s), macHashLenC, m,
      sequenceNumberC2s - 1, integrityC2s, macPrefixC2s);
  socket.sendRaw(Uint8List.fromList(encM + mac));
  if (tracePrint != null) {
    tracePrint('$hostport: sent MSG id=${msg.id}');
  }
}