diff options
| author | Ingo Klöcker <[email protected]> | 2023-12-15 10:05:19 +0100 |
|---|---|---|
| committer | Ingo Klöcker <[email protected]> | 2023-12-19 13:09:33 +0100 |
| commit | 963ace1f9f39f09fee522b996e05d42040b1f4b4 (patch) | |
| tree | 67a375f39ead00e24aea7082ed1163b0bd26c4b7 /tests | |
| parent | core: Support direct encryption of file with gpg (diff) | |
| download | gpgme-963ace1f9f39f09fee522b996e05d42040b1f4b4.tar.gz gpgme-963ace1f9f39f09fee522b996e05d42040b1f4b4.zip | |
core: Support direct signing of file with gpg
* src/gpgme.h.in (GPGME_SIG_MODE_FILE): New signature mode flag.
* src/engine-gpg.c (gpg_sign): Separate signature mode from additional
flags. Check for incompatible flags. Explicitly set output to stdout if
no output file is used. Pass filename instead of fd to gpg when new flag
is set.
* src/engine-gpgsm.c (gpgsm_sign): Return error if new flag is set.
* src/engine-uiserver.c (uiserver_sign): Ditto.
* src/sign.c (sign_start): Consider new flag on check for invalid flags.
* tests/run-sign.c (show_usage): New options --detach and
--direct-file-io.
(main): Parse new options. Create a detached signature if --detach is
given. Make gpg read the input file itself if --direct-file-io is given.
--
With this change the gpgme_op_sign* functions gain the possibility to
make gpg read the data to sign directly from a file instead of from an
input FD to which it is written by gpgme.
GnuPG-bug-id: 6550
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/run-sign.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/run-sign.c b/tests/run-sign.c index 07482dd5..c04fa819 100644 --- a/tests/run-sign.c +++ b/tests/run-sign.c @@ -87,6 +87,8 @@ show_usage (int ex) " --sender MBOX use MBOX as sender address\n" " --include-key-block use this option with gpg\n" " --clear create a clear text signature\n" + " --detach create a detached signature\n" + " --direct-file-io pass FILE instead of stream with content of FILE to backend\n" " --archive create a signed archive with the given file or directory\n" " --directory DIR switch to directory DIR before creating the archive\n" " --output FILE write output to FILE instead of stdout\n" @@ -113,6 +115,7 @@ main (int argc, char **argv) int use_loopback = 0; int include_key_block = 0; int diagnostics = 0; + int direct_file_io = 0; const char *sender = NULL; const char *s; @@ -185,6 +188,16 @@ main (int argc, char **argv) sigmode = GPGME_SIG_MODE_CLEAR; argc--; argv++; } + else if (!strcmp (*argv, "--detach")) + { + sigmode = GPGME_SIG_MODE_DETACH; + argc--; argv++; + } + else if (!strcmp (*argv, "--direct-file-io")) + { + direct_file_io = 1; + argc--; argv++; + } else if (!strcmp (*argv, "--archive")) { sigmode = GPGME_SIG_MODE_ARCHIVE; @@ -269,7 +282,15 @@ main (int argc, char **argv) } } - if (sigmode == GPGME_SIG_MODE_ARCHIVE) + if (direct_file_io) + { + sigmode |= GPGME_SIG_MODE_FILE; + err = gpgme_data_new (&in); + fail_if_err (err); + err = gpgme_data_set_file_name (in, *argv); + fail_if_err (err); + } + else if (sigmode == GPGME_SIG_MODE_ARCHIVE) { const char *path = *argv; err = gpgme_data_new_from_mem (&in, path, strlen (path), 0); |
