[Pkg-privacy-commits] [libotr] 06/225: * README: * configure.ac: * packaging/fedora/libotr.spec: * src/version.h: Change version to 3.0.0

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:44:43 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository libotr.

commit cd547a8b49f9faad20f6e1ab1361457c7ec1e148
Author: cypherpunk <cypherpunk>
Date:   Fri Jun 24 14:57:22 2005 +0000

    	* README:
    	* configure.ac:
    	* packaging/fedora/libotr.spec:
    	* src/version.h: Change version to 3.0.0
    
    	* Protocol: Clarify that, if the user requests to see the secure
    	session id in the middle of the conversation, the value
    	displayed should be the one calculated at the time the private
    	connection was established (the last Key Exchange Message that
    	caused a rekeying), _not_ the DH secure id calculated from DH
    	keys in more recent Data Messages.
    
    	* libotr.m4: Have the version check require an exact match on
    	the major version, since, for example, source that expects
    	libotr 2.0.0 won't work with libotr 3.0.0.
    
    	* libotr.m4: Add #include <stdlib.h> to the version test so that
    	it compiles cleanly with -Wall -Werror.
    
    	* src/proto.c:
    	* src/dh.h:
    	* src/dh.c:
    	* src/context.h:
    	* src/context.c: Save the secure session id so that it can be
    	displayed to the user upon request, instead of only when the
    	private session is initially set up.
    
    	* src/privkey.c:
    	* src/context.h:
    	* src/context.c: Allow the app to set a "trust level" for
    	fingerprints.  This is an arbitrary string, intended to indicate
    	whether (or possibly by what means) the user has verified that
    	this fingerprint is accurate.
    
    	* src/context.h:
    	* src/context.c: Allow the app to set an arbitrary binary
    	"preshared secret" for the ConnContext.  This is currently
    	unused, but in the future it would allow for users to exchange a
    	secret _before_ they generate their fingerprints.  [But the
    	protocol would have to be extended to support this.]
    
    	* src/message.h:
    	* src/message.c: Remove the "confirm_fingerprint" callback
    	which requires the user to acknowledge the new fingerprint
    	before it can be used.  Replace it with a "new_fingerprint"
    	callback which merely informs the user that a new fingerprint
    	has been received.
---
 ChangeLog                    | 50 ++++++++++++++++++++++++++++++++++++++++++++
 NEWS                         | 14 +++++++++++++
 Protocol                     | 35 ++++++++++++++++++++-----------
 README                       |  8 +------
 configure.ac                 |  4 ++--
 libotr.m4                    | 17 +++++++--------
 packaging/fedora/libotr.spec |  2 +-
 src/context.c                | 37 ++++++++++++++++++++++++++++++++
 src/context.h                | 29 ++++++++++++++++++++-----
 src/dh.c                     |  4 ++--
 src/dh.h                     |  5 ++++-
 src/message.c                | 37 ++++++--------------------------
 src/message.h                | 18 +++-------------
 src/privkey.c                | 31 ++++++++++++++++++++-------
 src/privkey.h                |  5 +++--
 src/proto.c                  |  7 +++++--
 src/version.h                |  6 +++---
 17 files changed, 208 insertions(+), 101 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ec5f16b..3f463bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,53 @@
+2005-06-24
+
+	* README:
+	* configure.ac:
+	* packaging/fedora/libotr.spec:
+	* src/version.h: Change version to 3.0.0
+
+	* Protocol: Clarify that, if the user requests to see the secure
+	session id in the middle of the conversation, the value
+	displayed should be the one calculated at the time the private
+	connection was established (the last Key Exchange Message that
+	caused a rekeying), _not_ the DH secure id calculated from DH
+	keys in more recent Data Messages.
+
+	* libotr.m4: Have the version check require an exact match on
+	the major version, since, for example, source that expects
+	libotr 2.0.0 won't work with libotr 3.0.0.
+
+	* libotr.m4: Add #include <stdlib.h> to the version test so that
+	it compiles cleanly with -Wall -Werror.
+
+	* src/proto.c:
+	* src/dh.h:
+	* src/dh.c:
+	* src/context.h:
+	* src/context.c: Save the secure session id so that it can be
+	displayed to the user upon request, instead of only when the
+	private session is initially set up.
+
+	* src/privkey.c:
+	* src/context.h:
+	* src/context.c: Allow the app to set a "trust level" for
+	fingerprints.  This is an arbitrary string, intended to indicate
+	whether (or possibly by what means) the user has verified that
+	this fingerprint is accurate.
+
+	* src/context.h:
+	* src/context.c: Allow the app to set an arbitrary binary
+	"preshared secret" for the ConnContext.  This is currently
+	unused, but in the future it would allow for users to exchange a
+	secret _before_ they generate their fingerprints.  [But the
+	protocol would have to be extended to support this.]
+
+	* src/message.h:
+	* src/message.c: Remove the "confirm_fingerprint" callback
+	which requires the user to acknowledge the new fingerprint
+	before it can be used.  Replace it with a "new_fingerprint"
+	callback which merely informs the user that a new fingerprint
+	has been received.
+
 2005-05-13
 
 	* libotr.m4: Fixed a bug which made configure fail to find the
diff --git a/NEWS b/NEWS
index 0fd4081..314a967 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,17 @@
+24 Jun 2005:
+- Remove the "confirm_fingerprint" callback which requires the user to
+  acknowledge the new fingerprint before it can be used.  Replace it
+  with a "new_fingerprint" callback which merely informs the user that a
+  new fingerprint has been received.
+- Allow the app to set a "trust level" for fingerprints.  This is an
+  arbitrary string, intended to indicate whether (or possibly by what
+  means) the user has verified that this fingerprint is accurate.
+- Clarify that, if the user requests to see the secure session id in
+  the middle of the conversation, the value displayed should be the one
+  calculated at the time the private connection was established (the
+  last Key Exchange Message that caused a rekeying), _not_ the DH secure
+  id calculated from DH keys in more recent Data Messages.
+
 3 May 2005:
 - Released 2.0.2
 
diff --git a/Protocol b/Protocol
index f236882..7f4416e 100644
--- a/Protocol
+++ b/Protocol
@@ -439,7 +439,7 @@ When you receive an OTR Data message:
 
 Calculating session keys:
     Given one of our DH key pairs, and one of his DH pubkeys, we
-    calculate a session id, two AES keys, and two MAC keys as follows:
+    calculate a DH secure id, two AES keys, and two MAC keys as follows:
 
     Let (our_x, our_y) be the private and public parts of our DH
     key pair.  Let their_y be his DH pubkey.
@@ -459,18 +459,29 @@ Calculating session keys:
     who is the "high" end can change every time a new DH pubkey is
     exchanged.
 
-    Calculate the session id as the SHA-1 hash of the (5+len)-byte value
+    Calculate the DH secure id as the SHA-1 hash of the (5+len)-byte value
     composed of the byte 0x00, followed by the (4+len) bytes of
