class Net::SSH::Test::Kex

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.

Public Class Methods

new(algorithms, connection, data) click to toggle source

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

# File lib/net/ssh/test/kex.rb, line 23
def initialize(algorithms, connection, data)
  @connection = connection

Public Instance Methods

exchange_keys() click to toggle source

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 29
def exchange_keys
  result = Net::SSH::Buffer.from(:byte, NEWKEYS)
  buffer = @connection.next_message
  raise Net::SSH::Exception, "expected NEWKEYS" unless buffer.type == NEWKEYS
  { session_id: "abc-xyz",
    shared_secret:"1234567890", 10),
    hashing_algorithm: OpenSSL::Digest::SHA1 }