Class: Win32::SSPI::DecryptedSecurityBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/winrm/win32/sspi.rb

Constant Summary collapse

SECBUFFER_DATA =

Security buffer data

0x1
SECBUFFER_TOKEN =

Security token

0x2
SECBUFFER_VERSION =
0

Instance Method Summary collapse

Constructor Details

#initialize(buffer) ⇒ DecryptedSecurityBuffer

Returns a new instance of DecryptedSecurityBuffer.



114
115
116
117
118
119
# File 'lib/winrm/win32/sspi.rb', line 114

def initialize(buffer)
  # unpack to extract the msg and token
  token_size, token_buffer, enc_buffer = buffer.unpack("L")
  @original_msg_len = buffer.length - token_size - 4
  @cbSecurityTrailer, @security_trailer, @data_buffer = buffer.unpack("La#{token_size}a#{@original_msg_len}")
end

Instance Method Details

#bufferObject



132
133
134
135
# File 'lib/winrm/win32/sspi.rb', line 132

def buffer
  unpack
  @buffer
end

#to_pObject



121
122
123
124
125
126
127
128
129
130
# File 'lib/winrm/win32/sspi.rb', line 121

def to_p
  # Assumption is that when to_p is called we are going to get a packed structure. Therefore,
  # set @unpacked back to nil so we know to unpack when accessors are next accessed.
  @unpacked = nil
  # Assignment of inner structure to variable is very important here. Without it,
  # will not be able to unpack changes to the structure. Alternative, nested unpacks,
  # does not work (i.e. @struct.unpack("LLP12")[2].unpack("LLP12") results in "no associated pointer")
  @sec_buffer = [@original_msg_len, SECBUFFER_DATA, @data_buffer, @cbSecurityTrailer, SECBUFFER_TOKEN, @security_trailer].pack("LLPLLP")
  @struct ||= [SECBUFFER_VERSION, 2, @sec_buffer].pack("LLP")
end