From 2bc19f4669f820ff952a9d1b02055e93891d99b4 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 27 Apr 2014 01:17:38 +0100 Subject: [PATCH] Added SMP secret authentication success message --- src/command/commands.c | 1 - src/otr/otr.c | 4 ++++ src/otr/otrlibv3.c | 2 ++ src/ui/core.c | 32 ++++++++++++++++++++++++++++++++ src/ui/ui.h | 1 + 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/command/commands.c b/src/command/commands.c index 3b066cf7..75f3c793 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2801,7 +2801,6 @@ cmd_otr(gchar **args, struct cmd_help_t help) } else { char *recipient = ui_current_recipient(); otr_smp_secret(recipient, secret); - ui_current_print_formatted_line('!', 0, "OTR secret entered"); } } return TRUE; diff --git a/src/otr/otr.c b/src/otr/otr.c index e246748b..fe87eed8 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -407,9 +407,13 @@ _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)); + ui_current_print_formatted_line('!', 0, "Authenticating %s...", recipient); + ui_current_page_off(); 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_current_print_formatted_line('!', 0, "Awaiting authentication from %s...", recipient); + ui_current_page_off(); } } diff --git a/src/otr/otrlibv3.c b/src/otr/otrlibv3.c index ce5a2f95..bfd25a5f 100644 --- a/src/otr/otrlibv3.c +++ b/src/otr/otrlibv3.c @@ -137,6 +137,7 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext } else { context->smstate->nextExpected = OTRL_SMP_EXPECT1; if ((context->active_fingerprint->trust != NULL) && (context->active_fingerprint->trust[0] != '\0')) { + ui_smp_successful(context->username); ui_trust(context->username); otr_trust(context->username); } else { @@ -153,6 +154,7 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext } else { context->smstate->nextExpected = OTRL_SMP_EXPECT1; if ((context->active_fingerprint->trust != NULL) && (context->active_fingerprint->trust[0] != '\0')) { + ui_smp_successful(context->username); ui_trust(context->username); otr_trust(context->username); } else { diff --git a/src/ui/core.c b/src/ui/core.c index 5c7343e9..400f8a7f 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -767,6 +767,7 @@ _ui_gone_secure(const char * const recipient, gboolean trusted) title_bar_set_recipient(recipient_str->str); g_string_free(recipient_str, TRUE); win_update_virtual(window); + ui_current_page_off(); } else { int num = wins_get_num(window); status_bar_new(num); @@ -793,6 +794,9 @@ _ui_smp_recipient_initiated(const char * const recipient) } else { win_vprint_line(window, '!', 0, "%s wants to authenticate your identity, use '/otr secret '.", recipient); win_update_virtual(window); + if (wins_is_current(window)) { + ui_current_page_off(); + } } } @@ -805,6 +809,9 @@ _ui_smp_unsuccessful_sender(const char * const recipient) } else { win_vprint_line(window, '!', 0, "Authentication failed, the secret you entered does not match the secret entered by %s.", recipient); win_update_virtual(window); + if (wins_is_current(window)) { + ui_current_page_off(); + } } } @@ -817,6 +824,9 @@ _ui_smp_unsuccessful_receiver(const char * const recipient) } else { win_vprint_line(window, '!', 0, "Authentication failed, the secret entered by %s does not match yours.", recipient); win_update_virtual(window); + if (wins_is_current(window)) { + ui_current_page_off(); + } } } @@ -829,6 +839,24 @@ _ui_smp_aborted(const char * const recipient) } else { win_vprint_line(window, '!', 0, "SMP session aborted."); win_update_virtual(window); + if (wins_is_current(window)) { + ui_current_page_off(); + } + } +} + +static void +_ui_smp_successful(const char * const recipient) +{ + ProfWin *window = wins_get_by_recipient(recipient); + if (window == NULL) { + return; + } else { + win_vprint_line(window, '!', 0, "Authentication successful."); + win_update_virtual(window); + if (wins_is_current(window)) { + ui_current_page_off(); + } } } @@ -846,6 +874,7 @@ _ui_gone_insecure(const char * const recipient) title_bar_set_recipient(recipient_str->str); g_string_free(recipient_str, TRUE); win_update_virtual(window); + ui_current_page_off(); } } } @@ -864,6 +893,7 @@ _ui_trust(const char * const recipient) title_bar_set_recipient(recipient_str->str); g_string_free(recipient_str, TRUE); win_update_virtual(window); + ui_current_page_off(); } } } @@ -882,6 +912,7 @@ _ui_untrust(const char * const recipient) title_bar_set_recipient(recipient_str->str); g_string_free(recipient_str, TRUE); win_update_virtual(window); + ui_current_page_off(); } } } @@ -2027,6 +2058,7 @@ ui_init_module(void) ui_trust = _ui_trust; ui_untrust = _ui_untrust; ui_smp_recipient_initiated = _ui_smp_recipient_initiated; + ui_smp_successful = _ui_smp_successful; ui_smp_unsuccessful_sender = _ui_smp_unsuccessful_sender; ui_smp_unsuccessful_receiver = _ui_smp_unsuccessful_receiver; ui_smp_aborted = _ui_smp_aborted; diff --git a/src/ui/ui.h b/src/ui/ui.h index 4aff8d4d..6853e0c7 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -64,6 +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)(const char * const recipient); void (*ui_smp_unsuccessful_sender)(const char * const recipient); void (*ui_smp_unsuccessful_receiver)(const char * const recipient); void (*ui_smp_aborted)(const char * const recipient);