X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FTest%2FSystem.Security.Cryptography%2FTripleDESCryptoServiceProviderTest.cs;h=7f3190c62d8c166208aa4f20682c460a0022fcc0;hb=261e0ba03b1220de78dad6882270e7ca14b88069;hp=4c43000496d42a3df6900f76d8740a8a211d00b1;hpb=2007998771b1c4d9e762943676d7959daaf74385;p=mono.git diff --git a/mcs/class/corlib/Test/System.Security.Cryptography/TripleDESCryptoServiceProviderTest.cs b/mcs/class/corlib/Test/System.Security.Cryptography/TripleDESCryptoServiceProviderTest.cs index 4c43000496d..7f3190c62d8 100644 --- a/mcs/class/corlib/Test/System.Security.Cryptography/TripleDESCryptoServiceProviderTest.cs +++ b/mcs/class/corlib/Test/System.Security.Cryptography/TripleDESCryptoServiceProviderTest.cs @@ -60,6 +60,12 @@ namespace MonoTests.System.Security.Cryptography { ICryptoTransform decryptor = tdes.CreateDecryptor (tdes.Key, tdes.IV); byte[] decdata = decryptor.TransformFinalBlock (encdata, 0, encdata.Length); // null key != SymmetricAlgorithm.Key + + // in about 1 out of 256 runs the exception will not be thrown because the padding will be + // the same as expected - however this still won't produce the right results (next check) + Assert.IsFalse (BitConverter.ToString (data) == BitConverter.ToString (decdata), "Compare"); + // so this case is ok too, throw the expected exception to make the unit test succeed + throw new CryptographicException ("1/256"); } [Test] @@ -108,6 +114,12 @@ namespace MonoTests.System.Security.Cryptography { ICryptoTransform decryptor = tdes.CreateDecryptor (null, tdes.IV); byte[] decdata = decryptor.TransformFinalBlock (encdata, 0, encdata.Length); // null key != SymmetricAlgorithm.Key + + // in about 1 out of 256 runs the exception will not be thrown because the padding will be + // the same as expected - however this still won't produce the right results (next check) + Assert.IsFalse (BitConverter.ToString (data) == BitConverter.ToString (decdata), "Compare"); + // so this case is ok too, throw the expected exception to make the unit test succeed + throw new CryptographicException ("1/256"); } [Test]