예제 #1
0
        public override void init(Session session,
                                  byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C)
        {
            this.session = session;
            this.V_S     = V_S;
            this.V_C     = V_C;
            this.I_S     = I_S;
            this.I_C     = I_C;

            //    sha=new SHA1();
            //    sha.init();
            try
            {
                sha = new Tamir.SharpSsh.jsch.jce.SHA1();
                sha.init();
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee);
            }

            buf    = new Buffer();
            packet = new Packet(buf);

            try
            {
                dh = new Tamir.SharpSsh.jsch.jce.DH();
                dh.init();
            }
            catch (Exception ee)
            {
                throw ee;
            }

            dh.setP(p);
            dh.setG(g);

            // The client responds with:
            // byte  SSH_MSG_KEXDH_INIT(30)
            // mpint e <- g^x mod p
            //         x is a random number (1 < x < (p-1)/2)

            e = dh.getE();

            packet.reset();
            buf.putByte((byte)SSH_MSG_KEXDH_INIT);
            buf.putMPInt(e);
            session.write(packet);

            state = SSH_MSG_KEXDH_REPLY;
        }
예제 #2
0
        //private byte[] f;

        public override void init(Session session,
                                  byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C)
        {
            this.session = session;
            this.V_S     = V_S;
            this.V_C     = V_C;
            this.I_S     = I_S;
            this.I_C     = I_C;

            //    sha=new SHA1();
            //    sha.init();

            try
            {
                sha = new Tamir.SharpSsh.jsch.jce.SHA1();
                sha.init();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            buf    = new Buffer();
            packet = new Packet(buf);

            try
            {
                dh = new Tamir.SharpSsh.jsch.jce.DH();
                dh.init();
            }
            catch (Exception e)
            {
                throw e;
            }

            packet.reset();
            buf.putByte((byte)0x22);
            buf.putInt(min);
            buf.putInt(preferred);
            buf.putInt(max);
            session.write(packet);

            state = SSH_MSG_KEX_DH_GEX_GROUP;
        }