hrr_rb_ssh 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/demo/server.rb +13 -1
  3. data/lib/hrr_rb_ssh/authentication/method/none/context.rb +1 -1
  4. data/lib/hrr_rb_ssh/authentication/method/none.rb +4 -4
  5. data/lib/hrr_rb_ssh/authentication/method/password/context.rb +1 -1
  6. data/lib/hrr_rb_ssh/authentication/method/password.rb +4 -4
  7. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/codable.rb +5 -5
  8. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss.rb +29 -18
  9. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa.rb +27 -16
  10. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm.rb +7 -13
  11. data/lib/hrr_rb_ssh/authentication/method/publickey/context.rb +1 -1
  12. data/lib/hrr_rb_ssh/authentication/method/publickey.rb +5 -5
  13. data/lib/hrr_rb_ssh/authentication/method.rb +6 -12
  14. data/lib/hrr_rb_ssh/authentication.rb +1 -1
  15. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env/context.rb +2 -2
  16. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env.rb +2 -3
  17. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec/context.rb +2 -2
  18. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec.rb +2 -3
  19. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req/context.rb +2 -2
  20. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req.rb +2 -3
  21. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell/context.rb +2 -2
  22. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell.rb +2 -3
  23. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem/context.rb +2 -2
  24. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem.rb +2 -3
  25. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type.rb +16 -11
  26. data/lib/hrr_rb_ssh/connection/channel/channel_type/session.rb +1 -15
  27. data/lib/hrr_rb_ssh/connection/channel/channel_type.rb +15 -10
  28. data/lib/hrr_rb_ssh/connection/channel.rb +1 -1
  29. data/lib/hrr_rb_ssh/data_type.rb +153 -0
  30. data/lib/hrr_rb_ssh/message/001_ssh_msg_disconnect.rb +6 -6
  31. data/lib/hrr_rb_ssh/message/002_ssh_msg_ignore.rb +4 -4
  32. data/lib/hrr_rb_ssh/message/003_ssh_msg_unimplemented.rb +4 -4
  33. data/lib/hrr_rb_ssh/message/004_ssh_msg_debug.rb +6 -6
  34. data/lib/hrr_rb_ssh/message/005_ssh_msg_service_request.rb +4 -4
  35. data/lib/hrr_rb_ssh/message/006_ssh_msg_service_accept.rb +4 -4
  36. data/lib/hrr_rb_ssh/message/020_ssh_msg_kexinit.rb +31 -31
  37. data/lib/hrr_rb_ssh/message/021_ssh_msg_newkeys.rb +3 -3
  38. data/lib/hrr_rb_ssh/message/030_ssh_msg_kexdh_init.rb +4 -4
  39. data/lib/hrr_rb_ssh/message/031_ssh_msg_kexdh_reply.rb +6 -6
  40. data/lib/hrr_rb_ssh/message/050_ssh_msg_userauth_request.rb +18 -18
  41. data/lib/hrr_rb_ssh/message/051_ssh_msg_userauth_failure.rb +5 -5
  42. data/lib/hrr_rb_ssh/message/052_ssh_msg_userauth_success.rb +3 -3
  43. data/lib/hrr_rb_ssh/message/060_ssh_msg_userauth_pk_ok.rb +5 -5
  44. data/lib/hrr_rb_ssh/message/080_ssh_msg_global_request.rb +13 -13
  45. data/lib/hrr_rb_ssh/message/081_ssh_msg_request_success.rb +6 -6
  46. data/lib/hrr_rb_ssh/message/082_ssh_msg_request_failure.rb +3 -3
  47. data/lib/hrr_rb_ssh/message/090_ssh_msg_channel_open.rb +25 -25
  48. data/lib/hrr_rb_ssh/message/091_ssh_msg_channel_open_confirmation.rb +25 -25
  49. data/lib/hrr_rb_ssh/message/092_ssh_msg_channel_open_failure.rb +7 -7
  50. data/lib/hrr_rb_ssh/message/093_ssh_msg_channel_window_adjust.rb +5 -5
  51. data/lib/hrr_rb_ssh/message/094_ssh_msg_channel_data.rb +5 -5
  52. data/lib/hrr_rb_ssh/message/095_ssh_msg_channel_extended_data.rb +6 -6
  53. data/lib/hrr_rb_ssh/message/096_ssh_msg_channel_eof.rb +4 -4
  54. data/lib/hrr_rb_ssh/message/097_ssh_msg_channel_close.rb +4 -4
  55. data/lib/hrr_rb_ssh/message/098_ssh_msg_channel_request.rb +53 -53
  56. data/lib/hrr_rb_ssh/message/099_ssh_msg_channel_success.rb +4 -4
  57. data/lib/hrr_rb_ssh/message/100_ssh_msg_channel_failure.rb +4 -4
  58. data/lib/hrr_rb_ssh/message/codable.rb +2 -3
  59. data/lib/hrr_rb_ssh/subclass_with_preference_listable.rb +29 -0
  60. data/lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb +4 -4
  61. data/lib/hrr_rb_ssh/transport/compression_algorithm/none.rb +1 -6
  62. data/lib/hrr_rb_ssh/transport/compression_algorithm/unfunctionable.rb +4 -0
  63. data/lib/hrr_rb_ssh/transport/compression_algorithm/zlib.rb +1 -6
  64. data/lib/hrr_rb_ssh/transport/compression_algorithm.rb +5 -11
  65. data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes128_cbc.rb +1 -2
  66. data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes128_ctr.rb +1 -2
  67. data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes192_cbc.rb +1 -2
  68. data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes192_ctr.rb +1 -2
  69. data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes256_cbc.rb +1 -2
  70. data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes256_ctr.rb +1 -2
  71. data/lib/hrr_rb_ssh/transport/encryption_algorithm/arcfour.rb +1 -2
  72. data/lib/hrr_rb_ssh/transport/encryption_algorithm/blowfish_cbc.rb +1 -2
  73. data/lib/hrr_rb_ssh/transport/encryption_algorithm/cast128_cbc.rb +1 -2
  74. data/lib/hrr_rb_ssh/transport/encryption_algorithm/functionable.rb +1 -2
  75. data/lib/hrr_rb_ssh/transport/encryption_algorithm/none.rb +1 -6
  76. data/lib/hrr_rb_ssh/transport/encryption_algorithm/three_des_cbc.rb +1 -2
  77. data/lib/hrr_rb_ssh/transport/encryption_algorithm/unfunctionable.rb +6 -0
  78. data/lib/hrr_rb_ssh/transport/encryption_algorithm.rb +5 -11
  79. data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman.rb +14 -14
  80. data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group14_sha1.rb +2 -5
  81. data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group1_sha1.rb +2 -5
  82. data/lib/hrr_rb_ssh/transport/kex_algorithm.rb +5 -10
  83. data/lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb +2 -3
  84. data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_md5.rb +3 -5
  85. data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_md5_96.rb +3 -5
  86. data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_sha1.rb +3 -5
  87. data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_sha1_96.rb +3 -5
  88. data/lib/hrr_rb_ssh/transport/mac_algorithm/none.rb +2 -8
  89. data/lib/hrr_rb_ssh/transport/mac_algorithm/unfunctionable.rb +4 -0
  90. data/lib/hrr_rb_ssh/transport/mac_algorithm.rb +5 -11
  91. data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss.rb +14 -13
  92. data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa.rb +12 -11
  93. data/lib/hrr_rb_ssh/transport/server_host_key_algorithm.rb +5 -10
  94. data/lib/hrr_rb_ssh/transport.rb +147 -108
  95. data/lib/hrr_rb_ssh/version.rb +1 -1
  96. metadata +4 -12
  97. data/lib/hrr_rb_ssh/authentication/method/method.rb +0 -34
  98. data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/algorithm.rb +0 -41
  99. data/lib/hrr_rb_ssh/connection/channel/channel_type/channel_type.rb +0 -30
  100. data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/request_type.rb +0 -34
  101. data/lib/hrr_rb_ssh/transport/compression_algorithm/compression_algorithm.rb +0 -34
  102. data/lib/hrr_rb_ssh/transport/data_type.rb +0 -163
  103. data/lib/hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm.rb +0 -34
  104. data/lib/hrr_rb_ssh/transport/kex_algorithm/kex_algorithm.rb +0 -34
  105. data/lib/hrr_rb_ssh/transport/mac_algorithm/mac_algorithm.rb +0 -34
  106. data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/server_host_key_algorithm.rb +0 -34
