Exemplo n.º 1
0
 void dump(FileStream outs)
 {
     //StreamWriter outs = new StreamWriter(fs);
     try {
         HostKey hk;
         for (int i = 0; i < pool.Count; i++)
         {
             hk = (HostKey)(pool[i]);
             //hk.dump(out);
             String host = hk.getHost();
             String type = hk.getType();
             if (type.Equals("UNKNOWN"))
             {
                 Write(outs, StringAux.getBytes(host));
                 Write(outs, cr);
                 continue;
             }
             Write(outs, StringAux.getBytes(host));
             Write(outs, space);
             Write(outs, StringAux.getBytes(type));
             Write(outs, space);
             Write(outs, StringAux.getBytes(hk.getKey()));
             Write(outs, cr);
         }
         outs.Flush();
     }
     catch (Exception e) {
         Console.WriteLine(e);
     }
 }
Exemplo n.º 2
0
 public void writeSECSHPublicKey(Stream outs, String comment)
 {
     byte[] pubblob = getPublicKeyBlob();
     byte[] pub     = StringAux.toBase64(pubblob, 0, pubblob.Length);
     try {
         Write(outs, StringAux.getBytes("---- BEGIN SSH2 PUBLIC KEY ----"));
         Write(outs, cr);
         Write(outs, StringAux.getBytes("Comment: \"" + comment + "\""));
         Write(outs, cr);
         int index = 0;
         while (index < pub.Length)
         {
             int len = 70;
             if ((pub.Length - index) < len)
             {
                 len = pub.Length - index;
             }
             outs.Write(pub, index, len);
             Write(outs, cr);
             index += len;
         }
         Write(outs, StringAux.getBytes("---- END SSH2 PUBLIC KEY ----"));
         Write(outs, cr);
     }
     catch (Exception e) {
         Console.WriteLine(e);
     }
 }
Exemplo n.º 3
0
        private bool isIncluded(String hosts, String host)
        {
            int i        = 0;
            int hostlen  = host.Length;
            int hostslen = hosts.Length;
            int j;

            while (i < hostslen)
            {
                j = hosts.IndexOf(',', i);
                if (j == -1)
                {
                    if (hostlen != hostslen - i)
                    {
                        return(false);
                    }
                    return(StringAux.regionMatches(hosts, true, i, host, 0, hostlen));
                    //return hosts.substring(i).equals(host);
                }
                if (hostlen == (j - i))
                {
                    if (StringAux.regionMatches(hosts, true, i, host, 0, hostlen))
                    {
                        return(true);
                    }
                    //if(hosts.substring(i, i+hostlen).equals(host)) return true;
                }
                i = j + 1;
            }
            return(false);
        }
Exemplo n.º 4
0
 public void setPubKey(byte[] y, byte[] p, byte[] q, byte[] g)
 {
     DSAKeyInfo.Y = StringAux.stripLeadingZeros(y);
     DSAKeyInfo.P = StringAux.stripLeadingZeros(p);
     DSAKeyInfo.Q = StringAux.stripLeadingZeros(q);
     DSAKeyInfo.G = StringAux.stripLeadingZeros(g);
 }
Exemplo n.º 5
0
 public void setPrvKey(byte[] x, byte[] p, byte[] q, byte[] g)
 {
     DSAKeyInfo.X = StringAux.stripLeadingZeros(x);
     DSAKeyInfo.P = StringAux.stripLeadingZeros(p);
     DSAKeyInfo.Q = StringAux.stripLeadingZeros(q);
     DSAKeyInfo.G = StringAux.stripLeadingZeros(g);
 }
Exemplo n.º 6
0
 public bool decrypt(String _passphrase)
 {
     byte[] passphrase = StringAux.getBytes(_passphrase);
     byte[] foo        = decrypt(data, passphrase, iv);
     if (parse(foo))
     {
         encrypted = false;
     }
     return(!encrypted);
 }
Exemplo n.º 7
0
 internal static void setCookie(String foo)
 {
     cookie_hex = StringAux.getBytes(foo);
     cookie     = new byte[16];
     for (int i = 0; i < 16; i++)
     {
         cookie[i] = (byte)(((revtable(cookie_hex[i * 2]) << 4) & 0xf0) |
                            ((revtable(cookie_hex[i * 2 + 1])) & 0xf));
     }
 }
