gpgme.git
18 months agoRelease 1.9.0 gpgme-1.9.0
Werner Koch [Tue, 28 Mar 2017 14:21:37 +0000 (16:21 +0200)]
Release 1.9.0

* configure.ac <c>: Bump LT version to C29/A18/R0.
<cpp>: Bump LT version to C10/A4/R0.
<qt>: Bump LT version to C9/A2/R0.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agocore: Prepare for new key listing data send by gpg.
Werner Koch [Tue, 28 Mar 2017 09:40:44 +0000 (11:40 +0200)]
core: Prepare for new key listing data send by gpg.

* src/gpgme.h.in (gpgme_user_id_t): New fields 'origin' and
'last_update'.
(gpgme_key_t): New fields 'origin' and 'last_update'.
* src/conversion.c (_gpgme_parse_timestamp_ul): New.
* src/keylist.c (keylist_colon_handler): Parse fields 19 and 20.

* tests/run-keylist.c (main): Print new fields.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agoqt: Disable testEncryptDecryptNowrap
Andre Heinecke [Mon, 27 Mar 2017 16:08:45 +0000 (18:08 +0200)]
qt: Disable testEncryptDecryptNowrap

* lang/qt/tests/t-encrypt.cpp (EncryptTest::testEncryptDecryptNowrap):
Disable test.

--
This test produces failures under CI/ASAN conditions as the
verify after the unwrap returns an error. As we currently
don't have time to look into this more it's disabled for now.
Similar to the testMixedEncryptDecrypt.

18 months agopython: Skip tests if running with GnuPG < 2.1.12.
Justus Winter [Mon, 27 Mar 2017 09:11:47 +0000 (11:11 +0200)]
python: Skip tests if running with GnuPG < 2.1.12.

* lang/python/tests/support.py (assert_gpg_version): Fix error
message.  Skip all tests when we use GnuPG older than 2.1.12.

GnuPG-bug-id: 3008
Signed-off-by: Justus Winter <justus@g10code.com>
18 months agoMention new cpp changes in the NEWS
Andre Heinecke [Fri, 24 Mar 2017 16:25:26 +0000 (17:25 +0100)]
Mention new cpp changes in the NEWS

--
Somone that calls a function startCombinedDecryptionAndVerification
should be required to always type it without autocompletion.

18 months agocpp: Respect decrypt flags in new functions
Andre Heinecke [Fri, 24 Mar 2017 16:24:04 +0000 (17:24 +0100)]
cpp: Respect decrypt flags in new functions

* lang/cpp/src/context.cpp: Respect directly provided flags
in the new decrypt functions.

--
Overlooked in the initial commit. Also fixed the according
unused variable warnings.

18 months agoqt: Add unittest for decrypt unwrap
Andre Heinecke [Fri, 24 Mar 2017 15:58:58 +0000 (16:58 +0100)]
qt: Add unittest for decrypt unwrap

* lang/qt/tests/t-encrypt.cpp
(EncryptTest::testEncryptDecryptNowrap): New.

18 months agocpp: Use gpgme_op_decrypt_ex and add new flags.
Andre Heinecke [Fri, 24 Mar 2017 15:51:26 +0000 (16:51 +0100)]
cpp: Use gpgme_op_decrypt_ex and add new flags.

* lang/cpp/src/context.cpp: New decrypt and decryptVerify functions
that take flags as arguments. Use new variants in old functions.
(Context::setDecryptionFlags): New helper.
(Context::Private::Private): Initialize new member.
* lang/cpp/src/context_p.h (Context::Private::decryptFlags): New.
* lang/cpp/src/context.h (Context::DecryptFlags): New enum.
(Context::EncryptionFlags): Extend for EncryptWrap.

--
The setDecryptionFlags provides a generic way to set decryption
flags for the whole context. This allows existing code to just
keep using the old functions and modify the decryption behavior
in a central place.

18 months agocore: New flags GPGME_DECRYPT_UNWRAP and GPGME_ENCRYPT_WRAP.
Werner Koch [Fri, 24 Mar 2017 13:36:54 +0000 (14:36 +0100)]
core: New flags GPGME_DECRYPT_UNWRAP and GPGME_ENCRYPT_WRAP.

* 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 <wk@gnupg.org>
18 months agoqt: Add test for Data::toKeys
Andre Heinecke [Wed, 22 Mar 2017 15:41:04 +0000 (16:41 +0100)]
qt: Add test for Data::toKeys

* lang/qt/tests/t-various.cpp (TestVarious::testKeyFromFile): New.

18 months agocpp: Wrap keylist_from_data
Andre Heinecke [Wed, 22 Mar 2017 15:38:35 +0000 (16:38 +0100)]
cpp: Wrap keylist_from_data

* lang/cpp/data.h, lang/cpp/data.cpp (GpgME::Data::toKeys): New.

--
Doing this in data instead of Context is a bit more idiomatic. But
this could also be added to Context.

18 months agoqt: Initialize library first in tests
Andre Heinecke [Wed, 22 Mar 2017 15:34:29 +0000 (16:34 +0100)]
qt: Initialize library first in tests

* lang/qt/tests/t-support.cpp (QGpgMETest::initTestCase): Initialize
library.

18 months agopython: Improve Python detection.
Justus Winter [Wed, 22 Mar 2017 14:33:06 +0000 (15:33 +0100)]
python: Improve Python detection.

* m4/python.m4 (_AM_PYTHON_INTERPRETER_LIST): Prefer the generic
'pythonX' over 'pythonX.Y'.  This way we select the users preferred
version for both flavors.  Prefer 'python' over 'python3' but not over
'python2' so that the algorithm still finds a 'python2' even if
'python' is a Python3.

Fixes-commit: 5189c08af9468cdeb6f16a6ecd0fee53e1e3aa0e
Signed-off-by: Justus Winter <justus@g10code.com>
18 months agocore: New API gpgme_op_set_uid_flag.
Werner Koch [Tue, 21 Mar 2017 18:02:20 +0000 (19:02 +0100)]
core: New API gpgme_op_set_uid_flag.

