hrr_rb_ssh 0.3.0.pre1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -3
  3. data/.travis.yml +1 -0
  4. data/README.md +208 -46
  5. data/demo/client.rb +71 -0
  6. data/demo/echo_server.rb +8 -3
  7. data/demo/more_flexible_auth.rb +105 -0
  8. data/demo/multi_step_auth.rb +99 -0
  9. data/demo/server.rb +10 -4
  10. data/demo/subsystem_echo_server.rb +8 -3
  11. data/hrr_rb_ssh.gemspec +6 -6
  12. data/lib/hrr_rb_ssh.rb +1 -1
  13. data/lib/hrr_rb_ssh/algorithm/publickey.rb +0 -1
  14. data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2.rb +12 -9
  15. data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2/ecdsa_signature_blob.rb +2 -4
  16. data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2/public_key_blob.rb +2 -4
  17. data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2/signature.rb +2 -4
  18. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_dss.rb +10 -7
  19. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_dss/public_key_blob.rb +2 -4
  20. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_dss/signature.rb +2 -4
  21. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa.rb +9 -6
  22. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa/public_key_blob.rb +2 -4
  23. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa/signature.rb +2 -4
  24. data/lib/hrr_rb_ssh/authentication.rb +103 -22
  25. data/lib/hrr_rb_ssh/authentication/constant.rb +14 -0
  26. data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb +44 -7
  27. data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/context.rb +16 -9
  28. data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_request.rb +7 -6
  29. data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_response.rb +5 -2
  30. data/lib/hrr_rb_ssh/authentication/method/none.rb +23 -7
  31. data/lib/hrr_rb_ssh/authentication/method/none/context.rb +15 -7
  32. data/lib/hrr_rb_ssh/authentication/method/password.rb +28 -7
  33. data/lib/hrr_rb_ssh/authentication/method/password/context.rb +16 -7
  34. data/lib/hrr_rb_ssh/authentication/method/publickey.rb +63 -10
  35. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm.rb +0 -1
  36. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb +32 -8
  37. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/signature_blob.rb +2 -4
  38. data/lib/hrr_rb_ssh/authentication/method/publickey/context.rb +11 -2
  39. data/lib/hrr_rb_ssh/client.rb +234 -0
  40. data/lib/hrr_rb_ssh/codable.rb +15 -13
  41. data/lib/hrr_rb_ssh/compat/ruby.rb +0 -1
  42. data/lib/hrr_rb_ssh/connection.rb +145 -75
  43. data/lib/hrr_rb_ssh/connection/channel.rb +342 -109
  44. data/lib/hrr_rb_ssh/connection/channel/channel_type/direct_tcpip.rb +24 -19
  45. data/lib/hrr_rb_ssh/connection/channel/channel_type/forwarded_tcpip.rb +24 -19
  46. data/lib/hrr_rb_ssh/connection/channel/channel_type/session.rb +19 -12
  47. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/proc_chain.rb +0 -2
  48. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/proc_chain/chain_context.rb +0 -3
  49. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env.rb +2 -5
  50. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env/context.rb +5 -4
  51. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec.rb +2 -5
  52. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec/context.rb +5 -4
  53. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req.rb +2 -5
  54. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req/context.rb +5 -4
  55. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell.rb +2 -5
  56. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell/context.rb +5 -4
  57. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem.rb +2 -5
  58. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem/context.rb +5 -4
  59. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/window_change.rb +2 -5
  60. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/window_change/context.rb +5 -4
  61. data/lib/hrr_rb_ssh/connection/global_request_handler.rb +14 -12
  62. data/lib/hrr_rb_ssh/connection/request_handler.rb +1 -3
  63. data/lib/hrr_rb_ssh/connection/request_handler/reference_env_request_handler.rb +0 -2
  64. data/lib/hrr_rb_ssh/connection/request_handler/reference_exec_request_handler.rb +4 -6
  65. data/lib/hrr_rb_ssh/connection/request_handler/reference_pty_req_request_handler.rb +10 -12
  66. data/lib/hrr_rb_ssh/connection/request_handler/reference_shell_request_handler.rb +4 -6
  67. data/lib/hrr_rb_ssh/connection/request_handler/reference_window_change_request_handler.rb +0 -2
  68. data/lib/hrr_rb_ssh/error/closed_authentication.rb +1 -1
  69. data/lib/hrr_rb_ssh/error/closed_connection.rb +1 -1
  70. data/lib/hrr_rb_ssh/error/closed_transport.rb +1 -1
  71. data/lib/hrr_rb_ssh/loggable.rb +42 -0
  72. data/lib/hrr_rb_ssh/message/001_ssh_msg_disconnect.rb +2 -4
  73. data/lib/hrr_rb_ssh/message/002_ssh_msg_ignore.rb +2 -4
  74. data/lib/hrr_rb_ssh/message/003_ssh_msg_unimplemented.rb +2 -4
  75. data/lib/hrr_rb_ssh/message/004_ssh_msg_debug.rb +2 -4
  76. data/lib/hrr_rb_ssh/message/005_ssh_msg_service_request.rb +2 -4
  77. data/lib/hrr_rb_ssh/message/006_ssh_msg_service_accept.rb +2 -4
  78. data/lib/hrr_rb_ssh/message/020_ssh_msg_kexinit.rb +2 -4
  79. data/lib/hrr_rb_ssh/message/021_ssh_msg_newkeys.rb +2 -4
  80. data/lib/hrr_rb_ssh/message/030_ssh_msg_kex_dh_gex_request_old.rb +2 -4
  81. data/lib/hrr_rb_ssh/message/030_ssh_msg_kexdh_init.rb +2 -4
  82. data/lib/hrr_rb_ssh/message/030_ssh_msg_kexecdh_init.rb +2 -4
  83. data/lib/hrr_rb_ssh/message/031_ssh_msg_kex_dh_gex_group.rb +2 -4
  84. data/lib/hrr_rb_ssh/message/031_ssh_msg_kexdh_reply.rb +2 -4
  85. data/lib/hrr_rb_ssh/message/031_ssh_msg_kexecdh_reply.rb +2 -4
  86. data/lib/hrr_rb_ssh/message/032_ssh_msg_kex_dh_gex_init.rb +2 -4
  87. data/lib/hrr_rb_ssh/message/033_ssh_msg_kex_dh_gex_reply.rb +2 -4
  88. data/lib/hrr_rb_ssh/message/034_ssh_msg_kex_dh_gex_request.rb +2 -4
  89. data/lib/hrr_rb_ssh/message/050_ssh_msg_userauth_request.rb +2 -4
  90. data/lib/hrr_rb_ssh/message/051_ssh_msg_userauth_failure.rb +2 -4
  91. data/lib/hrr_rb_ssh/message/052_ssh_msg_userauth_success.rb +2 -4
  92. data/lib/hrr_rb_ssh/message/060_ssh_msg_userauth_info_request.rb +2 -4
  93. data/lib/hrr_rb_ssh/message/060_ssh_msg_userauth_pk_ok.rb +2 -4
  94. data/lib/hrr_rb_ssh/message/061_ssh_msg_userauth_info_response.rb +2 -4
  95. data/lib/hrr_rb_ssh/message/080_ssh_msg_global_request.rb +2 -4
  96. data/lib/hrr_rb_ssh/message/081_ssh_msg_request_success.rb +2 -4
  97. data/lib/hrr_rb_ssh/message/082_ssh_msg_request_failure.rb +2 -4
  98. data/lib/hrr_rb_ssh/message/090_ssh_msg_channel_open.rb +2 -4
  99. data/lib/hrr_rb_ssh/message/091_ssh_msg_channel_open_confirmation.rb +2 -4
  100. data/lib/hrr_rb_ssh/message/092_ssh_msg_channel_open_failure.rb +2 -4
  101. data/lib/hrr_rb_ssh/message/093_ssh_msg_channel_window_adjust.rb +2 -4
  102. data/lib/hrr_rb_ssh/message/094_ssh_msg_channel_data.rb +2 -4
  103. data/lib/hrr_rb_ssh/message/095_ssh_msg_channel_extended_data.rb +2 -4
  104. data/lib/hrr_rb_ssh/message/096_ssh_msg_channel_eof.rb +2 -4
  105. data/lib/hrr_rb_ssh/message/097_ssh_msg_channel_close.rb +2 -4
  106. data/lib/hrr_rb_ssh/message/098_ssh_msg_channel_request.rb +3 -5
  107. data/lib/hrr_rb_ssh/message/099_ssh_msg_channel_success.rb +2 -4
  108. data/lib/hrr_rb_ssh/message/100_ssh_msg_channel_failure.rb +2 -4
  109. data/lib/hrr_rb_ssh/server.rb +16 -10
  110. data/lib/hrr_rb_ssh/transport.rb +113 -77
  111. data/lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb +5 -3
  112. data/lib/hrr_rb_ssh/transport/compression_algorithm/unfunctionable.rb +5 -3
  113. data/lib/hrr_rb_ssh/transport/encryption_algorithm/functionable.rb +5 -3
  114. data/lib/hrr_rb_ssh/transport/encryption_algorithm/unfunctionable.rb +5 -3
  115. data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman.rb +43 -37
  116. data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman/h0.rb +2 -4
  117. data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange.rb +87 -52
  118. data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange/h0.rb +2 -4
  119. data/lib/hrr_rb_ssh/transport/kex_algorithm/elliptic_curve_diffie_hellman.rb +43 -37
  120. data/lib/hrr_rb_ssh/transport/kex_algorithm/elliptic_curve_diffie_hellman/h0.rb +2 -4
  121. data/lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb +5 -3
  122. data/lib/hrr_rb_ssh/transport/mac_algorithm/unfunctionable.rb +5 -3
  123. data/lib/hrr_rb_ssh/transport/receiver.rb +8 -7
  124. data/lib/hrr_rb_ssh/transport/sender.rb +5 -3
  125. data/lib/hrr_rb_ssh/transport/sequence_number.rb +0 -4
  126. data/lib/hrr_rb_ssh/transport/server_host_key_algorithm.rb +0 -1
  127. data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/functionable.rb +5 -3
  128. data/lib/hrr_rb_ssh/version.rb +1 -1
  129. metadata +18 -51
  130. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb +0 -61
  131. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key.rb +0 -29
  132. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key_content.rb +0 -26
  133. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/pkey.rb +0 -158
  134. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/public_key_blob.rb +0 -23
  135. data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/signature.rb +0 -23
  136. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_ed25519.rb +0 -21
  137. data/lib/hrr_rb_ssh/compat/ruby/array.rb +0 -14
  138. data/lib/hrr_rb_ssh/logger.rb +0 -56
  139. data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_ed25519.rb +0 -20
