2002-11-20 Sebastien Pouliot <spouliot@videotron.ca>
authorSebastien Pouliot <sebastien@ximian.com>
Thu, 21 Nov 2002 02:30:39 +0000 (02:30 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Thu, 21 Nov 2002 02:30:39 +0000 (02:30 -0000)
* AllTests.cs: New. Added suites for very listed files.
* DataObjectTest.cs: New. Test suite for DataObject.
* DSAKeyValueTest.cs: New. Test suite for DSAKeyValue.
* KeyInfoNameTest.cs: New. Test suite for KeyInfoName.
* KeyInfoNodeTest.cs: New. Test suite for KeyInfoNode.
* KeyInfoRetrievalMethodTest.cs: New. Test suite for DSAKeyValue.
* KeyInfoTest.cs: New. Test suite for KeyInfo.
* KeyInfoX509DataTest.cs: New. Test suite for KeyInfoX509Data.
* ReferenceTest.cs: New. Incomplete test suite for Reference.
* RSAKeyValueTest.cs: New. Test suite for RSAKeyValue.
* SignatureTest.cs: New. Partial test suite for Signature.
* SignedInfoTest.cs: New. Partial test suite for SignedInfo.
* SignedXmlTest.cs: New. Partial test suite for SignedXml.
* TransformChainTest.cs: New. Test suite for TransformChain.
* XmlDsigBase64TransformTest.cs: New. Partial test suite for
XmlDsigBase64Transform
* XmlDsigXsltTransformTest.cs: New. Partial test suite for
XmlDsigXsltTransform.

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

17 files changed:
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/AllTests.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DSAKeyValueTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataObjectTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNameTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNodeTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoX509DataTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/RSAKeyValueTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformChainTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigBase64TransformTest.cs [new file with mode: 0644]
mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXsltTransformTest.cs [new file with mode: 0644]

diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/AllTests.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/AllTests.cs
new file mode 100644 (file)
index 0000000..3772a36
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// TestSuite.System.Security.Cryptography.Xml.AllTests.cs
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using System;
+using System.Security.Cryptography;
+using NUnit.Framework;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class AllTests : TestCase {
+
+       public AllTests (string name) : base (name) {}
+        
+       // because most crypto stuff works with byte[] buffers
+       static public void AssertEquals (string msg, byte[] array1, byte[] array2) 
+       {
+               if ((array1 == null) && (array2 == null))
+                       return;
+               if (array1 == null)
+                       Fail (msg + " -> First array is NULL");
+               if (array2 == null)
+                       Fail (msg + " -> Second array is NULL");
+
+               bool a = (array1.Length == array2.Length);
+               if (a) {
+                       for (int i = 0; i < array1.Length; i++) {
+                               if (array1 [i] != array2 [i]) {
+                                       a = false;
+                                       break;
+                               }
+                       }
+               }
+               msg += " -> Expected " + BitConverter.ToString (array1, 0);
+               msg += " is different than " + BitConverter.ToString (array2, 0);
+               Assert (msg, a);
+       }
+
+       public static ITest Suite { 
+               get {
+                       TestSuite suite =  new TestSuite ();
+                       suite.AddTest (DSAKeyValueTest.Suite);
+                       suite.AddTest (KeyInfoNameTest.Suite);
+                       suite.AddTest (KeyInfoNodeTest.Suite);
+                       suite.AddTest (KeyInfoRetrievalMethodTest.Suite);
+                       suite.AddTest (KeyInfoX509DataTest.Suite);
+                       suite.AddTest (ReferenceTest.Suite);
+                       suite.AddTest (RSAKeyValueTest.Suite);
+                       return suite;
+               }
+       }
+}
+}
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog
new file mode 100644 (file)
index 0000000..75e2ef4
--- /dev/null
@@ -0,0 +1,20 @@
+2002-11-20  Sebastien Pouliot  <spouliot@videotron.ca>
+
+       * AllTests.cs: New. Added suites for very listed files.
+       * DataObjectTest.cs: New. Test suite for DataObject.
+       * DSAKeyValueTest.cs: New. Test suite for DSAKeyValue.
+       * KeyInfoNameTest.cs: New. Test suite for KeyInfoName.
+       * KeyInfoNodeTest.cs: New. Test suite for KeyInfoNode.
+       * KeyInfoRetrievalMethodTest.cs: New. Test suite for DSAKeyValue.
+       * KeyInfoTest.cs: New. Test suite for KeyInfo.
+       * KeyInfoX509DataTest.cs: New. Test suite for KeyInfoX509Data.
+       * ReferenceTest.cs: New. Incomplete test suite for Reference.
+       * RSAKeyValueTest.cs: New. Test suite for RSAKeyValue.
+       * SignatureTest.cs: New. Partial test suite for Signature.
+       * SignedInfoTest.cs: New. Partial test suite for SignedInfo.
+       * SignedXmlTest.cs: New. Partial test suite for SignedXml.
+       * TransformChainTest.cs: New. Test suite for TransformChain.
+       * XmlDsigBase64TransformTest.cs: New. Partial test suite for 
+       XmlDsigBase64Transform
+       * XmlDsigXsltTransformTest.cs: New. Partial test suite for 
+       XmlDsigXsltTransform.
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DSAKeyValueTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DSAKeyValueTest.cs
new file mode 100644 (file)
index 0000000..28c9b18
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// DSAKeyValueTest.cs - NUnit Test Cases for DSAKeyValue
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class DSAKeyValueTest : TestCase {
+
+       public DSAKeyValueTest () : base ("System.Security.Cryptography.Xml.DSAKeyValue testsuite") {}
+       public DSAKeyValueTest (string name) : base (name) {}
+
+       protected override void SetUp () {}
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (DSAKeyValueTest)); 
+               }
+       }
+
+       public void TestGeneratedKey () 
+       {
+               DSAKeyValue dsa1 = new DSAKeyValue ();
+               AssertNotNull ("Key", dsa1.Key);
+               XmlElement xmlkey = dsa1.GetXml ();
+
+               DSAKeyValue dsa2 = new DSAKeyValue ();
+               dsa2.LoadXml (xmlkey);
+
+               Assert ("dsa1==dsa2", (dsa1.GetXml ().OuterXml) == (dsa2.GetXml ().OuterXml));
+
+               DSA key = dsa1.Key;
+               DSAKeyValue dsa3 = new DSAKeyValue (key);
+               Assert ("dsa3==dsa1", (dsa3.GetXml ().OuterXml) == (dsa1.GetXml ().OuterXml));
+               Assert ("dsa3==dsa2", (dsa3.GetXml ().OuterXml) == (dsa2.GetXml ().OuterXml));
+       }
+
+       public void TestImportKey () 
+       {
+               string dsaKey = "<KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><DSAKeyValue><P>xc+QZRWTgr390gzwNXF+WzoepZkvAQvCzfCm+YyXj0KPoeHHeSc5ORzXQw81V+7XJR3gupvlI4F7lW9YC538l+3eqGm8IQlCIS+U+7ICTDOFFKevqsYX0BnjO0vvE4aAtDyxfSOTCOAo1cJ+6G6xgcC1JGIBEYCtg1tH8wUewDE=</P><Q>yyfZb0S/rimXl9ScJ3zIba2oGl8=</Q><G>crLazMg+vgI7u6+Idgi9iTLdRa4fptat3gdY97zcc857+OVdmT+lVRpK3okWpmBbw2wSffU8QltwFf42BVs+/HGUOUo2hNqSSXgzl1i+1frO7/cqooHVcy5WX0xxaIPsKcREPI5pNPj/3g8apTgErLMGsHkFdngwbMed9DArTks=</G><Y>FlAozo17wV/LCMRrtnmMKxVQNpidJVkZNM1/0eR65x8giwPs6yXzJmFT8f2tmPJY2FIOAtp5JYin4xUhwIHF452Gg50wUrjV6WTGkiC+gzLC2fVIyGlVsFecLj6ue7J+MACG+b3NQnxFuT5maQnPnEeuGgjLXfwYsAR1vfU0Gas=</Y><J>+UPMvUPq9Fo6Q1fr2oEYDxfGMMtfdoQmVBxI+TkUYQsReodRzBbnvGV1uPLWTpKKd/uJNUHO/QGb05Cvc6u49/AToDJIyi4e01hTLNCzeQk/Hj19gowb5wkTIjyaH04VyPE5zYoTYfuu3Y3Q</J><Seed>+cvoO7bzdpAwAjnDDApPzBCl6zg=</Seed><PgenCounter>ATM=</PgenCounter></DSAKeyValue></KeyValue>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (dsaKey);
+
+               DSAKeyValue dsa1 = new DSAKeyValue ();
+               dsa1.LoadXml (doc.DocumentElement);
+
+               string s = (dsa1.GetXml ().OuterXml);
+               AssertEquals ("DSA Key", dsaKey, s);
+       }
+
+       public void TestInvalidValue () 
+       {
+               string badKey = "<Test></Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (badKey);
+
+               DSAKeyValue dsa1 = new DSAKeyValue ();
+
+               try {
+                       dsa1.LoadXml (null);
+                       Fail ("Expected ArgumentNullException but got none");
+               }
+               catch (ArgumentNullException) {
+                       // this is what we expect
+               }
+               catch (Exception e) {
+                       Fail ("Expected ArgumentNullException but got: " + e.ToString ());
+               }
+
+               try {
+                       dsa1.LoadXml (doc.DocumentElement);
+                       Fail ("Expected CryptographicException but got none");
+               }
+               catch (CryptographicException) {
+                       // this is what we expect
+               }
+               catch (Exception e) {
+                       Fail ("Expected CryptographicException but got: " + e.ToString ());
+               }
+       }
+}
+
+}
\ No newline at end of file
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataObjectTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataObjectTest.cs
new file mode 100644 (file)
index 0000000..362fa0c
--- /dev/null
@@ -0,0 +1,139 @@
+//
+// DataObjectTest.cs - NUnit Test Cases for DataObject
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class DataObjectTest : TestCase {
+
+       public DataObjectTest () : base ("System.Security.Cryptography.Xml.DataObject testsuite") {}
+       public DataObjectTest (string name) : base (name) {}
+
+       protected override void SetUp () {}
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (DataObjectTest)); 
+               }
+       }
+
+       public void TestNewDataObject () 
+       {
+               string test = "<Test>DataObject</Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (test);
+
+               DataObject obj1 = new DataObject ();
+               Assert ("Data.Count==0", (obj1.Data.Count == 0));
+
+               obj1.Id = "id";
+               obj1.MimeType = "mime";
+               obj1.Encoding = "encoding";
+               AssertEquals ("Only attributes", "<Object Id=\"id\" MimeType=\"mime\" Encoding=\"encoding\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (obj1.GetXml ().OuterXml));
+
+               obj1.Data = doc.ChildNodes;
+               Assert ("Data.Count==1", (obj1.Data.Count == 1));
+
+               XmlElement xel = obj1.GetXml ();
+
+               DataObject obj2 = new DataObject ();
+               obj2.LoadXml (xel);
+               AssertEquals ("obj1==obj2", (obj1.GetXml ().OuterXml), (obj2.GetXml ().OuterXml));
+
+               DataObject obj3 = new DataObject (obj1.Id, obj1.MimeType, obj1.Encoding, doc.DocumentElement);
+               AssertEquals ("obj2==obj3", (obj2.GetXml ().OuterXml), (obj3.GetXml ().OuterXml));
+       }
+
+       public void TestImportDataObject () 
+       {
+               string value1 = "<Object Id=\"id\" MimeType=\"mime\" Encoding=\"encoding\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Test xmlns=\"\">DataObject1</Test><Test xmlns=\"\">DataObject2</Test></Object>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value1);
+
+               DataObject obj1 = new DataObject ();
+               obj1.LoadXml (doc.DocumentElement);
+               Assert ("Data.Count==2", (obj1.Data.Count == 2));
+
+               string s = (obj1.GetXml ().OuterXml);
+               AssertEquals ("DataObject 1", value1, s);
+
+               string value2 = "<Object xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Test xmlns=\"\" /></Object>";
+               doc = new XmlDocument ();
+               doc.LoadXml (value2);
+
+               DataObject obj2 = new DataObject ();
+               obj2.LoadXml (doc.DocumentElement);
+
+               s = (obj2.GetXml ().OuterXml);
+               AssertEquals ("DataObject 2", value2, s);
+
+               string value3 = "<Object Id=\"id\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Test xmlns=\"\" /></Object>";
+               doc = new XmlDocument ();
+               doc.LoadXml (value3);
+
+               DataObject obj3 = new DataObject ();
+               obj3.LoadXml (doc.DocumentElement);
+
+               s = (obj3.GetXml ().OuterXml);
+               AssertEquals ("DataObject 3", value3, s);
+
+               string value4 = "<Object MimeType=\"mime\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Test xmlns=\"\" /></Object>";
+               doc = new XmlDocument ();
+               doc.LoadXml (value4);
+
+               DataObject obj4 = new DataObject ();
+               obj4.LoadXml (doc.DocumentElement);
+
+               s = (obj4.GetXml ().OuterXml);
+               AssertEquals ("DataObject 4", value4, s);
+       }
+
+       public void TestInvalidDataObject () 
+       {
+               DataObject obj1 = new DataObject ();
+               try {
+                       obj1.Data = null;
+                       Fail ("Expected ArgumentNullException but none");
+               }
+               catch (ArgumentNullException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("Expected ArgumentNullException but got: " + e.ToString ());
+               }
+
+               try {
+                       obj1.LoadXml (null);
+                       Fail ("Expected ArgumentNullException but none");
+               }
+               catch (ArgumentNullException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("Expected ArgumentNullException but got: " + e.ToString ());
+               }
+
+               // seems this isn't invalid !?!
+               string value = "<Test>Bad</Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+               obj1.LoadXml (doc.DocumentElement);
+               string s = (obj1.GetXml ().OuterXml);
+               AssertEquals ("DataObject Bad", value, s);
+       }
+}
+
+}
\ No newline at end of file
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNameTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNameTest.cs
new file mode 100644 (file)
index 0000000..4280d15
--- /dev/null
@@ -0,0 +1,82 @@
+//
+// KeyInfoNameTest.cs - NUnit Test Cases for KeyInfoName
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class KeyInfoNameTest : TestCase {
+
+       public KeyInfoNameTest () : base ("System.Security.Cryptography.Xml.KeyInfoName testsuite") {}
+       public KeyInfoNameTest (string name) : base (name) {}
+
+       protected override void SetUp () {}
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (KeyInfoNameTest)); 
+               }
+       }
+
+       public void TestNewKeyValue () 
+       {
+               string newKeyValue = "Mono::";
+               KeyInfoName name1 = new KeyInfoName ();
+               name1.Value = newKeyValue;
+               XmlElement xel = name1.GetXml ();
+
+               KeyInfoName name2 = new KeyInfoName ();
+               name2.LoadXml (xel);
+
+               AssertEquals ("name1==name2", (name1.GetXml ().OuterXml), (name2.GetXml ().OuterXml));
+               AssertEquals ("newKeyValue==value", newKeyValue, name1.Value);
+       }
+
+       public void TestImportKeyValue () 
+       {
+               string value = "<KeyName xmlns=\"http://www.w3.org/2000/09/xmldsig#\">Mono::</KeyName>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+
+               KeyInfoName name1 = new KeyInfoName ();
+               name1.LoadXml (doc.DocumentElement);
+
+               string s = (name1.GetXml ().OuterXml);
+               AssertEquals ("Name", value, s);
+       }
+
+       public void TestInvalidValue () 
+       {
+               string bad = "<Test></Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (bad);
+
+               KeyInfoName name1 = new KeyInfoName ();
+               try {
+                       name1.LoadXml (null);
+                       Fail ("Expected ArgumentNullException but got none");
+               }
+               catch (ArgumentNullException) {
+                       // this is what we expect
+               }
+               catch (Exception e) {
+                       Fail ("Expected ArgumentNullException but got: " + e.ToString ());
+               }
+               name1.LoadXml (doc.DocumentElement);
+               AssertEquals("invalid", "<KeyName xmlns=\"http://www.w3.org/2000/09/xmldsig#\"></KeyName>", (name1.GetXml ().OuterXml));
+       }
+}
+
+}
\ No newline at end of file
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNodeTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNodeTest.cs
new file mode 100644 (file)
index 0000000..3a1a94f
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// KeyInfoNodeTest.cs - NUnit Test Cases for KeyInfoNode
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class KeyInfoNodeTest : TestCase {
+
+       public KeyInfoNodeTest () : base ("System.Security.Cryptography.Xml.KeyInfoNode testsuite") {}
+       public KeyInfoNodeTest (string name) : base (name) {}
+
+       protected override void SetUp () {}
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (KeyInfoNodeTest)); 
+               }
+       }
+
+       public void TestNewKeyNode () 
+       {
+               string test = "<Test></Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (test);
+
+               KeyInfoNode node1 = new KeyInfoNode ();
+               node1.Value = doc.DocumentElement;
+               XmlElement xel = node1.GetXml ();
+
+               KeyInfoNode node2 = new KeyInfoNode (node1.Value);
+               node2.LoadXml (xel);
+
+               AssertEquals ("node1==node2", (node1.GetXml ().OuterXml), (node2.GetXml ().OuterXml));
+       }
+
+       public void TestImportKeyNode () 
+       {
+               // Note: KeyValue is a valid KeyNode
+               string value = "<KeyName xmlns=\"http://www.w3.org/2000/09/xmldsig#\">Mono::</KeyName>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+
+               KeyInfoNode node1 = new KeyInfoNode ();
+               node1.LoadXml (doc.DocumentElement);
+
+               string s = (node1.GetXml ().OuterXml);
+               AssertEquals ("Node", value, s);
+       }
+
+       // well there's no invalid value - unless you read the doc ;-)
+       public void TestInvalidKeyNode () 
+       {
+               string bad = "<Test></Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (bad);
+
+               KeyInfoNode node1 = new KeyInfoNode ();
+               // LAMESPEC: No ArgumentNullException is thrown if value == null
+               node1.LoadXml (null);
+               AssertNull ("Value==null", node1.Value);
+       }
+}
+
+}
\ No newline at end of file
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs
new file mode 100644 (file)
index 0000000..4062590
--- /dev/null
@@ -0,0 +1,92 @@
+//
+// KeyInfoRetrievalMethodTest.cs - NUnit Test Cases for KeyInfoRetrievalMethod
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class KeyInfoRetrievalMethodTest : TestCase {
+
+       public KeyInfoRetrievalMethodTest () : base ("System.Security.Cryptography.Xml.KeyInfoRetrievalMethod testsuite") {}
+       public KeyInfoRetrievalMethodTest (string name) : base (name) {}
+
+       protected override void SetUp () {}
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (KeyInfoRetrievalMethodTest)); 
+               }
+       }
+
+       public void TestNewKeyNode () 
+       {
+               string uri = "http://www.go-mono.com/";
+               KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
+
+               // verify empty XML
+               AssertEquals ("Empty", "<RetrievalElement xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));
+
+               uri1.Uri = uri;
+               XmlElement xel = uri1.GetXml ();
+
+               KeyInfoRetrievalMethod uri2 = new KeyInfoRetrievalMethod (uri1.Uri);
+               uri2.LoadXml (xel);
+
+               AssertEquals ("uri1==uri2", (uri1.GetXml ().OuterXml), (uri2.GetXml ().OuterXml));
+               AssertEquals ("uri==Uri", uri, uri1.Uri);
+       }
+
+       public void TestImportKeyNode () 
+       {
+               string value = "<RetrievalElement URI=\"http://www.go-mono.com/\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+
+               KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
+               uri1.LoadXml (doc.DocumentElement);
+
+               // verify that proper XML is generated (equals to original)
+               string s = (uri1.GetXml ().OuterXml);
+               AssertEquals ("Xml", value, s);
+
+               // verify that property is parsed correctly
+               AssertEquals ("Uri", "http://www.go-mono.com/", uri1.Uri);
+       }
+
+       public void TestInvalidKeyNode () 
+       {
+               KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
+               try {
+                       uri1.LoadXml (null);
+                       Fail ("Expected ArgumentNullException but got none");
+               }
+               catch (ArgumentNullException) {
+                       // this is what we expect
+               }
+               catch (Exception e) {
+                       Fail ("Expected ArgumentNullException but got: " + e.ToString ());
+               }
+
+               string bad = "<Test></Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (bad);
+               // no exception is thrown
+               uri1.LoadXml (doc.DocumentElement);
+               // note that URI="" is present (unlike a empty Uri)
+               AssertEquals("invalid", "<RetrievalElement URI=\"\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));
+       }
+}
+
+}
\ No newline at end of file
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs
new file mode 100644 (file)
index 0000000..47949ea
--- /dev/null
@@ -0,0 +1,205 @@
+//
+// KeyInfoTest.cs - NUnit Test Cases for KeyInfo
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class KeyInfoTest : TestCase {
+
+       public KeyInfoTest () : base ("System.Security.Cryptography.Xml.KeyInfo testsuite") {}
+       public KeyInfoTest (string name) : base (name) {}
+
+       private KeyInfo info;
+
+
+       protected override void SetUp () 
+       {
+               info = new KeyInfo ();
+       }
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (KeyInfoTest)); 
+               }
+       }
+
+       public void TestEmptyKeyInfo () 
+       {
+               AssertEquals ("empty", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (info.GetXml ().OuterXml));
+               AssertEquals ("empty count", 0, info.Count);
+       }
+
+       public void TestKeyInfoName () 
+       {
+               KeyInfoName name = new KeyInfoName ();
+               name.Value = "Mono::";
+               info.AddClause (name);
+               AssertEquals ("name", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyName>Mono::</KeyName></KeyInfo>", (info.GetXml ().OuterXml));
+               AssertEquals ("name count", 1, info.Count);
+       }
+
+       public void TestKeyInfoNode () 
+       {
+               string test = "<Test>KeyInfoNode</Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (test);
+
+               KeyInfoNode node = new KeyInfoNode (doc.DocumentElement);
+               info.AddClause (node);
+               AssertEquals ("node", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Test xmlns=\"\">KeyInfoNode</Test></KeyInfo>", (info.GetXml ().OuterXml));
+               AssertEquals ("node count", 1, info.Count);
+       }
+
+       string xmlDSA = "<DSAKeyValue><P>rjxsMU368YOCTQejWkiuO9e/vUVwkLtq1jKiU3TtJ53hBJqjFRuTa228vZe+BH2su9RPn/vYFWfQDv6zgBYe3eNdu4Afw+Ny0FatX6dl3E77Ra6Tsd3MmLXBiGSQ1mMNd5G2XQGpbt9zsGlUaexXekeMLxIufgfZLwYp67M+2WM=</P><Q>tf0K9rMyvUrU4cIkwbCrDRhQAJk=</Q><G>S8Z+1pGCed00w6DtVcqZLKjfqlCJ7JsugEFIgSy/Vxtu9YGCMclV4ijGEbPo/jU8YOSMuD7E9M7UaopMRcmKQjoKZzoJjkgVFP48Ohxl1f08lERnButsxanx3+OstFwUGQ8XNaGg3KrIoZt1FUnfxN3RHHTvVhjzNSHxMGULGaU=</G><Y>LnrxxRGLYeV2XLtK3SYz8RQHlHFZYrtznDZyMotuRfO5uC5YODhSFyLXvb1qB3WeGtF4h3Eo4KzHgMgfN2ZMlffxFRhJgTtH3ctbL8lfQoDkjeiPPnYGhspdJxr0tyZmiy0gkjJG3vwHYrLnvZWx9Wm/unqiOlGBPNuxJ+hOeP8=</Y><J>9RhE5TycDtdEIXxS3HfxFyXYgpy81zY5lVjwD6E9JP37MWEi80BlX6ab1YPm6xYSEoqReMPP9RgGiW6DuACpgI7+8vgCr4i/7VhzModJAA56PwvTu6UMt9xxKU/fT672v8ucREkMWoc7lEey</J><Seed>HxW3N4RHWVgqDQKuGg7iJTUTiCs=</Seed><PgenCounter>Asw=</PgenCounter></DSAKeyValue>";
+
+       public void TestDSAKeyValue () 
+       {
+               DSA key = DSA.Create ();
+               key.FromXmlString (xmlDSA);
+               DSAKeyValue dsa = new DSAKeyValue (key);
+               info.AddClause (dsa);
+               AssertEquals ("dsa", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + xmlDSA + "</KeyValue></KeyInfo>", (info.GetXml ().OuterXml));
+               AssertEquals ("dsa count", 1, info.Count);
+       }
+
+       static string xmlRSA = "<RSAKeyValue><Modulus>9DC4XNdQJwMRnz5pP2a6U51MHCODRilaIoVXqUPhCUb0lJdGroeqVYT84ZyIVrcarzD7Tqs3aEOIa3rKox0N1bxQpZPqayVQeLAkjLLtzJW/ScRJx3uEDJdgT1JnM1FH0GZTinmEdCUXdLc7+Y/c/qqIkTfbwHbRZjW0bBJyExM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue>";
+
+       public void TestRSAKeyValue () 
+       {
+               RSA key = RSA.Create ();
+               key.FromXmlString (xmlRSA);
+               RSAKeyValue rsa = new RSAKeyValue (key);
+               info.AddClause (rsa);
+               AssertEquals ("rsa", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + xmlRSA + "</KeyInfo>", (info.GetXml ().OuterXml));
+               AssertEquals ("rsa count", 1, info.Count);
+       }
+
+       public void TestRetrievalMethod () 
+       {
+               KeyInfoRetrievalMethod retrieval = new KeyInfoRetrievalMethod ();
+               retrieval.Uri = "http://www.go-mono.org/";
+               info.AddClause (retrieval);
+               AssertEquals ("RetrievalMethod", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RetrievalElement URI=\"http://www.go-mono.org/\" /></KeyInfo>", (info.GetXml ().OuterXml));
+               AssertEquals ("RetrievalMethod count", 1, info.Count);
+       }
+
+       static byte[] cert = { 0x30,0x82,0x02,0x1D,0x30,0x82,0x01,0x86,0x02,0x01,0x14,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x30,0x58,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x43,0x41,0x31,0x1F,0x30,0x1D,0x06,0x03,0x55,0x04,0x03,0x13,0x16,0x4B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,0x73,0x20,0x43,0x61,0x6E,0x61,0x64,0x61,0x20,0x49,0x6E,0x63,0x2E,0x31,0x28,0x30,0x26,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x2A,0x02,0x0B,0x02,0x01,0x13,0x18,0x6B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,
+               0x73,0x40,0x6B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,0x73,0x2E,0x63,0x61,0x30,0x1E,0x17,0x0D,0x39,0x36,0x30,0x35,0x30,0x37,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x17,0x0D,0x39,0x39,0x30,0x35,0x30,0x37,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x30,0x58,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x43,0x41,0x31,0x1F,0x30,0x1D,0x06,0x03,0x55,0x04,0x03,0x13,0x16,0x4B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,0x73,0x20,0x43,0x61,0x6E,0x61,0x64,0x61,0x20,0x49,0x6E,0x63,0x2E,0x31,0x28,0x30,0x26,0x06,
+               0x0A,0x2B,0x06,0x01,0x04,0x01,0x2A,0x02,0x0B,0x02,0x01,0x13,0x18,0x6B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,0x73,0x40,0x6B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,0x73,0x2E,0x63,0x61,0x30,0x81,0x9D,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x8B,0x00,0x30,0x81,0x87,0x02,0x81,0x81,0x00,0xCD,0x23,0xFA,0x2A,0xE1,0xED,0x98,0xF4,0xE9,0xD0,0x93,0x3E,0xD7,0x7A,0x80,0x02,0x4C,0xCC,0xC1,0x02,0xAF,0x5C,0xB6,0x1F,0x7F,0xFA,0x57,0x42,0x6F,0x30,0xD1,0x20,0xC5,0xB5,
+               0x21,0x07,0x40,0x2C,0xA9,0x86,0xC2,0xF3,0x64,0x84,0xAE,0x3D,0x85,0x2E,0xED,0x85,0xBD,0x54,0xB0,0x18,0x28,0xEF,0x6A,0xF8,0x1B,0xE7,0x0B,0x16,0x1F,0x93,0x25,0x4F,0xC7,0xF8,0x8E,0xC3,0xB9,0xCA,0x98,0x84,0x0E,0x55,0xD0,0x2F,0xEF,0x78,0x77,0xC5,0x72,0x28,0x5F,0x60,0xBF,0x19,0x2B,0xD1,0x72,0xA2,0xB7,0xD8,0x3F,0xE0,0x97,0x34,0x5A,0x01,0xBD,0x04,0x9C,0xC8,0x78,0x45,0xCD,0x93,0x8D,0x15,0xF2,0x76,0x10,0x11,0xAB,0xB8,0x5B,0x2E,0x9E,0x52,0xDD,0x81,0x3E,0x9C,0x64,0xC8,0x29,0x93,0x02,0x01,0x03,0x30,0x0D,0x06,
+               0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x03,0x81,0x81,0x00,0x32,0x1A,0x35,0xBA,0xBF,0x43,0x27,0xD6,0xB4,0xD4,0xB8,0x76,0xE5,0xE3,0x9B,0x4D,0x6C,0xC0,0x86,0xC9,0x77,0x35,0xBA,0x6B,0x16,0x2D,0x13,0x46,0x4A,0xB0,0x32,0x53,0xA1,0x5B,0x5A,0xE9,0x99,0xE2,0x0C,0x86,0x88,0x17,0x4E,0x0D,0xFE,0x82,0xAC,0x4E,0x47,0xEF,0xFB,0xFF,0x39,0xAC,0xEE,0x35,0xC8,0xFA,0x52,0x37,0x0A,0x49,0xAD,0x59,0xAD,0xE2,0x8A,0xA9,0x1C,0xC6,0x5F,0x1F,0xF8,0x6F,0x73,0x7E,0xCD,0xA0,0x31,0xE8,0x0C,0xBE,0xF5,0x4D,
+               0xD9,0xB2,0xAB,0x8A,0x12,0xB6,0x30,0x78,0x68,0x11,0x7C,0x0D,0xF1,0x49,0x4D,0xA3,0xFD,0xB2,0xE9,0xFF,0x1D,0xF0,0x91,0xFA,0x54,0x85,0xFF,0x33,0x90,0xE8,0xC1,0xBF,0xA4,0x9B,0xA4,0x62,0x46,0xBD,0x61,0x12,0x59,0x98,0x41,0x89 };
+
+       public void TestX509Data () 
+       {
+               X509Certificate x509 = new X509Certificate (cert);
+               KeyInfoX509Data x509data = new KeyInfoX509Data (x509);
+               info.AddClause (x509data);
+               AssertEquals ("X509Data", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509Certificate>MIICHTCCAYYCARQwDQYJKoZIhvcNAQEEBQAwWDELMAkGA1UEBhMCQ0ExHzAdBgNVBAMTFktleXdpdG5lc3MgQ2FuYWRhIEluYy4xKDAmBgorBgEEASoCCwIBExhrZXl3aXRuZXNzQGtleXdpdG5lc3MuY2EwHhcNOTYwNTA3MDAwMDAwWhcNOTkwNTA3MDAwMDAwWjBYMQswCQYDVQQGEwJDQTEfMB0GA1UEAxMWS2V5d2l0bmVzcyBDYW5hZGEgSW5jLjEoMCYGCisGAQQBKgILAgETGGtleXdpdG5lc3NAa2V5d2l0bmVzcy5jYTCBnTANBgkqhkiG9w0BAQEFAAOBiwAwgYcCgYEAzSP6KuHtmPTp0JM+13qAAkzMwQKvXLYff/pXQm8w0SDFtSEHQCyphsLzZISuPYUu7YW9VLAYKO9q+BvnCxYfkyVPx/iOw7nKmIQOVdAv73h3xXIoX2C/GSvRcqK32D/glzRaAb0EnMh4Rc2TjRXydhARq7hbLp5S3YE+nGTIKZMCAQMwDQYJKoZIhvcNAQEEBQADgYEAMho1ur9DJ9a01Lh25eObTWzAhsl3NbprFi0TRkqwMlOhW1rpmeIMhogXTg3+gqxOR+/7/zms7jXI+lI3CkmtWa3iiqkcxl8f+G9zfs2gMegMvvVN2bKrihK2MHhoEXwN8UlNo/2y6f8d8JH6VIX/M5Dowb+km6RiRr1hElmYQYk=</X509Certificate></X509Data></KeyInfo>", (info.GetXml ().OuterXml));
+               AssertEquals ("X509Data count", 1, info.Count);
+       }
+
+       public void TestComplex () 
+       {
+               KeyInfoName name = new KeyInfoName ();
+               name.Value = "Mono::";
+               info.AddClause (name);
+
+               DSA keyDSA = DSA.Create ();
+               keyDSA.FromXmlString (xmlDSA);
+               DSAKeyValue dsa = new DSAKeyValue (keyDSA);
+               info.AddClause (dsa);
+
+               RSA keyRSA = RSA.Create ();
+               keyRSA.FromXmlString (xmlRSA);
+               RSAKeyValue rsa = new RSAKeyValue (keyRSA);
+               info.AddClause (rsa);
+
+               KeyInfoRetrievalMethod retrieval = new KeyInfoRetrievalMethod ();
+               retrieval.Uri = "http://www.go-mono.org/";
+               info.AddClause (retrieval);
+
+               X509Certificate x509 = new X509Certificate (cert);
+               KeyInfoX509Data x509data = new KeyInfoX509Data (x509);
+               info.AddClause (x509data);
+
+               string s = "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyName>Mono::</KeyName><KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><DSAKeyValue><P>rjxsMU368YOCTQejWkiuO9e/vUVwkLtq1jKiU3TtJ53hBJqjFRuTa228vZe+BH2su9RPn/vYFWfQDv6zgBYe3eNdu4Afw+Ny0FatX6dl3E77Ra6Tsd3MmLXBiGSQ1mMNd5G2XQGpbt9zsGlUaexXekeMLxIufgfZLwYp67M+2WM=</P><Q>tf0K9rMyvUrU4cIkwbCrDRhQAJk=</Q><G>S8Z+1pGCed00w6DtVcqZLKjfqlCJ7JsugEFIgSy/Vxtu9YGCMclV4ijGEbPo/jU8YOSMuD7E9M7UaopMRcmKQjoKZzoJjkgVFP48Ohxl1f08lERnButsxanx3+OstFwUGQ8XNaGg3KrIoZt1FUnfxN3RHHTvVhjzNSHxMGULGaU=</G><Y>LnrxxRGLYeV2XLtK3SYz8RQHlHFZYrtznDZyMotuRfO5uC5YODhSFyLXvb1qB3WeGtF4h3Eo4KzHgMgfN2ZMlffxFRhJgTtH3ctbL8lfQoDkjeiPPnYGhspdJxr0tyZmiy0gkjJG3vwHYrLnvZWx9Wm/unqiOlGBPNuxJ+hOeP8=</Y><J>9RhE5TycDtdEIXxS3HfxFyXYgpy81zY5lVjwD6E9JP37MWEi80BlX6ab1YPm6xYSEoqReMPP9RgGiW6DuACpgI7+8vgCr4i/7VhzModJAA56PwvTu6UMt9xxKU/fT672v8ucREkMWoc7lEey</J><Seed>HxW3N4RHWVgqDQKuGg7iJTUTiCs=</Seed><PgenCounter>Asw=</PgenCounter></DSAKeyValue></KeyValue>";
+               s += "<KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RSAKeyValue><Modulus>9DC4XNdQJwMRnz5pP2a6U51MHCODRilaIoVXqUPhCUb0lJdGroeqVYT84ZyIVrcarzD7Tqs3aEOIa3rKox0N1bxQpZPqayVQeLAkjLLtzJW/ScRJx3uEDJdgT1JnM1FH0GZTinmEdCUXdLc7+Y/c/qqIkTfbwHbRZjW0bBJyExM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue><RetrievalElement URI=\"http://www.go-mono.org/\" /><X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\">";
+               s += "<X509Certificate>MIICHTCCAYYCARQwDQYJKoZIhvcNAQEEBQAwWDELMAkGA1UEBhMCQ0ExHzAdBgNVBAMTFktleXdpdG5lc3MgQ2FuYWRhIEluYy4xKDAmBgorBgEEASoCCwIBExhrZXl3aXRuZXNzQGtleXdpdG5lc3MuY2EwHhcNOTYwNTA3MDAwMDAwWhcNOTkwNTA3MDAwMDAwWjBYMQswCQYDVQQGEwJDQTEfMB0GA1UEAxMWS2V5d2l0bmVzcyBDYW5hZGEgSW5jLjEoMCYGCisGAQQBKgILAgETGGtleXdpdG5lc3NAa2V5d2l0bmVzcy5jYTCBnTANBgkqhkiG9w0BAQEFAAOBiwAwgYcCgYEAzSP6KuHtmPTp0JM+13qAAkzMwQKvXLYff/pXQm8w0SDFtSEHQCyphsLzZISuPYUu7YW9VLAYKO9q+BvnCxYfkyVPx/iOw7nKmIQOVdAv73h3xXIoX2C/GSvRcqK32D/glzRaAb0EnMh4Rc2TjRXydhARq7hbLp5S3YE+nGTIKZMCAQMwDQYJKoZIhvcNAQEEBQADgYEAMho1ur9DJ9a01Lh25eObTWzAhsl3NbprFi0TRkqwMlOhW1rpmeIMhogXTg3+gqxOR+/7/zms7jXI+lI3CkmtWa3iiqkcxl8f+G9zfs2gMegMvvVN2bKrihK2MHhoEXwN8UlNo/2y6f8d8JH6VIX/M5Dowb+km6RiRr1hElmYQYk=</X509Certificate></X509Data></KeyInfo>";
+               AssertEquals ("Complex", s, (info.GetXml ().OuterXml));
+               AssertEquals ("RetrievalMethod count", 5, info.Count);
+       }
+
+       public void TestImportKeyNode () 
+       {
+               string value = "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyName>Mono::</KeyName><KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><DSAKeyValue><P>rjxsMU368YOCTQejWkiuO9e/vUVwkLtq1jKiU3TtJ53hBJqjFRuTa228vZe+BH2su9RPn/vYFWfQDv6zgBYe3eNdu4Afw+Ny0FatX6dl3E77Ra6Tsd3MmLXBiGSQ1mMNd5G2XQGpbt9zsGlUaexXekeMLxIufgfZLwYp67M+2WM=</P><Q>tf0K9rMyvUrU4cIkwbCrDRhQAJk=</Q><G>S8Z+1pGCed00w6DtVcqZLKjfqlCJ7JsugEFIgSy/Vxtu9YGCMclV4ijGEbPo/jU8YOSMuD7E9M7UaopMRcmKQjoKZzoJjkgVFP48Ohxl1f08lERnButsxanx3+OstFwUGQ8XNaGg3KrIoZt1FUnfxN3RHHTvVhjzNSHxMGULGaU=</G><Y>LnrxxRGLYeV2XLtK3SYz8RQHlHFZYrtznDZyMotuRfO5uC5YODhSFyLXvb1qB3WeGtF4h3Eo4KzHgMgfN2ZMlffxFRhJgTtH3ctbL8lfQoDkjeiPPnYGhspdJxr0tyZmiy0gkjJG3vwHYrLnvZWx9Wm/unqiOlGBPNuxJ+hOeP8=</Y><J>9RhE5TycDtdEIXxS3HfxFyXYgpy81zY5lVjwD6E9JP37MWEi80BlX6ab1YPm6xYSEoqReMPP9RgGiW6DuACpgI7+8vgCr4i/7VhzModJAA56PwvTu6UMt9xxKU/fT672v8ucREkMWoc7lEey</J><Seed>HxW3N4RHWVgqDQKuGg7iJTUTiCs=</Seed><PgenCounter>Asw=</PgenCounter></DSAKeyValue></KeyValue>";
+               value += "<KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RSAKeyValue><Modulus>9DC4XNdQJwMRnz5pP2a6U51MHCODRilaIoVXqUPhCUb0lJdGroeqVYT84ZyIVrcarzD7Tqs3aEOIa3rKox0N1bxQpZPqayVQeLAkjLLtzJW/ScRJx3uEDJdgT1JnM1FH0GZTinmEdCUXdLc7+Y/c/qqIkTfbwHbRZjW0bBJyExM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue><RetrievalElement URI=\"http://www.go-mono.org/\" /><X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\">";
+               value += "<X509Certificate>MIICHTCCAYYCARQwDQYJKoZIhvcNAQEEBQAwWDELMAkGA1UEBhMCQ0ExHzAdBgNVBAMTFktleXdpdG5lc3MgQ2FuYWRhIEluYy4xKDAmBgorBgEEASoCCwIBExhrZXl3aXRuZXNzQGtleXdpdG5lc3MuY2EwHhcNOTYwNTA3MDAwMDAwWhcNOTkwNTA3MDAwMDAwWjBYMQswCQYDVQQGEwJDQTEfMB0GA1UEAxMWS2V5d2l0bmVzcyBDYW5hZGEgSW5jLjEoMCYGCisGAQQBKgILAgETGGtleXdpdG5lc3NAa2V5d2l0bmVzcy5jYTCBnTANBgkqhkiG9w0BAQEFAAOBiwAwgYcCgYEAzSP6KuHtmPTp0JM+13qAAkzMwQKvXLYff/pXQm8w0SDFtSEHQCyphsLzZISuPYUu7YW9VLAYKO9q+BvnCxYfkyVPx/iOw7nKmIQOVdAv73h3xXIoX2C/GSvRcqK32D/glzRaAb0EnMh4Rc2TjRXydhARq7hbLp5S3YE+nGTIKZMCAQMwDQYJKoZIhvcNAQEEBQADgYEAMho1ur9DJ9a01Lh25eObTWzAhsl3NbprFi0TRkqwMlOhW1rpmeIMhogXTg3+gqxOR+/7/zms7jXI+lI3CkmtWa3iiqkcxl8f+G9zfs2gMegMvvVN2bKrihK2MHhoEXwN8UlNo/2y6f8d8JH6VIX/M5Dowb+km6RiRr1hElmYQYk=</X509Certificate></X509Data></KeyInfo>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+               info.LoadXml (doc.DocumentElement);
+
+               AssertEquals ("Import", value, (info.GetXml ().OuterXml));
+               AssertEquals ("Import count", 5, info.Count);
+       }
+
+       public void TestNullClause () 
+       {
+               AssertEquals ("empty count", 0, info.Count);
+               // null is accepted...
+               info.AddClause (null);
+               AssertEquals ("null count", 1, info.Count);
+               // but can't get XML out if it!
+               try {
+                       XmlElement xel = info.GetXml ();
+                       Fail ("Expected NullReferenceException but got none");
+               }
+               catch (NullReferenceException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("Expected NullReferenceException but got: " + e.ToString ());
+               }
+       }
+
+       public void TestNullXml () 
+       {
+               try {
+                       info.LoadXml (null);
+                       Fail ("Expected ArgumentNullException but none");
+               }
+               catch (ArgumentNullException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("Expected ArgumentNullException but got: " + e.ToString ());
+               }
+       }
+
+       public void TestInvalid () 
+       {
+               string bad = "<Test></Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (bad);
+               info.LoadXml (doc.DocumentElement);
+               // LAMESPEC: no expection but Xml isn't loaded
+               AssertEquals ("invalid", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (info.GetXml ().OuterXml));
+               AssertEquals ("invalid count", 0, info.Count);
+       }
+}
+
+}
\ No newline at end of file
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoX509DataTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoX509DataTest.cs
new file mode 100644 (file)
index 0000000..36ce73a
--- /dev/null
@@ -0,0 +1,234 @@
+//
+// KeyInfoX509DataTest.cs - NUnit Test Cases for KeyInfoX509Data
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class KeyInfoX509DataTest : TestCase {
+
+       static byte[] cert = { 0x30,0x82,0x09,0xB9,0x30,0x82,0x09,0x22,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,0x20,0x0B,0x35,0x5E,0xCE,0xC4,0xB0,0x63,0xB7,0xDE,0xC6,0x34,0xB9,0x70,0x34,0x44,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x30,0x62,0x31,0x11,0x30,0x0F,0x06,0x03,0x55,0x04,0x07,0x13,0x08,0x49,0x6E,0x74,0x65,0x72,0x6E,0x65,0x74,0x31,0x17,0x30,0x15,0x06,0x03,0x55,0x04,0x0A,0x13,0x0E,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x34,0x30,0x32,0x06,0x03,0x55,0x04,0x0B,
+               0x13,0x2B,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x43,0x6C,0x61,0x73,0x73,0x20,0x31,0x20,0x43,0x41,0x20,0x2D,0x20,0x49,0x6E,0x64,0x69,0x76,0x69,0x64,0x75,0x61,0x6C,0x20,0x53,0x75,0x62,0x73,0x63,0x72,0x69,0x62,0x65,0x72,0x30,0x1E,0x17,0x0D,0x39,0x36,0x30,0x38,0x32,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x17,0x0D,0x39,0x37,0x30,0x38,0x32,0x30,0x32,0x33,0x35,0x39,0x35,0x39,0x5A,0x30,0x82,0x01,0x0A,0x31,0x11,0x30,0x0F,0x06,0x03,0x55,0x04,0x07,0x13,0x08,0x49,0x6E,0x74,0x65,0x72,0x6E,0x65,0x74,
+               0x31,0x17,0x30,0x15,0x06,0x03,0x55,0x04,0x0A,0x13,0x0E,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x34,0x30,0x32,0x06,0x03,0x55,0x04,0x0B,0x13,0x2B,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x43,0x6C,0x61,0x73,0x73,0x20,0x31,0x20,0x43,0x41,0x20,0x2D,0x20,0x49,0x6E,0x64,0x69,0x76,0x69,0x64,0x75,0x61,0x6C,0x20,0x53,0x75,0x62,0x73,0x63,0x72,0x69,0x62,0x65,0x72,0x31,0x46,0x30,0x44,0x06,0x03,0x55,0x04,0x0B,0x13,0x3D,0x77,0x77,0x77,0x2E,0x76,0x65,0x72,0x69,0x73,0x69,
+               0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x2F,0x72,0x65,0x70,0x6F,0x73,0x69,0x74,0x6F,0x72,0x79,0x2F,0x43,0x50,0x53,0x20,0x49,0x6E,0x63,0x6F,0x72,0x70,0x2E,0x20,0x62,0x79,0x20,0x52,0x65,0x66,0x2E,0x2C,0x4C,0x49,0x41,0x42,0x2E,0x4C,0x54,0x44,0x28,0x63,0x29,0x39,0x36,0x31,0x26,0x30,0x24,0x06,0x03,0x55,0x04,0x0B,0x13,0x1D,0x44,0x69,0x67,0x69,0x74,0x61,0x6C,0x20,0x49,0x44,0x20,0x43,0x6C,0x61,0x73,0x73,0x20,0x31,0x20,0x2D,0x20,0x4E,0x65,0x74,0x73,0x63,0x61,0x70,0x65,0x31,0x16,0x30,0x14,0x06,0x03,0x55,0x04,0x03,
+               0x13,0x0D,0x44,0x61,0x76,0x69,0x64,0x20,0x54,0x2E,0x20,0x47,0x72,0x61,0x79,0x31,0x1E,0x30,0x1C,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x0F,0x64,0x61,0x76,0x69,0x64,0x40,0x66,0x6F,0x72,0x6D,0x61,0x6C,0x2E,0x69,0x65,0x30,0x5C,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x4B,0x00,0x30,0x48,0x02,0x41,0x00,0xC5,0x81,0x07,0xA2,0xEB,0x0F,0xB8,0xFF,0xF8,0xF8,0x1C,0xEE,0x32,0xFF,0xBF,0x12,0x35,0x6A,0xF9,0x6B,0xC8,0xBE,0x2F,0xFB,0x3E,0xAF,0x04,0x51,
+               0x4A,0xAC,0xDD,0x10,0x29,0xA8,0xCD,0x40,0x5B,0x66,0x1E,0x98,0xEF,0xF2,0x4C,0x77,0xFA,0x8F,0x86,0xD1,0x21,0x67,0x92,0x44,0x4A,0xC4,0x89,0xC9,0x83,0xCF,0x88,0x9F,0x6F,0xE2,0x32,0x35,0x02,0x03,0x01,0x00,0x01,0xA3,0x82,0x07,0x08,0x30,0x82,0x07,0x04,0x30,0x09,0x06,0x03,0x55,0x1D,0x13,0x04,0x02,0x30,0x00,0x30,0x82,0x02,0x1F,0x06,0x03,0x55,0x1D,0x03,0x04,0x82,0x02,0x16,0x30,0x82,0x02,0x12,0x30,0x82,0x02,0x0E,0x30,0x82,0x02,0x0A,0x06,0x0B,0x60,0x86,0x48,0x01,0x86,0xF8,0x45,0x01,0x07,0x01,0x01,0x30,0x82,
+               0x01,0xF9,0x16,0x82,0x01,0xA7,0x54,0x68,0x69,0x73,0x20,0x63,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x20,0x69,0x6E,0x63,0x6F,0x72,0x70,0x6F,0x72,0x61,0x74,0x65,0x73,0x20,0x62,0x79,0x20,0x72,0x65,0x66,0x65,0x72,0x65,0x6E,0x63,0x65,0x2C,0x20,0x61,0x6E,0x64,0x20,0x69,0x74,0x73,0x20,0x75,0x73,0x65,0x20,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x63,0x74,0x6C,0x79,0x20,0x73,0x75,0x62,0x6A,0x65,0x63,0x74,0x20,0x74,0x6F,0x2C,0x20,0x74,0x68,0x65,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x43,
+               0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x50,0x72,0x61,0x63,0x74,0x69,0x63,0x65,0x20,0x53,0x74,0x61,0x74,0x65,0x6D,0x65,0x6E,0x74,0x20,0x28,0x43,0x50,0x53,0x29,0x2C,0x20,0x61,0x76,0x61,0x69,0x6C,0x61,0x62,0x6C,0x65,0x20,0x61,0x74,0x3A,0x20,0x68,0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x2F,0x43,0x50,0x53,0x3B,0x20,0x62,0x79,0x20,0x45,0x2D,0x6D,0x61,0x69,0x6C,0x20,0x61,0x74,0x20,0x43,0x50,0x53,0x2D,
+               0x72,0x65,0x71,0x75,0x65,0x73,0x74,0x73,0x40,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x3B,0x20,0x6F,0x72,0x20,0x62,0x79,0x20,0x6D,0x61,0x69,0x6C,0x20,0x61,0x74,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x2C,0x20,0x32,0x35,0x39,0x33,0x20,0x43,0x6F,0x61,0x73,0x74,0x20,0x41,0x76,0x65,0x2E,0x2C,0x20,0x4D,0x6F,0x75,0x6E,0x74,0x61,0x69,0x6E,0x20,0x56,0x69,0x65,0x77,0x2C,0x20,0x43,0x41,0x20,0x39,0x34,0x30,0x34,0x33,0x20,0x55,0x53,0x41,0x20,0x54,0x65,
+               0x6C,0x2E,0x20,0x2B,0x31,0x20,0x28,0x34,0x31,0x35,0x29,0x20,0x39,0x36,0x31,0x2D,0x38,0x38,0x33,0x30,0x20,0x43,0x6F,0x70,0x79,0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x63,0x29,0x20,0x31,0x39,0x39,0x36,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x20,0x20,0x41,0x6C,0x6C,0x20,0x52,0x69,0x67,0x68,0x74,0x73,0x20,0x52,0x65,0x73,0x65,0x72,0x76,0x65,0x64,0x2E,0x20,0x43,0x45,0x52,0x54,0x41,0x49,0x4E,0x20,0x57,0x41,0x52,0x52,0x41,0x4E,0x54,0x49,0x45,0x53,0x20,0x44,0x49,0x53,0x43,
+               0x4C,0x41,0x49,0x4D,0x45,0x44,0x20,0x61,0x6E,0x64,0x20,0x4C,0x49,0x41,0x42,0x49,0x4C,0x49,0x54,0x59,0x20,0x4C,0x49,0x4D,0x49,0x54,0x45,0x44,0x2E,0xA0,0x0E,0x06,0x0C,0x60,0x86,0x48,0x01,0x86,0xF8,0x45,0x01,0x07,0x01,0x01,0x01,0xA1,0x0E,0x06,0x0C,0x60,0x86,0x48,0x01,0x86,0xF8,0x45,0x01,0x07,0x01,0x01,0x02,0x30,0x2C,0x30,0x2A,0x16,0x28,0x68,0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x2F,0x72,0x65,0x70,0x6F,0x73,0x69,0x74,0x6F,
+               0x72,0x79,0x2F,0x43,0x50,0x53,0x20,0x30,0x11,0x06,0x09,0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x01,0x04,0x04,0x03,0x02,0x07,0x80,0x30,0x36,0x06,0x09,0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x08,0x04,0x29,0x16,0x27,0x68,0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x2F,0x72,0x65,0x70,0x6F,0x73,0x69,0x74,0x6F,0x72,0x79,0x2F,0x43,0x50,0x53,0x30,0x82,0x04,0x87,0x06,0x09,0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x0D,0x04,0x82,0x04,
+               0x78,0x16,0x82,0x04,0x74,0x43,0x41,0x55,0x54,0x49,0x4F,0x4E,0x3A,0x20,0x54,0x68,0x65,0x20,0x43,0x6F,0x6D,0x6D,0x6F,0x6E,0x20,0x4E,0x61,0x6D,0x65,0x20,0x69,0x6E,0x20,0x74,0x68,0x69,0x73,0x20,0x43,0x6C,0x61,0x73,0x73,0x20,0x31,0x20,0x44,0x69,0x67,0x69,0x74,0x61,0x6C,0x20,0x0A,0x49,0x44,0x20,0x69,0x73,0x20,0x6E,0x6F,0x74,0x20,0x61,0x75,0x74,0x68,0x65,0x6E,0x74,0x69,0x63,0x61,0x74,0x65,0x64,0x20,0x62,0x79,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2E,0x20,0x49,0x74,0x20,0x6D,0x61,0x79,0x20,0x62,
+               0x65,0x20,0x74,0x68,0x65,0x0A,0x68,0x6F,0x6C,0x64,0x65,0x72,0x27,0x73,0x20,0x72,0x65,0x61,0x6C,0x20,0x6E,0x61,0x6D,0x65,0x20,0x6F,0x72,0x20,0x61,0x6E,0x20,0x61,0x6C,0x69,0x61,0x73,0x2E,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x64,0x6F,0x65,0x73,0x20,0x61,0x75,0x74,0x68,0x2D,0x0A,0x65,0x6E,0x74,0x69,0x63,0x61,0x74,0x65,0x20,0x74,0x68,0x65,0x20,0x65,0x2D,0x6D,0x61,0x69,0x6C,0x20,0x61,0x64,0x64,0x72,0x65,0x73,0x73,0x20,0x6F,0x66,0x20,0x74,0x68,0x65,0x20,0x68,0x6F,0x6C,0x64,0x65,0x72,0x2E,
+               0x0A,0x0A,0x54,0x68,0x69,0x73,0x20,0x63,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x20,0x69,0x6E,0x63,0x6F,0x72,0x70,0x6F,0x72,0x61,0x74,0x65,0x73,0x20,0x62,0x79,0x20,0x72,0x65,0x66,0x65,0x72,0x65,0x6E,0x63,0x65,0x2C,0x20,0x61,0x6E,0x64,0x20,0x0A,0x69,0x74,0x73,0x20,0x75,0x73,0x65,0x20,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x63,0x74,0x6C,0x79,0x20,0x73,0x75,0x62,0x6A,0x65,0x63,0x74,0x20,0x74,0x6F,0x2C,0x20,0x74,0x68,0x65,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x0A,0x43,0x65,0x72,
+               0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x50,0x72,0x61,0x63,0x74,0x69,0x63,0x65,0x20,0x53,0x74,0x61,0x74,0x65,0x6D,0x65,0x6E,0x74,0x20,0x28,0x43,0x50,0x53,0x29,0x2C,0x20,0x61,0x76,0x61,0x69,0x6C,0x61,0x62,0x6C,0x65,0x0A,0x69,0x6E,0x20,0x74,0x68,0x65,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x72,0x65,0x70,0x6F,0x73,0x69,0x74,0x6F,0x72,0x79,0x20,0x61,0x74,0x3A,0x20,0x0A,0x68,0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,
+               0x63,0x6F,0x6D,0x3B,0x20,0x62,0x79,0x20,0x45,0x2D,0x6D,0x61,0x69,0x6C,0x20,0x61,0x74,0x0A,0x43,0x50,0x53,0x2D,0x72,0x65,0x71,0x75,0x65,0x73,0x74,0x73,0x40,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x3B,0x20,0x6F,0x72,0x20,0x62,0x79,0x20,0x6D,0x61,0x69,0x6C,0x20,0x61,0x74,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2C,0x0A,0x49,0x6E,0x63,0x2E,0x2C,0x20,0x32,0x35,0x39,0x33,0x20,0x43,0x6F,0x61,0x73,0x74,0x20,0x41,0x76,0x65,0x2E,0x2C,0x20,0x4D,0x6F,0x75,0x6E,0x74,0x61,0x69,0x6E,
+               0x20,0x56,0x69,0x65,0x77,0x2C,0x20,0x43,0x41,0x20,0x39,0x34,0x30,0x34,0x33,0x20,0x55,0x53,0x41,0x0A,0x0A,0x43,0x6F,0x70,0x79,0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x63,0x29,0x31,0x39,0x39,0x36,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x20,0x20,0x41,0x6C,0x6C,0x20,0x52,0x69,0x67,0x68,0x74,0x73,0x20,0x0A,0x52,0x65,0x73,0x65,0x72,0x76,0x65,0x64,0x2E,0x20,0x43,0x45,0x52,0x54,0x41,0x49,0x4E,0x20,0x57,0x41,0x52,0x52,0x41,0x4E,0x54,0x49,0x45,0x53,0x20,0x44,0x49,0x53,0x43,
+               0x4C,0x41,0x49,0x4D,0x45,0x44,0x20,0x41,0x4E,0x44,0x20,0x0A,0x4C,0x49,0x41,0x42,0x49,0x4C,0x49,0x54,0x59,0x20,0x4C,0x49,0x4D,0x49,0x54,0x45,0x44,0x2E,0x0A,0x0A,0x57,0x41,0x52,0x4E,0x49,0x4E,0x47,0x3A,0x20,0x54,0x48,0x45,0x20,0x55,0x53,0x45,0x20,0x4F,0x46,0x20,0x54,0x48,0x49,0x53,0x20,0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x45,0x20,0x49,0x53,0x20,0x53,0x54,0x52,0x49,0x43,0x54,0x4C,0x59,0x0A,0x53,0x55,0x42,0x4A,0x45,0x43,0x54,0x20,0x54,0x4F,0x20,0x54,0x48,0x45,0x20,0x56,0x45,0x52,0x49,
+               0x53,0x49,0x47,0x4E,0x20,0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x49,0x4F,0x4E,0x20,0x50,0x52,0x41,0x43,0x54,0x49,0x43,0x45,0x0A,0x53,0x54,0x41,0x54,0x45,0x4D,0x45,0x4E,0x54,0x2E,0x20,0x20,0x54,0x48,0x45,0x20,0x49,0x53,0x53,0x55,0x49,0x4E,0x47,0x20,0x41,0x55,0x54,0x48,0x4F,0x52,0x49,0x54,0x59,0x20,0x44,0x49,0x53,0x43,0x4C,0x41,0x49,0x4D,0x53,0x20,0x43,0x45,0x52,0x54,0x41,0x49,0x4E,0x0A,0x49,0x4D,0x50,0x4C,0x49,0x45,0x44,0x20,0x41,0x4E,0x44,0x20,0x45,0x58,0x50,0x52,0x45,0x53,0x53,0x20,
+               0x57,0x41,0x52,0x52,0x41,0x4E,0x54,0x49,0x45,0x53,0x2C,0x20,0x49,0x4E,0x43,0x4C,0x55,0x44,0x49,0x4E,0x47,0x20,0x57,0x41,0x52,0x52,0x41,0x4E,0x54,0x49,0x45,0x53,0x0A,0x4F,0x46,0x20,0x4D,0x45,0x52,0x43,0x48,0x41,0x4E,0x54,0x41,0x42,0x49,0x4C,0x49,0x54,0x59,0x20,0x4F,0x52,0x20,0x46,0x49,0x54,0x4E,0x45,0x53,0x53,0x20,0x46,0x4F,0x52,0x20,0x41,0x20,0x50,0x41,0x52,0x54,0x49,0x43,0x55,0x4C,0x41,0x52,0x0A,0x50,0x55,0x52,0x50,0x4F,0x53,0x45,0x2C,0x20,0x41,0x4E,0x44,0x20,0x57,0x49,0x4C,0x4C,0x20,0x4E,0x4F,
+               0x54,0x20,0x42,0x45,0x20,0x4C,0x49,0x41,0x42,0x4C,0x45,0x20,0x46,0x4F,0x52,0x20,0x43,0x4F,0x4E,0x53,0x45,0x51,0x55,0x45,0x4E,0x54,0x49,0x41,0x4C,0x2C,0x0A,0x50,0x55,0x4E,0x49,0x54,0x49,0x56,0x45,0x2C,0x20,0x41,0x4E,0x44,0x20,0x43,0x45,0x52,0x54,0x41,0x49,0x4E,0x20,0x4F,0x54,0x48,0x45,0x52,0x20,0x44,0x41,0x4D,0x41,0x47,0x45,0x53,0x2E,0x20,0x53,0x45,0x45,0x20,0x54,0x48,0x45,0x20,0x43,0x50,0x53,0x0A,0x46,0x4F,0x52,0x20,0x44,0x45,0x54,0x41,0x49,0x4C,0x53,0x2E,0x0A,0x0A,0x43,0x6F,0x6E,0x74,0x65,0x6E,
+               0x74,0x73,0x20,0x6F,0x66,0x20,0x74,0x68,0x65,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x65,0x64,0x0A,0x6E,0x6F,0x6E,0x76,0x65,0x72,0x69,0x66,0x69,0x65,0x64,0x53,0x75,0x62,0x6A,0x65,0x63,0x74,0x41,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x73,0x20,0x65,0x78,0x74,0x65,0x6E,0x73,0x69,0x6F,0x6E,0x20,0x76,0x61,0x6C,0x75,0x65,0x20,0x73,0x68,0x61,0x6C,0x6C,0x20,0x0A,0x6E,0x6F,0x74,0x20,0x62,0x65,0x20,0x63,0x6F,0x6E,0x73,0x69,0x64,0x65,0x72,0x65,0x64,0x20,
+               0x61,0x73,0x20,0x61,0x63,0x63,0x75,0x72,0x61,0x74,0x65,0x20,0x69,0x6E,0x66,0x6F,0x72,0x6D,0x61,0x74,0x69,0x6F,0x6E,0x20,0x76,0x61,0x6C,0x69,0x64,0x61,0x74,0x65,0x64,0x20,0x0A,0x62,0x79,0x20,0x74,0x68,0x65,0x20,0x49,0x41,0x2E,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x03,0x81,0x81,0x00,0x2B,0x3D,0x44,0xC7,0x32,0x59,0xAE,0xF1,0x5F,0x8F,0x3F,0x87,0xE3,0x3E,0xEB,0x81,0x30,0xF8,0xA9,0x96,0xDB,0x01,0x42,0x0B,0x04,0xEF,0x37,0x02,0x3F,0xD4,0x20,0x61,0x58,0xC4,0x4A,0x3A,
+               0x39,0xB3,0xFB,0xD9,0xF8,0xA5,0xC4,0x5E,0x33,0x5A,0x0E,0xFA,0x93,0x56,0x2F,0x6F,0xD6,0x61,0xA2,0xAF,0xA5,0x0C,0x1D,0xE2,0x41,0x65,0xF3,0x40,0x75,0x66,0x83,0xD2,0x5A,0xB4,0xB7,0x56,0x0B,0x8E,0x0D,0xA1,0x33,0x13,0x7D,0x49,0xC3,0xB1,0x00,0x68,0x83,0x7F,0xB5,0x66,0xD4,0x32,0x32,0xFE,0x8B,0x9A,0x5A,0xD6,0x01,0x72,0x31,0x5D,0x85,0x91,0xBC,0x93,0x9B,0x65,0x60,0x25,0xC6,0x1F,0xBC,0xDD,0x69,0x44,0x62,0xC2,0xB2,0x6F,0x46,0xAB,0x2F,0x20,0xA5,0x6F,0xDA,0x48,0x6C,0x9C };
+
+       static byte[] cert2 = { 0x30,0x82,0x02,0x1D,0x30,0x82,0x01,0x86,0x02,0x01,0x14,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x30,0x58,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x43,0x41,0x31,0x1F,0x30,0x1D,0x06,0x03,0x55,0x04,0x03,0x13,0x16,0x4B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,0x73,0x20,0x43,0x61,0x6E,0x61,0x64,0x61,0x20,0x49,0x6E,0x63,0x2E,0x31,0x28,0x30,0x26,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x2A,0x02,0x0B,0x02,0x01,0x13,0x18,0x6B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,
+               0x73,0x40,0x6B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,0x73,0x2E,0x63,0x61,0x30,0x1E,0x17,0x0D,0x39,0x36,0x30,0x35,0x30,0x37,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x17,0x0D,0x39,0x39,0x30,0x35,0x30,0x37,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x30,0x58,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x43,0x41,0x31,0x1F,0x30,0x1D,0x06,0x03,0x55,0x04,0x03,0x13,0x16,0x4B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,0x73,0x20,0x43,0x61,0x6E,0x61,0x64,0x61,0x20,0x49,0x6E,0x63,0x2E,0x31,0x28,0x30,0x26,0x06,
+               0x0A,0x2B,0x06,0x01,0x04,0x01,0x2A,0x02,0x0B,0x02,0x01,0x13,0x18,0x6B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,0x73,0x40,0x6B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,0x73,0x2E,0x63,0x61,0x30,0x81,0x9D,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x8B,0x00,0x30,0x81,0x87,0x02,0x81,0x81,0x00,0xCD,0x23,0xFA,0x2A,0xE1,0xED,0x98,0xF4,0xE9,0xD0,0x93,0x3E,0xD7,0x7A,0x80,0x02,0x4C,0xCC,0xC1,0x02,0xAF,0x5C,0xB6,0x1F,0x7F,0xFA,0x57,0x42,0x6F,0x30,0xD1,0x20,0xC5,0xB5,
+               0x21,0x07,0x40,0x2C,0xA9,0x86,0xC2,0xF3,0x64,0x84,0xAE,0x3D,0x85,0x2E,0xED,0x85,0xBD,0x54,0xB0,0x18,0x28,0xEF,0x6A,0xF8,0x1B,0xE7,0x0B,0x16,0x1F,0x93,0x25,0x4F,0xC7,0xF8,0x8E,0xC3,0xB9,0xCA,0x98,0x84,0x0E,0x55,0xD0,0x2F,0xEF,0x78,0x77,0xC5,0x72,0x28,0x5F,0x60,0xBF,0x19,0x2B,0xD1,0x72,0xA2,0xB7,0xD8,0x3F,0xE0,0x97,0x34,0x5A,0x01,0xBD,0x04,0x9C,0xC8,0x78,0x45,0xCD,0x93,0x8D,0x15,0xF2,0x76,0x10,0x11,0xAB,0xB8,0x5B,0x2E,0x9E,0x52,0xDD,0x81,0x3E,0x9C,0x64,0xC8,0x29,0x93,0x02,0x01,0x03,0x30,0x0D,0x06,
+               0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x03,0x81,0x81,0x00,0x32,0x1A,0x35,0xBA,0xBF,0x43,0x27,0xD6,0xB4,0xD4,0xB8,0x76,0xE5,0xE3,0x9B,0x4D,0x6C,0xC0,0x86,0xC9,0x77,0x35,0xBA,0x6B,0x16,0x2D,0x13,0x46,0x4A,0xB0,0x32,0x53,0xA1,0x5B,0x5A,0xE9,0x99,0xE2,0x0C,0x86,0x88,0x17,0x4E,0x0D,0xFE,0x82,0xAC,0x4E,0x47,0xEF,0xFB,0xFF,0x39,0xAC,0xEE,0x35,0xC8,0xFA,0x52,0x37,0x0A,0x49,0xAD,0x59,0xAD,0xE2,0x8A,0xA9,0x1C,0xC6,0x5F,0x1F,0xF8,0x6F,0x73,0x7E,0xCD,0xA0,0x31,0xE8,0x0C,0xBE,0xF5,0x4D,
+               0xD9,0xB2,0xAB,0x8A,0x12,0xB6,0x30,0x78,0x68,0x11,0x7C,0x0D,0xF1,0x49,0x4D,0xA3,0xFD,0xB2,0xE9,0xFF,0x1D,0xF0,0x91,0xFA,0x54,0x85,0xFF,0x33,0x90,0xE8,0xC1,0xBF,0xA4,0x9B,0xA4,0x62,0x46,0xBD,0x61,0x12,0x59,0x98,0x41,0x89 };
+
+       static byte[] cert3 = { 0x30,0x82,0x03,0x04,0x30,0x82,0x02,0xC4,0xA0,0x03,0x02,0x01,0x02,0x02,0x01,0x03,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x38,0x04,0x03,0x30,0x51,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x18,0x30,0x16,0x06,0x03,0x55,0x04,0x0A,0x13,0x0F,0x55,0x2E,0x53,0x2E,0x20,0x47,0x6F,0x76,0x65,0x72,0x6E,0x6D,0x65,0x6E,0x74,0x31,0x0C,0x30,0x0A,0x06,0x03,0x55,0x04,0x0B,0x13,0x03,0x44,0x6F,0x44,0x31,0x1A,0x30,0x18,0x06,0x03,0x55,0x04,0x03,0x13,0x11,0x41,0x72,0x6D,0x65,0x64,0x20,0x46,0x6F,
+               0x72,0x63,0x65,0x73,0x20,0x52,0x6F,0x6F,0x74,0x30,0x1E,0x17,0x0D,0x30,0x30,0x31,0x30,0x32,0x35,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x17,0x0D,0x30,0x33,0x30,0x31,0x30,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x30,0x51,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x18,0x30,0x16,0x06,0x03,0x55,0x04,0x0A,0x13,0x0F,0x55,0x2E,0x53,0x2E,0x20,0x47,0x6F,0x76,0x65,0x72,0x6E,0x6D,0x65,0x6E,0x74,0x31,0x0C,0x30,0x0A,0x06,0x03,0x55,0x04,0x0B,0x13,0x03,0x44,0x6F,0x44,0x31,0x1A,0x30,0x18,
+               0x06,0x03,0x55,0x04,0x03,0x13,0x11,0x41,0x72,0x6D,0x65,0x64,0x20,0x46,0x6F,0x72,0x63,0x65,0x73,0x20,0x52,0x6F,0x6F,0x74,0x30,0x82,0x01,0xB6,0x30,0x82,0x01,0x2B,0x06,0x07,0x2A,0x86,0x48,0xCE,0x38,0x04,0x01,0x30,0x82,0x01,0x1E,0x02,0x81,0x81,0x00,0x90,0x89,0x3E,0x18,0x1B,0xFE,0xA3,0x1D,0x16,0x89,0x00,0xB4,0xD5,0x40,0x82,0x4C,0x2E,0xEC,0x3D,0x66,0x0D,0x0D,0xB9,0x17,0x40,0x6E,0x3A,0x5C,0x03,0x7B,0x1B,0x93,0x28,0x0C,0xEF,0xB9,0x97,0xE3,0xA1,0xEB,0xE2,0xA3,0x7C,0x61,0xDD,0x6F,0xD5,0xAD,0x15,0x69,0x00,
+               0x16,0xB2,0xC3,0x08,0x3D,0xC4,0x59,0xC6,0xF2,0x70,0xA5,0xB0,0xF5,0x1F,0x1D,0xF4,0xB0,0x15,0xDA,0x7E,0x28,0x39,0x24,0x99,0x36,0x5B,0xEC,0x39,0x25,0xFA,0x92,0x49,0x65,0xD2,0x43,0x05,0x6A,0x9E,0xA3,0x7B,0xF0,0xDE,0xA3,0x2F,0xD3,0x6F,0x3A,0xF9,0x35,0xC3,0x29,0xD4,0x45,0x6C,0x56,0x9A,0xDE,0x36,0x6E,0xFE,0x12,0x68,0x96,0x7B,0x45,0x1D,0x2C,0xFF,0xB9,0x2D,0xF5,0x52,0x8C,0xDF,0x3E,0x2F,0x63,0x02,0x15,0x00,0x81,0xA9,0xB5,0xD0,0x04,0xF2,0x9B,0xA7,0xD8,0x55,0x4C,0x3B,0x32,0xA1,0x45,0x32,0x4F,0xF5,0x51,0xDD,
+               0x02,0x81,0x80,0x64,0x7A,0x88,0x0B,0xF2,0x3E,0x91,0x81,0x59,0x9C,0xF4,0xEA,0xC6,0x7B,0x0E,0xBE,0xEA,0x05,0xE8,0x77,0xFD,0x20,0x34,0x87,0xA1,0xC4,0x69,0xF6,0xC8,0x8B,0x19,0xDA,0xCD,0xFA,0x21,0x8A,0x57,0xA9,0x7A,0x26,0x0A,0x56,0xD4,0xED,0x4B,0x1B,0x7C,0x70,0xED,0xB4,0xE6,0x7A,0x6A,0xDE,0xD3,0x29,0xE2,0xE9,0x9A,0x33,0xED,0x09,0x8D,0x9E,0xDF,0xDA,0x2E,0x4A,0xC1,0x50,0x92,0xEE,0x2F,0xE5,0x5A,0xF3,0x85,0x62,0x6A,0x48,0xDC,0x1B,0x02,0x98,0xA6,0xB0,0xD1,0x09,0x4B,0x10,0xD1,0xF0,0xFA,0xE0,0xB1,0x1D,0x13,
+               0x54,0x4B,0xC0,0xA8,0x40,0xEF,0x71,0xE8,0x56,0x6B,0xA2,0x29,0xCB,0x1E,0x09,0x7D,0x27,0x39,0x91,0x3B,0x20,0x4F,0x98,0x39,0xE8,0x39,0xCA,0x98,0xC5,0xAF,0x54,0x03,0x81,0x84,0x00,0x02,0x81,0x80,0x54,0xA8,0x88,0xB5,0x8F,0x01,0x56,0xCE,0x18,0x8F,0xA6,0xD6,0x7C,0x29,0x29,0x75,0x45,0xE8,0x31,0xA4,0x07,0x17,0xED,0x1E,0x5D,0xB2,0x7B,0xBB,0xCE,0x3C,0x97,0x67,0x1E,0x88,0x0A,0xFE,0x7D,0x00,0x22,0x27,0x1D,0x66,0xEE,0xF6,0x1B,0xB6,0x95,0x7F,0x5A,0xFF,0x06,0x34,0x02,0x43,0xC3,0x83,0xC4,0x66,0x2C,0xA1,0x05,0x0E,
+               0x68,0xB3,0xCA,0xDC,0xD3,0xF9,0x0C,0xC0,0x66,0xDF,0x85,0x84,0x4B,0x20,0x5D,0x41,0xAC,0xC0,0xEC,0x37,0x92,0x0E,0x97,0x19,0xBF,0x53,0x35,0x63,0x27,0x18,0x33,0x35,0x42,0x4D,0xF0,0x2D,0x6D,0xA7,0xA4,0x98,0xAA,0x57,0xF3,0xD2,0xB8,0x6E,0x4E,0x8F,0xFF,0xBE,0x6F,0x4E,0x0F,0x0B,0x44,0x24,0xEE,0xDF,0x4C,0x22,0x5B,0x44,0x98,0x94,0xCB,0xB8,0xA3,0x2F,0x30,0x2D,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0x9D,0x2D,0x73,0xC3,0xB8,0xE3,0x4D,0x29,0x28,0xC3,0x65,0xBE,0xA9,0x98,0xCB,0xD6,0x8A,0x06,0x68,
+               0x9C,0x30,0x0C,0x06,0x03,0x55,0x1D,0x13,0x04,0x05,0x30,0x03,0x01,0x01,0xFF,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x38,0x04,0x03,0x03,0x2F,0x00,0x30,0x2C,0x02,0x14,0x5A,0x1B,0x2D,0x08,0x0E,0xE6,0x99,0x38,0x8F,0xB5,0x09,0xC9,0x89,0x79,0x7E,0x01,0x30,0xBD,0xCE,0xF0,0x02,0x14,0x71,0x7B,0x08,0x51,0x97,0xCE,0x4D,0x1F,0x6A,0x84,0x47,0x3A,0xC0,0xBD,0x13,0x89,0x81,0xB9,0x01,0x97 };
+
+       static byte[] x509crl = { 0x30, 0x82, 0x01, 0x05, 0x30, 0x72, 0x02, 0x01, 0x01, 0x30, 0x0B, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05, 0x30, 0x51, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x0F, 0x55, 0x2E, 0x53, 0x2E, 0x20, 0x47, 0x6F, 0x76, 0x65, 0x72, 0x6E, 0x6D, 0x65, 0x6E, 0x74, 0x31, 0x0C, 0x30, 0x0A, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x13, 0x03, 0x44, 0x6F, 0x44, 0x31, 0x1A, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x11, 0x41, 0x72, 0x6D, 0x65, 0x64, 0x20, 0x46, 0x6F, 0x72, 0x63, 0x65, 0x73, 0x20, 0x52, 0x6F, 0x6F, 0x74, 0x17, 0x0D, 0x30, 0x32, 0x31, 0x30, 0x31, 0x31, 0x31, 0x33, 0x31, 0x32, 0x35, 0x30, 0x5A, 0x30, 0x0B, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05, 0x03, 0x81, 0x81, 0x00, 0x7D, 0xA2, 0xD1, 0x19, 0x6D, 0x0F, 0x0F, 0xCB, 0xE4, 0xA3, 0xBE, 0xE0, 0x36, 0x0A, 0xF3, 0x4C, 0x9B, 0xAF, 0xE6, 0x4F, 0xF6, 0xE3, 0xAF, 0xCF, 0x55, 0xF3, 0xC6, 0xDB, 0xAB, 0x4C, 0x16, 0x32, 0xAA, 0x73, 0xAD, 0xCC, 0xDC, 0x32, 0x33, 0x60, 0xDF, 0x8B, 0xCC, 0x93, 0xB5, 0x4F, 0x6A, 0xEC, 0x70, 0x53, 0xAF, 0xCF, 0x07, 0x0F, 0xA0, 0xCD, 0x66, 0xAC, 0x00, 0x57, 0xC6, 0x5C, 0x5D, 0x21, 0xB1, 0xBD, 0x30, 0x89, 0x8E, 0x77, 0x8D, 0xD4, 0x69, 0x7E, 0xC0, 0x36, 0x7E, 0xD2, 0xD8, 0x20, 0x71, 0x08, 0x80, 0xD2, 0xCB, 0x74, 0x8B, 0xD8, 0x42, 0x17, 0x04, 0x99, 0x80, 0xA4, 0x52, 0x70, 0x2E, 0xC0, 0xE3, 0x8C, 0x0B, 0xFF, 0x79, 0xB7, 0x45, 0x77, 0xDC, 0xC5, 0xCF, 0x43, 0x98, 0x91, 0x7D, 0xF1, 0x01, 0xF7, 0x53, 0xD7, 0xC6, 0x51, 0x35, 0xF0, 0x89, 0xCC, 0xC1, 0xFF, 0xE2, 0x89 };
+
+       public KeyInfoX509DataTest () : base ("System.Security.Cryptography.Xml.KeyInfoX509Data testsuite") {}
+       public KeyInfoX509DataTest (string name) : base (name) {}
+
+       protected override void SetUp () {}
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (KeyInfoX509DataTest)); 
+               }
+       }
+
+       public void TestConstructors () 
+       {
+               KeyInfoX509Data data1 = new KeyInfoX509Data ();
+               try {
+                       XmlElement invalid = data1.GetXml ();
+                       Fail ("Expected CryptographicException but got none");
+               }
+               catch (CryptographicException) {
+                       // can't compare at this stage - so empty test is impossible
+               }
+               catch (Exception e) {
+                       Fail ("Expected CryptographicException but got: " + e.ToString ());
+               }
+
+               KeyInfoX509Data data2 = new KeyInfoX509Data (cert);
+
+               XmlElement xel = data2.GetXml ();
+               string s = "<X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509Certificate>MIIJuTCCCSKgAwIBAgIQIAs1Xs7EsGO33sY0uXA0RDANBgkqhkiG9w0BAQQFADBiMREwDwYDVQQHEwhJbnRlcm5ldDEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNDAyBgNVBAsTK1ZlcmlTaWduIENsYXNzIDEgQ0EgLSBJbmRpdmlkdWFsIFN1YnNjcmliZXIwHhcNOTYwODIxMDAwMDAwWhcNOTcwODIwMjM1OTU5WjCCAQoxETAPBgNVBAcTCEludGVybmV0MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE0MDIGA1UECxMrVmVyaVNpZ24gQ2xhc3MgMSBDQSAtIEluZGl2aWR1YWwgU3Vic2NyaWJlcjFGMEQGA1UECxM9d3d3LnZlcmlzaWduLmNvbS9yZXBvc2l0b3J5L0NQUyBJbmNvcnAuIGJ5IFJlZi4sTElBQi5MVEQoYyk5NjEmMCQGA1UECxMdRGlnaXRhbCBJRCBDbGFzcyAxIC0gTmV0c2NhcGUxFjAUBgNVBAMTDURhdmlkIFQuIEdyYXkxHjAcBgkqhkiG9w0BCQEWD2RhdmlkQGZvcm1hbC5pZTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDFgQei6w+4//j4HO4y/78SNWr5a8i+L/s+rwRRSqzdECmozUBbZh6Y7/JMd/qPhtEhZ5JESsSJyYPPiJ9v4jI1AgMBAAGjggcIMIIHBDAJBgNVHRMEAjAAMIICHwYDVR0DBIICFjCCAhIwggIOMIICCgYLYIZIAYb4RQEHAQEwggH5FoIBp1RoaXMgY2VydGlmaWNhdGUgaW5jb3Jwb3JhdGVzIGJ5IHJlZmVyZW5jZSwgYW5kIGl0cyB1c2UgaXMgc3RyaWN0bHkgc3ViamVjdCB0bywgdGhlIFZlcmlTaWduIENlcnRpZmljYXRpb24gUHJhY3RpY2UgU3RhdGVtZW50IChDUFMpLCBhdmFpbGFibGUgYXQ6IGh0dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9DUFM7IGJ5IEUtbWFpbCBhdCBDUFMtcmVxdWVzdHNAdmVyaXNpZ24uY29tOyBvciBieSBtYWlsIGF0IFZlcmlTaWduLCBJbmMuLCAyNTkzIENvYXN0IEF2ZS4sIE1vdW50YWluIFZpZXcsIENBIDk0MDQzIFVTQSBUZWwuICsxICg0MTUpIDk2MS04ODMwIENvcHlyaWdodCAoYykgMTk5NiBWZXJpU2lnbiwgSW5jLiAgQWxsIFJpZ2h0cyBSZXNlcnZlZC4gQ0VSVEFJTiBXQVJSQU5USUVTIERJU0NMQUlNRUQgYW5kIExJQUJJTElUWSBMSU1JVEVELqAOBgxghkgBhvhFAQcBAQGhDgYMYIZIAYb4RQEHAQECMCwwKhYoaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvQ1BTIDARBglghkgBhvhCAQEEBAMCB4AwNgYJYIZIAYb4QgEIBCkWJ2h0dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9yZXBvc2l0b3J5L0NQUzCCBIcGCWCGSAGG+EIBDQSCBHgWggR0Q0FVVElPTjogV";
+               s += "GhlIENvbW1vbiBOYW1lIGluIHRoaXMgQ2xhc3MgMSBEaWdpdGFsIApJRCBpcyBub3QgYXV0aGVudGljYXRlZCBieSBWZXJpU2lnbi4gSXQgbWF5IGJlIHRoZQpob2xkZXIncyByZWFsIG5hbWUgb3IgYW4gYWxpYXMuIFZlcmlTaWduIGRvZXMgYXV0aC0KZW50aWNhdGUgdGhlIGUtbWFpbCBhZGRyZXNzIG9mIHRoZSBob2xkZXIuCgpUaGlzIGNlcnRpZmljYXRlIGluY29ycG9yYXRlcyBieSByZWZlcmVuY2UsIGFuZCAKaXRzIHVzZSBpcyBzdHJpY3RseSBzdWJqZWN0IHRvLCB0aGUgVmVyaVNpZ24gCkNlcnRpZmljYXRpb24gUHJhY3RpY2UgU3RhdGVtZW50IChDUFMpLCBhdmFpbGFibGUKaW4gdGhlIFZlcmlTaWduIHJlcG9zaXRvcnkgYXQ6IApodHRwczovL3d3dy52ZXJpc2lnbi5jb207IGJ5IEUtbWFpbCBhdApDUFMtcmVxdWVzdHNAdmVyaXNpZ24uY29tOyBvciBieSBtYWlsIGF0IFZlcmlTaWduLApJbmMuLCAyNTkzIENvYXN0IEF2ZS4sIE1vdW50YWluIFZpZXcsIENBIDk0MDQzIFVTQQoKQ29weXJpZ2h0IChjKTE5OTYgVmVyaVNpZ24sIEluYy4gIEFsbCBSaWdodHMgClJlc2VydmVkLiBDRVJUQUlOIFdBUlJBTlRJRVMgRElTQ0xBSU1FRCBBTkQgCkxJQUJJTElUWSBMSU1JVEVELgoKV0FSTklORzogVEhFIFVTRSBPRiBUSElTIENFUlRJRklDQVRFIElTIFNUUklDVExZClNVQkpFQ1QgVE8gVEhFIFZFUklTSUdOIENFUlRJRklDQVRJT04gUFJBQ1RJQ0UKU1RBVEVNRU5ULiAgVEhFIElTU1VJTkcgQVVUSE9SSVRZIERJU0NMQUlNUyBDRVJUQUlOCklNUExJRUQgQU5EIEVYUFJFU1MgV0FSUkFOVElFUywgSU5DTFVESU5HIFdBUlJBTlRJRVMKT0YgTUVSQ0hBTlRBQklMSVRZIE9SIEZJVE5FU1MgRk9SIEEgUEFSVElDVUxBUgpQVVJQT1NFLCBBTkQgV0lMTCBOT1QgQkUgTElBQkxFIEZPUiBDT05TRVFVRU5USUFMLApQVU5JVElWRSwgQU5EIENFUlRBSU4gT1RIRVIgREFNQUdFUy4gU0VFIFRIRSBDUFMKRk9SIERFVEFJTFMuCgpDb250ZW50cyBvZiB0aGUgVmVyaVNpZ24gcmVnaXN0ZXJlZApub252ZXJpZmllZFN1YmplY3RBdHRyaWJ1dGVzIGV4dGVuc2lvbiB2YWx1ZSBzaGFsbCAKbm90IGJlIGNvbnNpZGVyZWQgYXMgYWNjdXJhdGUgaW5mb3JtYXRpb24gdmFsaWRhdGVkIApieSB0aGUgSUEuMA0GCSqGSIb3DQEBBAUAA4GBACs9RMcyWa7xX48/h+M+64Ew+KmW2wFCCwTvNwI/1CBhWMRKOjmz+9n4pcReM1oO+pNWL2/WYaKvpQwd4kFl80B1ZoPSWrS3VguODaEzE31Jw7EAaIN/tWbUMjL+i5pa1gFyMV2FkbyTm2VgJcYfvN1pRGLCsm9Gqy8gpW/aSGyc</X509Certificate></X509Data>";
+               AssertEquals ("1 cert", s, (data2.GetXml ().OuterXml));
+
+               data1.LoadXml (xel);
+               AssertEquals ("data1==data2", (data1.GetXml ().OuterXml), (data2.GetXml ().OuterXml));
+
+               X509Certificate x509 = new X509Certificate (cert);
+               KeyInfoX509Data data3 = new KeyInfoX509Data (x509);
+               AssertEquals ("data2==data3", (data2.GetXml ().OuterXml), (data3.GetXml ().OuterXml));
+       }
+
+       public void TestComplex () 
+       {
+               KeyInfoX509Data data1 = new KeyInfoX509Data (cert);
+               KeyInfoX509Data data2 = new KeyInfoX509Data ();
+
+               XmlElement xel = data1.GetXml ();
+               data2.LoadXml (xel);
+
+               AssertEquals ("data1==data2", (data1.GetXml ().OuterXml), (data2.GetXml ().OuterXml));
+               byte[] c = (data1.Certificates[0] as X509Certificate).GetRawCertData();
+               AllTests.AssertEquals ("Certificate[0]", cert, c);
+
+               // add a second X.509 certificate
+               X509Certificate x509 = new X509Certificate (cert2);
+               data1.AddCertificate (x509);
+               xel = data1.GetXml ();
+               data2.LoadXml (xel);
+               AssertEquals ("data1==data2", (data1.GetXml ().OuterXml), (data2.GetXml ().OuterXml));
+               c = (data1.Certificates [1] as X509Certificate).GetRawCertData();
+               AllTests.AssertEquals ("Certificate[1]", cert2, c);
+
+               // add properties from a third X.509 certificate
+               x509 = new X509Certificate (cert3);
+               data1.AddIssuerSerial (x509.GetIssuerName (), x509.GetSerialNumberString ());
+               xel = data1.GetXml ();
+               data2.LoadXml (xel);
+               AssertEquals ("data1==data2", (data1.GetXml ().OuterXml), (data2.GetXml ().OuterXml));
+               // TODO: The type of IssuerSerial isn't documented
+
+               // X509Certificate doesn't export SubjectKeyId so we must improvise
+               byte[] skid = { 0xDE, 0xAD, 0xC0, 0xDE };
+               data1.AddSubjectKeyId (skid);
+               xel = data1.GetXml ();
+               data2.LoadXml (xel);
+               AssertEquals ("data1==data2", (data1.GetXml ().OuterXml), (data2.GetXml ().OuterXml));
+               AllTests.AssertEquals ("SubjectKeyId", skid, data1.SubjectKeyIds[0]);
+
+               data1.AddSubjectName (x509.GetName ());
+               xel = data1.GetXml ();
+               data2.LoadXml (xel);
+               AssertEquals ("data1==data2", (data1.GetXml ().OuterXml), (data2.GetXml ().OuterXml));
+               string s = (string) data1.SubjectNames [0];
+               AllTests.AssertEquals ("SubjectName", x509.GetName (), s);
+       }
+
+       // There's a bug in the framework 1.0 where a CRL entry cannot be included
+       // in a same X509Data entry. This is not per XMLDSIG spec so Mono will accept
+       // this (anyway the bug should be fixed by Microsoft in future release).
+       public void TestCRL () 
+       {
+               KeyInfoX509Data data1 = new KeyInfoX509Data ();
+               data1.CRL = x509crl;
+               XmlElement xel = data1.GetXml ();
+
+               KeyInfoX509Data data2 = new KeyInfoX509Data ();
+               data2.LoadXml (xel);
+
+               AssertEquals ("data1==data2", (data1.GetXml ().OuterXml), (data2.GetXml ().OuterXml));
+               AllTests.AssertEquals ("crl1==crl2", data1.CRL, data2.CRL);
+       }
+
+       public void TestImportX509Data () 
+       {
+               string simple = "<X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509Certificate>MIIJuTCCCSKgAwIBAgIQIAs1Xs7EsGO33sY0uXA0RDANBgkqhkiG9w0BAQQFADBiMREwDwYDVQQHEwhJbnRlcm5ldDEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNDAyBgNVBAsTK1ZlcmlTaWduIENsYXNzIDEgQ0EgLSBJbmRpdmlkdWFsIFN1YnNjcmliZXIwHhcNOTYwODIxMDAwMDAwWhcNOTcwODIwMjM1OTU5WjCCAQoxETAPBgNVBAcTCEludGVybmV0MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE0MDIGA1UECxMrVmVyaVNpZ24gQ2xhc3MgMSBDQSAtIEluZGl2aWR1YWwgU3Vic2NyaWJlcjFGMEQGA1UECxM9d3d3LnZlcmlzaWduLmNvbS9yZXBvc2l0b3J5L0NQUyBJbmNvcnAuIGJ5IFJlZi4sTElBQi5MVEQoYyk5NjEmMCQGA1UECxMdRGlnaXRhbCBJRCBDbGFzcyAxIC0gTmV0c2NhcGUxFjAUBgNVBAMTDURhdmlkIFQuIEdyYXkxHjAcBgkqhkiG9w0BCQEWD2RhdmlkQGZvcm1hbC5pZTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDFgQei6w+4//j4HO4y/78SNWr5a8i+L/s+rwRRSqzdECmozUBbZh6Y7/JMd/qPhtEhZ5JESsSJyYPPiJ9v4jI1AgMBAAGjggcIMIIHBDAJBgNVHRMEAjAAMIICHwYDVR0DBIICFjCCAhIwggIOMIICCgYLYIZIAYb4RQEHAQEwggH5FoIBp1RoaXMgY2VydGlmaWNhdGUgaW5jb3Jwb3JhdGVzIGJ5IHJlZmVyZW5jZSwgYW5kIGl0cyB1c2UgaXMgc3RyaWN0bHkgc3ViamVjdCB0bywgdGhlIFZlcmlTaWduIENlcnRpZmljYXRpb24gUHJhY3RpY2UgU3RhdGVtZW50IChDUFMpLCBhdmFpbGFibGUgYXQ6IGh0dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9DUFM7IGJ5IEUtbWFpbCBhdCBDUFMtcmVxdWVzdHNAdmVyaXNpZ24uY29tOyBvciBieSBtYWlsIGF0IFZlcmlTaWduLCBJbmMuLCAyNTkzIENvYXN0IEF2ZS4sIE1vdW50YWluIFZpZXcsIENBIDk0MDQzIFVTQSBUZWwuICsxICg0MTUpIDk2MS04ODMwIENvcHlyaWdodCAoYykgMTk5NiBWZXJpU2lnbiwgSW5jLiAgQWxsIFJpZ2h0cyBSZXNlcnZlZC4gQ0VSVEFJTiBXQVJSQU5USUVTIERJU0NMQUlNRUQgYW5kIExJQUJJTElUWSBMSU1JVEVELqAOBgxghkgBhvhFAQcBAQGhDgYMYIZIAYb4RQEHAQECMCwwKhYoaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvQ1BTIDARBglghkgBhvhCAQEEBAMCB4AwNgYJYIZIAYb4QgEIBCkWJ2h0dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9yZXBvc2l0b3J5L0NQUzCCBIcGCWCGSAGG+EIBDQSCBHgWggR0Q0FVVElPTjogV";
+               simple += "GhlIENvbW1vbiBOYW1lIGluIHRoaXMgQ2xhc3MgMSBEaWdpdGFsIApJRCBpcyBub3QgYXV0aGVudGljYXRlZCBieSBWZXJpU2lnbi4gSXQgbWF5IGJlIHRoZQpob2xkZXIncyByZWFsIG5hbWUgb3IgYW4gYWxpYXMuIFZlcmlTaWduIGRvZXMgYXV0aC0KZW50aWNhdGUgdGhlIGUtbWFpbCBhZGRyZXNzIG9mIHRoZSBob2xkZXIuCgpUaGlzIGNlcnRpZmljYXRlIGluY29ycG9yYXRlcyBieSByZWZlcmVuY2UsIGFuZCAKaXRzIHVzZSBpcyBzdHJpY3RseSBzdWJqZWN0IHRvLCB0aGUgVmVyaVNpZ24gCkNlcnRpZmljYXRpb24gUHJhY3RpY2UgU3RhdGVtZW50IChDUFMpLCBhdmFpbGFibGUKaW4gdGhlIFZlcmlTaWduIHJlcG9zaXRvcnkgYXQ6IApodHRwczovL3d3dy52ZXJpc2lnbi5jb207IGJ5IEUtbWFpbCBhdApDUFMtcmVxdWVzdHNAdmVyaXNpZ24uY29tOyBvciBieSBtYWlsIGF0IFZlcmlTaWduLApJbmMuLCAyNTkzIENvYXN0IEF2ZS4sIE1vdW50YWluIFZpZXcsIENBIDk0MDQzIFVTQQoKQ29weXJpZ2h0IChjKTE5OTYgVmVyaVNpZ24sIEluYy4gIEFsbCBSaWdodHMgClJlc2VydmVkLiBDRVJUQUlOIFdBUlJBTlRJRVMgRElTQ0xBSU1FRCBBTkQgCkxJQUJJTElUWSBMSU1JVEVELgoKV0FSTklORzogVEhFIFVTRSBPRiBUSElTIENFUlRJRklDQVRFIElTIFNUUklDVExZClNVQkpFQ1QgVE8gVEhFIFZFUklTSUdOIENFUlRJRklDQVRJT04gUFJBQ1RJQ0UKU1RBVEVNRU5ULiAgVEhFIElTU1VJTkcgQVVUSE9SSVRZIERJU0NMQUlNUyBDRVJUQUlOCklNUExJRUQgQU5EIEVYUFJFU1MgV0FSUkFOVElFUywgSU5DTFVESU5HIFdBUlJBTlRJRVMKT0YgTUVSQ0hBTlRBQklMSVRZIE9SIEZJVE5FU1MgRk9SIEEgUEFSVElDVUxBUgpQVVJQT1NFLCBBTkQgV0lMTCBOT1QgQkUgTElBQkxFIEZPUiBDT05TRVFVRU5USUFMLApQVU5JVElWRSwgQU5EIENFUlRBSU4gT1RIRVIgREFNQUdFUy4gU0VFIFRIRSBDUFMKRk9SIERFVEFJTFMuCgpDb250ZW50cyBvZiB0aGUgVmVyaVNpZ24gcmVnaXN0ZXJlZApub252ZXJpZmllZFN1YmplY3RBdHRyaWJ1dGVzIGV4dGVuc2lvbiB2YWx1ZSBzaGFsbCAKbm90IGJlIGNvbnNpZGVyZWQgYXMgYWNjdXJhdGUgaW5mb3JtYXRpb24gdmFsaWRhdGVkIApieSB0aGUgSUEuMA0GCSqGSIb3DQEBBAUAA4GBACs9RMcyWa7xX48/h+M+64Ew+KmW2wFCCwTvNwI/1CBhWMRKOjmz+9n4pcReM1oO+pNWL2/WYaKvpQwd4kFl80B1ZoPSWrS3VguODaEzE31Jw7EAaIN/tWbUMjL+i5pa1gFyMV2FkbyTm2VgJcYfvN1pRGLCsm9Gqy8gpW/aSGyc</X509Certificate></X509Data>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (simple);
+
+               KeyInfoX509Data data1 = new KeyInfoX509Data ();
+               data1.LoadXml (doc.DocumentElement);
+
+               // verify that proper XML is generated (equals to original)
+               string s = (data1.GetXml ().OuterXml);
+               AssertEquals ("Xml-Simple", simple, s);
+
+               // verify that property is parsed correctly
+               byte[] c = (data1.Certificates[0] as X509Certificate).GetRawCertData();
+               AllTests.AssertEquals ("Certificate[0]", cert, c);
+
+               string complex = "<X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509IssuerSerial><X509IssuerName>C=US, O=U.S. Government, OU=DoD, CN=Armed Forces Root</X509IssuerName><X509SerialNumber>03</X509SerialNumber></X509IssuerSerial><X509SKI>3q3A3g==</X509SKI><X509SubjectName>C=US, O=U.S. Government, OU=DoD, CN=Armed Forces Root</X509SubjectName><X509Certificate>MIIJuTCCCSKgAwIBAgIQIAs1Xs7EsGO33sY0uXA0RDANBgkqhkiG9w0BAQQFADBiMREwDwYDVQQHEwhJbnRlcm5ldDEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNDAyBgNVBAsTK1ZlcmlTaWduIENsYXNzIDEgQ0EgLSBJbmRpdmlkdWFsIFN1YnNjcmliZXIwHhcNOTYwODIxMDAwMDAwWhcNOTcwODIwMjM1OTU5WjCCAQoxETAPBgNVBAcTCEludGVybmV0MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE0MDIGA1UECxMrVmVyaVNpZ24gQ2xhc3MgMSBDQSAtIEluZGl2aWR1YWwgU3Vic2NyaWJlcjFGMEQGA1UECxM9d3d3LnZlcmlzaWduLmNvbS9yZXBvc2l0b3J5L0NQUyBJbmNvcnAuIGJ5IFJlZi4sTElBQi5MVEQoYyk5NjEmMCQGA1UECxMdRGlnaXRhbCBJRCBDbGFzcyAxIC0gTmV0c2NhcGUxFjAUBgNVBAMTDURhdmlkIFQuIEdyYXkxHjAcBgkqhkiG9w0BCQEWD2RhdmlkQGZvcm1hbC5pZTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDFgQei6w+4//j4HO4y/78SNWr5a8i+L/s+rwRRSqzdECmozUBbZh6Y7/JMd/qPhtEhZ5JESsSJyYPPiJ9v4jI1AgMBAAGjggcIMIIHBDAJBgNVHRMEAjAAMIICHwYDVR0DBIICFjCCAhIwggIOMIICCgYLYIZIAYb4RQEHAQEwggH5FoIBp1RoaXMgY2VydGlmaWNhdGUgaW5jb3Jwb3JhdGVzIGJ5IHJlZmVyZW5jZSwgYW5kIGl0cyB1c2UgaXMgc3RyaWN0bHkgc3ViamVjdCB0bywgdGhlIFZlcmlTaWduIENlcnRpZmljYXRpb24gUHJhY3RpY2UgU3RhdGVtZW50IChDUFMpLCBhdmFpbGFibGUgYXQ6IGh0dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9DUFM7IGJ5IEUtbWFpbCBhdCBDUFMtcmVxdWVzdHNAdmVyaXNpZ24uY29tOyBvciBieSBtYWlsIGF0IFZlcmlTaWduLCBJbmMuLCAyNTkzIENvYXN0IEF2ZS4sIE1vdW50YWluIFZpZXcsIENBIDk0MDQzIFVTQSBUZWwuICsxICg0MTUpIDk2MS04ODMwIENvcHlyaWdodCAoYykgMTk5NiBWZXJpU2lnbiwgSW5jLiAgQWxsIFJpZ2h0cyBSZXNlcnZlZC4gQ0VSVEFJTiBXQVJSQU5USUVTIERJU0NMQUlNRUQgYW5kIExJQUJJTElUWSBMSU1JVEVELq";
+               complex += "AOBgxghkgBhvhFAQcBAQGhDgYMYIZIAYb4RQEHAQECMCwwKhYoaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvQ1BTIDARBglghkgBhvhCAQEEBAMCB4AwNgYJYIZIAYb4QgEIBCkWJ2h0dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9yZXBvc2l0b3J5L0NQUzCCBIcGCWCGSAGG+EIBDQSCBHgWggR0Q0FVVElPTjogVGhlIENvbW1vbiBOYW1lIGluIHRoaXMgQ2xhc3MgMSBEaWdpdGFsIApJRCBpcyBub3QgYXV0aGVudGljYXRlZCBieSBWZXJpU2lnbi4gSXQgbWF5IGJlIHRoZQpob2xkZXIncyByZWFsIG5hbWUgb3IgYW4gYWxpYXMuIFZlcmlTaWduIGRvZXMgYXV0aC0KZW50aWNhdGUgdGhlIGUtbWFpbCBhZGRyZXNzIG9mIHRoZSBob2xkZXIuCgpUaGlzIGNlcnRpZmljYXRlIGluY29ycG9yYXRlcyBieSByZWZlcmVuY2UsIGFuZCAKaXRzIHVzZSBpcyBzdHJpY3RseSBzdWJqZWN0IHRvLCB0aGUgVmVyaVNpZ24gCkNlcnRpZmljYXRpb24gUHJhY3RpY2UgU3RhdGVtZW50IChDUFMpLCBhdmFpbGFibGUKaW4gdGhlIFZlcmlTaWduIHJlcG9zaXRvcnkgYXQ6IApodHRwczovL3d3dy52ZXJpc2lnbi5jb207IGJ5IEUtbWFpbCBhdApDUFMtcmVxdWVzdHNAdmVyaXNpZ24uY29tOyBvciBieSBtYWlsIGF0IFZlcmlTaWduLApJbmMuLCAyNTkzIENvYXN0IEF2ZS4sIE1vdW50YWluIFZpZXcsIENBIDk0MDQzIFVTQQoKQ29weXJpZ2h0IChjKTE5OTYgVmVyaVNpZ24sIEluYy4gIEFsbCBSaWdodHMgClJlc2VydmVkLiBDRVJUQUlOIFdBUlJBTlRJRVMgRElTQ0xBSU1FRCBBTkQgCkxJQUJJTElUWSBMSU1JVEVELgoKV0FSTklORzogVEhFIFVTRSBPRiBUSElTIENFUlRJRklDQVRFIElTIFNUUklDVExZClNVQkpFQ1QgVE8gVEhFIFZFUklTSUdOIENFUlRJRklDQVRJT04gUFJBQ1RJQ0UKU1RBVEVNRU5ULiAgVEhFIElTU1VJTkcgQVVUSE9SSVRZIERJU0NMQUlNUyBDRVJUQUlOCklNUExJRUQgQU5EIEVYUFJFU1MgV0FSUkFOVElFUywgSU5DTFVESU5HIFdBUlJBTlRJRVMKT0YgTUVSQ0hBTlRBQklMSVRZIE9SIEZJVE5FU1MgRk9SIEEgUEFSVElDVUxBUgpQVVJQT1NFLCBBTkQgV0lMTCBOT1QgQkUgTElBQkxFIEZPUiBDT05TRVFVRU5USUFMLApQVU5JVElWRSwgQU5EIENFUlRBSU4gT1RIRVIgREFNQUdFUy4gU0VFIFRIRSBDUFMKRk9SIERFVEFJTFMuCgpDb250ZW50cyBvZiB0aGUgVmVyaVNpZ24gcmVnaXN0ZXJlZApub252ZXJpZmllZFN1YmplY3RBdHRyaWJ1dGVzIGV4dGVuc2lvbiB2YWx1ZSBzaGFsbCAKbm90IGJlIGNvbnNpZGVyZWQgYXMgYWNjdXJhdGUgaW5mb3JtYXRpb24gdmF";
+               complex += "saWRhdGVkIApieSB0aGUgSUEuMA0GCSqGSIb3DQEBBAUAA4GBACs9RMcyWa7xX48/h+M+64Ew+KmW2wFCCwTvNwI/1CBhWMRKOjmz+9n4pcReM1oO+pNWL2/WYaKvpQwd4kFl80B1ZoPSWrS3VguODaEzE31Jw7EAaIN/tWbUMjL+i5pa1gFyMV2FkbyTm2VgJcYfvN1pRGLCsm9Gqy8gpW/aSGyc</X509Certificate><X509Certificate>MIICHTCCAYYCARQwDQYJKoZIhvcNAQEEBQAwWDELMAkGA1UEBhMCQ0ExHzAdBgNVBAMTFktleXdpdG5lc3MgQ2FuYWRhIEluYy4xKDAmBgorBgEEASoCCwIBExhrZXl3aXRuZXNzQGtleXdpdG5lc3MuY2EwHhcNOTYwNTA3MDAwMDAwWhcNOTkwNTA3MDAwMDAwWjBYMQswCQYDVQQGEwJDQTEfMB0GA1UEAxMWS2V5d2l0bmVzcyBDYW5hZGEgSW5jLjEoMCYGCisGAQQBKgILAgETGGtleXdpdG5lc3NAa2V5d2l0bmVzcy5jYTCBnTANBgkqhkiG9w0BAQEFAAOBiwAwgYcCgYEAzSP6KuHtmPTp0JM+13qAAkzMwQKvXLYff/pXQm8w0SDFtSEHQCyphsLzZISuPYUu7YW9VLAYKO9q+BvnCxYfkyVPx/iOw7nKmIQOVdAv73h3xXIoX2C/GSvRcqK32D/glzRaAb0EnMh4Rc2TjRXydhARq7hbLp5S3YE+nGTIKZMCAQMwDQYJKoZIhvcNAQEEBQADgYEAMho1ur9DJ9a01Lh25eObTWzAhsl3NbprFi0TRkqwMlOhW1rpmeIMhogXTg3+gqxOR+/7/zms7jXI+lI3CkmtWa3iiqkcxl8f+G9zfs2gMegMvvVN2bKrihK2MHhoEXwN8UlNo/2y6f8d8JH6VIX/M5Dowb+km6RiRr1hElmYQYk=</X509Certificate></X509Data>";
+               doc.LoadXml (complex);
+               KeyInfoX509Data data2 = new KeyInfoX509Data ();
+               data2.LoadXml (doc.DocumentElement);
+               s = (data2.GetXml ().OuterXml);
+               AssertEquals ("Xml-Complex", complex, s);
+
+               string crl = "<X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509CRL>HoIBBTByAgEBMAsGCSqGSIb3DQEBBTBRMQswCQYDVQQGEwJVUzEYMBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50MQwwCgYDVQQLEwNEb0QxGjAYBgNVBAMTEUFybWVkIEZvcmNlcyBSb290Fw0wMjEwMTExMzEyNTBaMAsGCSqGSIb3DQEBBQOBgQB9otEZbQ8Py+SjvuA2CvNMm6/mT/bjr89V88bbq0wWMqpzrczcMjNg34vMk7VPauxwU6/PBw+gzWasAFfGXF0hsb0wiY53jdRpfsA2ftLYIHEIgNLLdIvYQhcEmYCkUnAuwOOMC/95t0V33MXPQ5iRffEB91PXxlE18InMwf/iiQ==</X509CRL></X509Data>";
+               doc.LoadXml (crl);
+               KeyInfoX509Data data3 = new KeyInfoX509Data ();
+               data3.LoadXml (doc.DocumentElement);
+               s = (data3.GetXml ().OuterXml);
+               AssertEquals ("Xml-Crl", crl, s);
+       }
+
+       public void TestInvalidKeyNode () 
+       {
+               KeyInfoX509Data data1 = new KeyInfoX509Data ();
+               try {
+                       data1.LoadXml (null);
+                       Fail ("Expected ArgumentNullException but got none");
+               }
+               catch (ArgumentNullException) {
+                       // this is what we expect
+               }
+               catch (Exception e) {
+                       Fail ("Expected ArgumentNullException but got: " + e.ToString ());
+               }
+
+               string bad = "<Test></Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (bad);
+               try {
+                       data1.LoadXml (doc.DocumentElement);
+                       Fail ("Expected CryptographicException but got none");
+               }
+               catch (CryptographicException) {
+                       // malformed certificate (none)
+               }
+               catch (Exception e) {
+                       Fail ("Expected CryptographicException but got: " + e.ToString ());
+               }
+       }
+}
+
+}
\ No newline at end of file
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/RSAKeyValueTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/RSAKeyValueTest.cs
new file mode 100644 (file)
index 0000000..b346a01
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// RSAKeyValueTest.cs - NUnit Test Cases for RSAKeyValue
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class RSAKeyValueTest : TestCase {
+
+       public RSAKeyValueTest () : base ("System.Security.Cryptography.Xml.RSAKeyValue testsuite") {}
+       public RSAKeyValueTest (string name) : base (name) {}
+
+       protected override void SetUp () {}
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (RSAKeyValueTest)); 
+               }
+       }
+
+       public void TestGeneratedKey () 
+       {
+               RSAKeyValue rsa1 = new RSAKeyValue ();
+               AssertNotNull ("Key", rsa1.Key);
+               XmlElement xmlkey = rsa1.GetXml ();
+
+               RSAKeyValue rsa2 = new RSAKeyValue ();
+               rsa2.LoadXml (xmlkey);
+
+               Assert ("rsa1==rsa2", (rsa1.GetXml ().OuterXml) == (rsa2.GetXml ().OuterXml));
+
+               RSA key = rsa1.Key;
+               RSAKeyValue rsa3 = new RSAKeyValue (key);
+               Assert ("rsa3==rsa1", (rsa3.GetXml ().OuterXml) == (rsa1.GetXml ().OuterXml));
+               Assert ("rsa3==rsa2", (rsa3.GetXml ().OuterXml) == (rsa2.GetXml ().OuterXml));
+       }
+
+       public void TestImportKey () 
+       {
+               string rsaKey = "<KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RSAKeyValue><Modulus>ogZ1/O7iks9ncETqNxLDKoPvgrT4nFx1a3lOmpywEmgbc5+8vI5dSzReH4v0YrflY75rIJx13CYWMsaHfQ78GtXvaeshHlQ3lLTuSdYEJceKll/URlBoKQtOj5qYIVSFOIVGHv4Y/0lnLftOzIydem29KKH6lJQlJawBBssR12s=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (rsaKey);
+
+               RSAKeyValue rsa1 = new RSAKeyValue ();
+               rsa1.LoadXml (doc.DocumentElement);
+
+               string s = (rsa1.GetXml ().OuterXml);
+               AssertEquals ("RSA Key", rsaKey, s);
+       }
+
+       public void TestInvalidValue () 
+       {
+               string badKey = "<Test></Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (badKey);
+
+               RSAKeyValue rsa1 = new RSAKeyValue ();
+
+               try {
+                       rsa1.LoadXml (null);
+                       Fail ("Expected ArgumentNullException but got none");
+               }
+               catch (ArgumentNullException) {
+                       // this is what we expect
+               }
+               catch (Exception e) {
+                       Fail ("Expected ArgumentNullException but got: " + e.ToString ());
+               }
+
+               try {
+                       rsa1.LoadXml (doc.DocumentElement);
+                       Fail ("Expected CryptographicException but got none");
+               }
+               catch (CryptographicException) {
+                       // this is what we expect
+               }
+               catch (Exception e) {
+                       Fail ("Expected CryptographicException but got: " + e.ToString ());
+               }
+       }
+}
+
+}
\ No newline at end of file
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs
new file mode 100644 (file)
index 0000000..6036860
--- /dev/null
@@ -0,0 +1,199 @@
+//
+// ReferenceTest.cs - NUnit Test Cases for Reference
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class ReferenceTest : TestCase {
+
+       public ReferenceTest () : base ("System.Security.Cryptography.Xml.Reference testsuite") {}
+       public ReferenceTest (string name) : base (name) {}
+
+       private Reference reference;
+
+       protected override void SetUp () 
+       {
+               reference = new Reference ();
+       }
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (ReferenceTest)); 
+               }
+       }
+
+       public void TestProperties () 
+       {
+               AssertNull ("Uri (null)", reference.Uri);
+               AssertNotNull ("TransformChain", reference.TransformChain);
+               AssertEquals ("ToString()", "System.Security.Cryptography.Xml.Reference", reference.ToString ());
+               // test uri constructor
+               string uri = "uri";
+               reference = new Reference (uri);
+               AssertEquals ("DigestMethod", "http://www.w3.org/2000/09/xmldsig#sha1", reference.DigestMethod);
+               AssertNull ("DigestValue", reference.DigestValue);
+               AssertNull ("Id", reference.Id);
+               AssertNull ("Type", reference.Type);
+               AssertEquals ("Uri", uri, reference.Uri);
+       }
+
+       public void TestLoadNoTransform () 
+       {
+               string value = "<Reference URI=\"#MyObjectId\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>/Vvq6sXEVbtZC8GwNtLQnGOy/VI=</DigestValue></Reference>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+               reference.LoadXml (doc.DocumentElement);
+               AssertEquals ("Load-Xml", value, (reference.GetXml().OuterXml));
+               AssertEquals ("Load-URI", "#MyObjectId", reference.Uri);
+               byte[] hash = { 0xFD, 0x5B, 0xEA, 0xEA, 0xC5, 0xC4, 0x55, 0xBB, 0x59, 0x0B, 0xC1, 0xB0, 0x36, 0xD2, 0xD0, 0x9C, 0x63, 0xB2, 0xFD, 0x52 };
+               AllTests.AssertEquals("Load-Digest", hash, reference.DigestValue);
+               AssertEquals ("Load-#Transform", 0, reference.TransformChain.Count);
+       }
+
+       public void TestLoadBase64Transform () 
+       {
+               string value = "<Reference xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#base64\" /></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>AAAAAAAAAAAAAAAAAAAAAAAAAAA=</DigestValue></Reference>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+               reference.LoadXml (doc.DocumentElement);
+               AssertEquals ("Load-Base64", value, (reference.GetXml().OuterXml));
+               AssertEquals ("Load-#Transform", 1, reference.TransformChain.Count);
+       }
+
+       public void TestLoadC14NTransform () 
+       {
+               string value = "<Reference xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Transforms><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>AAAAAAAAAAAAAAAAAAAAAAAAAAA=</DigestValue></Reference>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+               reference.LoadXml (doc.DocumentElement);
+               AssertEquals ("Load-C14N", value, (reference.GetXml().OuterXml));
+               AssertEquals ("Load-#Transform", 1, reference.TransformChain.Count);
+       }
+
+       public void TestLoadC14NWithCommentsTransforms () 
+       {
+               string value = "<Reference xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Transforms><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments\" /></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>AAAAAAAAAAAAAAAAAAAAAAAAAAA=</DigestValue></Reference>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+               reference.LoadXml (doc.DocumentElement);
+               AssertEquals ("Load-C14NWithComments", value, (reference.GetXml().OuterXml));
+               AssertEquals ("Load-#Transform", 1, reference.TransformChain.Count);
+       }
+
+       public void TestLoadEnvelopedSignatureTransforms () 
+       {
+               string value = "<Reference xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\" /></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>AAAAAAAAAAAAAAAAAAAAAAAAAAA=</DigestValue></Reference>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+               reference.LoadXml (doc.DocumentElement);
+               AssertEquals ("Load-Enveloped", value, (reference.GetXml().OuterXml));
+               AssertEquals ("Load-#Transform", 1, reference.TransformChain.Count);
+       }
+
+       public void TestLoadXPathTransforms () 
+       {
+               string value = "<Reference xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Transforms><Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xpath-19991116\"><XPath></XPath></Transform></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>AAAAAAAAAAAAAAAAAAAAAAAAAAA=</DigestValue></Reference>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+               reference.LoadXml (doc.DocumentElement);
+               AssertEquals ("Load-XPath", value, (reference.GetXml().OuterXml));
+               AssertEquals ("Load-#Transform", 1, reference.TransformChain.Count);
+       }
+
+       public void TestLoadXsltTransforms () 
+       {
+               string value = "<Reference xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Transforms><Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xslt-19991116\" /></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>AAAAAAAAAAAAAAAAAAAAAAAAAAA=</DigestValue></Reference>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+               try {
+                       reference.LoadXml (doc.DocumentElement);
+               }
+               catch (Exception e) {
+                       Fail (e.ToString ());
+               }
+               AssertEquals ("Load-Xslt", value, (reference.GetXml().OuterXml));
+               AssertEquals ("Load-#Transform", 1, reference.TransformChain.Count);
+       }
+
+       public void TestLoadAllTransforms () 
+       {
+               string value = "<Reference xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#base64\" /><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments\" /><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\" /><Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xpath-19991116\"><XPath></XPath></Transform><Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xslt-19991116\" /></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>AAAAAAAAAAAAAAAAAAAAAAAAAAA=</DigestValue></Reference>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+               reference.LoadXml (doc.DocumentElement);
+               AssertEquals ("Load-Xml", value, (reference.GetXml().OuterXml));
+               AssertEquals ("Load-#Transform", 6, reference.TransformChain.Count);
+       }
+
+       public void TestAllTransform () 
+       {
+               // adding an empty hash value
+               byte[] hash = new byte [20];
+               reference.DigestValue = hash;
+               XmlElement xel = reference.GetXml ();
+               // this is the minimal Reference (DisestValue)!
+               AssertNotNull ("GetXml", xel);
+
+               reference.AddTransform (new XmlDsigBase64Transform ());
+               reference.AddTransform (new XmlDsigC14NTransform ());
+               reference.AddTransform (new XmlDsigC14NWithCommentsTransform ());
+               reference.AddTransform (new XmlDsigEnvelopedSignatureTransform ());
+               reference.AddTransform (new XmlDsigXPathTransform ());
+               reference.AddTransform (new XmlDsigXsltTransform ());
+
+               string value = "<Reference xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#base64\" /><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments\" /><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\" /><Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xpath-19991116\"><XPath></XPath></Transform><Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xslt-19991116\" /></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>AAAAAAAAAAAAAAAAAAAAAAAAAAA=</DigestValue></Reference>";
+               AssertEquals("Get-Xml", value, (reference.GetXml().OuterXml));
+               // however this value cannot be loaded as it's missing some transform (xslt) parameters
+
+               // can we add them again ?
+               reference.AddTransform (new XmlDsigBase64Transform ());
+               reference.AddTransform (new XmlDsigC14NTransform ());
+               reference.AddTransform (new XmlDsigC14NWithCommentsTransform ());
+               reference.AddTransform (new XmlDsigEnvelopedSignatureTransform ());
+               reference.AddTransform (new XmlDsigXPathTransform ());
+               reference.AddTransform (new XmlDsigXsltTransform ());
+
+               // seems so ;-)
+               AssertEquals ("# Transforms", 12, reference.TransformChain.Count);
+       }
+
+       public void TestNull () 
+       {
+               // null DigestMethod -> "" DigestMethod !!!
+               reference.DigestMethod = null;
+               AssertNull ("DigestMethod null", reference.DigestMethod);
+       }
+
+       public void TestBadness ()
+       {
+               Reference reference = new Reference ();
+               reference.Uri = "#MyObjectId";
+               // not enough info
+               try {
+                       XmlElement bad = reference.GetXml ();
+                       Fail ("Expected NullReferenceException but got none");
+               }
+               catch (NullReferenceException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("Expected NullReferenceException but got: " + e.ToString ());
+               }
+               // bad hash - there's no validation!
+               reference.DigestMethod = "http://www.w3.org/2000/09/xmldsig#mono";
+       }
+}
+}
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs
new file mode 100644 (file)
index 0000000..54bcdbd
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// SignatureTest.cs - NUnit Test Cases for SignedXml
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class SignatureTest : TestCase {
+
+       public SignatureTest () : base ("System.Security.Cryptography.Xml.Signature testsuite") {}
+       public SignatureTest (string name) : base (name) {}
+
+       protected Signature signature;
+
+       protected override void SetUp () 
+       {
+               signature = new Signature ();
+       }
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (SignatureTest)); 
+               }
+       }
+
+       public void TestSignature () 
+       {
+               XmlElement xel = null;
+               // empty - missing SignedInfo
+               try {
+                       xel = signature.GetXml ();
+                       Fail ("Expected CryptographicException but got none");
+               }
+               catch (CryptographicException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("Expected CryptographicException but got :" + e.ToString ());
+               }
+
+               SignedInfo info = new SignedInfo ();
+               signature.SignedInfo = info;
+               info.SignatureMethod = "http://www.w3.org/2000/09/xmldsig#dsa-sha1";
+               signature.SignatureValue = new byte [128];
+               try {
+                       xel = signature.GetXml ();
+               }
+               catch (Exception e) {
+                       Fail ("Expected ... but got :" + e.ToString ());
+               }
+       }
+
+       public void TestLoad () 
+       {
+               string value = "<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\" /><Reference URI=\"#MyObjectId\"><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>/Vvq6sXEVbtZC8GwNtLQnGOy/VI=</DigestValue></Reference></SignedInfo><SignatureValue>A6XuE8Cy9iOffRXaW9b0+dUcMUJQnlmwLsiqtQnADbCtZXnXAaeJ6nGnQ4Mm0IGi0AJc7/2CoJReXl7iW4hltmFguG1e3nl0VxCyCTHKGOCo1u8R3K+B1rTaenFbSxs42EM7/D9KETsPlzfYfis36yM3PqatiCUOsoMsAiMGzlc=</SignatureValue><KeyInfo><KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RSAKeyValue><Modulus>tI8QYIpbG/m6JLyvP+S3X8mzcaAIayxomyTimSh9UCpEucRnGvLw0P73uStNpiF7wltTZA1HEsv+Ha39dY/0j/Wiy3RAodGDRNuKQao1wu34aNybZ673brbsbHFUfw/o7nlKD2xO84fbajBZmKtBBDy63NHt+QL+grSrREPfCTM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue></KeyInfo><Object Id=\"MyObjectId\"><MyElement xmlns=\"samples\">This is some text</MyElement></Object></Signature>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+               signature.LoadXml (doc.DocumentElement);
+               string s = signature.GetXml ().OuterXml;
+               AssertEquals ("Load", value, s);
+       }
+}
+
+}
\ No newline at end of file
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs
new file mode 100644 (file)
index 0000000..d3e6209
--- /dev/null
@@ -0,0 +1,156 @@
+//
+// SignedInfoTest.cs - NUnit Test Cases for SignedInfo
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class SignedInfoTest : TestCase {
+
+       public SignedInfoTest () : base ("System.Security.Cryptography.Xml.SignedInfo testsuite") {}
+       public SignedInfoTest (string name) : base (name) {}
+
+       protected SignedInfo info;
+
+       protected override void SetUp () 
+       {
+               info = new SignedInfo ();
+       }
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (SignedInfoTest)); 
+               }
+       }
+
+       public void TestEmpty () 
+       {
+               AssertEquals ("CanonicalizationMethod", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", info.CanonicalizationMethod);
+               // NON-WORKING ??? AssertEquals ("Id", "", info.Id);
+               AssertNotNull ("References", info.References);
+               AssertEquals ("References.Count", 0, info.References.Count);
+               // NON-WORKING ??? AssertEquals ("SignatureLength", "", info.SignatureLength);
+               // NON-WORKING ??? AssertEquals ("SignatureMethod", "", info.SignatureMethod);
+               AssertEquals ("ToString()", "System.Security.Cryptography.Xml.SignedInfo", info.ToString ());
+
+               try {
+                       string xml = info.GetXml().OuterXml;
+                       Fail ("Empty Xml: Expected CryptographicException but got none");
+               }
+               catch (CryptographicException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("Empty Xml: Expected CryptographicException but got: " + e.ToString ());
+               }
+       }
+
+       public void TestProperties () 
+       {
+               info.CanonicalizationMethod = "http://www.go-mono.com/";
+               AssertEquals ("CanonicalizationMethod", "http://www.go-mono.com/", info.CanonicalizationMethod);
+               info.Id = "Mono::";
+               AssertEquals ("Id", "Mono::", info.Id);
+       }
+
+       public void TestReferences () 
+       {
+               Reference r1 = new Reference ();
+               r1.Uri = "http://www.go-mono.com/";
+               r1.AddTransform (new XmlDsigBase64Transform ());
+               info.AddReference (r1);
+               AssertEquals ("References.Count 1", 1, info.References.Count);
+
+               Reference r2 = new Reference ("http://www.motus.com/");
+               r2.AddTransform (new XmlDsigBase64Transform ());
+               info.AddReference (r2);
+               AssertEquals ("References.Count 2", 2, info.References.Count);
+
+               info.SignatureMethod = "http://www.w3.org/2000/09/xmldsig#dsa-sha1";
+       }
+
+       public void TestLoad () 
+       {
+               string xml = "<SignedInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\" /><Reference URI=\"#MyObjectId\"><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>/Vvq6sXEVbtZC8GwNtLQnGOy/VI=</DigestValue></Reference></SignedInfo>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (xml);
+               info.LoadXml (doc.DocumentElement);
+               AssertEquals ("LoadXml", xml, (info.GetXml ().OuterXml));
+               AssertEquals ("LoadXml-C14N", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", info.CanonicalizationMethod);
+               AssertEquals ("LoadXml-Algo", "http://www.w3.org/2000/09/xmldsig#rsa-sha1", info.SignatureMethod);
+               AssertEquals ("LoadXml-Ref1", 1, info.References.Count);
+       }
+
+       // there are many (documented) not supported methods in SignedInfo
+       public void TestNotSupported () 
+       {
+               try {
+                       int n = info.Count;
+                       Fail ("Count: Expected NotSupportedException but got none");
+               }
+               catch (NotSupportedException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("Count: Expected NotSupportedException but got: " + e.ToString ());
+               }
+
+               try {
+                       bool b = info.IsReadOnly;
+                       Fail ("IsReadOnly: Expected NotSupportedException but got none");
+               }
+               catch (NotSupportedException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("IsReadOnly: Expected NotSupportedException but got: " + e.ToString ());
+               }
+
+               try {
+                       bool b = info.IsSynchronized;
+                       Fail ("IsSynchronized: Expected NotSupportedException but got none");
+               }
+               catch (NotSupportedException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("IsSynchronized: Expected NotSupportedException but got: " + e.ToString ());
+               }
+
+               try {
+                       object o = info.SyncRoot;
+                       Fail ("SyncRoot: Expected NotSupportedException but got none");
+               }
+               catch (NotSupportedException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("SyncRoot: Expected NotSupportedException but got: " + e.ToString ());
+               }
+
+               try {
+                       info.CopyTo (null, 0);
+                       Fail ("CopyTo: Expected NotSupportedException but got none");
+               }
+               catch (NotSupportedException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("CopyTo: Expected NotSupportedException but got: " + e.ToString ());
+               }
+       }
+}
+
+}
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs
new file mode 100644 (file)
index 0000000..aa76431
--- /dev/null
@@ -0,0 +1,233 @@
+//
+// SignedXmlTest.cs - NUnit Test Cases for SignedXml
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Text;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class SignedXmlTest : TestCase {
+
+       public SignedXmlTest () : base ("System.Security.Cryptography.Xml.SignedXml testsuite") {}
+       public SignedXmlTest (string name) : base (name) {}
+
+       protected override void SetUp () {}
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (SignedXmlTest)); 
+               }
+       }
+
+       public void TestStatic () 
+       {
+               AssertEquals ("XmlDsigCanonicalizationUrl", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", SignedXml.XmlDsigCanonicalizationUrl);
+               AssertEquals ("XmlDsigCanonicalizationWithCommentsUrl", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments", SignedXml.XmlDsigCanonicalizationWithCommentsUrl);
+               AssertEquals ("XmlDsigDSAUrl", "http://www.w3.org/2000/09/xmldsig#dsa-sha1", SignedXml.XmlDsigDSAUrl);
+               AssertEquals ("XmlDsigHMACSHA1Url", "http://www.w3.org/2000/09/xmldsig#hmac-sha1", SignedXml.XmlDsigHMACSHA1Url);
+               AssertEquals ("XmlDsigMinimalCanonicalizationUrl", "http://www.w3.org/2000/09/xmldsig#minimal", SignedXml.XmlDsigMinimalCanonicalizationUrl);
+               AssertEquals ("XmlDsigNamespaceUrl", "http://www.w3.org/2000/09/xmldsig#", SignedXml.XmlDsigNamespaceUrl);
+               AssertEquals ("XmlDsigRSASHA1Url", "http://www.w3.org/2000/09/xmldsig#rsa-sha1", SignedXml.XmlDsigRSASHA1Url);
+               AssertEquals ("XmlDsigSHA1Url", "http://www.w3.org/2000/09/xmldsig#sha1", SignedXml.XmlDsigSHA1Url);
+       }
+
+       // sample from MSDN (url)
+       public SignedXml MSDNSample () 
+       {
+               // Create example data to sign.
+               XmlDocument document = new XmlDocument ();
+               XmlNode node = document.CreateNode (XmlNodeType.Element, "", "MyElement", "samples");
+               node.InnerText = "This is some text";
+               document.AppendChild (node);
+               // Create the SignedXml message.
+               SignedXml signedXml = new SignedXml ();
+               // Create a data object to hold the data to sign.
+               DataObject dataObject = new DataObject ();
+               dataObject.Data = document.ChildNodes;
+               dataObject.Id = "MyObjectId";
+
+               // Add the data object to the signature.
+               signedXml.AddObject (dataObject);
+               // Create a reference to be able to package everything into the
+               // message.
+               Reference reference = new Reference ();
+               reference.Uri = "#MyObjectId";
+               // Add it to the message.
+               signedXml.AddReference (reference);
+
+               return signedXml;
+       }
+
+       public void TestAsymmetricRSASignature () 
+       {
+               SignedXml signedXml = MSDNSample ();
+
+               RSA key = RSA.Create ();
+               signedXml.SigningKey = key;
+
+               // Add a KeyInfo.
+               KeyInfo keyInfo = new KeyInfo ();
+               keyInfo.AddClause (new RSAKeyValue (key));
+               signedXml.KeyInfo = keyInfo;
+
+               // Compute the signature.
+               signedXml.ComputeSignature ();
+
+               // Get the XML representation of the signature.
+               XmlElement xmlSignature = signedXml.GetXml ();
+
+               // LAMESPEC: we must reload the signature or it won't work
+               // MS framework throw a "malformed element"
+               SignedXml vrfy = new SignedXml ();
+               vrfy.LoadXml (xmlSignature);
+
+               // assert that we can verify our own signature
+               Assert ("RSA-Compute/Verify", vrfy.CheckSignature ());
+       }
+
+       public void TestAsymmetricDSASignature () 
+       {
+               SignedXml signedXml = MSDNSample ();
+
+               DSA key = DSA.Create ();
+               signedXml.SigningKey = key;
+               // Add a KeyInfo.
+               KeyInfo keyInfo = new KeyInfo ();
+               keyInfo.AddClause (new DSAKeyValue (key));
+               signedXml.KeyInfo = keyInfo;
+
+               // Compute the signature.
+               signedXml.ComputeSignature ();
+
+               // Get the XML representation of the signature.
+               XmlElement xmlSignature = signedXml.GetXml ();
+
+               // LAMESPEC: we must reload the signature or it won't work
+               // MS framework throw a "malformed element"
+               SignedXml vrfy = new SignedXml ();
+               vrfy.LoadXml (xmlSignature);
+
+               // assert that we can verify our own signature
+               Assert ("DSA-Compute/Verify", vrfy.CheckSignature ());
+       }
+
+       public void TestSymmetricHMACSHA1Signature () 
+       {
+               SignedXml signedXml = MSDNSample ();
+
+               // Compute the signature.
+               byte[] secretkey = Encoding.Default.GetBytes ("password");
+               HMACSHA1 hmac = new HMACSHA1 (secretkey);
+               signedXml.ComputeSignature (hmac);
+
+               // Get the XML representation of the signature.
+               XmlElement xmlSignature = signedXml.GetXml ();
+
+               // LAMESPEC: we must reload the signature or it won't work
+               // MS framework throw a "malformed element"
+               SignedXml vrfy = new SignedXml ();
+               vrfy.LoadXml (xmlSignature);
+
+               // assert that we can verify our own signature
+               Assert ("HMACSHA1-Compute/Verify", vrfy.CheckSignature (hmac));
+       }
+
+       public void TestSymmetricMACTripleDESSignature () 
+       {
+               SignedXml signedXml = MSDNSample ();
+
+               // Compute the signature.
+               byte[] secretkey = Encoding.Default.GetBytes ("password");
+               MACTripleDES hmac = new MACTripleDES (secretkey);
+               try {
+                       signedXml.ComputeSignature (hmac);
+                       Fail ("Expected CryptographicException but none");
+               }
+               catch (CryptographicException) {
+                       // this is expected
+               }
+               catch (Exception e) {
+                       Fail ("Expected CryptographicException but got: " + e.ToString ());
+               }
+       }
+
+       // Using empty constructor
+       // LAMESPEC: The two other constructors don't seems to apply in verifying signatures
+       public void TestAsymmetricRSAVerify () 
+       {
+               string value = "<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\" /><Reference URI=\"#MyObjectId\"><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>/Vvq6sXEVbtZC8GwNtLQnGOy/VI=</DigestValue></Reference></SignedInfo><SignatureValue>A6XuE8Cy9iOffRXaW9b0+dUcMUJQnlmwLsiqtQnADbCtZXnXAaeJ6nGnQ4Mm0IGi0AJc7/2CoJReXl7iW4hltmFguG1e3nl0VxCyCTHKGOCo1u8R3K+B1rTaenFbSxs42EM7/D9KETsPlzfYfis36yM3PqatiCUOsoMsAiMGzlc=</SignatureValue><KeyInfo><KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RSAKeyValue><Modulus>tI8QYIpbG/m6JLyvP+S3X8mzcaAIayxomyTimSh9UCpEucRnGvLw0P73uStNpiF7wltTZA1HEsv+Ha39dY/0j/Wiy3RAodGDRNuKQao1wu34aNybZ673brbsbHFUfw/o7nlKD2xO84fbajBZmKtBBDy63NHt+QL+grSrREPfCTM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue></KeyInfo><Object Id=\"MyObjectId\"><MyElement xmlns=\"samples\">This is some text</MyElement></Object></Signature>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+
+               SignedXml v1 = new SignedXml ();
+               v1.LoadXml (doc.DocumentElement);
+               Assert ("RSA-CheckSignature()", v1.CheckSignature ());
+
+               SignedXml v2 = new SignedXml ();
+               v2.LoadXml (doc.DocumentElement);
+               AsymmetricAlgorithm key = null;
+               bool vrfy = v2.CheckSignatureReturningKey (out key);
+               Assert ("RSA-CheckSignatureReturningKey()", vrfy);
+
+               SignedXml v3 = new SignedXml ();
+               v3.LoadXml (doc.DocumentElement);
+               Assert ("RSA-CheckSignature(key)", v3.CheckSignature (key));
+       }
+
+       // Using empty constructor
+       // LAMESPEC: The two other constructors don't seems to apply in verifying signatures
+       public void TestAsymmetricDSAVerify () 
+       {
+               string value = "<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#dsa-sha1\" /><Reference URI=\"#MyObjectId\"><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>/Vvq6sXEVbtZC8GwNtLQnGOy/VI=</DigestValue></Reference></SignedInfo><SignatureValue>BYz/qRGjGsN1yMFPxWa3awUZm1y4I/IxOQroMxkOteRGgk1HIwhRYw==</SignatureValue><KeyInfo><KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><DSAKeyValue><P>iglVaZ+LsSL8Y0aDXmFMBwva3xHqIypr3l/LtqBH9ziV2Sh1M4JVasAiKqytWIWt/s/Uk8Ckf2tO2Ww1vsNi1NL+Kg9T7FE52sn380/rF0miwGkZeidzm74OWhykb3J+wCTXaIwOzAWI1yN7FoeoN7wzF12jjlSXAXeqPMlViqk=</P><Q>u4sowiJMHilNRojtdmIuQY2YnB8=</Q><G>SdnN7d+wn1n+HH4Hr8MIryIRYgcXdbZ5TH7jAnuWc1koqRc1AZfcYAZ6RDf+orx6Lzn055FTFiN+1NHQfGUtXJCWW0zz0FVV1NJux7WRj8vGTldjJ5ef0oCenkpwDjcIxWsZgVobve4GPoyN1sAc1scnkJB59oupibklmF4y72A=</G><Y>XejzS8Z51yfl0zbYnxSYYbHqreSLjNCoGPB/KjM1TOyV5sMjz0StKtGrFWryTWc7EgvFY7kUth4e04VKf9HbK8z/FifHTXj8+Tszbjzw8GfInnBwLN+vJgbpnjtypmiI5Bm2nLiRbfkdAHP+OrKtr/EauM9GQfYuaxm3/Vj8B84=</Y><J>vGwGg9wqwwWP9xsoPoXu6kHArJtadiNKe9azBiUx5Ob883gd5wlKfEcGuKkBmBySGbgwxyOsIBovd9Kk48hF01ymfQzAAuHR0EdJECSsTsTTKVTLQNBU32O+PRbLYpv4E8kt6rNL83JLJCBY</J><Seed>sqzn8J6fd2gtEyq6YOqiUSHgPE8=</Seed><PgenCounter>sQ==</PgenCounter></DSAKeyValue></KeyValue></KeyInfo><Object Id=\"MyObjectId\"><MyElement xmlns=\"samples\">This is some text</MyElement></Object></Signature>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+
+               SignedXml v1 = new SignedXml ();
+               v1.LoadXml (doc.DocumentElement);
+               Assert ("DSA-CheckSignature()", v1.CheckSignature ());
+
+               SignedXml v2 = new SignedXml ();
+               v2.LoadXml (doc.DocumentElement);
+               AsymmetricAlgorithm key = null;
+               bool vrfy = v2.CheckSignatureReturningKey (out key);
+               Assert ("DSA-CheckSignatureReturningKey()", vrfy);
+
+               SignedXml v3 = new SignedXml ();
+               v3.LoadXml (doc.DocumentElement);
+               Assert ("DSA-CheckSignature(key)", v3.CheckSignature (key));
+       }
+
+       public void TestSymmetricHMACSHA1Verify () 
+       {
+               string value = "<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#hmac-sha1\" /><Reference URI=\"#MyObjectId\"><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>/Vvq6sXEVbtZC8GwNtLQnGOy/VI=</DigestValue></Reference></SignedInfo><SignatureValue>e2RxYr5yGbvTqZLCFcgA2RAC0yE=</SignatureValue><Object Id=\"MyObjectId\"><MyElement xmlns=\"samples\">This is some text</MyElement></Object></Signature>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+
+               SignedXml v1 = new SignedXml ();
+               v1.LoadXml (doc.DocumentElement);
+
+               byte[] secretkey = Encoding.Default.GetBytes ("password");
+               HMACSHA1 hmac = new HMACSHA1 (secretkey);
+
+               Assert ("HMACSHA1-CheckSignature(key)", v1.CheckSignature (hmac));
+       }
+}
+
+}
\ No newline at end of file
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformChainTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformChainTest.cs
new file mode 100644 (file)
index 0000000..fb1d025
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// TransformChainTest.cs - NUnit Test Cases for TransformChain
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class TransformChainTest : TestCase {
+
+       public TransformChainTest () : base ("System.Security.Cryptography.Xml.TransformChain testsuite") {}
+       public TransformChainTest (string name) : base (name) {}
+
+       protected TransformChain chain;
+
+       protected override void SetUp () 
+       {
+               chain = new TransformChain ();
+       }
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (TransformChainTest)); 
+               }
+       }
+
+       public void TestEmpty () 
+       {
+               AssertEquals ("empty count", 0, chain.Count);
+               AssertNotNull ("IEnumerator", chain.GetEnumerator ());
+               AssertEquals ("ToString()", "System.Security.Cryptography.Xml.TransformChain", chain.ToString ());
+       }
+
+       public void TestChain () 
+       {
+               XmlDsigBase64Transform base64 = new XmlDsigBase64Transform ();
+               chain.Add (base64);
+               AssertEquals ("XmlDsigBase64Transform", base64, chain[0]);
+               AssertEquals ("count 1", 1, chain.Count);
+
+               XmlDsigC14NTransform c14n = new XmlDsigC14NTransform ();
+               chain.Add (c14n);
+               AssertEquals ("XmlDsigC14NTransform", c14n, chain[1]);
+               AssertEquals ("count 2", 2, chain.Count);
+
+               XmlDsigC14NWithCommentsTransform c14nc = new XmlDsigC14NWithCommentsTransform ();
+               chain.Add (c14nc);
+               AssertEquals ("XmlDsigC14NWithCommentsTransform", c14nc, chain[2]);
+               AssertEquals ("count 3", 3, chain.Count);
+
+               XmlDsigEnvelopedSignatureTransform esign = new XmlDsigEnvelopedSignatureTransform ();
+               chain.Add (esign);
+               AssertEquals ("XmlDsigEnvelopedSignatureTransform", esign, chain[3]);
+               AssertEquals ("count 4", 4, chain.Count);
+
+               XmlDsigXPathTransform xpath = new XmlDsigXPathTransform ();
+               chain.Add (xpath);
+               AssertEquals ("XmlDsigXPathTransform", xpath, chain[4]);
+               AssertEquals ("count 5", 5, chain.Count);
+
+               XmlDsigXsltTransform xslt = new XmlDsigXsltTransform ();
+               chain.Add (xslt);
+               AssertEquals ("XmlDsigXsltTransform", xslt, chain[5]);
+               AssertEquals ("count 6", 6, chain.Count);
+       }
+
+}
+
+}
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigBase64TransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigBase64TransformTest.cs
new file mode 100644 (file)
index 0000000..89941a5
--- /dev/null
@@ -0,0 +1,159 @@
+//
+// XmlDsigBase64TransformTest.cs - NUnit Test Cases for XmlDsigBase64Transform
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Text;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class XmlDsigBase64TransformTest : TestCase {
+
+       public XmlDsigBase64TransformTest () : base ("System.Security.Cryptography.Xml.XmlDsigBase64Transform testsuite") {}
+       public XmlDsigBase64TransformTest (string name) : base (name) {}
+
+       protected XmlDsigBase64Transform transform;
+
+       protected override void SetUp () 
+       {
+               transform = new XmlDsigBase64Transform ();
+       }
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (XmlDsigBase64TransformTest)); 
+               }
+       }
+
+       public void TestProperties () 
+       {
+               AssertEquals ("Algorithm", "http://www.w3.org/2000/09/xmldsig#base64", transform.Algorithm);
+
+               Type[] input = transform.InputTypes;
+               Assert ("Input #", (input.Length == 3));
+               // check presence of every supported input types
+               bool istream = false;
+               bool ixmldoc = false;
+               bool ixmlnl = false;
+               foreach (Type t in input) {
+                       if (t.ToString () == "System.IO.Stream")
+                               istream = true;
+                       if (t.ToString () == "System.Xml.XmlDocument")
+                               ixmldoc = true;
+                       if (t.ToString () == "System.Xml.XmlNodeList")
+                               ixmlnl = true;
+               }
+               Assert ("Input Stream", istream);
+               Assert ("Input XmlDocument", ixmldoc);
+               Assert ("Input XmlNodeList", ixmlnl);
+
+               Type[] output = transform.OutputTypes;
+               Assert ("Output #", (output.Length == 1));
+               // check presence of every supported output types
+               bool ostream = false;
+               foreach (Type t in input) {
+                       if (t.ToString () == "System.IO.Stream")
+                               ostream = true;
+               }
+               Assert ("Output Stream", ostream);
+       }
+
+       private string Stream2String (Stream s) 
+       {
+               StringBuilder sb = new StringBuilder ();
+               int b = s.ReadByte ();
+               while (b != -1) {
+                       sb.Append (b.ToString("X2"));
+                       b = s.ReadByte ();
+               }
+               return sb.ToString ();
+       }
+
+       private byte[] Stream2Array (Stream s) 
+       {
+               string st = Stream2String (s);
+               byte[] array = new byte [st.Length / 2];
+               for (int i=0; i < array.Length; i++) {
+                       string hex = st.Substring (i*2, 2);
+                       array [i] = Convert.ToByte(hex, 16);
+               }
+               return array;
+       }
+
+       public void TestLoadInput () 
+       {
+               string base64 = "XmlDsigBase64Transform";
+               UTF8Encoding utf8 = new UTF8Encoding ();
+               byte[] base64array = utf8.GetBytes (base64);
+               string xml = "<Test>" + Convert.ToBase64String (base64array) + "</Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (xml);
+
+               // load as XmlDocument
+               transform.LoadInput (doc);
+               Stream s = (Stream) transform.GetOutput ();
+               byte[] output = Stream2Array (s);
+               AssertEquals("XmlDocument", base64, utf8.GetString (output));
+
+               // load as XmlNodeList
+               XmlNodeList xpath = doc.SelectNodes ("//.");
+               transform.LoadInput (xpath);
+               s = (Stream) transform.GetOutput ();
+               output = Stream2Array (s);
+               // works with MS ??? why does xpath return 3 nodes ???
+               // AssertEquals("XPathNodeList", base64, utf8.GetString (output));
+
+               // load as XmlNodeList 
+               transform.LoadInput (doc.ChildNodes);
+               s = (Stream) transform.GetOutput ();
+               output = Stream2Array (s);
+               // FIXME: works with Mono ??? why doesn't this works with MS ???
+               AssertEquals("XmlChildNodes", base64, utf8.GetString (output));
+
+               // load as Stream
+               MemoryStream ms = new MemoryStream ();
+               byte[] x = utf8.GetBytes (Convert.ToBase64String (base64array));
+               ms.Write (x, 0, x.Length);
+               ms.Position = 0;
+               transform.LoadInput (ms);
+               s = (Stream) transform.GetOutput ();
+               output = Stream2Array (s);
+               AssertEquals("MemoryStream", base64, utf8.GetString (output));
+       }
+
+       public void TestUnsupportedInput () 
+       {
+               byte[] bad = { 0xBA, 0xD };
+               // LAMESPEC: input MUST be one of InputType - but no exception is thrown (not documented)
+               transform.LoadInput (bad);
+       }
+
+       public void TestUnsupportedOutput () 
+       {
+               try {
+                       XmlDocument doc = new XmlDocument();
+                       object o = transform.GetOutput (doc.GetType ());
+                       Fail ("Expected ArgumentException but got none");
+               }
+               catch (ArgumentException) {
+                       // this is what we expected
+               }
+               catch (Exception e) {
+                       Fail ("Expected ArgumentException but got: " + e.ToString ());
+               }
+       }
+}
+
+}
\ No newline at end of file
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXsltTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXsltTransformTest.cs
new file mode 100644 (file)
index 0000000..aee7a08
--- /dev/null
@@ -0,0 +1,156 @@
+//
+// XmlDsigXsltTransformTest.cs - NUnit Test Cases for XmlDsigXsltTransform
+//
+// Author:
+//     Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+//
+
+using NUnit.Framework;
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Text;
+using System.Xml;
+
+namespace MonoTests.System.Security.Cryptography.Xml {
+
+public class XmlDsigXsltTransformTest : TestCase {
+
+       public XmlDsigXsltTransformTest () : base ("System.Security.Cryptography.Xml.XmlDsigXsltTransform testsuite") {}
+       public XmlDsigXsltTransformTest (string name) : base (name) {}
+
+       protected XmlDsigXsltTransform transform;
+
+       protected override void SetUp () 
+       {
+               transform = new XmlDsigXsltTransform ();
+       }
+
+       protected override void TearDown () {}
+
+       public static ITest Suite {
+               get { 
+                       return new TestSuite (typeof (XmlDsigXsltTransformTest)); 
+               }
+       }
+
+       public void TestProperties () 
+       {
+               AssertEquals ("Algorithm", "http://www.w3.org/TR/1999/REC-xslt-19991116", transform.Algorithm);
+
+               Type[] input = transform.InputTypes;
+               Assert ("Input #", (input.Length == 3));
+               // check presence of every supported input types
+               bool istream = false;
+               bool ixmldoc = false;
+               bool ixmlnl = false;
+               foreach (Type t in input) {
+                       if (t.ToString () == "System.IO.Stream")
+                               istream = true;
+                       if (t.ToString () == "System.Xml.XmlDocument")
+                               ixmldoc = true;
+                       if (t.ToString () == "System.Xml.XmlNodeList")
+                               ixmlnl = true;
+               }
+               Assert ("Input Stream", istream);
+               Assert ("Input XmlDocument", ixmldoc);
+               Assert ("Input XmlNodeList", ixmlnl);
+
+               Type[] output = transform.OutputTypes;
+               Assert ("Output #", (output.Length == 1));
+               // check presence of every supported output types
+               bool ostream = false;
+               foreach (Type t in input) {
+                       if (t.ToString () == "System.IO.Stream")
+                               ostream = true;
+               }
+               Assert ("Output Stream", ostream);
+       }
+
+       private string Stream2Array (Stream s) 
+       {
+               StringBuilder sb = new StringBuilder ();
+               int b = s.ReadByte ();
+               while (b != -1) {
+                       sb.Append (b.ToString("X2"));
+                       b = s.ReadByte ();
+               }
+               return sb.ToString ();
+       }
+
+       public void Test () 
+       {
+               string test = "<Test>XmlDsigXsltTransform</Test>";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (test);
+
+               transform.LoadInnerXml (doc.ChildNodes);
+               Stream s = (Stream) transform.GetOutput ();
+               string output = Stream2Array (s);
+
+               // load as XmlDocument
+               transform.LoadInput (doc);
+               s = (Stream) transform.GetOutput ();
+               output = Stream2Array (s);
+
+               // load as XmlNodeList
+               transform.LoadInput (doc.ChildNodes);
+               s = (Stream) transform.GetOutput ();
+               output = Stream2Array (s);
+
+               // load as Stream
+               MemoryStream ms = new MemoryStream ();
+               doc.Save (ms);
+               ms.Position = 0;
+               transform.LoadInput (ms);
+               s = (Stream) transform.GetOutput ();
+               output = Stream2Array (s);
+       }
+
+       protected void AssertEquals (string msg, XmlNodeList expected, XmlNodeList actual) 
+       {
+               for (int i=0; i < expected.Count; i++) {
+                       if (expected[i].OuterXml != actual[i].OuterXml) {
+                               Fail (msg + " [" + i + "] expected " + expected[i].OuterXml + " bug got " + actual[i].OuterXml);
+                       }
+               }
+       }
+
+       public void TestLoadInnerXml () 
+       {
+               string value = "<Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xslt-19991116\" />";
+               XmlDocument doc = new XmlDocument ();
+               doc.LoadXml (value);
+
+               transform.LoadInnerXml (doc.ChildNodes);
+               // note: GetInnerXml is protected so we can't AssertEquals :-(
+               // unless we use reflection (making ti a lot more complicated)
+       }
+
+       public void TestUnsupportedInput () 
+       {
+               byte[] bad = { 0xBA, 0xD };
+               // LAMESPEC: input MUST be one of InputType - but no exception is thrown (not documented)
+               transform.LoadInput (bad);
+       }
+
+       public void TestUnsupportedOutput () 
+       {
+               try {
+                       XmlDocument doc = new XmlDocument();
+                       object o = transform.GetOutput (doc.GetType ());
+                       Fail ("Expected ArgumentException but got none");
+               }
+               catch (ArgumentException) {
+                       // this is what we expected
+               }
+               catch (Exception e) {
+                       Fail ("Expected ArgumentException but got: " + e.ToString ());
+               }
+       }
+}
+
+}
\ No newline at end of file