* src/gpgme.h.in (gpgme_op_set_uid_flag_start): New.
(gpgme_op_set_uid_flag_start): New.
* src/gpgme.def, src/libgpgme.vers: Add them.
* src/genkey.c (addrevuid_start): Change arg revoke to a flag.
(gpgme_op_revuid_start): Pass GENKEY_EXTRAFLAG_REVOKE for the fomer
revoke parameter.
(gpgme_op_revuid): Ditto.
(set_uid_flag): New.
(gpgme_op_set_uid_flag_start): New.
(gpgme_op_set_uid_flag): New.
* src/engine.h (GENKEY_EXTRAFLAG_SETPRIMARY): new.
* src/engine-gpg.c (gpg_adduid): Implement that flag.

* tests/run-genkey.c (main): New command --set-primary.
--

GnuPG-bug-id: 2931
Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agopython: Wrap 'gpgme_op_keylist_from_data_start'.
Justus Winter [Tue, 21 Mar 2017 11:32:31 +0000 (12:32 +0100)]
python: Wrap 'gpgme_op_keylist_from_data_start'.

* NEWS: Update.
* lang/python/gpg/core.py (Context.keylist): New keyword argument
'source'.  If given, list keys from 'source'.
* lang/python/gpgme.i: Wrap the argument to
'gpgme_op_keylist_from_data_start'.
* lang/python/tests/Makefile.am (py_tests): Add new test.
* lang/python/tests/support.py (EphemeralContext): Do not throw an
error if no agent has been started in the context.
* lang/python/tests/t-keylist-from-data.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
18 months agocore: Extend gpgme_get_dirinfo to return the gpg-wks-client name.
Werner Koch [Tue, 21 Mar 2017 10:16:16 +0000 (11:16 +0100)]
core: Extend gpgme_get_dirinfo to return the gpg-wks-client name.

* src/dirinfo.c (WANT_GPG_WKS_CLIENT_NAME): New const.
(struct dirinfo): New field 'gpg_wks_client_name'.
(get_gpgconf_item): Build it on demand.
(gpgme_get_dirinfo): New value "gpg-wks-client-name" for WHAT.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agocore: New encryption flag GPGME_ENCRYPT_THROW_KEYIDS.
Werner Koch [Tue, 21 Mar 2017 09:39:33 +0000 (10:39 +0100)]
core: New encryption flag GPGME_ENCRYPT_THROW_KEYIDS.

* 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 <wk@gnupg.org>
18 months agocore: New public API gpgme_op_keylist_from_data_start.
Andre Heinecke [Tue, 21 Mar 2017 08:38:11 +0000 (09:38 +0100)]
core: New public API gpgme_op_keylist_from_data_start.

* src/gpgme.h.in: New API gpgme_op_keylist_from_data_start.
* src/libgpgme.vers, src/gpgme.def: Add it.
* src/keylist.c (gpgme_op_keylist_from_data_start): New.
* src/engine-backend.h (engine_ops): Add field 'keylist_data'.  Change
all engines to pass NULL for it.
* src/engine.c (_gpgme_engine_op_keylist_data): New.
* src/engine-gpg.c (gpg_keylist_data): New.
(_gpgme_engine_ops_gpg): Register gpg_keylist_data.

* tests/run-keylist.c (main): New option --from-file.
--

Co-authored-by: Werner Koch <wk@gnupg.org>
GnuPG-bug-id: 2819

19 months agocore,cpp: New key flag 'is_de_vs'.
Werner Koch [Mon, 20 Mar 2017 18:56:10 +0000 (19:56 +0100)]
core,cpp: New key flag 'is_de_vs'.

* src/gpgme.h.in (_gpgme_subkey): New flag is_de_vs.
* tests/run-keylist.c (main): Print that flag.
* src/keylist.c (parse_pub_field18): New.
(keylist_colon_handler): Parse compliance flags.
* lang/cpp/src/key.cpp (Key::isDeVs): New.
(Subkey::isDeVs): New.

* lang/cpp/src/key.h (class Key): New method isDeVs.
(class Subkey): New method isDeVs.

Signed-off-by: Werner Koch <wk@gnupg.org>
19 months agotests: Fix distcheck.
Justus Winter [Mon, 20 Mar 2017 16:07:31 +0000 (17:07 +0100)]
tests: Fix distcheck.

* tests/start-stop-agent: Do not create 'gpg-agent.conf' if it does
not exist.

Fixes-commit: 16b202d9999591b71fb8bb49f6db10ef96d4cbe8
Signed-off-by: Justus Winter <justus@g10code.com>
19 months agopython: Fix version check.
Justus Winter [Mon, 20 Mar 2017 15:53:29 +0000 (16:53 +0100)]
python: Fix version check.

* lang/python/tests/support.py (assert_gpg_version): Cope with
non-released versions.

Fixes-commit: e1cf8bab319ba1dea41ba5d711dbb66ffd8e6fd6
Signed-off-by: Justus Winter <justus@g10code.com>
19 months agotests: Use 'gpg-agent --allow-loopback-pinentry' if applicable.
Justus Winter [Mon, 20 Mar 2017 15:36:27 +0000 (16:36 +0100)]
tests: Use 'gpg-agent --allow-loopback-pinentry' if applicable.

* lang/python/tests/Makefile.am (gpg-agent.conf): Do not hard-code the
option.  This breaks gpg-agent from GnuPG 2.0.
* tests/start-stop-agent: Rather, check if the option is supported and
add it to the configuration if it is.

GnuPG-bug-id: 3008
Fixes-commit: bbf19124bbec9eb6298cef2914baae7ac74382fe
Signed-off-by: Justus Winter <justus@g10code.com>
19 months agopython: Skip tests if GnuPG is too old.
Justus Winter [Mon, 20 Mar 2017 15:00:13 +0000 (16:00 +0100)]
python: Skip tests if GnuPG is too old.

* lang/python/tests/support.py (assert_gpg_version): New function.
* lang/python/tests/t-callbacks.py: Use the new function to skip the
test if GnuPG is too old.
* lang/python/tests/t-edit.py: Likewise.
* lang/python/tests/t-encrypt-sym.py: Likewise.
* lang/python/tests/t-quick-key-creation.py: Likewise.
* lang/python/tests/t-quick-key-manipulation.py: Likewise.
* lang/python/tests/t-quick-key-signing.py: Likewise.

GnuPG-bug-id: 3008
Signed-off-by: Justus Winter <justus@g10code.com>
19 months agopython: Remove superfluous initialization.
Justus Winter [Mon, 20 Mar 2017 15:07:07 +0000 (16:07 +0100)]
python: Remove superfluous initialization.

