2010-07-07 79 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和更高版本上使用。我很想被证明是错误的。