Commit Graph

737 Commits

Author SHA1 Message Date
Werner Koch
0c29119e06
core,w32: Fix invocation of gpgtar
* src/dirinfo.c (EXEEXT_S): New.
(get_gpgconf_item): Append ".exe" to gpg-wks-client and gpgtar.

* src/gpgme-w32spawn.c (mystderr): Add code to ease debugging.
2023-04-17 14:05:35 +02:00
Ingo Klöcker
d256ba7cc5
w32: Always use UTF-8 for localized texts
* configure.ac: Define GPG_ERR_ENABLE_GETTEXT_MACROS.
* src/version.c (do_subsystem_inits) [W32]: Switch gettext to UTF-8.
--

On Windows, applications using GpgME can now rely on localized texts
returned by GpgME, e.g. the texts for error codes, to be UTF-8 encoded.
In particular, this saves a useless and possibly lossy conversion to
native encoding and back to UTF-8. On other OSes, where we use the
system provided gettext, we assume that UTF-8 is used nowadays.

GnuPG-bug-id: 5960
2023-04-04 12:11:15 +02:00
Werner Koch
34cc7daba1
core: Minor code cleanup.
* src/engine-gpg.c (build_argv): Remove superfluous tes.
--

gpg_error_from_syserror is guaranteed not to return 0 even if errno is
not set.
2023-03-27 16:56:29 +02:00
Ingo Klöcker
b608c084b9
core: Initialize error variable
* src/engine-gpg.c (build_argv): Initialize err.
--

Fixes-commit: fbce7deb3b
2023-03-27 16:49:24 +02:00
Werner Koch
6d21256c92
core,cpp: Add new key flags to gpgme_subkey_t
* src/gpgme.h.in (struct _gpgme_subkey): Add bit flags can_renc,
can_timestamp, adn is_group_owned. Reduce size of _unused.
* src/keylist.c (set_subkey_capability): Set them.
* tests/run-keylist.c (main): Print them.

* lang/cpp/src/key.h (Subkey::canRenc): New.
(Subkey::canTimestamp): New.
(Subkey::isGroupOwned): New.
* lang/cpp/src/key.cpp: Implement new methods.
(Subkey::isQualified): Print them.
(std::ostream &operator<<): Print them.
--

GnuPG-bug-id: 6395
2023-03-21 08:37:47 +01:00
Werner Koch
c1f6535f14
core: Also detect legacy X.509 v0 certificates.
* src/data-identify.c (basic_detection): Loose the detection of X.509
certs.
2023-03-08 15:54:54 +01:00
Werner Koch
9c5506fde7
core: Switch to logging via gpgrt
* src/debug.c (errfp): Remove.
(debug_init): Factor some code out to ...
(safe_to_use_debug_file): new.
(tid_log_callback): New.
(debug_init): Rewrite to make use of gpgrt logging.
(_gpgme_debug): Ditto.
(_gpgme_debug_end): Remove extra LF testing code.
* src/dirinfo.c (get_gpgconf_item): Remove now unneeded LFs.  Realign
output.
2023-02-10 11:12:52 +01:00
Werner Koch
c0da6f77c6
core: Update copyright notices
--
2023-02-10 11:12:52 +01:00
Ingo Klöcker
41dc3bd22a
core: Allow finalization of signature verification of unencrypted data
* src/decrypt-verify.c (decrypt_verify_status_handler): Call
_gpgme_verify_status_handler on EOF even if
_gpgme_decrypt_status_handler returned NO DATA error.

* tests/gpg/t-decrypt-verify.c (normal_signed_message): New.
(main): Add test with signed, but not encrypted data.
--

This allows the verify status handler to finalize the verification of
the last signature even if the decrypt status handler returned a NO DATA
error because the input data wasn't encrypted.

GnuPG-bug-id: 6368
2023-02-10 09:54:03 +01:00
Ingo Klöcker
7ad717f6ba
core: Make usage of input size hint compatible with gpgtar
* 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
2023-02-02 09:59:01 +01:00
Ingo Klöcker
7f541547fc
core: Allow usage of gpgtar also for new enough gpg 2.2
* 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
2023-02-02 09:47:10 +01:00
Werner Koch
5ab9c234d6
core,w32: More robust detection of GnuPG Desktop dir layout
* 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
2023-02-01 17:29:24 +01:00
Werner Koch
359378c5b3
json: New operation "identify" and convenience option --identify.
* 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.
--
2023-01-31 09:52:04 +01:00
Ingo Klöcker
48b11f5762
core: Use signature modes as flags
* 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
2023-01-30 12:49:11 +01:00
Ingo Klöcker
3580bb139b
core: Update required GnuPG version for new archive features
* 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
2023-01-26 09:52:11 +01:00
Ingo Klöcker
5b79b32397
core: Support usage of gpgtar for verifying a signed archive
* 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
2023-01-25 11:26:34 +01:00
Ingo Klöcker
95ea3bf831
core: Support usage of gpgtar for decrypting an encrypted archive
* 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
2023-01-24 12:32:23 +01:00
Ingo Klöcker
419adf41af
core: Allow setting the base directory when creating an archive
* 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-23 12:17:22 +01:00
Ingo Klöcker
29cfcd316d
core: Support usage of gpgtar for creating an encrypted signed archive
* 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-19 11:08:42 +01:00
Ingo Klöcker
0ca45e48b4
core: Support usage of gpgtar for creating a signed archive
* 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
2023-01-19 10:45:04 +01:00
Ingo Klöcker
aa201b0bb6
core: Fix --set-filename argument
* src/engine-gpg.c (gpg_encrypt): Append equal sign to argument name.
--

GnuPG-bug-id: 6342
2023-01-19 10:29:56 +01:00
Ingo Klöcker
5d8316da1d
core: Support usage of gpgtar for encryption
* 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
2023-01-18 11:48:02 +01:00
Ingo Klöcker
d56b3bc1cf
core: Defer adding --status-fd and --logger-fd to argument list
* 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
2023-01-18 10:54:39 +01:00
Ingo Klöcker
12e490d97f
core: Extend gpgme_get_dirinfo to return the gpgtar name
* 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
2023-01-18 10:30:17 +01:00
Ingo Klöcker
fbce7deb3b
core: Use "goto leave" pattern to clean up resources
* 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
2023-01-17 09:31:38 +01:00
Ingo Klöcker
984ff7e3a2
core: Do not add obsolete --no-sk-comments to command line
* 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
2023-01-16 12:28:13 +01:00
NIIBE Yutaka
f9cbf2c8a8
gpgme.m4: Fix AM_PATH_GPGME_PTHREAD.
* 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 <gniibe@fsij.org>
2022-11-25 15:37:23 +09:00
Ingo Klöcker
5903fa454a
core: Allow nullptr for key on card-edit
* 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.
2022-11-15 10:03:23 +01:00
NIIBE Yutaka
abd51848bd
gpgme.m4: Include _AM_PATH_GPGRT_CONFIG implementation.
* 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 <gniibe@fsij.org>
2022-11-15 13:40:57 +09:00
Ingo Klöcker
6bcfbb3498
core: Check for nullptr
* src/edit.c (interact_start, edit_start): Return error if key is null.
--

This prevents a crash further down the road.
2022-11-11 11:46:11 +01:00
Ingo Klöcker
4f874ea431
core: New context flag "no-auto-check-trustdb"
* 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
2022-11-04 10:38:41 +01:00
NIIBE Yutaka
9f55dceca0
build: Prefer gpgrt-config when available.
* 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 <gniibe@fsij.org>
2022-11-02 10:12:46 +09:00
Werner Koch
1c9694f8d5
core: New global flags "inst-type".
* 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.
2022-10-26 12:10:57 +02:00
Werner Koch
830e017e5d
core: Protect against a theoretical integer overflow in parsetlv.c
* 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.
2022-10-24 13:50:41 +02:00
Werner Koch
b1e5f3b183
core: Fix SIG_CREATED status parsing for 0x1F sigs
* 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
2022-09-29 09:59:27 +02:00
NIIBE Yutaka
fbd9407646
Fix for modern compiler.
* src/argparse.c (show_version): It's no args.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-09-15 13:45:35 +09:00
NIIBE Yutaka
80670f60ba Fix parsing import status for invalid fingerprint.
* src/import.c (parse_import): Handle invalid fingerprint case.

--

GnuPG-bug-id: 6187
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-09-07 11:27:32 +09:00
Ingo Klöcker
1522813888 build: Omit -I... and -L... for standard paths in pkgconfig file
* 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.
2022-08-22 19:09:54 +02:00
Andre Heinecke
5f51a9b458
w32: Add another fallback to look for gpgconf.exe
* 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
2022-08-12 15:16:36 +02:00
NIIBE Yutaka
02a2f35035 build: When no gpg-error-config, not install gpgme-config.
* 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 <gniibe@fsij.org>
2022-06-28 11:28:12 +09:00
Ingo Klöcker
5d19eb4ad5 core: Handle import status lines during keylist operation
* 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: f3ca57dfd7
GnuPG-bug-id: 5951
2022-06-09 15:30:14 +02:00
Ingo Klöcker
f72cf726ca core: Set SECRET flag of subkeys stored on smart cards
* 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
2022-05-06 09:34:18 +02:00
Ingo Klöcker
f3ca57dfd7 core: Handle import status lines during keylist operation
* 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
2022-05-04 14:23:42 +02:00
Ingo Klöcker
aff9aaac68 core: Support --locate-external-keys command of gpg
* 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
2022-04-27 16:57:17 +02:00
Ingo Klöcker
e21c3b559d core: Return BAD_PASSPHRASE error code on symmetric decryption.
* 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
2022-04-25 12:14:42 +02:00
NIIBE Yutaka
a36d71a8e3 core: Don't use internal __assuan functions.
* 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 <gniibe@fsij.org>
2022-04-05 14:42:59 +09:00
NIIBE Yutaka
110a375401 core: Don't keep using deprecated ath_ API.
* 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 <gniibe@fsij.org>
2022-04-05 14:25:00 +09:00
NIIBE Yutaka
b2a2158384 core: Support keylist mode for op_keylist_from_data.
* 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 <gniibe@fsij.org>
2022-03-16 16:19:50 +09:00
Ingo Klöcker
3c2cff74b5 core: New function gpgme_op_receive_keys
* 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
2022-02-03 15:56:30 +01:00
Ingo Klöcker
a527bd7cf5 core: Return an error for secret key export operations
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
2022-01-10 12:34:49 +01:00