* lang/python/tests/support.py (init_gpgme): Remove.  This is an
remnant from the c tests.  Nowadays, the Python bindings initialize
GPGME automagically.
* lang/python/tests/initial.py: Remove call to 'support.init_gpgme'.
* lang/python/tests/t-callbacks.py: Likewise.
* lang/python/tests/t-decrypt-verify.py: Likewise.
* lang/python/tests/t-decrypt.py: Likewise.
* lang/python/tests/t-edit.py: Likewise.
* lang/python/tests/t-encrypt-large.py: Likewise.
* lang/python/tests/t-encrypt-sign.py: Likewise.
* lang/python/tests/t-encrypt-sym.py: Likewise.
* lang/python/tests/t-encrypt.py: Likewise.
* lang/python/tests/t-export.py: Likewise.
* lang/python/tests/t-file-name.py: Likewise.
* lang/python/tests/t-idiomatic.py: Likewise.
* lang/python/tests/t-import.py: Likewise.
* lang/python/tests/t-keylist.py: Likewise.
* lang/python/tests/t-sig-notation.py: Likewise.
* lang/python/tests/t-sign.py: Likewise.
* lang/python/tests/t-signers.py: Likewise.
* lang/python/tests/t-trustlist.py: Likewise.
* lang/python/tests/t-verify.py: Likewise.
* lang/python/tests/t-wait.py: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
19 months agopython: Make error message more helpful.
Justus Winter [Tue, 14 Mar 2017 10:10:21 +0000 (11:10 +0100)]
python: Make error message more helpful.

* lang/python/tests/run-tests.py: Make the error message shown when we
cannot locate the python module in the build tree more helpful.

Signed-off-by: Justus Winter <justus@g10code.com>
19 months agopython: Make tests more robust.
Justus Winter [Tue, 14 Mar 2017 10:08:08 +0000 (11:08 +0100)]
python: Make tests more robust.

* lang/python/tests/support.py (TemporaryDirectory): Always use our
own version even if 'tempfile.TemporaryDirectory' is provided, because
we need to use 'shutil.rmtree(..., ignore_errors=True)' to avoid it
tripping over gpg-agent deleting its own sockets.

Signed-off-by: Justus Winter <justus@g10code.com>
19 months agopython: Improve build system integration.
Justus Winter [Tue, 14 Mar 2017 10:22:28 +0000 (11:22 +0100)]
python: Improve build system integration.

* lang/python/Makefile.am: Use 'set -e' when chaining shell commands
together in rules.

Signed-off-by: Justus Winter <justus@g10code.com>
19 months agobuild: Improve Python detection.
Justus Winter [Mon, 13 Mar 2017 14:37:15 +0000 (15:37 +0100)]
build: Improve Python detection.

* configure.ac: Do not error out too early if we don't find a matching
Python version.  We handle this case later.

Signed-off-by: Justus Winter <justus@g10code.com>
19 months agobuild: Tune M4 macros for our needs.
Justus Winter [Thu, 9 Mar 2017 15:55:18 +0000 (16:55 +0100)]
build: Tune M4 macros for our needs.

* m4/ax_python_devel.m4: Do not emit 'HAVE_PYTHON'.
* m4/python.m4 (_AM_PYTHON_INTERPRETER_LIST): Add newer Python
versions, drop older ones.  Also, sort the list with older versions at
the front, newer and generic versions towards the end.  This makes the
algorithm pick the lowest version that meets the version requirement.

Signed-off-by: Justus Winter <justus@g10code.com>
19 months agobuild: Add M4 macros for python.
Justus Winter [Thu, 9 Mar 2017 15:54:35 +0000 (16:54 +0100)]
build: Add M4 macros for python.

* m4/python.m4: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
19 months agoqt: Add test for DN parser
Andre Heinecke [Mon, 13 Mar 2017 10:16:41 +0000 (11:16 +0100)]
qt: Add test for DN parser

* qt/tests/t-various.cpp (testDN): New.

--
A simple test for the DN parser that would have caught
the new / free mismatch fixed in 9d5048d4.

19 months agoqt: Use gpgrt_asprintf instead of qstrdup
Andre Heinecke [Mon, 13 Mar 2017 10:14:54 +0000 (11:14 +0100)]
qt: Use gpgrt_asprintf instead of qstrdup

* lang/qt/src/dn.cpp (parse_dn_part): Use gpgrt_asprintf instead
of qstrdup.

--
This fixes a new / free mismatch because qstrdup uses new and
the allocated parts are freed with free. Similar to: a09ed3f2

19 months agocore: Fix status error return for gpgsm.
Werner Koch [Thu, 9 Mar 2017 10:45:00 +0000 (11:45 +0100)]
core: Fix status error return for gpgsm.

* src/engine-gpgsm.c (gpgsm_assuan_simple_command): Make sure CB_ERR
is returned.
* src/import.c (parse_import_res): Do not return an error for the last
field.
(import_status_handler): Actually return the error from
parse_import_res.

Signed-off-by: Werner Koch <wk@gnupg.org>
19 months agopython: Print path of the Python module used during tests.
Justus Winter [Thu, 2 Mar 2017 15:06:29 +0000 (16:06 +0100)]
python: Print path of the Python module used during tests.

* lang/python/tests/initial.py: Print path of the Python module used
during tests.  Useful to detect if by any mistake the wrong module is
picked up.

Signed-off-by: Justus Winter <justus@g10code.com>
19 months agocore: Fix minor code style thing.
Werner Koch [Thu, 2 Mar 2017 13:52:52 +0000 (14:52 +0100)]
core: Fix minor code style thing.

* src/engine-gpg.c (gpg_add_algo_usage_expire): Use double parenthesis
for bit tests.

Signed-off-by: Werner Koch <wk@gnupg.org>
19 months agoRevert "core: Fix error types."
Werner Koch [Thu, 2 Mar 2017 13:47:51 +0000 (14:47 +0100)]
Revert "core: Fix error types."

--
This reverts commit 6df6e01ed5a581765d245bf7303cda4497d0eb22.

gpgme_error_t et al are from a time where we had no hard dependency on
libgpg-error.  Now libgpg-error is a required and thus it does not
make sense to have these surrogates.  In fact we should ventually
completely remove them.

Signed-off-by: Werner Koch <wk@gnupg.org>
19 months agocpp: Add subkey keygrip to API
Andre Heinecke [Thu, 2 Mar 2017 08:35:05 +0000 (09:35 +0100)]
cpp: Add subkey keygrip to API

* lang/cpp/src/key.cpp (Subkey::keyGrip): New.
* lang/cpp/src/key.h: Update accordingly.

