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.19.0 vendor/bundle/ruby/3.0.0/gems/gssapi-1.3.1/examples/gss_iov_client.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/gssapi-1.3.1/examples/gss_iov_client.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/gssapi-1.3.1/examples/gss_iov_client.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/gssapi-1.3.1/examples/gss_iov_client.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/gssapi-1.3.1/examples/gss_iov_client.rb
gssapi-1.3.1 examples/gss_iov_client.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/gssapi-1.3.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/gssapi-1.3.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/gssapi-1.3.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/gssapi-1.3.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/gssapi-1.3.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/gssapi-1.3.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/gssapi-1.3.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/gssapi-1.3.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/gssapi-1.3.0/examples/gss_iov_client.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb
gssapi-1.3.0 examples/gss_iov_client.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/gssapi-1.2.0/examples/gss_iov_client.rb