Sha256: f3018f7748c450f96b742234a5f6c545e7e24c10446bfcc9fdbc57aaff4afbb0

Contents?: true

Size: 1.44 KB

Versions: 166

Compression:

Stored size: 1.44 KB

Contents

require 'openssl'

require 'net/ssh/errors'
require 'net/ssh/transport/algorithms'
require 'net/ssh/transport/constants'
require 'net/ssh/transport/kex'

module Net; module SSH; module 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.
  class Kex
    include Net::SSH::Transport::Constants

    # Creates a new instance of the testing key-exchange algorithm with the
    # given arguments.
    def initialize(algorithms, connection, data)
      @connection = connection
    end

    # Exchange keys with the server. This returns a hash of constant values,
    # and does not actually exchange keys.
    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(32),
        :shared_secret     => OpenSSL::BN.new("1234567890", 10),
        :hashing_algorithm => OpenSSL::Digest::SHA1 }
    end
  end

end; end; end

Net::SSH::Transport::Algorithms::ALGORITHMS[:kex] << "test"
Net::SSH::Transport::Kex::MAP["test"] = Net::SSH::Test::Kex

Version data entries

166 entries across 136 versions & 20 rubygems

Version Path
depengine-0.0.13 etc/isolate/ruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
minmb-net-ssh-2.5.1 lib/net/ssh/test/kex.rb
depengine-0.0.12 etc/isolate/jruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.12 etc/isolate/ruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.11 etc/isolate/ruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.11 etc/isolate/jruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.10 etc/isolate/jruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.10 etc/isolate/ruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/net-ssh-2.2.2/lib/net/ssh/test/kex.rb
depengine-0.0.9 etc/isolate/jruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.9 etc/isolate/ruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.8 etc/isolate/jruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.8 etc/isolate/ruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.7 etc/isolate/jruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.7 etc/isolate/ruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.5 etc/isolate/jruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.5 etc/isolate/ruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.4 etc/isolate/ruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.4 etc/isolate/jruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb
depengine-0.0.3 etc/isolate/ruby-1.8/gems/net-ssh-2.0.23/lib/net/ssh/test/kex.rb