I'm new in Crypto and need help in TripleDES  
Author Message
Quotepower Kelvin





PostPosted: Common Language Runtime, I'm new in Crypto and need help in TripleDES Top

I need to communicate with a third party server. It will provide us a key to encrypt a password. It adopts 3DES-CBC and PKCS5 padding. Firstly in .NET, there is only PKCS7 padding and I found that using CBC need to using initial vector but I just have the key ONLY.

So how can I meet the requirements using .NET 2.0 Thanks in advance.



.NET Development35  
 
 
Brian Stern - MSFT





PostPosted: Common Language Runtime, I'm new in Crypto and need help in TripleDES Top

As I understand it, PKCS5 and PKCS7 padding are essentially the same -- basically the padding bytes are all filled with the number of bytes being padded. The only potential difference between the two is how to pad if the amount of padding is greater than 255 bytes, which isn't an issue since the TripleDESCryptoServiceProvider block size is 8 bytes. So you should be safe using PaddingMode.PKCS7.

As for the IV, that is odd. CBC isn't really considered secure unless you use an IV. If no IV is used by the server I suppose that's the same as providing an IV as byte array of zeros since the values are XOR'd. You could try that and see if it works. But not using an IV with CBC is suprising to me.

Brian Stern [MSFT]