我一直有这个问题。该平台不支持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>
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