summaryrefslogtreecommitdiff
path: root/plugins/MirOTR/libotr/src/context_priv.c
diff options
context:
space:
mode:
authorRené Schümann <white06tiger@gmail.com>2015-03-26 20:38:11 +0000
committerRené Schümann <white06tiger@gmail.com>2015-03-26 20:38:11 +0000
commit1f7e069bda342dff43e2224060f10fcb098ea62a (patch)
treea12ec12d646a4e3a7c97e062a3c8aa7730e4f6d4 /plugins/MirOTR/libotr/src/context_priv.c
parent52c68e0b3cf78f578da1754fbd6589d1936804f9 (diff)
MirOTR: major update to latest libotr 4, with OTR protocol 3 (backwards compatible to 2 and 1, 1 is disabled by default)
NOTE: doesn't build yet, just new libotr without required changes to MirOTR itself git-svn-id: http://svn.miranda-ng.org/main/trunk@12502 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirOTR/libotr/src/context_priv.c')
-rw-r--r--plugins/MirOTR/libotr/src/context_priv.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/plugins/MirOTR/libotr/src/context_priv.c b/plugins/MirOTR/libotr/src/context_priv.c
new file mode 100644
index 0000000000..47d05b9204
--- /dev/null
+++ b/plugins/MirOTR/libotr/src/context_priv.c
@@ -0,0 +1,95 @@
+/*
+ * Off-the-Record Messaging library
+ * Copyright (C) 2004-2012 Ian Goldberg, Chris Alexander, Willy Lew,
+ * Nikita Borisov
+ * <otr@cypherpunks.ca>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of version 2.1 of the GNU Lesser General
+ * Public License as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* system headers */
+#include <stdlib.h>
+#include <assert.h>
+
+/* libgcrypt headers */
+#include <gcrypt.h>
+
+/* libotr headers */
+#include "context_priv.h"
+
+/* Create a new private connection context */
+ConnContextPriv *otrl_context_priv_new()
+{
+ ConnContextPriv *context_priv;
+ context_priv = malloc(sizeof(*context_priv));
+ assert(context_priv != NULL);
+
+ context_priv->fragment = NULL;
+ context_priv->fragment_len = 0;
+ context_priv->fragment_n = 0;
+ context_priv->fragment_k = 0;
+ context_priv->numsavedkeys = 0;
+ context_priv->saved_mac_keys = NULL;
+ context_priv->generation = 0;
+ context_priv->lastsent = 0;
+ context_priv->lastmessage = NULL;
+ context_priv->lastrecv = 0;
+ context_priv->may_retransmit = 0;
+ context_priv->their_keyid = 0;
+ context_priv->their_y = NULL;
+ context_priv->their_old_y = NULL;
+ context_priv->our_keyid = 0;
+ context_priv->our_dh_key.groupid = 0;
+ context_priv->our_dh_key.priv = NULL;
+ context_priv->our_dh_key.pub = NULL;
+ context_priv->our_old_dh_key.groupid = 0;
+ context_priv->our_old_dh_key.priv = NULL;
+ context_priv->our_old_dh_key.pub = NULL;
+ otrl_dh_session_blank(&(context_priv->sesskeys[0][0]));
+ otrl_dh_session_blank(&(context_priv->sesskeys[0][1]));
+ otrl_dh_session_blank(&(context_priv->sesskeys[1][0]));
+ otrl_dh_session_blank(&(context_priv->sesskeys[1][1]));
+
+ return context_priv;
+}
+
+/* Resets the appropriate variables when a context
+ * is being force finished
+ */
+void otrl_context_priv_force_finished(ConnContextPriv *context_priv)
+{
+ free(context_priv->fragment);
+ context_priv->fragment = NULL;
+ context_priv->fragment_len = 0;
+ context_priv->fragment_n = 0;
+ context_priv->fragment_k = 0;
+ context_priv->numsavedkeys = 0;
+ free(context_priv->saved_mac_keys);
+ context_priv->saved_mac_keys = NULL;
+ gcry_free(context_priv->lastmessage);
+ context_priv->lastmessage = NULL;
+ context_priv->may_retransmit = 0;
+ context_priv->their_keyid = 0;
+ gcry_mpi_release(context_priv->their_y);
+ context_priv->their_y = NULL;
+ gcry_mpi_release(context_priv->their_old_y);
+ context_priv->their_old_y = NULL;
+ context_priv->our_keyid = 0;
+ otrl_dh_keypair_free(&(context_priv->our_dh_key));
+ otrl_dh_keypair_free(&(context_priv->our_old_dh_key));
+ otrl_dh_session_free(&(context_priv->sesskeys[0][0]));
+ otrl_dh_session_free(&(context_priv->sesskeys[0][1]));
+ otrl_dh_session_free(&(context_priv->sesskeys[1][0]));
+ otrl_dh_session_free(&(context_priv->sesskeys[1][1]));
+}