@@ -7,6 +7,10 @@ module HrrRbSsh
7
7
  class Transport
8
8
  class CompressionAlgorithm
9
9
  module Unfunctionable
10
+ def initialize direction=nil
11
+ @logger = HrrRbSsh::Logger.new(self.class.name)
12
+ end
13
+
10
14
  def deflate data
11
15
  data
12
16
  end
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/compression_algorithm/compression_algorithm'
5
4
  require 'hrr_rb_ssh/transport/compression_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,11 +8,7 @@ module HrrRbSsh
9
8
  class CompressionAlgorithm
10
9
  class Zlib < CompressionAlgorithm
11
10
  NAME = 'zlib'
12
-
13
- def initialize direction
14
- super
15
- end
16
-
11
+ PREFERENCE = 10
17
12
  include Functionable
18
13
  end
19
14
  end
@@ -1,24 +1,18 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
+ require 'hrr_rb_ssh/subclass_with_preference_listable'
5
+
4
6
  module HrrRbSsh
5
7
  class Transport
6
8
  class CompressionAlgorithm
7
- def self.list
8
- CompressionAlgorithm.list
9
- end
10
-
11
- def self.name_list
12
- CompressionAlgorithm.name_list
13
- end
14
-
15
- def self.[] key
16
- CompressionAlgorithm[key]
9
+ @subclass_list = Array.new
10
+ class << self
11
+ include SubclassWithPreferenceListable
17
12
  end
