[Pkg-privacy-commits] [irssi-plugin-otr] 11/267: New "/otr contexts" command and now presenting fingerprints when going secure with an unauth'ed fingerprint.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:22 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch debian
in repository irssi-plugin-otr.
commit 2e28d27a46ca57888d8a0657699f3860239bd9e9
Author: Uli Meis <a.sporto+bee at gmail.com>
Date: Thu Jun 5 17:41:58 2008 +0200
New "/otr contexts" command and now presenting fingerprints when going secure with an unauth'ed fingerprint.
---
formats.txt | 1 +
otr.c | 12 ++++++++++++
otr.h | 1 +
otr_ops.c | 20 ++++++++++++++++++++
otrutil.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
5 files changed, 82 insertions(+), 2 deletions(-)
diff --git a/formats.txt b/formats.txt
index fa7121d..fb0cf63 100644
--- a/formats.txt
+++ b/formats.txt
@@ -29,6 +29,7 @@ ops_notify title: %s prim: %s sec: %s
ops_display_bug BUG() in ops_display
ops_display msg: %s
ops_sec gone %9secure%9
+ops_fpcomp Your peer is not authenticated. To make sure you're talking to the right guy you can either agree on a secret and use the authentication described in %9/otr auth%9, or use the traditional way and compare fingerprints over a secure line (e.g. telephone) and subsequently enter %9/otr trust%9. Your fingerprint is: %s. %s's fingerprint: %s
ops_insec gone %9insecure%9
ops_still_reply still %9secure%9 (is reply)
ops_still_no_reply still %9secure%9 (is not reply)
diff --git a/otr.c b/otr.c
index 0667138..4d369cb 100644
--- a/otr.c
+++ b/otr.c
@@ -148,6 +148,16 @@ static void cmd_help(const char *data, void *server, WI_ITEM_REC *item)
}
/*
+ * /otr contexts
+ */
+static void cmd_contexts(const char *data, void *server, WI_ITEM_REC *item)
+{
+ char *s = otr_contexts();
+ printtext(NULL,NULL,MSGLEVEL_CRAP,s);
+ free(s);
+}
+
+/*
* otr statusbar
*/
static void otr_statusbar(SBAR_ITEM_REC *item, int get_size_only)
@@ -189,6 +199,7 @@ void otr_init(void)
command_bind("otr auth", NULL, (SIGNAL_FUNC) cmd_auth);
command_bind("otr authabort", NULL, (SIGNAL_FUNC) cmd_authabort);
command_bind("otr help", NULL, (SIGNAL_FUNC) cmd_help);
+ command_bind("otr contexts", NULL, (SIGNAL_FUNC) cmd_contexts);
statusbar_item_register("otr", NULL, otr_statusbar);
@@ -213,6 +224,7 @@ void otr_deinit(void)
command_unbind("otr auth", (SIGNAL_FUNC) cmd_auth);
command_unbind("otr authabort", (SIGNAL_FUNC) cmd_authabort);
command_unbind("otr help", (SIGNAL_FUNC) cmd_help);
+ command_unbind("otr contexts", (SIGNAL_FUNC) cmd_contexts);
statusbar_item_unregister("otr");
diff --git a/otr.h b/otr.h
index c166c0d..fd9030f 100644
--- a/otr.h
+++ b/otr.h
@@ -100,6 +100,7 @@ ConnContext *otr_getcontext(const char *accname,const char *nick,int create,void
void otr_trust(SERVER_REC *server, char *nick);
void otr_auth(SERVER_REC *server, char *nick, const char *secret);
void otr_authabort(SERVER_REC *server, char *nick);
+char *otr_contexts();
/* key/fingerprint stuff */
diff --git a/otr_ops.c b/otr_ops.c
index eba86b0..a3805fb 100644
--- a/otr_ops.c
+++ b/otr_ops.c
@@ -20,6 +20,7 @@
#include "otr.h"
OtrlMessageAppOps otr_ops;
+extern OtrlUserState otr_state;
/*
* Policy is currently fixed as OTR lib default (meaning opportunistic).
@@ -121,8 +122,27 @@ int ops_display_msg(void *opdata, const char *accountname,
void ops_secure(void *opdata, ConnContext *context)
{
struct co_info *coi = context->app_data;
+ char * trust = context->active_fingerprint->trust ? : "";
+ char ownfp[45],peerfp[45];
+
otr_notice(coi->server,
context->username,TXT_OPS_SEC);
+ if (*trust!='\0')
+ return;
+
+ /* not authenticated.
+ * Let's print out the fingerprints for comparison */
+
+ otrl_privkey_hash_to_human(peerfp,
+ context->active_fingerprint->fingerprint);
+
+ otr_notice(coi->server,context->username,TXT_OPS_FPCOMP,
+ otrl_privkey_fingerprint(otr_state,
+ ownfp,
+ context->accountname,
+ PROTOCOLID),
+ context->username,
+ peerfp);
}
/*
diff --git a/otrutil.c b/otrutil.c
index 8f08d93..437a9a8 100644
--- a/otrutil.c
+++ b/otrutil.c
@@ -174,9 +174,55 @@ char *otr_send(SERVER_REC *server, const char *msg,const char *to)
return NULL;
}
+char *otr_contexts() {
+ ConnContext *context;
+ Fingerprint *fprint;
+ int strs = 1024,i;
+ char *str = malloc(sizeof(char)*strs), *s = str, *trust;
+ char *state;
+
+ for(context = otr_state->context_root; context;
+ context = context->next) {
+ switch (context->msgstate) {
+ case OTRL_MSGSTATE_PLAINTEXT: state = "plaintext";break;
+ case OTRL_MSGSTATE_ENCRYPTED: state = "%gencrypted%n";break;
+ case OTRL_MSGSTATE_FINISHED: state = "finished ";break;
+ }
+ s += sprintf(s,"%%9%20s%%9 %30s %s\n",context->username,
+ context->accountname,state);
+
+ for (fprint = context->fingerprint_root.next; fprint;
+ fprint = fprint->next) {
+ trust = fprint->trust ? : "";
+ s += sprintf(s, " ");
+ for(i=0;i<20;++i)
+ s += sprintf(s, "%02x",
+ fprint->fingerprint[i]);
+ if (*trust=='\0')
+ s += sprintf(s, " %%rnot "
+ "authenticated%%n\n");
+ else if (strcmp(trust,"smp")==0)
+ s += sprintf(s,
+ " %%gauthenticated%%n via "
+ "shared secret (SMP)\n");
+ else
+ s += sprintf(s,
+ " %%gauthenticated%%n"
+ "manually\n");
+
+ if ((i=s-str)>strs/2) {
+ strs *= 2;
+ str = realloc(str,strs);
+ s = str+i;
+ }
+ }
+ }
+
+ return str;
+}
+
/*
* Get the OTR status of this conversation.
- * This wouldn't be half as long if the SMP state machine would work better.
*/
int otr_getstatus(char *mynick, char *nick, char *server)
{
@@ -243,7 +289,7 @@ void otr_trust(SERVER_REC *server, char *nick)
coi = co->app_data;
coi->smp_failed = FALSE;
- otr_notice(server,nick,TXT_FP_TRUST,accname);
+ otr_notice(server,nick,TXT_FP_TRUST,nick);
}
/*
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/irssi-plugin-otr.git
More information about the Pkg-privacy-commits
mailing list