class OpenSSL::PKey::RSA

This class is originally defined in the OpenSSL module. As needed, methods have been added to it by the Net::SSH module for convenience in dealing with SSH functionality.

Public Instance Methods

ssh_do_sign(data, sig_alg = nil) click to toggle source

Returns the signature for the given data.

# File lib/net/ssh/transport/openssl.rb, line 77
def ssh_do_sign(data, sig_alg = nil)
  digester =
    if sig_alg == "rsa-sha2-512"
      OpenSSL::Digest::SHA512.new
    elsif sig_alg == "rsa-sha2-256"
      OpenSSL::Digest::SHA256.new
    else
      OpenSSL::Digest::SHA1.new
    end
  sign(digester, data)
end
ssh_do_verify(sig, data, options = {}) click to toggle source

Verifies the given signature matches the given data.

# File lib/net/ssh/transport/openssl.rb, line 63
def ssh_do_verify(sig, data, options = {})
  digester =
    if options[:host_key] == "rsa-sha2-512"
      OpenSSL::Digest::SHA512.new
    elsif options[:host_key] == "rsa-sha2-256"
      OpenSSL::Digest::SHA256.new
    else
      OpenSSL::Digest::SHA1.new
    end

  verify(digester, sig, data)
end
ssh_signature_type()
Alias for: ssh_type
ssh_type() click to toggle source

Returns “ssh-rsa”, which is the description of this key type used by the SSH2 protocol.

# File lib/net/ssh/transport/openssl.rb, line 51
def ssh_type
  "ssh-rsa"
end
Also aliased as: ssh_signature_type
to_blob() click to toggle source

Converts the key to a blob, according to the SSH2 protocol.

# File lib/net/ssh/transport/openssl.rb, line 58
def to_blob
  @blob ||= Net::SSH::Buffer.from(:string, ssh_type, :bignum, e, :bignum, n).to_s
end