[Pkg-privacy-commits] [libotr] 52/225: * message.c: * dh.h: * dh.c: Support for applications requesting an extra session key that can be used for things like file transfers. (Almost done.)

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:44:52 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 a91b8c44182cbb41bc10c48f621ec91cab2a67dc
Author: cypherpunk <cypherpunk>
Date:   Wed Jul 2 15:53:46 2008 +0000

    	* message.c:
    	* dh.h:
    	* dh.c: Support for applications requesting an extra session key
    	that can be used for things like file transfers. (Almost done.)
---
 ChangeLog     |  2 +-
 src/message.c | 19 +++++++++++--------
 src/proto.c   | 12 ++++++++++--
 src/proto.h   |  3 ++-
 4 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index de9902d..7a362dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,7 +10,7 @@
 	* message.c:
 	* dh.h:
 	* dh.c: Support for applications requesting an extra session key
-	that can be used for things like file transfers.
+	that can be used for things like file transfers. (Almost done.)
 
 	* message.h:
 	* message.c: Applications now use the handle_smp_event callback
diff --git a/src/message.c b/src/message.c
index a0a0cd0..f06b81d 100644
--- a/src/message.c
+++ b/src/message.c
@@ -197,7 +197,7 @@ gcry_error_t otrl_message_sending(OtrlUserState us,
 	case OTRL_MSGSTATE_ENCRYPTED:
 	    /* Create the new, encrypted message */
 	    err = otrl_proto_create_data(&msgtosend, context, message, tlvs,
-		    0);
+		    0, NULL);
 	    if (!err) {
 		context->lastsent = time(NULL);
 		*messagep = msgtosend;
@@ -458,7 +458,7 @@ static void maybe_resend(EncrData *edata)
 
 	/* Re-encrypt the message with the new keys */
 	err = otrl_proto_create_data(&resendmsg,
-		edata->context, edata->context->lastmessage, NULL, 0);
+		edata->context, edata->context->lastmessage, NULL, 0, NULL);
 	if (!err) {
 	    const char *format = "<b>The last message "
 		"to %s was resent.</b>";
@@ -585,7 +585,7 @@ static void init_respond_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
 	    : OTRL_TLV_SMP2,
 	    smpmsglen, smpmsg);
     err = otrl_proto_create_data(&sendsmp, context, "", sendtlv,
-            OTRL_MSGFLAGS_IGNORE_UNREADABLE);
+            OTRL_MSGFLAGS_IGNORE_UNREADABLE, NULL);
     if (!err) {
         /*  Send it, and set the next expected message to the
 	 *  logical response */
@@ -638,7 +638,7 @@ void otrl_message_abort_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
 
     err = otrl_proto_create_data(&sendsmp,
 	    context, "", sendtlv,
-	    OTRL_MSGFLAGS_IGNORE_UNREADABLE);
+	    OTRL_MSGFLAGS_IGNORE_UNREADABLE, NULL);
     if (!err) {
 	/* Send the abort signal so our buddy knows we've stopped */
 	err = otrl_message_fragment_and_send(ops, opdata, context,
@@ -1143,7 +1143,8 @@ int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
 					nextmsglen, nextmsg);
 				err = otrl_proto_create_data(&sendsmp,
 				    context, "", sendtlv,
-				    OTRL_MSGFLAGS_IGNORE_UNREADABLE);
+				    OTRL_MSGFLAGS_IGNORE_UNREADABLE,
+				    NULL);
 				if (!err) {
 				err = otrl_message_fragment_and_send(ops,
 				    opdata, context, sendsmp,
@@ -1202,7 +1203,8 @@ int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
 					nextmsglen, nextmsg);
 				err = otrl_proto_create_data(&sendsmp,
 				    context, "", sendtlv,
-				    OTRL_MSGFLAGS_IGNORE_UNREADABLE);
+				    OTRL_MSGFLAGS_IGNORE_UNREADABLE,
+				    NULL);
 				if (!err) {
 				err = otrl_message_fragment_and_send(ops,
 				    opdata, context, sendsmp,
@@ -1319,7 +1321,8 @@ int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
 			    /* Create the heartbeat message */
 			    err = otrl_proto_create_data(&heartbeat,
 				    context, "", NULL,
-				    OTRL_MSGFLAGS_IGNORE_UNREADABLE);
+				    OTRL_MSGFLAGS_IGNORE_UNREADABLE,
+				    NULL);
 			    if (!err) {
 				/* Send it, and log a debug message */
 				if (ops->inject_message) {
@@ -1602,7 +1605,7 @@ void otrl_message_disconnect(OtrlUserState us, const OtrlMessageAppOps *ops,
 	    OtrlTLV *tlv = otrl_tlv_new(OTRL_TLV_DISCONNECTED, 0, NULL);
 
 	    err = otrl_proto_create_data(&encmsg, context, "", tlv,
-		    OTRL_MSGFLAGS_IGNORE_UNREADABLE);
+		    OTRL_MSGFLAGS_IGNORE_UNREADABLE, NULL);
 	    if (!err) {
 		ops->inject_message(opdata, accountname, protocol,
 			username, encmsg);
diff --git a/src/proto.c b/src/proto.c
index 992dda3..9d21c0e 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -360,9 +360,11 @@ OtrlMessageType otrl_proto_message_type(const char *message)
 
 /* Create an OTR Data message.  Pass the plaintext as msg, and an
  * optional chain of TLVs.  A newly-allocated string will be returned in
- * *encmessagep. */
+ * *encmessagep.  Put the current extra symmetric key into extrakey
+ * (if non-NULL). */
 gcry_error_t otrl_proto_create_data(char **encmessagep, ConnContext *context,
-	const char *msg, const OtrlTLV *tlvs, unsigned char flags)
+	const char *msg, const OtrlTLV *tlvs, unsigned char flags,
+	unsigned char *extrakey)
 {
     size_t justmsglen = strlen(msg);
     size_t msglen = justmsglen + 1 + otrl_tlv_seriallen(tlvs);
@@ -506,6 +508,12 @@ gcry_error_t otrl_proto_create_data(char **encmessagep, ConnContext *context,
 	}
     }
     gcry_free(msgdup);
+
+    /* Save a copy of the current extra key */
+    if (extrakey) {
+	memmove(extrakey, sess->extrakey, OTRL_EXTRAKEY_BYTES);
+    }
+
     return gcry_error(GPG_ERR_NO_ERROR);
 err:
     free(buf);
diff --git a/src/proto.h b/src/proto.h
index 035b4d1..4a60098 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -127,7 +127,8 @@ OtrlMessageType otrl_proto_message_type(const char *message);
  * optional chain of TLVs.  A newly-allocated string will be returned in
  * *encmessagep. */
 gcry_error_t otrl_proto_create_data(char **encmessagep, ConnContext *context,
-	const char *msg, const OtrlTLV *tlvs, unsigned char flags);
+	const char *msg, const OtrlTLV *tlvs, unsigned char flags,
+	unsigned char *extrakey);
 
 /* Extract the flags from an otherwise unreadable Data Message. */
 gcry_error_t otrl_proto_data_read_flags(const char *datamsg,

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