public void Disconnect(string msg) { if (_closed) { return; } SSH1DataWriter w = new SSH1DataWriter(); w.Write(msg); SSH1Packet p = SSH1Packet.FromPlainPayload(PacketType.SSH_MSG_DISCONNECT, w.ToByteArray()); p.WriteTo(_stream, _tCipher); _stream.Flush(); _closed = true; _stream.Close(); }
public void WriteTo(AbstractSocket strm, Cipher cipher) { int bodylen = 4 + _packetLength; byte[] buf = new byte[bodylen + (_mac == null? 0 : _mac.Length)]; WriteTo(buf, 0, false); if (cipher != null) { cipher.Encrypt(buf, 0, bodylen, buf, 0); } if (_mac != null) { Array.Copy(_mac, 0, buf, bodylen, _mac.Length); } strm.Write(buf, 0, buf.Length); strm.Flush(); }
public void WriteTo(AbstractSocket strm, Cipher cipher) { int bodylen = 4+_packetLength; byte[] buf = new byte[bodylen + (_mac==null? 0 : _mac.Length)]; WriteTo(buf, 0, false); if(cipher!=null) cipher.Encrypt(buf, 0, bodylen, buf, 0); if(_mac!=null) Array.Copy(_mac, 0, buf, bodylen, _mac.Length); strm.Write(buf, 0, buf.Length); strm.Flush(); }