+2006-10-11 Atsushi Enomoto <atsushi@ximian.com>
+
+ * SignedXml.cs : when SigningMethod does not match the algorithm that
+ the key actually supports, it raises an error.
+
2006-09-22 Atsushi Enomoto <atsushi@ximian.com>
* EncryptedXml.cs : use Padding member instead of const ISO10126 (though
public void ComputeSignature ()
{
if (key != null) {
- // required before hashing
- m_signature.SignedInfo.SignatureMethod = key.SignatureAlgorithm;
+ if (m_signature.SignedInfo.SignatureMethod == null)
+ // required before hashing
+ m_signature.SignedInfo.SignatureMethod = key.SignatureAlgorithm;
+ else if (m_signature.SignedInfo.SignatureMethod != key.SignatureAlgorithm)
+ throw new CryptographicException ("Specified SignatureAlgorithm is not supported by the signing key.");
DigestReferences ();
AsymmetricSignatureFormatter signer = null;
+2006-10-11 Atsushi Enomoto <atsushi@ximian.com>
+
+ * SignedXmlTest.cs : added a test for signature method mismatch.
+
2006-09-25 Gert Driesen <drieseng@users.sourceforge.net>
* SignedXmlTest.cs: Added tests for bug #79454 and bug #79483 (marked
return signedXml;
}
+ [Test]
+ [ExpectedException (typeof (CryptographicException))]
+ public void SignatureMethodMismatch ()
+ {
+ SignedXml signedXml = MSDNSample ();
+
+ RSA key = RSA.Create ();
+ signedXml.SigningKey = key;
+ signedXml.SignedInfo.SignatureMethod = SignedXml.XmlDsigHMACSHA1Url;
+
+ // Add a KeyInfo.
+ KeyInfo keyInfo = new KeyInfo ();
+ keyInfo.AddClause (new RSAKeyValue (key));
+ signedXml.KeyInfo = keyInfo;
+
+ AssertNotNull ("SignatureMethod", signedXml.SignatureMethod);
+ // Compute the signature - causes unsupported algorithm by the key.
+ signedXml.ComputeSignature ();
+ }
+
[Test]
public void AsymmetricRSASignature ()
{