hrr_rb_ssh 0.3.1 → 0.4.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +4 -4
- data/demo/server.rb +1 -1
- data/hrr_rb_ssh.gemspec +0 -2
- data/lib/hrr_rb_ssh/algorithm/publickey.rb +0 -1
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm.rb +0 -1
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm.rb +0 -1
- data/lib/hrr_rb_ssh/version.rb +1 -1
- metadata +4 -26
- 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/algorithm/publickey/ssh_ed25519.rb +0 -61
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_ed25519.rb +0 -21
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_ed25519.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bab944f20759d7530c45a2b305e75786a1550434acd505a92042a49631447065
|
4
|
+
data.tar.gz: 4c57b3e6df49eecc99b8e3415915df6c58827fd7c79030bdeaee8c397a00b302
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a725f5873e844406368f9958308ea95ed1a755a35cada1af968ae1c5c642d890483ca51eaf39f1512403ff7eda7da7760ee93f041a02e42c105a7d32517d5ff5
|
7
|
+
data.tar.gz: 7c594a07bddba8a7068c99ddee48a1188cf0d63bf7210307acc872b8d162103b5b6e39aa848f1547bfad7a7abc3f92c5720ed626b1970af8eb5aa02fedefad69
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -9,6 +9,8 @@ hrr_rb_ssh is a pure Ruby SSH 2.0 server and client implementation.
|
|
9
9
|
|
10
10
|
With hrr_rb_ssh, it is possible to write an SSH server easily, and also possible to write an original server side application on secure connection provided by SSH protocol. And it supports to write SSH client as well.
|
11
11
|
|
12
|
+
NOTE: ED25519 public key algorithm is now separated from hrr_rb_ssh. Please refer to [hrr_rb_ssh-ed25519](https://github.com/hirura/hrr_rb_ssh-ed25519).
|
13
|
+
|
12
14
|
## Table of Contents
|
13
15
|
|
14
16
|
- [Installation](#installation)
|
@@ -389,9 +391,9 @@ p HrrRbSsh::Transport::EncryptionAlgorithm.list_preferred
|
|
389
391
|
# => ["aes128-ctr", "aes192-ctr", "aes256-ctr", "aes128-cbc", "3des-cbc", "blowfish-cbc", "cast128-cbc", "aes192-cbc", "aes256-cbc", "arcfour"]
|
390
392
|
|
391
393
|
p HrrRbSsh::Transport::ServerHostKeyAlgorithm.list_supported
|
392
|
-
# => ["ssh-dss", "ssh-rsa", "ecdsa-sha2-nistp256", "ecdsa-sha2-nistp384", "ecdsa-sha2-nistp521"
|
394
|
+
# => ["ssh-dss", "ssh-rsa", "ecdsa-sha2-nistp256", "ecdsa-sha2-nistp384", "ecdsa-sha2-nistp521"]
|
393
395
|
p HrrRbSsh::Transport::ServerHostKeyAlgorithm.list_preferred
|
394
|
-
# => ["
|
396
|
+
# => ["ecdsa-sha2-nistp521", "ecdsa-sha2-nistp384", "ecdsa-sha2-nistp256", "ssh-rsa", "ssh-dss"]
|
395
397
|
|
396
398
|
p HrrRbSsh::Transport::KexAlgorithm.list_supported
|
397
399
|
# => ["diffie-hellman-group1-sha1", "diffie-hellman-group14-sha1", "diffie-hellman-group-exchange-sha1", "diffie-hellman-group-exchange-sha256", "diffie-hellman-group14-sha256", "diffie-hellman-group15-sha512", "diffie-hellman-group16-sha512", "diffie-hellman-group17-sha512", "diffie-hellman-group18-sha512", "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521"]
|
@@ -521,7 +523,6 @@ The following features are currently supported.
|
|
521
523
|
- ecdsa-sha2-nistp256
|
522
524
|
- ecdsa-sha2-nistp384
|
523
525
|
- ecdsa-sha2-nistp521
|
524
|
-
- ssh-ed25519
|
525
526
|
- Keyboard interactive (generic interactive / challenge response) authentication
|
526
527
|
|
527
528
|
### Transport layer
|
@@ -544,7 +545,6 @@ The following features are currently supported.
|
|
544
545
|
- ecdsa-sha2-nistp256
|
545
546
|
- ecdsa-sha2-nistp384
|
546
547
|
- ecdsa-sha2-nistp521
|
547
|
-
- ssh-ed25519
|
548
548
|
- Kex algorithm
|
549
549
|
- diffie-hellman-group1-sha1
|
550
550
|
- diffie-hellman-group14-sha1
|
data/demo/server.rb
CHANGED
@@ -18,7 +18,7 @@ def start_service io, logger=nil
|
|
18
18
|
HrrRbSsh::Logger.initialize logger if logger
|
19
19
|
|
20
20
|
tran_preferred_encryption_algorithms = %w(aes128-ctr aes192-ctr aes256-ctr aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc aes256-cbc arcfour)
|
21
|
-
tran_preferred_server_host_key_algorithms = %w(
|
21
|
+
tran_preferred_server_host_key_algorithms = %w(ecdsa-sha2-nistp521 ecdsa-sha2-nistp384 ecdsa-sha2-nistp256 ssh-rsa ssh-dss)
|
22
22
|
tran_preferred_kex_algorithms = %w(ecdh-sha2-nistp521 ecdh-sha2-nistp384 ecdh-sha2-nistp256 diffie-hellman-group14-sha1 diffie-hellman-group1-sha1)
|
23
23
|
tran_preferred_mac_algorithms = %w(hmac-sha2-512 hmac-sha2-256 hmac-sha1 hmac-md5 hmac-sha1-96 hmac-md5-96)
|
24
24
|
tran_preferred_compression_algorithms = %w(none zlib)
|
data/hrr_rb_ssh.gemspec
CHANGED
@@ -22,8 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.required_ruby_version = '>= 2.0.0'
|
24
24
|
|
25
|
-
spec.add_dependency "ed25519", "~> 1.2"
|
26
|
-
|
27
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
26
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
27
|
spec.add_development_dependency "simplecov", "~> 0.16"
|
@@ -19,4 +19,3 @@ require 'hrr_rb_ssh/algorithm/publickey/ssh_rsa'
|
|
19
19
|
require 'hrr_rb_ssh/algorithm/publickey/ecdsa_sha2_nistp256'
|
20
20
|
require 'hrr_rb_ssh/algorithm/publickey/ecdsa_sha2_nistp384'
|
21
21
|
require 'hrr_rb_ssh/algorithm/publickey/ecdsa_sha2_nistp521'
|
22
|
-
require 'hrr_rb_ssh/algorithm/publickey/ssh_ed25519'
|
@@ -23,4 +23,3 @@ require 'hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa'
|
|
23
23
|
require 'hrr_rb_ssh/authentication/method/publickey/algorithm/ecdsa_sha2_nistp256'
|
24
24
|
require 'hrr_rb_ssh/authentication/method/publickey/algorithm/ecdsa_sha2_nistp384'
|
25
25
|
require 'hrr_rb_ssh/authentication/method/publickey/algorithm/ecdsa_sha2_nistp521'
|
26
|
-
require 'hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_ed25519'
|
@@ -19,4 +19,3 @@ require 'hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa'
|
|
19
19
|
require 'hrr_rb_ssh/transport/server_host_key_algorithm/ecdsa_sha2_nistp256'
|
20
20
|
require 'hrr_rb_ssh/transport/server_host_key_algorithm/ecdsa_sha2_nistp384'
|
21
21
|
require 'hrr_rb_ssh/transport/server_host_key_algorithm/ecdsa_sha2_nistp521'
|
22
|
-
require 'hrr_rb_ssh/transport/server_host_key_algorithm/ssh_ed25519'
|
data/lib/hrr_rb_ssh/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hrr_rb_ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hirura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: ed25519
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.2'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.2'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rake
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,12 +87,6 @@ files:
|
|
101
87
|
- lib/hrr_rb_ssh/algorithm/publickey/ssh_dss.rb
|
102
88
|
- lib/hrr_rb_ssh/algorithm/publickey/ssh_dss/public_key_blob.rb
|
103
89
|
- lib/hrr_rb_ssh/algorithm/publickey/ssh_dss/signature.rb
|
104
|
-
- lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb
|
105
|
-
- lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key.rb
|
106
|
-
- lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key_content.rb
|
107
|
-
- lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/pkey.rb
|
108
|
-
- lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/public_key_blob.rb
|
109
|
-
- lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/signature.rb
|
110
90
|
- lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa.rb
|
111
91
|
- lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa/public_key_blob.rb
|
112
92
|
- lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa/signature.rb
|
@@ -130,7 +110,6 @@ files:
|
|
130
110
|
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb
|
131
111
|
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/signature_blob.rb
|
132
112
|
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss.rb
|
133
|
-
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_ed25519.rb
|
134
113
|
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa.rb
|
135
114
|
- lib/hrr_rb_ssh/authentication/method/publickey/context.rb
|
136
115
|
- lib/hrr_rb_ssh/client.rb
|
@@ -288,7 +267,6 @@ files:
|
|
288
267
|
- lib/hrr_rb_ssh/transport/server_host_key_algorithm/ecdsa_sha2_nistp521.rb
|
289
268
|
- lib/hrr_rb_ssh/transport/server_host_key_algorithm/functionable.rb
|
290
269
|
- lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss.rb
|
291
|
-
- lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_ed25519.rb
|
292
270
|
- lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa.rb
|
293
271
|
- lib/hrr_rb_ssh/version.rb
|
294
272
|
homepage: https://github.com/hirura/hrr_rb_ssh
|
@@ -306,9 +284,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
306
284
|
version: 2.0.0
|
307
285
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
308
286
|
requirements:
|
309
|
-
- - "
|
287
|
+
- - ">"
|
310
288
|
- !ruby/object:Gem::Version
|
311
|
-
version:
|
289
|
+
version: 1.3.1
|
312
290
|
requirements: []
|
313
291
|
rubygems_version: 3.0.3
|
314
292
|
signing_key:
|
@@ -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,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,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
|
@@ -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
|