aboutsummaryrefslogtreecommitdiffstats
path: root/tests/run-encrypt.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2024-09-09core: New encryption flags GPGME_ENCRYPT_ADD_RECP and _CHG_RECP.Werner Koch1-0/+14
* src/gpgme.h.in (GPGME_ENCRYPT_ADD_RECP, GPGME_ENCRYPT_CHG_RECP): New flag values. * src/engine-gpg.c (have_cmd_modify_recipients): New. (gpg_encrypt): Check availability of the feature and prepare command. * tests/run-encrypt.c (main): New options --add-recipients and --change-recipients. -- GnuPG-bug-id: 1825
2023-12-19core: Support direct encryption of file with gpgIngo Klöcker1-0/+15
* 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
2023-08-31Support GPGME_ENCRYPT_ALWAYS_TRUST also for S/MIME.Werner Koch1-1/+7
* src/engine-gpgsm.c (gpgsm_encrypt): Send the always-trust options. * tests/run-encrypt.c: Add option --always-trust. -- Note that the run-encrypt test tool used to assume always-trust for OpenPGP since 1.7.0 This bug has also been fixed by introducing the explicit option. GnuPG-bug-id: 6559
2023-06-19core: Support writing the sign/encrypt output directly to a fileIngo Klöcker1-3/+21
* src/engine-gpg.c (gpg_encrypt): Pass output file name to gpg if output has file name set. (gpg_encrypt_sign): Ditto. (gpg_sign): Ditto. * tests/run-encrypt.c (show_usage): New option --output. (main): Parse new option. Set file name on output if --output is given. Do not print output if --output is given. * tests/run-sign.c (show_usage): New option --output. (main): Parse new option. Set file name on output if --output is given. Do not print output if --output is given. -- This change makes it possible to tell gpg (and gpgtar) to write the output (i.e. the signed/encrypted data or the signature or the created archive) directly to a file with given file name instead of piping the output back to gpgme. GnuPG-bug-id: 6530
2023-06-15tests: Add option --cancel to run-encrypt.Werner Koch1-3/+29
* tests/run-encrypt.c (cancel_after_progress): New. (progress_cb): Take care of it. (main): Add option --cancel. -- This tool may now be used to test gpgme_cancel_async. Releated to GnuPG-bug-id: 6534
2023-01-23core: Allow setting the base directory when creating an archiveIngo Klöcker1-0/+16
* src/engine-gpg.c (gpg_encrypt, gpg_encrypt_sign, gpg_sign): Pass file name set in data with --directory option to gpgtar. * tests/run-encrypt.c (show_usage): New option --directory. (main): Parse new option. Set file name of input data to option value. * tests/run-sign.c (show_usage): New option --directory. (main): Parse new option. Set file name of input data to option value. -- GnuPG-bug-id: 6342
2023-01-19core: Support usage of gpgtar for creating an encrypted signed archiveIngo Klöcker1-7/+47
* src/engine-gpg.c (gpg_encrypt_sign): Set use_gpgtar engine flag if GPGME_ENCRYPT_ARCHIVE mode is set. Check for new enough gpg. Use add_gpg_arg_with_value for gpg-only options with a value and add_gpg_arg for gpg-only options without a value. Set extra options for gpgtar and pass input data to stdin when using gpgtar. * tests/run-encrypt.c (print_result): Rename to print_encrypt_result. Print header. (print_sign_result): New. (show_usage): New option --sign. (main): Parse new option. Sign and encrypt --sign is given. Print results of signing additionally to results of encryption. -- With this change the gpgme_op_encrypt_sign* functions get support for creating an encrypted and signed archive from files and/or directories passed as NUL-separated list in the "plain" data with gpgtar. GnuPG-bug-id: 6342
2023-01-18core: Support usage of gpgtar for encryptionIngo Klöcker1-37/+80
* src/gpgme.h.in (GPGME_ENCRYPT_ARCHIVE): New encryption flag. * src/engine-gpg.c (arg_and_data_s): New field gpg_arg. (engine_gpg): New flag use_gpgtar. (_add_arg): Add argument gpg_arg and set it. (add_arg_ext, add_arg_with_locp, add_arg, add_arg_pfx, add_arg_len): Adjust call of _add_arg. (add_arg_with_locp): Add argument front. (add_gpg_arg, add_gpg_arg_with_value): New. (gpg_new): Use add_gpg_arg_with_value for gpg-only options with a value and add_gpg_arg for gpg-only options without. (build_argv): Consider usage of gpgtar when counting arguments to pass to gpg/gpgtar. Prepend "--gpg-args" to all gpg-only arguments if gpgtar is used. (start): Set program to use. Read diagnostics output from stderr when using gpgtar. Do not pass --status-fd to gpgtar for gpg < 2.4.1. Use add_gpg_arg_with_value for --lc-ctype and --lc-messages. (gpg_encrypt): Set use_gpgtar engine flag if GPGME_ENCRYPT_ARCHIVE flag is set. Check for new enough gpg and incompatible flags. Use add_gpg_arg_with_value for gpg-only options with a value and add_gpg_arg for gpg-only options without a value. Set extra options for gpgtar and pass input data to stdin when using gpgtar. * 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 options --archive and --diagnostics. (main): Parse new options. Encrypt with gpgtar if --archive is given. Print stderr of gpg/gpgtar if --diagnostics is given. -- With this change the gpgme_op_encrypt* functions get support for encrypting a list of files and/or directories passed as NUL-separated list in "plain" data with gpgtar. GnuPG-bug-id: 6342
2018-11-16Add SPDX identifiers to most source filesWerner Koch1-1/+2
-- Signed-off-by: Werner Koch <[email protected]>
2018-04-17core: Add extended versions of the encrypt functions.Werner Koch1-11/+29
* src/gpgme.h.in (gpgme_op_encrypt_ext_start) New. (gpgme_op_encrypt_ext): New. (gpgme_op_encrypt_sign_ext_start): New. (gpgme_op_encrypt_sign_ext): New. * src/libgpgme.vers, tests/run-encrypt.c: Add them. * src/encrypt.c (encrypt_start): Add arg recpstring. (gpgme_op_encrypt): Factor code out to ... (gpgme_op_encrypt_ext): new function with new arg recpstring. (gpgme_op_encrypt_start): Factor code out to ... (gpgme_op_encrypt_ext_start): new function with new arg recpstring. * src/encrypt-sign.c (encrypt_sign_start): Add arg recpstring. (gpgme_op_encrypt_sign): Factor code out to ... (gpgme_op_encrypt_sign_ext): new function with new arg recpstring. (gpgme_op_encrypt_sign_start): Factor code out to ... (gpgme_op_encrypt_sign_ext_start): new function with new arg recpstring. * src/engine-backend.h (struct engine_ops): Change fields encrypt and encrypt_sign. * src/engine.c (_gpgme_engine_op_encrypt): Add arg recpstring and pass to engine. (_gpgme_engine_op_encrypt_sign): Ditto. * src/engine-gpg.c (append_args_from_recipients_string): New. (gpg_encrypt): Add arg recpstring and call new function as needed. (gpg_encrypt_sign): Ditto. * src/engine-gpgsm.c (set_recipients_from_string): New. (gpgsm_encrypt): Add arg recpstring and call new function as needed. * src/engine-uiserver.c (set_recipients_from_string): New. (uiserver_encrypt): Add arg recpstring and call new function as needed. * tests/run-encrypt.c (xstrdup): New. (main): Add option --keystring. * src/gpgme-json.c (get_keys): Simplify. (op_encrypt): Modify to make use of the extended encrypt function. -- This new feature can be used to avoid the need for a key lookup and thus several extra calls to the backend. Note that run-test uses a semicolon as delimiter because that make testing the feature on the command line much easier. Signed-off-by: Werner Koch <[email protected]>
2018-04-12core: Add new context flag "no-symkey-cache".Werner Koch1-11/+28
* 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]>
2017-03-24core: New flags GPGME_DECRYPT_UNWRAP and GPGME_ENCRYPT_WRAP.Werner Koch1-0/+6
* src/gpgme.h.in (GPGME_ENCRYPT_WRAP): New const. (gpgme_decrypt_flags_t): New enum. (GPGME_DECRYPT_VERIFY): New const (GPGME_DECRYPT_UNWRAP): New const (gpgme_op_decrypt_ext_start): New func. (gpgme_op_decrypt_ext): New func. * src/decrypt-verify.c (gpgme_op_decrypt_ext_start): New. (gpgme_op_decrypt_ext): New. (decrypt_verify_start): Add arg FLAGS. Replace call to engine_op_decrypt_verify by the plain decrypt with the flag set. (gpgme_op_decrypt_verify_start): Pass the flag. (gpgme_op_decrypt_verify): Pass the flag. * src/decrypt.c (decrypt_start): Rename to ... (_gpgme_decrypt_start): this. Add arg FLAGS. Pass FLAGS to engine_op_decrypt. (gpgme_op_decrypt_start): Adjust for chnage pass 0 for FLAG. (gpgme_op_decrypt_start): Ditto. * src/engine.c (_gpgme_engine_op_decrypt_verify): Remove. (_gpgme_engine_op_decrypt): Add arg FLAGS. * src/gpgme.def, src/libgpgme.vers: Add new functions. * src/engine-backend.h (struct engine_ops): Remove member 'decrypt_verify'. Add FLAGS to 'decrypt'. Adjust all initialization. * src/engine-uiserver.c (uiserver_decrypt): Remove. (uiserver_decrypt_verify): Remove. (_uiserver_decrypt): Rename to ... (uiserver_decrypt): this. Replace arg VERIFY by new arg FLAGS. * src/engine-gpg.c (gpg_decrypt): Support GPGME_DECRYPT_UNWRAP. (gpg_encrypt): Support GPGME_ENCRYPT_WRAP. * tests/run-decrypt.c (main): New option --unwrap. * tests/run-encrypt.c (main): New option --wrap. -- Manual testing of that wrap/unwrap feature can be done this way: ./run-encrypt --verbose --key Alice /etc/motd > x ./run-decrypt --verbose --unwrap x > y ./run-encrypt --verbose --key Bob --wrap y > z 1. The message was first encrypted to Alice. 2. Alice decrypts the message receiving a valid OpenPGP message. 3. Alice encrypt that message to Bob This will also work with encrypted and signed messages; the signature will be kept intact during re-encryption. Requires GnuPG 2.1.12. Signed-off-by: Werner Koch <[email protected]>
2017-03-21core: New encryption flag GPGME_ENCRYPT_THROW_KEYIDS.Werner Koch1-0/+6
* src/gpgme.h.in (GPGME_ENCRYPT_THROW_KEYIDS): New flag. * src/engine-gpg.c (gpg_encrypt): Implement flag (gpg_encrypt_sign): Implement flag. * tests/run-encrypt.c (main): New option --throw-keyids. -- It would be nice to also selectively hide recipients (that is gpg --hidden-recipient) but our API does not ye allow this because it is based on key objects. A possible way to implement that would be a API to set processing flags into a key but this is complicated due to the reference counting and thus the possibility that a key object is used by different context. Signed-off-by: Werner Koch <[email protected]>
2016-11-16doc: Replace http: by https: in core source files.Werner Koch1-1/+1
-- Signed-off-by: Werner Koch <[email protected]>
2016-08-12core: Make use of the "size-hint" in engine-gpg.Werner Koch1-2/+67
* src/engine-gpg.c: Include data.h. (add_input_size_hint): New. (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign, gpg_sign) (gpg_verify): Call new function, * tests/run-encrypt.c (status_cb): Print to stderr. (progress_cb): New.o (main): Add option --progress. Print full-status lines. Provide a size for the input data. Signed-off-by: Werner Koch <[email protected]>
2016-08-09core: Add support for mixed symmetric and asym encAndre Heinecke1-2/+12
* src/gpgme.h.in (gpgme_encrypt_flags_t): New flag GPGME_ENCRYPT_SYMMETRIC. * src/engine-gpg.c (gpg_encrypt): Also add --symmetric if the flag is given. * NEWS: Mention new flag. * tests/run-encrypt.c (show_usage): Extend for --symmetric. (main): Handle --symmetric. (main): Set passphrase_cb in loopback mode. (main): Fix encrypt call if no recipients are given. * tests/gpg/t-encrypt-mixed.c: New. * tests/gpg/Makefile.am (c_tests): Add new test. * doc/gpgme.texi: Document new flag.
2016-05-17tests: New maintenance helper run-encrypt.Werner Koch1-51/+46
* tests/run-encrypt.c: New. Signed-off-by: Werner Koch <[email protected]>
2015-08-25tests: Allow using run-sign to test loopback pinentry problems.Werner Koch1-0/+26
* tests/run-sign.c: Add options --status and --loopback.
2012-09-25Remove all trailing whitespace from source filesWerner Koch1-11/+11
-- Command used: sed -i 's,[ \t]*$,,' FILE
2009-11-03Prepare for a new protocol.Werner Koch1-3/+13
Comment clarification.
2009-08-06Fix detection of invalid signer keys.Werner Koch1-0/+187
Support the new INV_SGNR status code.