18
13
  end
19
14
  end
20
15
  end
21
16
 
22
- require 'hrr_rb_ssh/transport/compression_algorithm/compression_algorithm'
23
17
  require 'hrr_rb_ssh/transport/compression_algorithm/none'
24
18
  require 'hrr_rb_ssh/transport/compression_algorithm/zlib'
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm'
5
4
  require 'hrr_rb_ssh/transport/encryption_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,9 +8,9 @@ module HrrRbSsh
9
8
  class EncryptionAlgorithm
10
9
  class Aes128Cbc < EncryptionAlgorithm
11
10
  NAME = 'aes128-cbc'
11
+ PREFERENCE = 160
12
12
  CIPHER_NAME = "AES-128-CBC"
13
13
  BLOCK_SIZE = 16
14
-
15
14
  include Functionable
16
15
  end
17
16
  end
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm'
5
4
  require 'hrr_rb_ssh/transport/encryption_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,9 +8,9 @@ module HrrRbSsh
9
8
  class EncryptionAlgorithm
10
9
  class Aes128Ctr < EncryptionAlgorithm
11
10
  NAME = 'aes128-ctr'
11
+ PREFERENCE = 190
12
12
  CIPHER_NAME = "AES-128-CTR"
13
13
  BLOCK_SIZE = 16
14
-
15
14
  include Functionable
16
15
  end
17
16
  end
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm'
5
4
  require 'hrr_rb_ssh/transport/encryption_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,9 +8,9 @@ module HrrRbSsh
9
8
  class EncryptionAlgorithm
10
9
  class Aes192Cbc < EncryptionAlgorithm
11
10
  NAME = 'aes192-cbc'
11
+ PREFERENCE = 120
12
12
  CIPHER_NAME = "AES-192-CBC"
13
13
  BLOCK_SIZE = 16
14
-
15
14
  include Functionable
16
15
  end
17
16
  end
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm'
5
4
  require 'hrr_rb_ssh/transport/encryption_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,9 +8,9 @@ module HrrRbSsh
9
8
  class EncryptionAlgorithm
10
9
  class Aes192Ctr < EncryptionAlgorithm
11
10
  NAME = 'aes192-ctr'
11
+ PREFERENCE = 180
12
12
  CIPHER_NAME = "AES-192-CTR"
13
13
  BLOCK_SIZE = 16
14
-
15
14
  include Functionable
16
15
  end
17
16
  end
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm'
5
4
  require 'hrr_rb_ssh/transport/encryption_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,9 +8,9 @@ module HrrRbSsh
9
8
  class EncryptionAlgorithm
10
9
  class Aes256Cbc < EncryptionAlgorithm
