Example #1
0
        internal SSHServerInfo(SSHDataReader reader) {
            anti_spoofing_cookie = reader.Read(8); //first 8 bytes are cookie

            server_key_bits = reader.ReadInt32();
            server_key_public_exponent = reader.ReadMPInt();
            server_key_public_modulus = reader.ReadMPInt();
            host_key_bits = reader.ReadInt32();
            host_key_public_exponent = reader.ReadMPInt();
            host_key_public_modulus = reader.ReadMPInt();
        }
        /// <summary>
        /// Create new instance from SSH_FXP_STATUS packet data.
        /// </summary>
        /// <param name="dataReader">data reader</param>
        /// <returns>new instance</returns>
        internal static SFTPClientErrorException Create(SSHDataReader dataReader)
        {
            uint id = (uint)dataReader.ReadInt32();
            uint code = (uint)dataReader.ReadInt32();
            string message = dataReader.ReadUTF8String();
            string languageTag = dataReader.ReadString();

            return new SFTPClientErrorException(id, code, message, languageTag);
        }
Example #3
0
        private SFTPFileInfo ReadFileInfo(SSHDataReader dataReader, Encoding encoding)
        {
            byte[] fileNameData = dataReader.ReadByteString();
            string fileName = encoding.GetString(fileNameData);
            byte[] longNameData = dataReader.ReadByteString();
            string longName = encoding.GetString(longNameData);

            SFTPFileAttributes attributes = ReadFileAttributes(dataReader);

            return new SFTPFileInfo(fileName, longName, attributes);
        }
Example #4
0
        /// <summary>
        /// Create new instance from SSH_FXP_STATUS packet data.
        /// </summary>
        /// <param name="dataReader">data reader</param>
        /// <returns>new instance</returns>
        internal static SFTPClientErrorException Create(SSHDataReader dataReader)
        {
            uint id = (uint)dataReader.ReadInt32();
            uint code = (uint)dataReader.ReadInt32();
            byte[] messageData = dataReader.ReadString();
            string message = Encoding.UTF8.GetString(messageData);
            byte[] languageTagData = dataReader.ReadString();
            string languageTag = Encoding.ASCII.GetString(languageTagData);

            return new SFTPClientErrorException(id, code, message, languageTag);
        }
Example #5
0
        private SFTPFileAttributes ReadFileAttributes(SSHDataReader dataReader)
        {
            ulong fileSize = 0;
            uint uid = 0;
            uint gid = 0;
            uint permissions = 0666;
            uint atime = 0;
            uint mtime = 0;

            uint flags = (uint)dataReader.ReadInt32();

            if ((flags & SSH_FILEXFER_ATTR_SIZE) != 0) {
                fileSize = dataReader.ReadUInt64();
            }

            if ((flags & SSH_FILEXFER_ATTR_UIDGID) != 0) {
                uid = dataReader.ReadUInt32();
                gid = dataReader.ReadUInt32();
            }

            if ((flags & SSH_FILEXFER_ATTR_PERMISSIONS) != 0) {
                permissions = dataReader.ReadUInt32();
            }

            if ((flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0) {
                atime = dataReader.ReadUInt32();
                mtime = dataReader.ReadUInt32();
            }

            if ((flags & SSH_FILEXFER_ATTR_EXTENDED) != 0) {
                int count = dataReader.ReadInt32();
                for (int i = 0; i < count; i++) {
                    dataReader.ReadString();    // extended type
                    dataReader.ReadString();    // extended data
                }
            }

            return new SFTPFileAttributes(fileSize, uid, gid, permissions, atime, mtime);
        }