instance method
OpenSSL::PKey::DH#to_der
() -> ::String
dh.to_der → aString
ext/openssl/ossl_pkey_dh.c
View on GitHub ↗
static VALUE
ossl_dh_to_der(VALUE self)
{
OSSL_3_const DH *dh;
unsigned char *p;
long len;
VALUE str;
GetDH(self, dh);
if((len = i2d_DHparams(dh, NULL)) <= 0)
ossl_raise(ePKeyError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if(i2d_DHparams(dh, &p) < 0)
ossl_raise(ePKeyError, NULL);
ossl_str_adjust(str, p);
return str;
}
Serializes the DH parameters to a DER-encoding
Note that any existing per-session public/private keys will not get encoded, just the Diffie-Hellman parameters will be encoded.
See also public_to_der (X.509 SubjectPublicKeyInfo) and private_to_der (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for serialization with the private or public key components.