11
10
  NAME = 'aes256-cbc'
11
+ PREFERENCE = 110
12
12
  CIPHER_NAME = "AES-256-CBC"
13
13
  BLOCK_SIZE = 16
14
-
15
14
  include Functionable
16
15
  end
17
16
  end
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm'
5
4
  require 'hrr_rb_ssh/transport/encryption_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,9 +8,9 @@ module HrrRbSsh
9
8
  class EncryptionAlgorithm
10
9
  class Aes256Ctr < EncryptionAlgorithm
11
10
  NAME = 'aes256-ctr'
11
+ PREFERENCE = 170
12
12
  CIPHER_NAME = "AES-256-CTR"
13
13
  BLOCK_SIZE = 16
14
-
15
14
  include Functionable
16
15
  end
17
16
  end
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm'
5
4
  require 'hrr_rb_ssh/transport/encryption_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,9 +8,9 @@ module HrrRbSsh
9
8
  class EncryptionAlgorithm
10
9
  class Arcfour < EncryptionAlgorithm
11
10
  NAME = 'arcfour'
11
+ PREFERENCE = 100
12
12
  CIPHER_NAME = "RC4"
13
13
  BLOCK_SIZE = 8
14
-
15
14
  include Functionable
16
15
  end
17
16
  end
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm'
5
4
  require 'hrr_rb_ssh/transport/encryption_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,9 +8,9 @@ module HrrRbSsh
9
8
  class EncryptionAlgorithm
10
9
  class BlowfishCbc < EncryptionAlgorithm
11
10
  NAME = 'blowfish-cbc'
11
+ PREFERENCE = 140
12
12
  CIPHER_NAME = "BF-CBC"
13
13
  BLOCK_SIZE = 8
14
-
15
14
  include Functionable
16
15
  end
17
16
  end
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm'
5
4
  require 'hrr_rb_ssh/transport/encryption_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,9 +8,9 @@ module HrrRbSsh
9
8
  class EncryptionAlgorithm
10
9
  class Cast128Cbc < EncryptionAlgorithm
11
10
  NAME = 'cast128-cbc'
11
+ PREFERENCE = 130
12
12
  CIPHER_NAME = "CAST5-CBC"
13
13
  BLOCK_SIZE = 8
14
-
15
14
  include Functionable
16
15
  end
17
16
  end
@@ -14,8 +14,7 @@ module HrrRbSsh
14
14
  end
15
15
 
16
16
  def initialize direction, iv, key
17
- super
18
-
17
+ @logger = HrrRbSsh::Logger.new(self.class.name)
19
18
  @cipher = OpenSSL::Cipher.new(self.class::CIPHER_NAME)
20
19
  case direction
21
20
  when HrrRbSsh::Transport::Direction::OUTGOING
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/logger'
5
4
  require 'hrr_rb_ssh/transport/encryption_algorithm/unfunctionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,12 +8,8 @@ module HrrRbSsh
9
8
  class EncryptionAlgorithm
10
9
  class None < EncryptionAlgorithm
11
10
  NAME = 'none'
11
+ PREFERENCE = 0
12
12
  BLOCK_SIZE = 0
13
-
14
- def initialize direction=nil, iv=nil, key=nil
15
- super
16
- end
17
-
18
13
  include Unfunctionable
19
14
  end
20
15
  end
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm'
5
4
  require 'hrr_rb_ssh/transport/encryption_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
@@ -9,9 +8,9 @@ module HrrRbSsh
9
8
  class EncryptionAlgorithm
10
9
  class ThreeDesCbc < EncryptionAlgorithm
11
10
  NAME = '3des-cbc'
11
+ PREFERENCE = 150
12
12
  CIPHER_NAME = "DES-EDE3-CBC"
13
13
  BLOCK_SIZE = 8
14
-
15
14
  include Functionable
16
15
  end
17
16
  end
@@ -1,6 +1,8 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
+ require 'hrr_rb_ssh/logger'
5
+
4
6
  module HrrRbSsh
5
7
  class Transport
6
8
  class EncryptionAlgorithm
@@ -10,6 +12,10 @@ module HrrRbSsh
10
12
  klass.const_set(:KEY_LENGTH, 0)
11
13
  end
12
14
 
