コード例 #1
0
        /// <summary>
        /// Generates aes based on key and iv, that we get from login server.
        /// Used only in world server.
        /// </summary>
        /// <param name="key">bytes for key</param>
        /// <param name="iv">bytes for iv</param>
        public void GenerateAES(byte[] key, byte[] iv)
        {
            Key = key;
            IV  = iv;

            byte[] hashed = SHA256.Create().ComputeHash(IV);
            Array.Copy(hashed, IV, 16);

            // Decryption settings
            AesRecv    = new Aes128CounterMode(IV);
            CryptoRecv = AesRecv.CreateDecryptor(Key, null);
            // Encryption settings
            AesSend    = new Aes128CounterMode(IV);
            CryptoSend = AesSend.CreateEncryptor(Key, null);
        }
コード例 #2
0
        /// <summary>
        /// Generates aes based on rsa decrypted number.
        /// Used only in login server.
        /// </summary>
        /// <param name="DecryptedMessage">big integer number, that we get from game.exe</param>
        public void GenerateAES(BigInteger DecryptedMessage)
        {
            HMACSHA256 hmac = new HMACSHA256(DecryptedMessage.ToByteArray());

            byte[] HmacBytes = hmac.ComputeHash(RSAModulus);

            Key = new byte[16];
            IV  = new byte[16];

            Array.Copy(HmacBytes, 0, Key, 0, 16);
            Array.Copy(HmacBytes, 16, IV, 0, 16);

            // Decryption settings
            AesRecv    = new Aes128CounterMode(IV);
            CryptoRecv = AesRecv.CreateDecryptor(Key, null);
            // Encryption settings
            AesSend    = new Aes128CounterMode(IV);
            CryptoSend = AesSend.CreateEncryptor(Key, null);
        }