hrr_rb_ssh 0.4.0.pre2 → 0.4.0.pre3
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/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2/ecdsa_signature_blob.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2/public_key_blob.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2/signature.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2.rb +6 -6
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_dss/public_key_blob.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_dss/signature.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_dss.rb +4 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa/public_key_blob.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa/signature.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa.rb +4 -4
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_request.rb +1 -1
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_response.rb +1 -1
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb +3 -3
- data/lib/hrr_rb_ssh/authentication/method/none.rb +1 -1
- data/lib/hrr_rb_ssh/authentication/method/password.rb +1 -1
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb +2 -2
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/signature_blob.rb +2 -4
- data/lib/hrr_rb_ssh/authentication/method/publickey.rb +3 -3
- data/lib/hrr_rb_ssh/authentication.rb +4 -4
- data/lib/hrr_rb_ssh/codable.rb +11 -19
- data/lib/hrr_rb_ssh/connection/channel.rb +15 -15
- data/lib/hrr_rb_ssh/connection.rb +14 -14
- data/lib/hrr_rb_ssh/message/001_ssh_msg_disconnect.rb +2 -4
- data/lib/hrr_rb_ssh/message/002_ssh_msg_ignore.rb +2 -4
- data/lib/hrr_rb_ssh/message/003_ssh_msg_unimplemented.rb +2 -4
- data/lib/hrr_rb_ssh/message/004_ssh_msg_debug.rb +2 -4
- data/lib/hrr_rb_ssh/message/005_ssh_msg_service_request.rb +2 -4
- data/lib/hrr_rb_ssh/message/006_ssh_msg_service_accept.rb +2 -4
- data/lib/hrr_rb_ssh/message/020_ssh_msg_kexinit.rb +2 -4
- data/lib/hrr_rb_ssh/message/021_ssh_msg_newkeys.rb +2 -4
- data/lib/hrr_rb_ssh/message/030_ssh_msg_kex_dh_gex_request_old.rb +2 -4
- data/lib/hrr_rb_ssh/message/030_ssh_msg_kexdh_init.rb +2 -4
- data/lib/hrr_rb_ssh/message/030_ssh_msg_kexecdh_init.rb +2 -4
- data/lib/hrr_rb_ssh/message/031_ssh_msg_kex_dh_gex_group.rb +2 -4
- data/lib/hrr_rb_ssh/message/031_ssh_msg_kexdh_reply.rb +2 -4
- data/lib/hrr_rb_ssh/message/031_ssh_msg_kexecdh_reply.rb +2 -4
- data/lib/hrr_rb_ssh/message/032_ssh_msg_kex_dh_gex_init.rb +2 -4
- data/lib/hrr_rb_ssh/message/033_ssh_msg_kex_dh_gex_reply.rb +2 -4
- data/lib/hrr_rb_ssh/message/034_ssh_msg_kex_dh_gex_request.rb +2 -4
- data/lib/hrr_rb_ssh/message/050_ssh_msg_userauth_request.rb +2 -4
- data/lib/hrr_rb_ssh/message/051_ssh_msg_userauth_failure.rb +2 -4
- data/lib/hrr_rb_ssh/message/052_ssh_msg_userauth_success.rb +2 -4
- data/lib/hrr_rb_ssh/message/060_ssh_msg_userauth_info_request.rb +2 -4
- data/lib/hrr_rb_ssh/message/060_ssh_msg_userauth_pk_ok.rb +2 -4
- data/lib/hrr_rb_ssh/message/061_ssh_msg_userauth_info_response.rb +2 -4
- data/lib/hrr_rb_ssh/message/080_ssh_msg_global_request.rb +2 -4
- data/lib/hrr_rb_ssh/message/081_ssh_msg_request_success.rb +2 -4
- data/lib/hrr_rb_ssh/message/082_ssh_msg_request_failure.rb +2 -4
- data/lib/hrr_rb_ssh/message/090_ssh_msg_channel_open.rb +2 -4
- data/lib/hrr_rb_ssh/message/091_ssh_msg_channel_open_confirmation.rb +2 -4
- data/lib/hrr_rb_ssh/message/092_ssh_msg_channel_open_failure.rb +2 -4
- data/lib/hrr_rb_ssh/message/093_ssh_msg_channel_window_adjust.rb +2 -4
- data/lib/hrr_rb_ssh/message/094_ssh_msg_channel_data.rb +2 -4
- data/lib/hrr_rb_ssh/message/095_ssh_msg_channel_extended_data.rb +2 -4
- data/lib/hrr_rb_ssh/message/096_ssh_msg_channel_eof.rb +2 -4
- data/lib/hrr_rb_ssh/message/097_ssh_msg_channel_close.rb +2 -4
- data/lib/hrr_rb_ssh/message/098_ssh_msg_channel_request.rb +2 -4
- data/lib/hrr_rb_ssh/message/099_ssh_msg_channel_success.rb +2 -4
- data/lib/hrr_rb_ssh/message/100_ssh_msg_channel_failure.rb +2 -4
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman/h0.rb +2 -4
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman.rb +5 -5
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange/h0.rb +2 -4
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange.rb +9 -9
- data/lib/hrr_rb_ssh/transport/kex_algorithm/elliptic_curve_diffie_hellman/h0.rb +2 -4
- data/lib/hrr_rb_ssh/transport/kex_algorithm/elliptic_curve_diffie_hellman.rb +5 -5
- data/lib/hrr_rb_ssh/transport.rb +13 -13
- data/lib/hrr_rb_ssh/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fff6a446ca6bc1035e2118c0e7a569aa74ae870feecc74ae08a544da2a7aa7b7
|
4
|
+
data.tar.gz: daafac5b3866a8d0139f170130867f420593e7ce0a1f72cb7a9734f5467bbc51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6702107a31da914abcacc80f8cc8a918adc47f23521bc716a4b4aed3b9ca5a7a0330cdeba6119891c9dbe02457bdf139d93688cc67c8b307a0e8207c097b57ac
|
7
|
+
data.tar.gz: c9ce61c6880b7b4f14e7f0006afe66bf2e9cf4bd589a83769e3392227632ed3ba123fdadc18e40f774cdd32c043f3f4dffc6c4d84f5ecd69c8578ca31090831a
|
@@ -8,10 +8,8 @@ module HrrRbSsh
|
|
8
8
|
module Algorithm
|
9
9
|
class Publickey
|
10
10
|
module EcdsaSha2
|
11
|
-
|
12
|
-
|
13
|
-
include Codable
|
14
|
-
end
|
11
|
+
class EcdsaSignatureBlob
|
12
|
+
include Codable
|
15
13
|
DEFINITION = [
|
16
14
|
[DataType::Mpint, :'r'],
|
17
15
|
[DataType::Mpint, :'s'],
|
@@ -8,10 +8,8 @@ module HrrRbSsh
|
|
8
8
|
module Algorithm
|
9
9
|
class Publickey
|
10
10
|
module EcdsaSha2
|
11
|
-
|
12
|
-
|
13
|
-
include Codable
|
14
|
-
end
|
11
|
+
class PublicKeyBlob
|
12
|
+
include Codable
|
15
13
|
DEFINITION = [
|
16
14
|
[DataType::String, :'public key algorithm name'],
|
17
15
|
[DataType::String, :'identifier'],
|
@@ -8,10 +8,8 @@ module HrrRbSsh
|
|
8
8
|
module Algorithm
|
9
9
|
class Publickey
|
10
10
|
module EcdsaSha2
|
11
|
-
|
12
|
-
|
13
|
-
include Codable
|
14
|
-
end
|
11
|
+
class Signature
|
12
|
+
include Codable
|
15
13
|
DEFINITION = [
|
16
14
|
[DataType::String, :'public key algorithm name'],
|
17
15
|
[DataType::String, :'ecdsa signature blob'],
|
@@ -24,7 +24,7 @@ module HrrRbSsh
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def new_by_public_key_blob public_key_blob
|
27
|
-
public_key_blob_h = PublicKeyBlob.
|
27
|
+
public_key_blob_h = PublicKeyBlob.new(logger: logger).decode public_key_blob
|
28
28
|
@publickey = OpenSSL::PKey::EC.new(self.class::CURVE_NAME)
|
29
29
|
@publickey.public_key = OpenSSL::PKey::EC::Point.new(@publickey.group, OpenSSL::BN.new(public_key_blob_h[:'Q'], 2))
|
30
30
|
end
|
@@ -39,7 +39,7 @@ module HrrRbSsh
|
|
39
39
|
:'identifier' => self.class::IDENTIFIER,
|
40
40
|
:'Q' => @publickey.public_key.to_bn.to_s(2)
|
41
41
|
}
|
42
|
-
PublicKeyBlob.
|
42
|
+
PublicKeyBlob.new(logger: logger).encode public_key_blob_h
|
43
43
|
end
|
44
44
|
|
45
45
|
def ecdsa_signature_blob signature_blob
|
@@ -52,7 +52,7 @@ module HrrRbSsh
|
|
52
52
|
:'r' => r,
|
53
53
|
:'s' => s,
|
54
54
|
}
|
55
|
-
EcdsaSignatureBlob.
|
55
|
+
EcdsaSignatureBlob.new(logger: logger).encode ecdsa_signature_blob_h
|
56
56
|
end
|
57
57
|
|
58
58
|
def sign signature_blob
|
@@ -60,12 +60,12 @@ module HrrRbSsh
|
|
60
60
|
:'public key algorithm name' => self.class::NAME,
|
61
61
|
:'ecdsa signature blob' => ecdsa_signature_blob(signature_blob),
|
62
62
|
}
|
63
|
-
Signature.
|
63
|
+
Signature.new(logger: logger).encode signature_h
|
64
64
|
end
|
65
65
|
|
66
66
|
def verify signature, signature_blob
|
67
|
-
signature_h = Signature.
|
68
|
-
ecdsa_signature_blob_h = EcdsaSignatureBlob.decode signature_h[:'ecdsa signature blob']
|
67
|
+
signature_h = Signature.new(logger: logger).decode signature
|
68
|
+
ecdsa_signature_blob_h = EcdsaSignatureBlob.new(logger: logger).decode signature_h[:'ecdsa signature blob']
|
69
69
|
r = ecdsa_signature_blob_h[:'r']
|
70
70
|
s = ecdsa_signature_blob_h[:'s']
|
71
71
|
sign_asn1 = OpenSSL::ASN1::Sequence.new(
|
@@ -8,10 +8,8 @@ module HrrRbSsh
|
|
8
8
|
module Algorithm
|
9
9
|
class Publickey
|
10
10
|
class SshDss
|
11
|
-
|
12
|
-
|
13
|
-
include Codable
|
14
|
-
end
|
11
|
+
class PublicKeyBlob
|
12
|
+
include Codable
|
15
13
|
DEFINITION = [
|
16
14
|
[DataType::String, :'public key algorithm name'],
|
17
15
|
[DataType::Mpint, :'p'],
|
@@ -8,10 +8,8 @@ module HrrRbSsh
|
|
8
8
|
module Algorithm
|
9
9
|
class Publickey
|
10
10
|
class SshDss
|
11
|
-
|
12
|
-
|
13
|
-
include Codable
|
14
|
-
end
|
11
|
+
class Signature
|
12
|
+
include Codable
|
15
13
|
DEFINITION = [
|
16
14
|
[DataType::String, :'public key algorithm name'],
|
17
15
|
[DataType::String, :'signature blob'],
|
@@ -26,7 +26,7 @@ module HrrRbSsh
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def new_by_public_key_blob public_key_blob
|
29
|
-
public_key_blob_h = PublicKeyBlob.
|
29
|
+
public_key_blob_h = PublicKeyBlob.new(logger: logger).decode public_key_blob
|
30
30
|
@publickey = OpenSSL::PKey::DSA.new
|
31
31
|
if @publickey.respond_to?(:set_pqg)
|
32
32
|
@publickey.set_pqg public_key_blob_h[:'p'], public_key_blob_h[:'q'], public_key_blob_h[:'g']
|
@@ -54,7 +54,7 @@ module HrrRbSsh
|
|
54
54
|
:'g' => @publickey.g.to_i,
|
55
55
|
:'y' => @publickey.pub_key.to_i,
|
56
56
|
}
|
57
|
-
PublicKeyBlob.
|
57
|
+
PublicKeyBlob.new(logger: logger).encode public_key_blob_h
|
58
58
|
end
|
59
59
|
|
60
60
|
def sign signature_blob
|
@@ -67,11 +67,11 @@ module HrrRbSsh
|
|
67
67
|
:'public key algorithm name' => self.class::NAME,
|
68
68
|
:'signature blob' => (sign_r + sign_s),
|
69
69
|
}
|
70
|
-
Signature.
|
70
|
+
Signature.new(logger: logger).encode signature_h
|
71
71
|
end
|
72
72
|
|
73
73
|
def verify signature, signature_blob
|
74
|
-
signature_h = Signature.
|
74
|
+
signature_h = Signature.new(logger: logger).decode signature
|
75
75
|
sign_r = signature_h[:'signature blob'][ 0, 20]
|
76
76
|
sign_s = signature_h[:'signature blob'][20, 20]
|
77
77
|
sign_asn1 = OpenSSL::ASN1::Sequence.new(
|
@@ -8,10 +8,8 @@ module HrrRbSsh
|
|
8
8
|
module Algorithm
|
9
9
|
class Publickey
|
10
10
|
class SshRsa
|
11
|
-
|
12
|
-
|
13
|
-
include Codable
|
14
|
-
end
|
11
|
+
class PublicKeyBlob
|
12
|
+
include Codable
|
15
13
|
DEFINITION = [
|
16
14
|
[DataType::String, :'public key algorithm name'],
|
17
15
|
[DataType::Mpint, :'e'],
|
@@ -8,10 +8,8 @@ module HrrRbSsh
|
|
8
8
|
module Algorithm
|
9
9
|
class Publickey
|
10
10
|
class SshRsa
|
11
|
-
|
12
|
-
|
13
|
-
include Codable
|
14
|
-
end
|
11
|
+
class Signature
|
12
|
+
include Codable
|
15
13
|
DEFINITION = [
|
16
14
|
[DataType::String, :'public key algorithm name'],
|
17
15
|
[DataType::String, :'signature blob'],
|
@@ -26,7 +26,7 @@ module HrrRbSsh
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def new_by_public_key_blob public_key_blob
|
29
|
-
public_key_blob_h = PublicKeyBlob.
|
29
|
+
public_key_blob_h = PublicKeyBlob.new(logger: logger).decode public_key_blob
|
30
30
|
@publickey = OpenSSL::PKey::RSA.new
|
31
31
|
if @publickey.respond_to?(:set_key)
|
32
32
|
@publickey.set_key public_key_blob_h[:'n'], public_key_blob_h[:'e'], nil
|
@@ -46,7 +46,7 @@ module HrrRbSsh
|
|
46
46
|
:'e' => @publickey.e.to_i,
|
47
47
|
:'n' => @publickey.n.to_i,
|
48
48
|
}
|
49
|
-
PublicKeyBlob.
|
49
|
+
PublicKeyBlob.new(logger: logger).encode public_key_blob_h
|
50
50
|
end
|
51
51
|
|
52
52
|
def sign signature_blob
|
@@ -54,11 +54,11 @@ module HrrRbSsh
|
|
54
54
|
:'public key algorithm name' => self.class::NAME,
|
55
55
|
:'signature blob' => @publickey.sign(self.class::DIGEST, signature_blob),
|
56
56
|
}
|
57
|
-
Signature.
|
57
|
+
Signature.new(logger: logger).encode signature_h
|
58
58
|
end
|
59
59
|
|
60
60
|
def verify signature, signature_blob
|
61
|
-
signature_h = Signature.
|
61
|
+
signature_h = Signature.new(logger: logger).decode signature
|
62
62
|
signature_h[:'public key algorithm name'] == self.class::NAME && @publickey.verify(self.class::DIGEST, signature_h[:'signature blob'], signature_blob)
|
63
63
|
end
|
64
64
|
end
|
@@ -18,7 +18,7 @@ module HrrRbSsh
|
|
18
18
|
self.logger = logger
|
19
19
|
case payload[0,1].unpack("C")[0]
|
20
20
|
when Message::SSH_MSG_USERAUTH_INFO_RESPONSE::VALUE
|
21
|
-
message = Message::SSH_MSG_USERAUTH_INFO_RESPONSE.
|
21
|
+
message = Message::SSH_MSG_USERAUTH_INFO_RESPONSE.new(logger: logger).decode payload
|
22
22
|
@num_responses = message[:'num-responses']
|
23
23
|
@responses = Array.new(message[:'num-responses']){ |i| message[:"response[#{i+1}]"] }
|
24
24
|
else
|
@@ -39,13 +39,13 @@ module HrrRbSsh
|
|
39
39
|
:"language tag" => "",
|
40
40
|
:'submethods' => "",
|
41
41
|
}
|
42
|
-
payload = Message::SSH_MSG_USERAUTH_REQUEST.
|
42
|
+
payload = Message::SSH_MSG_USERAUTH_REQUEST.new(logger: logger).encode message
|
43
43
|
@transport.send payload
|
44
44
|
|
45
45
|
payload = @transport.receive
|
46
46
|
case payload[0,1].unpack("C")[0]
|
47
47
|
when Message::SSH_MSG_USERAUTH_INFO_REQUEST::VALUE
|
48
|
-
message = Message::SSH_MSG_USERAUTH_INFO_REQUEST.
|
48
|
+
message = Message::SSH_MSG_USERAUTH_INFO_REQUEST.new(logger: logger).decode payload
|
49
49
|
num_responses = @options['client_authentication_keyboard_interactive'].size
|
50
50
|
message = {
|
51
51
|
:'message number' => Message::SSH_MSG_USERAUTH_INFO_RESPONSE::VALUE,
|
@@ -55,7 +55,7 @@ module HrrRbSsh
|
|
55
55
|
{:"response[#{i+1}]" => response}
|
56
56
|
}.inject(Hash.new){ |a, b| a.merge(b) }
|
57
57
|
message.update(message_responses)
|
58
|
-
payload = Message::SSH_MSG_USERAUTH_INFO_RESPONSE.
|
58
|
+
payload = Message::SSH_MSG_USERAUTH_INFO_RESPONSE.new(logger: logger).encode message
|
59
59
|
@transport.send payload
|
60
60
|
@transport.receive
|
61
61
|
else
|
@@ -34,7 +34,7 @@ module HrrRbSsh
|
|
34
34
|
:"service name" => service_name,
|
35
35
|
:"method name" => NAME,
|
36
36
|
}
|
37
|
-
payload = Message::SSH_MSG_USERAUTH_REQUEST.
|
37
|
+
payload = Message::SSH_MSG_USERAUTH_REQUEST.new(logger: logger).encode message
|
38
38
|
@transport.send payload
|
39
39
|
payload = @transport.receive
|
40
40
|
end
|
@@ -40,7 +40,7 @@ module HrrRbSsh
|
|
40
40
|
:"FALSE" => false,
|
41
41
|
:"plaintext password" => password,
|
42
42
|
}
|
43
|
-
payload = Message::SSH_MSG_USERAUTH_REQUEST.
|
43
|
+
payload = Message::SSH_MSG_USERAUTH_REQUEST.new(logger: logger).encode message
|
44
44
|
@transport.send payload
|
45
45
|
|
46
46
|
payload = @transport.receive
|
@@ -38,7 +38,7 @@ module HrrRbSsh
|
|
38
38
|
:'public key algorithm name' => message[:'public key algorithm name'],
|
39
39
|
:'public key blob' => message[:'public key blob'],
|
40
40
|
}
|
41
|
-
signature_blob = SignatureBlob.
|
41
|
+
signature_blob = SignatureBlob.new(logger: logger).encode signature_blob_h
|
42
42
|
publickey = HrrRbSsh::Algorithm::Publickey[self.class::NAME].new message[:'public key blob'], logger: logger
|
43
43
|
publickey.verify message[:'signature'], signature_blob
|
44
44
|
rescue => e
|
@@ -65,7 +65,7 @@ module HrrRbSsh
|
|
65
65
|
:'public key algorithm name' => self.class::NAME,
|
66
66
|
:'public key blob' => publickey_blob
|
67
67
|
}
|
68
|
-
signature_blob = SignatureBlob.
|
68
|
+
signature_blob = SignatureBlob.new(logger: logger).encode signature_blob_h
|
69
69
|
publickey.sign signature_blob
|
70
70
|
end
|
71
71
|
end
|
@@ -9,10 +9,8 @@ module HrrRbSsh
|
|
9
9
|
class Method
|
10
10
|
class Publickey
|
11
11
|
class Algorithm
|
12
|
-
|
13
|
-
|
14
|
-
include Codable
|
15
|
-
end
|
12
|
+
class SignatureBlob
|
13
|
+
include Codable
|
16
14
|
DEFINITION = [
|
17
15
|
[DataType::String, :'session identifier'],
|
18
16
|
[DataType::Byte, :'message number'],
|
@@ -47,7 +47,7 @@ module HrrRbSsh
|
|
47
47
|
:'public key algorithm name from the request' => public_key_algorithm_name,
|
48
48
|
:'public key blob from the request' => public_key_blob,
|
49
49
|
}
|
50
|
-
payload = Message::SSH_MSG_USERAUTH_PK_OK.
|
50
|
+
payload = Message::SSH_MSG_USERAUTH_PK_OK.new(logger: logger).encode message
|
51
51
|
end
|
52
52
|
|
53
53
|
def request_authentication username, service_name
|
@@ -75,7 +75,7 @@ module HrrRbSsh
|
|
75
75
|
:'public key algorithm name' => public_key_algorithm_name,
|
76
76
|
:'public key blob' => public_key_blob,
|
77
77
|
}
|
78
|
-
payload = Message::SSH_MSG_USERAUTH_REQUEST.
|
78
|
+
payload = Message::SSH_MSG_USERAUTH_REQUEST.new(logger: logger).encode message
|
79
79
|
@transport.send payload
|
80
80
|
end
|
81
81
|
|
@@ -93,7 +93,7 @@ module HrrRbSsh
|
|
93
93
|
:'public key blob' => public_key_blob,
|
94
94
|
:'signature' => signature,
|
95
95
|
}
|
96
|
-
payload = Message::SSH_MSG_USERAUTH_REQUEST.
|
96
|
+
payload = Message::SSH_MSG_USERAUTH_REQUEST.new(logger: logger).encode message
|
97
97
|
@transport.send payload
|
98
98
|
end
|
99
99
|
end
|
@@ -87,7 +87,7 @@ module HrrRbSsh
|
|
87
87
|
payload = @transport.receive
|
88
88
|
case payload[0,1].unpack("C")[0]
|
89
89
|
when Message::SSH_MSG_USERAUTH_REQUEST::VALUE
|
90
|
-
userauth_request_message = Message::SSH_MSG_USERAUTH_REQUEST.
|
90
|
+
userauth_request_message = Message::SSH_MSG_USERAUTH_REQUEST.new(logger: logger).decode payload
|
91
91
|
method_name = userauth_request_message[:'method name']
|
92
92
|
log_info { "authentication method: #{method_name}" }
|
93
93
|
method = Method[method_name].new(@transport, {'session id' => @transport.session_id}.merge(@options), @variables, authentication_methods, logger: logger)
|
@@ -143,7 +143,7 @@ module HrrRbSsh
|
|
143
143
|
@closed = false
|
144
144
|
break
|
145
145
|
when Message::SSH_MSG_USERAUTH_FAILURE::VALUE
|
146
|
-
message = Message::SSH_MSG_USERAUTH_FAILURE.
|
146
|
+
message = Message::SSH_MSG_USERAUTH_FAILURE.new(logger: logger).decode payload
|
147
147
|
partial_success = message[:'partial success']
|
148
148
|
if partial_success
|
149
149
|
log_info { "partially verified" }
|
@@ -169,7 +169,7 @@ module HrrRbSsh
|
|
169
169
|
:'authentications that can continue' => authentication_methods,
|
170
170
|
:'partial success' => partial_success,
|
171
171
|
}
|
172
|
-
payload = Message::SSH_MSG_USERAUTH_FAILURE.
|
172
|
+
payload = Message::SSH_MSG_USERAUTH_FAILURE.new(logger: logger).encode message
|
173
173
|
@transport.send payload
|
174
174
|
end
|
175
175
|
|
@@ -177,7 +177,7 @@ module HrrRbSsh
|
|
177
177
|
message = {
|
178
178
|
:'message number' => Message::SSH_MSG_USERAUTH_SUCCESS::VALUE,
|
179
179
|
}
|
180
|
-
payload = Message::SSH_MSG_USERAUTH_SUCCESS.
|
180
|
+
payload = Message::SSH_MSG_USERAUTH_SUCCESS.new(logger: logger).encode message
|
181
181
|
@transport.send payload
|
182
182
|
end
|
183
183
|
|
data/lib/hrr_rb_ssh/codable.rb
CHANGED
@@ -5,39 +5,34 @@ require 'hrr_rb_ssh/loggable'
|
|
5
5
|
|
6
6
|
module HrrRbSsh
|
7
7
|
module Codable
|
8
|
-
|
9
|
-
include Loggable
|
8
|
+
include Loggable
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
10
|
+
def initialize logger: nil
|
11
|
+
self.logger = logger
|
14
12
|
end
|
15
13
|
|
16
14
|
def common_definition
|
17
|
-
self::DEFINITION
|
15
|
+
self.class::DEFINITION
|
18
16
|
end
|
19
17
|
|
20
18
|
def conditional_definition message
|
21
|
-
return [] unless self.const_defined? :CONDITIONAL_DEFINITION
|
19
|
+
return [] unless self.class.const_defined? :CONDITIONAL_DEFINITION
|
22
20
|
message.inject([]){ |a, (k,v)|
|
23
21
|
field_name = k
|
24
22
|
field_value = if v.instance_of? ::Proc then v.call else v end
|
25
|
-
a + (self::CONDITIONAL_DEFINITION.fetch(field_name, {})[field_value] || [])
|
23
|
+
a + (self.class::CONDITIONAL_DEFINITION.fetch(field_name, {})[field_value] || [])
|
26
24
|
}
|
27
25
|
end
|
28
26
|
|
29
|
-
def encode message, complementary_message={}
|
30
|
-
|
31
|
-
loggable_instalce.log_key = self.to_s
|
32
|
-
|
33
|
-
loggable_instalce.log_debug { 'encoding message: ' + message.inspect }
|
27
|
+
def encode message, complementary_message={}
|
28
|
+
log_debug { 'encoding message: ' + message.inspect }
|
34
29
|
definition = common_definition + conditional_definition(message.merge complementary_message)
|
35
30
|
definition.map{ |data_type, field_name|
|
36
31
|
begin
|
37
32
|
field_value = if message[field_name].instance_of? ::Proc then message[field_name].call else message[field_name] end
|
38
33
|
data_type.encode field_value
|
39
34
|
rescue => e
|
40
|
-
|
35
|
+
log_debug { "'field_name', 'field_value': #{field_name.inspect}, #{field_value.inspect}" }
|
41
36
|
raise e
|
42
37
|
end
|
43
38
|
}.join
|
@@ -63,16 +58,13 @@ module HrrRbSsh
|
|
63
58
|
end
|
64
59
|
end
|
65
60
|
|
66
|
-
def decode payload, complementary_message={}
|
67
|
-
loggable_instalce = LoggableClass.new(logger)
|
68
|
-
loggable_instalce.log_key = self.to_s
|
69
|
-
|
61
|
+
def decode payload, complementary_message={}
|
70
62
|
payload_io = StringIO.new payload
|
71
63
|
decoded_message = decode_recursively(payload_io).inject(Hash.new){ |h, (k, v)| h.update({k => v}) }
|
72
64
|
if complementary_message.any?
|
73
65
|
decoded_message.merge! decode_recursively(payload_io, complementary_message.to_a).inject(Hash.new){ |h, (k, v)| h.update({k => v}) }
|
74
66
|
end
|
75
|
-
|
67
|
+
log_debug { 'decoded message: ' + decoded_message.inspect }
|
76
68
|
decoded_message
|
77
69
|
end
|
78
70
|
end
|
@@ -405,7 +405,7 @@ module HrrRbSsh
|
|
405
405
|
:'message number' => Message::SSH_MSG_CHANNEL_SUCCESS::VALUE,
|
406
406
|
:'recipient channel' => @remote_channel,
|
407
407
|
}
|
408
|
-
payload = Message::SSH_MSG_CHANNEL_SUCCESS.
|
408
|
+
payload = Message::SSH_MSG_CHANNEL_SUCCESS.new(logger: logger).encode message
|
409
409
|
@connection.send payload
|
410
410
|
end
|
411
411
|
|
@@ -414,7 +414,7 @@ module HrrRbSsh
|
|
414
414
|
:'message number' => Message::SSH_MSG_CHANNEL_FAILURE::VALUE,
|
415
415
|
:'recipient channel' => @remote_channel,
|
416
416
|
}
|
417
|
-
payload = Message::SSH_MSG_CHANNEL_FAILURE.
|
417
|
+
payload = Message::SSH_MSG_CHANNEL_FAILURE.new(logger: logger).encode message
|
418
418
|
@connection.send payload
|
419
419
|
end
|
420
420
|
|
@@ -424,7 +424,7 @@ module HrrRbSsh
|
|
424
424
|
:'recipient channel' => @remote_channel,
|
425
425
|
:'bytes to add' => INITIAL_WINDOW_SIZE,
|
426
426
|
}
|
427
|
-
payload = Message::SSH_MSG_CHANNEL_WINDOW_ADJUST.
|
427
|
+
payload = Message::SSH_MSG_CHANNEL_WINDOW_ADJUST.new(logger: logger).encode message
|
428
428
|
@connection.send payload
|
429
429
|
end
|
430
430
|
|
@@ -434,7 +434,7 @@ module HrrRbSsh
|
|
434
434
|
:'recipient channel' => @remote_channel,
|
435
435
|
:'data' => data,
|
436
436
|
}
|
437
|
-
payload = Message::SSH_MSG_CHANNEL_DATA.
|
437
|
+
payload = Message::SSH_MSG_CHANNEL_DATA.new(logger: logger).encode message
|
438
438
|
@connection.send payload
|
439
439
|
end
|
440
440
|
|
@@ -445,7 +445,7 @@ module HrrRbSsh
|
|
445
445
|
:'data type code' => code,
|
446
446
|
:'data' => data,
|
447
447
|
}
|
448
|
-
payload = Message::SSH_MSG_CHANNEL_EXTENDED_DATA.
|
448
|
+
payload = Message::SSH_MSG_CHANNEL_EXTENDED_DATA.new(logger: logger).encode message
|
449
449
|
@connection.send payload
|
450
450
|
end
|
451
451
|
|
@@ -462,7 +462,7 @@ module HrrRbSsh
|
|
462
462
|
:'terminal height, pixels' => term_height_pixel,
|
463
463
|
:'encoded terminal modes' => encoded_term_modes,
|
464
464
|
}
|
465
|
-
payload = Message::SSH_MSG_CHANNEL_REQUEST.
|
465
|
+
payload = Message::SSH_MSG_CHANNEL_REQUEST.new(logger: logger).encode message
|
466
466
|
@connection.send payload
|
467
467
|
end
|
468
468
|
|
@@ -475,7 +475,7 @@ module HrrRbSsh
|
|
475
475
|
:'variable name' => variable_name,
|
476
476
|
:'variable value' => variable_value,
|
477
477
|
}
|
478
|
-
payload = Message::SSH_MSG_CHANNEL_REQUEST.
|
478
|
+
payload = Message::SSH_MSG_CHANNEL_REQUEST.new(logger: logger).encode message
|
479
479
|
@connection.send payload
|
480
480
|
end
|
481
481
|
|
@@ -486,7 +486,7 @@ module HrrRbSsh
|
|
486
486
|
:'request type' => "shell",
|
487
487
|
:'want reply' => false,
|
488
488
|
}
|
489
|
-
payload = Message::SSH_MSG_CHANNEL_REQUEST.
|
489
|
+
payload = Message::SSH_MSG_CHANNEL_REQUEST.new(logger: logger).encode message
|
490
490
|
@connection.send payload
|
491
491
|
end
|
492
492
|
|
@@ -498,7 +498,7 @@ module HrrRbSsh
|
|
498
498
|
:'want reply' => false,
|
499
499
|
:'command' => command,
|
500
500
|
}
|
501
|
-
payload = Message::SSH_MSG_CHANNEL_REQUEST.
|
501
|
+
payload = Message::SSH_MSG_CHANNEL_REQUEST.new(logger: logger).encode message
|
502
502
|
@connection.send payload
|
503
503
|
end
|
504
504
|
|
@@ -510,7 +510,7 @@ module HrrRbSsh
|
|
510
510
|
:'want reply' => false,
|
511
511
|
:'subsystem name' => subsystem_name,
|
512
512
|
}
|
513
|
-
payload = Message::SSH_MSG_CHANNEL_REQUEST.
|
513
|
+
payload = Message::SSH_MSG_CHANNEL_REQUEST.new(logger: logger).encode message
|
514
514
|
@connection.send payload
|
515
515
|
end
|
516
516
|
|
@@ -525,7 +525,7 @@ module HrrRbSsh
|
|
525
525
|
:'terminal width, pixels' => term_width_pixel,
|
526
526
|
:'terminal height, pixels' => term_height_pixel,
|
527
527
|
}
|
528
|
-
payload = Message::SSH_MSG_CHANNEL_REQUEST.
|
528
|
+
payload = Message::SSH_MSG_CHANNEL_REQUEST.new(logger: logger).encode message
|
529
529
|
@connection.send payload
|
530
530
|
end
|
531
531
|
|
@@ -537,7 +537,7 @@ module HrrRbSsh
|
|
537
537
|
:'want reply' => false,
|
538
538
|
:'signal name' => signal_name,
|
539
539
|
}
|
540
|
-
payload = Message::SSH_MSG_CHANNEL_REQUEST.
|
540
|
+
payload = Message::SSH_MSG_CHANNEL_REQUEST.new(logger: logger).encode message
|
541
541
|
@connection.send payload
|
542
542
|
end
|
543
543
|
|
@@ -549,7 +549,7 @@ module HrrRbSsh
|
|
549
549
|
:'want reply' => false,
|
550
550
|
:'exit status' => exitstatus,
|
551
551
|
}
|
552
|
-
payload = Message::SSH_MSG_CHANNEL_REQUEST.
|
552
|
+
payload = Message::SSH_MSG_CHANNEL_REQUEST.new(logger: logger).encode message
|
553
553
|
@connection.send payload
|
554
554
|
end
|
555
555
|
|
@@ -558,7 +558,7 @@ module HrrRbSsh
|
|
558
558
|
:'message number' => Message::SSH_MSG_CHANNEL_EOF::VALUE,
|
559
559
|
:'recipient channel' => @remote_channel,
|
560
560
|
}
|
561
|
-
payload = Message::SSH_MSG_CHANNEL_EOF.
|
561
|
+
payload = Message::SSH_MSG_CHANNEL_EOF.new(logger: logger).encode message
|
562
562
|
@connection.send payload
|
563
563
|
end
|
564
564
|
|
@@ -567,7 +567,7 @@ module HrrRbSsh
|
|
567
567
|
:'message number' => Message::SSH_MSG_CHANNEL_CLOSE::VALUE,
|
568
568
|
:'recipient channel' => @remote_channel,
|
569
569
|
}
|
570
|
-
payload = Message::SSH_MSG_CHANNEL_CLOSE.
|
570
|
+
payload = Message::SSH_MSG_CHANNEL_CLOSE.new(logger: logger).encode message
|
571
571
|
@connection.send payload
|
572
572
|
end
|
573
573
|
end
|