15
+ def initialize direction=nil, iv=nil, key=nil
16
+ @logger = HrrRbSsh::Logger.new(self.class.name)
17
+ end
18
+
13
19
  def block_size
14
20
  self.class::BLOCK_SIZE
15
21
  end
@@ -1,25 +1,19 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
+ require 'hrr_rb_ssh/subclass_with_preference_listable'
5
+
4
6
  module HrrRbSsh
5
7
  class Transport
6
8
  class EncryptionAlgorithm
7
- def self.list
8
- EncryptionAlgorithm.list
9
- end
10
-
11
- def self.name_list
12
- EncryptionAlgorithm.name_list
13
- end
14
-
15
- def self.[] key
16
- EncryptionAlgorithm[key]
9
+ @subclass_list = Array.new
10
+ class << self
11
+ include SubclassWithPreferenceListable
17
12
  end
18
13
  end
19
14
  end
20
15
  end
21
16
 
22
- require 'hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm'
23
17
  require 'hrr_rb_ssh/transport/encryption_algorithm/none'
24
18
  require 'hrr_rb_ssh/transport/encryption_algorithm/three_des_cbc'
25
19
  require 'hrr_rb_ssh/transport/encryption_algorithm/blowfish_cbc'
@@ -2,26 +2,26 @@
2
2
  # vim: et ts=2 sw=2
3
3
 
4
4
  require 'openssl'
5
- require 'hrr_rb_ssh/transport/data_type'
5
+ require 'hrr_rb_ssh/logger'
6
+ require 'hrr_rb_ssh/data_type'
6
7
 
7
8
  module HrrRbSsh
8
9
  class Transport
9
10
  class KexAlgorithm
10
11
  module DiffieHellman
11
12
  H0_DEFINITION = [
12
- ['string', 'V_C'],
13
- ['string', 'V_S'],
14
- ['string', 'I_C'],
15
- ['string', 'I_S'],
16
- ['string', 'K_S'],
17
- ['mpint', 'e'],
18
- ['mpint', 'f'],
19
- ['mpint', 'k'],
13
+ [DataType::String, 'V_C'],
14
+ [DataType::String, 'V_S'],
15
+ [DataType::String, 'I_C'],
16
+ [DataType::String, 'I_S'],
17
+ [DataType::String, 'K_S'],
18
+ [DataType::Mpint, 'e'],
19
+ [DataType::Mpint, 'f'],
20
+ [DataType::Mpint, 'k'],
20
21
  ]
21
22
 
22
23
  def initialize
23
- super
24
-
24
+ @logger = HrrRbSsh::Logger.new(self.class.name)
25
25
  @dh = OpenSSL::PKey::DH.new
26
26
  if @dh.respond_to?(:set_pqg)
27
27
  @dh.set_pqg OpenSSL::BN.new(self.class::P, 16), nil, OpenSSL::BN.new(self.class::G)
@@ -35,7 +35,7 @@ module HrrRbSsh
35
35
  def encode definition, payload
36
36
  definition.map{ |data_type, field_name|
37
37
  field_value = if payload[field_name].instance_of? ::Proc then payload[field_name].call else payload[field_name] end
38
- HrrRbSsh::Transport::DataType[data_type].encode(field_value)
38
+ data_type.encode(field_value)
39
39
  }.join
40
40
  end
41
41
 
@@ -81,8 +81,8 @@ module HrrRbSsh
81
81
  end
82
82
 
83
83
  def build_key(_k, h, _x, session_id, key_length)
84
- k = HrrRbSsh::Transport::DataType::Mpint.encode _k
85
- x = HrrRbSsh::Transport::DataType::Byte.encode _x
84
+ k = DataType::Mpint.encode _k
85
+ x = DataType::Byte.encode _x
86
86
 
87
87
  key = OpenSSL::Digest.digest(self.class::DIGEST, k + h + x + session_id)
88
88
 
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/kex_algorithm/kex_algorithm'
5
4
  require 'hrr_rb_ssh/transport/kex_algorithm/diffie_hellman'
6
5
 
7
6
  module HrrRbSsh
@@ -9,7 +8,8 @@ module HrrRbSsh
9
8
  class KexAlgorithm
10
9
  class DiffieHellmanGroup14Sha1 < KexAlgorithm
