2006-07-01 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Sat, 1 Jul 2006 14:50:36 +0000 (14:50 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Sat, 1 Jul 2006 14:50:36 +0000 (14:50 -0000)
* RSAPKCS1SignatureDeformatterTest.cs: Added test case where
SetHashAlgorithm isn't called and the hash algorithm name is derived
from the hash instance. From bug #78744 by Diego Mesa Tabares.

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

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

index 6a2cb6e3f2c236d318a78c36709b3a09eec8f550..4fa5797ea6296c3b5da36004a6840866aa692770 100644 (file)
@@ -1,3 +1,9 @@
+2006-07-01  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * RSAPKCS1SignatureDeformatterTest.cs: Added test case where 
+       SetHashAlgorithm isn't called and the hash algorithm name is derived
+       from the hash instance. From bug #78744 by Diego Mesa Tabares.
+
 2006-06-15  Sebastien Pouliot  <sebastien@ximian.com>
 
        * HashAlgorithmTest.cs: Added new test cases wrt the output buffer 
index a1060f6498770d44d85b2d6fb140d3b9a67ec260..430a323b57702fa7b18fcb27f91f3675a7dc4571 100644 (file)
@@ -5,12 +5,13 @@
 //     Sebastien Pouliot (sebastien@ximian.com)
 //
 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// (C) 2004 Novell (http://www.novell.com)
+// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
 //
 
 using NUnit.Framework;
 using System;
 using System.Security.Cryptography;
+using System.Text;
 
 namespace MonoTests.System.Security.Cryptography {
 
@@ -296,7 +297,7 @@ namespace MonoTests.System.Security.Cryptography {
                public void VerifySignatureHashNoKey ()
                {
                        RSAPKCS1SignatureDeformatter fmt = new RSAPKCS1SignatureDeformatter ();
-                       HashAlgorithm hash = hash = SHA1.Create ();
+                       HashAlgorithm hash = SHA1.Create ();
                        try {
                                // no key
                                fmt.VerifySignature (hash, shaSignature);
@@ -414,5 +415,19 @@ namespace MonoTests.System.Security.Cryptography {
                                Fail ("VerifySignatureMD5HashBadSignatureLength - Expected CryptographicUnexpectedOperationException but got: " + e.ToString ());
                        }
                }
+
+               [Test]
+               public void VerifySignatureWithoutCallingSetHashAlgorithm ()
+               {
+                       string text = "text to sign";
+                       RSA rsa = RSA.Create ();
+                       RSAPKCS1SignatureFormatter fmt = new RSAPKCS1SignatureFormatter (rsa);
+                       SHA1 hash = SHA1.Create ();
+                       hash.ComputeHash (Encoding.UTF8.GetBytes (text));
+                       byte[] signature = fmt.CreateSignature (hash);
+
+                       RSAPKCS1SignatureDeformatter def = new RSAPKCS1SignatureDeformatter (rsa);
+                       Assert ("Signature Ok", def.VerifySignature (hash, signature));
+               }
        }
 }