Class Net::SSH::Test::Kex

  1. 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.

Methods

public class

  1. new

public instance

  1. exchange_keys

Public class methods

new (algorithms, connection, data)

Creates a new instance of the testing key-exchange algorithm with the given arguments.

[show source]
    # File lib/net/ssh/test/kex.rb, line 21
21:     def initialize(algorithms, connection, data)
22:       @connection = connection
23:     end

Public instance methods

exchange_keys ()

Exchange keys with the server. This returns a hash of constant values, and does not actually exchange keys.

[show source]
    # 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