11
10
  NAME = 'diffie-hellman-group14-sha1'
12
-
11
+ PREFERENCE = 20
12
+ DIGEST = 'sha1'
13
13
  P = \
14
14
  "FFFFFFFF" "FFFFFFFF" "C90FDAA2" "2168C234" \
15
15
  "C4C6628B" "80DC1CD1" "29024E08" "8A67CC74" \
@@ -28,9 +28,6 @@ module HrrRbSsh
28
28
  "3995497C" "EA956AE5" "15D22618" "98FA0510" \
29
29
  "15728E5A" "8AACAA68" "FFFFFFFF" "FFFFFFFF"
30
30
  G = 2
31
-
32
- DIGEST = 'sha1'
33
-
34
31
  include DiffieHellman
35
32
  end
36
33
  end
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/kex_algorithm/kex_algorithm'
5
4
  require 'hrr_rb_ssh/transport/kex_algorithm/diffie_hellman'
6
5
 
7
6
  module HrrRbSsh
@@ -9,7 +8,8 @@ module HrrRbSsh
9
8
  class KexAlgorithm
10
9
  class DiffieHellmanGroup1Sha1 < KexAlgorithm
11
10
  NAME = 'diffie-hellman-group1-sha1'
12
-
11
+ PREFERENCE = 10
12
+ DIGEST = 'sha1'
13
13
  P = \
14
14
  "FFFFFFFF" "FFFFFFFF" "C90FDAA2" "2168C234" \
15
15
  "C4C6628B" "80DC1CD1" "29024E08" "8A67CC74" \
@@ -20,9 +20,6 @@ module HrrRbSsh
20
20
  "EE386BFB" "5A899FA5" "AE9F2411" "7C4B1FE6" \
21
21
  "49286651" "ECE65381" "FFFFFFFF" "FFFFFFFF"
22
22
  G = 2
23
-
24
- DIGEST = 'sha1'
25
-
26
23
  include DiffieHellman
27
24
  end
28
25
  end
@@ -1,19 +1,14 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
+ require 'hrr_rb_ssh/subclass_with_preference_listable'
5
+
4
6
  module HrrRbSsh
5
7
  class Transport
6
8
  class KexAlgorithm
7
- def self.list
8
- KexAlgorithm.list
9
- end
10
-
11
- def self.name_list
12
- KexAlgorithm.name_list
13
- end
14
-
15
- def self.[] key
16
- KexAlgorithm[key]
9
+ @subclass_list = Array.new
10
+ class << self
11
+ include SubclassWithPreferenceListable
17
12
  end
18
13
  end
19
14
  end
@@ -8,8 +8,7 @@ module HrrRbSsh
8
8
  class MacAlgorithm
9
9
  module Functionable
10
10
  def initialize key
11
- super
12
-
11
+ @logger = HrrRbSsh::Logger.new(self.class.name)
13
12
  @key = key
14
13
  end
15
14
 
@@ -22,7 +21,7 @@ module HrrRbSsh
22
21
  end
23
22
 
24
23
  def compute sequence_number, unencrypted_packet
25
- data = HrrRbSsh::Transport::DataType::Uint32.encode(sequence_number) + unencrypted_packet
24
+ data = HrrRbSsh::DataType::Uint32.encode(sequence_number) + unencrypted_packet
26
25
  digest = OpenSSL::HMAC.digest self.class::DIGEST, @key, data
27
26
  digest[0, digest_length]
28
27
  end
@@ -1,19 +1,17 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/mac_algorithm/mac_algorithm'
5
4
  require 'hrr_rb_ssh/transport/mac_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
8
7
  class Transport
9
8
  class MacAlgorithm
10
9
  class HmacMd5 < MacAlgorithm
11
- NAME = 'hmac-md5'
12
- DIGEST = 'md5'
13
-
10
+ NAME = 'hmac-md5'
11
+ PREFERENCE = 30
12
+ DIGEST = 'md5'
14
13
  DIGEST_LENGTH = 16
15
14
  KEY_LENGTH = 16
16
-
17
15
  include Functionable
18
16
  end
19
17
  end
@@ -1,19 +1,17 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/mac_algorithm/mac_algorithm'
5
4
  require 'hrr_rb_ssh/transport/mac_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
