2003-05-29 Sebastien Pouliot <spouliot@videotron.ca>
authorSebastien Pouliot <sebastien@ximian.com>
Fri, 30 May 2003 01:43:17 +0000 (01:43 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Fri, 30 May 2003 01:43:17 +0000 (01:43 -0000)
* PKCS1MaskGenerationMethodTest.cs: Added [Ignore] to vector test
(as it's result isn't valid on both framework 1.0 and 1.1).
* RSAPKCS1SignatureDeformatter.cs: Splitting the test for NUnit2
cloned the previous error into many more tests. Hopefully fixed.

svn path=/trunk/mcs/; revision=14999

mcs/class/corlib/Test/System.Security.Cryptography/ChangeLog
mcs/class/corlib/Test/System.Security.Cryptography/PKCS1MaskGenerationMethodTest.cs
mcs/class/corlib/Test/System.Security.Cryptography/RSAPKCS1SignatureDeformatterTest.cs

index 277d0b1867eae4baef8a179a3390403bd895adad..ea558674891bd2c958c3a32ccc088852d0f6c8f4 100644 (file)
@@ -1,3 +1,10 @@
+2003-05-29  Sebastien Pouliot  <spouliot@videotron.ca>
+
+       * PKCS1MaskGenerationMethodTest.cs: Added [Ignore] to vector test
+       (as it's result isn't valid on both framework 1.0 and 1.1).
+       * RSAPKCS1SignatureDeformatter.cs: Splitting the test for NUnit2
+       cloned the previous error into many more tests. Hopefully fixed.
+
 2003-05-28  Sebastien Pouliot  <spouliot@videotron.ca>
 
        * RSAPKCS1SignatureDeformatter.cs: Fixed (well I hope so) a test
index 22527b769d2e3e8908dbd878eae7d002667d9163..3fb7f8181cce6d6771fec6e172af2daa8b40a6ed 100644 (file)
@@ -75,6 +75,7 @@ namespace MonoTests.System.Security.Cryptography {
                // This test will FAIL with MS framework 1.0 and 1.1 as their MGF1 implementation is buggy
                // see ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1-vec.zip for RSA tests vector
                [Test]
+               [Ignore ("Known to fail under MS runtime - both 1.0 and 1.1")]
                public void PKCS1v21TestVector ()
                {
                        pkcs1.HashName = "SHA1";
index aa01f363a9957d16a411d5c7e24bf66026973699..96cbd5d4d98ce0cffc0feccfb41c65f4e61af0f4 100644 (file)
@@ -142,7 +142,7 @@ namespace MonoTests.System.Security.Cryptography {
                        try {
                                // no key
                                fmt.VerifySignature (hash, shaSignature);
-                               Fail ("VerifySignature(?) no key - Expected CryptographicUnexpectedOperationException but none");
+                               Fail ("VerifySHA1SignatureWithNullKey - Expected CryptographicUnexpectedOperationException but none");
                        }
                        catch (CryptographicUnexpectedOperationException) {
                                // this was expected
@@ -151,7 +151,7 @@ namespace MonoTests.System.Security.Cryptography {
                                // this wasn't expected - but that's the result from framework 1.1
                        }
                        catch (Exception e) {
-                               Fail ("VerifySignature(?) no key - Expected CryptographicUnexpectedOperationException but got: " + e.ToString ());
+                               Fail ("VerifySHA1SignatureWithNullKey - Expected CryptographicUnexpectedOperationException but got: " + e.ToString ());
                        }
                }
 
@@ -244,13 +244,26 @@ namespace MonoTests.System.Security.Cryptography {
                }
 
                [Test]
-               [ExpectedException (typeof (CryptographicUnexpectedOperationException))]
+// v.1.0       [ExpectedException (typeof (CryptographicUnexpectedOperationException))]
+// v.1.1       [ExpectedException (typeof (NullReferenceException))]
                public void VerifySignatureHashNoKey ()
                {
                        RSAPKCS1SignatureDeformatter fmt = new RSAPKCS1SignatureDeformatter ();
                        HashAlgorithm hash = hash = SHA1.Create ();
-                       // no key
-                       fmt.VerifySignature (hash, shaSignature);
+                       try {
+                               // no key
+                               fmt.VerifySignature (hash, shaSignature);
+                               Fail ("VerifySignatureHashNoKey - Expected CryptographicUnexpectedOperationException but none");
+                       }
+                       catch (CryptographicUnexpectedOperationException) {
+                               // this was expected
+                       }
+                       catch (NullReferenceException) {
+                               // this wasn't expected - but that's the result from framework 1.1
+                       }
+                       catch (Exception e) {
+                               Fail ("VerifySignatureHashNoKey - Expected CryptographicUnexpectedOperationException but got: " + e.ToString ());
+                       }
                }
 
                [Test]
@@ -270,14 +283,27 @@ namespace MonoTests.System.Security.Cryptography {
                }
 
                [Test]
-               [ExpectedException (typeof (CryptographicUnexpectedOperationException))]
+// v.1.0       [ExpectedException (typeof (CryptographicUnexpectedOperationException))]
+// v.1.1       [ExpectedException (typeof (NullReferenceException))]
                public void VerifySignatureSHA1HashBadSignatureLength () 
                {
                        RSAPKCS1SignatureDeformatter fmt = GetDefaultDeformatter ("SHA1");
                        // wrong signature length
                        byte[] badSignature = new byte [shaSignature.Length-1];
                        HashAlgorithm hash = SHA1.Create ();
-                       Assert ("VerifySignature(SHA1, badSign)", !fmt.VerifySignature (hash, badSignature));
+                       try {
+                               fmt.VerifySignature (hash, badSignature);
+                               Fail ("VerifySignatureSHA1HashBadSignatureLength - Expected CryptographicUnexpectedOperationException but none");
+                       }
+                       catch (CryptographicUnexpectedOperationException) {
+                               // this was expected
+                       }
+                       catch (NullReferenceException) {
+                               // this wasn't expected - but that's the result from framework 1.1
+                       }
+                       catch (Exception e) {
+                               Fail ("VerifySignatureSHA1HashBadSignatureLength - Expected CryptographicUnexpectedOperationException but got: " + e.ToString ());
+                       }
                }
 
                [Test]
@@ -295,7 +321,8 @@ namespace MonoTests.System.Security.Cryptography {
                }
 
                [Test]
-               [ExpectedException (typeof (CryptographicUnexpectedOperationException))]
+// v.1.0       [ExpectedException (typeof (CryptographicUnexpectedOperationException))]
+// v.1.1       [ExpectedException (typeof (NullReferenceException))]
                public void VerifyBadSignatureMD5Hash () 
                {
                        RSAPKCS1SignatureDeformatter fmt = GetDefaultDeformatter ("MD5");
@@ -304,18 +331,43 @@ namespace MonoTests.System.Security.Cryptography {
                        Array.Copy (md5Signature, 0, badSignature, 0, badSignature.Length);
                        badSignature[0] = (byte) ~md5Signature [0];
                        HashAlgorithm hash = MD5.Create ();
-                       fmt.VerifySignature (hash, md5Signature);
+                       try {
+                               fmt.VerifySignature (hash, md5Signature);
+                               Fail ("VerifyBadSignatureMD5Hash - Expected CryptographicUnexpectedOperationException but none");
+                       }
+                       catch (CryptographicUnexpectedOperationException) {
+                               // this was expected
+                       }
+                       catch (NullReferenceException) {
+                               // this wasn't expected - but that's the result from framework 1.1
+                       }
+                       catch (Exception e) {
+                               Fail ("VerifyBadSignatureMD5Hash - Expected CryptographicUnexpectedOperationException but got: " + e.ToString ());
+                       }
                }
 
                [Test]
-               [ExpectedException (typeof (CryptographicUnexpectedOperationException))]
+// v.1.0       [ExpectedException (typeof (CryptographicUnexpectedOperationException))]
+// v.1.1       [ExpectedException (typeof (NullReferenceException))]
                public void VerifySignatureMD5HashBadSignatureLength () 
                {
                        RSAPKCS1SignatureDeformatter fmt = GetDefaultDeformatter ("MD5");
                        // wrong signature length
                        byte[] badSignature = new byte [md5Signature.Length-1];
                        HashAlgorithm hash = MD5.Create ();
-                       Assert ("VerifySignature(MD5, badSign)", !fmt.VerifySignature (hash, md5Signature));
+                       try {
+                               fmt.VerifySignature (hash, md5Signature);
+                               Fail ("VerifySignatureMD5HashBadSignatureLength - Expected CryptographicUnexpectedOperationException but none");
+                       }
+                       catch (CryptographicUnexpectedOperationException) {
+                               // this was expected
+                       }
+                       catch (NullReferenceException) {
+                               // this wasn't expected - but that's the result from framework 1.1
+                       }
+                       catch (Exception e) {
+                               Fail ("VerifySignatureMD5HashBadSignatureLength - Expected CryptographicUnexpectedOperationException but got: " + e.ToString ());
+                       }
                }
        }
 }