19 months agocpp: Add interactor to generate keys on smartcard
Andre Heinecke [Wed, 1 Mar 2017 10:17:27 +0000 (11:17 +0100)]
cpp: Add interactor to generate keys on smartcard

* lang/cpp/src/editinteractor.cpp (EditInteractor::needsNoResponse):
Handle new states.
* lang/cpp/src/gpggencardkeyinteractor.cpp,
lang/cpp/src/gpggencardkeyinteractor.h: New.
* lang/cpp/src/Makefile.am: Update accordingly.

19 months agoqt: Allow creation of default keys without name
Andre Heinecke [Wed, 1 Mar 2017 10:14:07 +0000 (11:14 +0100)]
qt: Allow creation of default keys without name

* lang/qt/src/defaultkeygenerationjob.cpp
(DefaultKeyGenerationJob::start): Handle empty name and email.

19 months agodoc: Correct documentation for recp arg of gpgme_op_encrypt_sign_start
Daniel Kahn Gillmor [Sat, 25 Feb 2017 21:08:11 +0000 (16:08 -0500)]
doc: Correct documentation for recp arg of gpgme_op_encrypt_sign_start

* doc/gpgme.texi (gpgme_op_encrypt_sign_start): recp is an array of
gpgme_key_t, not a single element.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
19 months agopython: Fix test.
Justus Winter [Mon, 20 Feb 2017 09:23:41 +0000 (10:23 +0100)]
python: Fix test.

* lang/python/tests/t-quick-key-manipulation.py: Modify the
configuration file in the ephemeral home directory, not the one used
by all the tests.

Fixes-commit: 15fbac9e72a4d1bff9a3b9e9822f9175b09fbcd5
Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Support manipulating the TOFU policy.
Justus Winter [Fri, 17 Feb 2017 16:07:05 +0000 (17:07 +0100)]
python: Support manipulating the TOFU policy.

* NEWS: Update.
* doc/gpgme.texi: Fix typos.
* lang/python/gpg/constants/__init__.py: Import new files.
* lang/python/gpg/constants/tofu/__init__.py: New file.
* lang/python/gpg/constants/tofu/policy.py: New file.
* lang/python/gpg/core.py (Context.key_tofu_policy): New function.
* lang/python/gpgme.i: Nice reprs for gpgme_tofu_info_t.
* lang/python/setup.py.in: Install new package.
* lang/python/tests/t-quick-key-manipulation.py: Extend test.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Support quick key signing.
Justus Winter [Fri, 17 Feb 2017 14:44:35 +0000 (15:44 +0100)]
python: Support quick key signing.

* NEWS: Update.
* doc/gpgme.texi (gpgme_op_keysign): Fix the description of the
'expire' argument.
* lang/python/gpg/constants/__init__.py: Import new file.
* lang/python/gpg/constants/keysign.py: New file.
* lang/python/gpg/core.py (Context.key_sign): New function.
* lang/python/tests/Makefile.am (py_tests): Add new test.
* lang/python/tests/t-quick-key-signing.py: New test.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Fix teardown of ephemeral contexts.
Justus Winter [Fri, 17 Feb 2017 11:18:56 +0000 (12:18 +0100)]
python: Fix teardown of ephemeral contexts.

* lang/python/tests/support.py (EphemeralContext): New function.
* lang/python/tests/t-quick-key-creation.py: Use the new function to
manage ephemeral contexts.
* lang/python/tests/t-quick-key-manipulation.py: Likewise.
* lang/python/tests/t-quick-subkey-creation.py: Likewise.
--

Previously, there was a problem with cleaning up ephemeral home
directories.  shutil.rmtree deleted the agents main socket, gpg-agent
detected that, and deleted the other sockets as well, racing
shutil.rmtree which did not cope will with that.

Fix this by asking the agent nicely to shut down.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Fix using strings as commands in the assuan protocol.
Justus Winter [Fri, 17 Feb 2017 11:10:34 +0000 (12:10 +0100)]
python: Fix using strings as commands in the assuan protocol.

* lang/python/gpg/core.py (Context.assuan_transact): Fix testing
whether the command is a string on Python2.
* lang/python/tests/t-protocol-assuan.py: Improve the test to detect
this problem.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Support adding and revoking UIDs.
Justus Winter [Thu, 16 Feb 2017 16:52:49 +0000 (17:52 +0100)]
python: Support adding and revoking UIDs.

* NEWS: Update.
* lang/python/gpg/core.py (Context.key_add_uid): New function.
(Context.key_revoke_uid): Likewise.
* lang/python/tests/Makefile.am (XTESTS): Add new test.
* lang/python/tests/t-quick-key-manipulation.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Support quick subkey creation.
Justus Winter [Thu, 16 Feb 2017 15:38:21 +0000 (16:38 +0100)]
python: Support quick subkey creation.

* NEWS: Update.
* lang/python/gpg/core.py (Context.create_subkey): New function.
* lang/python/tests/Makefile.am (XTESTS): Add new test.
* lang/python/tests/t-quick-subkey-creation.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Support quick key creation.
Justus Winter [Thu, 16 Feb 2017 13:53:11 +0000 (14:53 +0100)]
python: Support quick key creation.

* NEWS: Update.
* lang/python/gpg/constants/__init__.py: Import new file.
* lang/python/gpg/constants/create.py: New file.
* lang/python/gpg/core.py (Context.create_key): New function.
* lang/python/tests/Makefile.am (XTESTS): Add new test.
* lang/python/tests/support.py (TemporaryDirectory): New class.
* lang/python/tests/t-quick-key-creation.py: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Fix passphrase callback wrapping.
Justus Winter [Thu, 16 Feb 2017 13:49:27 +0000 (14:49 +0100)]
python: Fix passphrase callback wrapping.

* lang/python/helpers.c (pyPassphraseCb): Cope with 'passphrase_info'
being NULL.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Fix error handling.
Justus Winter [Thu, 16 Feb 2017 13:42:17 +0000 (14:42 +0100)]
python: Fix error handling.

* lang/python/gpgme.i (typemap gpgme_key_t[]): Set an error if a
non-key element is discovered.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agocore: Fix expiration time handling when creating keys.
Justus Winter [Wed, 15 Feb 2017 15:17:13 +0000 (16:17 +0100)]
core: Fix expiration time handling when creating keys.

