Help with TripleDES crypto

I'm trying to get some data to decrypt using TripleDES. It was encrypted with OpenSSL. I have the key and iv used I just cant' get my C# to produce the valid result. Wondering if someone here can help.

The OpenSSL command to DECRYPT the data is:

openssl enc -d -in accessId.bin -out accessId.txt -K EB2B2AEACFFF4084285A443328E8E929F1E4AE7A1521ABEB -iv F6EE4A8CDC2E5E13 -p -des-ede3-cfb

And this works.

accessId.bin has the following bytes in it: {0x81, 0x05, 0x16, 0x2b, 0x91, 0x9e, 0x2a, 0xe2}

Here's what I have tried in C#:

 // Create a new 3DES key. var Key = new byte[] { 0xEB, 0x2B, 0x2A, 0xEA, 0xCF, 0xFF, 0x40, 0x84, 0x28, 0x5A, 0x44, 0x33, 0x28, 0xE8, 0xE9, 0x29, 0xF1, 0xE4, 0xAE, 0x7A, 0x15, 0x21, 0xAB, 0xEB }; // Create the IV var IV = new byte[] { 0xF6, 0xEE, 0x4A, 0x8C, 0xDC, 0x2E, 0x5E, 0x13 }; TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider(); des.KeySize = 192; des.Key = Key; des.IV = IV; des.Mode = CipherMode.CFB; des.Padding = PaddingMode.None; ICryptoTransform ic = des.CreateDecryptor(); byte[] dec = ic.TransformFinalBlock(new byte[] { 0x81, 0x05, 0x16, 0x2B, 0x91, 0x9E, 0x2A, 0xE2 }, 0, 8); 

Ultimately it should return the bytes for the ASCII string "SYSADM" but it doesn't. Anyone know why?

by tslater2006 via /r/csharp

Leave a Reply