Class: Inspec::Resources::RsaKey
Instance Method Summary
collapse
Methods included from PkeyReader
#raise_if_unset, #read_pkey
Methods included from FileReader
#read_file_content
Constructor Details
#initialize(keypath, passphrase = nil) ⇒ RsaKey
Returns a new instance of RsaKey.
28
29
30
31
32
|
# File 'lib/resources/key_rsa.rb', line 28
def initialize(keypath, passphrase = nil)
@key_path = keypath
@passphrase = passphrase
@key = read_pkey(read_file_content(@key_path, allow_empty: true), @passphrase)
end
|
Instance Method Details
#key_length ⇒ Object
54
55
56
57
|
# File 'lib/resources/key_rsa.rb', line 54
def key_length
return if @key.nil?
@key.public_key.n.num_bytes * 8
end
|
#private? ⇒ Boolean
44
45
46
47
|
# File 'lib/resources/key_rsa.rb', line 44
def private?
return if @key.nil?
@key.private?
end
|
#private_key ⇒ Object
49
50
51
52
|
# File 'lib/resources/key_rsa.rb', line 49
def private_key
return if @key.nil?
@key.to_s
end
|
#public? ⇒ Boolean
34
35
36
37
|
# File 'lib/resources/key_rsa.rb', line 34
def public?
return if @key.nil?
@key.public?
end
|
#public_key ⇒ Object
39
40
41
42
|
# File 'lib/resources/key_rsa.rb', line 39
def public_key
return if @key.nil?
@key.public_key.to_s
end
|
#to_s ⇒ Object
59
60
61
|
# File 'lib/resources/key_rsa.rb', line 59
def to_s
"rsa_key #{@key_path}"
end
|