* NEWS: Update.
* doc/gpgme.texi (gpgme_op_createkey): Clarify the meaning of the
'expire' parameter.
(GPGME_CREATE_NOEXPIRE): Document new flag.
(gpgme_op_createsubkey): Clarify the meaning of the 'expire'
parameter.
* src/engine-gpg.c (gpg_add_algo_usage_expire): Fix handling of the
expiration time.
* src/gpgme.h.in (GPGME_CREATE_NOEXPIRE): New macro.
--

Previously, the documentation stated that the expiration time was an
absolute timestamp.  However, this value was passed using the
'seconds=N' syntax to GnuPG which specifies the expiration time in
seconds relative to the creation time.  Fix the documentation.

Furthermore, the documentation stated that using 0 results in keys
that do not expire.  This was communicated to GnuPG by using the
implicit default.  However, as of GnuPG 2.1.17, the default was
changed to create keys that expire within a reasonable timespan.

Fix this discrepancy by aligning the behavior with recent GnuPG
versions: 0 means use a reasonable default, and introduce a flag that
can be used to create keys that do not expire.  Communicate this
explicitly to GnuPG.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Fix build system integration.
Justus Winter [Wed, 15 Feb 2017 10:31:27 +0000 (11:31 +0100)]
python: Fix build system integration.

* lang/python/Makefile.am (copystamp): Also copy the setup script, and
link the header files.
(all-local): Use local setup script.
(sdist): Fix Python source distribution creation.
(CLEANFILES): Remove now obsolete files.
(install-exec-local): Use local setup script.
* lang/python/setup.py.in: Adjust relative paths to in-tree files.

Fixes-commit: fe65a26ab584bd70fad45c7c4d44330e30a748a4
Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Update lists of functions returning gpgme_error_t.
Justus Winter [Wed, 15 Feb 2017 10:28:02 +0000 (11:28 +0100)]
python: Update lists of functions returning gpgme_error_t.

* lang/python/gpg/core.py (Context._errorcheck): Add instructions how
to update the list.  Update list.
(Data._errorcheck): Likewise.
(Context.set_engine_info): Simplify.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agocore: Fix error types.
Justus Winter [Wed, 15 Feb 2017 08:45:46 +0000 (09:45 +0100)]
core: Fix error types.

* NEWS: Update.
* src/data.c (gpgme_data_set_flag): Return a 'gpgme_error_t'.
* src/error.c (gpgme_strerror_r): Fix type of first argument.
* src/gpgme.h.in (gpgme_strerror_r): Adapt.
(gpgme_data_set_flag): Likewise.
--
Fix for consistency.  This should not pose problems, because typedef
gpg_error_t gpgme_error_t.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Wrap utility functions.
Justus Winter [Tue, 14 Feb 2017 15:30:30 +0000 (16:30 +0100)]
python: Wrap utility functions.

* NEWS: Update.
* lang/python/gpg/core.py (pubkey_algo_string): New function.
(pubkey_algo_name): Add docstring.
(hash_algo_name): Likewise.
(get_protocol_name): Likewise.
(addrspec_from_uid): New function.
* lang/python/gpgme.i (gpgme_pubkey_algo_string): Result must be
freed.
(gpgme_addrspec_from_uid): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Use the correct function to free buffers.
Justus Winter [Tue, 14 Feb 2017 15:16:05 +0000 (16:16 +0100)]
python: Use the correct function to free buffers.

* lang/python/gpgme.i (char *): Free using 'gpgme_free'.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Add keylist mode parameter.
Justus Winter [Tue, 14 Feb 2017 14:56:41 +0000 (15:56 +0100)]
python: Add keylist mode parameter.

* NEWS: Update.
* lang/python/gpg/core.py (Context.keylist): Add 'mode' parameter.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Nicer repr for user ids.
Justus Winter [Tue, 14 Feb 2017 14:55:20 +0000 (15:55 +0100)]
python: Nicer repr for user ids.

* lang/python/gpgme.i (_gpgme_user_id): Provide a nicer repr() for
user ids.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Add convenience functions for the home directory.
Justus Winter [Tue, 14 Feb 2017 12:43:01 +0000 (13:43 +0100)]
python: Add convenience functions for the home directory.

* NEWS: Update.
* lang/python/gpg/core.py (Context.__init__): Add 'home_dir' argument.
(__repr__): Include 'home_dir'.
(Context.home_dir): New property.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agoqt: Make sure to remove the tofu.db on clean.
Justus Winter [Tue, 14 Feb 2017 11:45:15 +0000 (12:45 +0100)]
qt: Make sure to remove the tofu.db on clean.

* lang/qt/tests/Makefile.am (CLEANFILES): Add 'tofu.db'.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopython: Extend SWIG gpgme_{sub,}key with a __repr__ method.
Tobias Mueller [Tue, 20 Dec 2016 17:02:36 +0000 (18:02 +0100)]
python: Extend SWIG gpgme_{sub,}key with a __repr__ method.

* lang/python/gpgme.i: Added a genericrepr macro and use it for
gpgme_key, gpgme_subkey, and gpgme_key_sig.
--

To look nicer in Python's REPL.

We define a generic __repr__ as a SWIG macro and use that to extend some
defined SWIG objects.

The alternative would have been to write a custom __repr__ function for
each class but that would need to be changed everytime the object's
structure changes. The bindings should be easy to maintain, I guess.
This comes at the expense that the reprs are now relatively long and
contain, for example, both keyid and fingerprint.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
20 months agopython: Remove the -builtin flag for SWIG.
Tobias Mueller [Tue, 20 Dec 2016 17:02:20 +0000 (18:02 +0100)]
python: Remove the -builtin flag for SWIG.

* lang/python/setup.py.in: Call SWIG without the builtin flag.
--

The SWIG documentation
<http://www.swig.org/Doc2.0/Python.html#Python_nn28> leaves the
impression that -builtin is solely for increasing performance:

    New in SWIG version 2.0.4: The use of Python proxy classes has
    performance implications that may be unacceptable for a high-
    performance library. The new -builtin option instructs SWIG to
    forego the use of proxy classes, and instead create wrapped types as
    new built-in Python types. When this option is used, the following
    section ("Proxy classes") does not apply. Details on the use of the
    -builtin option are in the Built-in Types section.

While not wasting CPU cycles is good, it also prevents Python code being
written in the wrapper itself. That, however, may be useful to make it
easier to extend the wrapper.

