Class: Win32::SSPI::EncryptedSecurityBuffer

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

Overview

SecurityBuffer for data to be encrypted

Constant Summary collapse

SECBUFFER_DATA =

Security buffer data

0x1
SECBUFFER_TOKEN =

Security token

0x2
SECBUFFER_VERSION =
0

Instance Method Summary collapse

Constructor Details

#initialize(data_buffer, sizes) ⇒ EncryptedSecurityBuffer

Returns a new instance of EncryptedSecurityBuffer.



66
67
68
69
70
71
# File 'lib/winrm/win32/sspi.rb', line 66

def initialize(data_buffer, sizes)
  @original_msg_len = data_buffer.length
  @cbSecurityTrailer = sizes.cbSecurityTrailer
  @data_buffer = data_buffer
  @security_trailer = "\0" * sizes.cbSecurityTrailer
end

Instance Method Details

#bufferObject



84
85
86
87
# File 'lib/winrm/win32/sspi.rb', line 84

def buffer
  unpack
  @buffer
end

#to_pObject



73
74
75
76
77
78
79
80
81
82
# File 'lib/winrm/win32/sspi.rb', line 73

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