aboutsummaryrefslogtreecommitdiffstats
path: root/src (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* core: Make usage of input size hint compatible with gpgtarIngo Klöcker2023-02-021-13/+8
| | | | | | | | * src/engine-gpg.c (add_input_size_hint): Use add_gpg_arg_with_value to add the --input-size-hint option. -- GnuPG-bug-id: 6342
* core: Allow usage of gpgtar also for new enough gpg 2.2Ingo Klöcker2023-02-021-19/+23
| | | | | | | | | | | | | | * src/engine-gpg.c (have_usable_gpgtar): New. (start): Always pass --status-fd to the called process. (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign, gpg_sign, gpg_verify): Use have_usable_gpgtar() to check for suitable gpg. -- The version check in start() is not needed because versions of gpg that are unsuitable for the usage of gpgtar are rejected already by the callers. GnuPG-bug-id: 6342
* core,w32: More robust detection of GnuPG Desktop dir layoutWerner Koch2023-02-011-20/+75
| | | | | | | | | | * src/w32-util.c (INST_TYPE_GPG4WIN, INST_TYPE_GPGDESK): New to replace the numeric constants. (find_version_file): New. (_gpgme_get_gpgconf_path): Guess a default for inst_type. -- GnuPG-bug-id: 6362
* json: New operation "identify" and convenience option --identify.Werner Koch2023-01-311-1/+126
| | | | | | | | | * src/gpgme-json.c (data_type_to_string): New. (op_identify): New. (process_request): Add to command list. (cmd_identify): New. (main): Add option --identify. --
* core: Use signature modes as flagsIngo Klöcker2023-01-308-26/+37
| | | | | | | | | | | | | | | | | | | | | | | | | * src/engine-backend.h (engine_ops.sign): Rename argument mode to flags. * src/engine-gpg.c (gpg_sign): Rename argument mode to flags. Check for invalid combination of flags. * src/engine-gpgsm.c (gpgsm_sign): Rename argument mode to flags. Check for unsupported flags. * src/engine-uiserver.c (gpgsm_sign): Rename argument mode to flags. Check for unsupported flags. * src/engine.c, src/engine.h (_gpgme_engine_op_sign): Rename argument mode to flags. * src/gpgme.h.in (GPGME_SIG_MODE_ARCHIVE): Change value to 4. (gpgme_op_sign_start, gpgme_op_sign): Rename argument mode to flags. * src/sign.c (sign_start): Rename argument mode to flags. Adjust check for invalid flags. (gpgme_op_sign_start, gpgme_op_sign): Rename argument mode to flags. -- Using the signature mode constants as flags is more natural, even if currently all flags are mutually exclusive, because archives are signed with a normal signature. GnuPG-bug-id: 6342
* core: Update required GnuPG version for new archive featuresIngo Klöcker2023-01-261-5/+5
| | | | | | | | | | | * src/engine-gpg.c (gpg_decrypt, gpg_encrypt, gpg_encrypt_sign, gpg_sign, gpg_verify): Require gpg 2.4.1. -- To work properly the archive feature needs a fix added in GnuPG 2.4.1. GnuPG-bug-id: 6342
* core: Support usage of gpgtar for verifying a signed archiveIngo Klöcker2023-01-2510-31/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/gpgme.h.in (gpgme_verify_flags_t): New enum. (GPGME_VERIFY_ARCHIVE): New const. (gpgme_op_verify_ext_start): New func. (gpgme_op_verify_ext): New func. * src/gpgme.def, src/libgpgme.vers: Add new functions. * src/verify.c (gpgme_op_verify_ext_start): New. (gpgme_op_verify_ext): New. (verify_start): Add arg FLAGS. Pass the flags to _gpgme_engine_op_verify. (gpgme_op_verify_start): Call gpgme_op_verify_ext_start with 0 for FLAGS. (gpgme_op_verify): Call gpgme_op_verify_ext with 0 for FLAGS. * src/engine.c, src/engine.h (_gpgme_engine_op_verify): Add arg FLAGS. * src/engine-backend.h (struct engine_ops): Add FLAGS to 'verify'. * src/engine-gpg.c (gpg_verify): Add arg FLAGS. Set use_gpgtar engine flag if GPGME_VERIFY_ARCHIVE flag is set. Check for new enough gpg. Use 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_verify): Add arg FLAGS. Return error if GPGME_VERIFY_ARCHIVE flag is set. * src/engine-uiserver.c (uiserver_verify): Ditto. * tests/run-verify.c (show_usage): New options --archive, --directory, and --diagnostics. (main): Parse new options. Verify and extract with gpgtar if --archive is given. Set file name of output data to value of --directory option. Print stderr of gpg/gpgtar if --diagnostics is given. -- GnuPG-bug-id: 6342
* core: Support usage of gpgtar for decrypting an encrypted archiveIngo Klöcker2023-01-242-20/+48
| | | | | | | | | | | | | | | | | | * src/gpgme.h.in (GPGME_DECRYPT_ARCHIVE): New decryption flag. * src/engine-gpg.c (gpg_decrypt): Set use_gpgtar engine flag if GPGME_DECRYPT_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. * tests/run-decrypt.c (show_usage): New options --archive and --directory. (main): Parse new options. Decrypt with gpgtar if --archive is given. Set file name of output data to value of --directory option. -- GnuPG-bug-id: 6342
* core: Allow setting the base directory when creating an archiveIngo Klöcker2023-01-231-16/+30
| | | | | | | | | | | | | * 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
* core: Support usage of gpgtar for creating an encrypted signed archiveIngo Klöcker2023-01-191-15/+35
| | | | | | | | | | | | | | | | | | | | | | * 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
* core: Support usage of gpgtar for creating a signed archiveIngo Klöcker2023-01-193-31/+44
| | | | | | | | | | | | | | | | | | | | | | | | | * src/gpgme.h.in (GPGME_SIG_MODE_ARCHIVE): New signature mode. * src/engine-gpg.c (append_args_from_sender, append_args_from_sig_notations): Use add_gpg_arg_with_value for gpg-only options with a value. (gpg_sign): Set use_gpgtar engine flag if GPGME_SIG_MODE_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. * src/sign.c (sign_start): Add GPGME_SIG_MODE_ARCHIVE as valid mode. * tests/run-sign.c (show_usage): New options --archive and --diagnostics. (main): Parse new options. Sign with gpgtar if --archive is given. Print stderr of gpg/gpgtar if --diagnostics is given. -- With this change the gpgme_op_sign* functions get support for creating a signed archive from files and/or directories passed as NUL-separated list in the "in" data with gpgtar. GnuPG-bug-id: 6342
* core: Fix --set-filename argumentIngo Klöcker2023-01-191-1/+1
| | | | | | | * src/engine-gpg.c (gpg_encrypt): Append equal sign to argument name. -- GnuPG-bug-id: 6342
* core: Support usage of gpgtar for encryptionIngo Klöcker2023-01-184-79/+222
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* core: Defer adding --status-fd and --logger-fd to argument listIngo Klöcker2023-01-181-41/+60
| | | | | | | | | | | | | | | * src/engine-gpg.c (_append_to_arglist, _prepend_to_arglist): New. (_add_arg): Use _append_to_arglist and _prepend_to_arglist. (add_data_ext): New. Extends add_data. (add_data): Uses add_data_ext. (gpg_new): Do not add --status-fd and --logger-fd to argument list. (start): Prepend --logger-fd and --status-fd to the argument list. -- This change makes it possible to handle those two arguments differently if gpgtar is used instead of gpg. GnuPG-bug-id: 6342
* core: Extend gpgme_get_dirinfo to return the gpgtar nameIngo Klöcker2023-01-182-0/+20
| | | | | | | | | | | | | * src/dirinfo.c (WANT_GPGTAR_NAME): New. (dirinfo): Add field gpgtar_name. (get_gpgconf_item): Build gpgtar_name on demand and return it. (_gpgme_get_default_gpgtar_name) : New. (gpgme_get_dirinfo): New value "gpgtar-name" for WHAT. * src/util.h (_gpgme_get_default_gpgtar_name): New. * tests/t-engine-info.c (main): Add gpgtar-name to the output. GnuPG-bug-id: 6342
* core: Use "goto leave" pattern to clean up resourcesIngo Klöcker2023-01-171-68/+62
| | | | | | | | | | | * src/engine-gpg.c (build_argv): Initialize fd_data_map and argv. Goto leave on error. Free fd_data_map and argv on error. -- This will make it easier to add an additional "--with-gpg-args" option where needed. GnuPG-bug-id: 6342
* core: Do not add obsolete --no-sk-comments to command lineIngo Klöcker2023-01-161-11/+0
| | | | | | | | | * src/engine-gpg.c (build_argv): Don't add "--no-sk-comments" to argv. -- This option is a no-op since 1.4.3 and 1.4.23 is the latest 1.4 release. GnuPG-bug-id: 6342
* gpgme.m4: Fix AM_PATH_GPGME_PTHREAD.NIIBE Yutaka2022-11-251-21/+24
| | | | | | | | | | * src/gpgme.m4 (AM_PATH_GPGME_PTHREAD): It's deprecated, since gpgme supports threads and GNU C library has integrated pthread features. -- GnuPG-bug-id: 6285 Signed-off-by: NIIBE Yutaka <[email protected]>
* core: Allow nullptr for key on card-editIngo Klöcker2022-11-151-3/+4
| | | | | | | | * src/edit.c (interact_start, edit_start): Return error if key is null on edit-key. -- In case of card-edit, key is typically null.
* gpgme.m4: Include _AM_PATH_GPGRT_CONFIG implementation.NIIBE Yutaka2022-11-151-6/+95
| | | | | | | | | | * src/gpgme.m4 (_AM_PATH_GPGRT_CONFIG): New. (_AM_PATH_GPGME_CONFIG): Require _AM_PATH_GPGRT_CONFIG. -- GnuPG-bug-id: 6273 Signed-off-by: NIIBE Yutaka <[email protected]>
* core: Check for nullptrIngo Klöcker2022-11-111-2/+2
| | | | | | | * src/edit.c (interact_start, edit_start): Return error if key is null. -- This prevents a crash further down the road.
* core: New context flag "no-auto-check-trustdb"Ingo Klöcker2022-11-043-0/+29
| | | | | | | | | | | | | | | | | * src/context.h (gpgme_context): Add field no_auto_check_trustdb. * src/gpgme.c (gpgme_set_ctx_flag, gpgme_get_ctx_flag): Add flag "no-auto-check-trustdb". * src/engine-gpg.c (engine_gpg): Add flags.no_auto_check_trustdb. (gpg_set_engine_flags): Set the flag. (build_argv): Pass option to gpg. * tests/run-keylist.c (show_usage, main): Add option --no-trust-check. -- This makes the --no-auto-check-trustdb option available in the GPGME API to disable the potentially expensive automatic trust database check. GnuPG-bug-id: 6261
* build: Prefer gpgrt-config when available.NIIBE Yutaka2022-11-021-2/+2
| | | | | | | | | | | | * src/gpgme.m4: Overriding the decision by --with-gpgme-prefix, use gpgrt-config gpgme when gpgrt-config is available. -- This may offer better migration. GnuPG-bug-id: 5034 Signed-off-by: NIIBE Yutaka <[email protected]>
* core: New global flags "inst-type".Werner Koch2022-10-264-4/+61
| | | | | | | | | | | | | | * src/gpgme.c (gpgme_set_global_flag): Add flag "inst-type". * src/w32-util.c (_gpgme_set_get_inst_type): New. (INST_TYPE_GPG4WIN_DIR): New. (INST_TYPE_GPGDESK_DIR): New. (_gpgme_get_gpgconf_path): Implement this flag. Replace fixed strings by the macros. * src/posix-util.c (_gpgme_set_get_inst_type): New dummy. -- This is intended for use by Kleopatra to reliable find the expected GnuPG installation.
* core: Protect against a theoretical integer overflow in parsetlv.cWerner Koch2022-10-241-0/+3
| | | | | | | | * src/parsetlv.c (_gpgme_parse_tlv): Detect integer overflow. -- Although there is no concrete case where we use for example (to.nhdr+ti.length), it feels safer to protect against this anyway.
* core: Fix SIG_CREATED status parsing for 0x1F sigsWerner Koch2022-09-291-0/+9
| | | | | | | | | | * src/sign.c (parse_sig_created): Special case the rfc4880 "1F" status. -- This has always been wrong but we can't simply force strtol to assume hex. Patch compiles but has received no specific test. For details see GnuPG-bug-id: 6223
* Fix for modern compiler.NIIBE Yutaka2022-09-151-1/+1
| | | | | | | | * src/argparse.c (show_version): It's no args. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* Fix parsing import status for invalid fingerprint.NIIBE Yutaka2022-09-071-5/+10
| | | | | | | | | * src/import.c (parse_import): Handle invalid fingerprint case. -- GnuPG-bug-id: 6187 Signed-off-by: NIIBE Yutaka <[email protected]>
* build: Omit -I... and -L... for standard paths in pkgconfig fileIngo Klöcker2022-08-221-2/+2
| | | | | | | | | | | | | | | | * configure.ac (GPGME_CONFIG_CFLAGS): Prefix with -I${includedir} for non-standard include paths. (GPGME_CONFIG_LIBS): Prefix with -L${libdir} for non-standard library paths. * src/gpgme.pc.in (Cflags): Remove hard-coded -I${includedir}. (Libs): Remove hard-coded -L${libdir}. -- This helps prevent problems when building/linking something that depends on gpgme (installed in standard path) and some other library (installed in a standard path and a custom path). See T6136 for related changes in libgpg-error.
* w32: Add another fallback to look for gpgconf.exeAndre Heinecke2022-08-121-2/+10
| | | | | | | | | | | | | | | | | * src/w32-util.c (_gpgme_get_gpgconf_path): Add fallback for GnuPG VS-Desktop install scheme. -- GnuPG VS-Desktop has the install layout: %PROGRAMFILES%\GnuPG VS-Desktop\bin\libgpgme.dll %PROGRAMFILES%\GnuPG VS-Desktop\GnuPG\bin\gpgconf.exe This fallback is of course only required if the registry string pointing to the correct install directory is broken. GnuPG-Bug-Id: T6131
* build: When no gpg-error-config, not install gpgme-config.NIIBE Yutaka2022-06-281-0/+4
| | | | | | | | | | | | | | * configure.ac (USE_GPGRT_CONFIG): New. * src/Makefile.am [USE_GPGRT_CONFIG]: Conditionalize the install of gpgme-config. -- When system will migrate use of gpgrt-config and removal of gpg-error-config, gpgme-config will not be installed (but use gpgme.pc by gpgrt-config). Signed-off-by: NIIBE Yutaka <[email protected]>
* core: Handle import status lines during keylist operationIngo Klöcker2022-06-091-0/+4
| | | | | | | | | | | | * src/keylist.c (gpgme_op_keylist_from_data_start): Call _gpgme_op_import_init_result. -- This fixes a crash when importing keys from data. Initializing the import result was missing for this keylist operation. Fixes-commit: f3ca57dfd7af19f9b2fd01616a81dc889707a4d3 GnuPG-bug-id: 5951
* core: Set SECRET flag of subkeys stored on smart cardsIngo Klöcker2022-05-061-0/+1
| | | | | | | | | | | | | * src/keylist.c (parse_sec_field15): Set SECRET flag. -- Explicitly setting the SECRET flag for subkeys stored on smart cards makes sure that the flag is also set if GPGME_KEYLIST_MODE_WITH_SECRET is used when listing OpenPGP keys (as documented in the API documentation). If secret keys are listed, then the flag is already set when the packet type is parsed. GnuPG-bug-id: 5965
* core: Handle import status lines during keylist operationIngo Klöcker2022-05-043-23/+55
| | | | | | | | | | | | | | | | | | | | | | * src/import.c (import_status_handler): Rename to ... (_gpgme_import_status_handler): this. Make non-static. (_gpgme_op_import_init_result): New. (_gpgme_op_import_start, _gpgme_op_import_keys_start, _gpgme_op_receive_keys_start): Call _gpgme_op_import_init_result. * src/keylist.c (keylist_status_handler): Call _gpgme_import_status_handler to handle import status lines. (gpgme_op_keylist_start, gpgme_op_keylist_ext_start): Call _gpgme_op_import_init_result. * src/ops.h (_gpgme_op_import_init_result, _gpgme_import_status_handler): New prototypes. -- If a keylist operation with keylist mode GPGME_KEYLIST_MODE_LOCATE is run, then gpg emits import status lines. Handling those status lines allows users to retrieve the result of a --locate-(external)-keys command. GnuPG-bug-id: 5951
* core: Support --locate-external-keys command of gpgIngo Klöcker2022-04-275-2/+20
| | | | | | | | | | | | | | * src/gpgme.h.in (GPGME_KEYLIST_MODE_FORCE_EXTERN): New. (GPGME_KEYLIST_MODE_LOCATE_EXTERNAL): New. * src/gpgme.c (gpgme_set_keylist_mode): Check for invalid mode. * src/engine-gpg.c (gpg_keylist_build_options): Use "--locate-external-keys" instead of "--locate-keys" if flag is set. * src/gpgme-json.c (op_keylist): New flag "force-extern". * src/gpgme-tool.c (gt_get_keylist_mode, cmd_keylist_mode): Handle new mode. -- GnuPG-bug-id: 5951
* core: Return BAD_PASSPHRASE error code on symmetric decryption.Ingo Klöcker2022-04-251-2/+21
| | | | | | | | | | | | | * src/decrypt.c (op_data_t): Add field symdecrypt_failed. (parse_status_error): Handle BAD_PASSPHRASE error code. (_gpgme_decrypt_status_handler): Consult new field. -- Return a bad passphrase error if the failure during symmetric decryption is likely caused by the user entering a wrong passphrase. The special error code of a failed public key decryption takes precedence. GnuPG-bug-id: 5939
* core: Don't use internal __assuan functions.NIIBE Yutaka2022-04-051-4/+28
| | | | | | | | | | * configure.ac (nanosleep): Detect. * src/assuan-support.c: Don't use __assuan_usleep. (my_socketpair): Don't use __assuan_socketpair. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* core: Don't keep using deprecated ath_ API.NIIBE Yutaka2022-04-052-11/+23
| | | | | | | | | | | | | | | | | * src/posix-io.c: Don't include ath.h. (_gpgme_io_read): Call read directly. (_gpgme_io_write): Call write directly. (_gpgme_io_waitpid): Call waitpid directly. (_gpgme_io_select_select): Call select directly. (_gpgme_io_recvmsg): Call recvmsg directly. (_gpgme_io_sendmsg): Call sendmsg directly. (_gpgme_io_connect): Call connect directly. * src/assuan-support.c: Don't include ath.h. (my_waitpid): Call waitpid directly. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* core: Support keylist mode for op_keylist_from_data.NIIBE Yutaka2022-03-165-5/+11
| | | | | | | | | | | | | | * src/engine-backend.h (keylist_data): Add MODE argument. * src/engine-gpg.c (gpg_keylist_data): Add MODE argument. * src/engine.c (_gpgme_engine_op_keylist_data): Likewise. * src/engine.h (_gpgme_engine_op_keylist_data): Declaration. * src/keylist.c (gpgme_op_keylist_from_data_start): Call _gpgme_engine_op_keylist_data with ctx->keylist_mode. -- GnuPG-bug-id: 5438 Signed-off-by: NIIBE Yutaka <[email protected]>
* core: New function gpgme_op_receive_keysIngo Klöcker2022-02-039-12/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | * src/gpgme.h.in (gpgme_op_receive_keys_start, gpgme_op_receive_keys): New. * src/gpgme.def, src/libgpgme.vers: Add them. * src/engine-backend.h (struct engine_ops): Add arg keyids to field 'import'. * src/engine.h, src/engine.c (_gpgme_engine_op_import): Add arg keyids. * src/engine.c (_gpgme_engine_op_import): Forward new arg keyids. * src/import.c: (_gpgme_op_import_start, _gpgme_op_import_keys_start): Pass NULL to new arg of _gpgme_op_import_start. (_gpgme_op_receive_keys_start, gpgme_op_receive_keys_start, gpgme_op_receive_keys): New. * src/engine-gpg.c (gpg_import): Add arg keyids. Extend check for valid arguments. Build command line if keyids are given. * src/engine-gpgsm.c (gpgsm_import): Add arg keyids. Return error if keyids is not NULL. tests/run-receive-keys.c: New. tests/Makefile.am (noinst_PROGRAMS): Add new test runner. -- The new function allows importing keys given by their key ids or fingerprints from a keyserver (like gpg's --recv-keys command). GnuPG-bug-id: 5808
* core: Return an error for secret key export operationsIngo Klöcker2022-01-101-1/+2
| | | | | | | | | | | src/export.c (export_status_handler): Handle "export_keys.secret". -- This allows callers of the synchronous export operations to react properly to errors (e.g. wrong passphrase) during the export of secret keys. GnuPG-bug-id: 5766
* core: Add new option --secret-subkey to help texts.Ingo Klöcker2022-01-041-1/+2
| | | | | | | | * src/gpgme-tool.c (hlp_export): Add new option. * tests/run-export.c (show_usage): Print new option. -- GnuPG-bug-id: 5757
* core: New export mode to export secret subkeys.Ingo Klöcker2022-01-044-4/+23
| | | | | | | | | | | | | | | | | | | * src/gpgme.h.in (GPGME_EXPORT_MODE_SECRET_SUBKEY): New. * src/export.c (check_mode): Allow new mode and check for invalid combinations. (export_keys_start): Return error if new mode flag is set. * src/engine-gpg.c (export_common): Implement. * src/gpgme-tool.c (cmd_export): New option --secret-subkey. * tests/run-export.c (main): New option --secret-subkey. -- This adds support for exporting secret subkeys (via gpg's --export-secret-subkeys) to gpgme_op_export[_ext][_start]. The flag is not supported by gpgme_op_export_keys[_start] because there is no way to specify which subkey(s) to export with these functions. GnuPG-bug-id: 5757
* core: Check for unsupported export mode flagsIngo Klöcker2022-01-041-0/+12
| | | | | | | | | | | src/engine-gpgsm.c (gpgsm_export, gpgsm_export_ext): Return error if an unsupported mode flag is set. -- The minimal mode flag has no effect for X.509 certificates, but we still treat it as supported (as documented in the API documentation). GnuPG-bug-id: 5757
* core: Check for combination of ssh mode with other mode flagsIngo Klöcker2022-01-041-0/+10
| | | | | | | | | | * src/export.c (check_mode): Return error if ssh mode is combined with another mode flag. -- The SSH mode flag cannot be used in combination with other flags. GnuPG-bug-id: 5757
* core: Factor out the check for valid export mode flags.Ingo Klöcker2022-01-041-38/+22
| | | | | | | | * src/export.c (check_mode): New. (export_start, export_ext_start): Call check_mode. -- GnuPG-bug-id: 5757
* core: Detect bad passphrase error on certificate importIngo Klöcker2021-12-221-1/+53
| | | | | | | | | | | | | | | | | | | | | * src/import.c (gpgme_op_import_result): Check fpr for NULL. (parse_error): New. (import_status_handler): Handle error status line. * doc/gpgme.texi (gpgme_import_status_t): Mention that fpr can be NULL. * tests/gpg/t-import.c (check_result): Check fpr for NULL. * tests/run-threaded.c (delete_impres): Check fpr for NULL. -- When importing an encrypted certificate a wrong passphrase may be entered. In this case gpgsm emits a status line with a bad passphrase error and an "invalid object" error. To make it possible for callers to handle a wrong passphrase error more gracefully, an import status with bad passphrase error is added to the import result for each status line with bad passphrase error. GnuPG-bug-id: 5713
* core: Allow setting import filters when importing keysIngo Klöcker2021-12-148-6/+47
| | | | | | | | | | | | | | | | | | | * src/context.h (struct gpgme_context): New field import_filter. * src/engine-backend.h (struct engine_ops): Add arg import_filter to field 'import'. * src/engine-gpg.c (gpg_import): Add arg import_filter and pass option --import-filter with argument value to gpg. Adjust all callers. * src/engine-gpgsm.c (gpgsm_import): Add dummy arg import_filter. * src/gpgme.c (gpgme_release): Free 'import_filter'. (gpgme_set_ctx_flag, gpgme_get_ctx_flag): New flag "import-filter". * tests/run-import.c (main): Add option --import-filter. -- This makes the --import-filter option available in the GPGME API for key imports. GnuPG-bug-id: 5739
* core: Set --key-origin option only if supported by gpgIngo Klöcker2021-12-141-1/+1
| | | | | | | | * src/engine-gpg.c (gpg_import): Do not pass --key-origin option to gpg if gpg is too old. -- GnuPG-bug-id: 5733
* core: Allow specifiying a key origin when importing keysIngo Klöcker2021-12-138-8/+34
| | | | | | | | | | | | | | | | | | | | * src/context.h (struct gpgme_context): New field key_origin. * src/engine-backend.h (struct engine_ops): Add arg key_origin to field 'import'. * src/engine-gpg.c (gpg_import): Add arg key_origin and pass option --key-origin with argument value to gpg. Adjust all callers. * src/engine-gpgsm.c (gpgsm_import): Add dummy arg key_origin. * src/gpgme.c (gpgme_release): Free 'key_origin'. (gpgme_set_ctx_flag, gpgme_get_ctx_flag): New flag "key-origin". * tests/run-import.c (main): Add option --key-origin. * tests/gpg/t-import.c (main): Set and verify key origin. -- This makes the --key-origin option available in the GPGME API for key imports. GnuPG-bug-id: 5733