[Pkg-privacy-commits] [libotr] 142/225: Imported Upstream version 3.2.0

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:45:16 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 ff6669bb9182c4268624e183483410faaccf90d3
Author: intrigeri <intrigeri at boum.org>
Date:   Tue Feb 18 20:12:54 2014 +0000

    Imported Upstream version 3.2.0
---
 ChangeLog               |  35 +++++++++++++
 Makefile.am             |   5 +-
 Makefile.in             |  58 +++++++++++++++------
 NEWS                    |   4 ++
 README                  |   6 +--
 UPGRADING               | 133 ++++++++++++++++++++++++++++--------------------
 configure               |   7 +--
 configure.ac            |   6 +--
 libotr.pc.in            |  11 ++++
 src/auth.c              |   2 +-
 src/auth.h              |   2 +-
 src/b64.c               |   2 +-
 src/b64.h               |   2 +-
 src/context.c           |   2 +-
 src/context.h           |   2 +-
 src/dh.c                |   2 +-
 src/dh.h                |   2 +-
 src/mem.c               |   2 +-
 src/mem.h               |   2 +-
 src/message.c           | 108 ++++++++++++++++++++++++++++-----------
 src/message.h           |   8 ++-
 src/privkey-t.h         |   2 +-
 src/privkey.c           |   2 +-
 src/privkey.h           |   2 +-
 src/proto.c             |   2 +-
 src/proto.h             |   2 +-
 src/serial.h            |   2 +-
 src/sm.c                |  23 ++++++++-
 src/sm.h                |  13 ++++-
 src/tlv.c               |   2 +-
 src/tlv.h               |   5 +-
 src/userstate.c         |   2 +-
 src/userstate.h         |   2 +-
 src/version.h           |   6 +--
 toolkit/ctrmode.c       |   2 +-
 toolkit/ctrmode.h       |   2 +-
 toolkit/otr_mackey.c    |   2 +-
 toolkit/otr_modify.c    |   2 +-
 toolkit/otr_parse.c     |   2 +-
 toolkit/otr_readforge.c |   2 +-
 toolkit/otr_remac.c     |   2 +-
 toolkit/otr_sesskeys.c  |   2 +-
 toolkit/parse.c         |   2 +-
 toolkit/parse.h         |   2 +-
 toolkit/readotr.c       |   2 +-
 toolkit/readotr.h       |   2 +-
 toolkit/sesskeys.c      |   2 +-
 toolkit/sesskeys.h      |   2 +-
 toolkit/sha1hmac.c      |   2 +-
 toolkit/sha1hmac.h      |   2 +-
 50 files changed, 344 insertions(+), 154 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ffea13b..a919221 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2008-06-15:
+
+	* README: Release version 3.2.0.
+
+2008-06-13:
+
+	* UPGRADING: Clarify what was new in 3.1.0, what was changed
+	in 3.2.0.
+
+2008-05-27:
+
+	* UPGRADING: Update documentation.
+
+	* README:
+	* toolkit/*.[ch]:
+	* src/*.[ch]: Update copyright dates to 2004-2008.
+
+	* src/tlv.h: Add new OTRL_TLV_SMP1Q TLV type to indicate an
+	instance of the first SMP message, with an explicit question.
+
+	* src/sm.h:
+	* src/sm.c: More carefully track the progress of the SMP using a
+	new smp_prog_state field.  Also keep track of whether Bob
+	received an explicit question from Alice using a new
+	received_question field.
+
+	* src/message.c: Handle explicit questions for the SMP.
+
+	* src/message.c: Behave better if an SMP message fails
+	verification.
+
+	* README:
+	* configure.ac:
+	* src/version.h: Update version number to 3.2.0.
+
 2007-07-26
 
 	* src/sm.c:
diff --git a/Makefile.am b/Makefile.am
index 0c40235..a8c925c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,9 @@
 SUBDIRS = src toolkit
 
-EXTRA_DIST = Protocol-v2.html UPGRADING packaging libotr.m4
+EXTRA_DIST = Protocol-v2.html UPGRADING packaging libotr.m4 libotr.pc.in
 
 aclocaldir = $(datadir)/aclocal
 aclocal_DATA = libotr.m4
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libotr.pc
diff --git a/Makefile.in b/Makefile.in
index 0184ef3..f3c832d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -38,9 +38,9 @@ build_triplet = @build@
 host_triplet = @host@
 DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
-	$(top_srcdir)/configure AUTHORS COPYING COPYING.LIB ChangeLog \
-	INSTALL NEWS config.guess config.sub depcomp install-sh \
-	ltmain.sh missing
+	$(srcdir)/libotr.pc.in $(top_srcdir)/configure AUTHORS COPYING \
+	COPYING.LIB ChangeLog INSTALL NEWS config.guess config.sub \
+	depcomp install-sh ltmain.sh missing
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
@@ -50,7 +50,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno configure.status.lineno
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = config.h
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = libotr.pc
 SOURCES =
 DIST_SOURCES =
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@@ -65,9 +65,11 @@ am__vpath_adj = case $$p in \
     *) f=$$p;; \
   esac;
 am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
-am__installdirs = "$(DESTDIR)$(aclocaldir)"
+am__installdirs = "$(DESTDIR)$(aclocaldir)" \
+	"$(DESTDIR)$(pkgconfigdir)"
 aclocalDATA_INSTALL = $(INSTALL_DATA)
-DATA = $(aclocal_DATA)
+pkgconfigDATA_INSTALL = $(INSTALL_DATA)
+DATA = $(aclocal_DATA) $(pkgconfig_DATA)
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
@@ -183,9 +185,11 @@ sharedstatedir = @sharedstatedir@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 SUBDIRS = src toolkit
-EXTRA_DIST = Protocol-v2.html UPGRADING packaging libotr.m4
+EXTRA_DIST = Protocol-v2.html UPGRADING packaging libotr.m4 libotr.pc.in
 aclocaldir = $(datadir)/aclocal
 aclocal_DATA = libotr.m4
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libotr.pc
 all: config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
@@ -240,6 +244,8 @@ $(srcdir)/config.h.in:  $(am__configure_deps)
 
 distclean-hdr:
 	-rm -f config.h stamp-h1
+libotr.pc: $(top_builddir)/config.status $(srcdir)/libotr.pc.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -267,6 +273,23 @@ uninstall-aclocalDATA:
 	  echo " rm -f '$(DESTDIR)$(aclocaldir)/$$f'"; \
 	  rm -f "$(DESTDIR)$(aclocaldir)/$$f"; \
 	done
+install-pkgconfigDATA: $(pkgconfig_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkgconfigdir)" || $(mkdir_p) "$(DESTDIR)$(pkgconfigdir)"
+	@list='$(pkgconfig_DATA)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f=$(am__strip_dir) \
+	  echo " $(pkgconfigDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgconfigdir)/$$f'"; \
+	  $(pkgconfigDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgconfigdir)/$$f"; \
+	done
+
+uninstall-pkgconfigDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkgconfig_DATA)'; for p in $$list; do \
+	  f=$(am__strip_dir) \
+	  echo " rm -f '$(DESTDIR)$(pkgconfigdir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(pkgconfigdir)/$$f"; \
+	done
 
 # This directory's subdirectories are mostly independent; you can cd
 # into them and run `make' without going through this Makefile.
@@ -403,6 +426,7 @@ distclean-tags:
 distdir: $(DISTFILES)
 	$(am__remove_distdir)
 	mkdir $(distdir)
+	$(mkdir_p) $(distdir)/.
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -546,7 +570,7 @@ check: check-recursive
 all-am: Makefile $(DATA) config.h
 installdirs: installdirs-recursive
 installdirs-am:
-	for dir in "$(DESTDIR)$(aclocaldir)"; do \
+	for dir in "$(DESTDIR)$(aclocaldir)" "$(DESTDIR)$(pkgconfigdir)"; do \
 	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
 	done
 install: install-recursive
@@ -593,7 +617,7 @@ info: info-recursive
 
 info-am:
 
-install-data-am: install-aclocalDATA
+install-data-am: install-aclocalDATA install-pkgconfigDATA
 
 install-exec-am:
 
@@ -621,7 +645,8 @@ ps: ps-recursive
 
 ps-am:
 
-uninstall-am: uninstall-aclocalDATA uninstall-info-am
+uninstall-am: uninstall-aclocalDATA uninstall-info-am \
+	uninstall-pkgconfigDATA
 
 uninstall-info: uninstall-info-recursive
 
@@ -634,12 +659,13 @@ uninstall-info: uninstall-info-recursive
 	distuninstallcheck dvi dvi-am html html-am info info-am \
 	install install-aclocalDATA install-am install-data \
 	install-data-am install-exec install-exec-am install-info \
-	install-info-am install-man install-strip installcheck \
-	installcheck-am installdirs installdirs-am maintainer-clean \
-	maintainer-clean-generic maintainer-clean-recursive \
-	mostlyclean mostlyclean-generic mostlyclean-libtool \
-	mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
-	uninstall uninstall-aclocalDATA uninstall-am uninstall-info-am
+	install-info-am install-man install-pkgconfigDATA \
+	install-strip installcheck installcheck-am installdirs \
+	installdirs-am maintainer-clean maintainer-clean-generic \
+	maintainer-clean-recursive mostlyclean mostlyclean-generic \
+	mostlyclean-libtool mostlyclean-recursive pdf pdf-am ps ps-am \
+	tags tags-recursive uninstall uninstall-aclocalDATA \
+	uninstall-am uninstall-info-am uninstall-pkgconfigDATA
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/NEWS b/NEWS
index 7b10a73..7e3363f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+27 May 2008:
+- Added support for one-way authentication using an explicit question,
+  based on the SOUPS 2008 user study.
+
 1 Aug 2007:
 - Released 3.1.0
 
diff --git a/README b/README
index 48e8d6e..0b87bcc 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
 	      Off-the-Record Messaging Library and Toolkit
-			  v3.1.0,  1 Aug 2007
+			  v3.2.0, 15 Jun 2008
 
 This is a library and toolkit which implements Off-the-Record (OTR) Messaging.
 
@@ -267,7 +267,7 @@ The Off-the-Record Messaging library (in the src directory) is
 covered by the following (LGPL) license:
 
     Off-the-Record Messaging library
-    Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+    Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
 			     <otr at cypherpunks.ca>
 
     This library is free software; you can redistribute it and/or
@@ -288,7 +288,7 @@ The Off-the-Record Messaging Toolkit (in the toolkit directory) is covered
 by the following (GPL) license:
 
     Off-the-Record Messaging Toolkit
-    Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+    Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
 		             <otr at cypherpunks.ca>
 
     This program is free software; you can redistribute it and/or modify
diff --git a/UPGRADING b/UPGRADING
index a55de4e..6ca2134 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -19,16 +19,16 @@ Table of Contents
 1. Introduction
 
 This file contains information about the changes between the 3.0.0 and
-the 3.1.0 APIs for libotr.  Note that, as a minor release, applications
-compiled against 3.0.0 will continue to work with 3.1.0.  This document
-explains how to add the new functionality in 3.1.0.
+the 3.2.0 APIs for libotr.  Note that, as a minor release, applications
+compiled against 3.0.0 will continue to work with 3.2.0.  This document
+explains how to add the new functionality in 3.2.0.
 
 2. Major Additions
 
-This section describes the new features in OTR 3.1.0 along with a short
+This section describes the new features in OTR 3.2.0 along with a short
 history or motivation for each.
 
-2.1. Fragmentation
+2.1. Fragmentation  [Added in 3.1.0]
 
 Most IM networks supported by Pidgin have fixed maximum message sizes
 (MMS) of approximately 1-3 kB.  The longer messages in the initial key
@@ -39,9 +39,9 @@ networks with low MMS values, support for fragmentation was added.
 OTR version 3.0.0 added support for recombining message fragments to
 recover the original message.  Now that users may be assumed to be able to
 handle message fragments, support for fragmenting and sending large
-messages has been added to OTR 3.1.0.
+messages has been added to OTR 3.2.0.
 
-2.2. Socialist Millionaires' Protocol
+2.2. Socialist Millionaires' Protocol  [Added in 3.1.0, revised in 3.2.0]
 
 In version 3.0.0, the only method available to authenticate a buddy was
 fingerprint verification.  However, many users who are unfamiliar with
@@ -53,7 +53,7 @@ but this is a large enough hassle that many users omit fingerprint
 verification altogether.
 
 To allow for a method of authentication that is both easier to understand
-and easier to use, OTR version 3.1.0 includes the Socialist Millionaires'
+and easier to use, OTR version 3.2.0 includes the Socialist Millionaires'
 Protocol (SMP).  SMP runs as follows: each user inputs a secret string,
 say "x" and "y".  They then exchange a series of messages which reveal
 the value of (x==y), but no additional information about the inputs.
@@ -84,7 +84,7 @@ For detailed information on how SMP works, see the paper by Boudot,
 Schoenmakers and Traore titled "A Fair and Efficient Solution to the
 Socialist Millionaires Problem" (2001), on which our solution is based.
 
-3. Required Changes
+3. Required Changes  [Added in 3.1.0]
 
 3.1. OtrlMessageAppOps Callbacks
 
@@ -142,7 +142,7 @@ released.
 Setting account_name to NULL will cause libotr to use
 ConnContext->accountname as the displayed name for an account.
 
-3.2. Using Fragmentation
+3.2. Using Fragmentation  [Added in 3.1.0]
 
 To make use of fragmentation, first make sure that the max_message_size
 callback described in 3.1.1. has been implemented.  Then, whenever you
@@ -168,7 +168,7 @@ regular message.  In order to reassemble the fragments, however, they
 must be received in order, so at most one of the latter two options
 will result in readable messages.
 
-3.3. Using SMP
+3.3. Using SMP  [Added in 3.1.0, revised in 3.2.0]
 
 Recall from section 2.2. above that SMP takes one input string from each
 user and outputs either failure or success.
@@ -216,8 +216,11 @@ SMP by sending an appropriate OTRL_TLV_SMP_ABORT (see below).
 The protocol itself consists of 4 messages passed between the two users,
 say Alice and Bob.  These messages are identified through their TLVs:
 
-OTRL_TLV_SMP1       The initial message, containing Alice's secret
-OTRL_TLV_SMP2       A response containing Bob's secret
+OTRL_TLV_SMP1       The initial message, containing a commitment to
+                      Alice's secret
+OTRL_TLV_SMP1Q      Like OTRL_TLV_SMP1, but also containing a question
+                      to display to Bob
+OTRL_TLV_SMP2       A response containing a commitment to Bob's secret
 OTRL_TLV_SMP3       The next message in the chain, from Alice to Bob
 OTRL_TLV_SMP4       The final message in the chain, from Bob to Alice
 OTRL_TLV_SMP_ABORT  Indicates an error has occurred. Will reset SMP state
@@ -247,49 +250,69 @@ like this:
     ConnContext *context = [correct context];
     NextExpectedSMP nextMsg = context->smstate->nextExpected;
 
-    tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1);
-    if (tlv) {
-        if (nextMsg != OTRL_SMP_EXPECT1)
-	    [abort SMP];
-        else {
-	    [get secret from user and continue SMP];
-        }
-    }
-    tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP2);
-    if (tlv) {
-        if (nextMsg != OTRL_SMP_EXPECT2)
-	    [abort SMP];
-        else {
-	    // If we received TLV2, we will send TLV3 and expect TLV4
-            context->smstate->nextExpected = OTRL_SMP_EXPECT4;
-        }
-    }
-    tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP3);
-    if (tlv) {
-        if (nextMsg != OTRL_SMP_EXPECT3)
-	    [abort SMP];
-        else {
-	    // If we received TLV3, we will send TLV4
-            // We will not expect more messages, so prepare for next SMP
-            context->smstate->nextExpected = OTRL_SMP_EXPECT1;
-	    // Report result to user
-        }
-    }
-    tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP4);
-    if (tlv) {
-        if (nextMsg != OTRL_SMP_EXPECT4)
-	    [abort SMP];
-        else {
-            // We will not expect more messages, so prepare for next SMP
-            context->smstate->nextExpected = OTRL_SMP_EXPECT1;
-	    // Report result to user
-        }
-    }
-    tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT);
-    if (tlv) {
-	// The message we are waiting for will not arrive, so reset
-        // and prepare for the next SMP
+    if (context->smstate->sm_prog_state == OTRL_SMP_PROG_CHEATED) {
+	otrg_plugin_abort_smp(context);
+	otrg_dialog_update_smp(context, 0.0);
 	context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+	context->smstate->sm_prog_state = OTRL_SMP_PROG_OK;
+    } else {
+	tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1Q);
+	if (tlv) {
+	    if (nextMsg != OTRL_SMP_EXPECT1)
+		[abort SMP];
+	    else {
+		char *question = (char *)tlv->data;
+		char *eoq = memchr(question, '\0', tlv->len);
+		if (eoq) {
+		    [prompt the user with question, get the response,
+			and continue SMP];
+		}
+	    }
+	}
+	tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1);
+	if (tlv) {
+	    if (nextMsg != OTRL_SMP_EXPECT1)
+		[abort SMP];
+	    else {
+		[get secret from user and continue SMP];
+	    }
+	}
+	tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP2);
+	if (tlv) {
+	    if (nextMsg != OTRL_SMP_EXPECT2)
+		[abort SMP];
+	    else {
+		// If we received TLV2, we will send TLV3 and expect TLV4
+		context->smstate->nextExpected = OTRL_SMP_EXPECT4;
+	    }
+	}
+	tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP3);
+	if (tlv) {
+	    if (nextMsg != OTRL_SMP_EXPECT3)
+		[abort SMP];
+	    else {
+		// If we received TLV3, we will send TLV4
+		// We will not expect more messages, so prepare for next SMP
+		context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+		// Report result to user
+	    }
+	}
+	tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP4);
+	if (tlv) {
+	    if (nextMsg != OTRL_SMP_EXPECT4)
+		[abort SMP];
+	    else {
+		// We will not expect more messages, so prepare for next SMP
+		context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+		// Report result to user
+	    }
+	}
+	tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT);
+	if (tlv) {
+	    // The message we are waiting for will not arrive, so reset
+	    // and prepare for the next SMP
+	    context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+	}
     }
 
 To report the result to the user after receiving OTRL_TLV_SMP3 or
diff --git a/configure b/configure
index 652ad7c..e5f2fea 100755
--- a/configure
+++ b/configure
@@ -1808,7 +1808,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE=libotr
- VERSION=3.1.0
+ VERSION=3.2.0
 
 
 cat >>confdefs.h <<_ACEOF
@@ -1938,7 +1938,7 @@ am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
 
 
 
-LIBOTR_LIBTOOL_VERSION="3:0:1"
+LIBOTR_LIBTOOL_VERSION="4:0:2"
 
 
 
@@ -18697,7 +18697,7 @@ echo "$as_me: error: libgcrypt 1.2.0 or newer is required." >&2;}
 
 
 
-                              ac_config_files="$ac_config_files Makefile src/Makefile toolkit/Makefile"
+                                        ac_config_files="$ac_config_files Makefile src/Makefile toolkit/Makefile libotr.pc"
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
@@ -19257,6 +19257,7 @@ do
   "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
   "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
   "toolkit/Makefile" ) CONFIG_FILES="$CONFIG_FILES toolkit/Makefile" ;;
+  "libotr.pc" ) CONFIG_FILES="$CONFIG_FILES libotr.pc" ;;
   "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
   "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
   *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
diff --git a/configure.ac b/configure.ac
index 1d3b44c..51d83a9 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, 3.1.0)
-LIBOTR_LIBTOOL_VERSION="3:0:1"
+AM_INIT_AUTOMAKE(libotr, 3.2.0)
+LIBOTR_LIBTOOL_VERSION="4:0:2"
 
 AC_SUBST(LIBOTR_LIBTOOL_VERSION)
 
@@ -27,5 +27,5 @@ AM_PROG_LIBTOOL
 
 AM_PATH_LIBGCRYPT(1:1.2.0,,AC_MSG_ERROR(libgcrypt 1.2.0 or newer is required.))
 
-AC_OUTPUT([Makefile src/Makefile toolkit/Makefile])
+AC_OUTPUT([Makefile src/Makefile toolkit/Makefile libotr.pc])
 
diff --git a/libotr.pc.in b/libotr.pc.in
new file mode 100644
index 0000000..9538f8e
--- /dev/null
+++ b/libotr.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libotr
+Description: Off-the-Record Messaging Library
+Version: 3.1.0
+URL: http://otr.cypherpunks.ca/
+Libs: -L${libdir} -lotr
+Cflags: -I${includedir}
diff --git a/src/auth.c b/src/auth.c
index f8916ca..a6752c3 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/auth.h b/src/auth.h
index a42c7e2..6de75dd 100644
--- a/src/auth.h
+++ b/src/auth.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/b64.c b/src/b64.c
index 4964c57..b8736da 100644
--- a/src/b64.c
+++ b/src/b64.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/b64.h b/src/b64.h
index f7a1692..34ef03f 100644
--- a/src/b64.h
+++ b/src/b64.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/context.c b/src/context.c
index 0b22f98..dd5536f 100644
--- a/src/context.c
+++ b/src/context.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/context.h b/src/context.h
index c680d33..e722c56 100644
--- a/src/context.h
+++ b/src/context.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/dh.c b/src/dh.c
index 9a4a055..610c84e 100644
--- a/src/dh.c
+++ b/src/dh.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/dh.h b/src/dh.h
index a35edbb..d68328f 100644
--- a/src/dh.h
+++ b/src/dh.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/mem.c b/src/mem.c
index b9fc384..b2a2191 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/mem.h b/src/mem.h
index caa2343..19e00cf 100644
--- a/src/mem.h
+++ b/src/mem.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/message.c b/src/message.c
index ff1da30..704bb5c 100644
--- a/src/message.c
+++ b/src/message.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
@@ -509,8 +509,8 @@ static void set_smp_trust(const OtrlMessageAppOps *ops, void *opdata,
 }
 
 static void init_respond_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
-	void *opdata, ConnContext *context, const unsigned char *secret,
-	size_t secretlen, int initiating)
+	void *opdata, ConnContext *context, const char *question,
+	const unsigned char *secret, size_t secretlen, int initiating)
 {
     unsigned char *smpmsg = NULL;
     int smpmsglen;
@@ -560,8 +560,25 @@ static void init_respond_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
 		&smpmsg, &smpmsglen);
     }
 
+    /* If we've got a question, attach it to the smpmsg */
+    if (question != NULL) {
+	size_t qlen = strlen(question);
+	unsigned char *qsmpmsg = malloc(qlen + 1 + smpmsglen);
+	if (!qsmpmsg) {
+	    free(smpmsg);
+	    return;
+	}
+	strcpy((char *)qsmpmsg, question);
+	memmove(qsmpmsg + qlen + 1, smpmsg, smpmsglen);
+	free(smpmsg);
+	smpmsg = qsmpmsg;
+	smpmsglen += qlen + 1;
+    }
+
     /* Send msg with next smp msg content */
-    sendtlv = otrl_tlv_new(initiating ? OTRL_TLV_SMP1 : OTRL_TLV_SMP2,
+    sendtlv = otrl_tlv_new(initiating ?
+	    (question != NULL ? OTRL_TLV_SMP1Q : OTRL_TLV_SMP1)
+	    : OTRL_TLV_SMP2,
 	    smpmsglen, smpmsg);
     err = otrl_proto_create_data(&sendsmp, context, "", sendtlv,
             OTRL_MSGFLAGS_IGNORE_UNREADABLE);
@@ -583,7 +600,16 @@ void otrl_message_initiate_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
 	void *opdata, ConnContext *context, const unsigned char *secret,
 	size_t secretlen)
 {
-    init_respond_smp(us, ops, opdata, context, secret, secretlen, 1);
+    init_respond_smp(us, ops, opdata, context, NULL, secret, secretlen, 1);
+}
+
+/* Initiate the Socialist Millionaires' Protocol and send a prompt
+ * question to the buddy */
+void otrl_message_initiate_smp_q(OtrlUserState us,
+	const OtrlMessageAppOps *ops, void *opdata, ConnContext *context,
+	const char *question, const unsigned char *secret, size_t secretlen)
+{
+    init_respond_smp(us, ops, opdata, context, question, secret, secretlen, 1);
 }
 
 /* Respond to a buddy initiating the Socialist Millionaires' Protocol */
@@ -591,7 +617,7 @@ void otrl_message_respond_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
 	void *opdata, ConnContext *context, const unsigned char *secret,
 	size_t secretlen)
 {
-    init_respond_smp(us, ops, opdata, context, secret, secretlen, 0);
+    init_respond_smp(us, ops, opdata, context, NULL, secret, secretlen, 0);
 }
 
 /* Abort the SMP.  Called when an unexpected SMP message breaks the
@@ -1006,12 +1032,24 @@ int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
 
                     /* If TLVs contain SMP data, process it */
 		    nextMsg = context->smstate->nextExpected;
+                    tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1Q);
+		    if (tlv && nextMsg == OTRL_SMP_EXPECT1) {
+			/* We can only do the verification half now.
+			 * We must wait for the secret to be entered
+			 * to continue. */
+			char *question = (char *)tlv->data;
+			char *qend = memchr(question, '\0', tlv->len - 1);
+			size_t qlen = qend ? (qend - question + 1) : tlv->len;
+			otrl_sm_step2a(context->smstate, tlv->data + qlen,
+				tlv->len - qlen, 1);
+                    }
                     tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1);
 		    if (tlv && nextMsg == OTRL_SMP_EXPECT1) {
 			/* We can only do the verification half now.
 			 * We must wait for the secret to be entered
 			 * to continue. */
-			otrl_sm_step2a(context->smstate, tlv->data, tlv->len);
+			otrl_sm_step2a(context->smstate, tlv->data, tlv->len,
+				0);
                     }
                     tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP2);
 		    if (tlv && nextMsg == OTRL_SMP_EXPECT2) {
@@ -1022,17 +1060,22 @@ int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
 			otrl_sm_step3(context->smstate, tlv->data, tlv->len,
 					&nextmsg, &nextmsglen);
 			
-			/* Send msg with next smp msg content */
-			sendtlv = otrl_tlv_new(OTRL_TLV_SMP3, nextmsglen,
-				nextmsg);
-			err = otrl_proto_create_data(&sendsmp,
-				context, "", sendtlv,
-				OTRL_MSGFLAGS_IGNORE_UNREADABLE);
-			if (!err) {
-			    err = otrl_message_fragment_and_send(ops, opdata, context, sendsmp, OTRL_FRAGMENT_SEND_ALL, NULL);
+			if (context->smstate->sm_prog_state !=
+				OTRL_SMP_PROG_CHEATED) {
+			    /* Send msg with next smp msg content */
+			    sendtlv = otrl_tlv_new(OTRL_TLV_SMP3, nextmsglen,
+				    nextmsg);
+			    err = otrl_proto_create_data(&sendsmp,
+				    context, "", sendtlv,
+				    OTRL_MSGFLAGS_IGNORE_UNREADABLE);
+			    if (!err) {
+				err = otrl_message_fragment_and_send(ops,
+					opdata, context, sendsmp,
+					OTRL_FRAGMENT_SEND_ALL, NULL);
+			    }
+			    free(sendsmp);
+			    otrl_tlv_free(sendtlv);
 			}
-			free(sendsmp);
-			otrl_tlv_free(sendtlv);
 			free(nextmsg);
                     }
                     tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP3);
@@ -1044,20 +1087,27 @@ int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
 			err = otrl_sm_step4(context->smstate, tlv->data,
 					tlv->len, &nextmsg, &nextmsglen);
 			/* Set trust level based on result */
-			set_smp_trust(ops, opdata, context,
-				(err == gcry_error(GPG_ERR_NO_ERROR)));
+			if (context->smstate->received_question == 0) {
+			    set_smp_trust(ops, opdata, context,
+				    (err == gcry_error(GPG_ERR_NO_ERROR)));
+			}
 			
-			/* Send msg with next smp msg content */
-			sendtlv = otrl_tlv_new(OTRL_TLV_SMP4, nextmsglen,
-				nextmsg);
-			err = otrl_proto_create_data(&sendsmp,
-				context, "", sendtlv,
-				OTRL_MSGFLAGS_IGNORE_UNREADABLE);
-			if (!err) {
-			    err = otrl_message_fragment_and_send(ops, opdata, context, sendsmp, OTRL_FRAGMENT_SEND_ALL, NULL);
+			if (context->smstate->sm_prog_state !=
+				OTRL_SMP_PROG_CHEATED) {
+			    /* Send msg with next smp msg content */
+			    sendtlv = otrl_tlv_new(OTRL_TLV_SMP4, nextmsglen,
+				    nextmsg);
+			    err = otrl_proto_create_data(&sendsmp,
+				    context, "", sendtlv,
+				    OTRL_MSGFLAGS_IGNORE_UNREADABLE);
+			    if (!err) {
+				err = otrl_message_fragment_and_send(ops,
+					opdata, context, sendsmp,
+					OTRL_FRAGMENT_SEND_ALL, NULL);
+			    }
+			    free(sendsmp);
+			    otrl_tlv_free(sendtlv);
 			}
-			free(sendsmp);
-			otrl_tlv_free(sendtlv);
 			free(nextmsg);
                     }
                     tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP4);
diff --git a/src/message.h b/src/message.h
index 9ef8e93..e658e9d 100644
--- a/src/message.h
+++ b/src/message.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
@@ -191,6 +191,12 @@ void otrl_message_initiate_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
 	void *opdata, ConnContext *context, const unsigned char *secret,
 	size_t secretlen);
 
+/* Initiate the Socialist Millionaires' Protocol and send a prompt
+ * question to the buddy */
+void otrl_message_initiate_smp_q(OtrlUserState us,
+	const OtrlMessageAppOps *ops, void *opdata, ConnContext *context,
+	const char *question, const unsigned char *secret, size_t secretlen);
+
 /* Respond to a buddy initiating the Socialist Millionaires' Protocol */
 void otrl_message_respond_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
 	void *opdata, ConnContext *context, const unsigned char *secret,
diff --git a/src/privkey-t.h b/src/privkey-t.h
index 66a1033..3421b8b 100644
--- a/src/privkey-t.h
+++ b/src/privkey-t.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/privkey.c b/src/privkey.c
index 6ae44ee..cfb7f42 100644
--- a/src/privkey.c
+++ b/src/privkey.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/privkey.h b/src/privkey.h
index 65c73ef..83e7d48 100644
--- a/src/privkey.h
+++ b/src/privkey.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/proto.c b/src/proto.c
index 844af2e..3f8c987 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/proto.h b/src/proto.h
index 4a988ba..d7b0ae6 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/serial.h b/src/serial.h
index 005b86c..edc3184 100644
--- a/src/serial.h
+++ b/src/serial.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/sm.c b/src/sm.c
index a51887a..535ae22 100644
--- a/src/sm.c
+++ b/src/sm.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
@@ -95,6 +95,8 @@ void otrl_sm_state_new(OtrlSMState *smst)
     smst->pab = NULL;
     smst->qab = NULL;
     smst->nextExpected = OTRL_SMP_EXPECT1;
+    smst->received_question = 0;
+    smst->sm_prog_state = OTRL_SMP_PROG_OK;
 }
 
 /*
@@ -115,6 +117,8 @@ void otrl_sm_state_init(OtrlSMState *smst)
     smst->q = gcry_mpi_new(SM_MOD_LEN_BITS);
     smst->pab = gcry_mpi_new(SM_MOD_LEN_BITS);
     smst->qab = gcry_mpi_new(SM_MOD_LEN_BITS);
+    smst->received_question = 0;
+    smst->sm_prog_state = OTRL_SMP_PROG_OK;
 }
 
 /*
@@ -605,6 +609,7 @@ gcry_error_t otrl_sm_step1(OtrlSMAliceState *astate,
     }
     gcry_mpi_set(astate->secret, secret_mpi);
     gcry_mpi_release(secret_mpi);
+    astate->received_question = 0;
 
     otrl_sm_msg1_init(&msg1);
 
@@ -619,13 +624,14 @@ gcry_error_t otrl_sm_step1(OtrlSMAliceState *astate,
 
     serialize_mpi_array(output, outputlen, SM_MSG1_LEN, msg1);
     otrl_sm_msg_free(&msg1, SM_MSG1_LEN);
+    astate->sm_prog_state = OTRL_SMP_PROG_OK;
     return gcry_error(GPG_ERR_NO_ERROR);
 }
 
 /* Receive the first message in SMP exchange, which was generated by
  * otrl_sm_step1.  Input is saved until the user inputs their secret
  * information.  No output. */
