How to convert ECDiffieHellmanPublicKey instance to DER file in .net framework?
问题 I have following code: ECDiffieHellman ecdh = ECDiffieHellman.Create(ECCurve.NamedCurves.nistP256); ECDiffieHellmanPublicKey ecdhPublic = ecdh.PublicKey; How can I export the ECDiffieHellmanPublicKey instance (ecdhPublic) into DER encoded file? 回答1: Using BouncyCastle (http://www.bouncycastle.org/) you can export your ECDH public key to a DER encoded ANS.1 Object X9ECParameters ecP = NistNamedCurves.GetByName("P-256"); ECDomainParameters ecSpec = new ECDomainParameters(ecP.Curve, ecP.G, ecP.N