8
7
  class Transport
9
8
  class MacAlgorithm
10
9
  class HmacMd5_96 < MacAlgorithm
11
- NAME = 'hmac-md5-96'
12
- DIGEST = 'md5'
13
-
10
+ NAME = 'hmac-md5-96'
11
+ PREFERENCE = 10
12
+ DIGEST = 'md5'
14
13
  DIGEST_LENGTH = 12
15
14
  KEY_LENGTH = 16
16
-
17
15
  include Functionable
18
16
  end
19
17
  end
@@ -1,19 +1,17 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/mac_algorithm/mac_algorithm'
5
4
  require 'hrr_rb_ssh/transport/mac_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
8
7
  class Transport
9
8
  class MacAlgorithm
10
9
  class HmacSha1 < MacAlgorithm
11
- NAME = 'hmac-sha1'
12
- DIGEST = 'sha1'
13
-
10
+ NAME = 'hmac-sha1'
11
+ PREFERENCE = 40
12
+ DIGEST = 'sha1'
14
13
  DIGEST_LENGTH = 20
15
14
  KEY_LENGTH = 20
16
-
17
15
  include Functionable
18
16
  end
19
17
  end
@@ -1,19 +1,17 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/mac_algorithm/mac_algorithm'
5
4
  require 'hrr_rb_ssh/transport/mac_algorithm/functionable'
6
5
 
7
6
  module HrrRbSsh
8
7
  class Transport
9
8
  class MacAlgorithm
10
9
  class HmacSha1_96 < MacAlgorithm
11
- NAME = 'hmac-sha1-96'
12
- DIGEST = 'sha1'
13
-
10
+ NAME = 'hmac-sha1-96'
11
+ PREFERENCE = 30
12
+ DIGEST = 'sha1'
14
13
  DIGEST_LENGTH = 12
15
14
  KEY_LENGTH = 20
16
-
17
15
  include Functionable
18
16
  end
19
17
  end
@@ -1,22 +1,16 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
- require 'hrr_rb_ssh/transport/mac_algorithm/mac_algorithm'
5
4
  require 'hrr_rb_ssh/transport/mac_algorithm/unfunctionable'
6
5
 
7
6
  module HrrRbSsh
8
7
  class Transport
9
8
  class MacAlgorithm
10
9
  class None < MacAlgorithm
11
- NAME = 'none'
12
-
10
+ NAME = 'none'
11
+ PREFERENCE = 0
13
12
  DIGEST_LENGTH = 0
14
13
  KEY_LENGTH = 0
15
-
16
- def initialize key=nil
17
- super
18
- end
19
-
20
14
  include Unfunctionable
21
15
  end
22
16
  end
@@ -7,6 +7,10 @@ module HrrRbSsh
7
7
  class Transport
8
8
  class MacAlgorithm
9
9
  module Unfunctionable
10
+ def initialize key=nil
11
+ @logger = HrrRbSsh::Logger.new(self.class.name)
12
+ end
13
+
10
14
  def digest_length
11
15
  self.class::DIGEST_LENGTH
12
16
  end
@@ -1,25 +1,19 @@
1
1
  # coding: utf-8
2
2
  # vim: et ts=2 sw=2
3
3
 
4
+ require 'hrr_rb_ssh/subclass_with_preference_listable'
5
+
4
6
  module HrrRbSsh
5
7
  class Transport
6
8
  class MacAlgorithm
7
- def self.list
8
- MacAlgorithm.list
9
- end
10
-
11
- def self.name_list
12
- MacAlgorithm.name_list
13
- end
14
-
15
- def self.[] key
16
- MacAlgorithm[key]
9
+ @subclass_list = Array.new
10
+ class << self
11
+ include SubclassWithPreferenceListable
17
12
  end
18
13
  end
19
14
  end
20
15
  end
21
16
 
22
- require 'hrr_rb_ssh/transport/mac_algorithm/mac_algorithm'
23
17
  require 'hrr_rb_ssh/transport/mac_algorithm/none'
24
18
  require 'hrr_rb_ssh/transport/mac_algorithm/hmac_sha1'
25
19
  require 'hrr_rb_ssh/transport/mac_algorithm/hmac_sha1_96'