title: cryptographicexception the parameter is incorrect
body: <p>I am using ECDSA with SHA1 encryption because I am trying to make a licencing activation for a desktop application. For that I use a PHP server to which I give PC information and the server gives me the public the key and then I want to validate the data in C#.</p>
  
  <p>I generated this public key in PHP:</p>
  
  <pre><code>"-----BEGIN PUBLIC KEY-----
  MDIwEAYHKoZIzj0CAQYFK4EEAAYDHgAEKzL3PFVVo3IWftdEYmwiSO/4zULGM/wB
  8BrLjQ==
  -----END PUBLIC KEY-----";
  </code></pre>
  
  <p>I used the code from here <a href="http://securitydriven.net/inferno/" rel="nofollow">http://securitydriven.net/inferno/</a> To get to this</p>
  
  <pre><code>byte[] thePublicKeyToBytes = GetBytesFromPEM(thePublicKey2, "PUBLIC KEY");
  CngKey dsaKeyPublic2 = thePublicKeyToBytes.ToPublicKeyFromBlob();
  
  byte[] theRestToBytes = GetBytes(theRestInBinary);
  byte[] meinData = GetBytes("Blabla");
  
  using (var ecdsa = new ECDsaCng(dsaKeyPublic2) { HashAlgorithm = CngAlgorithm.Sha1 }) // verify DSA signature with public key
  {
      if (ecdsa.VerifyData(meinData, theRestToBytes)) MessageBox.Show("Signature verified.");
      else MessageBox.Show("Signature verification failed.");
  }
  </code></pre>
  
  <p>where the procedure is:</p>
  
  <pre><code>byte[] GetBytesFromPEM(string pemString, string section)
  {
      var header = String.Format("-----BEGIN {0}-----", section);
      var footer = String.Format("-----END {0}-----", section);
  
      var start = pemString.IndexOf(header, StringComparison.Ordinal) + header.Length;
      var end = pemString.IndexOf(footer, start, StringComparison.Ordinal) - start;
  
      if (start &lt; 0 || end &lt; 0)
      {
          return null;
      }
  
      return Convert.FromBase64String(pemString.Substring(start, end));
  }
  </code></pre>
  
  <p>The problem is that I get this exception "cryptographicexception the parameter is incorrect" at this line:</p>
  
  <pre><code>CngKey dsaKeyPublic2 = thePublicKeyToBytes.ToPublicKeyFromBlob();
  </code></pre>
  
  <p>I can't show the inferno's public key, but I saw that the length of their key is 384. Is this where I am doing it wrong? The length of the generated public key?</p>