Commit Graph

3111 Commits

Author SHA1 Message Date
Daniel Kahn Gillmor
c4cf527ea2 gpg: Send --with-keygrip when listing keys
* src/engine-gpg.c (gpg_keylist_build_options): Always pass
--with-keygrip when listing keys.

--

Some older versions of GnuPG (at least gpg in version
2.2.12-1+deb10u1) appear to unilaterally emit the keygrip, and it's
certainly useful to know that programmatically it will always be
present in the output needed.

However, as of GnuPG 2.2.19-1, the following command does not emit the
keygrip for non-secret keys:

   gpg --with-colons --with-secret --list-keys

This change fixes tests/json/t-json by making the output comply with
tests/json/t-keylist-secret.out.json correctly.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
GnuPG-Bug-Id: 4820
2020-01-23 17:57:54 -05:00
Daniel Kahn Gillmor
f2aeb2563b tests/json: Bravo key does not have secret key material
* tests/json/t-keylist-secret.out.json: indicate correctly that the
"Bravo" test key does not have secret key material.

--

Some older versions of GnuPG are buggy, and will claim "secret: true"
for this key, even though the keyring in question has no secret key
material for it.

The underlying call to gpg looks something like:

    gpg --with-colons --with-secret --list-keys -- \
        alpha@example.net bravo@example.net

You can see the change in field 15 of the "pub" and "sub" output.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
GnuPG-Bug-Id: 4820
2020-01-23 17:57:20 -05:00
Andre Heinecke
39052913f2
core: Add MacOS fallbacks to look for binaries
* src/posix-util.c (find_executable): New.
(walk_path_str): Factored out from walk_path.
(walk_path): Replaced by find_executable.
(_gpgme_get_gpg_path, _gpgme_get_gpgconf_path): Use find_executable.

--
This should help to locate GnuPG on MacOS systems where
it is not part of the PATH environment variable and
should reduce the need to have fixed path known
at GPGME compile time.

mailvelope/issue699
2020-01-17 12:42:56 +01:00
Andre Heinecke
194272dbc3
cpp, qt: Use uidhash to select uids for signing
* lang/cpp/src/gpgsignkeyeditinteractor.cpp (action):
Use uidhash instead of number.
(GpgSignKeyEditInteractor::setKey): New.
* lang/cpp/src/gpgsignkeyeditinteractor.h: Update accordingly.
* lang/cpp/src/key.h, lang/cpp/src/key.cpp: Wrap uidhash.
* lang/qt/src/qgpgmesignkeyjob.cpp: Set the key.

--
Using the uidhash avoids problems when the user ids
on --edit-key are different ones then the uids
captured by gpgme when listing keys. Or if
they are in a different order. This can happen
with cached keys or keys with user attributes.
2019-12-13 18:06:00 +01:00
Werner Koch
5eeae535ee
core: Extend gpgme_user_id_t with uidhash member.
* src/gpgme.h.in (struct _gpgme_user_id): Add field 'uidhash'.
* src/key.c (gpgme_key_unref): Free it.
* src/keylist.c (keylist_colon_handler): Set it.
* tests/run-keylist.c (main): Print it.
--

The uidhash value is part of gpg's output since the year 2005.  This
now adds support to gpgme.  The application for uidhash is to select
a user id in an edit interactor: Instead of giving the number of the
user id, the uidhash value can be be used to avoid tracking the user
id numbers.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-12-13 15:11:00 +01:00
Andre Heinecke
7e7eaf4342
Revert "doc: Remove UI Server documentation"
This reverts commit 1b2ad3b73c.

--
Just removing the documentation was not the right way as
this is still in use.
2019-12-11 10:30:41 +01:00
Daniel Kahn Gillmor
ae4d7761a1 gpg: Avoid error diagnostics with --override-session-key when verifying
* src/engine-gpg.c (gpg_decrypt): only send --no-keyring when we are
not verifying.

--

Without this change, the signature verification would fail.  This
problem was introduced in bded8ebc59 in
an attempt to avoid an error when *not* verifying.  Clearly more test
suite coverage is needed to avoid introducing this sort of problem in
the future.

