title: How to verify data against signature with public key that uses sha1ecdsa?
body: <p>Knowing little about cryptography I have great problems with what seems to be a simple task.</p>
  
  <p>I have .pem certificate, bytes of data, and signature of that data.
  I want to check if someone changed the data by matching it against signature.</p>
  
  <p>My try:</p>
  
  <pre><code>private bool VerifySignature(byte[] data, byte[] signature)
  {
    try
    {
      X509Certificate certificate = new X509Certificate("cert_filename.pem");
      if (certificate == null)
        return false;
  
      DSACryptoServiceProvider dsa = (DSACryptoServiceProvider)certificate.PublicKey.Key;
  
      return dsa.VerifyData(data, signatureData);
    }
    catch
    {
      return false;
    }
  }
  </code></pre>
  
  <p>But it gives me an error</p>
  
  <blockquote>
    <p>'Algorithm of certificates key is not supported'
    (System.NotSupportedException).</p>
  </blockquote>
  
  <p>Looking into loaded certificate it says that the signature algorithm is 'sha1ecdsa'.</p>
  
  <p>I am trying only to verify data against signature. What am I missing here?
  I would like to do it without any external solutions as it seems to be really trivial task.</p>
  
  <p>Update: I am trying to achieve same functionality as in below Java code:</p>
  
  <pre><code>private boolean verify(byte[] data, byte[] signature)
  {
    boolean isLicenseCorrect = false;
  
    Signature sig = Signature.getInstance("SHA1WithECDSA");
    sig.initVerify(certificate.getPublicKey());
    sig.update(data);
  
    return sig.verify(signature);
  }
  </code></pre>