[git] GPGME - branch, master, updated. gpgme-1.11.1-236-ga5f8dac

[email protected] (by Andre Heinecke)
Newsgroups gmane.comp.encryption.gpg.cvs
Message-ID <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, master has been updated
       via  a5f8dac77d50480a208c99398df323c58ce6dc58 (commit)
      from  f62dd4bb27c36e44acf93af1daf24eefda3029c2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a5f8dac77d50480a208c99398df323c58ce6dc58
Author: Andre Heinecke <[email protected]>
Date:   Thu Aug 23 20:49:26 2018 +0200

    json: Add sender and file name to encrypt
    
    * src/gpgme-json.c (hlp_encrypt, op_encrypt): Support sender
    and file_name.

diff --git a/src/gpgme-json.c b/src/gpgme-json.c
index d636ddb..9358269 100644
--- a/src/gpgme-json.c
+++ b/src/gpgme-json.c
@@ -1607,6 +1607,8 @@ static const char hlp_encrypt[] =
   "protocol:      Either \"openpgp\" (default) or \"cms\".\n"
   "signing_keys:  Similar to the keys parameter for added signing.\n"
   "               (openpgp only)"
+  "file_name:     The file name associated with the data.\n"
+  "sender:        Sender info to embed in a signature.\n"
   "\n"
   "Optional boolean flags (default is false):\n"
   "base64:        Input data is base64 encoded.\n"
@@ -1634,12 +1636,14 @@ op_encrypt (cjson_t request, cjson_t result)
   char **signing_patterns = NULL;
   int opt_mime;
   char *keystring = NULL;
+  char *file_name = NULL;
   gpgme_data_t input = NULL;
   gpgme_data_t output = NULL;
   int abool;
   gpgme_encrypt_flags_t encrypt_flags = 0;
   gpgme_ctx_t keylist_ctx = NULL;
   gpgme_key_t key = NULL;
+  cjson_t j_tmp = NULL;
 
   if ((err = get_protocol (request, &protocol)))
     goto leave;
@@ -1676,6 +1680,17 @@ op_encrypt (cjson_t request, cjson_t result)
   if (abool)
     encrypt_flags |= GPGME_ENCRYPT_WANT_ADDRESS;
 
+  j_tmp = cJSON_GetObjectItem (request, "file_name");
+  if (j_tmp && cjson_is_string (j_tmp))
+    {
+      file_name = j_tmp->valuestring;
+    }
+
+  j_tmp = cJSON_GetObjectItem (request, "sender");
+  if (j_tmp && cjson_is_string (j_tmp))
+    {
+      gpgme_set_sender (ctx, j_tmp->valuestring);
+    }
 
   /* Get the keys.  */
   err = get_keys (request, "keys", &keystring);
@@ -1724,6 +1739,10 @@ op_encrypt (cjson_t request, cjson_t result)
   if (opt_mime)
     gpgme_data_set_encoding (input, GPGME_DATA_ENCODING_MIME);
 
+  if (file_name)
+    {
+      gpgme_data_set_file_name (input, file_name);
+    }
 
   /* Create an output data object.  */
   err = gpgme_data_new (&output);
@@ -1765,6 +1784,8 @@ op_encrypt (cjson_t request, cjson_t result)
   xfree_array (signing_patterns);
   xfree (keystring);
   release_onetime_context (keylist_ctx);
+  /* Reset sender in case the context is reused */
+  gpgme_set_sender (ctx, NULL);
   gpgme_key_unref (key);
   gpgme_signers_clear (ctx);
   release_context (ctx);

-----------------------------------------------------------------------

Summary of changes:
 src/gpgme-json.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.