Partially reverts: 856bcfe2934237011984fab0bc69800a7c25c34b

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
20 months agopython: Call SWIG_NewPointerObj rather than SWIG_Python_NewPointerObj.
Tobias Mueller [Tue, 20 Dec 2016 17:01:27 +0000 (18:01 +0100)]
python: Call SWIG_NewPointerObj rather than SWIG_Python_NewPointerObj.

* lang/python/gpgme.i (pygpgme_wrap_gpgme_data_t): Provide a "self"
variable for SWIG_NewPointerObj and call SWIG_NewPointerObj rather than
SWIG_Python_NewPointerObj.
--

SWIG_Python_NewPointerObj seems to be an implementation detail, because
SWIG's documentation does not mention that function at all.  In fact,
SWIG_NewPointerObj is a call to SWIG_Python_NewPointerObj with the first
parameter being either NULL or the "self" variable, depending on whether
SWIG is called with the -builtin flag.  So far, the first parameter was
hard-coded to NULL.  This change also hard-codes it to NULL but makes
it more explicit.  The benefit is that the documented function is being
used and that compilation works regardless of the -builtin flag.

Partially reverts: 856bcfe2934237011984fab0bc69800a7c25c34b

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
20 months agopython: Conditionally provide py3 argument to SWIG
Tobias Mueller [Tue, 20 Dec 2016 17:00:36 +0000 (18:00 +0100)]
python: Conditionally provide py3 argument to SWIG

* lang/python/setup.py.in: Only call with -py3 when we run under python3
or higher.
--

If we ever remove the -builtin flag and leave the the -py3 flag, SWIG
will generate Python code which will be incompatible with Python 2,
because the py3 flag generates python3 code which is incompatible with
python2.

So we conditionally generate SWIG bindings with -py3.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
20 months agopython: Use one copy of the source tree per Python version.
Justus Winter [Mon, 13 Feb 2017 15:44:53 +0000 (16:44 +0100)]
python: Use one copy of the source tree per Python version.

* lang/python/Makefile.am (copystamp): Create one copy per Python
version.
(all-local): Adapt.
(clean-local): Likewise.
(install-exec-local): Likewise.
* lang/python/tests/run-tests.py: Likewise.
--

Currently, we use one copy of the Python module's source to build for
all Python versions.  This is problematic, because SWIG writes a
wrapper file into the source tree.  Currently, this file works with
both Python 2 and 3, but this is purely by chance.

Improve the situation by creating one copy per Python version so that
SWIG can write version-specific code into each copy.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agobuild: Use macOS' compatibility macros to enable all features.
Justus Winter [Mon, 13 Feb 2017 13:58:07 +0000 (14:58 +0100)]
build: Use macOS' compatibility macros to enable all features.

* configure.ac: On macOS, use the compatibility macros to expose every
feature of the libc.  This is the equivalent of _GNU_SOURCE on GNU
libc.
--
Not defining this leads to compilation errors or superfluous warnings
on macOS.

GnuPG-bug-id: 2910
Signed-off-by: Justus Winter <justus@g10code.com>
20 months agoRevert "Disable fd-passing for Apple."
Justus Winter [Mon, 13 Feb 2017 13:01:32 +0000 (14:01 +0100)]
Revert "Disable fd-passing for Apple."

The actual bug has been located, so this can be reverted.

This reverts commit ef5b4ae37d13142e89a051908dc080cda3d24baa.

20 months agoqt: Add missing #include <functional>
Igor Gnatenko [Sat, 11 Feb 2017 07:36:24 +0000 (08:36 +0100)]
qt: Add missing #include <functional>

* lang/qt/src/qgpgmenewcryptoconfig.cpp,
lang/qt/src/threadedjobmixin.h: Include functional.

--
With GCC 7.0, functional is not included transitively and we get:
In file included from qgpgmedeletejob.h:39:0,
                 from qgpgmedeletejob.cpp:38:
threadedjobmixin.h:98:33: error: 'function' in namespace 'std'
    does not name a template type
     void setFunction(const std::function<T_result()> &function)
                                 ^~~~~~~~

std::{function,bind,placeholders,mem_fn} are defined in functional.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1417383
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
GnuPG-Bug-Id: 2955

Commit Message amended by Andre Heinecke

Signed-off-by: Andre Heinecke <aheinecke@intevation.de>
20 months agoqt: Don't rely on implicit include in t-verify
Andre Heinecke [Tue, 7 Feb 2017 09:01:58 +0000 (10:01 +0100)]
qt: Don't rely on implicit include in t-verify

* lang/qt/tests/t-various.cpp: Include QTemporaryDir

--
This fixes build with some Qt Versions

20 months agodoc: Document that gpgme_op_genkey() parms parameter is not XML.
Daniel Kahn Gillmor [Thu, 26 Jan 2017 23:36:39 +0000 (18:36 -0500)]
doc: Document that gpgme_op_genkey() parms parameter is not XML.

* doc/gpgme.texi (GnupgKeyParms): document that input format is not
true XML.

--

Please see discussion at
https://lists.gnupg.org/pipermail/gnupg-devel/2017-January/032507.html

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
20 months agocore: Optimize fork/exec for *BSD and Solaris.
Werner Koch [Fri, 3 Feb 2017 12:56:23 +0000 (13:56 +0100)]
core: Optimize fork/exec for *BSD and Solaris.

* configure.ac (closefrom): Add to ac_check_funcs.
* src/posix-io.c (_gpgme_io_spawn): Use closefrom.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agocore: Fix possible deadlock due to get_max_fds.
Werner Koch [Fri, 3 Feb 2017 12:13:22 +0000 (13:13 +0100)]
core: Fix possible deadlock due to get_max_fds.

* src/posix-io.c (get_max_fds): Do not use the Linux optimization.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agocore: Minor cleanup of commit 195c735
Werner Koch [Fri, 3 Feb 2017 12:08:39 +0000 (13:08 +0100)]
core: Minor cleanup of commit 195c735

* src/verify.c (parse_tofu_user): For cleanness use gpg_error ...
(_gpgme_verify_status_handler): ... and gpg_err_code.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agoqt: Add test for tofu conflict
Andre Heinecke [Thu, 2 Feb 2017 16:16:27 +0000 (17:16 +0100)]
qt: Add test for tofu conflict

* lang/qt/tests/t-tofuinfo.cpp (TofuInfoTest::testTofuConflict): New.

