about summary refs log tree commit diff stats
path: root/src/otr/otr.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-04-30 23:59:40 +0100
committerJames Booth <boothj5@gmail.com>2014-04-30 23:59:40 +0100
commita077d2008a25e5639f558c09077de5ebb8a921fd (patch)
tree71e1f747364deb1ab97b5644355410d265b62a9d /src/otr/otr.c
parenteaa19598c1fa6fdc168e6cce12c56f348c26a227 (diff)
downloadprofani-tty-a077d2008a25e5639f558c09077de5ebb8a921fd.tar.gz
Added question answer authentication (libotr 3.2.x)
Diffstat (limited to 'src/otr/otr.c')
-rw-r--r--src/otr/otr.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/otr/otr.c b/src/otr/otr.c
index 2ad8e752..043dc30f 100644
--- a/src/otr/otr.c
+++ b/src/otr/otr.c
@@ -451,6 +451,40 @@ _otr_smp_secret(const char * const recipient, const char *secret)
 }
 
 static void
+_otr_smp_question(const char * const recipient, const char *question, const char *answer)
+{
+    ConnContext *context = otrlib_context_find(user_state, recipient, jid);
+
+    if (context == NULL) {
+        return;
+    }
+
+    if (context->msgstate != OTRL_MSGSTATE_ENCRYPTED) {
+        return;
+    }
+
+    otrl_message_initiate_smp_q(user_state, &ops, NULL, context, question, (const unsigned char*)answer, strlen(answer));
+    ui_otr_authetication_waiting(recipient);
+}
+
+static 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));
+}
+
+static void
 _otr_end_session(const char * const recipient)
 {
     otrlib_end_session(user_state, recipient, jid, &ops);
@@ -560,4 +594,6 @@ otr_init_module(void)
     otr_decrypt_message = _otr_decrypt_message;
     otr_free_message = _otr_free_message;
     otr_smp_secret = _otr_smp_secret;
+    otr_smp_question = _otr_smp_question;
+    otr_smp_answer = _otr_smp_answer;
 }