void otr_smp_secret(const char *const recipient, const char *secret) { ConnContext *context = otrlib_context_find(user_state, recipient, jid); if (context == NULL) { return; } if (context->msgstate != OTRL_MSGSTATE_ENCRYPTED) { return; } // if recipient initiated SMP, send response, else initialise ProfChatWin *chatwin = wins_get_chat(recipient); if (g_hash_table_contains(smp_initiators, recipient)) { otrl_message_respond_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret)); if (chatwin) { chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_AUTH, NULL); } g_hash_table_remove(smp_initiators, context->username); } else { otrl_message_initiate_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret)); if (chatwin) { chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_AUTH_WAIT, NULL); } } }
void OtrInternal::respondSMP(ConnContext *context, TreeModelItem &item, const QString &secret, bool initiate) { if( initiate ){ context = otrl_context_find( m_userstate, item.m_item_name.toAscii(), item.m_account_name.toAscii(), item.m_protocol_name.toAscii(), 0, NULL, NULL, NULL); otrl_message_initiate_smp( m_userstate, &m_uiOps, this, context, (unsigned char*)secret.toAscii().data(), secret.toAscii().count() ); } else { otrl_message_respond_smp( m_userstate, &m_uiOps, this, context, (unsigned char*)secret.toAscii().data(), secret.toAscii().count()); } sendCustomNessage(item,tr("Authenticating contact...")); }
void otr_smp_answer(const char *const recipient, const char *answer) { ConnContext *context = otrlib_context_find(user_state, recipient, jid); if (context == NULL) { return; } if (context->msgstate != OTRL_MSGSTATE_ENCRYPTED) { return; } // if recipient initiated SMP, send response, else initialise otrl_message_respond_smp(user_state, &ops, NULL, context, (const unsigned char*)answer, strlen(answer)); }
void OtrInternal::continueSMP(const QString& account, const QString& contact, const QString& secret) { ConnContext* context = otrl_context_find(m_userstate, contact.toUtf8().constData(), account.toUtf8().constData(), OTR_PROTOCOL_STRING, #if (OTRL_VERSION_MAJOR >= 4) OTRL_INSTAG_BEST, #endif false, NULL, NULL, NULL); if (context) { QByteArray secretArray = secret.toUtf8(); const char* secretPointer = secretArray.constData(); size_t secretLength = qstrlen(secretPointer); otrl_message_respond_smp(m_userstate, &m_uiOps, this, context, reinterpret_cast<const unsigned char*>(secretPointer), secretLength); } }
static void _otr_smp_secret(const char * const recipient, const char *secret) { ConnContext *context = otrlib_context_find(user_state, recipient, jid); if (context == NULL) { return; } if (context->msgstate != OTRL_MSGSTATE_ENCRYPTED) { return; } // if recipient initiated SMP, send response, else initialise if (g_hash_table_contains(smp_initiators, recipient)) { otrl_message_respond_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret)); ui_otr_authenticating(recipient); g_hash_table_remove(smp_initiators, context->username); } else { otrl_message_initiate_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret)); ui_otr_authetication_waiting(recipient); } }
void input_send_smp_response(char *arg) { char *msg, *temp, *sn; if (conn->conn == NULL) return; printf("\n"); temp = strchr(arg, ' '); if (temp == NULL) { b_echostr_s(); printf("No message to send.\n"); return; } if (strlen(temp + 1) == 0) { b_echostr_s(); printf("No message to send.\n"); return; } msg = temp + 1; sn = malloc(temp - arg + 1); sn[temp - arg] = 0; strncpy(sn, arg, temp - arg); struct BuddyList *buddy = find_buddy(sn); if (buddy) { if (buddy->otr_context) { b_echostr_s(); printf("[OTR] Responding to %s\n", sn); otrl_message_respond_smp(userstate, &ui_ops, NULL, buddy->otr_context, msg, strlen(msg)); return; } } b_echostr_s(); printf("[OTR] No OTR context found for %s\n", sn); }
/* * Initiate or respond to SMP authentication. */ void otr_auth(SERVER_REC *irssi, const char *nick, const char *question, const char *secret) { int ret; size_t secret_len = 0; ConnContext *ctx; struct otr_peer_context *opc; assert(irssi); assert(nick); ctx = otr_find_context(irssi, nick, 0); if (!ctx) { IRSSI_NOTICE(irssi, nick, "Context for %9%s%9 not found.", nick); goto end; } opc = ctx->app_data; /* Again, code flow error. */ assert(opc); if (ctx->msgstate != OTRL_MSGSTATE_ENCRYPTED) { IRSSI_INFO(irssi, nick, "You need to establish an OTR session before you " "can authenticate."); goto end; } /* Aborting an ongoing auth */ if (ctx->smstate->nextExpected != OTRL_SMP_EXPECT1) { otr_auth_abort(irssi, nick); } /* reset trust level */ if (ctx->active_fingerprint) { ret = otrl_context_is_fingerprint_trusted(ctx->active_fingerprint); if (!ret) { otrl_context_set_trust(ctx->active_fingerprint, ""); key_write_fingerprints(user_state_global); } } /* Libotr allows empty secret. */ if (secret) { secret_len = strlen(secret); } if (opc->ask_secret) { otrl_message_respond_smp(user_state_global->otr_state, &otr_ops, irssi, ctx, (unsigned char *) secret, secret_len); otr_status_change(irssi, nick, OTR_STATUS_SMP_RESPONDED); IRSSI_NOTICE(irssi, nick, "%yResponding to authentication...%n"); } else { if (question) { otrl_message_initiate_smp_q(user_state_global->otr_state, &otr_ops, irssi, ctx, question, (unsigned char *) secret, secret_len); } else { otrl_message_initiate_smp(user_state_global->otr_state, &otr_ops, irssi, ctx, (unsigned char *) secret, secret_len); } otr_status_change(irssi, nick, OTR_STATUS_SMP_STARTED); IRSSI_NOTICE(irssi, nick, "%yInitiated authentication...%n"); } opc->ask_secret = 0; end: return; }