Skip to content

Commit

Permalink
Changed build to not depend on libtool or the pidgin source.
Browse files Browse the repository at this point in the history
Updated README accordingly.
And the makefile, of course.
Had to add the jabber protocol plugin headers to this source tree.
  • Loading branch information
gkdr committed Feb 2, 2017
1 parent e8bb7e2 commit 9a43d65
Show file tree
Hide file tree
Showing 33 changed files with 2,441 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lib/
build/
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ That being said, indicating encrypted chats by setting the topic does not seem t

## Installation
1. Create a folder `lib`, and put the source code of the dependencies in there. You do not have to "install" the libs, the makefile in this project will call the right targets in their makefiles later on.
2. Install the used libs' dependencies.
3. [Get the Pidgin source code](https://www.pidgin.im/download/) and put it in the root directory of this repository, same as the makefile. (The plugin was developed with 2.11.0, and that is also what the makefile uses as the folder name. If yours is different, you will need to adopt it.)
4. Copy the only sourcefile `lurch.c` into `pidgin-x.y.z/libpurple/plugins`.
5. Type `make lurch` (or just `make`). This will compile the plugin, the two libs you just got, link everything together and put it in your `~/.purple/` directory.
6. Done. The next time you start Pidgin (or a different libpurple client), you should be able to activate it in the "Plugins" window.
2. Install the used libs' dependencies (which boils down to SQLite, OpenSSL, Mini-XML, and the libaxolotl-c that comes with axc.).
3. In case you don't have it yet, install `libpurple-dev`.)
4. Type `make lurch` (or just `make`). This will compile the plugin, the two libs you just got, and link everything together into one file.
5. To easily copy it in your plugin dir, type `make install`.
6. The next time you start Pidgin (or a different libpurple client), you should be able to activate it in the "Plugins" window.

## Usage
This plugin will set the topic to notify the user if encryption is enabled or not. If it is, it will generally not send plaintext messages. If a plaintext message is received, the user will be warned.
Expand Down
45 changes: 45 additions & 0 deletions headers/jabber/adhoccommands.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* purple - Jabber Protocol Plugin
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*
*/

#ifndef PURPLE_JABBER_ADHOCCOMMANDS_H_
#define PURPLE_JABBER_ADHOCCOMMANDS_H_

#include "jabber.h"

/* Implementation of XEP-0050 */

void jabber_adhoc_disco_result_cb(JabberStream *js, const char *from,
JabberIqType type, const char *id,
xmlnode *packet, gpointer data);

void jabber_adhoc_execute(JabberStream *js, JabberAdHocCommands *cmd);

void jabber_adhoc_execute_action(PurpleBlistNode *node, gpointer data);

void jabber_adhoc_got_list(JabberStream *js, const char *from, xmlnode *query);

void jabber_adhoc_server_get_list(JabberStream *js);

void jabber_adhoc_init_server_commands(JabberStream *js, GList **m);

#endif /* PURPLE_JABBER_ADHOCCOMMANDS_H_ */
67 changes: 67 additions & 0 deletions headers/jabber/auth.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @file auth.h Authentication routines
*
* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef PURPLE_JABBER_AUTH_H_
#define PURPLE_JABBER_AUTH_H_

typedef struct _JabberSaslMech JabberSaslMech;

#include "jabber.h"
#include "xmlnode.h"

typedef enum {
JABBER_SASL_STATE_FAIL = -1, /* Abort, Retry, Fail? */
JABBER_SASL_STATE_OK = 0, /* Hooray! */
JABBER_SASL_STATE_CONTINUE = 1 /* More authentication required */
} JabberSaslState;

struct _JabberSaslMech {
gint8 priority; /* Higher priority will be tried before lower priority */
const gchar *name;
JabberSaslState (*start)(JabberStream *js, xmlnode *mechanisms, xmlnode **reply, char **msg);
JabberSaslState (*handle_challenge)(JabberStream *js, xmlnode *packet, xmlnode **reply, char **msg);
JabberSaslState (*handle_success)(JabberStream *js, xmlnode *packet, char **msg);
JabberSaslState (*handle_failure)(JabberStream *js, xmlnode *packet, xmlnode **reply, char **msg);
void (*dispose)(JabberStream *js);
};

void jabber_auth_start(JabberStream *js, xmlnode *packet);
void jabber_auth_start_old(JabberStream *js);
void jabber_auth_handle_challenge(JabberStream *js, xmlnode *packet);
void jabber_auth_handle_success(JabberStream *js, xmlnode *packet);
void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet);

JabberSaslMech *jabber_auth_get_plain_mech(void);
JabberSaslMech *jabber_auth_get_digest_md5_mech(void);
JabberSaslMech **jabber_auth_get_scram_mechs(gint *count);
#ifdef HAVE_CYRUS_SASL
JabberSaslMech *jabber_auth_get_cyrus_mech(void);
#endif

