簡體   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