/** * writes to encrypted stream */ public void WriteTo(AbstractSocket output, Cipher cipher) { byte[] image = BuildImage(); //dumpBA(image); byte[] encrypted = new byte[image.Length - 4]; cipher.Encrypt(image, 4, image.Length - 4, encrypted, 0); //length field must not be encrypted Array.Copy(encrypted, 0, image, 4, encrypted.Length); output.Write(image, 0, image.Length); }
private static void SendMyVersion(AbstractSocket stream, SSHConnectionParameter param) { string cv = SSHUtil.ClientVersionString(param.Protocol); if (param.Protocol == SSHProtocol.SSH1) { cv += param.SSH1VersionEOL; } else { cv += "\r\n"; } byte[] data = Encoding.UTF8.GetBytes(cv); stream.Write(data, 0, data.Length); }
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(); }
/** * writes to plain stream */ public void WriteTo(AbstractSocket output) { byte[] image = BuildImage(); output.Write(image, 0, image.Length); }
private static void SendMyVersion(AbstractSocket stream, SSHConnectionParameter param) { string cv = SSHUtil.ClientVersionString(param.Protocol); if (param.Protocol == SSHProtocol.SSH1) cv += param.SSH1VersionEOL; else cv += "\r\n"; byte[] data = Encoding.UTF8.GetBytes(cv); stream.Write(data, 0, data.Length); }
/** * writes to encrypted stream */ public void WriteTo(AbstractSocket output, Cipher cipher) { byte[] image = BuildImage(); //dumpBA(image); byte[] encrypted = new byte[image.Length-4]; cipher.Encrypt(image, 4, image.Length-4, encrypted, 0); //length field must not be encrypted Array.Copy(encrypted, 0, image, 4, encrypted.Length); output.Write(image, 0, image.Length); }