aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-03-17 16:22:51 +0000
committerWerner Koch <[email protected]>2020-03-17 16:24:21 +0000
commit3afa534645e3826c95e7c70d7ae61ffa2d63acec (patch)
treea7d2d0ece9d59dc8081cf44fa383db2f372a8835 /tests
parentpython: fix minor typo in howto (diff)
downloadgpgme-3afa534645e3826c95e7c70d7ae61ffa2d63acec.tar.gz
gpgme-3afa534645e3826c95e7c70d7ae61ffa2d63acec.zip
core: New context flags "include-key-block" and "auto-key-import".
* src/gpgme.c (gpgme_set_ctx_flag): Add flags "include-key-block" and "auto-key-import". (gpgme_get_ctx_flag): Ditto. * src/context.h (struct gpgme_context): Add flags include_key_block and auto_key_import. * src/engine-gpg.c (struct engine_gpg): Likewise. (gpg_set_engine_flags): Set the flags for gpg versions >= 2.2.20. (gpg_decrypt): Set option according to the new flags. (gpg_encrypt): Ditto. (gpg_encrypt_sign): Ditto. (gpg_sign): Ditto. (gpg_verify): Ditto. tests/run-verify: Add option --auto-key-import. tests/run-sign: add option --include-key-block. -- GnuPG-bug-id: 4856 Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/run-sign.c20
-rw-r--r--tests/run-verify.c20
2 files changed, 39 insertions, 1 deletions
diff --git a/tests/run-sign.c b/tests/run-sign.c
index 5576b8f5..55b2e482 100644
--- a/tests/run-sign.c
+++ b/tests/run-sign.c
@@ -85,6 +85,7 @@ show_usage (int ex)
" --loopback use a loopback pinentry\n"
" --key NAME use key NAME for signing\n"
" --sender MBOX use MBOX as sender address\n"
+ " --include-key-block use this option with gpg\n"
, stderr);
exit (ex);
}
@@ -103,6 +104,7 @@ main (int argc, char **argv)
gpgme_sign_result_t result;
int print_status = 0;
int use_loopback = 0;
+ int include_key_block = 0;
const char *sender = NULL;
const char *s;
@@ -165,6 +167,11 @@ main (int argc, char **argv)
use_loopback = 1;
argc--; argv++;
}
+ else if (!strcmp (*argv, "--include-key-block"))
+ {
+ include_key_block = 1;
+ argc--; argv++;
+ }
else if (!strncmp (*argv, "--", 2))
show_usage (1);
@@ -197,6 +204,8 @@ main (int argc, char **argv)
err = gpgme_get_key (ctx, key_string, &akey, 1);
if (err)
{
+ fprintf (stderr, PGM ": get key '%s' failed: %s\n",
+ key_string, gpg_strerror (err));
exit (1);
}
err = gpgme_signers_add (ctx, akey);
@@ -210,6 +219,17 @@ main (int argc, char **argv)
fail_if_err (err);
}
+ if (include_key_block)
+ {
+ err = gpgme_set_ctx_flag (ctx, "include-key-block", "1");
+ if (err)
+ {
+ fprintf (stderr, PGM ": error setting include-key-block: %s\n",
+ gpgme_strerror (err));
+ exit (1);
+ }
+ }
+
err = gpgme_data_new_from_file (&in, *argv, 1);
if (err)
{
diff --git a/tests/run-verify.c b/tests/run-verify.c
index 83a6533a..e42eb6bf 100644
--- a/tests/run-verify.c
+++ b/tests/run-verify.c
@@ -234,6 +234,7 @@ show_usage (int ex)
" --sender MBOX use MBOX as sender address\n"
" --repeat N repeat the operation N times\n"
" --auto-key-retrieve\n"
+ " --auto-key-import\n"
, stderr);
exit (ex);
}
@@ -248,6 +249,7 @@ main (int argc, char **argv)
int print_status = 0;
const char *sender = NULL;
int auto_key_retrieve = 0;
+ int auto_key_import = 0;
int repeats = 1;
if (argc)
@@ -304,7 +306,11 @@ main (int argc, char **argv)
auto_key_retrieve = 1;
argc--; argv++;
}
-
+ else if (!strcmp (*argv, "--auto-key-import"))
+ {
+ auto_key_import = 1;
+ argc--; argv++;
+ }
else if (!strncmp (*argv, "--", 2))
show_usage (1);
@@ -372,6 +378,18 @@ main (int argc, char **argv)
}
}
+ if (auto_key_import)
+ {
+ gpgme_set_ctx_flag (ctx, "auto-key-import", "1");
+ s = gpgme_get_ctx_flag (ctx, "auto-key-import");
+ if (!s || strcmp (s, "1"))
+ {
+ fprintf (stderr, PGM ": gpgme_get_ctx_flag failed for '%s'\n",
+ "auto-key-import");
+ exit (1);
+ }
+ }
+
if (sender)
{
err = gpgme_set_sender (ctx, sender);