-    secbytes.  When a new private connection is established, display
-    these 8 bytes to the user as two 4-byte (big-endian) values, in C
-    "%08x" format.  If we are the "low" end of the key exchange, display
-    the first 10 bytes in bold, and the second 10 bytes in non-bold.  If
-    we are the "high" end of the key exchange, display the first 10 bytes
-    in non-bold, and the second 10 bytes in bold.  This session id can be
-    used by the parties to verify (say, over the telephone, assuming the
-    parties recognize each others' voices) that there is no
-    man-in-the-middle by having each side read his bold part to the
-    other.
+    secbytes.
+    
+    When a new private connection is established, the "secure session
+    id" for the connection is set to be the DH secure id calculated in
+    this way.
+    
+    The secure session id should be displayed as two 10-byte
+    (big-endian) values, in C "%20x" format.  If we are the "low" end of
+    the key exchange, display the first 10 bytes in bold, and the second
+    10 bytes in non-bold.  If we are the "high" end of the key exchange,
+    display the first 10 bytes in non-bold, and the second 10 bytes in
+    bold.  This session id can be used by the parties to verify (say,
+    over the telephone, assuming the parties recognize each others'
+    voices) that there is no man-in-the-middle by having each side read
+    his bold part to the other.
+
+    To be clear, if the user requests to see the secure session id in
+    the middle of the conversation, the value displayed should be the
+    one calculated at the time the private connection was established
+    (the last Key Exchange Message that caused a rekeying), _not_ the DH
+    secure id calculated from DH keys in more recent Data Messages.
 
     Now set the values of "sendbyte" and "recvbyte" according to whether
     we are the "low" or the "high" end of the key exchange:
diff --git a/README b/README
index 0be6d4f..1879d1a 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
 	      Off-the-Record Messaging Library and Toolkit
-			  v2.0.2,  3 May 2005
+			  v3.0.0, 24 Jun 2005
 
 This is a library and toolkit which implements Off-the-Record (OTR) Messaging.
 
@@ -74,12 +74,6 @@ pointer you pass to the library, and it will pass back (opaquely) to the
 UI functions when it calls them.  You can use this to keep track of
 state or any other information.
 
-NOTE: if you use automatic (stack) variables for the opdata, or if you
-use heap variables that may get free()d, be extra careful in the
-confirm_fingerprint function.  You need to make sure the opdata is not
-deallocated before the user chooses whether to accept the fingerprint or
-not.
-
 You will need to include proto.h and message.h, and you can find a list
 of the UI functions in message.h.
 
diff --git a/configure.ac b/configure.ac
index 16dc114..97300a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,8 +16,8 @@ dnl   For a backwards-incompatible API change (e.g. changing data structures):
 dnl     Change the libotr package version from a.b.c to (a+1).0.0
 dnl     Change the libotr libtool version from x:y:z to (x+1):0:0
 
-AM_INIT_AUTOMAKE(libotr, 2.0.2)
-LIBOTR_LIBTOOL_VERSION="1:2:0"
+AM_INIT_AUTOMAKE(libotr, 3.0.0)
+LIBOTR_LIBTOOL_VERSION="2:0:0"
 
 AC_SUBST(LIBOTR_LIBTOOL_VERSION)
 
diff --git a/libotr.m4 b/libotr.m4
index 97f2320..ec6d998 100644
--- a/libotr.m4
+++ b/libotr.m4
@@ -67,9 +67,8 @@ LIBOTR_LIBS="$LIBOTR_LIBS -lotr"
 LIBS="$LIBOTR_LIBS $LIBS"
 AC_MSG_RESULT($LIBOTR_LIBS)
 
-dnl Check for a working version of libasound that is of the right version.
-min_libotr_version=ifelse([$1], ,2.0.0,$1)
-AC_MSG_CHECKING(for libotr headers version >= $min_libotr_version)
+dnl Check for a working version of libotr that is of the right version.
+min_libotr_version=ifelse([$1], ,3.0.0,$1)
 no_libotr=""
     libotr_min_major_version=`echo $min_libotr_version | \
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
@@ -77,22 +76,20 @@ no_libotr=""
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
     libotr_min_sub_version=`echo $min_libotr_version | \
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
+AC_MSG_CHECKING(for libotr headers version $libotr_min_major_version.x >= $min_libotr_version)
 
 AC_LANG_SAVE
 AC_LANG_C
 AC_TRY_COMPILE([
-#include <libotr/proto.h>
+#include <stdlib.h>
 #include <libotr/version.h>
 ], [
-#  if(OTRL_VERSION_MAJOR > $libotr_min_major_version)
-  exit(0);
+#  if(OTRL_VERSION_MAJOR != $libotr_min_major_version)
+#    error not present
 #  else
-#    if(OTRL_VERSION_MAJOR < $libotr_min_major_version)
-#      error not present
-#    endif
 
 #    if(OTRL_VERSION_MINOR > $libotr_min_minor_version)
-  exit(0);
+       exit(0);
 #    else
 #      if(OTRL_VERSION_MINOR < $libotr_min_minor_version)
 #        error not present
diff --git a/packaging/fedora/libotr.spec b/packaging/fedora/libotr.spec
index 5e2411e..e6c0c5d 100644
--- a/packaging/fedora/libotr.spec
+++ b/packaging/fedora/libotr.spec
@@ -1,6 +1,6 @@
 Summary: Off-The-Record Messaging library and toolkit
 Name: libotr
-Version: 2.0.2
+Version: 3.0.0
 Release: 3%{?dist}
 License: GPL, LGPL
 Group: System Environment/Libraries
diff --git a/src/context.c b/src/context.c
index 54a93b3..8f136c2 100644
--- a/src/context.c
+++ b/src/context.c
@@ -61,7 +61,10 @@ static ConnContext * new_context(const char * user, const char * accountname,
     otrl_dh_session_blank(&(context->sesskeys[0][1]));
     otrl_dh_session_blank(&(context->sesskeys[1][0]));
     otrl_dh_session_blank(&(context->sesskeys[1][1]));
+    memset(context->sessionid, 0, 20);
     context->numsavedkeys = 0;
+    context->preshared_secret = NULL;
+    context->preshared_secret_len = 0;
     context->saved_mac_keys = NULL;
     context->generation = 0;
     context->lastsent = 0;
@@ -140,6 +143,7 @@ Fingerprint *otrl_context_find_fingerprint(ConnContext *context,
 	assert(f->fingerprint != NULL);
 	memmove(f->fingerprint, fingerprint, 20);
 	f->context = context;
+	f->trust = NULL;
 	f->next = context->fingerprint_root.next;
 	if (f->next) {
 	    f->next->tous = &(f->next);
@@ -151,6 +155,34 @@ Fingerprint *otrl_context_find_fingerprint(ConnContext *context,
     return NULL;
 }
 
+/* Set the trust level for a given fingerprint */
+void otrl_context_set_trust(Fingerprint *fprint, const char *trust)
+{
+    if (fprint == NULL) return;
+
+    free(fprint->trust);
+    fprint->trust = trust ? strdup(trust) : NULL;
+}
+
+/* Set the preshared secret for a given fingerprint.  Note that this
+ * currently only stores the secret in the ConnContext structure, but
+ * doesn't yet do anything with it. */
+void otrl_context_set_preshared_secret(ConnContext *context,
+	unsigned char *secret, size_t secret_len)
+{
+    free(context->preshared_secret);
+    context->preshared_secret = NULL;
+    context->preshared_secret_len = 0;
+
+    if (secret_len) {
+	context->preshared_secret = malloc(secret_len);
+	if (context->preshared_secret) {
+	    memmove(context->preshared_secret, secret, secret_len);
+	    context->preshared_secret_len = secret_len;
+	}
+    }
+}
+
 /* Force a context into the CONN_SETUP state (so that it only has local
  * DH keys). */
 void otrl_context_force_setup(ConnContext *context)
@@ -166,6 +198,10 @@ void otrl_context_force_setup(ConnContext *context)
     otrl_dh_session_free(&(context->sesskeys[0][1]));
     otrl_dh_session_free(&(context->sesskeys[1][0]));
     otrl_dh_session_free(&(context->sesskeys[1][1]));
+    memset(context->sessionid, 0, 20);
+    free(context->preshared_secret);
+    context->preshared_secret = NULL;
+    context->preshared_secret_len = 0;
     context->numsavedkeys = 0;
     free(context->saved_mac_keys);
     context->saved_mac_keys = NULL;
@@ -204,6 +240,7 @@ void otrl_context_forget_fingerprint(Fingerprint *fprint,
 	if (context->state != CONN_CONNECTED ||
 		context->active_fingerprint != fprint) {
 	    free(fprint->fingerprint);
+	    free(fprint->trust);
 	    *(fprint->tous) = fprint->next;
 	    if (fprint->next) {
 		fprint->next->tous = fprint->tous;
diff --git a/src/context.h b/src/context.h
index 12278f3..2dd6940 100644
--- a/src/context.h
+++ b/src/context.h
@@ -30,13 +30,17 @@ typedef enum {
 } ConnectionState;
 
 typedef struct fingerprint {
-    unsigned char *fingerprint;        /* The fingerprint, or NULL */
-    struct context *context;           /* The context to which we belong */
     struct fingerprint *next;          /* The next fingerprint in the list */
     struct fingerprint **tous;         /* A pointer to the pointer to us */
+    unsigned char *fingerprint;        /* The fingerprint, or NULL */
+    struct context *context;           /* The context to which we belong */
+    char *trust;                       /* The trust level of the fingerprint */
 } Fingerprint;
 
 typedef struct context {
+    struct context * next;             /* Linked list pointer */
+    struct context ** tous;            /* A pointer to the pointer to us */
+
     char * username;                   /* The user this context is for */
     char * accountname;                /* The username is relative to
 					  this account... */
@@ -62,6 +66,15 @@ typedef struct context {
 					  derived from DH key[our_keyid-i]
 					  and mpi Y[their_keyid-j] */
 
+    unsigned char sessionid[20];       /* The sessionid and direction */
+    SessionDirection sessiondir;       /* determined when this private
+					  connection was established. */
+
+    unsigned char *preshared_secret;   /* A secret you share with this
+					  user, in order to do
+					  authentication. */
+    size_t preshared_secret_len;       /* The length of the above secret. */
+
     /* saved mac keys to be revealed later */
     unsigned int numsavedkeys;
     unsigned char *saved_mac_keys;
@@ -87,9 +100,6 @@ typedef struct context {
     void *app_data;
     /* A function to free the above data when we forget this context */
     void (*app_data_free)(void *);
-
-    struct context * next;             /* Linked list pointer */
-    struct context ** tous;            /* A pointer to the pointer to us */
 } ConnContext;
 
 #include "userstate.h"
@@ -112,6 +122,15 @@ ConnContext * otrl_context_find(OtrlUserState us, const char *user,
 Fingerprint *otrl_context_find_fingerprint(ConnContext *context,
 	unsigned char fingerprint[20], int add_if_missing, int *addedp);
 
+/* Set the trust level for a given fingerprint */
+void otrl_context_set_trust(Fingerprint *fprint, const char *trust);
+
+/* Set the preshared secret for a given fingerprint.  Note that this
+ * currently only stores the secret in the ConnContext structure, but
+ * doesn't yet do anything with it. */
+void otrl_context_set_preshared_secret(ConnContext *context,
+	unsigned char *secret, size_t secret_len);
+
 /* Force a context into the CONN_SETUP state (so that it only has local
  * DH keys). */
 void otrl_context_force_setup(ConnContext *context);
diff --git a/src/dh.c b/src/dh.c
index 522c29f..9179440 100644
--- a/src/dh.c
+++ b/src/dh.c
@@ -135,7 +135,7 @@ gcry_error_t otrl_dh_session(DH_sesskeys *sess, DH_keypair *kp, gcry_mpi_t y)
 	return gcry_error(GPG_ERR_ENOMEM);
     }
     gabdata[0] = 0x00;
-    gcry_md_hash_buffer(GCRY_MD_SHA1, sess->sessionid, gabdata, gablen+5);
+    gcry_md_hash_buffer(GCRY_MD_SHA1, sess->dhsecureid, gabdata, gablen+5);
 
     /* Are we the "high" or "low" end of the connection? */
     if ( gcry_mpi_cmp(kp->pub, y) > 0 ) {
@@ -214,7 +214,7 @@ void otrl_dh_session_blank(DH_sesskeys *sess)
     sess->sendmac = NULL;
     sess->rcvenc = NULL;
     sess->rcvmac = NULL;
-    memset(sess->sessionid, 0, 20);
+    memset(sess->dhsecureid, 0, 20);
     memset(sess->sendctr, 0, 16);
     memset(sess->rcvctr, 0, 16);
     memset(sess->sendmackey, 0, 20);
diff --git a/src/dh.h b/src/dh.h
index a64c84b..78cba4f 100644
--- a/src/dh.h
+++ b/src/dh.h
@@ -34,7 +34,10 @@ typedef enum {
 
 typedef struct {
     SessionDirection dir;
-    unsigned char sessionid[20];
+    unsigned char dhsecureid[20];  /* Don't display this value to the
+				      user when she asks to see the
+				      secure session id.  Display
+				      context->sessionid instead. */
     unsigned char sendctr[16];
     unsigned char rcvctr[16];
     gcry_cipher_hd_t sendenc;
diff --git a/src/message.c b/src/message.c
index 6179318..61e6355 100644
--- a/src/message.c
+++ b/src/message.c
@@ -37,11 +37,6 @@
  * resending in response to a rekey? */
 #define RESEND_INTERVAL 60
 
-struct s_OTRConfirmResponse {
-    OTRKeyExchangeMsg kem;
-    ConnContext *context;
-};
-
 /* Deallocate a message allocated by other otrl_message_* routines. */
 void otrl_message_free(char *message)
 {
@@ -342,16 +337,6 @@ static int process_kem(OtrlUserState us, OtrlMessageAppOps *ops, void *opdata,
     return retval;
 }
 
-static void process_confresp(OtrlUserState us, OtrlMessageAppOps *ops,
-	void *opdata, OTRConfirmResponse *confresp, int resp)
-{
-    if (resp == 1) {
-	process_kem(us, ops, opdata, confresp->context, NULL, confresp->kem);
-    }
-    otrl_proto_free_key_exchange(confresp->kem);
-    free(confresp);
-}
-
 /* Handle a message just received from the network.  It is safe to pass
  * all received messages to this routine.  add_appdata is a function
  * that will be called in the event that a new ConnContext is created.
@@ -522,23 +507,13 @@ int otrl_message_receiving(OtrlUserState us, OtrlMessageAppOps *ops,
 			    kem->key_fingerprint, 0, NULL);
 
 		    if (!found_print) {
-			/* Warn the user about the new fingerprint */
-			OTRConfirmResponse *confresp =
-			    malloc(sizeof(OTRConfirmResponse));
-			if (confresp) {
-			    confresp->kem = kem;
-			    confresp->context = context;
-			    if (ops->confirm_fingerprint) {
-				ops->confirm_fingerprint(us, opdata,
-					accountname, protocol, sender, kem,
-					process_confresp, confresp);
-			    } else {
-				process_confresp(us, ops, opdata, confresp,
-					-1);
-			    }
-			} else {
-			    otrl_proto_free_key_exchange(kem);
+			/* Inform the user of the new fingerprint */
+			if (ops->new_fingerprint) {
+			    ops->new_fingerprint(us, opdata,
+				    accountname, protocol, sender, kem);
 			}
+			process_kem(us, ops, opdata, context, NULL, kem);
+			otrl_proto_free_key_exchange(kem);
 		    } else {
 			time_t now;
 			int rekeyed = process_kem(us, ops, opdata,
diff --git a/src/message.h b/src/message.h
index ad20361..2f19bbf 100644
--- a/src/message.h
+++ b/src/message.h
@@ -35,8 +35,6 @@ typedef enum {
 
 #define OTRL_POLICY_DEFAULT OTRL_POLICY_OPPORTUNISTIC
 
-typedef struct s_OTRConfirmResponse OTRConfirmResponse;
-
 typedef struct s_OtrlMessageAppOps {
     /* Return the OTR policy for the given context. */
     OtrlPolicy (*policy)(void *opdata, ConnContext *context);
@@ -86,20 +84,10 @@ typedef struct s_OtrlMessageAppOps {
     /* Deallocate a string allocated by protocol_name */
     void (*protocol_name_free)(void *opdata, const char *protocol_name);
 
-    /* Ask the user of the given accountname to confirm an unknown
-     * fingerprint (contained in kem) for the given username of the
-     * given protocol.  When the user has decided, call
-     * response_cb(us, ops, opdata, response_data, resp) where resp is 1
-     * to accept the fingerprint, 0 to reject it, and -1 if the user
-     * didn't make a choice (say, by destroying the dialog window).
-     * BE SURE to call response_cb no matter what happens. */
-    void (*confirm_fingerprint)(OtrlUserState us, void *opdata,
+    /* A new fingerprint for the given user has been received. */
+    void (*new_fingerprint)(OtrlUserState us, void *opdata,
 	    const char *accountname, const char *protocol,
-	    const char *username, OTRKeyExchangeMsg kem,
-	    void (*response_cb)(OtrlUserState us,
-		struct s_OtrlMessageAppOps *ops, void *opdata,
-		OTRConfirmResponse *response_data, int resp),
-	    OTRConfirmResponse *response_data);
+	    const char *username, OTRKeyExchangeMsg kem);
 
     /* The list of known fingerprints has changed.  Write them to disk. */
     void (*write_fingerprints)(void *opdata);
diff --git a/src/privkey.c b/src/privkey.c
index dc3b1d4..56133a4 100644
--- a/src/privkey.c
+++ b/src/privkey.c
@@ -363,9 +363,11 @@ gcry_error_t otrl_privkey_read_fingerprints(OtrlUserState us,
 	char *accountname;
 	char *protocol;
 	char *hex;
+	char *trust;
 	char *tab;
 	char *eol;
-	int res, i, j;
+	Fingerprint *fng;
+	int i, j;
 	/* Parse the line, which should be of the form:
 	 *    username\taccountname\tprotocol\t40_hex_nybbles\n          */
 	username = storeline;
@@ -384,10 +386,21 @@ gcry_error_t otrl_privkey_read_fingerprints(OtrlUserState us,
 	*tab = '\0';
 
 	hex = tab + 1;
-	eol = strchr(hex, '\r');
-	if (!eol) eol = strchr(hex, '\n');
-	if (!eol) continue;
-	*eol = '\0';
+	tab = strchr(hex, '\t');
+	if (!tab) {
+	    eol = strchr(hex, '\r');
+	    if (!eol) eol = strchr(hex, '\n');
+	    if (!eol) continue;
+	    *eol = '\0';
+	    trust = NULL;
+	} else {
+	    *tab = '\0';
+	    trust = tab + 1;
+	    eol = strchr(trust, '\r');
+	    if (!eol) eol = strchr(trust, '\n');
+	    if (!eol) continue;
+	    *eol = '\0';
+	}
 
 	if (strlen(hex) != 40) continue;
 	for(j=0, i=0; i<40; i+=2) {
@@ -397,7 +410,8 @@ gcry_error_t otrl_privkey_read_fingerprints(OtrlUserState us,
 	context = otrl_context_find(us, username, accountname, protocol,
 		1, NULL, add_app_data, data);
 	/* Add the fingerprint if not already there */
-	otrl_context_find_fingerprint(context, fingerprint, 1, NULL);
+	fng = otrl_context_find_fingerprint(context, fingerprint, 1, NULL);
+	otrl_context_set_trust(fng, trust);
     }
     fclose(storef);
 
@@ -425,9 +439,10 @@ gcry_error_t otrl_privkey_write_fingerprints(OtrlUserState us,
 	    int i;
 	    fprintf(storef, "%s\t%s\t%s\t", context->username,
 		    context->accountname, context->protocol);
-	    for(i=0;i<20;++i)
+	    for(i=0;i<20;++i) {
 		fprintf(storef, "%02x", fprint->fingerprint[i]);
-	    fprintf(storef, "\n");
+	    }
+	    fprintf(storef, "\t%s\n", fprint->trust ? fprint->trust : "");
 	}
     }
     fclose(storef);
diff --git a/src/privkey.h b/src/privkey.h
index 1fe0608..b0066f0 100644
--- a/src/privkey.h
+++ b/src/privkey.h
@@ -23,13 +23,14 @@
 #include <gcrypt.h>
 
 typedef struct s_PrivKey {
+    struct s_PrivKey *next;
+    struct s_PrivKey **tous;
+
     char *accountname;
     char *protocol;
     gcry_sexp_t privkey;
     unsigned char *pubkey_data;
     size_t pubkey_datalen;
-    struct s_PrivKey *next;
-    struct s_PrivKey **tous;
 } PrivKey;
 
 #include "context.h"
diff --git a/src/proto.c b/src/proto.c
index 349e101..e18f242 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -672,10 +672,10 @@ gcry_error_t otrl_proto_accept_key_exchange(OtrlUserState us,
 		if (err) return err;
 	    }
 	    if (context->their_keyid > 0 &&
-		    (kem->keyid == context->their_keyid &&
+		    ((kem->keyid == context->their_keyid &&
 			!gcry_mpi_cmp(kem->dh_pubkey, context->their_y))
 		    || (kem->keyid == (context->their_keyid - 1) &&
-			!gcry_mpi_cmp(kem->dh_pubkey, context->their_old_y))) {
+			!gcry_mpi_cmp(kem->dh_pubkey, context->their_old_y)))) {
 		/* We've already seen this key of theirs, so all is
 		 * good. */
 		break;
@@ -704,6 +704,9 @@ gcry_error_t otrl_proto_accept_key_exchange(OtrlUserState us,
 		    &(context->our_old_dh_key), context->their_y);
 	    if (err) return err;
 	    context->state = CONN_CONNECTED;
+	    memmove(context->sessionid, context->sesskeys[1][0].dhsecureid,
+		    20);
+	    context->sessiondir = context->sesskeys[1][0].dir;
 	    context->active_fingerprint = fprint;
 	    context->generation++;
 	    context->lastmessage = savedmessage;
diff --git a/src/version.h b/src/version.h
index 1096bbb..77187c1 100644
--- a/src/version.h
+++ b/src/version.h
@@ -20,10 +20,10 @@
 #ifndef __VERSION_H__
 #define __VERSION_H__
 
-#define OTRL_VERSION "2.0.2"
+#define OTRL_VERSION "3.0.0"
 
-#define OTRL_VERSION_MAJOR 2
+#define OTRL_VERSION_MAJOR 3
 #define OTRL_VERSION_MINOR 0
-#define OTRL_VERSION_SUB 2
+#define OTRL_VERSION_SUB 0
 
 #endif

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/libotr.git



More information about the Pkg-privacy-commits mailing list