aboutsummaryrefslogtreecommitdiffstats
path: root/tests/run-decrypt.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2018-04-12 07:17:27 +0000
committerWerner Koch <[email protected]>2018-04-12 07:17:27 +0000
commitf7700a016926f0d8e9cb3c0337837deb7fe01079 (patch)
treecd622990455db03ba7b67cd1f1acd192eb38463c /tests/run-decrypt.c
parentqt: Add test for resetting config value (diff)
downloadgpgme-f7700a016926f0d8e9cb3c0337837deb7fe01079.tar.gz
gpgme-f7700a016926f0d8e9cb3c0337837deb7fe01079.zip
core: Add new context flag "no-symkey-cache".
* src/gpgme.c (gpgme_set_ctx_flag): Set flag. (gpgme_get_ctx_flag): Get flag. * src/context.h (struct gpgme_context): Add field no_symkey_cache. * src/engine-gpg.c (struct engine_gpg): Ditto. (gpg_set_engine_flags): Set flag. (build_argv): Pass option --no-symkey-cache to gpg. * tests/run-decrypt.c (print_result): Fix segv for symmetric messages. (main): New option --no-symkey-cache. * tests/run-encrypt.c (main): New option --no-symkey-cache. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tests/run-decrypt.c')
-rw-r--r--tests/run-decrypt.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/run-decrypt.c b/tests/run-decrypt.c
index f4c47544..a2e82a0e 100644
--- a/tests/run-decrypt.c
+++ b/tests/run-decrypt.c
@@ -60,7 +60,7 @@ print_result (gpgme_decrypt_result_t result)
if (result->session_key)
printf ("Session key: %s\n", result->session_key);
- for (recp = result->recipients; recp->next; recp = recp->next)
+ for (recp = result->recipients; recp && recp->next; recp = recp->next)
{
printf ("recipient %d\n", count++);
printf (" status ....: %s\n", gpgme_strerror (recp->status));
@@ -82,6 +82,7 @@ show_usage (int ex)
" --export-session-key show the session key\n"
" --override-session-key STRING use STRING as session key\n"
" --request-origin STRING use STRING as request origin\n"
+ " --no-symkey-cache disable the use of that cache\n"
" --unwrap remove only the encryption layer\n"
, stderr);
exit (ex);
@@ -104,6 +105,7 @@ main (int argc, char **argv)
int export_session_key = 0;
const char *override_session_key = NULL;
const char *request_origin = NULL;
+ int no_symkey_cache = 0;
int raw_output = 0;
if (argc)
@@ -160,6 +162,11 @@ main (int argc, char **argv)
request_origin = *argv;
argc--; argv++;
}
+ else if (!strcmp (*argv, "--no-symkey-cache"))
+ {
+ no_symkey_cache = 1;
+ argc--; argv++;
+ }
else if (!strcmp (*argv, "--unwrap"))
{
flags |= GPGME_DECRYPT_UNWRAP;
@@ -226,6 +233,17 @@ main (int argc, char **argv)
}
}
+ if (no_symkey_cache)
+ {
+ err = gpgme_set_ctx_flag (ctx, "no-symkey-cache", "1");
+ if (err)
+ {
+ fprintf (stderr, PGM ": error setting no-symkey-cache: %s\n",
+ gpgme_strerror (err));
+ exit (1);
+ }
+ }
+
err = gpgme_data_new_from_stream (&in, fp_in);
if (err)
{