I'm using .NET and I've written an awesome routine (xD) that encrypts and decrypts a file using AES256 CBC. It works perfectly, but now they told me that the encrypted file must be of the same size of the decrypted one. (There is a problem with some other API's, not my fault, I swear.)
So, I've tried everything that I can find, but nothing works. The .NET Framework has a CipherMode.CTS that looks exactly like what I need, but unfortunately it is not currently supported.
I tried to set the padding to none, but of course I've got errors because the block size is less than what it's supposed to be.
Ideas?
Edit: I've managed to solve this problem in 2 ways:
With .NET API SymmetricAlgorithm alg = new RijndaelManaged(); alg.Mode = CipherMode.CFB; alg.Padding = PaddingMode.None; alg.FeedbackSize = 8;
With BouncyCastle API's IBufferedCipher cipher = new CtsBlockCipher(new CbcBlockCipher(new AesFastEngine()));
Hope this can help others with the same problem :)