Class: Net::NTLM::ChannelBinding

Inherits:
Object
  • Object
show all
Defined in:
lib/net/ntlm/channel_binding.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(outer_channel) ⇒ ChannelBinding

Returns a new instance of ChannelBinding.

Parameters:

  • outer_channel (OpenSSL::X509::Certificate)

    Server certificate securing the outer TLS channel



18
19
20
21
22
23
24
25
# File 'lib/net/ntlm/channel_binding.rb', line 18

def initialize(outer_channel)
  @channel = outer_channel
  @unique_prefix = 'tls-server-end-point'
  @initiator_addtype = 0
  @initiator_address_length = 0
  @acceptor_addrtype = 0
  @acceptor_address_length = 0
end

Instance Attribute Details

#acceptor_address_lengthObject (readonly)

Returns the value of attribute acceptor_address_length.



29
30
31
# File 'lib/net/ntlm/channel_binding.rb', line 29

def acceptor_address_length
  @acceptor_address_length
end

#acceptor_addrtypeObject (readonly)

Returns the value of attribute acceptor_addrtype.



28
29
30
# File 'lib/net/ntlm/channel_binding.rb', line 28

def acceptor_addrtype
  @acceptor_addrtype
end

#channelObject (readonly)

Returns the value of attribute channel.



27
28
29
# File 'lib/net/ntlm/channel_binding.rb', line 27

def channel
  @channel
end

#initiator_address_lengthObject (readonly)

Returns the value of attribute initiator_address_length.



28
29
30
# File 'lib/net/ntlm/channel_binding.rb', line 28

def initiator_address_length
  @initiator_address_length
end

#initiator_addtypeObject (readonly)

Returns the value of attribute initiator_addtype.



27
28
29
# File 'lib/net/ntlm/channel_binding.rb', line 27

def initiator_addtype
  @initiator_addtype
end

#unique_prefixObject (readonly)

Returns the value of attribute unique_prefix.



27
28
29
# File 'lib/net/ntlm/channel_binding.rb', line 27

def unique_prefix
  @unique_prefix
end

Class Method Details

.create(outer_channel) ⇒ NTLM::ChannelBinding

Creates a ChannelBinding used for Extended Protection Authentication

Parameters:

  • outer_channel (OpenSSL::X509::Certificate)

    Server certificate securing the outer TLS channel

Returns:

  • (NTLM::ChannelBinding)

    A ChannelBinding holding a token that can be embedded in a Type3 message

See Also:



12
13
14
# File 'lib/net/ntlm/channel_binding.rb', line 12

def self.create(outer_channel)
  new(outer_channel)
end

Instance Method Details

#application_dataObject



55
56
57
58
59
60
61
62
# File 'lib/net/ntlm/channel_binding.rb', line 55

def application_data
  @application_data ||= begin
    data = unique_prefix
    data << ':'
    data << channel_hash.digest
    data
  end
end

#channel_binding_tokenString

Returns a channel binding hash acceptable for use as a AV_PAIR MsvAvChannelBindings

field value as specified in the NTLM protocol

Returns:

  • (String)

    MD5 hash of gss_channel_bindings_struct



35
36
37
# File 'lib/net/ntlm/channel_binding.rb', line 35

def channel_binding_token
  @channel_binding_token ||= OpenSSL::Digest::MD5.new(gss_channel_bindings_struct).digest
end

#channel_hashObject



51
52
53
# File 'lib/net/ntlm/channel_binding.rb', line 51

def channel_hash
  @channel_hash ||= OpenSSL::Digest::SHA256.new(channel.to_der)
end

#gss_channel_bindings_structObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/net/ntlm/channel_binding.rb', line 39

def gss_channel_bindings_struct
  @gss_channel_bindings_struct ||= begin
    token = [initiator_addtype].pack('I')
    token << [initiator_address_length].pack('I')
    token << [acceptor_addrtype].pack('I')
    token << [acceptor_address_length].pack('I')
    token << [application_data.length].pack('I')
    token << application_data
    token
  end
end