module PuTTY::Key::OpenSSL::DSA

The {DSA} module is included into OpenSSL::PKey::DSA when using the PuTTY::Key refinement or calling {PuTTY::Key.global_install}. This adds a to_ppk instance method to OpenSSL::PKey::DSA.

Public Instance Methods

to_ppk() click to toggle source

Returns a new {PPK} instance that is equivalent to this key.

to_ppk can be called on instances of OpenSSL::PKey::DSA.

@return [PPK] A new instance of {PPK} that is equivalent to this key.

@raise [InvalidStateError] If the key has not been initialized.

# File lib/putty/key/openssl.rb, line 117
def to_ppk
  PPK.new.tap do |ppk|
    ppk.algorithm = 'ssh-dss'
    begin
      ppk.public_blob = Util.ssh_pack('ssh-dss', p, q, g, pub_key)
      ppk.private_blob = Util.ssh_pack(priv_key)
    rescue NilValueError
      raise InvalidStateError, 'The key has not been fully initialized (the p, q, g, pub_key and priv_key parameters must all be assigned)'
    end
  end
end