Method: GSSAPI::Simple#unwrap_message

Defined in:
lib/gssapi/simple.rb

#unwrap_message(msg, encrypted = true) ⇒ Object

Unwrap a message previously wrapped with gss_wrap.

Parameters:

  • msg (String)

    The message to unwrap

  • encrypted (Boolean) (defaults to: true)

    Whether or not this message was encrypted (true) or just signed (false)

Raises:



183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/gssapi/simple.rb', line 183

def unwrap_message(msg, encrypted = true)
  min_stat = FFI::MemoryPointer.new :OM_uint32
  in_buff = GSSAPI::LibGSSAPI::UnManagedGssBufferDesc.new
  in_buff.value = msg
  out_buff = GSSAPI::LibGSSAPI::ManagedGssBufferDesc.new
  conf_state = FFI::MemoryPointer.new :int
  conf_state.write_int((encrypted ? 1 : 0))
  q_op = FFI::MemoryPointer.new :OM_uint32
  q_op.write_int(0)
  maj_stat = GSSAPI::LibGSSAPI.gss_unwrap(min_stat, @context, in_buff.pointer, out_buff.pointer, conf_state, q_op)
  raise GssApiError.new(maj_stat, min_stat), "Failed to gss_unwrap message" if maj_stat != 0
  out_buff.value
end