20 months agocore: Handle multiple TOFU_USER lines in verify
Andre Heinecke [Thu, 2 Feb 2017 13:02:31 +0000 (14:02 +0100)]
core: Handle multiple TOFU_USER lines in verify

* src/verify.c (op_data_t): Add conflict_user_seen.
(parse_tofu_user): Return ERR_DUP_VALUE for mutltiple TOFU_USERS.
(_gpgme_verify_status_handler): Handle ERR_DUP_VALUE from
parse_tofu_user to ignore the next TOFU_STATS.

--
This fixes TOFU Conflict verification with GnuPG-2.1.17 and 2.1.18

GnuPG-Bug-Id: 2914

20 months agocore: Replace all calls to *sprintf by gpgrt_*sprintf.
Werner Koch [Thu, 2 Feb 2017 11:35:59 +0000 (12:35 +0100)]
core: Replace all calls to *sprintf by gpgrt_*sprintf.

* configure.ac (vasprintf): Remove check.
* src/vasprintf.c: Remove file.
* src/util.h (vasprintf, asprintf): Remove prototypes.  Replace all
calls to vasprintf and asprintf by gpgrt_vasprintf or gpgrt_asprintf.
Also take care to use gpgrt_free on the returned value.
* src/w32-util.c (_gpgme_get_gpgconf_path): Replace a gpgrt_asprintf
by _gpgme_strconcat.
(snprintf): New macro to use gpgrt_snprintf instead of the system's
standard snprintf.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agocore: Remove unused check for funopen/fopencookie.
Werner Koch [Thu, 2 Feb 2017 11:28:39 +0000 (12:28 +0100)]
core: Remove unused check for funopen/fopencookie.

* configure.ac (funopen): Remove check.
* src/funopen.c: Remove file.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agocore: Explain in gpgme.h that most stucts are read-only.
Werner Koch [Thu, 2 Feb 2017 09:13:36 +0000 (10:13 +0100)]
core: Explain in gpgme.h that most stucts are read-only.

--

It is common that developers look up only the header file and do not
read the manual.  These comments should make it clear that most
structures in gpgme.h are read-only and may only be allocated by
gpgme.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agocore: Un-deprecate gpgme_data_rewind.
Werner Koch [Thu, 2 Feb 2017 08:50:47 +0000 (09:50 +0100)]
core: Un-deprecate gpgme_data_rewind.

* src/gpgme.h.in (gpgme_data_rewind): Un-deprecate.
* src/data-compat.c (gpgme_data_rewind): Move to ...
* src/data.c (gpgme_data_rewind): here.
--

That function is very convenient because it is required a lot with
memory streams.  It also documents the intention of the caller better
than gpgme_data_seek with its addition parameters and the need to map
system errors.  Thus it does not make sense to make it a first class
citizen again.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agocore: Move all deprecated stuff to the end of gpgme.h.
Werner Koch [Thu, 2 Feb 2017 08:46:01 +0000 (09:46 +0100)]
core: Move all deprecated stuff to the end of gpgme.h.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agocore: Cleanup gpgme_key_unref frees
Andre Heinecke [Wed, 1 Feb 2017 17:06:54 +0000 (18:06 +0100)]
core: Cleanup gpgme_key_unref frees

* src/key.c (gpgme_key_unref): Nowadays we assume free(NULL) is ok.

20 months agocore: Fix leakage of address for mail only uids
Andre Heinecke [Wed, 1 Feb 2017 17:03:35 +0000 (18:03 +0100)]
core: Fix leakage of address for mail only uids

* src/key.c (gpgme_key_unref): Always free address if set.
(_gpgme_key_append_name): Remove memory optimization for address.

--
The check if address is not allocated would now be more complicated
then just comparing it to email because email is set to address
also when an email was not parsed from the user id.

20 months agocore: Improve mailbox only uid handling
Andre Heinecke [Wed, 1 Feb 2017 15:16:22 +0000 (16:16 +0100)]
core: Improve mailbox only uid handling

* src/key.c (_gpgme_key_append_name): Set email and remove name
for uid only keys.

--
If we have a name and no email but the name can be parsed as
an address we now treat the address as email and remove the name.

This fixes downstream users that rely on email to show email
addresses and don't expilicity handle this case.

E.g. A userid foo@example.com was:
uid->name = "foo@example.com"
uid->email = ""
uid->address = "foo@example.com"

It is now:
uid->name = ""
uid->email = "foo@example.com"
uid->address = "foo@example.com"

20 months agoqt: Increase timeout when waiting for signals.
Justus Winter [Tue, 31 Jan 2017 09:47:00 +0000 (10:47 +0100)]
qt: Increase timeout when waiting for signals.

* lang/qt/tests/t-support.h (QSIGNALSPY_TIMEOUT): New macro.
* lang/qt/tests/t-encrypt.cpp: Use the new macro as timeout when
waiting for signals.
* lang/qt/tests/t-keylist.cpp: Likewise.
* lang/qt/tests/t-keylocate.cpp: Likewise.
* lang/qt/tests/t-ownertrust.cpp: Likewise.
* lang/qt/tests/t-wkspublish.cpp: Likewise.
--
Increase the timeout when waiting for signals from 5 seconds to 60.
This addresses intermittent test failures on slow machines.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agocore: Add new context flag "redraw".
Werner Koch [Tue, 31 Jan 2017 08:44:29 +0000 (09:44 +0100)]
core: Add new context flag "redraw".

* src/context.h (struct gpgme_context): New field 'redraw_suggested'.
* src/op-support.c (_gpgme_op_reset): Clear REDRAW_SUGGESTED.
* src/progress.c (_gpgme_progress_status_handler): Set REDRAW_SUGGESTED.
* src/gpgme.c (gpgme_set_ctx_flag, gpgme_get_ctx_flag): Add "redraw".
* tests/run-sign.c (main): Use it.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agotests: Reduce iterations / threads
Andre Heinecke [Mon, 30 Jan 2017 13:19:52 +0000 (14:19 +0100)]
tests: Reduce iterations / threads

* tests/gpg/t-gpgconf.c (main): Reduce iterations to 10.
* tests/gpg/t-thread-keylist-verify.c,
tests/gpg/t-thread-keylist.c (THREAD_COUNT): Reduce to 10.

--
While these tests tested for race conditions a smaller number
of iteration should still show problems if they are run on
multiple systems and regulary. While the 100 Thread count in
the t-thread tests could lead to resource problems.

