update to 3.1.0 from Sebastien Carlier
ok steven@
This commit is contained in:
parent
1a7379bab8
commit
64ca3c8ae0
@ -1,18 +1,17 @@
|
||||
# $OpenBSD: Makefile,v 1.8 2007/09/15 23:29:58 merdely Exp $
|
||||
# $OpenBSD: Makefile,v 1.9 2007/11/29 14:05:48 okan Exp $
|
||||
# $FreeBSD: Makefile,v 1.2 2005/04/21 14:22:54 pav Exp $
|
||||
|
||||
COMMENT= The portable OTR Messaging Library and toolkit
|
||||
|
||||
DISTNAME= libotr-3.0.0
|
||||
PKGNAME= ${DISTNAME}p0
|
||||
DISTNAME= libotr-3.1.0
|
||||
CATEGORIES= security
|
||||
SHARED_LIBS= otr 3.0
|
||||
LIBotr_ALIAS= realotr
|
||||
SHARED_LIBS= otr 3.1
|
||||
|
||||
HOMEPAGE= http://www.cypherpunks.ca/otr/
|
||||
|
||||
MASTER_SITES= ${HOMEPAGE}
|
||||
|
||||
# GPLv2
|
||||
PERMIT_PACKAGE_CDROM= Yes
|
||||
PERMIT_PACKAGE_FTP= Yes
|
||||
PERMIT_DISTFILES_CDROM= Yes
|
||||
@ -27,12 +26,4 @@ CONFIGURE_STYLE= gnu
|
||||
CONFIGURE_ARGS= ${CONFIGURE_SHARED}
|
||||
USE_LIBTOOL= Yes
|
||||
|
||||
MAN1= otr_toolkit.1
|
||||
MLINKS= otr_toolkit.1 otr_parse.1 \
|
||||
otr_toolkit.1 otr_sesskeys.1 \
|
||||
otr_toolkit.1 otr_mackey.1 \
|
||||
otr_toolkit.1 otr_readforge.1 \
|
||||
otr_toolkit.1 otr_modify.1 \
|
||||
otr_toolkit.1 otr_remac.1
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
@ -1,5 +1,5 @@
|
||||
MD5 (libotr-3.0.0.tar.gz) = EXrqLH3msgjr7WYgRfRvPg==
|
||||
RMD160 (libotr-3.0.0.tar.gz) = BFdKRo0JayOtY+4CZJjr5rKiPKE=
|
||||
SHA1 (libotr-3.0.0.tar.gz) = WDWs34BUnRiVqEIkX5nFWbW51s0=
|
||||
SHA256 (libotr-3.0.0.tar.gz) = CFs72z7wTuKlnNhT/w8sMaR1h7ztFXrT8DldJL7Ww7A=
|
||||
SIZE (libotr-3.0.0.tar.gz) = 392431
|
||||
MD5 (libotr-3.1.0.tar.gz) = YmailmzJ4AgirdMXWwt3zw==
|
||||
RMD160 (libotr-3.1.0.tar.gz) = ig4aT4SqK1B3Pt2va3RhU2hCaCo=
|
||||
SHA1 (libotr-3.1.0.tar.gz) = v4uOmrb3ba8IOA63MqwCyNpAUNg=
|
||||
SHA256 (libotr-3.1.0.tar.gz) = chVgu6Iex+VMdZJd4m/ntZ7Nr5ybgWE6BSo9hrctfvQ=
|
||||
SIZE (libotr-3.1.0.tar.gz) = 428444
|
||||
|
@ -1,12 +0,0 @@
|
||||
$OpenBSD: patch-src_Makefile_in,v 1.1 2005/12/25 15:52:38 sturm Exp $
|
||||
--- src/Makefile.in.orig Sun Dec 25 12:23:53 2005
|
||||
+++ src/Makefile.in Sun Dec 25 12:24:36 2005
|
||||
@@ -181,7 +181,7 @@ lib_LTLIBRARIES = libotr.la
|
||||
libotr_la_SOURCES = privkey.c context.c proto.c b64.c dh.c mem.c message.c \
|
||||
userstate.c tlv.c auth.c
|
||||
|
||||
-libotr_la_LDFLAGS = -version-info @LIBOTR_LIBTOOL_VERSION@ @LIBS@ @LIBGCRYPT_LIBS@
|
||||
+libotr_la_LDFLAGS = $(librealotr_la_LDFLAGS) @LIBS@ @LIBGCRYPT_LIBS@
|
||||
otrincdir = $(includedir)/libotr
|
||||
otrinc_HEADERS = b64.h context.h dh.h mem.h message.h privkey.h proto.h \
|
||||
version.h userstate.h tlv.h serial.h auth.h privkey-t.h
|
@ -1,12 +0,0 @@
|
||||
$OpenBSD: patch-src_auth_c,v 1.1 2006/10/31 19:54:22 alek Exp $
|
||||
--- src/auth.c.orig Sun Oct 30 22:01:15 2005
|
||||
+++ src/auth.c Sun Oct 29 00:31:54 2006
|
||||
@@ -1188,7 +1188,7 @@ gcry_error_t otrl_auth_handle_v1_key_exc
|
||||
unsigned char *buf = NULL, *bufp = NULL;
|
||||
unsigned char *fingerprintstart, *fingerprintend;
|
||||
unsigned char fingerprintbuf[20], hashbuf[20];
|
||||
- gcry_mpi_t p, q, g, y, received_pub;
|
||||
+ gcry_mpi_t p, q, g, y, received_pub = NULL;
|
||||
gcry_sexp_t pubs = NULL;
|
||||
size_t buflen, lenp;
|
||||
unsigned char received_reply;
|
@ -1,16 +0,0 @@
|
||||
$OpenBSD: patch-src_context_h,v 1.1 2006/10/31 19:54:22 alek Exp $
|
||||
--- src/context.h.orig Wed Oct 19 19:24:57 2005
|
||||
+++ src/context.h Sun Oct 29 00:31:54 2006
|
||||
@@ -38,9 +38,9 @@ typedef enum {
|
||||
sent to him. */
|
||||
} OtrlMessageState;
|
||||
|
||||
-typedef struct fingerprint {
|
||||
- struct fingerprint *next; /* The next fingerprint in the list */
|
||||
- struct fingerprint **tous; /* A pointer to the pointer to us */
|
||||
+typedef struct s_fingerprint {
|
||||
+ struct s_fingerprint *next; /* The next fingerprint in the list */
|
||||
+ struct s_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 */
|
@ -1,12 +0,0 @@
|
||||
$OpenBSD: patch-src_message_c,v 1.1 2006/10/31 19:54:22 alek Exp $
|
||||
--- src/message.c.orig Thu Oct 27 22:24:11 2005
|
||||
+++ src/message.c Sun Oct 29 00:31:54 2006
|
||||
@@ -830,7 +830,7 @@ int otrl_message_receiving(OtrlUserState
|
||||
break;
|
||||
}
|
||||
format = is_conflict ? "We received an unreadable "
|
||||
- "encrypted messahe from %s." :
|
||||
+ "encrypted message from %s." :
|
||||
"We received a malformed data message from %s.";
|
||||
buf = malloc(strlen(format) + strlen(sender) - 1);
|
||||
if (buf) {
|
@ -1,247 +0,0 @@
|
||||
$OpenBSD: patch-src_privkey_c,v 1.1 2006/10/31 19:54:22 alek Exp $
|
||||
--- src/privkey.c.orig Sun Oct 16 17:51:11 2005
|
||||
+++ src/privkey.c Sun Oct 29 00:31:54 2006
|
||||
@@ -157,6 +157,27 @@ static gcry_error_t make_pubkey(unsigned
|
||||
gcry_error_t otrl_privkey_read(OtrlUserState us, const char *filename)
|
||||
{
|
||||
FILE *privf;
|
||||
+ gcry_error_t err;
|
||||
+
|
||||
+ /* Open the privkey file. We use rb mode so that on WIN32, fread()
|
||||
+ * reads the same number of bytes that fstat() indicates are in the
|
||||
+ * file. */
|
||||
+ privf = fopen(filename, "rb");
|
||||
+ if (!privf) {
|
||||
+ err = gcry_error_from_errno(errno);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ err = otrl_privkey_read_FILEp(us, privf);
|
||||
+
|
||||
+ fclose(privf);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+/* Read a sets of private DSA keys from a FILE* into the given
|
||||
+ * OtrlUserState. The FILE* must be open for reading. */
|
||||
+gcry_error_t otrl_privkey_read_FILEp(OtrlUserState us, FILE *privf)
|
||||
+{
|
||||
int privfd;
|
||||
struct stat st;
|
||||
char *buf;
|
||||
@@ -166,37 +187,26 @@ gcry_error_t otrl_privkey_read(OtrlUserS
|
||||
gcry_sexp_t allkeys;
|
||||
size_t i;
|
||||
|
||||
+ if (!privf) return gcry_error(GPG_ERR_NO_ERROR);
|
||||
+
|
||||
/* Release any old ideas we had about our keys */
|
||||
otrl_privkey_forget_all(us);
|
||||
|
||||
- /* Open the privkey file. We use rb mode so that on WIN32, fread()
|
||||
- * reads the same number of bytes that fstat() indicates are in the
|
||||
- * file. */
|
||||
- privf = fopen(filename, "rb");
|
||||
- if (!privf) {
|
||||
- err = gcry_error_from_errno(errno);
|
||||
- return err;
|
||||
- }
|
||||
-
|
||||
/* Load the data into a buffer */
|
||||
privfd = fileno(privf);
|
||||
if (fstat(privfd, &st)) {
|
||||
err = gcry_error_from_errno(errno);
|
||||
- fclose(privf);
|
||||
return err;
|
||||
}
|
||||
buf = malloc(st.st_size);
|
||||
if (!buf && st.st_size > 0) {
|
||||
- fclose(privf);
|
||||
return gcry_error(GPG_ERR_ENOMEM);
|
||||
}
|
||||
if (fread(buf, st.st_size, 1, privf) != 1) {
|
||||
err = gcry_error_from_errno(errno);
|
||||
- fclose(privf);
|
||||
free(buf);
|
||||
return err;
|
||||
}
|
||||
- fclose(privf);
|
||||
|
||||
err = gcry_sexp_new(&allkeys, buf, st.st_size, 0);
|
||||
free(buf);
|
||||
@@ -363,14 +373,46 @@ gcry_error_t otrl_privkey_generate(OtrlU
|
||||
const char *accountname, const char *protocol)
|
||||
{
|
||||
gcry_error_t err;
|
||||
- gcry_sexp_t key, parms, privkey;
|
||||
FILE *privf;
|
||||
#ifndef WIN32
|
||||
mode_t oldmask;
|
||||
#endif
|
||||
+
|
||||
+#ifndef WIN32
|
||||
+ oldmask = umask(077);
|
||||
+#endif
|
||||
+ privf = fopen(filename, "w+b");
|
||||
+ if (!privf) {
|
||||
+#ifndef WIN32
|
||||
+ umask(oldmask);
|
||||
+#endif
|
||||
+ err = gcry_error_from_errno(errno);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ err = otrl_privkey_generate_FILEp(us, privf, accountname, protocol);
|
||||
+
|
||||
+ fclose(privf);
|
||||
+#ifndef WIN32
|
||||
+ umask(oldmask);
|
||||
+#endif
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+/* Generate a private DSA key for a given account, storing it into a
|
||||
+ * FILE*, and loading it into the given OtrlUserState. Overwrite any
|
||||
+ * previously generated keys for that account in that OtrlUserState.
|
||||
+ * The FILE* must be open for reading and writing. */
|
||||
+gcry_error_t otrl_privkey_generate_FILEp(OtrlUserState us, FILE *privf,
|
||||
+ const char *accountname, const char *protocol)
|
||||
+{
|
||||
+ gcry_error_t err;
|
||||
+ gcry_sexp_t key, parms, privkey;
|
||||
static const char *parmstr = "(genkey (dsa (nbits 4:1024)))";
|
||||
OtrlPrivKey *p;
|
||||
|
||||
+ if (!privf) return gcry_error(GPG_ERR_NO_ERROR);
|
||||
+
|
||||
/* Create a DSA key */
|
||||
err = gcry_sexp_new(&parms, parmstr, strlen(parmstr), 0);
|
||||
if (err) {
|
||||
@@ -387,16 +429,6 @@ gcry_error_t otrl_privkey_generate(OtrlU
|
||||
gcry_sexp_release(key);
|
||||
|
||||
/* Output the other keys we know */
|
||||
-#ifndef WIN32
|
||||
- oldmask = umask(077);
|
||||
-#endif
|
||||
- privf = fopen(filename, "w");
|
||||
- if (!privf) {
|
||||
- err = gcry_error_from_errno(errno);
|
||||
- gcry_sexp_release(privkey);
|
||||
- return err;
|
||||
- }
|
||||
-
|
||||
fprintf(privf, "(privkeys\n");
|
||||
|
||||
for (p=us->privkey_root; p; p=p->next) {
|
||||
@@ -411,12 +443,10 @@ gcry_error_t otrl_privkey_generate(OtrlU
|
||||
account_write(privf, accountname, protocol, privkey);
|
||||
gcry_sexp_release(privkey);
|
||||
fprintf(privf, ")\n");
|
||||
- fclose(privf);
|
||||
-#ifndef WIN32
|
||||
- umask(oldmask);
|
||||
-#endif
|
||||
|
||||
- return otrl_privkey_read(us, filename);
|
||||
+ fseek(privf, 0, SEEK_SET);
|
||||
+
|
||||
+ return otrl_privkey_read_FILEp(us, privf);
|
||||
}
|
||||
|
||||
/* Convert a hex character to a value */
|
||||
@@ -436,18 +466,36 @@ gcry_error_t otrl_privkey_read_fingerpri
|
||||
void (*add_app_data)(void *data, ConnContext *context),
|
||||
void *data)
|
||||
{
|
||||
- FILE *storef;
|
||||
gcry_error_t err;
|
||||
- ConnContext *context;
|
||||
- char storeline[1000];
|
||||
- unsigned char fingerprint[20];
|
||||
- size_t maxsize = sizeof(storeline);
|
||||
+ FILE *storef;
|
||||
|
||||
- storef = fopen(filename, "r");
|
||||
+ storef = fopen(filename, "rb");
|
||||
if (!storef) {
|
||||
err = gcry_error_from_errno(errno);
|
||||
return err;
|
||||
}
|
||||
+
|
||||
+ err = otrl_privkey_read_fingerprints_FILEp(us, storef, add_app_data, data);
|
||||
+
|
||||
+ fclose(storef);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+/* Read the fingerprint store from a FILE* into the given
|
||||
+ * OtrlUserState. Use add_app_data to add application data to each
|
||||
+ * ConnContext so created. The FILE* must be open for reading. */
|
||||
+gcry_error_t otrl_privkey_read_fingerprints_FILEp(OtrlUserState us,
|
||||
+ FILE *storef,
|
||||
+ void (*add_app_data)(void *data, ConnContext *context),
|
||||
+ void *data)
|
||||
+{
|
||||
+ ConnContext *context;
|
||||
+ char storeline[1000];
|
||||
+ unsigned char fingerprint[20];
|
||||
+ size_t maxsize = sizeof(storeline);
|
||||
+
|
||||
+ if (!storef) return gcry_error(GPG_ERR_NO_ERROR);
|
||||
+
|
||||
while(fgets(storeline, maxsize, storef)) {
|
||||
char *username;
|
||||
char *accountname;
|
||||
@@ -503,7 +551,6 @@ gcry_error_t otrl_privkey_read_fingerpri
|
||||
fng = otrl_context_find_fingerprint(context, fingerprint, 1, NULL);
|
||||
otrl_context_set_trust(fng, trust);
|
||||
}
|
||||
- fclose(storef);
|
||||
|
||||
return gcry_error(GPG_ERR_NO_ERROR);
|
||||
}
|
||||
@@ -512,16 +559,31 @@ gcry_error_t otrl_privkey_read_fingerpri
|
||||
gcry_error_t otrl_privkey_write_fingerprints(OtrlUserState us,
|
||||
const char *filename)
|
||||
{
|
||||
- FILE *storef;
|
||||
gcry_error_t err;
|
||||
- ConnContext *context;
|
||||
- Fingerprint *fprint;
|
||||
+ FILE *storef;
|
||||
|
||||
- storef = fopen(filename, "w");
|
||||
+ storef = fopen(filename, "wb");
|
||||
if (!storef) {
|
||||
err = gcry_error_from_errno(errno);
|
||||
return err;
|
||||
}
|
||||
+
|
||||
+ err = otrl_privkey_write_fingerprints_FILEp(us, storef);
|
||||
+
|
||||
+ fclose(storef);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+/* Write the fingerprint store from a given OtrlUserState to a FILE*.
|
||||
+ * The FILE* must be open for writing. */
|
||||
+gcry_error_t otrl_privkey_write_fingerprints_FILEp(OtrlUserState us,
|
||||
+ FILE *storef)
|
||||
+{
|
||||
+ ConnContext *context;
|
||||
+ Fingerprint *fprint;
|
||||
+
|
||||
+ if (!storef) return gcry_error(GPG_ERR_NO_ERROR);
|
||||
+
|
||||
for(context = us->context_root; context; context = context->next) {
|
||||
/* Don't both with the first (fingerprintless) entry. */
|
||||
for (fprint = context->fingerprint_root.next; fprint;
|
||||
@@ -535,7 +597,6 @@ gcry_error_t otrl_privkey_write_fingerpr
|
||||
fprintf(storef, "\t%s\n", fprint->trust ? fprint->trust : "");
|
||||
}
|
||||
}
|
||||
- fclose(storef);
|
||||
|
||||
return gcry_error(GPG_ERR_NO_ERROR);
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
$OpenBSD: patch-src_privkey_h,v 1.1 2006/10/31 19:54:22 alek Exp $
|
||||
--- src/privkey.h.orig Sun Oct 16 17:51:11 2005
|
||||
+++ src/privkey.h Sun Oct 29 00:31:54 2006
|
||||
@@ -20,6 +20,7 @@
|
||||
#ifndef __PRIVKEY_H__
|
||||
#define __PRIVKEY_H__
|
||||
|
||||
+#include <stdio.h>
|
||||
#include "privkey-t.h"
|
||||
#include "userstate.h"
|
||||
|
||||
@@ -36,12 +37,23 @@ char *otrl_privkey_fingerprint(OtrlUserS
|
||||
* OtrlUserState. */
|
||||
gcry_error_t otrl_privkey_read(OtrlUserState us, const char *filename);
|
||||
|
||||
+/* Read a sets of private DSA keys from a FILE* into the given
|
||||
+ * OtrlUserState. The FILE* must be open for reading. */
|
||||
+gcry_error_t otrl_privkey_read_FILEp(OtrlUserState us, FILE *privf);
|
||||
+
|
||||
/* Generate a private DSA key for a given account, storing it into a
|
||||
* file on disk, and loading it into the given OtrlUserState. Overwrite any
|
||||
* previously generated keys for that account in that OtrlUserState. */
|
||||
gcry_error_t otrl_privkey_generate(OtrlUserState us, const char *filename,
|
||||
const char *accountname, const char *protocol);
|
||||
|
||||
+/* Generate a private DSA key for a given account, storing it into a
|
||||
+ * FILE*, and loading it into the given OtrlUserState. Overwrite any
|
||||
+ * previously generated keys for that account in that OtrlUserState.
|
||||
+ * The FILE* must be open for reading and writing. */
|
||||
+gcry_error_t otrl_privkey_generate_FILEp(OtrlUserState us, FILE *privf,
|
||||
+ const char *accountname, const char *protocol);
|
||||
+
|
||||
/* Read the fingerprint store from a file on disk into the given
|
||||
* OtrlUserState. Use add_app_data to add application data to each
|
||||
* ConnContext so created. */
|
||||
@@ -50,9 +62,22 @@ gcry_error_t otrl_privkey_read_fingerpri
|
||||
void (*add_app_data)(void *data, ConnContext *context),
|
||||
void *data);
|
||||
|
||||
+/* Read the fingerprint store from a FILE* into the given
|
||||
+ * OtrlUserState. Use add_app_data to add application data to each
|
||||
+ * ConnContext so created. The FILE* must be open for reading. */
|
||||
+gcry_error_t otrl_privkey_read_fingerprints_FILEp(OtrlUserState us,
|
||||
+ FILE *storef,
|
||||
+ void (*add_app_data)(void *data, ConnContext *context),
|
||||
+ void *data);
|
||||
+
|
||||
/* Write the fingerprint store from a given OtrlUserState to a file on disk. */
|
||||
gcry_error_t otrl_privkey_write_fingerprints(OtrlUserState us,
|
||||
const char *filename);
|
||||
+
|
||||
+/* Write the fingerprint store from a given OtrlUserState to a FILE*.
|
||||
+ * The FILE* must be open for writing. */
|
||||
+gcry_error_t otrl_privkey_write_fingerprints_FILEp(OtrlUserState us,
|
||||
+ FILE *storef);
|
||||
|
||||
/* Fetch the private key from the given OtrlUserState associated with
|
||||
* the given account */
|
@ -1,14 +0,0 @@
|
||||
$OpenBSD: patch-src_proto_h,v 1.1 2006/10/31 19:54:22 alek Exp $
|
||||
--- src/proto.h.orig Thu Oct 27 18:01:04 2005
|
||||
+++ src/proto.h Sun Oct 29 00:31:54 2006
|
||||
@@ -40,8 +40,8 @@ typedef unsigned int OtrlPolicy;
|
||||
#define OTRL_POLICY_ALLOW_V2 0x02
|
||||
#define OTRL_POLICY_REQUIRE_ENCRYPTION 0x04
|
||||
#define OTRL_POLICY_SEND_WHITESPACE_TAG 0x08
|
||||
-#define OTRL_POLICY_WHITESPACE_START_AKE 0x08
|
||||
-#define OTRL_POLICY_ERROR_START_AKE 0x10
|
||||
+#define OTRL_POLICY_WHITESPACE_START_AKE 0x10
|
||||
+#define OTRL_POLICY_ERROR_START_AKE 0x20
|
||||
|
||||
#define OTRL_POLICY_VERSION_MASK (OTRL_POLICY_ALLOW_V1 | OTRL_POLICY_ALLOW_V2)
|
||||
|
@ -1,256 +0,0 @@
|
||||
$OpenBSD: patch-src_tests_c,v 1.1 2006/10/31 19:54:22 alek Exp $
|
||||
--- src/tests.c.orig Sun Oct 29 00:31:54 2006
|
||||
+++ src/tests.c Sun Oct 29 00:31:54 2006
|
||||
@@ -0,0 +1,252 @@
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include "proto.h"
|
||||
+#include "privkey.h"
|
||||
+#include "message.h"
|
||||
+
|
||||
+#define ALICE "alice"
|
||||
+#define BOB "bob"
|
||||
+#define PROTO "prpl-oscar"
|
||||
+
|
||||
+static OtrlPolicy ALICEPOLICY = OTRL_POLICY_DEFAULT &~ OTRL_POLICY_ALLOW_V1;
|
||||
+static OtrlPolicy BOBPOLICY = OTRL_POLICY_DEFAULT;
|
||||
+
|
||||
+void receiving(const char *from, const char *to, const char *msg);
|
||||
+
|
||||
+typedef struct s_node {
|
||||
+ struct s_node *next;
|
||||
+ char *from, *to, *msg;
|
||||
+} MsgNode;
|
||||
+
|
||||
+static MsgNode *noderoot = NULL;
|
||||
+static MsgNode **nodeend = &noderoot;
|
||||
+
|
||||
+static void dispatch(void)
|
||||
+{
|
||||
+ while(noderoot) {
|
||||
+ MsgNode *node = noderoot;
|
||||
+
|
||||
+ receiving(node->from, node->to, node->msg);
|
||||
+ free(node->from);
|
||||
+ free(node->to);
|
||||
+ free(node->msg);
|
||||
+ noderoot = node->next;
|
||||
+ free(node);
|
||||
+ if (noderoot == NULL) nodeend = &noderoot;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void inject(const char *from, const char *to, const char *msg)
|
||||
+{
|
||||
+ MsgNode *node = malloc(sizeof(*node));
|
||||
+ node->from = strdup(from);
|
||||
+ node->to = strdup(to);
|
||||
+ node->msg = strdup(msg);
|
||||
+ node->next = NULL;
|
||||
+ *nodeend = node;
|
||||
+ nodeend = &(node->next);
|
||||
+ printf("[%s->%s: %s]\n\n", from, to, msg);
|
||||
+}
|
||||
+
|
||||
+static OtrlPolicy op_policy(void *opdata, ConnContext *context)
|
||||
+{
|
||||
+ if (!strcmp(context->accountname, ALICE)) return ALICEPOLICY;
|
||||
+ if (!strcmp(context->accountname, BOB)) return BOBPOLICY;
|
||||
+ return OTRL_POLICY_DEFAULT;
|
||||
+}
|
||||
+
|
||||
+static void op_inject(void *opdata, const char *accountname,
|
||||
+ const char *protocol, const char *recipient, const char *message)
|
||||
+{
|
||||
+ inject(accountname, recipient, message);
|
||||
+}
|
||||
+
|
||||
+static void op_notify(void *opdata, OtrlNotifyLevel level,
|
||||
+ const char *accountname, const char *protocol,
|
||||
+ const char *username, const char *title,
|
||||
+ const char *primary, const char *secondary)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static int op_display_otr_message(void *opdata, const char *accountname,
|
||||
+ const char *protocol, const char *username, const char *msg)
|
||||
+{
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static void op_gone_secure(void *opdata, ConnContext *context)
|
||||
+{
|
||||
+ printf("SECURE (%d): %s / %s\n\n", context->protocol_version,
|
||||
+ context->accountname, context->username);
|
||||
+}
|
||||
+
|
||||
+static void op_gone_insecure(void *opdata, ConnContext *context)
|
||||
+{
|
||||
+ printf("INSECURE: %s / %s\n\n", context->accountname, context->username);
|
||||
+}
|
||||
+
|
||||
+static void op_still_secure(void *opdata, ConnContext *context, int is_reply)
|
||||
+{
|
||||
+ printf("REFRESH (%d/%d): %s / %s\n\n", is_reply, context->protocol_version,
|
||||
+ context->accountname, context->username);
|
||||
+}
|
||||
+
|
||||
+static OtrlMessageAppOps ops = {
|
||||
+ op_policy,
|
||||
+ NULL,
|
||||
+ NULL,
|
||||
+ op_inject,
|
||||
+ op_notify,
|
||||
+ op_display_otr_message,
|
||||
+ NULL,
|
||||
+ NULL,
|
||||
+ NULL,
|
||||
+ NULL,
|
||||
+ NULL,
|
||||
+ op_gone_secure,
|
||||
+ op_gone_insecure,
|
||||
+ op_still_secure,
|
||||
+ NULL
|
||||
+};
|
||||
+
|
||||
+static OtrlUserState us;
|
||||
+
|
||||
+void receiving(const char *from, const char *to, const char *msg)
|
||||
+{
|
||||
+ int ignore;
|
||||
+ char *newmsg;
|
||||
+ OtrlTLV *tlvs;
|
||||
+
|
||||
+ ignore = otrl_message_receiving(us, &ops, NULL, to, PROTO, from, msg,
|
||||
+ &newmsg, &tlvs, NULL, NULL);
|
||||
+
|
||||
+ if (!ignore) {
|
||||
+ printf("%s> %s\n\n", from, newmsg ? newmsg : msg);
|
||||
+ }
|
||||
+
|
||||
+ otrl_message_free(newmsg);
|
||||
+ otrl_tlv_free(tlvs);
|
||||
+}
|
||||
+
|
||||
+static void sending(const char *from, const char *to, const char *msg)
|
||||
+{
|
||||
+ gcry_error_t err;
|
||||
+ OtrlTLV *tlvs = NULL;
|
||||
+ char *newmsg;
|
||||
+
|
||||
+ err = otrl_message_sending(us, &ops, NULL, from, PROTO, to, msg,
|
||||
+ tlvs, &newmsg, NULL, NULL);
|
||||
+
|
||||
+ if (!err) {
|
||||
+ inject(from, to, newmsg ? newmsg : msg);
|
||||
+ }
|
||||
+
|
||||
+ otrl_message_free(newmsg);
|
||||
+ otrl_tlv_free(tlvs);
|
||||
+}
|
||||
+
|
||||
+void test(int vers, int both)
|
||||
+{
|
||||
+ printf("\n\n*** Testing version %d, %s ***\n\n", vers,
|
||||
+ both ? "simultaneous start" : "Alice start");
|
||||
+
|
||||
+ otrl_context_forget_all(us);
|
||||
+ ALICEPOLICY = vers == 1 ? (OTRL_POLICY_DEFAULT &~ OTRL_POLICY_ALLOW_V2) :
|
||||
+ OTRL_POLICY_DEFAULT;
|
||||
+ sending(ALICE, BOB, "?OTR?");
|
||||
+ if (both) {
|
||||
+ sending(BOB, ALICE, "?OTR?");
|
||||
+ }
|
||||
+ dispatch();
|
||||
+ sending(ALICE, BOB, "Hi there");
|
||||
+ dispatch();
|
||||
+}
|
||||
+
|
||||
+void test_unreadable(void)
|
||||
+{
|
||||
+ ConnContext *bobcontext;
|
||||
+
|
||||
+ printf("\n\n*** Testing Bob receiving unreadable messages from "
|
||||
+ "Alice ***\n\n");
|
||||
+
|
||||
+ bobcontext = otrl_context_find(us, ALICE, BOB, PROTO, 0, NULL, NULL, NULL);
|
||||
+ otrl_context_force_plaintext(bobcontext);
|
||||
+ sending(ALICE, BOB, "unreadable text");
|
||||
+ dispatch();
|
||||
+
|
||||
+}
|
||||
+
|
||||
+void test_crash1(void)
|
||||
+{
|
||||
+ ConnContext *alicecontext, *bobcontext;
|
||||
+
|
||||
+ printf("\n\n*** Testing old double gcry_cipher_release case ***\n\n");
|
||||
+
|
||||
+ otrl_context_forget_all(us);
|
||||
+ ALICEPOLICY = OTRL_POLICY_DEFAULT;
|
||||
+ sending(ALICE, BOB, "?OTR?");
|
||||
+ dispatch();
|
||||
+
|
||||
+ alicecontext = otrl_context_find(us, BOB, ALICE, PROTO, 0, NULL, NULL, NULL);
|
||||
+ bobcontext = otrl_context_find(us, ALICE, BOB, PROTO, 0, NULL, NULL, NULL);
|
||||
+
|
||||
+ sending(ALICE, BOB, "Hi!"); dispatch();
|
||||
+ sending(BOB, ALICE, "There!"); dispatch();
|
||||
+ sending(ALICE, BOB, "You!"); dispatch();
|
||||
+ otrl_context_force_plaintext(bobcontext);
|
||||
+ sending(BOB, ALICE, "?OTR?"); dispatch();
|
||||
+ sending(ALICE, BOB, "now."); dispatch();
|
||||
+ printf("%d %p %p\n", alicecontext->our_keyid, alicecontext->their_y, alicecontext->their_old_y);
|
||||
+ printf("%p %p %p %p\n",
|
||||
+ alicecontext->sesskeys[0][0].sendenc,
|
||||
+ alicecontext->sesskeys[0][1].sendenc,
|
||||
+ alicecontext->sesskeys[1][0].sendenc,
|
||||
+ alicecontext->sesskeys[1][1].sendenc);
|
||||
+ sending(BOB, ALICE, "then."); dispatch();
|
||||
+}
|
||||
+
|
||||
+void test_refresh(int vers)
|
||||
+{
|
||||
+ ConnContext *alicecontext, *bobcontext;
|
||||
+
|
||||
+ printf("\n\n*** Testing refresh ***\n\n");
|
||||
+
|
||||
+ otrl_context_forget_all(us);
|
||||
+ ALICEPOLICY = vers == 1 ? (OTRL_POLICY_DEFAULT &~ OTRL_POLICY_ALLOW_V2) :
|
||||
+ OTRL_POLICY_DEFAULT;
|
||||
+ sending(ALICE, BOB, "?OTR?"); dispatch();
|
||||
+
|
||||
+ alicecontext = otrl_context_find(us, BOB, ALICE, PROTO, 0, NULL, NULL, NULL);
|
||||
+ bobcontext = otrl_context_find(us, ALICE, BOB, PROTO, 0, NULL, NULL, NULL);
|
||||
+ printf("%p %p\n", alicecontext, bobcontext);
|
||||
+
|
||||
+ sending(ALICE, BOB, "Hi!"); dispatch();
|
||||
+ sending(BOB, ALICE, "There!"); dispatch();
|
||||
+ sending(ALICE, BOB, "You!"); dispatch();
|
||||
+ sending(ALICE, BOB, "Guys!"); dispatch();
|
||||
+ sending(BOB, ALICE, "?OTR?"); dispatch();
|
||||
+ sending(ALICE, BOB, "Refreshed!"); dispatch();
|
||||
+ sending(BOB, ALICE, "Also refreshed!"); dispatch();
|
||||
+}
|
||||
+
|
||||
+int main(int argc, char **argv)
|
||||
+{
|
||||
+ OTRL_INIT;
|
||||
+ us = otrl_userstate_create();
|
||||
+
|
||||
+ otrl_privkey_read(us, "/home/iang/.gaim/otr.private_key");
|
||||
+
|
||||
+ test(1,0);
|
||||
+ test(2,0);
|
||||
+ test(1,1);
|
||||
+ test(2,1);
|
||||
+ test_unreadable();
|
||||
+ test_crash1();
|
||||
+ test_refresh(2);
|
||||
+ test_refresh(1);
|
||||
+
|
||||
+ otrl_userstate_free(us);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
@ -1,3 +1,2 @@
|
||||
This is the library and toolkit for Off-the-Record Messaging used by
|
||||
the gaim-otr GAIM plugin.
|
||||
|
||||
the pidgin-otr plugin.
|
||||
|
@ -1,4 +1,4 @@
|
||||
@comment $OpenBSD: PLIST,v 1.3 2006/10/31 19:54:22 alek Exp $
|
||||
@comment $OpenBSD: PLIST,v 1.4 2007/11/29 14:05:48 okan Exp $
|
||||
%%SHARED%%
|
||||
bin/otr_mackey
|
||||
bin/otr_modify
|
||||
@ -17,6 +17,7 @@ include/libotr/privkey-t.h
|
||||
include/libotr/privkey.h
|
||||
include/libotr/proto.h
|
||||
include/libotr/serial.h
|
||||
include/libotr/sm.h
|
||||
include/libotr/tlv.h
|
||||
include/libotr/userstate.h
|
||||
include/libotr/version.h
|
||||
|
Loading…
Reference in New Issue
Block a user