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.
- checksums.yaml +4 -4
- data/.gitignore +0 -3
- data/.travis.yml +1 -0
- data/README.md +208 -46
- data/demo/client.rb +71 -0
- data/demo/echo_server.rb +8 -3
- data/demo/more_flexible_auth.rb +105 -0
- data/demo/multi_step_auth.rb +99 -0
- data/demo/server.rb +10 -4
- data/demo/subsystem_echo_server.rb +8 -3
- data/hrr_rb_ssh.gemspec +6 -6
- data/lib/hrr_rb_ssh.rb +1 -1
- data/lib/hrr_rb_ssh/algorithm/publickey.rb +0 -1
- data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2.rb +12 -9
- 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/ssh_dss.rb +10 -7
- 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_rsa.rb +9 -6
- 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/authentication.rb +103 -22
- data/lib/hrr_rb_ssh/authentication/constant.rb +14 -0
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb +44 -7
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/context.rb +16 -9
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_request.rb +7 -6
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_response.rb +5 -2
- data/lib/hrr_rb_ssh/authentication/method/none.rb +23 -7
- data/lib/hrr_rb_ssh/authentication/method/none/context.rb +15 -7
- data/lib/hrr_rb_ssh/authentication/method/password.rb +28 -7
- data/lib/hrr_rb_ssh/authentication/method/password/context.rb +16 -7
- data/lib/hrr_rb_ssh/authentication/method/publickey.rb +63 -10
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm.rb +0 -1
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb +32 -8
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/signature_blob.rb +2 -4
- data/lib/hrr_rb_ssh/authentication/method/publickey/context.rb +11 -2
- data/lib/hrr_rb_ssh/client.rb +234 -0
- data/lib/hrr_rb_ssh/codable.rb +15 -13
- data/lib/hrr_rb_ssh/compat/ruby.rb +0 -1
- data/lib/hrr_rb_ssh/connection.rb +145 -75
- data/lib/hrr_rb_ssh/connection/channel.rb +342 -109
- data/lib/hrr_rb_ssh/connection/channel/channel_type/direct_tcpip.rb +24 -19
- data/lib/hrr_rb_ssh/connection/channel/channel_type/forwarded_tcpip.rb +24 -19
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session.rb +19 -12
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/proc_chain.rb +0 -2
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/proc_chain/chain_context.rb +0 -3
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env.rb +2 -5
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env/context.rb +5 -4
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec.rb +2 -5
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec/context.rb +5 -4
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req.rb +2 -5
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req/context.rb +5 -4
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell.rb +2 -5
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell/context.rb +5 -4
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem.rb +2 -5
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem/context.rb +5 -4
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/window_change.rb +2 -5
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/window_change/context.rb +5 -4
- data/lib/hrr_rb_ssh/connection/global_request_handler.rb +14 -12
- data/lib/hrr_rb_ssh/connection/request_handler.rb +1 -3
- data/lib/hrr_rb_ssh/connection/request_handler/reference_env_request_handler.rb +0 -2
- data/lib/hrr_rb_ssh/connection/request_handler/reference_exec_request_handler.rb +4 -6
- data/lib/hrr_rb_ssh/connection/request_handler/reference_pty_req_request_handler.rb +10 -12
- data/lib/hrr_rb_ssh/connection/request_handler/reference_shell_request_handler.rb +4 -6
- data/lib/hrr_rb_ssh/connection/request_handler/reference_window_change_request_handler.rb +0 -2
- data/lib/hrr_rb_ssh/error/closed_authentication.rb +1 -1
- data/lib/hrr_rb_ssh/error/closed_connection.rb +1 -1
- data/lib/hrr_rb_ssh/error/closed_transport.rb +1 -1
- data/lib/hrr_rb_ssh/loggable.rb +42 -0
- 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 +3 -5
- 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/server.rb +16 -10
- data/lib/hrr_rb_ssh/transport.rb +113 -77
- data/lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb +5 -3
- data/lib/hrr_rb_ssh/transport/compression_algorithm/unfunctionable.rb +5 -3
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/functionable.rb +5 -3
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/unfunctionable.rb +5 -3
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman.rb +43 -37
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman/h0.rb +2 -4
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange.rb +87 -52
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange/h0.rb +2 -4
- data/lib/hrr_rb_ssh/transport/kex_algorithm/elliptic_curve_diffie_hellman.rb +43 -37
- data/lib/hrr_rb_ssh/transport/kex_algorithm/elliptic_curve_diffie_hellman/h0.rb +2 -4
- data/lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb +5 -3
- data/lib/hrr_rb_ssh/transport/mac_algorithm/unfunctionable.rb +5 -3
- data/lib/hrr_rb_ssh/transport/receiver.rb +8 -7
- data/lib/hrr_rb_ssh/transport/sender.rb +5 -3
- data/lib/hrr_rb_ssh/transport/sequence_number.rb +0 -4
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm.rb +0 -1
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/functionable.rb +5 -3
- data/lib/hrr_rb_ssh/version.rb +1 -1
- metadata +18 -51
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb +0 -61
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key.rb +0 -29
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key_content.rb +0 -26
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/pkey.rb +0 -158
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/public_key_blob.rb +0 -23
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/signature.rb +0 -23
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_ed25519.rb +0 -21
- data/lib/hrr_rb_ssh/compat/ruby/array.rb +0 -14
- data/lib/hrr_rb_ssh/logger.rb +0 -56
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_ed25519.rb +0 -20
@@ -1,61 +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 Algorithm
|
8
|
-
class Publickey
|
9
|
-
class SshEd25519 < Publickey
|
10
|
-
NAME = 'ssh-ed25519'
|
11
|
-
|
12
|
-
def initialize arg
|
13
|
-
begin
|
14
|
-
new_by_key_str arg
|
15
|
-
rescue PKey::Error
|
16
|
-
new_by_public_key_blob arg
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def new_by_key_str key_str
|
21
|
-
@publickey = PKey.new(key_str)
|
22
|
-
end
|
23
|
-
|
24
|
-
def new_by_public_key_blob public_key_blob
|
25
|
-
public_key_blob_h = PublicKeyBlob.decode(public_key_blob)
|
26
|
-
@publickey = PKey.new
|
27
|
-
@publickey.set_public_key(public_key_blob_h[:key])
|
28
|
-
end
|
29
|
-
|
30
|
-
def to_pem
|
31
|
-
@publickey.public_key.to_pem
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_public_key_blob
|
35
|
-
public_key_blob_h = {
|
36
|
-
:'public key algorithm name' => self.class::NAME,
|
37
|
-
:'key' => @publickey.public_key.key_str,
|
38
|
-
}
|
39
|
-
PublicKeyBlob.encode(public_key_blob_h)
|
40
|
-
end
|
41
|
-
|
42
|
-
def sign signature_blob
|
43
|
-
signature_h = {
|
44
|
-
:'public key algorithm name' => self.class::NAME,
|
45
|
-
:'signature blob' => @publickey.sign(signature_blob),
|
46
|
-
}
|
47
|
-
Signature.encode signature_h
|
48
|
-
end
|
49
|
-
|
50
|
-
def verify signature, signature_blob
|
51
|
-
signature_h = Signature.decode signature
|
52
|
-
signature_h[:'public key algorithm name'] == self.class::NAME && @publickey.public_key.verify(signature_h[:'signature blob'], signature_blob)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
require 'hrr_rb_ssh/algorithm/publickey/ssh_ed25519/pkey'
|
60
|
-
require 'hrr_rb_ssh/algorithm/publickey/ssh_ed25519/public_key_blob'
|
61
|
-
require 'hrr_rb_ssh/algorithm/publickey/ssh_ed25519/signature'
|
@@ -1,29 +0,0 @@
|
|
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
|
-
module Algorithm
|
9
|
-
class Publickey
|
10
|
-
class SshEd25519
|
11
|
-
module OpenSSHPrivateKey
|
12
|
-
class << self
|
13
|
-
include Codable
|
14
|
-
end
|
15
|
-
DEFINITION = [
|
16
|
-
[DataType::String, :'cipher'],
|
17
|
-
[DataType::String, :'kdfname'],
|
18
|
-
[DataType::Uint32, :'kdfopts'],
|
19
|
-
[DataType::Uint32, :'number of public keys'],
|
20
|
-
[DataType::Uint32, :'first public key length'],
|
21
|
-
[DataType::String, :'name'],
|
22
|
-
[DataType::String, :'public key'],
|
23
|
-
[DataType::String, :'content'],
|
24
|
-
]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,26 +0,0 @@
|
|
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
|
-
module Algorithm
|
9
|
-
class Publickey
|
10
|
-
class SshEd25519
|
11
|
-
module OpenSSHPrivateKeyContent
|
12
|
-
class << self
|
13
|
-
include Codable
|
14
|
-
end
|
15
|
-
DEFINITION = [
|
16
|
-
[DataType::Uint64, :'unknown'],
|
17
|
-
[DataType::String, :'name'],
|
18
|
-
[DataType::String, :'public key'],
|
19
|
-
[DataType::String, :'key pair'],
|
20
|
-
[DataType::String, :'padding'],
|
21
|
-
]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,158 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
# vim: et ts=2 sw=2
|
3
|
-
|
4
|
-
require 'stringio'
|
5
|
-
require 'base64'
|
6
|
-
require 'ed25519'
|
7
|
-
|
8
|
-
module HrrRbSsh
|
9
|
-
module Algorithm
|
10
|
-
class Publickey
|
11
|
-
class SshEd25519
|
12
|
-
class PKey
|
13
|
-
class Error < ::StandardError
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize arg=nil
|
17
|
-
case arg
|
18
|
-
when ::Ed25519::SigningKey, ::Ed25519::VerifyKey
|
19
|
-
@key = arg
|
20
|
-
when ::String
|
21
|
-
@key = load_key_str arg
|
22
|
-
when nil
|
23
|
-
# do nothing
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def load_key_str key_str
|
28
|
-
begin
|
29
|
-
load_openssh_key key_str
|
30
|
-
rescue
|
31
|
-
begin
|
32
|
-
load_openssl_key key_str
|
33
|
-
rescue
|
34
|
-
raise Error
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def load_openssh_key key_str
|
40
|
-
begin_marker = "-----BEGIN OPENSSH PRIVATE KEY-----\n"
|
41
|
-
end_marker = "-----END OPENSSH PRIVATE KEY-----\n"
|
42
|
-
magic = "openssh-key-v1"
|
43
|
-
|
44
|
-
raise Error unless key_str.start_with? begin_marker
|
45
|
-
raise Error unless key_str.end_with? end_marker
|
46
|
-
decoded_key_str = Base64.decode64(key_str[begin_marker.size...-end_marker.size])
|
47
|
-
raise Error unless decoded_key_str[0,14] == magic
|
48
|
-
|
49
|
-
private_key_h = OpenSSHPrivateKey.decode decoded_key_str[15..-1]
|
50
|
-
private_key_content_h = OpenSSHPrivateKeyContent.decode private_key_h[:'content']
|
51
|
-
key_pair = private_key_content_h[:'key pair']
|
52
|
-
|
53
|
-
::Ed25519::SigningKey.new(key_pair[0,32])
|
54
|
-
end
|
55
|
-
|
56
|
-
def load_openssl_key key_str
|
57
|
-
private_key_begin_marker = "-----BEGIN PRIVATE KEY-----\n"
|
58
|
-
public_key_begin_marker = "-----BEGIN PUBLIC KEY-----\n"
|
59
|
-
if key_str.start_with? private_key_begin_marker
|
60
|
-
begin_marker = "-----BEGIN PRIVATE KEY-----\n"
|
61
|
-
end_marker = "-----END PRIVATE KEY-----\n"
|
62
|
-
|
63
|
-
raise Error unless key_str.start_with? begin_marker
|
64
|
-
raise Error unless key_str.end_with? end_marker
|
65
|
-
|
66
|
-
decoded_key_str = Base64.decode64(key_str[begin_marker.size...-end_marker.size])
|
67
|
-
key_der = OpenSSL::ASN1.decode decoded_key_str
|
68
|
-
|
69
|
-
::Ed25519::SigningKey.new(key_der.value[2].value[2..-1])
|
70
|
-
elsif key_str.start_with? public_key_begin_marker
|
71
|
-
begin_marker = "-----BEGIN PUBLIC KEY-----\n"
|
72
|
-
end_marker = "-----END PUBLIC KEY-----\n"
|
73
|
-
|
74
|
-
raise Error unless key_str.start_with? begin_marker
|
75
|
-
raise Error unless key_str.end_with? end_marker
|
76
|
-
|
77
|
-
decoded_key_str = Base64.decode64(key_str[begin_marker.size...-end_marker.size])
|
78
|
-
key_der = OpenSSL::ASN1.decode decoded_key_str
|
79
|
-
|
80
|
-
::Ed25519::VerifyKey.new(key_der.value[1].value)
|
81
|
-
else
|
82
|
-
raise Error
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def set_public_key key_str
|
87
|
-
@key = ::Ed25519::VerifyKey.new(key_str)
|
88
|
-
end
|
89
|
-
|
90
|
-
def to_pem
|
91
|
-
ed25519_object_id = '1.3.101.112'
|
92
|
-
case @key
|
93
|
-
=begin
|
94
|
-
when ::Ed25519::SigningKey
|
95
|
-
begin_marker = "-----BEGIN PRIVATE KEY-----\n"
|
96
|
-
end_marker = "-----END PRIVATE KEY-----\n"
|
97
|
-
key_asn1 = OpenSSL::ASN1::Sequence.new(
|
98
|
-
[
|
99
|
-
OpenSSL::ASN1::Integer.new(OpenSSL::BN.new(0)),
|
100
|
-
OpenSSL::ASN1::Sequence.new(
|
101
|
-
[
|
102
|
-
OpenSSL::ASN1::ObjectId.new(ed25519_object_id),
|
103
|
-
]
|
104
|
-
),
|
105
|
-
OpenSSL::ASN1::OctetString.new(@key.to_bytes),
|
106
|
-
]
|
107
|
-
)
|
108
|
-
=end
|
109
|
-
when ::Ed25519::VerifyKey
|
110
|
-
begin_marker = "-----BEGIN PUBLIC KEY-----\n"
|
111
|
-
end_marker = "-----END PUBLIC KEY-----\n"
|
112
|
-
key_asn1 = OpenSSL::ASN1::Sequence.new(
|
113
|
-
[
|
114
|
-
OpenSSL::ASN1::Sequence.new(
|
115
|
-
[
|
116
|
-
OpenSSL::ASN1::ObjectId.new(ed25519_object_id),
|
117
|
-
]
|
118
|
-
),
|
119
|
-
OpenSSL::ASN1::BitString.new(@key.to_bytes),
|
120
|
-
]
|
121
|
-
)
|
122
|
-
end
|
123
|
-
pem_str = Base64.encode64(key_asn1.to_der)
|
124
|
-
begin_marker + pem_str + end_marker
|
125
|
-
end
|
126
|
-
|
127
|
-
def public_key
|
128
|
-
case @key
|
129
|
-
when ::Ed25519::SigningKey
|
130
|
-
self.class.new @key.verify_key
|
131
|
-
when ::Ed25519::VerifyKey
|
132
|
-
self
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def key_str
|
137
|
-
@key.to_bytes
|
138
|
-
end
|
139
|
-
|
140
|
-
def sign data
|
141
|
-
@key.sign data
|
142
|
-
end
|
143
|
-
|
144
|
-
def verify signature, data
|
145
|
-
begin
|
146
|
-
@key.verify signature, data
|
147
|
-
rescue ::Ed25519::VerifyError
|
148
|
-
false
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
require 'hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key'
|
158
|
-
require 'hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key_content'
|
@@ -1,23 +0,0 @@
|
|
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
|
-
module Algorithm
|
9
|
-
class Publickey
|
10
|
-
class SshEd25519
|
11
|
-
module PublicKeyBlob
|
12
|
-
class << self
|
13
|
-
include Codable
|
14
|
-
end
|
15
|
-
DEFINITION = [
|
16
|
-
[DataType::String, :'public key algorithm name'],
|
17
|
-
[DataType::String, :'key'],
|
18
|
-
]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,23 +0,0 @@
|
|
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
|
-
module Algorithm
|
9
|
-
class Publickey
|
10
|
-
class SshEd25519
|
11
|
-
module Signature
|
12
|
-
class << self
|
13
|
-
include Codable
|
14
|
-
end
|
15
|
-
DEFINITION = [
|
16
|
-
[DataType::String, :'public key algorithm name'],
|
17
|
-
[DataType::String, :'signature blob'],
|
18
|
-
]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
# vim: et ts=2 sw=2
|
3
|
-
|
4
|
-
require 'hrr_rb_ssh/authentication/method/publickey/algorithm/functionable'
|
5
|
-
|
6
|
-
module HrrRbSsh
|
7
|
-
class Authentication
|
8
|
-
class Method
|
9
|
-
class Publickey
|
10
|
-
class Algorithm
|
11
|
-
class SshEd25519 < Algorithm
|
12
|
-
NAME = 'ssh-ed25519'
|
13
|
-
PREFERENCE = 60
|
14
|
-
|
15
|
-
include Functionable
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/hrr_rb_ssh/logger.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
# vim: et ts=2 sw=2
|
3
|
-
|
4
|
-
module HrrRbSsh
|
5
|
-
class Logger
|
6
|
-
@@logger = nil
|
7
|
-
|
8
|
-
class << self
|
9
|
-
def initialize logger
|
10
|
-
@@logger = logger
|
11
|
-
end
|
12
|
-
|
13
|
-
def uninitialize
|
14
|
-
@@logger = nil
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialized?
|
18
|
-
@@logger != nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def initialize name
|
23
|
-
@name = name
|
24
|
-
end
|
25
|
-
|
26
|
-
def fatal
|
27
|
-
if @@logger
|
28
|
-
@@logger.fatal { "#{@name}: #{yield}" }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def error
|
33
|
-
if @@logger
|
34
|
-
@@logger.error { "#{@name}: #{yield}" }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def warn
|
39
|
-
if @@logger
|
40
|
-
@@logger.warn { "#{@name}: #{yield}" }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def info
|
45
|
-
if @@logger
|
46
|
-
@@logger.info { "#{@name}: #{yield}" }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def debug
|
51
|
-
if @@logger
|
52
|
-
@@logger.debug { "#{@name}: #{yield}" }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
# vim: et ts=2 sw=2
|
3
|
-
|
4
|
-
require 'ed25519'
|
5
|
-
require 'hrr_rb_ssh/openssl_secure_random'
|
6
|
-
require 'hrr_rb_ssh/transport/server_host_key_algorithm/functionable'
|
7
|
-
|
8
|
-
module HrrRbSsh
|
9
|
-
class Transport
|
10
|
-
class ServerHostKeyAlgorithm
|
11
|
-
class SshEd25519 < ServerHostKeyAlgorithm
|
12
|
-
NAME = 'ssh-ed25519'
|
13
|
-
PREFERENCE = 60
|
14
|
-
SECRET_KEY = ::Ed25519::SigningKey.generate
|
15
|
-
|
16
|
-
include Functionable
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|