Changes in / [88de0c9:560129a]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    r88de0c9 r560129a  
    88  OTR support (cf. http://www.cypherpunks.ca/otr/)
    99 
    10   (c) 2008-2010 Sven Moritz Hallberg <pesco@khjk.org>
    11   (c) 2008 funded by stonedcoder.org
     10  2008, Sven Moritz Hallberg <pesco@khjk.org>
     11  (c) and funded by stonedcoder.org
    1212   
    1313  files used to store OTR data:
     
    158158
    159159/* combined handler for the 'otr smp' and 'otr smpq' commands */
    160 void otr_smp_or_smpq(irc_t *irc, const char *nick, const char *question,
     160void otr_initiate_smp(irc_t *irc, const char *nick, const char *question,
    161161                const char *secret);
    162162
     
    738738void cmd_otr_smp(irc_t *irc, char **args)
    739739{
    740         otr_smp_or_smpq(irc, args[1], NULL, args[2]);   /* no question */
     740        otr_initiate_smp(irc, args[1], NULL, args[2]);  /* no question */
    741741}
    742742
    743743void cmd_otr_smpq(irc_t *irc, char **args)
    744744{
    745         otr_smp_or_smpq(irc, args[1], args[2], args[3]);
     745        otr_initiate_smp(irc, args[1], args[2], args[3]);
    746746}
    747747
     
    10741074        nextMsg = context->smstate->nextExpected;
    10751075
    1076         if (context->smstate->sm_prog_state == OTRL_SMP_PROG_CHEATED) {
    1077                 irc_usermsg(irc, "smp %s: opponent violated protocol, aborting",
    1078                         u->nick);
    1079                 otrl_message_abort_smp(us, ops, u->bu->ic, context);
    1080                 otrl_sm_state_free(context->smstate);
    1081                 return;
    1082         }
    1083 
    10841076        tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1Q);
    10851077        if (tlv) {
     
    10901082                } else {
    10911083                        char *question = g_strndup((char *)tlv->data, tlv->len);
    1092                         irc_usermsg(irc, "smp: initiated by %s with question: \x02\"%s\"\x02", u->nick,
     1084                        irc_usermsg(irc, "smp: initiated by %s with question: \"%s\"", u->nick,
    10931085                                question);
    10941086                        irc_usermsg(irc, "smp: respond with \x02otr smp %s <answer>\x02",
     
    11301122                } else {
    11311123                        /* SMP3 received, otrl_message_receiving will have sent SMP4 and set fp trust */
    1132                         /* as noted above, fp trust SHOULD have been set by libotr.
    1133                          * however at least version 3.2.0 seems to forget it when
    1134                          * responding to an smp session that was initiated with SMP1Q
    1135                          * (question and answer); other cases appear to work fine.
    1136                          * as a workaround, we explicitly set it below.
    1137                          */
    1138                         if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
    1139                                 otrl_context_set_trust(context->active_fingerprint, "smp");
    1140                                 irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
     1124                        const char *trust = context->active_fingerprint->trust;
     1125                        if(!trust || trust[0]=='\0') {
     1126                                irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
    11411127                                        u->nick);
    11421128                        } else {
    1143                                 otrl_context_set_trust(context->active_fingerprint, "");
    1144                                 irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
     1129                                irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
    11451130                                        u->nick);
    11461131                        }
     
    11571142                } else {
    11581143                        /* SMP4 received, otrl_message_receiving will have set fp trust */
    1159                         if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
    1160                                 irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
     1144                        const char *trust = context->active_fingerprint->trust;
     1145                        if(!trust || trust[0]=='\0') {
     1146                                irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
    11611147                                        u->nick);
    11621148                        } else {
    1163                                 irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
     1149                                irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
    11641150                                        u->nick);
    11651151                        }
     
    11771163
    11781164/* combined handler for the 'otr smp' and 'otr smpq' commands */
    1179 void otr_smp_or_smpq(irc_t *irc, const char *nick, const char *question,
     1165void otr_initiate_smp(irc_t *irc, const char *nick, const char *question,
    11801166                const char *secret)
    11811167{
     
    12081194                otrl_sm_state_free(ctx->smstate);
    12091195        }
    1210 
     1196       
    12111197        if(question) {
    12121198                /* this was 'otr smpq', just initiate */
Note: See TracChangeset for help on using the changeset viewer.