Exemplo n.º 8
0
 public void setPassphrase(String passphrase)
 {
     if (passphrase == null || passphrase.Length == 0)
     {
         setPassphrase((byte[])null);
     }
     else
     {
         setPassphrase(StringAux.getBytes(passphrase));
     }
 }
Exemplo n.º 9
0
 public void setPrvKey(byte[] e, byte[] n, byte[] d, byte[] p, byte[] q, byte[] dp, byte[] dq, byte[] c)
 {
     RSAKeyInfo.Exponent = e;
     RSAKeyInfo.D        = StringAux.stripLeadingZeros(d);
     RSAKeyInfo.Modulus  = StringAux.stripLeadingZeros(n);
     RSAKeyInfo.P        = StringAux.stripLeadingZeros(p);
     RSAKeyInfo.Q        = StringAux.stripLeadingZeros(q);
     RSAKeyInfo.DP       = StringAux.stripLeadingZeros(dp);
     RSAKeyInfo.DQ       = StringAux.stripLeadingZeros(dq);
     RSAKeyInfo.InverseQ = StringAux.stripLeadingZeros(c);
 }
Exemplo n.º 10
0
 public void setPubKey(byte[] e, byte[] n)
 {
     //    RSAPublicKeySpec rsaPubKeySpec =
     //	new RSAPublicKeySpec(new BigInteger(n),
     //			     new BigInteger(e));
     //    PublicKey pubKey=keyFactory.generatePublic(rsaPubKeySpec);
     //    signature.initVerify(pubKey);
     RSAKeyInfo.Modulus  = StringAux.stripLeadingZeros(n);
     RSAKeyInfo.Exponent = e;
     //			Util.Dump("C:\\e.bin", e);
     //			Util.Dump("C:\\n.bin", n);
 }
Exemplo n.º 11
0
        public String getFingerPrint(SshClient jsch)
        {
            IHASH hash = null;

            try {
                hash = (IHASH)Activator.CreateInstance(Type.GetType(jsch.getConfig("md5")));
            }
            catch (Exception e) {
                Console.Error.WriteLine("getFingerPrint: " + e);
            }
            return(StringAux.getFingerPrint(hash, key));
        }
