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.
26
27
28
29
30
|
# 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
|
Instance Method Details
#key_length ⇒ Object
56
57
58
59
60
|
# 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? ⇒ Boolean
44
45
46
47
48
|
# File 'lib/inspec/resources/key_rsa.rb', line 44
def private?
return if @key.nil?
@key.private?
end
|
#private_key ⇒ Object
50
51
52
53
54
|
# File 'lib/inspec/resources/key_rsa.rb', line 50
def private_key
return if @key.nil?
@key.to_s
end
|
#public? ⇒ Boolean
32
33
34
35
36
|
# File 'lib/inspec/resources/key_rsa.rb', line 32
def public?
return if @key.nil?
@key.public?
end
|
#public_key ⇒ Object
38
39
40
41
42
|
# File 'lib/inspec/resources/key_rsa.rb', line 38
def public_key
return if @key.nil?
@key.public_key.to_s
end
|
#resource_id ⇒ Object
62
63
64
|
# File 'lib/inspec/resources/key_rsa.rb', line 62
def resource_id
@key_path || "RSA Key"
end
|
#to_s ⇒ Object
66
67
68
|
# File 'lib/inspec/resources/key_rsa.rb', line 66
def to_s
"rsa_key #{@key_path}"
end
|