title: How to Verify a RSA-SHA512 XML Signature in .NET?
body: <p>With the help of the <a href="http://msdn.microsoft.com/en-us/library/ye0db953%28v=vs.110%29.aspx" rel="noreferrer">MSDN site about SignedXml</a>, I can easily verify if an XML DSig is correct. It works perfectly if the signature method sha1 was used.</p>
  
  <p>However, when I receive the SignatureMethod <strong><em>RSA-SHA512</em></strong> (<a href="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512" rel="noreferrer">http://www.w3.org/2001/04/xmldsig-more#rsa-sha512</a>), <strong>CheckSignature()</strong> breaks with an CryptograhicException: <em>SignatureDescription could not be created for the signature algorithm supplied.</em></p>
  
  <p><strong>It seems like CheckSignature() is not able to verify RSA-SHA512 signatures.</strong></p>
  
  <p>Does anyone know how to check these kind of signatures?</p>
  
  <p>The code, taken from the MSDN site, is:</p>
  
  <pre><code>public static bool VerifyXml(XmlDocument doc, bool removeSignatureElement = false)
  {
      // Check arguments.
      if (doc == null)
          throw new ArgumentException("doc");
  
      // Create a new SignedXml object and pass it the XML document class.
      SignedXml signedXml = new SignedXml(doc);
  
      // Find the "Signature" node and create a new XmlNodeList object.
      XmlNodeList nodeList = doc.GetElementsByTagName("Signature", Constants.NamespaceDSig);
  
      // Throw an exception if no signature was found.
      if (nodeList.Count &lt; 1)
      {
          throw new CryptographicException("Verification failed: No Signature was found in the document.");
      }
  
      // This example only supports one signature for the entire XML document.  Throw an exception if more than one signature was found.
      if (nodeList.Count &gt; 1)
      {
          throw new CryptographicException("Verification failed: More that one signature was found for the document.");
      }
  
      // Load the first &lt;signature&gt; node.  
      signedXml.LoadXml((XmlElement)nodeList[0]);
  
      // Check the signature and return the result.
      bool signedCorrectly = signedXml.CheckSignature(); // throws the Exception!!!
  
      return signedCorrectly;
  }
  </code></pre>
  
  <p>The signed XML is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;Notification xmlns="http://www.xxxxxxxxxxx.xx/xxxxx"&gt;
      &lt;xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Type="http://www.w3.org/2001/04/xmlenc#Content"&gt; ... &lt;/xenc:EncryptedData&gt;
      &lt;ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
          &lt;ds:SignedInfo&gt;
              &lt;ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/&gt;
              &lt;ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"/&gt;
              &lt;ds:Reference URI=""&gt;
                  &lt;ds:Transforms&gt;
                      &lt;ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/&gt;
                      &lt;ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"/&gt;
                  &lt;/ds:Transforms&gt;
                  &lt;ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/&gt;
                  &lt;ds:DigestValue&gt;WsHcyNL7Jh8HSzR9ArzTqomBkHs=&lt;/ds:DigestValue&gt;
              &lt;/ds:Reference&gt;
          &lt;/ds:SignedInfo&gt;
          &lt;ds:SignatureValue&gt;
  pWDatSEbypIUVQR9NFmLkB9kKWjMb6rKWGFFvGqT5tOUILeDhMHUqjCRB9v/g6yYdogC9TRWouhz
  ...VoZAIBs7EqCbLt7RgpB4GHWc9E3qp65NaCgluw==
          &lt;/ds:SignatureValue&gt;
          &lt;ds:KeyInfo&gt;
              &lt;ds:X509Data&gt;
                  &lt;ds:X509Certificate&gt;
  MIIG+zCCBOOgAwIBAgIHAe2+sRfTfDANBgkqhkiG9w0BAQUFADCBkTELMAkGA1UEBhMCQVQxDTAL
  ...tvawqBjOfkw1yeDzsDMJHfMuAcpYfrEL
                  &lt;/ds:X509Certificate&gt;
              &lt;/ds:X509Data&gt;
          &lt;/ds:KeyInfo&gt;
      &lt;/ds:Signature&gt;
  &lt;/Notification&gt;
  </code></pre>