}
[Test]
-#if NET_2_0
[Ignore ("2.0 throws a NullReferenceException - reported as FDBK25892")]
// http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=02dd9730-d1ad-4170-8c82-36858c55fbe2
-#endif
[ExpectedException (typeof (ArgumentNullException))]
public void Constructor_XmlDocument_Null ()
{
}
[Test]
-#if !NET_2_0
- [ExpectedException (typeof (CryptographicException))]
-#endif
public void Constructor_XmlElement_WithoutLoadXml ()
{
XmlDocument doc = new XmlDocument ();
// Compute the signature.
byte[] secretkey = Encoding.Default.GetBytes ("password");
HMACSHA1 hmac = new HMACSHA1 (secretkey);
-#if NET_2_0
Assert.AreEqual (0, signedXml.KeyInfo.Count, "KeyInfo");
-#else
- Assert.IsNull (signedXml.KeyInfo, "KeyInfo");
-#endif
Assert.IsNull (signedXml.SignatureLength, "SignatureLength");
Assert.IsNull (signedXml.SignatureMethod, "SignatureMethod");
Assert.IsNull (signedXml.SignatureValue, "SignatureValue");
signedXml.ComputeSignature (hmac);
-#if NET_2_0
Assert.AreEqual (0, signedXml.KeyInfo.Count, "KeyInfo");
-#else
- Assert.IsNull (signedXml.KeyInfo, "KeyInfo");
-#endif
Assert.IsNull (signedXml.SignatureLength, "SignatureLength");
Assert.AreEqual (SignedXml.XmlDsigHMACSHA1Url, signedXml.SignatureMethod, "SignatureMethod");
Assert.AreEqual (20, signedXml.SignatureValue.Length, "SignatureValue");
AsymmetricAlgorithm aa2 = sxe.PublicGetPublicKey ();
Assert.IsNull (aa2, "Second Public Key is null");
}
-#if NET_2_0
[Test]
// [ExpectedException (typeof (ArgumentNullException))]
public void AddObject_Null ()
SignedXml sx = new SignedXml ();
sx.AddReference (null);
}
-#else
- [Test]
- public void Add_Null ()
- {
- SignedXml sx = new SignedXml ();
- // no ArgumentNull exceptions for those
- sx.AddObject (null);
- sx.AddReference (null);
- }
-#endif
[Test]
[ExpectedException (typeof (CryptographicException))]
public void GetXml_WithoutInfo ()
}
[Test]
-#if !NET_2_0
- [ExpectedException (typeof (CryptographicException))]
-#endif
public void CheckSignatureEmpty ()
{
SignedXml sx = new SignedXml ();
Assert.IsNull (sign.GetIdElement (new XmlDocument (), null));
}
-#if NET_2_0
[Test]
[Category ("NotWorking")] // bug #79483
public void DigestValue_CRLF ()
// verify MS-generated signature
Assert.IsTrue (sign.CheckSignature (new HMACRIPEMD160 (hmackey)));
}
-#endif
// CVE-2009-0217
// * a 0-length signature is the worse case - it accepts anything
// * between 1-7 bits length are considered invalid (not a multiple of 8)
SignedXml sign = GetSignedXml (xml);
Assert.IsTrue (sign.CheckSignature (new HMACSHA1 (Encoding.ASCII.GetBytes ("secret"))));
}
-#if NET_2_0
[Test]
[Category ("NotDotNet")] // will fail until a fix is available
public void VerifyHMAC_SmallerHalfLength ()
SignedXml sign = GetSignedXml (xml);
Assert.IsTrue (sign.CheckSignature (new HMACSHA256 (Encoding.ASCII.GetBytes ("secret"))));
}
-#endif
[Test]
public void VerifyHMAC_FullLength ()
{