GnuPG-bug-id: 3464
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-12-06 10:41:44 +09:00
Daniel Kahn Gillmor
c0c97dbbe6 gpgme-tool: Fix help text for INCLUDE_CERTS.
* src/gpgme-tool.c (hlp_include_certs): added missing newline.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-12-03 18:42:07 -05:00
Werner Koch
d480a3c8f3
core,w32: Silence compiler warnings.
* src/w32-util.c (_gpgme_w32_cancel_synchronous_io): Add some casts.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-11-27 20:40:39 +01:00
Andre Heinecke
1b2ad3b73c
doc: Remove UI Server documentation
* doc/Makefile.am: Remove uiserver.texi
* doc/gpgme.texi: Remove UI-Server mentions.
* doc/uiserver.texi: Removed.

--
This prepares the removal of UI Server from implementing
applications like Kleopatra.
The only user of the UI Server is GpgEX and even that
does not need it at all and is better served with process
calls.

GnuPG-Bug-Id: T4030
2019-11-12 11:04:11 +01:00
NIIBE Yutaka
c493242007 qt,tests: Take care for old DSA key using deprecated digest algo.
* lang/qt/tests/t-remarks.cpp (initTestCase): Supply
allow-weak-key-signatures flag for GnuPG 2.3, which
normally rejects use of SHA1 digest.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2019-11-08 08:07:33 +09:00
Andre Heinecke
e7b5c6405d
qt, tests: Add check for supported versions
* lang/qt/tests/t-encrypt.cpp (decryptSupported): Moved to
t-support as loopbackSupported.
* lang/qt/tests/t-remarks.cpp: Check for loopbackSupported.
* lang/qt/tests/t-support.cpp, lang/qt/tests/t-support.h
(loopbackSupported): New.

--
This ensures that the tests do not fail with GnuPG 2.0.x
2019-11-06 09:21:02 +01:00
Andre Heinecke
024edbbd3c
qt, tests: Replace accidentally commited assert
* lang/qt/test/t-remarks.cpp (testRemarkReplaceSingleUIDExportable):
Use QVERIFY instead of assert.

--
An assert causes the temp directory not to be cleaned up. I
use this to analyze test failures.
If you want to see the tests home directory after a failure you
can just change a failing verify to an assert.
2019-11-06 09:12:09 +01:00
Andre Heinecke
a56f6015e9
qt,tests: Add test to add an exportable certify
* lang/qt/test/t-remarks.cpp (testRemarkReplaceSingleUIDExportable):
New.

--
Just checking in case the edit-key offers new states for that.
2019-11-06 09:10:03 +01:00
NIIBE Yutaka
1b840a151a python: Fix how to generate documentation.
* lang/python/doc/Makefile.am: Explicitly write rules to generate rst
and texinfo files.

Fixes-commit: 36428d8cf1
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2019-11-06 10:30:16 +09:00
Andre Heinecke
9cf4db1e52
qt, tests: Add testcase for multiple remarsk
* lang/qt/tests/t-remarks.cpp (testMultipleRemarks): New.
2019-11-04 13:56:14 +01:00
Andre Heinecke
cb7668caeb
cpp: Add API to obtain mutliple remarks
* lang/cpp/src/key.cpp, lang/cpp/src/key.h (UserID::remarks): New.
* NEWS: Mention this.

--
This can be useful if we want to show remarks made by others, too.

For:
GnuPG-Bug-Id: T4734
2019-11-04 13:54:55 +01:00
Andre Heinecke
db888b1cc0
qt,tests: Move remarks test out and extend it
* lang/qt/tests/t-various.cpp (testRemarks): Move out.
* lang/qt/tests/t-remarks.cpp: New.
* lang/qt/tests/Makefile.am: Update accordingly.
--
While t-various is nice to add a quick test for more
extensive stuff it is better to move it in its own test.

This also tests with a key that has only a single uid.
2019-11-04 11:18:35 +01:00
Andre Heinecke
08933c183a
cpp: Fix dupe_ok state for single uid
* lang/cpp/src/gpgsignkeyeditinteractor.cpp (makeTable):
Add transition from command to dupe_ok
2019-11-04 11:17:27 +01:00
Werner Koch
067b1a73d9
doc: Note the need for a base tag.
--
2019-11-04 09:15:43 +01:00
Andre Heinecke
d61491dd25
qt: Allow adding empty remarks
* lang/qt/src/qgpgmesignkeyjob.cpp (sign_key): Allow empty
remarks.
2019-11-01 12:05:47 +01:00
Andre Heinecke
174caaa6f5
cpp: Minor optimization in remark lookup
* lang/cpp/src/key.cpp (UserID::remark): Use C-API.

--
The other parts of that function already use the C API
so we can also avoid function calls for the keyListMode.
2019-11-01 12:04:41 +01:00
Andre Heinecke
266e05eee8
cpp: Fix adding duplicated sigs on multiple uids
* lang/cpp/src/gpgsignkeyeditinteractor.cpp: Add another
state DUPE_OK2 to allow gpg looping over all uids.

--
When duplicated signatures should be added to multiple
user ids GnuPG will ask for each uid so we have to
add a transition for that.

GnuPG-Bug-Id: T4734
2019-11-01 12:02:07 +01:00
Andre Heinecke
a4d5394b46
cpp: Add env var to control editinteractor debug
* lang/cpp/src/editinteractor.cpp (EditInteractor::Private::Private):
Read "GPGMEPP_INTERACTOR_DEBUG" env var.
(EditInteractor::Private::~Private): Close debug file.

--
While it was possible for the application to control the
debug through setDebugChannel it is often times helpful
to just debug without changing the application using
GPGME
2019-11-01 12:00:18 +01:00
Andre Heinecke
1242c6c93a
core: Fix parsing of userid sigs after a subpkg
* src/keylist.c (keylist_colon_handler): Do not clear
out the tmp_uid when a subpacket line is encountered.

--
When the uid is cleared no more signatures following
the subpacket are parsed, so we now no longer clear
it when a subpacket is encountered.
2019-10-29 16:43:37 +01:00
Andre Heinecke
1f3ca698f1
qt,tests: Add test for remarks
* lang/qt/tests/t-various.cpp (testRemark): New.
2019-10-29 16:36:45 +01:00
Andre Heinecke
373acd6923
qt: Extend signkeyjob to handle remarks and dups
* lang/qt/src/qgpgmesignkeyjob.cpp: Handle remarks and
dupeOK.
* lang/qt/src/signkeyjob.h (SignKeyJob::setDupeOk),
(SignKeyJob::setRemark): New.

--
This API makes it easy for Kleopatra to add remarks for:
GnuPG-Bug-Id: T4734
2019-10-29 16:33:58 +01:00
Andre Heinecke
36f7f7a478
cpp: Add support for multiple keysigs in edit
* lang/cpp/src/gpgsignkeyeditinteractor.cpp
(GpgSignKeyEditInteractor::setDupeOk): New.
(makeTable): Add new tansitions.
(SignKeyState): Add DUPE_OK Status.
(GpgSignKeyEditInteractor::action): Handle DUPE_OK.
(GpgSignKeyEditInteractor::Private::Private): Carry flag.

--
When extended-edit is enabled this can be used to answer
the "dupe_ok" query from the edit-key with yes.

This is for:
GnuPG-Bug-Id: T4734
2019-10-29 16:31:20 +01:00
Andre Heinecke
83ecf1686a
cpp: Add convenience API to obtain remarks
* lang/cpp/src/key.h, lang/cpp/src/key.cpp (UserID::remark): New.

--
A remark made by one key on another is a signature notation on
a user id certification signature with the name "rem@gnupg.org".

This helps with:
GnuPG-Bug-Id: T4734
2019-10-29 16:24:01 +01:00
Andre Heinecke
0224408c63
core: Add cert-notation support and extended-edit
* src/context.h (gpgme_context): Add new flag for extended-edit.
* src/engine-gpg.c (append_args_from_sig_notations): Add flags to
control the kind of notations.
(gpg_edit): Respect extended-edit and notations.
(gpg_encrypt_sign, gpg_sign): Update call to
append_args_from_sig_notations.
* src/gpgme.c (gpgme_set_ctx_flag, gpgme_get_ctx_flag): Support
extended-edit.
* NEWS, doc/gpgme.texi: Mention extended-edit.

--
This provides a way to get the extended key-edit interface without
breaking bad state machines that rely on the current command flow.

A use case for this is to enable multiple local signatures, which
can be used together with annotations for:

GnuPG-Bug-Id: T4734
2019-10-29 16:11:54 +01:00
Andre Heinecke
9d83698818
cpp: Minor coding style fix
--
2019-10-29 11:04:41 +01:00
Andre Heinecke
fe2892618c
core,w32: Initialize dbg_help for socket debugging
* src/w32-io.c (_gpgme_io_select): Initialize dbg_help.

--
This fixes a crash on Windows because dbg_help might
be used unitialized.
2019-10-28 16:02:22 +01:00
Werner Koch
2b2977c215
doc: Remove cruft from a doc entry.
--

Reported-by: dkg@fifthhorseman.net
2019-10-01 08:08:17 +02:00
NIIBE Yutaka
b97434fbf0 json: Fix t-decrypt-verify.out for GnuPG >= 2.3.
* tests/json/t-decrypt-verify.out.json: Remove check with key of
04071FB807287134.

--

GnuPG 2.3 changes how public key decryption works; It collects list of
PUBKEY_ENC packets and then processes an ENCRYPTED* packet.  At the
stage of processing an ENCRYPTED* packet, it checks if private keys
can decrypt any of PUBKEY_ENC packets.  It does not necessarily
examine all of PUBKEY_ENC packets.  Only when it finds a PUBKEY_ENC
packet cannot be decrypted, it reports STATUS_NO_SECKEY with keyid of
that packet.

GnuPG 2.2 or older tries PUBKEY_ENC packets in order, and the first
successful PUBKEY_ENC packet is used.  Rest of PUBKEY_ENC packets are
not examined, but STATUS_NO_SECKEY with keyid is reported even when
there is a valid private key.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2019-08-06 11:19:59 +09:00
Andre Heinecke
6f4a886b30
core: Fix arg counting in enginge-gpg
* src/engine-gpg.c (build_argv): Properly check for all
arguments and allocate memory for them.

--
This fixes a potential buffer overflow which could be created
by using unusual and partially contradictory options.
Like offline and auto-key-locate together while
using ignore-mdc-error.
As the list of arguments should not be user controlled the
impact of this is very low.

To ensure that this does not happen in the future an
assert is also added with this patch.
2019-07-16 11:39:29 +02:00
NIIBE Yutaka
36428d8cf1 python: doc: Remove generated files, put rules in Makefile.
* lang/python/doc/Makefile.am (EXTRA_DIST): Remove files not
distributed like files under meta.
* Add rules to generate .rst and .texi files.
* lang/python/doc/rst: Remove .rst files to be generated.
* lang/python/doc/texinfo: Remove .texi files to be generated.

GnuPG-bug-id: 4275
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2019-07-12 14:53:55 +09:00
NIIBE Yutaka
d9387650ff python: doc: Add suffix for org files.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2019-07-12 14:53:31 +09:00
Maximilian Krambach
ed1dffb474 js: improve connection check
--

* Connection.js: In some cases, the browser disconnect does not
  happen inmediately (e.g. wrong extension for the app). I added a
  delay of 25 ms to see if the connection was closed by the browser.
  Also, I tried to make the checkConnection more readable.
2019-07-03 16:19:44 +02:00
Maximilian Krambach
f5e27a12d3 js: Error handling for browser errors
--

* Connection.js
  - Add some meaningful nativeMessaging feedback for failing
    communication due to misconfiguration or other browser-originated
    fails
  - add an "isDisconnected" property
  - "isNativeHostUnknown" tries to match browser's feedback string if
    the browser does not find gpgme-json
* init.js
  - initialization will now reject with a more meaningful error if the
    configuration is not set up or other browser-based errors
    (chrome.runtime.lastError) are present. This should speed up
    the normal initialization (not having to waiting for a timeout
    any more in case of improper setup)
* errors.js
  - CONN_NATIVEMESSAGE: New error that passes the browser's
    nativeMessaging error
  - CONN_NO_CONFIG: native messaging error indicating that the
    nativeMessaging host was not set up properly
* unittests.js:
  - added the "isDisconnected" property to the startup tests
  - added tests for proper behavior of connection checks
2019-06-19 12:58:44 +02:00
Werner Koch
44cedf9796
Post release updates
--
2019-06-13 15:35:58 +02:00
Werner Koch
ea11c2a13c
Release 1.13.1
* configure.ac: Bump LT versions to c=C33/A22/R1 cpp=C16/A10/R0
qt=C10/A3/R4.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-13 15:18:38 +02:00
Werner Koch
7d0a979c07
python: Fix regression in t-decrypt-verify test.
* lang/python/tests/t-decrypt-verify.py: Comment recent changes.
--

Fixes-commit: bd2d282e57
GnuPG-bug-id: 4276
2019-06-13 15:18:36 +02:00
Werner Koch
ad1395f210
python: Set a default-key into gpg.conf for the tests.
* lang/python/tests/Makefile.am (gpg.conf): Set a default key.

--

It seems we need to set a default key because at least t-sign.py does
not specify the key to use and we do not want to rely on the order of
keys in the keyring.

Also
Fixes-commit: f3ca2c9ce9

gpg 2.0 is end-of-life and we don't need these extra options anymore.
In fact they for the use of some gpg version and don't use the version
gpgconf knows about.  This also aligns the python tests to what we use
for the C test suite.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-13 11:56:08 +02:00
Werner Koch
4f11210b21
core: At debug levels up to 9 print only an ascii dump.
* src/debug.c (_gpgme_debug_buffer): Switch between two output
formats.
--

The new format is much more practical than the bunch of hex digits
followed by just 16 ascii chars.  To get the old behaviour use a debug
level of 10.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-13 08:46:16 +02:00
Werner Koch
f6fd90c99a
tests: Minor fix to run-threaded.c.
* tests/run-threaded.c (random_data_close): Correct FD test.
--

An invalid DS is -1 and not 0; this fix is for correctness and does
not chnage anything in the real world.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-06 18:59:16 +02:00
Werner Koch
f84abcad25
core: Add commented debug helper to posix-io.c.
* src/posix-io.c (_gpgme_is_fd_valid): New out-commented function.
--

This code is sometimes useful to track down invalid file descriptors.
We keep it commented in the code.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-06 18:57:28 +02:00
Werner Koch
6b9ff1ba39
core: Fix error return value of _gpgme_run_io_cb.
* src/wait.c (_gpgme_run_io_cb): Fix return code.
--

The function needs to return an gpg_error_t and not ERRNO.

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-06 18:57:28 +02:00
Andre Heinecke
e6f2827306
tests: Add option "allow-del" to run-threaded
* tests/run-threaded.c (main): Handle allow-del.
(allow-del): New. Variable to allow deletion of keys.
(import): Delete key after import if allow-del is set.
(delete_impres): Delete keys from an import result.
(delete_fpr): Delete a key by fingerprint.

--
This is intended to test write access and locking of the
keyring by repeatedly importing and deleting pubkeys.

It is an option because it might cause keyring corruption
etc. so it should be explicitly enabled.
2019-06-06 09:19:02 +02:00
Andre Heinecke
024a7f75d4
tests: Implement import in run-threaded
* tests/run-threaded.c (import): New.
(do_data_op): Call it.
2019-06-05 17:23:59 +02:00
Werner Koch
0f68c9f16b
core: Prettify _gpgme_io_select debug output again and fix TRACE_SYSRES.
* src/debug.c (_gpgme_debug): Take better care of NULL userinfo.
(_gpgme_debug_end): Rework.
(_trace_sysres): Print ERRNO and not the supplied RES.
--

The TRACE_SYSRES patch fixes
Regression-due-to: 7a1e7006d0

Signed-off-by: Werner Koch <wk@gnupg.org>
2019-06-05 16:48:47 +02:00