[corlib] Fixes security tests failures
[mono.git] / mcs / class / System.Security / System.Security.Cryptography.Xml / XmlDsigC14NTransform.cs
index 90b15cdb9ac31f6c1efa9b9ca1eaa69c92604e9d..acbf322dc5e7ec80e8afffaaa284b26bc85691e6 100644 (file)
@@ -48,14 +48,16 @@ namespace System.Security.Cryptography.Xml {
                private XmlCanonicalizer canonicalizer;
                private Stream s;
                
-               public XmlDsigC14NTransform () 
+               public XmlDsigC14NTransform () : this (false)
                {
-                       Algorithm = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
-                       canonicalizer = new XmlCanonicalizer (false, false, PropagatedNamespaces);
                }
 
                public XmlDsigC14NTransform (bool includeComments) 
                {
+                       if (includeComments)
+                               Algorithm = XmlSignature.AlgorithmNamespaces.XmlDsigC14NWithCommentsTransform;
+                       else
+                               Algorithm = XmlSignature.AlgorithmNamespaces.XmlDsigC14NTransform;
                        canonicalizer = new XmlCanonicalizer (includeComments, false, PropagatedNamespaces);
                }
 
@@ -86,13 +88,12 @@ namespace System.Security.Cryptography.Xml {
                        return null; // THIS IS DOCUMENTED AS SUCH
                }
 
-#if NET_2_0
                [ComVisible (false)]
                public override byte[] GetDigestedOutput (HashAlgorithm hash)
                {
+                       // no null check, MS throws a NullReferenceException here
                        return hash.ComputeHash ((Stream) GetOutput ());
                }
-#endif
 
                public override object GetOutput () 
                {
@@ -118,9 +119,7 @@ namespace System.Security.Cryptography.Xml {
                        if (stream != null) {
                                XmlDocument doc = new XmlDocument ();
                                doc.PreserveWhitespace = true;  // REALLY IMPORTANT
-#if NET_1_1
                                doc.XmlResolver = GetResolver ();
-#endif
                                doc.Load (new XmlSignatureStreamReader (new StreamReader (stream)));
 //                             doc.Load ((Stream) obj);
                                s = canonicalizer.Canonicalize (doc);
@@ -137,12 +136,8 @@ namespace System.Security.Cryptography.Xml {
                        if (nl != null) {
                                s = canonicalizer.Canonicalize (nl);
                        }
-#if NET_2_0
                        else
                                throw new ArgumentException ("obj");
-#else
-                       // note: there is no default are other types won't throw an exception
-#endif
                }
        }
 }