[Mono-dev] Possible Crypto bug found...

Stutzman, JL Jason @ IS jae.stutzman at L-3com.com
Thu Jul 19 13:21:43 EDT 2007

Using the sample code found below:


In the sample there is a loop that encrypts and decrypts several times.
If I add an extra encrypt in the loop before doing a decrypt:

cipherText = rijndaelKey.Encrypt(plainText);
cipherText = rijndaelKey.Encrypt(plainText);

then the Decrypt throws and exception on mono (which is not exactly
relevant, just pointing to the real problem):

System.OverflowException: Number overflow.
  at <0x00000> <unknown method>
  at (wrapper managed-to-native)
System.Object:__icall_wrapper_mono_array_new_specific (intptr,int)
  at RijndaelEnhanced.DecryptToBytes (System.Byte[] cipherTextBytes)
  at RijndaelEnhanced.Decrypt (System.Byte[] cipherTextBytes) [0x00000] 
  at RijndaelEnhancedTest.Main (System.String[] args) [0x00000] 

However if I recreate the encryptor and decryptor each time, the sample

What seems to be happening is that the decryptor is not working
properly. The reason for this error is that the array trying to be
created is a negative size :)...but that is because the salt length is
greater than the decrypted size. My point is that the sample is showing
differences between the two runtimes.

On MS I don't have to recreate the encryptor/decryptor each time. Is
this known? Is the goal for crypto stuff to work the same as MS?


More information about the Mono-devel-list mailing list