/* Create a new connection context. */ static ConnContext * new_context(const char * user, const char * accountname, const char * protocol) { ConnContext * context; OtrlSMState *smstate; context = malloc(sizeof(*context)); assert(context != NULL); context->username = strdup(user); context->accountname = strdup(accountname); context->protocol = strdup(protocol); context->fragment = NULL; context->fragment_len = 0; context->fragment_n = 0; context->fragment_k = 0; context->msgstate = OTRL_MSGSTATE_PLAINTEXT; otrl_auth_new(&(context->auth)); smstate = malloc(sizeof(OtrlSMState)); assert(smstate != NULL); otrl_sm_state_new(smstate); context->smstate = smstate; context->fingerprint_root.fingerprint = NULL; context->fingerprint_root.context = context; context->fingerprint_root.next = NULL; context->fingerprint_root.tous = NULL; context->active_fingerprint = NULL; context->their_keyid = 0; context->their_y = NULL; context->their_old_y = NULL; context->our_keyid = 0; context->our_dh_key.groupid = 0; context->our_dh_key.priv = NULL; context->our_dh_key.pub = NULL; context->our_old_dh_key.groupid = 0; context->our_old_dh_key.priv = NULL; context->our_old_dh_key.pub = NULL; otrl_dh_session_blank(&(context->sesskeys[0][0])); otrl_dh_session_blank(&(context->sesskeys[0][1])); otrl_dh_session_blank(&(context->sesskeys[1][0])); otrl_dh_session_blank(&(context->sesskeys[1][1])); memset(context->sessionid, 0, 20); context->sessionid_len = 0; context->protocol_version = 0; context->numsavedkeys = 0; context->preshared_secret = NULL; context->preshared_secret_len = 0; context->saved_mac_keys = NULL; context->generation = 0; context->lastsent = 0; context->lastmessage = NULL; context->may_retransmit = 0; context->otr_offer = OFFER_NOT; context->app_data = NULL; context->app_data_free = NULL; context->next = NULL; return context; }
/* Create a new connection context. */ static ConnContext * new_context(const char * user, const char * accountname, const char * protocol) { ConnContext * context; OtrlSMState *smstate; context = malloc(sizeof(ConnContext)); assert(context != NULL); context->username = strdup(user); context->accountname = strdup(accountname); context->protocol = strdup(protocol); context->msgstate = OTRL_MSGSTATE_PLAINTEXT; otrl_auth_new(context); smstate = malloc(sizeof(OtrlSMState)); assert(smstate != NULL); otrl_sm_state_new(smstate); context->smstate = smstate; context->our_instance = 0; context->their_instance = OTRL_INSTAG_MASTER; context->fingerprint_root.fingerprint = NULL; context->fingerprint_root.context = context; context->fingerprint_root.next = NULL; context->fingerprint_root.tous = NULL; context->active_fingerprint = NULL; memset(context->sessionid, 0, 20); context->sessionid_len = 0; context->protocol_version = 0; context->otr_offer = OFFER_NOT; context->app_data = NULL; context->app_data_free = NULL; context->context_priv = otrl_context_priv_new(); assert(context->context_priv != NULL); context->next = NULL; context->m_context = context; context->recent_rcvd_child = NULL; context->recent_sent_child = NULL; context->recent_child = NULL; return context; }