Sha256: cacc6af570824cf4811dddb1f5a201d1ce8c6b731d8dd3fa2194247113d3a292

Contents?: true

Size: 1.04 KB

Versions: 55

Compression:

Stored size: 1.04 KB

Contents

#!/usr/bin/env ruby
$: << '../lib'
$: << '.'
#require 'gssapi/heimdal'
require 'gssapi'
require 'gss_iov_helpers'
require 'base64'
require 'socket'

class GssIovClient
  include GssIOVHelpers

  def initialize
    @host = 'example.org'
    @service  = 'host'
    @sock = TCPSocket.new(@host, 8082)
    @gss = GSSAPI::Simple.new(@host, @service)
  end

  def run
    handshake
    begin
      print "> "
      msg = STDIN.gets.chomp
      emsg = iov_encrypt(msg)
      @sock.write("#{emsg.last}\n")
    end while msg != 'exit'

    @sock.close
  end


  private

  def handshake
    tok = @gss.init_context
    stok = Base64.strict_encode64(tok)

    @sock.write("#{stok}\n") # send initial token
    stok = @sock.gets.chomp  # get back continuation token
    ctx = @gss.init_context(Base64.strict_decode64(stok.chomp)) # complete security context
    puts "Connection #{(ctx ? 'succeeded' : 'failed')}"
  end

  # Encrypt message
  def msg_enc(msg)
    emsg = @gss.wrap_message(msg)
    Base64.strict_encode64(emsg)
  end

end


cli = GssIovClient.new
cli.run

Version data entries

55 entries across 46 versions & 5 rubygems

Version Path
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.1.1.0 vendor/bundle/ruby/2.5.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.0.4.0 vendor/bundle/ruby/2.5.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.0.3.0 vendor/bundle/ruby/2.5.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.5.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.0.0.1 vendor/bundle/ruby/2.4.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-1.9.8.1 vendor/bundle/ruby/2.4.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-1.9.7.1 vendor/bundle/ruby/2.4.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb