c# - 此平台不支持 Diffie-Hellman 加密算法

标签 c#

我一直有这个问题。

The specified cryptographic algorithm is not supported on this platform.

Exception Details: System.PlatformNotSupportedException: The specified cryptographic algorithm is not supported on this platform.

下面是代码。此代码在安装了 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>

最佳答案

MSDN表示该类在以下操作系统上受支持:

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

关于c# - 此平台不支持 Diffie-Hellman 加密算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3198954/

相关文章:

C#:更新 List<of T> 中的项目值

c# - 没有表单的 FileSystemWatcher.SynchronizingObject

c# - 在节点集合中查找节点的子节点

c# - 比较两个图像,并返回以 % 为单位的相似率

c# - 使用 RS256 PII 的 JWT SecurityTokenInvalidSignatureException 被隐藏

c# - 如何使我的应用程序打开文件?

c# - 为什么 IEnumerable 投影不是不可变的?

c# - Microsoft.Azure.Documents.DocumentClientException : Server could not parse the Url

c# - C#中的快速数组复制

c# - 银光数据网格 : Copy & paste