Class: SshTresor::AgentKey
- Inherits:
-
Struct
- Object
- Struct
- SshTresor::AgentKey
- Defined in:
- lib/ssh_tresor/agent.rb
Instance Attribute Summary collapse
-
#blob ⇒ Object
Returns the value of attribute blob.
-
#comment ⇒ Object
Returns the value of attribute comment.
Instance Method Summary collapse
- #fingerprint ⇒ Object
- #fingerprint_bytes ⇒ Object
- #key_type ⇒ Object
- #matches_fingerprint?(prefix) ⇒ Boolean
- #md5_fingerprint ⇒ Object
- #security_key? ⇒ Boolean
- #ssh_type ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#blob ⇒ Object
Returns the value of attribute blob
11 12 13 |
# File 'lib/ssh_tresor/agent.rb', line 11 def blob @blob end |
#comment ⇒ Object
Returns the value of attribute comment
11 12 13 |
# File 'lib/ssh_tresor/agent.rb', line 11 def comment @comment end |
Instance Method Details
#fingerprint ⇒ Object
16 17 18 |
# File 'lib/ssh_tresor/agent.rb', line 16 def fingerprint "SHA256:#{Base64.strict_encode64(fingerprint_bytes).delete("=")}" end |
#fingerprint_bytes ⇒ Object
12 13 14 |
# File 'lib/ssh_tresor/agent.rb', line 12 def fingerprint_bytes @fingerprint_bytes ||= Digest::SHA256.digest(blob) end |
#key_type ⇒ Object
28 29 30 |
# File 'lib/ssh_tresor/agent.rb', line 28 def key_type @key_type ||= Agent.format_key_type(blob) end |
#matches_fingerprint?(prefix) ⇒ Boolean
36 37 38 39 40 |
# File 'lib/ssh_tresor/agent.rb', line 36 def matches_fingerprint?(prefix) normalized_prefix = prefix.delete_prefix("SHA256:") normalized_fingerprint = fingerprint.delete_prefix("SHA256:") normalized_fingerprint.start_with?(normalized_prefix) end |
#md5_fingerprint ⇒ Object
20 21 22 |
# File 'lib/ssh_tresor/agent.rb', line 20 def md5_fingerprint Digest::MD5.digest(blob).bytes.map { |byte| "%02x" % byte }.join(":") end |
#security_key? ⇒ Boolean
32 33 34 |
# File 'lib/ssh_tresor/agent.rb', line 32 def security_key? ssh_type.start_with?("sk-") end |
#ssh_type ⇒ Object
24 25 26 |
# File 'lib/ssh_tresor/agent.rb', line 24 def ssh_type @ssh_type ||= SSHEncoding::Reader.new(blob).string end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/ssh_tresor/agent.rb', line 42 def to_s "#{fingerprint} #{key_type} #{comment}" end |