Class: Trezor::KeyManager
- Inherits:
-
Object
- Object
- Trezor::KeyManager
- Includes:
- Enumerable, Utils
- Defined in:
- lib/trezor/key_manager.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#each_identity ⇒ Object
For compatibility with Net::SSH::Authentication::KeyManager.
- #identities ⇒ Object
-
#initialize(identities_file_or_string) ⇒ KeyManager
constructor
A new instance of KeyManager.
- #sign(ssh_identity, blob) ⇒ Object
Constructor Details
#initialize(identities_file_or_string) ⇒ KeyManager
Returns a new instance of KeyManager.
9 10 11 |
# File 'lib/trezor/key_manager.rb', line 9 def initialize(identities_file_or_string) @path = identities_file_or_string end |
Instance Method Details
#each ⇒ Object
17 18 19 |
# File 'lib/trezor/key_manager.rb', line 17 def each identities.each { |i| yield i } end |
#each_identity ⇒ Object
For compatibility with Net::SSH::Authentication::KeyManager
22 23 24 |
# File 'lib/trezor/key_manager.rb', line 22 def each_identity each { |i| yield i.key } end |
#identities ⇒ Object
13 14 15 |
# File 'lib/trezor/key_manager.rb', line 13 def identities @identities ||= load_identities end |
#sign(ssh_identity, blob) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/trezor/key_manager.rb', line 26 def sign(ssh_identity, blob) nonce = blob.read_buffer.to_s type = blob.read_byte # SSH2_MSG_USERAUTH_REQUEST == 50 (from ssh2.h, line 108) user = blob.read_buffer.to_s conn = blob.read_buffer.to_s auth = blob.read_buffer.to_s have_sig = blob.read_byte # have_sig == 1 (from sshconnect2.c, line 1056) key_type = blob.read_buffer.to_s public_key = blob.read_buffer.to_s identity = identities.find { |i| i.key.fingerprint == ssh_identity.fingerprint } return unless identity identity.sign(blob) end |