示例#1
0
        protected virtual void KeyExchangeReceive(object sender, PacketEventArgs e)
        {
            if (!e.IsComplete)
            {
                var keyExchange = e.Read <KeyExchange>();
                var key         = MD5Hash.GetKey(keyExchange.Nonce.Data);

                var rc4Encryption = new Rc4Encryption(key);

                if (e.Chain.IsInput)
                {
                    if (!IsClient)
                    {
                        Session.Connection.EncodeStack.Setup(new MppcPacker());
                    }
                    Session.Connection.EncodeStack.Setup(rc4Encryption);
                }
                else
                {
                    Session.Connection.DecodeStack.Setup(rc4Encryption);
                    if (IsClient)
                    {
                        Session.Connection.DecodeStack.Setup(new MppcUnpacker());
                    }
                }
            }
        }
示例#2
0
        protected internal override void HandleData(ConnectionStatus data)
        {
            byte[] CMKey = new byte[16];

            Random rnd = new Random();

            rnd.NextBytes(CMKey);

            data.SMKey = SMKey;
            data.CMKey = CMKey;

            MD5Hash md5Hash = data.MD5;
            EncDec  encDec  = data.EncDec;

            byte[] decKey = md5Hash.GetKey(CMKey);
            byte[] encKey = md5Hash.GetKey(SMKey);

            encDec.CreateEncode(encKey);
            encDec.CreateDecode(decKey);
        }