Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Bad Version of provider." while loading the Public key with RSACryptoServiceProvider

I am creating RSA key pair using AsymmetricKeyAlgorithmProvider (Windows.Security.Cryptography.Core) and exporting the keys as shown below:

  AsymmetricKeyAlgorithmProvider rsaGenKeys = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithmNames.RsaPkcs1);

  CryptographicKey keyPair = rsaGenKeys.CreateKeyPair(2048);
  byte[] privateKeyBlob = keyPair.Export(CryptographicPrivateKeyBlobType.Pkcs1RsaPrivateKey).ToArray();

  string privateKeyBlobStr = Convert.ToBase64String(privateKeyBlob);

  byte[] publicKeyBlob = keyPair.ExportPublicKey().ToArray();

  string pubilcKeyBlobStr = Convert.ToBase64String(publicKeyBlob);

Now, the receiver of this data happens to be a Silverlight app and is using RSACryptoServiceProvider (System.Security.Cryptography) to load this public key:

RSACryptoServiceProvider rsaPublic = new RSACryptoServiceProvider();
byte[] keyBlobBytes = Convert.FromBase64String(keyBlob);
rsaPublic.ImportCspBlob(keyBlobBytes);

Where keyBlob is the byte array having the public key. The issue is when ImportCspBlob is called it throws exception saying "Bad Version of provider."

like image 719
tavier Avatar asked Apr 16 '15 16:04

tavier


1 Answers

I had the same error. For some reason FxSSH did not like a public RSA key I generated. I had to use the RSA key in the https://github.com/Aimeast/FxSsh readme.

like image 121
humbe Avatar answered Sep 21 '22 07:09

humbe