Methods
Classes and Modules
Module Net::SSH::Transport::OSSL::HMACModule Net::SSH::Transport::OSSL::ReaderBufferImpl
Class Net::SSH::Transport::OSSL::Buffer
Class Net::SSH::Transport::OSSL::BufferFactory
Class Net::SSH::Transport::OSSL::CipherFactory
Class Net::SSH::Transport::OSSL::DigestFactory
Class Net::SSH::Transport::OSSL::HMACFactory
Class Net::SSH::Transport::OSSL::KeyFactory
Class Net::SSH::Transport::OSSL::ReaderBuffer
Public Instance methods
Register all OpenSSL-related services.
[ show source ]
# File lib/net/ssh/transport/ossl/services.rb, line 25
25: def register_services( container )
26: # make sure the user has a valid Ruby and OpenSSL installed.
27: version_check
28:
29: # Register all OpenSSL services in the :ossl namespace.
30: container.namespace_define :ossl do |b|
31:
32: # The list of known sources of HMAC algorithm implementations.
33: b.hmac_algorithm_sources { Array.new }
34: b.require 'net/ssh/transport/ossl/hmac/services', "#{self}::HMAC"
35:
36: # The hash mapping SSH2 cipher names to OpenSSL cipher names.
37: b.cipher_names do
38: Hash[ "3des-cbc" => "des-ede3-cbc",
39: "blowfish-cbc" => "bf-cbc",
40: "aes256-cbc" => "aes-256-cbc",
41: "aes192-cbc" => "aes-192-cbc",
42: "aes128-cbc" => "aes-128-cbc",
43: "idea-cbc" => "idea-cbc",
44: "none" => "none" ]
45: end
46:
47: # The hash mapping key names to OpenSSL key implementations.
48: b.key_names do
49: Hash[ "dh" => OpenSSL::PKey::DH,
50: "rsa" => OpenSSL::PKey::RSA,
51: "dsa" => OpenSSL::PKey::DSA ]
52: end
53:
54: # The hash mapping digest names to OpenSSL digest implementations.
55: b.digest_names do
56: Hash[ "sha1" => OpenSSL::Digest::SHA1,
57: "md5" => OpenSSL::Digest::MD5 ]
58: end
59:
60: # The factory for converting cipher names to cipher implementations.
61: b.cipher_factory( :model => :singleton_deferred ) do |c,p|
62: require 'net/ssh/transport/ossl/cipher-factory'
63: svc = CipherFactory.new( c.cipher_names )
64: svc.identity_cipher = c.identity_cipher
65: svc
66: end
67:
68: # The factory for converting HMAC names to HMAC implementations.
69: b.hmac_factory( :model => :singleton_deferred ) do |c,p|
70: require 'net/ssh/transport/ossl/hmac-factory'
71: HMACFactory.new( c.hmac_algorithm_sources )
72: end
73:
74: # The factory for obtaining OpenSSL-specific buffer implementations.
75: b.buffer_factory do
76: require 'net/ssh/transport/ossl/buffer-factory'
77: BufferFactory.new
78: end
79:
80: # The factory for converting key names to key implementations.
81: b.key_factory( :model => :singleton_deferred ) do |c,p|
82: require 'net/ssh/transport/ossl/key-factory'
83: svc = KeyFactory.new( c.key_names )
84: svc.buffers = c.buffer_factory
85: svc.prompter = c.prompter if c.knows_key?( :prompter )
86: svc
87: end
88:
89: # The factory for creating OpenSSL::BN (big number) instances.
90: b.bn_factory { OpenSSL::BN }
91:
92: # The factory for converting digest names to digest implementations.
93: b.digest_factory do |c,p|
94: require 'net/ssh/transport/ossl/digest-factory'
95: DigestFactory.new( c.digest_names )
96: end
97:
98: end
99:
100: # Register each of the factories defined above in the corresponding
101: # factory map, under the :ossl key.
102: container.define do |b|
103: b.cipher_factories[:ossl] = b.ossl.cipher_factory
104: b.hmac_factories[:ossl] = b.ossl.hmac_factory
105: b.key_factories[:ossl] = b.ossl.key_factory
106: b.buffer_factories[:ossl] = b.ossl.buffer_factory
107: b.bn_factories[:ossl] = b.ossl.bn_factory
108: b.digest_factories[:ossl] = b.ossl.digest_factory
109: end
110: end
Tries to make sure that the correct minimum versions of libraries are installed.
[ show source ]
# File lib/net/ssh/transport/ossl/services.rb, line 115
115: def version_check
116: if RUBY_VERSION < "1.8.2"
117: unless OpenSSL::PKey::DH.instance_methods.include? "p"
118: warn "Your OpenSSL module (the Ruby module, not the library)\n" +
119: "is too old. Please go to the Net::SSH downloads page\n" +
120: "and install the most recent snapshot of the OpenSSL\n" +
121: "module.\n\n" +
122: " http://rubyforge.org/projects/net-ssh"
123: abort
124: end
125: end
126:
127: # make sure that the OpenSSL library itself is at least version 0.9.7
128: match = OpenSSL::OPENSSL_VERSION.match(
129: /OpenSSL (\d+)\.(\d+)\.(\d+)(.*?) / )
130: major = match[1].to_i
131: minor = match[2].to_i
132: tiny = match[3].to_i
133: patch = match[4]
134:
135: if major < 1 && ( minor < 9 || minor == 9 && tiny < 7 )
136: ver = "#{major}.#{minor}.#{tiny}#{patch}"
137: warn "Your OpenSSL library (the library itself, not the Ruby\n" +
138: "module) is version #{ver}, too old to use with Net::SSH.\n" +
139: "Please upgrade to at least version 0.9.7 and then rebuild\n" +
140: "your Ruby OpenSSL module."
141: abort
142: end
143: end