private byte[] xorData; // This table is used for encrypting the server->client stream

        #endregion Fields

        #region Constructors

        public GameEncryption(uint seed)
        {
            cipherTable = new byte[0x100];

            // Set up the crypt key
            byte[] key = new byte[16];
            key[0] = key[4] = key[8] = key[12] = (byte)((seed >> 24) & 0xff);
            key[1] = key[5] = key[9] = key[13] = (byte)((seed >> 16) & 0xff);
            key[2] = key[6] = key[10] = key[14] = (byte)((seed >> 8) & 0xff);
            key[3] = key[7] = key[11] = key[15] = (byte)(seed & 0xff);

            byte[] iv = new byte[0];
            engine = new TwofishEncryption(128, ref key, ref iv, CipherMode.ECB, TwofishBase.EncryptionDirection.Decrypting);

            // Initialize table
            for ( int i = 0; i < 256; ++i )
                cipherTable[i] = (byte)i;

            sendPos = 0;

            // We need to fill the table initially to calculate the MD5 hash of it
            refreshCipherTable();

            // Create a MD5 hash of the twofish crypt data and use it as a 16-byte xor table
            // for encrypting the server->client stream.
            MD5 md5 = new MD5CryptoServiceProvider();
            xorData = md5.ComputeHash(cipherTable);
        }
Beispiel #2
0
        private byte[] xorData;       // This table is used for encrypting the server->client stream

        public GameEncryption(uint seed)
        {
            cipherTable = new byte[0x100];

            // Set up the crypt key
            byte[] key = new byte[16];
            key[0] = key[4] = key[8] = key[12] = (byte)((seed >> 24) & 0xff);
            key[1] = key[5] = key[9] = key[13] = (byte)((seed >> 16) & 0xff);
            key[2] = key[6] = key[10] = key[14] = (byte)((seed >> 8) & 0xff);
            key[3] = key[7] = key[11] = key[15] = (byte)(seed & 0xff);

            byte[] iv = new byte[0];
            engine = new TwofishEncryption(128, ref key, ref iv, CipherMode.ECB, TwofishBase.EncryptionDirection.Decrypting);

            // Initialize table
            for (int i = 0; i < 256; ++i)
            {
                cipherTable[i] = (byte)i;
            }

            sendPos = 0;

            // We need to fill the table initially to calculate the MD5 hash of it
            refreshCipherTable();

            // Create a MD5 hash of the twofish crypt data and use it as a 16-byte xor table
            // for encrypting the server->client stream.
            MD5 md5 = new MD5CryptoServiceProvider();

            xorData = md5.ComputeHash(cipherTable);
        }