Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrypt to self for sent messages #11

Open
github-k8n opened this issue Nov 4, 2014 · 2 comments
Open

Encrypt to self for sent messages #11

github-k8n opened this issue Nov 4, 2014 · 2 comments

Comments

@github-k8n
Copy link
Contributor

When using OpenPGP encryption with carbon messages, the sent text can not be decrypted on other devices as it is only encrypted to the recipient, not to the sender's key.

Please add an option (or do it by default) to add your own key as recipients when encrypting the message.

See also https://github.com/siacs/Conversations/issues/558

@github-k8n
Copy link
Contributor Author

Some quick and dirty patch that encrypts to the sender if the key was selected (works for me..)

--- pidgin-gpg.c    2011-01-12 21:03:30.000000000 +0100
+++ pidgin-gpg.c    2014-11-09 21:19:57.102561976 +0100
@@ -463,14 +463,16 @@
    gpgme_error_t error;
    gpgme_ctx_t ctx;
    gpgme_key_t key;
+   gpgme_key_t sender_key;
    gpgme_data_t plain,cipher;
    char* cipher_str = NULL;
    char* cipher_str_dup = NULL;
    size_t len;
-   gpgme_key_t key_arr[2];
+   gpgme_key_t key_arr[3];

    key_arr[0] = NULL;
    key_arr[1] = NULL;
+   key_arr[2] = NULL;

    // connect to gpgme
    gpgme_check_version (NULL);
@@ -491,6 +493,33 @@
    }
    key_arr[0] = key;

+   // check if user selected a main key
+   const char* sender_fpr = purple_prefs_get_string(PREF_MY_KEY);
+   if (sender_fpr == NULL)
+       sender_fpr = "";
+   if (strcmp(sender_fpr,"") != 0)
+   {
+       // connect to gpgme
+       gpgme_check_version (NULL);
+       error = gpgme_new(&ctx);
+       if (error)
+       {
+           purple_debug_error(PLUGIN_ID,"gpgme_new failed: %s %s\n",gpgme_strsource (error), gpgme_strerror (error));
+           return NULL;
+       }
+
+       // get key by fingerprint
+       error = gpgme_get_key(ctx,sender_fpr,&sender_key,0);
+       if (error || !sender_key)
+       {
+           purple_debug_error(PLUGIN_ID,"gpgme_get_key failed: %s %s\n",gpgme_strsource (error), gpgme_strerror (error));
+           gpgme_release (ctx);
+           return NULL;
+       }
+       key_arr[1] = sender_key;
+   }
+
+
    // create data containers
    gpgme_data_new_from_mem (&plain, plain_str,strlen(plain_str),1);
    gpgme_data_new(&cipher);

@github-k8n
Copy link
Contributor Author

Created pull request with this and a few additional things for carbon copy support.
#14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant