Class | Net::SSH::Test::Kex |
In: |
lib/net/ssh/test/kex.rb
lib/net/ssh/test/kex.rb |
Parent: | Object |
An implementation of a key-exchange strategy specifically for unit tests. (This strategy would never really work against a real SSH server—it makes too many assumptions about the server‘s response.)
This registers itself with the transport key-exchange system as the "test" algorithm.
Exchange keys with the server. This returns a hash of constant values, and does not actually exchange keys.
# File lib/net/ssh/test/kex.rb, line 27 27: def exchange_keys 28: result = Net::SSH::Buffer.from(:byte, NEWKEYS) 29: @connection.send_message(result) 30: 31: buffer = @connection.next_message 32: raise Net::SSH::Exception, "expected NEWKEYS" unless buffer.type == NEWKEYS 33: 34: { :session_id => "abc-xyz", 35: :server_key => OpenSSL::PKey::RSA.new(32), 36: :shared_secret => OpenSSL::BN.new("1234567890", 10), 37: :hashing_algorithm => OpenSSL::Digest::SHA1 } 38: end
Exchange keys with the server. This returns a hash of constant values, and does not actually exchange keys.
# File lib/net/ssh/test/kex.rb, line 27 27: def exchange_keys 28: result = Net::SSH::Buffer.from(:byte, NEWKEYS) 29: @connection.send_message(result) 30: 31: buffer = @connection.next_message 32: raise Net::SSH::Exception, "expected NEWKEYS" unless buffer.type == NEWKEYS 33: 34: { :session_id => "abc-xyz", 35: :server_key => OpenSSL::PKey::RSA.new(32), 36: :shared_secret => OpenSSL::BN.new("1234567890", 10), 37: :hashing_algorithm => OpenSSL::Digest::SHA1 } 38: end