/**
         * 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);
        }
Example #2
0
        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);
        }
Example #3
0
        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();
        }
Example #4
0
        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);
 }
Example #6
0
 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);
 }
Example #7
0
        /**
        * 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);
        }
Example #8
0
 /**
 * writes to plain stream
 */
 public void WriteTo(AbstractSocket output)
 {
     byte[] image = BuildImage();
     output.Write(image, 0, image.Length);
 }