hrr_rb_ssh 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/demo/server.rb +23 -3
- data/hrr_rb_ssh.gemspec +2 -2
- data/lib/hrr_rb_ssh/authentication/method/method.rb +34 -0
- data/lib/hrr_rb_ssh/authentication/method/none.rb +5 -14
- data/lib/hrr_rb_ssh/authentication/method/password.rb +6 -12
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/algorithm.rb +41 -0
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/codable.rb +33 -0
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_dss.rb +105 -0
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_rsa.rb +85 -0
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm.rb +28 -0
- data/lib/hrr_rb_ssh/authentication/method/publickey.rb +9 -25
- data/lib/hrr_rb_ssh/authentication/method.rb +12 -9
- data/lib/hrr_rb_ssh/connection/channel/channel_type/channel_type.rb +30 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env/context.rb +46 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env.rb +34 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec/context.rb +44 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec.rb +34 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req/context.rb +54 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req.rb +34 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/request_type.rb +34 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell/context.rb +41 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell.rb +34 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem/context.rb +44 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem.rb +34 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type.rb +33 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session.rb +30 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type.rb +25 -0
- data/lib/hrr_rb_ssh/connection/channel.rb +2 -12
- data/lib/hrr_rb_ssh/transport/compression_algorithm/compression_algorithm.rb +34 -0
- data/lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb +31 -0
- data/lib/hrr_rb_ssh/transport/compression_algorithm/none.rb +7 -19
- data/lib/hrr_rb_ssh/transport/compression_algorithm/unfunctionable.rb +20 -0
- data/lib/hrr_rb_ssh/transport/compression_algorithm/zlib.rb +7 -24
- data/lib/hrr_rb_ssh/transport/compression_algorithm.rb +11 -9
- data/lib/hrr_rb_ssh/transport/direction.rb +11 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes128_cbc.rb +19 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes128_ctr.rb +19 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes192_cbc.rb +19 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes192_ctr.rb +19 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes256_cbc.rb +19 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes256_ctr.rb +19 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/arcfour.rb +19 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/blowfish_cbc.rb +19 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/cast128_cbc.rb +19 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/encryption_algorithm.rb +34 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/functionable.rb +61 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/none.rb +6 -33
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/three_des_cbc.rb +19 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/unfunctionable.rb +35 -0
- data/lib/hrr_rb_ssh/transport/encryption_algorithm.rb +20 -9
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman.rb +3 -4
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group14_sha1.rb +4 -8
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group1_sha1.rb +4 -8
- data/lib/hrr_rb_ssh/transport/kex_algorithm/kex_algorithm.rb +34 -0
- data/lib/hrr_rb_ssh/transport/kex_algorithm.rb +10 -9
- data/lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb +32 -0
- data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_md5.rb +21 -0
- data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_md5_96.rb +21 -0
- data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_sha1.rb +5 -29
- data/lib/hrr_rb_ssh/transport/mac_algorithm/hmac_sha1_96.rb +21 -0
- data/lib/hrr_rb_ssh/transport/mac_algorithm/mac_algorithm.rb +34 -0
- data/lib/hrr_rb_ssh/transport/mac_algorithm/none.rb +6 -22
- data/lib/hrr_rb_ssh/transport/mac_algorithm/unfunctionable.rb +24 -0
- data/lib/hrr_rb_ssh/transport/mac_algorithm.rb +14 -9
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/server_host_key_algorithm.rb +34 -0
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_dss.rb +106 -0
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_rsa.rb +4 -11
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm.rb +10 -8
- data/lib/hrr_rb_ssh/transport.rb +23 -15
- data/lib/hrr_rb_ssh/version.rb +1 -1
- metadata +51 -17
- data/lib/hrr_rb_ssh/authentication/method/publickey/ssh_rsa.rb +0 -116
- data/lib/hrr_rb_ssh/connection/channel/session/env/context.rb +0 -43
- data/lib/hrr_rb_ssh/connection/channel/session/env.rb +0 -31
- data/lib/hrr_rb_ssh/connection/channel/session/exec/context.rb +0 -41
- data/lib/hrr_rb_ssh/connection/channel/session/exec.rb +0 -31
- data/lib/hrr_rb_ssh/connection/channel/session/pty_req/context.rb +0 -50
- data/lib/hrr_rb_ssh/connection/channel/session/pty_req.rb +0 -31
- data/lib/hrr_rb_ssh/connection/channel/session/shell/context.rb +0 -37
- data/lib/hrr_rb_ssh/connection/channel/session/shell.rb +0 -31
- data/lib/hrr_rb_ssh/connection/channel/session/subsystem/context.rb +0 -40
- data/lib/hrr_rb_ssh/connection/channel/session/subsystem.rb +0 -31
- data/lib/hrr_rb_ssh/connection/channel/session.rb +0 -31
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/aes_128_cbc.rb +0 -73
@@ -1,73 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
# vim: et ts=2 sw=2
|
3
|
-
|
4
|
-
require 'openssl'
|
5
|
-
|
6
|
-
require 'hrr_rb_ssh/logger'
|
7
|
-
|
8
|
-
module HrrRbSsh
|
9
|
-
class Transport
|
10
|
-
class EncryptionAlgorithm
|
11
|
-
name_list = [
|
12
|
-
'aes128-cbc'
|
13
|
-
]
|
14
|
-
|
15
|
-
class Aes128Cbc
|
16
|
-
CIPHER_NAME = "AES-128-CBC"
|
17
|
-
|
18
|
-
BLOCK_SIZE = OpenSSL::Cipher.new(CIPHER_NAME).block_size
|
19
|
-
IV_LENGTH = OpenSSL::Cipher.new(CIPHER_NAME).iv_len
|
20
|
-
KEY_LENGTH = OpenSSL::Cipher.new(CIPHER_NAME).key_len
|
21
|
-
|
22
|
-
def initialize iv, key
|
23
|
-
@logger = HrrRbSsh::Logger.new self.class.name
|
24
|
-
|
25
|
-
@encryptor = OpenSSL::Cipher.new(CIPHER_NAME)
|
26
|
-
@encryptor.encrypt
|
27
|
-
@encryptor.padding = 0
|
28
|
-
@encryptor.iv = iv
|
29
|
-
@encryptor.key = key
|
30
|
-
|
31
|
-
@decryptor = OpenSSL::Cipher.new(CIPHER_NAME)
|
32
|
-
@decryptor.decrypt
|
33
|
-
@decryptor.padding = 0
|
34
|
-
@decryptor.iv = iv
|
35
|
-
@decryptor.key = key
|
36
|
-
end
|
37
|
-
|
38
|
-
def block_size
|
39
|
-
BLOCK_SIZE
|
40
|
-
end
|
41
|
-
|
42
|
-
def iv_length
|
43
|
-
IV_LENGTH
|
44
|
-
end
|
45
|
-
|
46
|
-
def key_length
|
47
|
-
KEY_LENGTH
|
48
|
-
end
|
49
|
-
|
50
|
-
def encrypt data
|
51
|
-
if data.empty?
|
52
|
-
data
|
53
|
-
else
|
54
|
-
@encryptor.update(data) + @encryptor.final
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def decrypt data
|
59
|
-
if data.empty?
|
60
|
-
data
|
61
|
-
else
|
62
|
-
@decryptor.update(data) + @decryptor.final
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
@@list ||= Hash.new
|
68
|
-
name_list.each do |name|
|
69
|
-
@@list[name] = Aes128Cbc
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|