Class: SelfCrypto::OutboundSession
- Defined in:
- ext/self_crypto/session.c
Instance Method Summary collapse
Methods inherited from Session
from_pickle, #last_error, #to_pickle, #will_receive?
Constructor Details
#initialize(account, identity, one_time_key) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'ext/self_crypto/session.c', line 37
static VALUE initialize_outbound(VALUE self, VALUE account, VALUE identity, VALUE one_time_key) {
size_t size;
OlmSession * this;
OlmAccount * a;
Data_Get_Struct(self, OlmSession, this);
Data_Get_Struct(account, OlmAccount, a);
size = self_olm_create_outbound_session_random_length(this);
if (rb_obj_is_instance_of(account, rb_eval_string("SelfCrypto::Account")) != Qtrue) {
rb_raise(rb_eTypeError, "account must be an instance of SelfCrypto::Account");
}
if (rb_obj_is_kind_of(identity, rb_eval_string("String")) != Qtrue) {
rb_raise(rb_eTypeError, "identity must be kind of String");
}
if (rb_obj_is_kind_of(one_time_key, rb_eval_string("String")) != Qtrue) {
rb_raise(rb_eTypeError, "one_time_key must be kind of String");
}
if (self_olm_create_outbound_session(
this,
a,
RSTRING_PTR(identity), RSTRING_LEN(identity),
RSTRING_PTR(one_time_key), RSTRING_LEN(one_time_key),
RSTRING_PTR(get_random(size)), size
) == -1) {
raise_olm_error(self_olm_session_last_error(this));
}
return self;
}
|