Exemple #1
0
        /// <summary>
        /// Decrypts the packet data
        /// </summary>
        private void Decrypt(byte[] data)
        {
            if (!RecvCipher.Handshaken)
            {
                RecvCipher.RecvHandshake(ref data);
                ArrayReader pr = new ArrayReader(data);
                pr.ReadShort(); //Version
                pr.ReadMapleString(); //Sub Version
                uint siv = pr.ReadUInt();
                uint riv = pr.ReadUInt();
                SendCipher.SetIV(siv);
                RecvCipher.SetIV(riv);

                if (HandshakeFinished != null)
                    HandshakeFinished(siv, riv);
            }
            else
            {
                RecvCipher.Decrypt(ref data);
                if (data.Length == 0) return;

                if (PacketFinished != null)
                    PacketFinished(data);
            }
            Wait();
        }
Exemple #2
0
        /// <summary>
        /// Decrypts the packet data
        /// </summary>
        private void Decrypt(byte[] data)
        {
            if (!RecvCipher.Handshaken)
            {
                RecvCipher.Handshake(ref data);
                ArrayReader pr = new ArrayReader(data);
                Debug.WriteLine("Server version {0}.{1}", pr.ReadShort(), pr.ReadMapleString());
                uint siv = pr.ReadUInt();
                uint riv = pr.ReadUInt();
                SendCipher.SetIV(siv);
                RecvCipher.SetIV(riv);

                if (HandshakeFinished != null)
                    HandshakeFinished(siv, riv);
            }
            else
            {
                RecvCipher.Decrypt(ref data);
                if (data.Length == 0) return;

                if (PacketFinished != null)
                    PacketFinished(data);
            }
            Wait();
        }