mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Tidied UI messages for SMP shared secret authentication
This commit is contained in:
parent
84c7fc9ae0
commit
c39c093fa5
@ -407,6 +407,7 @@ _otr_smp_secret(const char * const recipient, const char *secret)
|
||||
// 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));
|
||||
g_hash_table_remove(smp_initiators, context->username);
|
||||
} else {
|
||||
otrl_message_initiate_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret));
|
||||
}
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include <libotr/message.h>
|
||||
|
||||
#include "ui/ui.h"
|
||||
#include "otr/otr.h"
|
||||
#include "otr/otrlib.h"
|
||||
|
||||
OtrlPolicy
|
||||
otrlib_policy(void)
|
||||
@ -116,7 +118,6 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
|
||||
if (nextMsg != OTRL_SMP_EXPECT1) {
|
||||
otrl_message_abort_smp(user_state, ops, NULL, context);
|
||||
} else {
|
||||
// [get secret from user and continue SMP];
|
||||
ui_smp_recipient_initiated(context->username);
|
||||
g_hash_table_insert(smp_initiators, strdup(context->username), strdup(context->username));
|
||||
}
|
||||
@ -126,7 +127,6 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
|
||||
if (nextMsg != OTRL_SMP_EXPECT2) {
|
||||
otrl_message_abort_smp(user_state, ops, NULL, context);
|
||||
} else {
|
||||
// If we received TLV2, we will send TLV3 and expect TLV4
|
||||
context->smstate->nextExpected = OTRL_SMP_EXPECT4;
|
||||
}
|
||||
}
|
||||
@ -135,14 +135,14 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
|
||||
if (nextMsg != OTRL_SMP_EXPECT3) {
|
||||
otrl_message_abort_smp(user_state, ops, NULL, context);
|
||||
} else {
|
||||
// If we received TLV3, we will send TLV4
|
||||
// We will not expect more messages, so prepare for next SMP
|
||||
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
|
||||
// Report result to user
|
||||
if ((context->active_fingerprint->trust != NULL) && (context->active_fingerprint->trust[0] != '\0')) {
|
||||
ui_smp_successful_sender(context->username);
|
||||
ui_trust(context->username);
|
||||
otr_trust(context->username);
|
||||
} else {
|
||||
ui_smp_unsuccessful_sender(context->username);
|
||||
ui_untrust(context->username);
|
||||
otr_untrust(context->username);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -151,21 +151,22 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext
|
||||
if (nextMsg != OTRL_SMP_EXPECT4) {
|
||||
otrl_message_abort_smp(user_state, ops, NULL, context);
|
||||
} else {
|
||||
// We will not expect more messages, so prepare for next SMP
|
||||
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
|
||||
// Report result to user
|
||||
if ((context->active_fingerprint->trust != NULL) && (context->active_fingerprint->trust[0] != '\0')) {
|
||||
ui_smp_successful_receiver(context->username);
|
||||
ui_trust(context->username);
|
||||
otr_trust(context->username);
|
||||
} else {
|
||||
ui_smp_unsuccessful_receiver(context->username);
|
||||
ui_untrust(context->username);
|
||||
otr_untrust(context->username);
|
||||
}
|
||||
}
|
||||
}
|
||||
tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT);
|
||||
if (tlv) {
|
||||
// The message we are waiting for will not arrive, so reset
|
||||
// and prepare for the next SMP
|
||||
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
|
||||
ui_smp_aborted(context->username);
|
||||
ui_untrust(context->username);
|
||||
otr_untrust(context->username);
|
||||
}
|
||||
}
|
@ -791,19 +791,7 @@ _ui_smp_recipient_initiated(const char * const recipient)
|
||||
if (window == NULL) {
|
||||
return;
|
||||
} else {
|
||||
win_vprint_line(window, '!', 0, "%s initiated SMP with secret, use '/otr secret <secret>' to start a trusted session.", recipient);
|
||||
win_update_virtual(window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_smp_successful_sender(const char * const recipient)
|
||||
{
|
||||
ProfWin *window = wins_get_by_recipient(recipient);
|
||||
if (window == NULL) {
|
||||
return;
|
||||
} else {
|
||||
win_vprint_line(window, '!', 0, "SMP session started.");
|
||||
win_vprint_line(window, '!', 0, "%s wants to authenticate your identity, use '/otr secret <secret>'.", recipient);
|
||||
win_update_virtual(window);
|
||||
}
|
||||
}
|
||||
@ -815,19 +803,7 @@ _ui_smp_unsuccessful_sender(const char * const recipient)
|
||||
if (window == NULL) {
|
||||
return;
|
||||
} else {
|
||||
win_vprint_line(window, '!', 0, "SMP session failed, the secret you entered does not match the secret entered by %s.", recipient);
|
||||
win_update_virtual(window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_smp_successful_receiver(const char * const recipient)
|
||||
{
|
||||
ProfWin *window = wins_get_by_recipient(recipient);
|
||||
if (window == NULL) {
|
||||
return;
|
||||
} else {
|
||||
win_vprint_line(window, '!', 0, "SMP session started.");
|
||||
win_vprint_line(window, '!', 0, "Authentication failed, the secret you entered does not match the secret entered by %s.", recipient);
|
||||
win_update_virtual(window);
|
||||
}
|
||||
}
|
||||
@ -839,7 +815,7 @@ _ui_smp_unsuccessful_receiver(const char * const recipient)
|
||||
if (window == NULL) {
|
||||
return;
|
||||
} else {
|
||||
win_vprint_line(window, '!', 0, "SMP session failed, the secret %s entered does not match the secret you entered.", recipient);
|
||||
win_vprint_line(window, '!', 0, "Authentication failed, the secret entered by %s does not match yours.", recipient);
|
||||
win_update_virtual(window);
|
||||
}
|
||||
}
|
||||
@ -2051,9 +2027,7 @@ ui_init_module(void)
|
||||
ui_trust = _ui_trust;
|
||||
ui_untrust = _ui_untrust;
|
||||
ui_smp_recipient_initiated = _ui_smp_recipient_initiated;
|
||||
ui_smp_successful_sender = _ui_smp_successful_sender;
|
||||
ui_smp_unsuccessful_sender = _ui_smp_unsuccessful_sender;
|
||||
ui_smp_successful_receiver = _ui_smp_successful_receiver;
|
||||
ui_smp_unsuccessful_receiver = _ui_smp_unsuccessful_receiver;
|
||||
ui_smp_aborted = _ui_smp_aborted;
|
||||
ui_chat_win_contact_online = _ui_chat_win_contact_online;
|
||||
|
@ -64,9 +64,7 @@ void (*ui_gone_insecure)(const char * const recipient);
|
||||
void (*ui_trust)(const char * const recipient);
|
||||
void (*ui_untrust)(const char * const recipient);
|
||||
void (*ui_smp_recipient_initiated)(const char * const recipient);
|
||||
void (*ui_smp_successful_sender)(const char * const recipient);
|
||||
void (*ui_smp_unsuccessful_sender)(const char * const recipient);
|
||||
void (*ui_smp_successful_receiver)(const char * const recipient);
|
||||
void (*ui_smp_unsuccessful_receiver)(const char * const recipient);
|
||||
void (*ui_smp_aborted)(const char * const recipient);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user