dh.public_key â aDH
Instance Public methods
Returns a new DH instance that carries just the
public information, i.e. the prime p
and the generator
g
, but no public/private key yet. Such a pair may be generated
using #generate_key!. The
âpublic keyâ needed for a key exchange with #compute_key is considered as
per-session information and may be retrieved with DH#pub_key once a key
pair has been generated. If the current instance already contains private
information (and thus a valid public/private key pair), this information
will no longer be present in the new instance generated by #public_key. This feature is helpful
for publishing the Diffie-Hellman parameters without leaking any of the
private per-session information.
Example
dh = OpenSSL::PKey::DH.new(2048) # has public and private key set public_key = dh.public_key # contains only prime and generator parameters = public_key.to_der # it's safe to publish this
Please login to continue.