views:

178

answers:

3

Hello There, I am using AES encryption algorithm (Rijndael implementation). I am using MS Visual Studio 2008 IDE for my development work. I could see a strange problem in my Debug and Release mode. When I encrypt a string in Debug mode it generates different bytes than Release mode. But fortunately decrypting will result same string. I have tried in Mac, it generates one more byte sequence but able to decrypt all byte sequences correctly.

Is this problem related to encryption algorithm or Debug/Release settings? Is there any solution to avoid this?

Regards Devara Gudda

A: 

You should verify the difference between your "release" and "debug" settings, the most problems occour at "Configuration Properties -> C/C++ -> Code Generation" and also the "Character Set" under "Configuration Properties -> General".

I have my implementation of AES and it compiles fine under both default configurations of VC2008.

Douglas Gemignani
A: 

You might want to verify how you're specifying buffer sizes for the plain text/cipher text. In debug builds the compiler usually initializes buffers to a known value (to detect overflow errors typically). In VC++ 2008 Express for instance, I find that char buffers are initialized to 0xCD in debug builds. In release builds of course, no such thing is done. I am not saying this is the cause for what you are observing - just something you might want to check out.

Ranju V
+2  A: 

AES is a block cipher. You can encrypt and decrypt blocks of a fixed size of 128 bits with it. To encrypt and decrypt longer sequences you typically use a certain "mode of operation" and a certain "padding scheme" which both might involve some randonmess via the IV (initialization vector) and padding. In those cases the cipher text will be a bit longer and different each time due to the "randomness" that is involved. Actually, it's not a bad property that the same message encrypts to different cipher texts. You even need this to protect yourself from certain attacks.

sellibitze