title: C# Get CngKey object from public key in text file
body: <p>I have got a file in which there are several public keys for ECDSA SHA256. The file looks like:</p>
  
  <pre><code>KEY_ID: 1
  STATUS: VALID
  -----BEGIN PUBLIC KEY-----
  MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEaq6djyzkpHdX7kt8DsSt6IuSoXjp
  WVlLfnZPoLaGKc/2BSfYQuFIO2hfgueQINJN3ZdujYXfUJ7Who+XkcJqHQ==
  -----END PUBLIC KEY-----
  
  KEY_ID: 2
  STATUS: VALID
  -----BEGIN PUBLIC KEY-----
  MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE+Y5mYZL/EEY9zGji+hrgGkeoyccK
  D0/oBoSDALHc9+LXHKsxXiEV7/h6d6+fKRDb6Wtx5cMzXT9HyY+TjPeuTg==
  -----END PUBLIC KEY-----
  
  KEY_ID: 3
  STATUS: VALID
  -----BEGIN PUBLIC KEY-----
  MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEkvgJ6sc2MM0AAFUJbVOD/i34YJJ8
  ineqTN+DMjpI5q7fQNPEv9y2z/ecPl8qPus8flS4iLOOxdwGoF1mU9lwfA==
  -----END PUBLIC KEY-----
  </code></pre>
  
  <p>How can I can get CngKey object (or list of CngKey) for one (or all) of these keys?</p>
  
  <p>I have tried something like  </p>
  
  <pre><code>string plainTextKey = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEaq6djyzkpHdX7kt8DsSt6IuSoXjpWVlLfnZPoLaGKc/2BSfYQuFIO2hfgueQINJN3ZdujYXfUJ7Who+XkcJqHQ==";
  byte[] publicKeyBytes = Convert.FromBase64String(plainTextKey);
  CngKey ret = CngKey.Import(publicKeyBytes, CngKeyBlobFormat.EccPublicBlob);
  </code></pre>
  
  <p>but Import method throws System.Security.Cryptography.CryptographicException for invalid parameter.</p>