Mercurial > hg
changeset 2188:84252c616919
PGP: Encrypt messages with our own PGP key when carbons are enabled
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 04 Oct 2015 19:04:43 +0200 |
parents | e3b66c8ead4f |
children | 3b91f6a100f5 |
files | mcabber/mcabber/api.h mcabber/mcabber/pgp.c mcabber/mcabber/pgp.h mcabber/mcabber/xmpp.c |
diffstat | 4 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mcabber/mcabber/api.h Sun Oct 04 19:04:04 2015 +0200 +++ b/mcabber/mcabber/api.h Sun Oct 04 19:04:43 2015 +0200 @@ -4,7 +4,7 @@ #include <glib.h> #include <mcabber/config.h> // For MCABBER_BRANCH -#define MCABBER_API_VERSION 36 +#define MCABBER_API_VERSION 37 #define MCABBER_API_MIN 36 #define MCABBER_BRANCH_DEV 1
--- a/mcabber/mcabber/pgp.c Sun Oct 04 19:04:04 2015 +0200 +++ b/mcabber/mcabber/pgp.c Sun Oct 04 19:04:43 2015 +0200 @@ -118,6 +118,13 @@ gpg.private_key = NULL; } +// gpg_get_private_key_id() +// Return the current private key id (static string). +const char *gpg_get_private_key_id(void) +{ + return gpg.private_key; +} + // strip_header_footer(data) // Remove PGP header & footer from data. // Return a new string, or NULL.
--- a/mcabber/mcabber/pgp.h Sun Oct 04 19:04:04 2015 +0200 +++ b/mcabber/mcabber/pgp.h Sun Oct 04 19:04:43 2015 +0200 @@ -12,6 +12,7 @@ void gpg_terminate(void); void gpg_set_passphrase(const char *passphrase); void gpg_set_private_key(const char *priv_keyid); +const char *gpg_get_private_key_id(void); char *gpg_verify(const char *gpg_data, const char *text, gpgme_sigsum_t *sigsum); char *gpg_sign(const char *gpg_data);
--- a/mcabber/mcabber/xmpp.c Sun Oct 04 19:04:04 2015 +0200 +++ b/mcabber/mcabber/xmpp.c Sun Oct 04 19:04:43 2015 +0200 @@ -383,8 +383,13 @@ if (!key && res_pgpdata) key = res_pgpdata->sign_keyid; if (key) { - const char *keys[] = { key }; - enc = gpg_encrypt(text, keys, 1); + int nkeys = 1; + const char *keys[] = { key, 0 }; + if (carbons_enabled()) { + keys[1] = gpg_get_private_key_id(); + nkeys++; + } + enc = gpg_encrypt(text, keys, nkeys); } if (!enc && force) { if (encrypted)