diff options
author | Ingo Klöcker <[email protected]> | 2023-12-14 09:59:47 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2023-12-19 12:07:45 +0000 |
commit | 0221d7f28a315d305409cf2dcae853c22ad94d31 (patch) | |
tree | f7ae74a09d54e224a69dd6689d30e79c643c02e7 /tests | |
parent | doc: Fix documentation for creating encrypted/signed archive (diff) | |
download | gpgme-0221d7f28a315d305409cf2dcae853c22ad94d31.tar.gz gpgme-0221d7f28a315d305409cf2dcae853c22ad94d31.zip |
core: Support direct encryption of file with gpg
* src/gpgme.h.in (GPGME_ENCRYPT_FILE): New encryption flag.
* src/engine-gpg.c (gpg_encrypt, gpg_encrypt_sign): Check for
incompatible flags. Pass filename instead of fd to gpg when new flag is
set.
* src/engine-gpgsm.c (gpgsm_encrypt): Return error if new flag is set.
* src/engine-uiserver.c (uiserver_encrypt): Ditto.
* tests/run-encrypt.c (show_usage): New option --direct-file-io.
(main): Parse new option. Make gpg read the input file itself if the
option is given.
--
With this change the gpgme_op_encrypt* and gpgme_op_encrypt_sign*
functions gain the possibility to make gpg read the data to (sign and)
encrypt 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-encrypt.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/run-encrypt.c b/tests/run-encrypt.c index 80c40729..8e8b559c 100644 --- a/tests/run-encrypt.c +++ b/tests/run-encrypt.c @@ -151,6 +151,7 @@ show_usage (int ex) " --no-symkey-cache disable the use of that cache\n" " --wrap assume input is valid OpenPGP message\n" " --symmetric encrypt symmetric (OpenPGP only)\n" + " --direct-file-io pass FILE instead of stream with content of FILE to backend\n" " --archive encrypt given file or directory into an archive\n" " --directory DIR switch to directory DIR before encrypting into an archive\n" " --output FILE write output to FILE instead of stdout\n" @@ -186,6 +187,7 @@ main (int argc, char **argv) int no_symkey_cache = 0; int diagnostics = 0; int sign = 0; + int direct_file_io = 0; if (argc) { argc--; argv++; } @@ -289,6 +291,11 @@ main (int argc, char **argv) no_symkey_cache = 1; argc--; argv++; } + else if (!strcmp (*argv, "--direct-file-io")) + { + direct_file_io = 1; + argc--; argv++; + } else if (!strcmp (*argv, "--archive")) { flags |= GPGME_ENCRYPT_ARCHIVE; @@ -378,6 +385,14 @@ main (int argc, char **argv) fail_if_err (err); } } + else if (direct_file_io) + { + flags |= GPGME_ENCRYPT_FILE; + err = gpgme_data_new (&in); + fail_if_err (err); + err = gpgme_data_set_file_name (in, *argv); + fail_if_err (err); + } else { err = gpgme_data_new_from_file (&in, *argv, 1); |