繁体   English   中英

“提供程序的错误版本。” 使用 RSACryptoServiceProvider 加载公钥时

[英]“Bad Version of provider.” while loading the Public key with RSACryptoServiceProvider

我正在使用AsymmetricKeyAlgorithmProvider ( Windows.Security.Cryptography.Core ) 创建 RSA 密钥对并导出密钥,如下所示:

  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);

现在,此数据的接收者恰好是 Silverlight 应用程序,并且正在使用RSACryptoServiceProvider ( System.Security.Cryptography ) 加载此公钥:

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

其中 keyBlob 是具有公钥的字节数组。 问题是当调用 ImportCspBlob 时,它会抛出异常,说“提供程序的版本错误”。

我有同样的错误。 出于某种原因,FxSSH 不喜欢我生成的公共 RSA 密钥。 我必须在https://github.com/Aimeast/FxSsh自述文件中使用 RSA 密钥。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM