Class: Trezor::KeyManager

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Utils
Defined in:
lib/trezor/key_manager.rb

Instance Method Summary collapse

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

#eachObject



17
18
19
# File 'lib/trezor/key_manager.rb', line 17

def each
  identities.each { |i| yield i }
end

#each_identityObject

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

#identitiesObject



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