class Inspec::Resources::RsaKey

Public Class Methods

new(keypath, passphrase = nil) click to toggle source
# File lib/inspec/resources/key_rsa.rb, line 26
def initialize(keypath, passphrase = nil)
  @key_path = keypath
  @passphrase = passphrase
  @key = read_pkey(read_file_content(@key_path, allow_empty: true), @passphrase)
end

Public Instance Methods

key_length() click to toggle source
# File lib/inspec/resources/key_rsa.rb, line 56
def key_length
  return if @key.nil?

  @key.public_key.n.num_bytes * 8
end
private?() click to toggle source
# File lib/inspec/resources/key_rsa.rb, line 44
def private?
  return if @key.nil?

  @key.private?
end
private_key() click to toggle source
# File lib/inspec/resources/key_rsa.rb, line 50
def private_key
  return if @key.nil?

  @key.to_s
end
public?() click to toggle source
# File lib/inspec/resources/key_rsa.rb, line 32
def public?
  return if @key.nil?

  @key.public?
end
public_key() click to toggle source
# File lib/inspec/resources/key_rsa.rb, line 38
def public_key
  return if @key.nil?

  @key.public_key.to_s
end
to_s() click to toggle source
# File lib/inspec/resources/key_rsa.rb, line 62
def to_s
  "rsa_key #{@key_path}"
end