+2007-01-12 Atsushi Enomoto <atsushi@ximian.com>
+
+ * SignedXml.cs : actually ComputeSignature() itself does not raise
+ silly exception. It always use CryptographicException.
+ Added another check; malformed reference object.
+
2007-01-12 Atsushi Enomoto <atsushi@ximian.com>
* SignedXml.cs : ComputeSignature() should check empty key.
}
}
if (objectName != null) {
+ bool found = false;
foreach (DataObject obj in m_signature.ObjectList) {
if (obj.Id == objectName) {
XmlElement xel = obj.GetXml ();
doc.LoadXml (xel.OuterXml);
FixupNamespaceNodes (xel, doc.DocumentElement);
+ found = true;
break;
}
}
+ if (!found)
+ throw new CryptographicException (String.Format ("Malformed reference object: {0}", objectName));
}
}
}
}
else
-#if NET_2_0 // correct
throw new CryptographicException ("signing key is not specified");
-#else // silly
- throw new ArgumentNullException ("signing key is not specified");
-#endif
}
public void ComputeSignature (KeyedHashAlgorithm macAlg)
+2007-01-12 Atsushi Enomoto <atsushi@ximian.com>
+
+ * SignedXmlTest.cs : fixed ComputeSignatureNoSigningKey() to not
+ expect silly exception. Added test for malformed reference.
+
2007-01-12 Atsushi Enomoto <atsushi@ximian.com>
* SignedXmlTest.cs : added ComputeSignatureNoSigningKey().
}
[Test]
-#if NET_2_0
- [ExpectedException (typeof (CryptographicException))] // correct
-#else
- [ExpectedException (typeof (ArgumentNullException))] // silly
-#endif
+ [ExpectedException (typeof (CryptographicException))]
public void ComputeSignatureNoSigningKey ()
{
- SignedXml signedXml = new SignedXml (new XmlDocument ());
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<foo/>");
+ SignedXml signedXml = new SignedXml (doc);
Reference reference = new Reference ();
reference.Uri = "";
signedXml.ComputeSignature ();
}
+ [Test]
+ [ExpectedException (typeof (CryptographicException))]
+ public void ComputeSignatureMissingReferencedObject ()
+ {
+ XmlDocument doc = new XmlDocument ();
+ doc.LoadXml ("<foo/>");
+ SignedXml signedXml = new SignedXml (doc);
+ DSA key = DSA.Create ();
+ signedXml.SigningKey = key;
+
+ Reference reference = new Reference ();
+ reference.Uri = "#bleh";
+
+ XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform ();
+ reference.AddTransform (env);
+ signedXml.AddReference (reference);
+
+ signedXml.ComputeSignature ();
+ }
+
#if NET_2_0
[Test]
[Category ("NotWorking")] // bug #79483