class Net::SSH::Test::Kex

  1. lib/net/ssh/test/kex.rb
Parent: Test

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
def initialize(algorithms, connection, data)
  @connection = connection
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
def exchange_keys
  result = Net::SSH::Buffer.from(:byte, NEWKEYS)
  @connection.send_message(result)

  buffer = @connection.next_message
  raise Net::SSH::Exception, "expected NEWKEYS" unless buffer.type == NEWKEYS

  { :session_id        => "abc-xyz",
    :server_key        => OpenSSL::PKey::RSA.new(512),
    :shared_secret     => OpenSSL::BN.new("1234567890", 10),
    :hashing_algorithm => OpenSSL::Digest::SHA1 }
end