Search code examples
javacopenssldiffie-hellman

Java.Security.Key.getEncoded() OpenSSL DH Equivalent


How can I achieve the same result in C with OpenSSL as the getEncoded() Method produces? It is required for a Diffie-Hellman Key Agreement and I have to send my public key to a java server (But I think the getEncoded() Method not only encodes the Public Key but also the parameters which should be also required for my case)

My current status is that I have a OpenSSL DH Object which contains the PublicKey and p&g as BigNums.

Would bey very great if anyone knows how to do that.


Solution

  • If encoded DH object means DER encoded, then i2d_DHParams can help you. It is given here.