hrr_rb_ssh 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/demo/server.rb +5 -97
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss/public_key_blob.rb +30 -0
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss/signature.rb +27 -0
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss/signature_blob.rb +33 -0
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss.rb +8 -31
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa/public_key_blob.rb +28 -0
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa/signature.rb +27 -0
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa/signature_blob.rb +33 -0
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa.rb +8 -29
- data/lib/hrr_rb_ssh/codable.rb +64 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/window_change/context.rb +50 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/window_change.rb +33 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type.rb +1 -0
- data/lib/hrr_rb_ssh/connection/request_handler/reference_env_request_handler.rb +21 -0
- data/lib/hrr_rb_ssh/connection/request_handler/reference_exec_request_handler.rb +28 -0
- data/lib/hrr_rb_ssh/connection/request_handler/reference_pty_req_request_handler.rb +32 -0
- data/lib/hrr_rb_ssh/connection/request_handler/reference_shell_request_handler.rb +81 -0
- data/lib/hrr_rb_ssh/connection/request_handler/reference_window_change_request_handler.rb +21 -0
- data/lib/hrr_rb_ssh/connection/request_handler.rb +6 -0
- data/lib/hrr_rb_ssh/message/001_ssh_msg_disconnect.rb +1 -1
- data/lib/hrr_rb_ssh/message/002_ssh_msg_ignore.rb +1 -1
- data/lib/hrr_rb_ssh/message/003_ssh_msg_unimplemented.rb +1 -1
- data/lib/hrr_rb_ssh/message/004_ssh_msg_debug.rb +1 -1
- data/lib/hrr_rb_ssh/message/005_ssh_msg_service_request.rb +1 -1
- data/lib/hrr_rb_ssh/message/006_ssh_msg_service_accept.rb +1 -1
- data/lib/hrr_rb_ssh/message/020_ssh_msg_kexinit.rb +1 -1
- data/lib/hrr_rb_ssh/message/021_ssh_msg_newkeys.rb +1 -1
- data/lib/hrr_rb_ssh/message/030_ssh_msg_kex_dh_gex_request_old.rb +24 -0
- data/lib/hrr_rb_ssh/message/030_ssh_msg_kexdh_init.rb +1 -1
- data/lib/hrr_rb_ssh/message/031_ssh_msg_kex_dh_gex_group.rb +25 -0
- data/lib/hrr_rb_ssh/message/031_ssh_msg_kexdh_reply.rb +1 -1
- data/lib/hrr_rb_ssh/message/032_ssh_msg_kex_dh_gex_init.rb +24 -0
- data/lib/hrr_rb_ssh/message/033_ssh_msg_kex_dh_gex_reply.rb +26 -0
- data/lib/hrr_rb_ssh/message/034_ssh_msg_kex_dh_gex_request.rb +26 -0
- data/lib/hrr_rb_ssh/message/050_ssh_msg_userauth_request.rb +1 -1
- data/lib/hrr_rb_ssh/message/051_ssh_msg_userauth_failure.rb +1 -1
- data/lib/hrr_rb_ssh/message/052_ssh_msg_userauth_success.rb +1 -1
- data/lib/hrr_rb_ssh/message/060_ssh_msg_userauth_pk_ok.rb +1 -1
- data/lib/hrr_rb_ssh/message/080_ssh_msg_global_request.rb +1 -1
- data/lib/hrr_rb_ssh/message/081_ssh_msg_request_success.rb +1 -1
- data/lib/hrr_rb_ssh/message/082_ssh_msg_request_failure.rb +1 -1
- data/lib/hrr_rb_ssh/message/090_ssh_msg_channel_open.rb +1 -1
- data/lib/hrr_rb_ssh/message/091_ssh_msg_channel_open_confirmation.rb +1 -1
- data/lib/hrr_rb_ssh/message/092_ssh_msg_channel_open_failure.rb +1 -1
- data/lib/hrr_rb_ssh/message/093_ssh_msg_channel_window_adjust.rb +1 -1
- data/lib/hrr_rb_ssh/message/094_ssh_msg_channel_data.rb +1 -1
- data/lib/hrr_rb_ssh/message/095_ssh_msg_channel_extended_data.rb +1 -1
- data/lib/hrr_rb_ssh/message/096_ssh_msg_channel_eof.rb +1 -1
- data/lib/hrr_rb_ssh/message/097_ssh_msg_channel_close.rb +1 -1
- data/lib/hrr_rb_ssh/message/098_ssh_msg_channel_request.rb +1 -1
- data/lib/hrr_rb_ssh/message/099_ssh_msg_channel_success.rb +1 -1
- data/lib/hrr_rb_ssh/message/100_ssh_msg_channel_failure.rb +1 -1
- data/lib/hrr_rb_ssh/message.rb +5 -0
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman/h0.rb +29 -0
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman.rb +28 -18
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group14_sha256.rb +35 -0
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group15_sha512.rb +35 -0
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group16_sha512.rb +41 -0
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group17_sha512.rb +47 -0
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group18_sha512.rb +62 -0
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange/h0.rb +34 -0
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange.rb +170 -0
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange_sha1.rb +17 -0
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange_sha256.rb +17 -0
- data/lib/hrr_rb_ssh/transport/kex_algorithm.rb +7 -0
- data/lib/hrr_rb_ssh/transport/receiver.rb +16 -14
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss/public_key_blob.rb +26 -0
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss/signature.rb +23 -0
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss.rb +11 -39
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa/public_key_blob.rb +25 -0
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa/signature.rb +23 -0
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa.rb +11 -38
- data/lib/hrr_rb_ssh/transport.rb +9 -29
- data/lib/hrr_rb_ssh/version.rb +1 -1
- metadata +35 -4
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/codable.rb +0 -33
- data/lib/hrr_rb_ssh/message/codable.rb +0 -66
@@ -9,9 +9,8 @@ module HrrRbSsh
|
|
9
9
|
class ServerHostKeyAlgorithm
|
10
10
|
class SshDss < ServerHostKeyAlgorithm
|
11
11
|
NAME = 'ssh-dss'
|
12
|
-
|
13
12
|
PREFERENCE = 10
|
14
|
-
|
13
|
+
DIGEST = 'sha1'
|
15
14
|
SECRET_KEY = <<-EOB
|
16
15
|
-----BEGIN DSA PRIVATE KEY-----
|
17
16
|
MIIBuwIBAAKBgQD3fQ6cwTtOJpVI0iASOQZxkhwPRNy7UwovQkEK6bXW33HaCebO
|
@@ -27,41 +26,11 @@ MRl/p42OrQzL/chRPvRf
|
|
27
26
|
-----END DSA PRIVATE KEY-----
|
28
27
|
EOB
|
29
28
|
|
30
|
-
KEY_FORMAT_DEFINITION = [
|
31
|
-
[DataType::String, 'ssh-dss'],
|
32
|
-
[DataType::Mpint, 'p'],
|
33
|
-
[DataType::Mpint, 'q'],
|
34
|
-
[DataType::Mpint, 'g'],
|
35
|
-
[DataType::Mpint, 'y'],
|
36
|
-
]
|
37
|
-
|
38
|
-
SIGN_DEFINITION = [
|
39
|
-
[DataType::String, 'ssh-dss'],
|
40
|
-
[DataType::String, 'dss_signature_blob'],
|
41
|
-
]
|
42
|
-
|
43
29
|
def initialize
|
44
30
|
@logger = HrrRbSsh::Logger.new(self.class.name)
|
45
31
|
@dss = OpenSSL::PKey::DSA.new SECRET_KEY
|
46
32
|
end
|
47
33
|
|
48
|
-
def encode definition, payload
|
49
|
-
definition.map{ |data_type, field_name|
|
50
|
-
field_value = if payload[field_name].instance_of? ::Proc then payload[field_name].call else payload[field_name] end
|
51
|
-
data_type.encode( field_value )
|
52
|
-
}.join
|
53
|
-
end
|
54
|
-
|
55
|
-
def decode definition, payload
|
56
|
-
payload_io = StringIO.new payload, 'r'
|
57
|
-
definition.map{ |data_type, field_name|
|
58
|
-
[
|
59
|
-
field_name,
|
60
|
-
data_type.decode( payload_io )
|
61
|
-
]
|
62
|
-
}.to_h
|
63
|
-
end
|
64
|
-
|
65
34
|
def server_public_host_key
|
66
35
|
payload = {
|
67
36
|
'ssh-dss' => 'ssh-dss',
|
@@ -70,11 +39,11 @@ MRl/p42OrQzL/chRPvRf
|
|
70
39
|
'g' => @dss.g.to_i,
|
71
40
|
'y' => @dss.pub_key.to_i,
|
72
41
|
}
|
73
|
-
encode
|
42
|
+
PublicKeyBlob.encode payload
|
74
43
|
end
|
75
44
|
|
76
|
-
def sign
|
77
|
-
hash = OpenSSL::Digest.digest(
|
45
|
+
def sign data
|
46
|
+
hash = OpenSSL::Digest.digest(self.class::DIGEST, data)
|
78
47
|
sign_der = @dss.syssign(hash)
|
79
48
|
sign_asn1 = OpenSSL::ASN1.decode(sign_der)
|
80
49
|
sign_r = sign_asn1.value[0].value.to_s(2).rjust(20, ["00"].pack("H"))
|
@@ -83,11 +52,11 @@ MRl/p42OrQzL/chRPvRf
|
|
83
52
|
'ssh-dss' => 'ssh-dss',
|
84
53
|
'dss_signature_blob' => (sign_r + sign_s),
|
85
54
|
}
|
86
|
-
encode
|
55
|
+
Signature.encode payload
|
87
56
|
end
|
88
57
|
|
89
|
-
def verify
|
90
|
-
payload = decode
|
58
|
+
def verify sign, data
|
59
|
+
payload = Signature.decode sign
|
91
60
|
dss_signature_blob = payload['dss_signature_blob']
|
92
61
|
sign_r = dss_signature_blob[ 0, 20]
|
93
62
|
sign_s = dss_signature_blob[20, 20]
|
@@ -98,10 +67,13 @@ MRl/p42OrQzL/chRPvRf
|
|
98
67
|
]
|
99
68
|
)
|
100
69
|
sign_der = sign_asn1.to_der
|
101
|
-
hash = OpenSSL::Digest.digest(
|
70
|
+
hash = OpenSSL::Digest.digest(self.class::DIGEST, data)
|
102
71
|
payload['ssh-dss'] == 'ssh-dss' && @dss.sysverify(hash, sign_der)
|
103
72
|
end
|
104
73
|
end
|
105
74
|
end
|
106
75
|
end
|
107
76
|
end
|
77
|
+
|
78
|
+
require 'hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss/public_key_blob'
|
79
|
+
require 'hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss/signature'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: et ts=2 sw=2
|
3
|
+
|
4
|
+
require 'hrr_rb_ssh/data_type'
|
5
|
+
require 'hrr_rb_ssh/codable'
|
6
|
+
|
7
|
+
module HrrRbSsh
|
8
|
+
class Transport
|
9
|
+
class ServerHostKeyAlgorithm
|
10
|
+
class SshRsa
|
11
|
+
module PublicKeyBlob
|
12
|
+
class << self
|
13
|
+
include Codable
|
14
|
+
end
|
15
|
+
DEFINITION = [
|
16
|
+
[DataType::String, 'ssh-rsa'],
|
17
|
+
[DataType::Mpint, 'e'],
|
18
|
+
[DataType::Mpint, 'n'],
|
19
|
+
]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: et ts=2 sw=2
|
3
|
+
|
4
|
+
require 'hrr_rb_ssh/data_type'
|
5
|
+
require 'hrr_rb_ssh/codable'
|
6
|
+
|
7
|
+
module HrrRbSsh
|
8
|
+
class Transport
|
9
|
+
class ServerHostKeyAlgorithm
|
10
|
+
class SshRsa
|
11
|
+
module Signature
|
12
|
+
class << self
|
13
|
+
include Codable
|
14
|
+
end
|
15
|
+
DEFINITION = [
|
16
|
+
[DataType::String, 'ssh-rsa'],
|
17
|
+
[DataType::String, 'rsa_signature_blob'],
|
18
|
+
]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -2,16 +2,14 @@
|
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
4
|
require 'hrr_rb_ssh/logger'
|
5
|
-
require 'hrr_rb_ssh/data_type'
|
6
5
|
|
7
6
|
module HrrRbSsh
|
8
7
|
class Transport
|
9
8
|
class ServerHostKeyAlgorithm
|
10
9
|
class SshRsa < ServerHostKeyAlgorithm
|
11
10
|
NAME = 'ssh-rsa'
|
12
|
-
|
13
11
|
PREFERENCE = 20
|
14
|
-
|
12
|
+
DIGEST = 'sha1'
|
15
13
|
SECRET_KEY = <<-EOB
|
16
14
|
-----BEGIN RSA PRIVATE KEY-----
|
17
15
|
MIIEpAIBAAKCAQEA71zHt9RvbXmxuOCWPKR65iBHO+a8M7Mfo4vRCs/dorZN7XL1
|
@@ -42,61 +40,36 @@ vzTNM3SFzgt3bHkdEtDLc64aoBX+dHOot6u71XLZrshnHPtiZ0C/ZA==
|
|
42
40
|
-----END RSA PRIVATE KEY-----
|
43
41
|
EOB
|
44
42
|
|
45
|
-
KEY_FORMAT_DEFINITION = [
|
46
|
-
[DataType::String, 'ssh-rsa'],
|
47
|
-
[DataType::Mpint, 'e'],
|
48
|
-
[DataType::Mpint, 'n'],
|
49
|
-
]
|
50
|
-
|
51
|
-
SIGN_DEFINITION = [
|
52
|
-
[DataType::String, 'ssh-rsa'],
|
53
|
-
[DataType::String, 'rsa_signature_blob'],
|
54
|
-
]
|
55
|
-
|
56
43
|
def initialize
|
57
44
|
@logger = HrrRbSsh::Logger.new(self.class.name)
|
58
45
|
@rsa = OpenSSL::PKey::RSA.new SECRET_KEY
|
59
46
|
end
|
60
47
|
|
61
|
-
def encode definition, payload
|
62
|
-
definition.map{ |data_type, field_name|
|
63
|
-
field_value = if payload[field_name].instance_of? ::Proc then payload[field_name].call else payload[field_name] end
|
64
|
-
data_type.encode( field_value )
|
65
|
-
}.join
|
66
|
-
end
|
67
|
-
|
68
|
-
def decode definition, payload
|
69
|
-
payload_io = StringIO.new payload, 'r'
|
70
|
-
definition.map{ |data_type, field_name|
|
71
|
-
[
|
72
|
-
field_name,
|
73
|
-
data_type.decode( payload_io )
|
74
|
-
]
|
75
|
-
}.to_h
|
76
|
-
end
|
77
|
-
|
78
48
|
def server_public_host_key
|
79
49
|
payload = {
|
80
50
|
'ssh-rsa' => 'ssh-rsa',
|
81
51
|
'e' => @rsa.e.to_i,
|
82
52
|
'n' => @rsa.n.to_i,
|
83
53
|
}
|
84
|
-
encode
|
54
|
+
PublicKeyBlob.encode payload
|
85
55
|
end
|
86
56
|
|
87
|
-
def sign
|
57
|
+
def sign data
|
88
58
|
payload = {
|
89
59
|
'ssh-rsa' => 'ssh-rsa',
|
90
|
-
'rsa_signature_blob' => @rsa.sign(
|
60
|
+
'rsa_signature_blob' => @rsa.sign(self.class::DIGEST, data),
|
91
61
|
}
|
92
|
-
encode
|
62
|
+
Signature.encode payload
|
93
63
|
end
|
94
64
|
|
95
|
-
def verify
|
96
|
-
payload = decode
|
97
|
-
payload['ssh-rsa'] == 'ssh-rsa' && @rsa.verify(
|
65
|
+
def verify sign, data
|
66
|
+
payload = Signature.decode sign
|
67
|
+
payload['ssh-rsa'] == 'ssh-rsa' && @rsa.verify(self.class::DIGEST, payload['rsa_signature_blob'], data)
|
98
68
|
end
|
99
69
|
end
|
100
70
|
end
|
101
71
|
end
|
102
72
|
end
|
73
|
+
|
74
|
+
require 'hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa/public_key_blob'
|
75
|
+
require 'hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa/signature'
|
data/lib/hrr_rb_ssh/transport.rb
CHANGED
@@ -209,7 +209,6 @@ module HrrRbSsh
|
|
209
209
|
def exchange_version
|
210
210
|
send_version
|
211
211
|
receive_version
|
212
|
-
|
213
212
|
update_version_strings
|
214
213
|
end
|
215
214
|
|
@@ -224,20 +223,19 @@ module HrrRbSsh
|
|
224
223
|
receive_kexinit receive
|
225
224
|
end
|
226
225
|
update_kex_and_server_host_key_algorithms
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
send_kexdh_reply
|
232
|
-
|
233
|
-
send_newkeys
|
234
|
-
receive_newkeys receive
|
235
|
-
end
|
226
|
+
start_kex_algorithm
|
227
|
+
send_newkeys
|
228
|
+
receive_newkeys receive
|
229
|
+
update_encryption_mac_compression_algorithms
|
236
230
|
end
|
237
231
|
end
|
238
232
|
@in_kex = false
|
239
233
|
end
|
240
234
|
|
235
|
+
def start_kex_algorithm
|
236
|
+
@kex_algorithm.start self, @mode
|
237
|
+
end
|
238
|
+
|
241
239
|
def verify_service_request
|
242
240
|
service_request_message = receive_service_request
|
243
241
|
service_name = service_request_message['service name']
|
@@ -383,23 +381,6 @@ module HrrRbSsh
|
|
383
381
|
update_remote_algorithms message
|
384
382
|
end
|
385
383
|
|
386
|
-
def receive_kexdh_init payload
|
387
|
-
message = HrrRbSsh::Message::SSH_MSG_KEXDH_INIT.decode payload
|
388
|
-
@kex_algorithm.set_e message['e']
|
389
|
-
@session_id ||= @kex_algorithm.hash self
|
390
|
-
end
|
391
|
-
|
392
|
-
def send_kexdh_reply
|
393
|
-
message = {
|
394
|
-
'message number' => HrrRbSsh::Message::SSH_MSG_KEXDH_REPLY::VALUE,
|
395
|
-
'server public host key and certificates (K_S)' => @server_host_key_algorithm.server_public_host_key,
|
396
|
-
'f' => @kex_algorithm.pub_key,
|
397
|
-
'signature of H' => @kex_algorithm.sign(self),
|
398
|
-
}
|
399
|
-
payload = HrrRbSsh::Message::SSH_MSG_KEXDH_REPLY.encode message
|
400
|
-
send payload
|
401
|
-
end
|
402
|
-
|
403
384
|
def send_newkeys
|
404
385
|
message = {
|
405
386
|
'message number' => HrrRbSsh::Message::SSH_MSG_NEWKEYS::VALUE,
|
@@ -410,8 +391,6 @@ module HrrRbSsh
|
|
410
391
|
|
411
392
|
def receive_newkeys payload
|
412
393
|
message = HrrRbSsh::Message::SSH_MSG_NEWKEYS.decode payload
|
413
|
-
|
414
|
-
update_encryption_mac_compression_algorithms
|
415
394
|
end
|
416
395
|
|
417
396
|
def receive_service_request
|
@@ -456,6 +435,7 @@ module HrrRbSsh
|
|
456
435
|
end
|
457
436
|
|
458
437
|
def update_encryption_mac_compression_algorithms
|
438
|
+
@session_id ||= @kex_algorithm.hash(self)
|
459
439
|
update_encryption_algorithm
|
460
440
|
update_mac_algorithm
|
461
441
|
update_compression_algorithm
|
data/lib/hrr_rb_ssh/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hrr_rb_ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hirura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,13 +94,19 @@ files:
|
|
94
94
|
- lib/hrr_rb_ssh/authentication/method/password/context.rb
|
95
95
|
- lib/hrr_rb_ssh/authentication/method/publickey.rb
|
96
96
|
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm.rb
|
97
|
-
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/codable.rb
|
98
97
|
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss.rb
|
98
|
+
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss/public_key_blob.rb
|
99
|
+
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss/signature.rb
|
100
|
+
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss/signature_blob.rb
|
99
101
|
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa.rb
|
102
|
+
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa/public_key_blob.rb
|
103
|
+
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa/signature.rb
|
104
|
+
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa/signature_blob.rb
|
100
105
|
- lib/hrr_rb_ssh/authentication/method/publickey/context.rb
|
101
106
|
- lib/hrr_rb_ssh/closed_authentication_error.rb
|
102
107
|
- lib/hrr_rb_ssh/closed_connection_error.rb
|
103
108
|
- lib/hrr_rb_ssh/closed_transport_error.rb
|
109
|
+
- lib/hrr_rb_ssh/codable.rb
|
104
110
|
- lib/hrr_rb_ssh/compat.rb
|
105
111
|
- lib/hrr_rb_ssh/connection.rb
|
106
112
|
- lib/hrr_rb_ssh/connection/channel.rb
|
@@ -117,9 +123,16 @@ files:
|
|
117
123
|
- lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell/context.rb
|
118
124
|
- lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem.rb
|
119
125
|
- lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem/context.rb
|
126
|
+
- lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/window_change.rb
|
127
|
+
- lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/window_change/context.rb
|
120
128
|
- lib/hrr_rb_ssh/connection/channel/proc_chain.rb
|
121
129
|
- lib/hrr_rb_ssh/connection/channel/proc_chain/chain_context.rb
|
122
130
|
- lib/hrr_rb_ssh/connection/request_handler.rb
|
131
|
+
- lib/hrr_rb_ssh/connection/request_handler/reference_env_request_handler.rb
|
132
|
+
- lib/hrr_rb_ssh/connection/request_handler/reference_exec_request_handler.rb
|
133
|
+
- lib/hrr_rb_ssh/connection/request_handler/reference_pty_req_request_handler.rb
|
134
|
+
- lib/hrr_rb_ssh/connection/request_handler/reference_shell_request_handler.rb
|
135
|
+
- lib/hrr_rb_ssh/connection/request_handler/reference_window_change_request_handler.rb
|
123
136
|
- lib/hrr_rb_ssh/data_type.rb
|
124
137
|
- lib/hrr_rb_ssh/logger.rb
|
125
138
|
- lib/hrr_rb_ssh/message.rb
|
@@ -131,8 +144,13 @@ files:
|
|
131
144
|
- lib/hrr_rb_ssh/message/006_ssh_msg_service_accept.rb
|
132
145
|
- lib/hrr_rb_ssh/message/020_ssh_msg_kexinit.rb
|
133
146
|
- lib/hrr_rb_ssh/message/021_ssh_msg_newkeys.rb
|
147
|
+
- lib/hrr_rb_ssh/message/030_ssh_msg_kex_dh_gex_request_old.rb
|
134
148
|
- lib/hrr_rb_ssh/message/030_ssh_msg_kexdh_init.rb
|
149
|
+
- lib/hrr_rb_ssh/message/031_ssh_msg_kex_dh_gex_group.rb
|
135
150
|
- lib/hrr_rb_ssh/message/031_ssh_msg_kexdh_reply.rb
|
151
|
+
- lib/hrr_rb_ssh/message/032_ssh_msg_kex_dh_gex_init.rb
|
152
|
+
- lib/hrr_rb_ssh/message/033_ssh_msg_kex_dh_gex_reply.rb
|
153
|
+
- lib/hrr_rb_ssh/message/034_ssh_msg_kex_dh_gex_request.rb
|
136
154
|
- lib/hrr_rb_ssh/message/050_ssh_msg_userauth_request.rb
|
137
155
|
- lib/hrr_rb_ssh/message/051_ssh_msg_userauth_failure.rb
|
138
156
|
- lib/hrr_rb_ssh/message/052_ssh_msg_userauth_success.rb
|
@@ -151,7 +169,6 @@ files:
|
|
151
169
|
- lib/hrr_rb_ssh/message/098_ssh_msg_channel_request.rb
|
152
170
|
- lib/hrr_rb_ssh/message/099_ssh_msg_channel_success.rb
|
153
171
|
- lib/hrr_rb_ssh/message/100_ssh_msg_channel_failure.rb
|
154
|
-
- lib/hrr_rb_ssh/message/codable.rb
|
155
172
|
- lib/hrr_rb_ssh/subclass_with_preference_listable.rb
|
156
173
|
- lib/hrr_rb_ssh/transport.rb
|
157
174
|
- lib/hrr_rb_ssh/transport/compression_algorithm.rb
|
@@ -177,8 +194,18 @@ files:
|
|
177
194
|
- lib/hrr_rb_ssh/transport/encryption_algorithm/unfunctionable.rb
|
178
195
|
- lib/hrr_rb_ssh/transport/kex_algorithm.rb
|
179
196
|
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman.rb
|
197
|
+
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman/h0.rb
|
180
198
|
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group14_sha1.rb
|
199
|
+
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group14_sha256.rb
|
200
|
+
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group15_sha512.rb
|
201
|
+
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group16_sha512.rb
|
202
|
+
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group17_sha512.rb
|
203
|
+
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group18_sha512.rb
|
181
204
|
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group1_sha1.rb
|
205
|
+
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange.rb
|
206
|
+
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange/h0.rb
|
207
|
+
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange_sha1.rb
|
208
|
+
- lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange_sha256.rb
|
182
209
|
- lib/hrr_rb_ssh/transport/mac_algorithm.rb
|
183
210
|
- lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb
|
184
211
|
- lib/hrr_rb_ssh/transport/mac_algorithm/hmac_md5.rb
|
@@ -193,7 +220,11 @@ files:
|
|
193
220
|
- lib/hrr_rb_ssh/transport/sequence_number.rb
|
194
221
|
- lib/hrr_rb_ssh/transport/server_host_key_algorithm.rb
|
195
222
|
- lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss.rb
|
223
|
+
- lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss/public_key_blob.rb
|
224
|
+
- lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss/signature.rb
|
196
225
|
- lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa.rb
|
226
|
+
- lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa/public_key_blob.rb
|
227
|
+
- lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa/signature.rb
|
197
228
|
- lib/hrr_rb_ssh/version.rb
|
198
229
|
homepage: https://github.com/hirura/hrr_rb_ssh
|
199
230
|
licenses:
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
# vim: et ts=2 sw=2
|
3
|
-
|
4
|
-
require 'hrr_rb_ssh/data_type'
|
5
|
-
|
6
|
-
module HrrRbSsh
|
7
|
-
class Authentication
|
8
|
-
class Method
|
9
|
-
class Publickey
|
10
|
-
class Algorithm
|
11
|
-
module Codable
|
12
|
-
def encode definition, payload
|
13
|
-
definition.map{ |data_type, field_name|
|
14
|
-
field_value = if payload[field_name].instance_of? ::Proc then payload[field_name].call else payload[field_name] end
|
15
|
-
data_type.encode(field_value)
|
16
|
-
}.join
|
17
|
-
end
|
18
|
-
|
19
|
-
def decode definition, payload
|
20
|
-
payload_io = StringIO.new payload, 'r'
|
21
|
-
definition.map{ |data_type, field_name|
|
22
|
-
[
|
23
|
-
field_name,
|
24
|
-
data_type.decode(payload_io)
|
25
|
-
]
|
26
|
-
}.to_h
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
# vim: et ts=2 sw=2
|
3
|
-
|
4
|
-
require 'hrr_rb_ssh/logger'
|
5
|
-
|
6
|
-
module HrrRbSsh
|
7
|
-
module Message
|
8
|
-
module Codable
|
9
|
-
def logger
|
10
|
-
@logger ||= HrrRbSsh::Logger.new self.name
|
11
|
-
end
|
12
|
-
|
13
|
-
def common_definition
|
14
|
-
self::DEFINITION
|
15
|
-
end
|
16
|
-
|
17
|
-
def conditional_definition message
|
18
|
-
message.inject([]){ |a, (k,v)|
|
19
|
-
field_name = k
|
20
|
-
field_value = if v.instance_of? ::Proc then v.call else v end
|
21
|
-
a + ((self::CONDITIONAL_DEFINITION rescue {}).fetch(field_name, {})[field_value] || [])
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
def encode message, complementary_message={}
|
26
|
-
logger.debug('encoding message: ' + message.inspect)
|
27
|
-
definition = common_definition + conditional_definition(message.merge complementary_message)
|
28
|
-
definition.map{ |data_type, field_name|
|
29
|
-
field_value = if message[field_name].instance_of? ::Proc then message[field_name].call else message[field_name] end
|
30
|
-
data_type.encode( field_value )
|
31
|
-
}.join
|
32
|
-
end
|
33
|
-
|
34
|
-
def decode payload, complementary_message={}
|
35
|
-
def decode_recursively payload_io, message=nil
|
36
|
-
if message.class == Array and message.size == 0
|
37
|
-
[]
|
38
|
-
else
|
39
|
-
definition = case message
|
40
|
-
when nil
|
41
|
-
common_definition
|
42
|
-
when Array
|
43
|
-
conditional_definition(message)
|
44
|
-
end
|
45
|
-
decoded_message = definition.map{ |data_type, field_name|
|
46
|
-
[
|
47
|
-
field_name,
|
48
|
-
data_type.decode( payload_io )
|
49
|
-
]
|
50
|
-
}
|
51
|
-
|
52
|
-
decoded_message + decode_recursively(payload_io, decoded_message)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
payload_io = StringIO.new payload
|
57
|
-
decoded_message = decode_recursively(payload_io).to_h
|
58
|
-
if complementary_message.any?
|
59
|
-
decoded_message.merge! decode_recursively(payload_io, complementary_message.to_a).to_h
|
60
|
-
end
|
61
|
-
logger.debug('decoded message: ' + decoded_message.inspect)
|
62
|
-
decoded_message
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|