Example #1
0
        /// <summary>
        /// Checks the validity of the stored HMAC in the packet buffer.
        /// </summary>
        /// <param name="packetData">The packet the way it was received.</param>
        /// <returns>A boolean that indicates if the stored HMAC is whether or not valid.</returns>
        public bool VerifyHmac(byte[] packetData)
        {
            byte[] storedHmac = Sequence.ReadBlock(packetData, packetData.Length - 10, 10);

            byte[] authData     = Sequence.ReadBlock(packetData, 2, packetData.Length - 10 - 2);
            byte[] expectedHmac = MD5Hmac.ComputeHMAC(authData, HmacKey, 10);

            return(storedHmac.SequenceEqual(expectedHmac));
        }
Example #2
0
 /// <summary>
 /// Computes the HMAC for the specified packet data.
 /// </summary>
 /// <param name="authData"> The whole packet buffer, except for the size and the own HMAC.</param>
 /// <returns>The HMAC of the packet, which, in the case of Grand Chase, has the size of 10 bytes.</returns>
 public byte[] GetHmac(byte[] authData)
 {
     return(MD5Hmac.ComputeHMAC(authData, HmacKey, 10));
 }
Example #3
0
 /// <summary>
 /// Computes the HMAC for the specified packet data.
 /// </summary>
 /// <param name="partialBuffer">The whole packet buffer, except for the own HMAC.</param>
 /// <returns>The HMAC.</returns>
 public byte[] GetHmac(byte[] partialBuffer)
 {
     byte[] authData = Sequence.ReadBlock(partialBuffer, 2, partialBuffer.Length - 2);
     return(MD5Hmac.ComputeHmac(authData, HmacKey, 10));
 }