2010-07-07 82 views
2

我一直有這個問題。該平臺不支持Diffie-Hellman加密算法

此平臺不支持指定的加密算法。

異常詳細信息:System.PlatformNotSupportedException:此平臺不支持指定的加密算法。

以下是代碼。此代碼在裝有3.5框架的Windows XP Pro SP3和Windows 2003 Server上失敗。

<%@ Page Language="C#" AutoEventWireup="true" %> 

<%@ Import Namespace="System"%> 

<%@ Import Namespace="System.Web"%> 

<%@ Import Namespace="System.Security.Cryptography"%> 



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 

<head runat="server"> 

</head> 

<body> 

    <% 

    //http://blogs.msdn.com/b/shawnfa/archive/2007/01/22/elliptic-curve-diffie-hellman.aspx 

    //http://msdn.microsoft.com/en-us/library/cc488021.aspx is about 200-millisecond wait. 

    ECDiffieHellmanCng alice = new ECDiffieHellmanCng(); 

    alice.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash; 

    alice.HashAlgorithm = CngAlgorithm.Sha256; 

    ECDiffieHellmanCng bob = new ECDiffieHellmanCng(); 

    bob.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash; 

    bob.HashAlgorithm = CngAlgorithm.Sha256; 

    byte[] bobKey = bob.DeriveKeyMaterial(alice.PublicKey); 

    byte[] aliceKey = alice.DeriveKeyMaterial(bob.PublicKey); 

    AesCryptoServiceProvider aes = new AesCryptoServiceProvider(); 

    aes.Key = aliceKey; 



    %> 

</body> 

</html> 

回答

0

這可能是由於操作系統的差異。您嘗試運行的代碼只能在某些Windows操作系統或僅在64位或僅在32位計算機上運行。你有這個算法的文檔嗎?

+0

http://msdn.microsoft.com/zh-cn/library/system.security.cryptography.ecdiffiehellmancng.aspx 該文檔說 Windows 7,Windows Vista SP1或更高版本,Windows XP SP3,Windows Server 2008(服務器核心角色不支持),Windows Server 2008 R2(不支持服務器核心角色) .NET Framework不支持所有平臺的所有版本。有關受支持版本的列表,請參閱.NET Framework系統要求。 受以下版本支持:4,3.5 – NanoHead 2010-07-07 21:36:28

1

MSDN說,類支持以下操作系統:

  • 的Windows 7
  • Windows Vista SP1或更高版本
  • 的Windows XP SP3
  • 的Windows Server 2008 (服務器核心不支持)
  • Windows Server 2008 R2(服務器核心 不支持的角色)
+0

我在Windows XP SP3上使用.NET 3.5 SP1嘗試了它,並且收到相同的錯誤消息。 – 2010-07-08 00:45:33

+0

我其實有一些其他方法完全相同的問題。文檔說它與我的操作系統兼容,但我得到這個異常。 – sbenderli 2010-07-08 20:54:48

1

根據閱讀其他Microsoft文檔,我自己的實驗和提問者的說法,我確信MSDN文檔有誤,並且Elliptic Curve DH僅在Windows Vista和更高版本上受支持。 Windows CNG只支持ECDH,而Windows只能在Vista和更高版本上使用。我很想被證明是錯誤的。