[Pkg-privacy-commits] [libotr] 54/225: Support for applications requesting an extra session key that can be used for things like file transfers.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:44:53 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 74464022e27ec41c006a28bfdf088ed26874fbee
Author: cypherpunk <cypherpunk>
Date: Wed Jul 2 18:32:17 2008 +0000
Support for applications requesting an extra session key
that can be used for things like file transfers.
---
ChangeLog | 2 +-
src/message.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
src/message.h | 7 +++++++
3 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 7a362dd..de9902d 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. (Almost done.)
+ that can be used for things like file transfers.
* message.h:
* message.c: Applications now use the handle_smp_event callback
diff --git a/src/message.c b/src/message.c
index 42f2a99..b2286a2 100644
--- a/src/message.c
+++ b/src/message.c
@@ -1623,3 +1623,47 @@ void otrl_message_disconnect(OtrlUserState us, const OtrlMessageAppOps *ops,
ops->update_context_list(opdata);
}
}
+
+/* Get the current extra symmetric key (of size OTRL_EXTRAKEY_BYTES
+ * bytes) and let the other side know what we're going to use it for. */
+gcry_error_t otrl_message_symkey(OtrlUserState us,
+ const OtrlMessageAppOps *ops, void *opdata, ConnContext *context,
+ unsigned int use, const unsigned char *usedata, size_t usedatalen,
+ unsigned char *symkey)
+{
+ if (!context || (usedatalen > 0 && !usedata)) {
+ return gcry_error(GPG_ERR_INV_VALUE);
+ }
+
+ if (context->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
+ context->their_keyid > 0) {
+ unsigned char *tlvdata = malloc(usedatalen+4);
+ char *encmsg = NULL;
+ gcry_error_t err;
+ OtrlTLV *tlv;
+
+ tlvdata[0] = (use >> 24) & 0xff;
+ tlvdata[1] = (use >> 16) & 0xff;
+ tlvdata[2] = (use >> 8) & 0xff;
+ tlvdata[3] = (use) & 0xff;
+ if (usedatalen > 0) {
+ memmove(tlvdata+4, usedata, usedatalen);
+ }
+
+ tlv = otrl_tlv_new(OTRL_TLV_SYMKEY, usedatalen+4, tlvdata);
+ free(tlvdata);
+
+ err = otrl_proto_create_data(&encmsg, context, "", tlv,
+ OTRL_MSGFLAGS_IGNORE_UNREADABLE, symkey);
+ if (!err && ops->inject_message) {
+ ops->inject_message(opdata, context->accountname,
+ context->protocol, context->username, encmsg);
+ }
+ free(encmsg);
+
+ return err;
+ }
+
+ /* We weren't in an encrypted session. */
+ return gcry_error(GPG_ERR_INV_VALUE);
+}
diff --git a/src/message.h b/src/message.h
index db39896..7fda2d1 100644
--- a/src/message.h
+++ b/src/message.h
@@ -233,4 +233,11 @@ void otrl_message_respond_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
void otrl_message_abort_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
void *opdata, ConnContext *context);
+/* Get the current extra symmetric key (of size OTRL_EXTRAKEY_BYTES
+ * bytes) and let the other side know what we're going to use it for. */
+gcry_error_t otrl_message_symkey(OtrlUserState us,
+ const OtrlMessageAppOps *ops, void *opdata, ConnContext *context,
+ unsigned int use, const unsigned char *usedata, size_t usedatalen,
+ unsigned char *symkey);
+
#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