-gcry_error_t otrl_sm_step2a(OtrlSMBobState *bstate, const unsigned char* input, const int inputlen)
+gcry_error_t otrl_sm_step2a(OtrlSMBobState *bstate, const unsigned char* input, const int inputlen, int received_question)
 {
     gcry_mpi_t *msg1;
     gcry_error_t err;
@@ -634,6 +640,8 @@ gcry_error_t otrl_sm_step2a(OtrlSMBobState *bstate, const unsigned char* input,
     if (! bstate->g1) {
 	otrl_sm_state_init(bstate);
     }
+    bstate->received_question = received_question;
+    bstate->sm_prog_state = OTRL_SMP_PROG_CHEATED;
 
     /* Read from input to find the mpis */
     err = unserialize_mpi_array(&msg1, SM_MSG1_LEN, input, inputlen);
@@ -662,6 +670,7 @@ gcry_error_t otrl_sm_step2a(OtrlSMBobState *bstate, const unsigned char* input,
     gcry_mpi_powm(bstate->g2, msg1[0], bstate->x2, SM_MODULUS);
     gcry_mpi_powm(bstate->g3, msg1[3], bstate->x3, SM_MODULUS);
 
+    bstate->sm_prog_state = OTRL_SMP_PROG_OK;
     return gcry_error(GPG_ERR_NO_ERROR);
 }
 
@@ -739,6 +748,7 @@ gcry_error_t otrl_sm_step3(OtrlSMAliceState *astate, const unsigned char* input,
     
     *output = NULL;
     *outputlen = 0;
+    astate->sm_prog_state = OTRL_SMP_PROG_CHEATED;
     
     err = unserialize_mpi_array(&msg2, SM_MSG2_LEN, input, inputlen);
     if (err != gcry_error(GPG_ERR_NO_ERROR)) return err;
@@ -800,6 +810,7 @@ gcry_error_t otrl_sm_step3(OtrlSMAliceState *astate, const unsigned char* input,
     gcry_mpi_release(qa2);
     gcry_mpi_release(inv);
 
+    astate->sm_prog_state = OTRL_SMP_PROG_OK;
     return gcry_error(GPG_ERR_NO_ERROR);
 }
 
@@ -823,6 +834,7 @@ gcry_error_t otrl_sm_step4(OtrlSMBobState *bstate, const unsigned char* input, c
 
     *output = NULL;
     *outputlen = 0;
+    bstate->sm_prog_state = OTRL_SMP_PROG_CHEATED;
     
     if (err != gcry_error(GPG_ERR_NO_ERROR)) return err;
 
@@ -866,6 +878,9 @@ gcry_error_t otrl_sm_step4(OtrlSMBobState *bstate, const unsigned char* input, c
     gcry_mpi_release(rab);
     gcry_mpi_release(inv);
 
+    bstate->sm_prog_state = comp ? OTRL_SMP_PROG_FAILED :
+	OTRL_SMP_PROG_SUCCEEDED;
+
     if (comp)
         return gcry_error(GPG_ERR_INV_VALUE);
     else
@@ -884,6 +899,7 @@ gcry_error_t otrl_sm_step5(OtrlSMAliceState *astate, const unsigned char* input,
     gcry_mpi_t *msg4;
     gcry_error_t err;
     err = unserialize_mpi_array(&msg4, SM_MSG4_LEN, input, inputlen);
+    astate->sm_prog_state = OTRL_SMP_PROG_CHEATED;
     
     if (err != gcry_error(GPG_ERR_NO_ERROR)) return err;
 
@@ -903,6 +919,9 @@ gcry_error_t otrl_sm_step5(OtrlSMAliceState *astate, const unsigned char* input,
     gcry_mpi_release(rab);
     otrl_sm_msg_free(&msg4, SM_MSG4_LEN);
 
+    astate->sm_prog_state = comp ? OTRL_SMP_PROG_FAILED :
+	OTRL_SMP_PROG_SUCCEEDED;
+
     if (comp)
         return gcry_error(GPG_ERR_INV_VALUE);
     else
diff --git a/src/sm.h b/src/sm.h
index 10737c6..2e94f07 100644
--- a/src/sm.h
+++ b/src/sm.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
@@ -33,9 +33,18 @@ typedef enum {
     OTRL_SMP_EXPECT5
 } NextExpectedSMP;
 
+typedef enum {
+    OTRL_SMP_PROG_OK = 0,            /* All is going fine so far */
+    OTRL_SMP_PROG_CHEATED = -2,      /* Some verification failed */
+    OTRL_SMP_PROG_FAILED = -1,       /* The secrets didn't match */
+    OTRL_SMP_PROG_SUCCEEDED = 1      /* The SMP completed successfully */
+} OtrlSMProgState;
+
 typedef struct {
     gcry_mpi_t secret, x2, x3, g1, g2, g3, g3o, p, q, pab, qab;
     NextExpectedSMP nextExpected;
+    int received_question;  /* 1 if we received a question in an SMP1Q TLV */
+    OtrlSMProgState sm_prog_state;
 } OtrlSMState;
 
 typedef OtrlSMState OtrlSMAliceState;
@@ -65,7 +74,7 @@ void otrl_sm_state_init(OtrlSMState *smst);
 void otrl_sm_state_free(OtrlSMState *smst);
 
 gcry_error_t otrl_sm_step1(OtrlSMAliceState *astate, const unsigned char* secret, int secretlen, unsigned char** output, int* outputlen);
-gcry_error_t otrl_sm_step2a(OtrlSMBobState *bstate, const unsigned char* input, const int inputlen);
+gcry_error_t otrl_sm_step2a(OtrlSMBobState *bstate, const unsigned char* input, const int inputlen, int received_question);
 gcry_error_t otrl_sm_step2b(OtrlSMBobState *bstate, const unsigned char* secret, int secretlen, unsigned char **output, int* outputlen);
 gcry_error_t otrl_sm_step3(OtrlSMAliceState *astate, const unsigned char* input, const int inputlen, unsigned char **output, int* outputlen);
 gcry_error_t otrl_sm_step4(OtrlSMBobState *bstate, const unsigned char* input, const int inputlen, unsigned char **output, int* outputlen);
diff --git a/src/tlv.c b/src/tlv.c
index efa280e..0cea7b5 100644
--- a/src/tlv.c
+++ b/src/tlv.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/tlv.h b/src/tlv.h
index a378b9d..affe0d5 100644
--- a/src/tlv.h
+++ b/src/tlv.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
@@ -41,6 +41,9 @@ typedef struct s_OtrlTLV {
 #define OTRL_TLV_SMP3            0x0004
 #define OTRL_TLV_SMP4            0x0005
 #define OTRL_TLV_SMP_ABORT       0x0006
+/* Like OTRL_TLV_SMP1, but there's a question for the buddy at the
+ * beginning */
+#define OTRL_TLV_SMP1Q           0x0007
 
 /* Make a single TLV, copying the supplied data */
 OtrlTLV *otrl_tlv_new(unsigned short type, unsigned short len,
diff --git a/src/userstate.c b/src/userstate.c
index df9e191..6de95b8 100644
--- a/src/userstate.c
+++ b/src/userstate.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/userstate.h b/src/userstate.h
index 157005d..8525df0 100644
--- a/src/userstate.h
+++ b/src/userstate.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
diff --git a/src/version.h b/src/version.h
index 01b4f38..11cb586 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging library
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This library is free software; you can redistribute it and/or
@@ -20,10 +20,10 @@
 #ifndef __VERSION_H__
 #define __VERSION_H__
 
-#define OTRL_VERSION "3.1.0"
+#define OTRL_VERSION "3.2.0"
 
 #define OTRL_VERSION_MAJOR 3
-#define OTRL_VERSION_MINOR 1
+#define OTRL_VERSION_MINOR 2
 #define OTRL_VERSION_SUB 0
 
 #endif
diff --git a/toolkit/ctrmode.c b/toolkit/ctrmode.c
index 9c79e04..f89cfbd 100644
--- a/toolkit/ctrmode.c
+++ b/toolkit/ctrmode.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/ctrmode.h b/toolkit/ctrmode.h
index a7a8303..a1e049e 100644
--- a/toolkit/ctrmode.h
+++ b/toolkit/ctrmode.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/otr_mackey.c b/toolkit/otr_mackey.c
index bb79e30..214d59b 100644
--- a/toolkit/otr_mackey.c
+++ b/toolkit/otr_mackey.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/otr_modify.c b/toolkit/otr_modify.c
index 2ac225c..c6d045f 100644
--- a/toolkit/otr_modify.c
+++ b/toolkit/otr_modify.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/otr_parse.c b/toolkit/otr_parse.c
index 348282f..f3bcee4 100644
--- a/toolkit/otr_parse.c
+++ b/toolkit/otr_parse.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/otr_readforge.c b/toolkit/otr_readforge.c
index 1eae299..203001c 100644
--- a/toolkit/otr_readforge.c
+++ b/toolkit/otr_readforge.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/otr_remac.c b/toolkit/otr_remac.c
index 0d4c457..4ae04fc 100644
--- a/toolkit/otr_remac.c
+++ b/toolkit/otr_remac.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/otr_sesskeys.c b/toolkit/otr_sesskeys.c
index 656e791..5c5583f 100644
--- a/toolkit/otr_sesskeys.c
+++ b/toolkit/otr_sesskeys.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/parse.c b/toolkit/parse.c
index f048530..5f357fc 100644
--- a/toolkit/parse.c
+++ b/toolkit/parse.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/parse.h b/toolkit/parse.h
index 171888e..f98cb6a 100644
--- a/toolkit/parse.h
+++ b/toolkit/parse.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/readotr.c b/toolkit/readotr.c
index f6ff00b..04e9fca 100644
--- a/toolkit/readotr.c
+++ b/toolkit/readotr.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/readotr.h b/toolkit/readotr.h
index 90144b8..75a7e2f 100644
--- a/toolkit/readotr.h
+++ b/toolkit/readotr.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/sesskeys.c b/toolkit/sesskeys.c
index d41b77a..d823ebc 100644
--- a/toolkit/sesskeys.c
+++ b/toolkit/sesskeys.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/sesskeys.h b/toolkit/sesskeys.h
index 0a09e45..7a98ac8 100644
--- a/toolkit/sesskeys.h
+++ b/toolkit/sesskeys.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/sha1hmac.c b/toolkit/sha1hmac.c
index ec54b3e..272a4fb 100644
--- a/toolkit/sha1hmac.c
+++ b/toolkit/sha1hmac.c
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify
diff --git a/toolkit/sha1hmac.h b/toolkit/sha1hmac.h
index ce44487..ad5159a 100644
--- a/toolkit/sha1hmac.h
+++ b/toolkit/sha1hmac.h
@@ -1,6 +1,6 @@
 /*
  *  Off-the-Record Messaging Toolkit
- *  Copyright (C) 2004-2007  Ian Goldberg, Chris Alexander, Nikita Borisov
+ *  Copyright (C) 2004-2008  Ian Goldberg, Chris Alexander, Nikita Borisov
  *                           <otr at cypherpunks.ca>
  *
  *  This program is free software; you can redistribute it and/or modify

-- 
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