20 months agopython: Ensure quick-random is used if gpg is gpg2
Andre Heinecke [Thu, 26 Jan 2017 09:44:02 +0000 (10:44 +0100)]
python: Ensure quick-random is used if gpg is gpg2

* lang/python/tests/Makefile.am (gpg.conf): Configure
agent-program accordingly.

20 months agopython: default op_keylist_start parameters.
Tobias Mueller [Sat, 3 Dec 2016 22:12:37 +0000 (23:12 +0100)]
python: default op_keylist_start parameters.

* lang/python/gpgme.i: Added gpgme_op_keylist_start with defaults
* lang/python/tests/t-keylist.py: Added tests for default parameters
--

To increase the ease of use, op_keylist_start
parameters default to sensible values.
The empty string matches all keys.
We assume that the user wants to retrieve public keys most of the time,
so we default to public keys rather than secret keys.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
20 months agotests: Use --debug-quick-random for tests
Andre Heinecke [Wed, 25 Jan 2017 13:10:18 +0000 (14:10 +0100)]
tests: Use --debug-quick-random for tests

* tests/start-stop-agent: Don't autostart agent on --stop and
running check. Use --debug-quick-random when starting.

--
This should speed up the tests especially on low entropy systems.
Possibly fixing a hang on pythons op_genkey test in the Launchpad
build enviorment (see launchpad issue 1655298)

20 months agow32: Fix closing file descriptors.
Justus Winter [Mon, 23 Jan 2017 14:08:23 +0000 (15:08 +0100)]
w32: Fix closing file descriptors.

* src/w32-io.c (writer): Only stop once the buffer is drained.
(destroy_writer): Wait for the writers buffer to be drained.  This
aligns '_gpgme_io_close's behavior with close(2) and fclose(3).

GnuPG-bug-id: 2881
Signed-off-by: Justus Winter <justus@g10code.com>
21 months agotests: Add safeguards against nullptr deref
Andre Heinecke [Tue, 17 Jan 2017 14:20:56 +0000 (15:20 +0100)]
tests: Add safeguards against nullptr deref

* t-gpgconf.c (main): Test some values before dereferencing them.

21 months agoqt: Use QVERIFY instead of Q_ASSERT in conf test
Andre Heinecke [Mon, 16 Jan 2017 13:16:20 +0000 (14:16 +0100)]
qt: Use QVERIFY instead of Q_ASSERT in conf test

* lang/qt/tests/t-config.cpp: Use QVERIFY instead of Q_ASSERT.

21 months agoqt: Add test for CryptoConfig
Andre Heinecke [Wed, 21 Dec 2016 09:32:25 +0000 (10:32 +0100)]
qt: Add test for CryptoConfig

* lang/qt/tests/t-config.cpp: New.
* lang/qt/tests/Makefile.am: Update accordingly.

21 months agotests: Fix distcheck.
Justus Winter [Mon, 16 Jan 2017 12:21:02 +0000 (13:21 +0100)]
tests: Fix distcheck.

* tests/gpg/Makefile.am (CLEANFILES): Remove gpgconf backups.

Fixes-commit: ea7bb62f5d981615847528b3ce53be9cc4d741a7
Signed-off-by: Justus Winter <justus@g10code.com>
21 months agoFix changing options with gpgconf.
Justus Winter [Thu, 12 Jan 2017 13:05:15 +0000 (14:05 +0100)]
Fix changing options with gpgconf.

* src/engine-gpgconf.c (gpgconf_write): Connect a pipe to the child's
stderr, and wait for it to be closed as an indication that gpgconf has
exited.  Also improve error handling.

GnuPG-bug-id: 2881
Signed-off-by: Justus Winter <justus@g10code.com>
21 months agotests: Improve the gpgconf test.
Justus Winter [Thu, 12 Jan 2017 13:01:00 +0000 (14:01 +0100)]
tests: Improve the gpgconf test.

* tests/gpg/t-gpgconf.c: Include support functions.
(fail_if_err): Remove macro.
(init_gpgme): Remove function.
(lookup): New function.
(main): Update some values and verify that the changes are applied.
* tests/gpg/t-support.h (test): New assert-like macro.

GnuPG-bug-id: 2881
Signed-off-by: Justus Winter <justus@g10code.com>
21 months agotests: Enable gpgconf test.
Justus Winter [Mon, 9 Jan 2017 12:09:39 +0000 (13:09 +0100)]
tests: Enable gpgconf test.

--
Fixes: 02ba35c1b6a2cbb3361b2f2ad507c53564b2be0b
Signed-off-by: Justus Winter <justus@g10code.com>
21 months agoqt: Add support for stringValueList in CryptoConf
Andre Heinecke [Thu, 12 Jan 2017 11:57:00 +0000 (12:57 +0100)]
qt: Add support for stringValueList in CryptoConf

* lang/qt/src/Makefile.am (qgpgme_sources): Add cryptoconfig.cpp
* lang/qt/src/cryptoconfig.cpp: New.
* lang/qt/src/cryptoconfig.h (CryptoConfigEntry::stringValueList):
New.
* lang/qt/src/qgpgmenewcryptoconfig.cpp
(QGpgMENewCryptoConfigEntry::stringValueList): New.
* lang/qt/src/qgpgmenewcryptoconfig.h: Update accordingly.

--
This is a pardigm change in cryptoconfig.h to avoid ABI breaks
with each new config value we support it now has an implementation
that is directly related to qgpgmenewcryptoconfig, which is now
the only one.

21 months agoqt: Don't use qstrdup in test passphrase cb
Andre Heinecke [Thu, 12 Jan 2017 10:44:11 +0000 (11:44 +0100)]
qt: Don't use qstrdup in test passphrase cb

* lang/qt/tests/t-support.h (TestPassphraseProvider::getPassphrase):
Use gpgrt_asprintf instead of strdup.

--
To avoid problems on MacOS we want to avoid strdup so that
qgpgme can be built without extensions. But qstrdup allocates
with new and not with malloc, so use gpgrt_asprintf instead.

21 months agoqt: Clean up test dirs on failure
Andre Heinecke [Wed, 11 Jan 2017 15:20:31 +0000 (16:20 +0100)]
qt: Clean up test dirs on failure

* t-encrypt.cpp,
t-keylist.cpp,
t-keylocate.cpp,
t-ownertrust.cpp,
t-tofuinfo.cpp,
t-various.cpp,
t-verify.cpp,
t-wkspublish.cpp: Use QVERIFY instead of Q_ASSERT