Problem with XTEA encryption [Panda II]


I’m pretty new to the .NETMF stuff and GHIElectronics hardware. I’ve got a Panda II with the Connect Shield. I’ve build a TCP client - server application that runs pretty good allready and now I wanna add some encryption.

On the Panda I am using the XTEA class that comes with the GHIElectronics System.dll to encrypt my byte arrays. The size of the byte array is a mutiple of 8 (I am padding the array with zeros if necessary to get the correct size).
On my PC I am using the Key_TinyEncryptionAlgorithm class from Microsoft.SPOT.Cryptography (like the example from Jens Kuhner)

The key I use for testing is {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, the IV is {0}.

When I encrypt a row of 8 bytes (e.g. the string “12345678” converted to a byte array) both algorithms give me {12, 165, 195, 81, 4, 206,170,165} as encrypted output.
So far so good, the problem starts when I want to encrypt a byte array that is longer than 8 bytes. The String “1234567812345678” as byte array is {12, 165, 195, 81, 4, 206, 170, 165, 12, 165, 195, 81, 4, 206,170,165} when encrypted on the Panda II.
On my PC I get {12, 165, 195, 81, 4, 206, 170, 165, 228, 105, 103, 225, 206, 33, 255, 50} for the same string.
The first 8 bytes are the same, but the next 8 bytes are different.

Is the GHI algorithm for XTEA different from the algorithm used by Microsoft? Is there anything else I’ve to take care of to get the same result on both platforms?
As it is right now I can’t use XTEA because I can’t decrypt the data from my Panda II on my PC or the other way round.
The SDK version I am using is 1.0.15.

XTEA is made to only encrypt blocks of 8 bytes but microsoft hacked it a bit so it will work with different sizes. The lib provided by GHI is the standard XTEA 8-byte-block-only algorithm.

On PC, you will have to process each 8 bytes individually. You can modify Jens’ code or find code online

Here is a good implementation, convert from C to C#