summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README4
-rw-r--r--configure.ac8
-rw-r--r--src/rexmpp.c12
-rw-r--r--src/rexmpp.h7
-rw-r--r--src/rexmpp_openpgp.c72
5 files changed, 100 insertions, 3 deletions
diff --git a/README b/README
index 4292503..c60b82c 100644
--- a/README
+++ b/README
@@ -14,8 +14,8 @@ rely on any particular UI, should be flexible and not stay in the way
of implementing additional XEPs on top of it, and should try to make
it easy to implement a decent client application using it.
-Current dependencies: libunbound, libxml2, gsasl, nettle, gpgme.
-Optionally gnutls with gnutls-dane or openssl, icu-i18n.
+Current dependencies: libunbound, libxml2, gsasl, nettle. Optionally
+gnutls with gnutls-dane or openssl, icu-i18n, gpgme.
A rough roadmap:
diff --git a/configure.ac b/configure.ac
index de90408..d6be743 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,7 +25,13 @@ PKG_CHECK_MODULES([GSASL], [libgsasl])
PKG_CHECK_MODULES([NETTLE], [nettle])
-AM_PATH_GPGME
+
+# GPGME, optional
+
+AC_ARG_WITH([gpgme],
+ AS_HELP_STRING([--without-gpgme], [Don't use GPGME for OpenPGP]))
+AS_IF([test "x$with_gpgme" != "xno"],
+ [AM_PATH_GPGME([], [AC_DEFINE([HAVE_GPGME], [1], [GPGME is available])])])
# TLS: GnuTLS, OpenSSL, or none
diff --git a/src/rexmpp.c b/src/rexmpp.c
index bfaca29..5c41625 100644
--- a/src/rexmpp.c
+++ b/src/rexmpp.c
@@ -15,11 +15,15 @@
#include <sys/types.h>
#include <sys/socket.h>
+#include "config.h"
+
#include <libxml/tree.h>
#include <libxml/xmlsave.h>
#include <gsasl.h>
#include <unbound.h>
+#ifdef HAVE_GPGME
#include <gpgme.h>
+#endif
#include <nettle/sha1.h>
#include "rexmpp.h"
@@ -387,7 +391,11 @@ rexmpp_err_t rexmpp_init (rexmpp_t *s,
s->track_roster_presence = 1;
s->track_roster_events = 1;
s->nick_notifications = 1;
+#ifdef HAVE_GPGME
s->retrieve_openpgp_keys = 1;
+#else
+ s->retrieve_openpgp_keys = 0;
+#endif
s->autojoin_bookmarked_mucs = 1;
s->require_tls = 1;
s->send_buffer = NULL;
@@ -489,6 +497,7 @@ rexmpp_err_t rexmpp_init (rexmpp_t *s,
gsasl_callback_hook_set(s->sasl_ctx, s);
gsasl_callback_set(s->sasl_ctx, rexmpp_sasl_cb);
+#ifdef HAVE_GPGME
gpgme_check_version(NULL);
err = gpgme_new(&(s->pgp_ctx));
if (gpg_err_code(err) != GPG_ERR_NO_ERROR) {
@@ -499,6 +508,7 @@ rexmpp_err_t rexmpp_init (rexmpp_t *s,
xmlFreeParserCtxt(s->xml_parser);
return REXMPP_E_PGP;
}
+#endif
return REXMPP_SUCCESS;
}
@@ -565,7 +575,9 @@ void rexmpp_cleanup (rexmpp_t *s) {
/* Frees the things that persist through reconnects. */
void rexmpp_done (rexmpp_t *s) {
rexmpp_cleanup(s);
+#ifdef HAVE_GPGME
gpgme_release(s->pgp_ctx);
+#endif
gsasl_done(s->sasl_ctx);
rexmpp_tls_deinit(s);
if (s->resolver_ctx != NULL) {
diff --git a/src/rexmpp.h b/src/rexmpp.h
index b47703f..bfcde96 100644
--- a/src/rexmpp.h
+++ b/src/rexmpp.h
@@ -10,10 +10,15 @@
#define REXMPP_H
#include <stdint.h>
+
+#include "config.h"
+
#include <unbound.h>
#include <gsasl.h>
#include <libxml/tree.h>
+#ifdef HAVE_GPGME
#include <gpgme.h>
+#endif
typedef struct rexmpp rexmpp_t;
@@ -347,7 +352,9 @@ struct rexmpp
Gsasl_session *sasl_session;
/* OpenPGP structures */
+#ifdef HAVE_GPGME
gpgme_ctx_t pgp_ctx;
+#endif
};
/**
diff --git a/src/rexmpp_openpgp.c b/src/rexmpp_openpgp.c
index 2ec975d..fd22cf4 100644
--- a/src/rexmpp_openpgp.c
+++ b/src/rexmpp_openpgp.c
@@ -42,7 +42,11 @@ Possible future improvements:
#include <string.h>
#include <time.h>
+#include "config.h"
+
+#ifdef HAVE_GPGME
#include <gpgme.h>
+#endif
#include <libxml/tree.h>
#include <gsasl.h>
@@ -52,6 +56,8 @@ Possible future improvements:
#include "rexmpp_pubsub.h"
+#ifdef HAVE_GPGME
+
void rexmpp_pgp_fp_reply (rexmpp_t *s,
xmlNodePtr req,
xmlNodePtr response,
@@ -817,3 +823,69 @@ rexmpp_err_t rexmpp_openpgp_set_home_dir (rexmpp_t *s, const char *home_dir) {
}
return REXMPP_SUCCESS;
}
+
+#else
+
+/* Dummy functions for when it's built without GPGME. */
+
+rexmpp_err_t gpgme_not_supported(rexmpp_t *s) {
+ rexmpp_log(s, LOG_ERR, "rexmpp is compiled without GPGME support");
+ return REXMPP_E_PGP;
+}
+
+rexmpp_err_t
+rexmpp_openpgp_check_keys (rexmpp_t *s,
+ const char *jid,
+ xmlNodePtr items) {
+ (void)jid;
+ (void)items;
+ return gpgme_not_supported(s);
+}
+
+rexmpp_err_t rexmpp_openpgp_publish_key (rexmpp_t *s, const char *fp) {
+ (void)fp;
+ return gpgme_not_supported(s);
+}
+
+void rexmpp_openpgp_retract_key (rexmpp_t *s, const char *fp) {
+ (void)fp;
+ gpgme_not_supported(s);
+}
+
+xmlNodePtr
+rexmpp_openpgp_decrypt_verify (rexmpp_t *s,
+ const char *cipher_base64) {
+ (void)cipher_base64;
+ gpgme_not_supported(s);
+ return NULL;
+}
+
+xmlNodePtr
+rexmpp_openpgp_decrypt_verify_message (rexmpp_t *s,
+ xmlNodePtr message,
+ int *valid) {
+ (void)message;
+ (void)valid;
+ gpgme_not_supported(s);
+ return NULL;
+}
+
+char *rexmpp_openpgp_payload (rexmpp_t *s,
+ xmlNodePtr payload,
+ const char **recipients,
+ const char **signers,
+ enum rexmpp_ox_mode mode) {
+ (void)recipients;
+ (void)signers;
+ (void)mode;
+ xmlFreeNode(payload);
+ gpgme_not_supported(s);
+ return NULL;
+}
+
+rexmpp_err_t rexmpp_openpgp_set_home_dir (rexmpp_t *s, const char *home_dir) {
+ (void)home_dir;
+ return gpgme_not_supported(s);
+}
+
+#endif