+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
// 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 {
public void VerifySignatureHashNoKey ()
{
RSAPKCS1SignatureDeformatter fmt = new RSAPKCS1SignatureDeformatter ();
- HashAlgorithm hash = hash = SHA1.Create ();
+ HashAlgorithm hash = SHA1.Create ();
try {
// no key
fmt.VerifySignature (hash, shaSignature);
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));
+ }
}
}