示例#1
0
        /// <summary>
        /// Decrypts the specified packet buffer.
        /// </summary>
        /// <param name="packetData">The packet the way it was received.</param>
        /// <returns>The decrypted packet data.</returns>
        public byte[] DecryptPacket(byte[] packetData)
        {
            byte[] iv            = Sequence.ReadBlock(packetData, 8, 8);
            byte[] encryptedData = Sequence.ReadBlock(packetData, 16, packetData.Length - 10 - 16);

            byte[] decryptedData = DESEncryption.DecryptData(encryptedData, iv, Key);
            int    paddingLength = (decryptedData.Last() + 2);

            return(Sequence.ReadBlock(decryptedData, 0, decryptedData.Length - paddingLength));
        }
示例#2
0
        /// <summary>
        /// Decrypts the specified packet buffer.
        /// </summary>
        /// <param name="packetData">The packet the way it was received.</param>
        /// <returns>The decrypted packet data.</returns>
        public byte[] DecryptPacket(byte[] packetData)
        {
            byte[] iv            = Sequence.ReadBlock(packetData, 8, 8);
            byte[] encryptedData = Sequence.ReadBlock(packetData, 16, packetData.Length - 10 - 16);

            byte[] decryptedData = DESEncryption.DecryptData(encryptedData, iv, Key);
            int    paddingLength = (decryptedData.Last() + 2);

            //System.Console.WriteLine(decryptedData.Length);
            //System.Console.WriteLine("padding data length: {0}", paddingLength);
            return(Sequence.ReadBlock(decryptedData, 0, decryptedData.Length - paddingLength));
        }
示例#3
0
 /// <summary>
 /// Encrypts the given packet payload data.
 /// </summary>
 /// <param name="payload">The payload data to be encrypted.</param>
 /// <param name="iv">The initialization vector (IV).</param>
 /// <returns>The encrypted payload data.</returns>
 public byte[] EncryptPacket(byte[] payload, byte[] iv)
 {
     byte[] paddedData = PadData(payload);
     return(DESEncryption.EncryptData(paddedData, iv, Key));
 }