[corlib] Remove RijndaelManaged test that makes no sense with referencesource impl
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Sun, 3 Jan 2016 16:11:46 +0000 (17:11 +0100)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 4 Jan 2016 03:05:08 +0000 (04:05 +0100)
The CreateEncryptor_KeyNull and CreateDecryptor_KeyNull tests tried to verify the previous Mono
behavior of throwing a CryptographicException when a null key is passed to the methods [1].

However, with the move to referencesource this no longer happens since when a null key is passed
a random one is generated instead [2].

The existing tests passed out of pure luck because a different CryptographicException is thrown later on:

```
System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.
  at System.Security.Cryptography.RijndaelManagedTransform.DecryptData (System.Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, System.Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) [0x007b5] in /Users/alexander/dev/mono/external/referencesource/mscorlib/system/security/cryptography/rijndaelmanagedtransform.cs:751
  at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock (System.Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) [0x000bb] in /Users/alexander/dev/mono/external/referencesource/mscorlib/system/security/cryptography/rijndaelmanagedtransform.cs:336
  at MonoTests.System.Security.Cryptography.RijndaelManagedTest.CreateDecryptor_KeyNull () [0x00066] in /Users/alexander/dev/mono/mcs/class/corlib/Test/System.Security.Cryptography/RijndaelManagedTest.cs:233
```

Unfortunately, sometimes it happens with the random key that this exception *doesn't* get thrown as the padding is valid, which makes the test randomly fail on Jenkins.
Deleting those tests is the simplest fix.

[1] https://github.com/mono/mono/blob/mono-4.0.0-branch/mcs/class/corlib/System.Security.Cryptography/RijndaelManagedTransform.cs#L107
[2] https://github.com/mono/referencesource/blob/33edf60ec4d35aba11850872777c8b3a484ca484/mscorlib/system/security/cryptography/rijndaelmanaged.cs#L66

mcs/class/corlib/Test/System.Security.Cryptography/RijndaelManagedTest.cs

index 2d9795ade100389d8cf10d5248ec714903ddd60b..b7bf46057a067543d842d0f505357f19943b3ae7 100644 (file)
@@ -176,19 +176,6 @@ namespace MonoTests.System.Security.Cryptography {
                        );
                }
 
-               [Test]
-               [ExpectedException (typeof (CryptographicException))]
-               public void CreateEncryptor_KeyNull ()
-               {
-                       ICryptoTransform encryptor = aes.CreateEncryptor (null, aes.IV);
-                       byte[] data = new byte[encryptor.InputBlockSize];
-                       byte[] encdata = encryptor.TransformFinalBlock (data, 0, data.Length);
-
-                       ICryptoTransform decryptor = aes.CreateDecryptor (aes.Key, aes.IV);
-                       byte[] decdata = decryptor.TransformFinalBlock (encdata, 0, encdata.Length);
-                       // null key != SymmetricAlgorithm.Key
-               }
-
                [Test]
                public void CreateEncryptor_IvNull ()
                {
@@ -220,19 +207,6 @@ namespace MonoTests.System.Security.Cryptography {
                        // SymmetricAlgorithm Key and IV not changed by CreateEncryptor
                }
 
-               [Test]
-               [ExpectedException (typeof (CryptographicException))]
-               public void CreateDecryptor_KeyNull ()
-               {
-                       ICryptoTransform encryptor = aes.CreateEncryptor (aes.Key, aes.IV);
-                       byte[] data = new byte[encryptor.InputBlockSize];
-                       byte[] encdata = encryptor.TransformFinalBlock (data, 0, data.Length);
-
-                       ICryptoTransform decryptor = aes.CreateDecryptor (null, aes.IV);
-                       byte[] decdata = decryptor.TransformFinalBlock (encdata, 0, encdata.Length);
-                       // null key != SymmetricAlgorithm.Key
-               }
-
                [Test]
                public void CreateDecryptor_IvNull ()
                {