void jabber_auth_add_mech(JabberSaslMech *);
void jabber_auth_remove_mech(JabberSaslMech *);

void jabber_auth_init(void);
void jabber_auth_uninit(void);

#endif /* PURPLE_JABBER_AUTH_H_ */
39 changes: 39 additions & 0 deletions headers/jabber/auth_digest_md5.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* @file auth_digest_md5.h Implementation of SASL DIGEST-MD5 authentication
*
* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef PURPLE_JABBER_AUTH_DIGEST_MD5_H_
#define PURPLE_JABBER_AUTH_DIGEST_MD5_H_

#include "internal.h"

/*
* Every function in this file is ONLY exposed for tests.
* DO NOT USE ANYTHING HERE OR YOU WILL BE SENT TO THE PIT OF DESPAIR.
*/

/*
* Parse a DIGEST-MD5 challenge.
*/
GHashTable *jabber_auth_digest_md5_parse(const char *challenge);

#endif /* PURPLE_JABBER_AUTH_DIGEST_MD5_H_ */
95 changes: 95 additions & 0 deletions headers/jabber/auth_scram.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/**
* @file auth_scram.h Implementation of SASL-SCRAM authentication
*
* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef PURPLE_JABBER_AUTH_SCRAM_H_
#define PURPLE_JABBER_AUTH_SCRAM_H_

/*
* Every function in this file is ONLY exposed for tests.
* DO NOT USE ANYTHING HERE OR YOU WILL BE SENT TO THE PIT OF DESPAIR.
*/

/* Per-connection state stored between messages.
* This is stored in js->auth_data_mech.
*/
typedef struct {
const char *mech_substr;
const char *name;
guint size;
} JabberScramHash;

typedef struct {
const JabberScramHash *hash;
char *cnonce;
GString *auth_message;

GString *client_proof;
GString *server_signature;

gchar *password;
gboolean channel_binding;
int step;
} JabberScramData;

#include "auth.h"

/**
* Implements the Hi() function as described in the SASL-SCRAM I-D.
*
* @param hash The struct corresponding to the hash function to be used.
* @param str The string to perform the PBKDF2 operation on.
* @param salt The salt.
* @param iterations The number of iterations to perform.
*
* @returns A newly allocated string containing the result. The string is
* NOT null-terminated and its length is the length of the binary
* output of the hash function in-use.
*/
guchar *jabber_scram_hi(const JabberScramHash *hash, const GString *str,
GString *salt, guint iterations);

/**
* Calculates the proofs as described in Section 3 of the SASL-SCRAM I-D.
*
* @param data A JabberScramData structure. hash and auth_message must be
* set. client_proof and server_signature will be set as a result
* of this function.
* @param salt The salt (as specified by the server)
* @param iterations The number of iterations to perform.
*
* @returns TRUE if the proofs were successfully calculated. FALSE otherwise.
*/
gboolean jabber_scram_calc_proofs(JabberScramData *data, GString *salt,
guint iterations);

/**
* Feed the algorithm with the data from the server.
*/
gboolean jabber_scram_feed_parser(JabberScramData *data, gchar *in, gchar **out);

/**
* Clean up and destroy the data struct
*/
void jabber_scram_data_destroy(JabberScramData *data);

#endif /* PURPLE_JABBER_AUTH_SCRAM_H_ */
43 changes: 43 additions & 0 deletions headers/jabber/bosh.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @file bosh.h Bidirectional-streams over Synchronous HTTP (BOSH) (XEP-0124 and XEP-0206)
*
* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef PURPLE_JABBER_BOSH_H_
#define PURPLE_JABBER_BOSH_H_

typedef struct _PurpleBOSHConnection PurpleBOSHConnection;

#include "jabber.h"

void jabber_bosh_init(void);
void jabber_bosh_uninit(void);

PurpleBOSHConnection* jabber_bosh_connection_init(JabberStream *js, const char *url);
void jabber_bosh_connection_destroy(PurpleBOSHConnection *conn);

gboolean jabber_bosh_connection_is_ssl(PurpleBOSHConnection *conn);
void jabber_bosh_connection_send_keepalive(PurpleBOSHConnection *conn);

void jabber_bosh_connection_connect(PurpleBOSHConnection *conn);
void jabber_bosh_connection_close(PurpleBOSHConnection *conn);
void jabber_bosh_connection_send_raw(PurpleBOSHConnection *conn, const char *data);
#endif /* PURPLE_JABBER_BOSH_H_ */

0 comments on commit 9a43d65

Please sign in to comment.