如何在Linux上序列化和反序列化ECDiffieHellmanOpenSsl的公钥?

时间:2019-03-26 21:15:22

标签: c# .net asp.net-core openssl cryptography

我正在尝试将具有Linux支持的密钥交换设置移植到dotnet核心(预览版3.0)。对于Linux支持,似乎我需要使用Nuget上ECDiffieHellmanOpenSsl中可用的System.Security.Cryptography.OpenSsl类。我不知道如何序列化和反序列化公钥以在服务器和客户端之间进行通信。

使用等效的CNG类(ECDiffieHellmanCng),您只需调用

ecdh.PublicKey.ToByteArray()

将密钥序列化为字节数组,然后一旦将密钥发送给另一方,该一方将使用

导入
EncKeyBlob = ecdh.DeriveKeyMaterial(CngKey.Import(otherpublickey, CngKeyBlobFormat.EccPublicBlob));

但是,在ECDiffieHellmanOpenSsl上调用ecdh.PublicKey.ToByteArray()在Ubuntu 18.04上会抛出Unhandled Exception: System.PlatformNotSupportedException: Operation is not supported on this platform.

此外,我看不到该类的OpenSSL版本的任何CngKey.Import()等效项。

我在这里想念什么?

0 个答案:

没有答案