Exemplo n.º 12
0
        public void request(Session session, AChannel channel)
        {
            Buffer buf    = new Buffer();
            Packet packet = new Packet(buf);

            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(StringAux.getBytes("signal"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putString(StringAux.getBytes(signal));
            session.write(packet);
        }
Exemplo n.º 13
0
        public String getFingerPrint()
        {
            IHASH hash = null;

            try {
                Type t = Type.GetType(session.getConfig("md5"));
                hash = (IHASH)(Activator.CreateInstance(t));
            }
            catch (Exception e) {
                Console.Error.WriteLine("getFingerPrint: " + e);
            }
            return(StringAux.getFingerPrint(hash, getHostKey()));
        }
Exemplo n.º 14
0
 public String getFingerPrint()
 {
     if (hash == null)
     {
         hash = genHash();
     }
     byte[] kblob = getPublicKeyBlob();
     if (kblob == null)
     {
         return(null);
     }
     return(getKeySize() + " " + StringAux.getFingerPrint(hash, kblob));
 }
Exemplo n.º 15
0
 public void writePublicKey(Stream outs, String comment)
 {
     byte[] pubblob = getPublicKeyBlob();
     byte[] pub     = StringAux.toBase64(pubblob, 0, pubblob.Length);
     try {
         Write(outs, getKeyTypeName());
         Write(outs, space);
         outs.Write(pub, 0, pub.Length);
         Write(outs, space);
         Write(outs, StringAux.getBytes(comment));
         Write(outs, cr);
     }
     catch (Exception e) {
         Console.WriteLine(e);
     }
 }
Exemplo n.º 16
0
        internal static void delPort(Session session, int rport)
        {
            lock (pool) {
                Object[] foo = null;
                for (int i = 0; i < pool.Count; i++)
                {
                    Object[] bar = (Object[])(pool[i]);
                    if (bar[0] != session)
                    {
                        continue;
                    }
                    if (((int)bar[1]) != rport)
                    {
                        continue;
                    }
                    foo = bar;
                    break;
                }
                if (foo == null)
                {
                    return;
                }
                pool.Remove(foo);
            }

            Buffer buf    = new Buffer(100);          // ??
            Packet packet = new Packet(buf);

            try {
                // byte SSH_MSG_GLOBAL_REQUEST 80
                // string "cancel-tcpip-forward"
                // boolean want_reply
                // string  address_to_bind (e.g. "127.0.0.1")
                // uint32  port number to bind
                packet.reset();
                buf.putByte((byte)80 /*SSH_MSG_GLOBAL_REQUEST*/);
                buf.putString(StringAux.getBytesUTF8("cancel-tcpip-forward"));
                buf.putByte((byte)0);
                buf.putString(StringAux.getBytesUTF8("0.0.0.0"));
                buf.putInt(rport);
                session.write(packet);
            }
            catch            //(Exception e)
            {
                //    throw new JSchException(e.toString());
            }
        }
Exemplo n.º 17
0
        public void request(Session session, AChannel channel)
        {
            Buffer buf    = new Buffer();
            Packet packet = new Packet(buf);

            // send
            // byte     SSH_MSG_CHANNEL_REQUEST(98)
            // uint32 recipient channel
            // string request type       // "shell"
            // boolean want reply        // 0
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(StringAux.getBytes("shell"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            session.write(packet);
        }
Exemplo n.º 18
0
        public void writePrivateKey(Stream outs)
        {
            byte[]   plain   = getPrivateKey();
            byte[][] _iv     = new byte[1][];
            byte[]   encoded = encrypt(plain, _iv);
            byte[]   iv      = _iv[0];
            byte[]   prv     = StringAux.toBase64(encoded, 0, encoded.Length);

            try {
                Write(outs, getBegin());
                Write(outs, cr);
                if (passphrase != null)
                {
                    Write(outs, header[0]);
                    Write(outs, cr);
                    Write(outs, header[1]);
                    for (int j = 0; j < iv.Length; j++)
                    {
                        outs.WriteByte(b2a((byte)((iv[j] >> 4) & 0x0f)));
                        outs.WriteByte(b2a((byte)(iv[j] & 0x0f)));
                    }
                    Write(outs, cr);
                    Write(outs, cr);
                }
                int i = 0;
                while (i < prv.Length)
                {
                    if (i + 64 < prv.Length)
                    {
                        outs.Write(prv, i, 64);
                        Write(outs, cr);
                        i += 64;
                        continue;
                    }
                    outs.Write(prv, i, prv.Length - i);
                    Write(outs, cr);
                    break;
                }
                Write(outs, getEnd());
                Write(outs, cr);
                //outs.close();
            }
            catch (Exception e) {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 19
0
 internal IProxy getProxy(String host)
 {
     if (proxies == null)
     {
         return(null);
     }
     byte[] _host = System.Text.Encoding.Default.GetBytes(host);
     lock (proxies) {
         for (int i = 0; i < proxies.Count; i += 2)
         {
             if (StringAux.glob(((byte[])proxies[i]), _host))
             {
                 return((IProxy)(proxies[i + 1]));
             }
         }
     }
     return(null);
 }
Exemplo n.º 20
0
    public void EndDrag()
    {
        if (Input.GetMouseButtonUp(0))
        {
            int index        = TMP_TextUtilities.FindIntersectingCharacter(text, Input.mousePosition, Camera.main, true);
            int indexPalavra = TMP_TextUtilities.FindIntersectingWord(text, Input.mousePosition, Camera.main);

            if (index >= 0)
            {
                bool flag = false;
                if (StringAux.CreckSprite(text.text, index) == 1)
                {
                    flag = true;
                    for (int i = 0; i < 4; i++)
                    {
                        indexBlocosQuestaoUsados[i] = info.indexOpcaoArrastada;
                    }
                }
                else if (StringAux.CreckPalavra(text.text, indexPalavra))
                {
                    flag = true;
                    for (int i = 0; i < 4; i++)
                    {
                        indexBlocosQuestaoUsados[i] = info.indexOpcaoArrastada;
                    }
                }
                if (flag)
                {
                    bool resp = false;

                    if (((StartupDay_QuestaoLacuna)info.atividade.questoes[info.indexQuestao]).blocoLugar[indexBlocosQuestaoUsados[0]] == 1)
                    {
                        resp = true;
                    }
                    for (int i = 0; i < 4; i++)
                    {
                        indexBlocosQuestaoUsados[i] = -1;
                    }
                    gerente.Resposta(resp);
                }
            }
        }
    }
Exemplo n.º 21
0
        public void request(Session session, AChannel channel)
        {
            Packet packet = session.packet;
            Buffer buf    = session.buf;

            // send
            // byte     SSH_MSG_CHANNEL_REQUEST(98)
            // uint32 recipient channel
            // string request type       // "exec"
            // boolean want reply        // 0
            // string command
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(StringAux.getBytesUTF8("exec"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putString(StringAux.getBytesUTF8(command));
            session.write(packet);
        }
Exemplo n.º 22
0
        public virtual bool start(Session session)
        {
            Packet packet = session.packet;
            Buffer buf    = session.buf;

            // send
            // byte      SSH_MSG_SERVICE_REQUEST(5)
            // string    service name "ssh-userauth"
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_SERVICE_REQUEST);
            buf.putString(StringAux.getBytes("ssh-userauth"));
            session.write(packet);

            // receive
            // byte      SSH_MSG_SERVICE_ACCEPT(6)
            // string    service name
            buf = session.read(buf);
            //System.out.println("read: 6 ? "+buf.buffer[5]);
            return(buf.buffer[5] == 6);
        }
Exemplo n.º 23
0
        internal static SftpATTRS getATTR(Buffer buf)
        {
            SftpATTRS attr = new SftpATTRS();

            attr.flags = buf.getInt();
            if ((attr.flags & SSH_FILEXFER_ATTR_SIZE) != 0)
            {
                attr.size = buf.getLong();
            }
            if ((attr.flags & SSH_FILEXFER_ATTR_UIDGID) != 0)
            {
                attr.uid = buf.getInt();
                attr.gid = buf.getInt();
            }
            if ((attr.flags & SSH_FILEXFER_ATTR_PERMISSIONS) != 0)
            {
                attr.permissions = buf.getInt();
            }
            if ((attr.flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0)
            {
                attr.atime = buf.getInt();
            }
            if ((attr.flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0)
            {
                attr.mtime = buf.getInt();
            }
            if ((attr.flags & SSH_FILEXFER_ATTR_EXTENDED) != 0)
            {
                int count = buf.getInt();
                if (count > 0)
                {
                    attr.extended = new String[count * 2];
                    for (int i = 0; i < count; i++)
                    {
                        attr.extended[i * 2]     = StringAux.getString(buf.getString());
                        attr.extended[i * 2 + 1] = StringAux.getString(buf.getString());
                    }
                }
            }
            return(attr);
        }
Exemplo n.º 24
0
        internal ChannelX11()
            : base()
        {
            setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX);
            setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX);
            setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE);

            type = StringAux.getBytes("x11");
            try {
                IPEndPoint ep = new IPEndPoint(Dns.GetHostEntry(host).AddressList[0], port);
                socket = new Socket(ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, 1);
                socket.Connect(ep);
                io = new IO();
                NetworkStream ns = new NetworkStream(socket);
                io.setInputStream(ns);
                io.setOutputStream(ns);
            }
            catch (Exception e) {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 25
0
 void setProxy(String hosts, IProxy proxy)
 {
     String[] patterns = StringAux.split(hosts, ",");
     if (proxies == null)
     {
         proxies = new System.Collections.ArrayList();
     }
     lock (proxies) {
         for (int i = 0; i < patterns.Length; i++)
         {
             if (proxy == null)
             {
                 proxies[0] = null;
                 proxies[0] = System.Text.Encoding.Default.GetBytes(patterns[i]);
             }
             else
             {
                 proxies.Add(System.Text.Encoding.Default.GetBytes(patterns[i]));
                 proxies.Add(proxy);
             }
         }
     }
 }
Exemplo n.º 26
0
 internal void dump(Buffer buf)
 {
     buf.putInt(flags);
     if ((flags & SSH_FILEXFER_ATTR_SIZE) != 0)
     {
         buf.putLong(size);
     }
     if ((flags & SSH_FILEXFER_ATTR_UIDGID) != 0)
     {
         buf.putInt(uid);
         buf.putInt(gid);
     }
     if ((flags & SSH_FILEXFER_ATTR_PERMISSIONS) != 0)
     {
         buf.putInt(permissions);
     }
     if ((flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0)
     {
         buf.putInt(atime);
     }
     if ((flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0)
     {
         buf.putInt(mtime);
     }
     if ((flags & SSH_FILEXFER_ATTR_EXTENDED) != 0)
     {
         int count = extended.Length / 2;
         if (count > 0)
         {
             for (int i = 0; i < count; i++)
             {
                 buf.putString(StringAux.getBytes(extended[i * 2]));
                 buf.putString(StringAux.getBytes(extended[i * 2 + 1]));
             }
         }
     }
 }
Exemplo n.º 27
0
        public void request(Session session, AChannel channel)
        {
            Buffer buf    = new Buffer();
            Packet packet = new Packet(buf);

            bool reply = waitForReply();

            if (reply)
            {
                channel.reply = -1;
            }

            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(StringAux.getBytes("subsystem"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putString(StringAux.getBytes("sftp"));
            session.write(packet);

            if (reply)
            {
                while (channel.reply == -1)
                {
                    try {
                        System.Threading.Thread.Sleep(10);
                    }
                    catch                    //(Exception ee)
                    {
                    }
                }
                if (channel.reply == 0)
                {
                    throw new SshClientException("failed to send sftp request");
                }
            }
        }
Exemplo n.º 28
0
        public void request(Session session, AChannel channel)
        {
            Buffer buf    = new Buffer();
            Packet packet = new Packet(buf);

            //byte      SSH_MSG_CHANNEL_REQUEST
            //uint32    recipient_channel
            //string    "window-change"
            //boolean   FALSE
            //uint32    terminal width, columns
            //uint32    terminal height, rows
            //uint32    terminal width, pixels
            //uint32    terminal height, pixels
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(StringAux.getBytes("window-change"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putInt(width_columns);
            buf.putInt(height_rows);
            buf.putInt(width_pixels);
            buf.putInt(height_pixels);
            session.write(packet);
        }
Exemplo n.º 29
0
        public void request(Session session, AChannel channel)
        {
            Buffer buf    = new Buffer();
            Packet packet = new Packet(buf);

            // byte      SSH_MSG_CHANNEL_REQUEST(98)
            // uint32 recipient channel
            // string request type        // "x11-req"
            // boolean want reply         // 0
            // boolean   single connection
            // string    x11 authentication protocol // "MIT-MAGIC-COOKIE-1".
            // string    x11 authentication cookie
            // uint32    x11 screen number
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(StringAux.getBytes("x11-req"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putByte((byte)0);
            buf.putString(StringAux.getBytes("MIT-MAGIC-COOKIE-1"));
            buf.putString(ChannelX11.getFakedCookie(session));
            buf.putInt(0);
            session.write(packet);
        }
Exemplo n.º 30
0
        public override bool next(LibSterileSSH.SecureShell.Buffer _buf)
        {
            int  i, j;
            bool result = false;

            switch (state)
            {
            case SSH_MSG_KEXDH_REPLY:
                // The server responds with:
                // byte      SSH_MSG_KEXDH_REPLY(31)
                // string    server public host key and certificates (K_S)
                // mpint     f
                // string    signature of H
                j = _buf.getInt();
                j = _buf.getByte();
                j = _buf.getByte();
                if (j != 31)
                {
                    Console.WriteLine("type: must be 31 " + j);
                    result = false;
                    break;
                }

                K_S = _buf.getString();
                // K_S is server_key_blob, which includes ....
                // string ssh-dss
                // impint p of dsa
                // impint q of dsa
                // impint g of dsa
                // impint pub_key of dsa
                //System.out.print("K_S: "); //dump(K_S, 0, K_S.length);
                byte[] f        = _buf.getMPInt();
                byte[] sig_of_H = _buf.getString();

                /*
                 * for(int ii=0; ii<sig_of_H.length;ii++){
                 * System.out.print(Integer.toHexString(sig_of_H[ii]&0xff));
                 * System.out.print(": ");
                 * }
                 * Console.WriteLine("");
                 */

                dh.setF(f);
                K = dh.getK();

                //The hash H is computed as the HASH hash of the concatenation of the
                //following:
                // string    V_C, the client's version string (CR and NL excluded)
                // string    V_S, the server's version string (CR and NL excluded)
                // string    I_C, the payload of the client's SSH_MSG_KEXINIT
                // string    I_S, the payload of the server's SSH_MSG_KEXINIT
                // string    K_S, the host key
                // mpint     e, exchange value sent by the client
                // mpint     f, exchange value sent by the server
                // mpint     K, the shared secret
                // This value is called the exchange hash, and it is used to authenti-
                // cate the key exchange.
                buf.reset();
                buf.putString(V_C);
                buf.putString(V_S);
                buf.putString(I_C);
                buf.putString(I_S);
                buf.putString(K_S);
                buf.putMPInt(e);
                buf.putMPInt(f);
                buf.putMPInt(K);
                byte[] foo = new byte[buf.getLength()];
                buf.getByte(foo);
                sha.update(foo, 0, foo.Length);
                H = sha.digest();
                //System.out.print("H -> "); //dump(H, 0, H.length);

                i = 0;
                j = 0;
                j = (int)((K_S[i++] << 24) & 0xff000000) | ((K_S[i++] << 16) & 0x00ff0000) |
                    ((K_S[i++] << 8) & 0x0000ff00) | ((K_S[i++]) & 0x000000ff);
                String alg = StringAux.getString(K_S, i, j);
                i += j;

                result = false;

                if (alg.Equals("ssh-rsa"))
                {
                    byte[] tmp;
                    byte[] ee;
                    byte[] n;

                    type = RSA;

                    j = (int)((K_S[i++] << 24) & 0xff000000) | ((K_S[i++] << 16) & 0x00ff0000) |
                        ((K_S[i++] << 8) & 0x0000ff00) | ((K_S[i++]) & 0x000000ff);
                    tmp = new byte[j];
                    Array.Copy(K_S, i, tmp, 0, j);
                    i += j;
                    ee = tmp;
                    j  = (int)((K_S[i++] << 24) & 0xff000000) | ((K_S[i++] << 16) & 0x00ff0000) |
                         ((K_S[i++] << 8) & 0x0000ff00) | ((K_S[i++]) & 0x000000ff);
                    tmp = new byte[j];
                    Array.Copy(K_S, i, tmp, 0, j);
                    i += j;
                    n  = tmp;

                    //	SignatureRSA sig=new SignatureRSA();
                    //	sig.init();

                    ISignatureRSA sig = null;
                    try {
                        Type t = Type.GetType(session.getConfig("signature.rsa"));
                        sig = (ISignatureRSA)(Activator.CreateInstance(t));
                        sig.init();
                    }
                    catch (Exception eee) {
                        Console.WriteLine(eee);
                    }

                    sig.setPubKey(ee, n);
                    sig.update(H);
                    result = sig.verify(sig_of_H);
                    //MainClass.dump(ee, n, sig_of_H, H);
                }
                else if (alg.Equals("ssh-dss"))
                {
                    byte[] q = null;
                    byte[] tmp;
                    byte[] p;
                    byte[] g;

                    type = DSS;

                    j = (int)((K_S[i++] << 24) & 0xff000000) | ((K_S[i++] << 16) & 0x00ff0000) |
                        ((K_S[i++] << 8) & 0x0000ff00) | ((K_S[i++]) & 0x000000ff);
                    tmp = new byte[j];
                    Array.Copy(K_S, i, tmp, 0, j);
                    i += j;
                    p  = tmp;
                    j  = (int)((K_S[i++] << 24) & 0xff000000) | ((K_S[i++] << 16) & 0x00ff0000) |
                         ((K_S[i++] << 8) & 0x0000ff00) | ((K_S[i++]) & 0x000000ff);
                    tmp = new byte[j];
                    Array.Copy(K_S, i, tmp, 0, j);
                    i += j;
                    q  = tmp;
                    j  = (int)((K_S[i++] << 24) & 0xff000000) | ((K_S[i++] << 16) & 0x00ff0000) |
                         ((K_S[i++] << 8) & 0x0000ff00) | ((K_S[i++]) & 0x000000ff);
                    tmp = new byte[j];
                    Array.Copy(K_S, i, tmp, 0, j);
                    i += j;
                    g  = tmp;
                    j  = (int)((K_S[i++] << 24) & 0xff000000) | ((K_S[i++] << 16) & 0x00ff0000) |
                         ((K_S[i++] << 8) & 0x0000ff00) | ((K_S[i++]) & 0x000000ff);
                    tmp = new byte[j];
                    Array.Copy(K_S, i, tmp, 0, j);
                    i += j;
                    f  = tmp;
                    //	SignatureDSA sig=new SignatureDSA();
                    //	sig.init();
                    ISignatureDSA sig = null;
                    try {
                        Type t = Type.GetType(session.getConfig("signature.dss"));
                        sig = (ISignatureDSA)(Activator.CreateInstance(t));
                        sig.init();
                    }
                    catch (Exception ee) {
                        Console.WriteLine(ee);
                    }
                    sig.setPubKey(f, p, q, g);
                    sig.update(H);
                    result = sig.verify(sig_of_H);
                }
                else
                {
                    Console.WriteLine("unknow alg");
                }
                state = STATE_END;
                break;
            }
            return(result);
        }