[ECDiffieHellmanCng
->不支持平台
[ECDiffieHellmanOpenSsl
-> PublicKey.ToByteArray()
->不支持平台
这里是其他人在7个月前的基本相同(未回答)的问题How do I serialize and deserialize the public key for ECDiffieHellmanOpenSsl on Linux?
如果有办法驯服所提供的课程,我想避免参加第三方代表。
ECDiffieHellmanCng
在Linux上不受支持。
Linux使用ECDiffieHellmanOpenSsl
,但请注意
涉及的类型不会在平台之间转换
例如,您可以找到一些在测试套件中如何使用它的示例
[Fact]
public void VerifyDuplicateKey_ValidHandle()
{
using (var first = new ECDiffieHellmanOpenSsl())
using (SafeEvpPKeyHandle firstHandle = first.DuplicateKeyHandle())
using (ECDiffieHellman second = new ECDiffieHellmanOpenSsl(firstHandle))
using (ECDiffieHellmanPublicKey firstPublic = first.PublicKey)
using (ECDiffieHellmanPublicKey secondPublic = second.PublicKey)
{
byte[] firstSecond = first.DeriveKeyFromHash(secondPublic, HashAlgorithmName.SHA256);
byte[] secondFirst = second.DeriveKeyFromHash(firstPublic, HashAlgorithmName.SHA256);
byte[] firstFirst = first.DeriveKeyFromHash(firstPublic, HashAlgorithmName.SHA256);
Assert.Equal(firstSecond, secondFirst);
Assert.Equal(firstFirst, firstSecond);
}
}