Ejemplo n.º 1
0
        public override byte[] Decrypt(byte[] data)
        {
            lock (this)
            {
                using (ByteBuffer buffer = new ByteBuffer(data))
                {
                    byte[] header = buffer.ReadBytes(4);

                    if (!this.Decryptograph.IsValidPacket(header))
                    {
                        throw new CryptographyException("Invalid header.");
                    }

                    byte[] content = buffer.GetContent();

                    int length = AesCryptograph.RetrieveLength(header);

                    if (content.Length == length)
                    {
                        this.Decryptograph.Crypt(content);
                        BlurCryptograph.Decrypt(content);

                        return(content);
                    }
                    else
                    {
                        throw new CryptographyException(string.Format("Packet length not matching ({0} != {1}).", content.Length, length));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void UpdateIV()
        {
            byte[] newIV = new byte[4] {
                0xF2, 0x53, 0x50, 0xC6
            };

            for (int i = 0; i < 4; i++)
            {
                AesCryptograph.Shuffle(this.IV[i], newIV);
            }

            this.IV = newIV;
        }
Ejemplo n.º 3
0
        public byte[] Initialize()
        {
            byte[] receiveIV = BitConverter.GetBytes(Application.Random.Next());
            byte[] sendIV    = BitConverter.GetBytes(Application.Random.Next());

            this.Encryptograph = new AesCryptograph(sendIV, unchecked ((short)(0xFFFF - Application.MapleVersion)));
            this.Decryptograph = new AesCryptograph(receiveIV, Application.MapleVersion);

            using (ByteBuffer buffer = new ByteBuffer(16))
            {
                buffer.WriteShort(0x0E);
                buffer.WriteShort(Application.MapleVersion);
                buffer.WriteString(Application.PatchVersion);
                buffer.WriteBytes(receiveIV);
                buffer.WriteBytes(sendIV);
                buffer.WriteByte(8);

                return(buffer.Array);
            }
        }