summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2020-11-19 12:39:53 +0300
committerdefanor <defanor@uberspace.net>2020-11-19 12:39:53 +0300
commit53e218af8591f209644c63032f264fcbd154b827 (patch)
tree6260082546c2421fd6f3b62b0f98a539b0612fb1
parentf56e6496224eb5b997facfe80d9d6262c9296f93 (diff)
Sign messages with appropriate keys
That is, the keys which are both published for the account and available.
-rw-r--r--src/rexmpp_openpgp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/rexmpp_openpgp.c b/src/rexmpp_openpgp.c
index ecb0fc7..983946c 100644
--- a/src/rexmpp_openpgp.c
+++ b/src/rexmpp_openpgp.c
@@ -375,6 +375,10 @@ char *rexmpp_openpgp_encrypt_sign (rexmpp_t *s,
char *fingerprint = xmlGetProp(metadata, "v4-fingerprint");
err = gpgme_get_key(s->pgp_ctx, fingerprint, &keys[nkeys], 0);
if (gpg_err_code(err) == GPG_ERR_NO_ERROR) {
+ if (strcmp(recipients[i], s->initial_jid.bare) == 0) {
+ /* Own keys: also add them for signing. */
+ gpgme_signers_add(s->pgp_ctx, keys[nkeys]);
+ }
nkeys++;
if (nkeys == allocated) {
allocated *= 2;
@@ -442,7 +446,8 @@ char *rexmpp_openpgp_encrypt_sign (rexmpp_t *s,
gpgme_data_t cipher_dh, plain_dh;
gpgme_data_new(&cipher_dh);
gpgme_data_new_from_mem(&plain_dh, plaintext, strlen(plaintext), 0);
- err = gpgme_op_encrypt_sign(s->pgp_ctx, keys, 0, plain_dh, cipher_dh);
+ err = gpgme_op_encrypt_sign(s->pgp_ctx, keys, GPGME_ENCRYPT_NO_ENCRYPT_TO,
+ plain_dh, cipher_dh);
for (i = 0; i < nkeys; i++) {
gpgme_key_release(keys[i]);
}