Exemplo n.º 1
0
        private void sendClientDH(NetworkIOArgs args)
        {
            this.sendstate = Esend.SENDCHALLENGE;
            //this.client.Recv(this.buffer, 0, 2);

            this.client.RecvPackage();
        }
Exemplo n.º 2
0
        private void sendtoken(NetworkIOArgs args)
        {
            NetworkCallback temp = this.requestServerCompleted;

            if (temp != null)
            {
                temp(null);
            }
        }
Exemplo n.º 3
0
 private void recvServerDHCount(NetworkIOArgs args)
 {
     //int count = this.getBigEndianCount(args.Data);
     //if (count < BUFFERSIZE)
     //{
     //    Array.Clear(args.Data, 0, args.Count);
     //    client.Recv(args.Data, 0, count);
     //    this.recvState = Erecv.RECVSERVERDH;
     //}
 }
Exemplo n.º 4
0
        private void recvChallenge(NetworkIOArgs args)
        {
            this.challenge = Convert.FromBase64String(Encoding.UTF8.GetString(args.Data, 0, args.Count));

            Array.Clear(args.Data, 0, args.Count);
            this.recvState = Erecv.RECVSERVERDH;
            byte[] clientkey = kcrypt.randomkey();
            this.clientkey = BitConverter.ToUInt64(clientkey, 0);
            client.SendPackage(kcrypt.encode64str(kcrypt.dhexchange(this.clientkey)));
        }
Exemplo n.º 5
0
        private void recvChallengeCount(NetworkIOArgs args)
        {
            //int count = this.getBigEndianCount(args.Data);
            //if (count < BUFFERSIZE)
            //{
            //    Array.Clear(args.Data, 0, args.Count);
            //    client.Recv(args.Data, 0, count);
            //    this.recvState = Erecv.RECVCHALLENGE;

            //}
        }
Exemplo n.º 6
0
        private void recvServers(NetworkIOArgs args)
        {
            client.RecvCompleted -= Client_RecvCompleted;
            client.SendCompleted -= Client_SendCompleted;
            this.token            = null;
            NetworkCallback temp = loginCompleted;

            if (temp != null)
            {
                temp(args);
            }
        }
Exemplo n.º 7
0
        private void recvServerDH(NetworkIOArgs args)
        {
            Debug.Log(string.Format("serverDH is {0}", Encoding.UTF8.GetString(args.Data, 0, args.Count)));
            this.serverDH = BitConverter.ToUInt64(Convert.FromBase64String(Encoding.UTF8.GetString(args.Data, 0, args.Count)), 0);
            Array.Clear(args.Data, 0, args.Count);

            this.recvState = Erecv.RECVSERVERSCOUNT;
            this.secret    = kcrypt.dhsecret(this.serverDH, this.clientkey);
            Debug.Log(string.Format("serverDH is {0}", Convert.ToBase64String(BitConverter.GetBytes(this.secret))));
            kcrypt.SetDesKey(secret);
            ulong sChall = kcrypt.hmac64(BitConverter.ToUInt64(this.challenge, 0), this.secret);

            client.SendPackage(Convert.ToBase64String(BitConverter.GetBytes(sChall)));
        }
Exemplo n.º 8
0
 private void Client_SendCompleted(NetWorkArgs args)
 {
     try
     {
         if (args.State == NetworkState.Sended)
         {
             NetworkIOArgs arg = args as NetworkIOArgs;
             Type          t   = this.GetType();
             System.Reflection.MethodInfo callback = t.GetMethod(sendMethodName[(int)this.sendstate].Trim(), BindingFlags.NonPublic | BindingFlags.Instance);
             object[] param = new object[] { arg };
             callback.Invoke(this, param);
         }
     }
     catch
     {
     }
 }
Exemplo n.º 9
0
 private void Client_RecvCompleted(NetWorkArgs args)
 {
     try
     {
         if (args.State == NetworkState.Recved)
         {
             NetworkIOArgs arg      = args as NetworkIOArgs;
             Type          t        = this.GetType();
             MethodInfo    callback = t.GetMethod(recvMethodName[(int)this.recvState].Trim(), BindingFlags.NonPublic | BindingFlags.Instance);
             object[]      param    = new object[] { arg };
             callback.Invoke(this, param);
         }
     }
     catch
     {
     }
 }
Exemplo n.º 10
0
 private void sendChallenge(NetworkIOArgs args)
 {
     this.client.SendPackage(Convert.ToBase64String(kcrypt.DesEncrypt(Encoding.UTF8.GetBytes(this.token))));
     this.sendstate = Esend.SENDTOKEN;
 }
Exemplo n.º 11
0
 private void sendToken(NetworkIOArgs args)
 {
     this.client.RecvPackage();
 }