Sha256: 31f2c515ea00f2885d1739d6f528d778382d47ddbcd009c561a6d5e0cd4c0bfa

Contents?: true

Size: 1.44 KB

Versions: 87

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(512),
        :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

87 entries across 77 versions & 10 rubygems

Version Path
net-ssh-2.10.0.beta2 lib/net/ssh/test/kex.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/net-ssh-2.9.2/lib/net/ssh/test/kex.rb
net-ssh-2.10.0.beta1 lib/net/ssh/test/kex.rb
net-ssh-2.9.3.beta1 lib/net/ssh/test/kex.rb
net-ssh-2.9.2 lib/net/ssh/test/kex.rb
net-ssh-2.9.2.rc3 lib/net/ssh/test/kex.rb
net-ssh-2.9.2.rc2 lib/net/ssh/test/kex.rb
net-ssh-2.9.2.rc1 lib/net/ssh/test/kex.rb
net-ssh-2.9.2.beta lib/net/ssh/test/kex.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/test/kex.rb
net-ssh-2.9.1 lib/net/ssh/test/kex.rb
net-ssh-2.9.0 lib/net/ssh/test/kex.rb
net-ssh-2.8.0 lib/net/ssh/test/kex.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/test/kex.rb
net-ssh-2.7.0 lib/net/ssh/test/kex.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/net-ssh-2.6.7/lib/net/ssh/test/kex.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/net-ssh-2.6.8/lib/net/ssh/test/kex.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/net-ssh-2.6.7/lib/net/ssh/test/kex.rb
net-ssh-2.6.8 lib/net/ssh/test/kex.rb
vagrant-shell-0.2.6 vendor/bundle/gems/net-ssh-2.6.7/lib/net/ssh/test/kex.rb