Method: Themis::Ssession#initialize

Defined in:
lib/rbthemis.rb

#initialize(id, private_key, transport) ⇒ Ssession

Returns a new instance of Ssession.

Raises:


304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/rbthemis.rb', line 304

def initialize(id, private_key, transport)
  id_buf, id_length = string_to_pointer_size(id)
  private_key_buf, private_key_length = string_to_pointer_size(private_key)

  @callbacks = CallbacksStruct.new
  @callbacks[:get_pub_key_for_id] = GetPubKeyByIDCallback

  MAPPING[transport.object_id] = transport
  @transport_obj_id = transport.object_id

  @callbacks[:user_data] = FFI::MemoryPointer.new(:uint64)
  @callbacks[:user_data].write_uint64(@transport_obj_id)

  @session = secure_session_create(
    id_buf, id_length, private_key_buf, private_key_length, @callbacks)

  raise ThemisError, 'Secure Session failed creating' if @session.null?
end