Class: Inspec::Resources::RsaKey
- Inherits:
-
Object
- Object
- Inspec::Resources::RsaKey
- Includes:
- FileReader
- Defined in:
- lib/resources/key_rsa.rb
Instance Method Summary collapse
-
#initialize(keypath, passphrase = nil) ⇒ RsaKey
constructor
A new instance of RsaKey.
- #key_length ⇒ Object
- #private? ⇒ Boolean
- #private_key ⇒ Object
- #public? ⇒ Boolean
- #public_key ⇒ Object
- #to_s ⇒ Object
Methods included from FileReader
Constructor Details
#initialize(keypath, passphrase = nil) ⇒ RsaKey
Returns a new instance of RsaKey.
26 27 28 29 30 |
# File 'lib/resources/key_rsa.rb', line 26 def initialize(keypath, passphrase = nil) @key_path = keypath @passphrase = passphrase @key = OpenSSL::PKey.read(read_file_content(@key_path, allow_empty: true), @passphrase) end |
Instance Method Details
#key_length ⇒ Object
52 53 54 55 |
# File 'lib/resources/key_rsa.rb', line 52 def key_length return if @key.nil? @key.public_key.n.num_bytes * 8 end |
#private? ⇒ Boolean
42 43 44 45 |
# File 'lib/resources/key_rsa.rb', line 42 def private? return if @key.nil? @key.private? end |
#private_key ⇒ Object
47 48 49 50 |
# File 'lib/resources/key_rsa.rb', line 47 def private_key return if @key.nil? @key.to_s end |
#public? ⇒ Boolean
32 33 34 35 |
# File 'lib/resources/key_rsa.rb', line 32 def public? return if @key.nil? @key.public? end |
#public_key ⇒ Object
37 38 39 40 |
# File 'lib/resources/key_rsa.rb', line 37 def public_key return if @key.nil? @key.public_key.to_s end |
#to_s ⇒ Object
57 58 59 |
# File 'lib/resources/key_rsa.rb', line 57 def to_s "rsa_key #{@key_path}" end |