@@ -8,10 +8,8 @@ module HrrRbSsh
8
8
  class Transport
9
9
  class KexAlgorithm
10
10
  module DiffieHellmanGroupExchange
11
- module H0
12
- class << self
13
- include Codable
14
- end
11
+ class H0
12
+ include Codable
15
13
  DEFINITION = [
16
14
  [DataType::String, :'V_C'],
17
15
  [DataType::String, :'V_S'],
@@ -2,7 +2,7 @@
2
2
  # vim: et ts=2 sw=2
3
3
 
4
4
  require 'openssl'
5
- require 'hrr_rb_ssh/logger'
5
+ require 'hrr_rb_ssh/loggable'
6
6
  require 'hrr_rb_ssh/data_type'
7
7
  require 'hrr_rb_ssh/transport/kex_algorithm/iv_computable'
8
8
 
@@ -10,80 +10,86 @@ module HrrRbSsh
10
10
  class Transport
11
11
  class KexAlgorithm
12
12
  module EllipticCurveDiffieHellman
13
+ include Loggable
13
14
  include IvComputable
14
15
 
15
- def initialize
16
- @logger = Logger.new(self.class.name)
16
+ def initialize logger: nil
17
+ self.logger = logger
17
18
  @dh = OpenSSL::PKey::EC.new(self.class::CURVE_NAME)
18
19
  @dh.generate_key
20
+ @public_key = @dh.public_key.to_bn.to_i
19
21
  end
20
22
 
21
- def start transport, mode
22
- case mode
23
+ def start transport
24
+ case transport.mode
23
25
  when Mode::SERVER
24
- receive_kexecdh_init transport.receive
26
+ @k_s = transport.server_host_key_algorithm.server_public_host_key
27
+ @q_s = @public_key
28
+ message = receive_kexecdh_init transport.receive
29
+ @q_c = message[:'Q_C']
30
+ @shared_secret = OpenSSL::BN.new(@dh.dh_compute_key(OpenSSL::PKey::EC::Point.new(OpenSSL::PKey::EC.new(self.class::CURVE_NAME).group, OpenSSL::BN.new(@q_c))), 2).to_i
25
31
  send_kexecdh_reply transport
26
- else
27
- raise "unsupported mode"
32
+ when Mode::CLIENT
33
+ @q_c = @public_key
34
+ send_kexecdh_init transport
35
+ message = receive_kexecdh_reply transport.receive
36
+ @k_s = message[:'K_S']
37
+ @q_s = message[:'Q_S']
38
+ @shared_secret = OpenSSL::BN.new(@dh.dh_compute_key(OpenSSL::PKey::EC::Point.new(OpenSSL::PKey::EC.new(self.class::CURVE_NAME).group, OpenSSL::BN.new(@q_s))), 2).to_i
28
39
  end
29
40
  end
30
41
 
31
- def set_q_c q_c
32
- @q_c = q_c
33
- end
34
-
35
42
  def shared_secret
36
- k = OpenSSL::BN.new(@dh.dh_compute_key(OpenSSL::PKey::EC::Point.new(OpenSSL::PKey::EC.new(self.class::CURVE_NAME).group, OpenSSL::BN.new(@q_c))), 2).to_i
37
- end
38
-
39
- def public_key
40
- f = @dh.public_key.to_bn.to_i
43
+ @shared_secret
41
44
  end
42
45
 
43
46
  def hash transport
44
- q_c = @q_c
45
- q_s = public_key
46
- k = shared_secret
47
-
48
47
  h0_payload = {
49
48
  :'V_C' => transport.v_c,
50
49
  :'V_S' => transport.v_s,
51
50
  :'I_C' => transport.i_c,
52
51
  :'I_S' => transport.i_s,
53
- :'K_S' => transport.server_host_key_algorithm.server_public_host_key,
54
- :'Q_C' => q_c,
55
- :'Q_S' => q_s,
56
- :'K' => k,
52
+ :'K_S' => @k_s,
53
+ :'Q_C' => @q_c,
54
+ :'Q_S' => @q_s,
55
+ :'K' => @shared_secret,
57
56
  }
58
- h0 = H0.encode h0_payload
59
-
60
- h = OpenSSL::Digest.digest self.class::DIGEST, h0
61
-
62
- h
57
+ h0 = H0.new(logger: logger).encode h0_payload
58
+ h = OpenSSL::Digest.digest self.class::DIGEST, h0
63
59
  end
64
60
 
65
61
  def sign transport
66
62
  h = hash transport
67
63
  s = transport.server_host_key_algorithm.sign h
68
-
69
- s
70
64
  end
71
65
 
72
66
  def receive_kexecdh_init payload
73
- message = Message::SSH_MSG_KEXECDH_INIT.decode payload
74
- set_q_c message[:'Q_C']
67
+ Message::SSH_MSG_KEXECDH_INIT.new(logger: logger).decode payload
75
68
  end
76
69
 
77
70
  def send_kexecdh_reply transport
78
71
  message = {
79
72
  :'message number' => Message::SSH_MSG_KEXECDH_REPLY::VALUE,
80
- :'K_S' => transport.server_host_key_algorithm.server_public_host_key,
81
- :'Q_S' => public_key,
73
+ :'K_S' => @k_s,
74
+ :'Q_S' => @q_s,
82
75
  :'signature of H' => sign(transport),
83
76
  }
84
- payload = Message::SSH_MSG_KEXECDH_REPLY.encode message
77
+ payload = Message::SSH_MSG_KEXECDH_REPLY.new(logger: logger).encode message
85
78
  transport.send payload
86
79
  end
80
+
81
+ def send_kexecdh_init transport
82
+ message = {
83
+ :'message number' => Message::SSH_MSG_KEXECDH_INIT::VALUE,
84
+ :'Q_C' => @q_c,
85
+ }
86
+ payload = Message::SSH_MSG_KEXECDH_INIT.new(logger: logger).encode message
87
+ transport.send payload
88
+ end
89
+
90
+ def receive_kexecdh_reply payload
91
+ Message::SSH_MSG_KEXECDH_REPLY.new(logger: logger).decode payload
92
+ end
87
93
  end
88
94
  end
89
95
  end
@@ -8,10 +8,8 @@ module HrrRbSsh
8
8
  class Transport
9
9
  class KexAlgorithm
10
10
  module EllipticCurveDiffieHellman
11
- module H0
12
- class << self
13
- include Codable
14
- end
11
+ class H0
12
+ include Codable
15
13
  DEFINITION = [
16
14
  [DataType::String, :'V_C'],
17
15
  [DataType::String, :'V_S'],
@@ -1,14 +1,16 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  class Transport
8
8
  class MacAlgorithm
9
9
  module Functionable
10
- def initialize key
11
- @logger = Logger.new(self.class.name)
10
+ include Loggable
11
+
12
+ def initialize key, logger: nil
13
+ self.logger = logger
12
14
  @key = key
13
15
  end
14
16
 
@@ -1,14 +1,16 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  class Transport
8
8
  class MacAlgorithm
9
9
  module Unfunctionable
10
- def initialize key=nil
11
- @logger = Logger.new(self.class.name)
10
+ include Loggable
11
+
12
+ def initialize key=nil, logger: nil
13
+ self.logger = logger
12
14
  end
13
15
 
14
16
  def digest_length
@@ -1,14 +1,15 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
5
- #require 'hrr_rb_ssh/transport/packet'
4
+ require 'hrr_rb_ssh/loggable'
6
5
 
7
6
  module HrrRbSsh
8
7
  class Transport
9
8
  class Receiver
10
- def initialize
11
- @logger = Logger.new self.class.name
9
+ include Loggable
10
+
11
+ def initialize logger: nil
12
+ self.logger = logger
12
13
  end
13
14
 
14
15
  def depacketize transport, packet
@@ -34,7 +35,7 @@ module HrrRbSsh
34
35
  block_size = [transport.incoming_encryption_algorithm.block_size, minimum_block_size].max
35
36
  encrypted_packet.push transport.io.read(block_size)
36
37
  if (encrypted_packet.last == nil) || (encrypted_packet.last.length != block_size)
37
- @logger.warn { "IO is EOF" }
38
+ log_info { "IO is EOF" }
38
39
  raise EOFError
39
40
  end
40
41
  unencrypted_packet.push transport.incoming_encryption_algorithm.decrypt(encrypted_packet.last)
@@ -43,7 +44,7 @@ module HrrRbSsh
43
44
  following_packet_length = packet_length_field_length + packet_length - block_size
44
45
  encrypted_packet.push transport.io.read(following_packet_length)
45
46
  if (encrypted_packet.last == nil) || (encrypted_packet.last.length != following_packet_length)
46
- @logger.warn { "IO is EOF" }
47
+ log_info { "IO is EOF" }
47
48
  raise EOFError
48
49
  end
49
50
  unencrypted_packet.push transport.incoming_encryption_algorithm.decrypt(encrypted_packet.last)
@@ -55,7 +56,7 @@ module HrrRbSsh
55
56
  mac_length = transport.incoming_mac_algorithm.digest_length
56
57
  mac = transport.io.read mac_length
57
58
  if (mac == nil) || (mac.length != mac_length)
58
- @logger.warn { "IO is EOF" }
59
+ log_info { "IO is EOF" }
59
60
  raise EOFError
60
61
  end
61
62
  mac
@@ -1,13 +1,15 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  class Transport
8
8
  class Sender
9
- def initialize
10
- @logger = Logger.new self.class.name
9
+ include Loggable
10
+
11
+ def initialize logger: nil
12
+ self.logger = logger
11
13
  end
12
14
 
13
15
  def packetize transport, payload
@@ -1,8 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
5
-
6
4
  module HrrRbSsh
7
5
  class Transport
8
6
  class SequenceNumber
@@ -10,8 +8,6 @@ module HrrRbSsh
10
8
 
11
9
  def initialize
12
10
  @sequence_number = 0
13
-
14
- @logger = Logger.new self.class.name
15
11
  end
16
12
 
17
13
  def increment
@@ -19,4 +19,3 @@ require 'hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa'
19
19
  require 'hrr_rb_ssh/transport/server_host_key_algorithm/ecdsa_sha2_nistp256'
20
20
  require 'hrr_rb_ssh/transport/server_host_key_algorithm/ecdsa_sha2_nistp384'
21
21
  require 'hrr_rb_ssh/transport/server_host_key_algorithm/ecdsa_sha2_nistp521'
22
- require 'hrr_rb_ssh/transport/server_host_key_algorithm/ssh_ed25519'
@@ -1,14 +1,16 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
4
+ require 'hrr_rb_ssh/loggable'
5
5
 
6
6
  module HrrRbSsh
7
7
  class Transport
8
8
  class ServerHostKeyAlgorithm
9
9
  module Functionable
10
- def initialize secret_key=nil
11
- @logger = Logger.new(self.class.name)
10
+ include Loggable
11
+
12
+ def initialize secret_key=nil, logger: nil
13
+ self.logger = logger
12
14
  @publickey = Algorithm::Publickey[self.class::NAME].new (secret_key || self.class::SECRET_KEY)
13
15
  end
14
16
 
@@ -2,5 +2,5 @@
2
2
  # vim: et ts=2 sw=2
3
3
 
4
4
  module HrrRbSsh
5
- VERSION = "0.3.0.pre1"
5
+ VERSION = "0.4.2"
6
6
  end
metadata CHANGED
@@ -1,57 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hrr_rb_ssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - hirura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-20 00:00:00.000000000 Z
11
+ date: 2020-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ed25519
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.2'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.2'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.16'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.16'
41
13
  - !ruby/object:Gem::Dependency
42
14
  name: rake
43
15
  requirement: !ruby/object:Gem::Requirement
44
16
  requirements:
45
17
  - - "~>"
46
18
  - !ruby/object:Gem::Version
47
- version: '10.0'
19
+ version: '12.0'
48
20
  type: :development
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
24
  - - "~>"
53
25
  - !ruby/object:Gem::Version
54
- version: '10.0'
26
+ version: '12.0'
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: rspec
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -67,20 +39,20 @@ dependencies:
67
39
  - !ruby/object:Gem::Version
68
40
  version: '3.0'
69
41
  - !ruby/object:Gem::Dependency
70
- name: codeclimate-test-reporter
42
+ name: simplecov
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
45
  - - "~>"
74
46
  - !ruby/object:Gem::Version
75
- version: 1.0.8
47
+ version: '0.16'
76
48
  type: :development
77
49
  prerelease: false
78
50
  version_requirements: !ruby/object:Gem::Requirement
79
51
  requirements:
80
52
  - - "~>"
81
53
  - !ruby/object:Gem::Version
82
- version: 1.0.8
83
- description: Pure Ruby SSH 2.0 server implementation
54
+ version: '0.16'
55
+ description: Pure Ruby SSH 2.0 server and client implementation
84
56
  email:
85
57
  - hirura@gmail.com
86
58
  executables: []
@@ -95,7 +67,10 @@ files:
95
67
  - LICENSE
96
68
  - README.md
97
69
  - Rakefile
70
+ - demo/client.rb
98
71
  - demo/echo_server.rb
72
+ - demo/more_flexible_auth.rb
73
+ - demo/multi_step_auth.rb
99
74
  - demo/server.rb
100
75
  - demo/subsystem_echo_server.rb
101
76
  - hrr_rb_ssh.gemspec
@@ -112,17 +87,12 @@ files:
112
87
  - lib/hrr_rb_ssh/algorithm/publickey/ssh_dss.rb
113
88
  - lib/hrr_rb_ssh/algorithm/publickey/ssh_dss/public_key_blob.rb
114
89
  - lib/hrr_rb_ssh/algorithm/publickey/ssh_dss/signature.rb
115
- - lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb
116
- - lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key.rb
117
- - lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key_content.rb
118
- - lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/pkey.rb
119
- - lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/public_key_blob.rb
120
- - lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/signature.rb
121
90
  - lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa.rb
122
91
  - lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa/public_key_blob.rb
123
92
  - lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa/signature.rb
124
93
  - lib/hrr_rb_ssh/authentication.rb
125
94
  - lib/hrr_rb_ssh/authentication/authenticator.rb
95
+ - lib/hrr_rb_ssh/authentication/constant.rb
126
96
  - lib/hrr_rb_ssh/authentication/method.rb
127
97
  - lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb
128
98
  - lib/hrr_rb_ssh/authentication/method/keyboard_interactive/context.rb
@@ -140,16 +110,15 @@ files:
140
110
  - lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb
141
111
  - lib/hrr_rb_ssh/authentication/method/publickey/algorithm/signature_blob.rb
142
112
  - lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss.rb
143
- - lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_ed25519.rb
144
113
  - lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa.rb
145
114
  - lib/hrr_rb_ssh/authentication/method/publickey/context.rb
115
+ - lib/hrr_rb_ssh/client.rb
146
116
  - lib/hrr_rb_ssh/codable.rb
147
117
  - lib/hrr_rb_ssh/compat.rb
148
118
  - lib/hrr_rb_ssh/compat/openssh.rb
149
119
  - lib/hrr_rb_ssh/compat/openssh/authorized_keys.rb
150
120
  - lib/hrr_rb_ssh/compat/openssh/public_key.rb
151
121
  - lib/hrr_rb_ssh/compat/ruby.rb
152
- - lib/hrr_rb_ssh/compat/ruby/array.rb
153
122
  - lib/hrr_rb_ssh/compat/ruby/openssl.rb
154
123
  - lib/hrr_rb_ssh/compat/ruby/openssl/bn.rb
155
124
  - lib/hrr_rb_ssh/compat/ruby/queue.rb
@@ -193,7 +162,7 @@ files:
193
162
  - lib/hrr_rb_ssh/error/closed_authentication.rb
194
163
  - lib/hrr_rb_ssh/error/closed_connection.rb
195
164
  - lib/hrr_rb_ssh/error/closed_transport.rb
196
- - lib/hrr_rb_ssh/logger.rb
165
+ - lib/hrr_rb_ssh/loggable.rb
197
166
  - lib/hrr_rb_ssh/message.rb
198
167
  - lib/hrr_rb_ssh/message/001_ssh_msg_disconnect.rb
199
168
  - lib/hrr_rb_ssh/message/002_ssh_msg_ignore.rb
@@ -298,7 +267,6 @@ files:
298
267
  - lib/hrr_rb_ssh/transport/server_host_key_algorithm/ecdsa_sha2_nistp521.rb
299
268
  - lib/hrr_rb_ssh/transport/server_host_key_algorithm/functionable.rb
300
269
  - lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss.rb
301
- - lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_ed25519.rb
302
270
  - lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa.rb
303
271
  - lib/hrr_rb_ssh/version.rb
304
272
  homepage: https://github.com/hirura/hrr_rb_ssh
@@ -316,13 +284,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
316
284
  version: 2.0.0
317
285
  required_rubygems_version: !ruby/object:Gem::Requirement
318
286
  requirements:
319
- - - ">"
287
+ - - ">="
320
288
  - !ruby/object:Gem::Version
321
- version: 1.3.1
289
+ version: '0'
322
290
  requirements: []
323
- rubyforge_project:
324
- rubygems_version: 2.7.6
291
+ rubygems_version: 3.1.2
325
292
  signing_key:
326
293
  specification_version: 4
327
- summary: Pure Ruby SSH 2.0 server implementation
294
+ summary: Pure Ruby SSH 2.0 server and client implementation
328
295
  test_files: []