1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-05-29 21:58:04 +02:00
Commit Graph

316 Commits

Author SHA1 Message Date
Yuri Chornoivan
24cf0606b4 Clean up word replication.
--

This fixes extra word repetitions (like "the the" or "is is") in the
code and docs.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2017-02-21 13:11:46 -05:00
Justus Winter
90d383f1eb
tests: Test and document other ways to create keys.
* doc/gpg.texi: Clarify usage and expiration arguments for key
generation.
* tests/openpgp/quick-key-manipulation.scm: Test all variants.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-15 15:51:09 +01:00
Justus Winter
127e1e532d
tests: Check expiration times of created keys.
* tests/gpgscm/ffi.c (do_get_time): New function.
(ffi_init): Expose new function.
* tests/gpgscm/ffi.scm (get-time): Document new function.
* tests/gpgscm/time.scm: New file.
* tests/openpgp/quick-key-manipulation.scm: Use the new facilities to
check the expiration times of created keys.
* tests/openpgp/tofu.scm: Use the new module.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-15 14:53:07 +01:00
Werner Koch
b456e5be91
gpg: Make --export-ssh-key work for the primary key.
* g10/export.c (export_ssh_key): Also check the primary key.
--

If no suitable subkey was found for export, we now check whether the
primary key is suitable for export and export this one.  Without this
change it was only possible to export the primary key by using the '!'
suffix in the key specification.

Also added a sample key for testing this.

GnuPG-bug-id: 2957
Signed-off-by: Werner Koch <wk@gnupg.org>
2017-02-14 10:55:13 +01:00
Justus Winter
6823ed4658
gpg,common: Make sure that all fd given are valid.
* common/sysutils.c (gnupg_fd_valid): New function.
* common/sysutils.h (gnupg_fd_valid): New declaration.
* common/logging.c (log_set_file): Use the new function.
* g10/cpr.c (set_status_fd): Likewise.
* g10/gpg.c (main): Likewise.
* g10/keylist.c (read_sessionkey_from_fd): Likewise.
* g10/passphrase.c (set_attrib_fd): Likewise.
* tests/openpgp/Makefile.am (XTESTS): Add the new test.
* tests/openpgp/issue2941.scm: New file.
--

Consider a situation where the user passes "--status-fd 3" but file
descriptor 3 is not open.

During the course of executing the rest of the commands, it's possible
that gpg itself will open some files, and file descriptor 3 will get
allocated.

In this situation, the status information will be appended directly to
whatever file happens to have landed on fd 3 (the trustdb? the
keyring?).

This is a potential data destruction issue for all writable file
descriptor options:

   --status-fd
   --attribute-fd
   --logger-fd

It's also a potential issue for readable file descriptor options, but
the risk is merely weird behavior, and not data corruption:

   --override-session-key-fd
   --passphrase-fd
   --command-fd

Fixes this by checking whether the fd is valid early on before using
it.

GnuPG-bug-id: 2941
Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-08 14:28:49 +01:00
Justus Winter
56aa85f88f tests: Skip key types not supported by OpenSSH.
* tests/openpgp/ssh-import.scm (path): New variable.
(ssh,ssh-keygen,ssh-version,ssh-supports?): Likewise.
--

Skip algorithms not supported by the OpenSSH in the ssh import test.
This notably fixes the test on macOS when the stock ssh version is
used.

GnuPG-bug-id: 2847
GnuPG-bug-id: 2947
Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-07 18:08:33 +01:00
Neal H. Walfield
64be8e1e86 tests: Improve description of test.
* tests/openpgp/issue2929.scm: Improve description of test.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
2017-02-02 14:47:34 +01:00
Neal H. Walfield
e596b21f4b Revert "Revert "tests: Add test demonstrating issue2929.""
This reverts commit 59048b0f1a.
2017-02-02 14:43:15 +01:00
Justus Winter
59048b0f1a Revert "tests: Add test demonstrating issue2929."
This reverts commit 5aafa56dff.
2017-01-30 13:25:32 +01:00
Justus Winter
5aafa56dff tests: Add test demonstrating issue2929.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/issue2929.scm: New file.
--
This test demonstrates a problem with the TOFU trust model when a new
key is created.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-24 14:28:36 +01:00
Justus Winter
628ff84346 tests: Enable gpgconf test.
* tests/openpgp/Makefile.am (XTESTS): Re-add gpgconf.scm.
--
This partially reverts 25e0298238.

That change was not sufficiently motivated, and our continuous
integration server shows no recent distcheck failures.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-24 14:20:36 +01:00
Werner Koch
25e0298238
build: Change make distcheck configure and temp. remove gpgconf.scm.
* Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Also test gpgtar and
wks-tools.  Disable ntbtls.
* tests/openpgp/Makefile.am (XTESTS): Temporary remove gpgconf.scm.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-01-23 21:14:32 +01:00
Justus Winter
8b1611a960 tests: Improve GPGHOME handling.
* tests/openpgp/defs.scm (GPGHOME): New variable.
* tests/openpgp/ssh-import.scm: Remove redundant code, use 'path-join'.
* tests/openpgp/tofu.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-16 13:59:56 +01:00
Justus Winter
88e42ef08d tests: Improve gpgconf test.
* tests/openpgp/defs.scm (valgrind): New variable.
(gpg-config): Fix clearing an option.
* tests/openpgp/gpgconf.scm: Also toggle 'quiet'.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-10 15:50:57 +01:00
Justus Winter
c8cfc62125 tests: Add test for gpgconf.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/defs.scm (percent-encode): New function.
(gpg-conf): Generalize so that we can feed stdin.
(gpg-config): New function.
* tests/openpgp/gpgconf.scm: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-10 12:40:52 +01:00
Justus Winter
168c8c9d79 tests: New test for --{show,override}-session-key.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/decrypt-session-key.scm: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-05 17:05:59 +01:00
Justus Winter
4ded213698 tests: Fix macro.
* tests/openpgp/defs.scm (with-ephemeral-home-directory): Make
hygienic, use define-macro, do not change to the ephemeral home
directory.
* tests/gpgsm/setup.scm: Change to the ephemeral home directory.
* tests/openpgp/setup.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-05 17:00:36 +01:00
Justus Winter
28e149609d tests,w32: Fix locating the components.
* tests/openpgp/defs.scm (percent-decode): New function.
(bin-prefix): New variable.
(installed?): Likewise.
(tool-hardcoded): Use the new variables.
(gpg-conf): Use the new function to decode the values.
(gpg-components): Do not use '--build-prefix' when 'installed?'.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-04 16:54:41 +01:00
Justus Winter
6d06519833 tests: Fix faked time in the TOFU test.
* tests/openpgp/tofu.scm (GPG): Fix time delta.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-01-02 18:23:34 +01:00
Justus Winter
c067a012c7 tests: Add macro managing ephemeral home directories.
* tests/openpgp/defs.scm (with-ephemeral-home-directory): New macro.
* tests/openpgp/setup.scm: Use the new macro.
2016-12-20 16:49:05 +01:00
Justus Winter
e2ed3c1597 tests: Add missing encrypted sample, cleanup samples handling.
* tests/openpgp/Makefile.am (TEST_FILES): Add new file.
* tests/openpgp/defs.scm (plain-files): Add 'plain-large'.
(all-files): New variable.
(create-sample-files): New function.
(create-legacy-gpghome): Use new function.
* tests/openpgp/plain-large.asc: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-20 16:25:35 +01:00
Justus Winter
0bf16d7026 tests: Use sequential test runner if only one test is given.
* tests/openpgp/run-tests.scm: Use sequential test runner if only one
test is given.
--

This allows one to set the environment variable TESTFLAGS to
'--parallel' and enjoy faster test execution times without interfering
with stdio when one works on a single test.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-19 17:23:56 +01:00
Neal H. Walfield
aec89a7297 test: Extend TOFU tests to also check the days with signatures.
* tests/openpgp/tofu.scm (GPGTIME): Define the "standard" base time.
(faketime): New function.
(days->seconds): Likewise.
(GPG): Use faketime.
(check-counts): Also check the number of expected days with signatures
and encryptions.  Update callers.  Extend tests.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
2016-12-19 16:01:39 +01:00
Justus Winter
a1afc450e1 tests: New test for --delete-[secret-]keys.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/defs.scm (keys): New variable.
(have-public-key?): New function.
(have-secret-key?): Likewise.
(have-secret-key-file?): Likewise.
* tests/openpgp/delete-keys.scm: New file.
* tests/openpgp/quick-key-manipulation.scm: Move the accessors to
'defs.scm'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-19 15:42:35 +01:00
Justus Winter
41ad04d403 g10: Rework the --quick-* interface.
* g10/gpg.c (opts): Rename options.
(main): Update errors.
* doc/gpg.texi: Update accordingly.
--
I decided not to keep the old versions as aliases in the documentation
because the interface is a fairly recent addition.

GnuPG-bug-id: 2700
Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-15 15:32:51 +01:00
Justus Winter
ca1e9749bf common: Support locating components in the build tree.
* common/homedir.c (gnupg_build_directory): New variable.
(gnupg_module_name_called): Likewise.
(gnupg_set_builddir): New function.
(gnupg_set_builddir_from_env): Likewise.
(gnupg_module_name): Support locating components in the build tree.
* common/util.h (gnupg_set_builddir): New prototype.
* tests/openpgp/defs.scm (tools): Drop 'gpg and 'gpg-agent.
(tool): Rename to 'tool-hardcoded.
(gpg-conf): New function, with accessors for the results.
(gpg-components): New variable.
(tool): New function.
* tools/gpgconf.c (enum cmd_and_opt_values): New key.
(opts): New option '--build-prefix'.
(main): Handle new option.
--

This change makes sure that the components from the build tree are
used, and not some older installed version in PATH.  It also lets us
make GPGME use components from the build tree, making it possible to
execute GPGME's test suite with them.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-14 16:41:18 +01:00
Justus Winter
55dc81125a tests: Rework check for trust models.
* tests/openpgp/defs.scm (gpg-has-option?): New function.
(have-opt-always-trust): Use a simpler test for that option.  This way
that is less distracting when we run the tests with verbose=3.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-14 16:41:18 +01:00
Justus Winter
892c827e72 g10,sm: Spell out --gen-key.
* g10/gpg.c (opts): Spell out option.
* sm/gpgsm.c (opts): Likewise.
* doc/gpg.texi: Update accordingly.

GnuPG-bug-id: 2700
Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-13 17:30:55 +01:00
Justus Winter
04754ce3a7 g10: Hyphenate --clearsign.
* g10/gpg.c (opts): Hyphenate option.
* doc/gpg.texi: Update accordingly.
* po: Update translations.
* tests/openpgp: Update tests.

GnuPG-bug-id: 2700
Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-13 17:30:54 +01:00
Justus Winter
dd3dde07a9 g10: Create expiring keys in quick key generation mode.
* doc/gpg.texi: Document that fact.
* g10/keygen.c (quick_generate_keypair): Use a default value.
* tests/openpgp/quick-key-manipulation.scm: Test that fact.

GnuPG-bug-id: 2701
Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-13 16:35:08 +01:00
Justus Winter
d43dabf460 gpgscm: Generalize the test runner.
* tests/gpgscm/tests.scm (test::scm) Add explicit name argument.
(test::binary): Likewise.  Also, add missing unquote.
* tests/openpgp/run-tests.scm: Adapt accordingly.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-13 15:09:26 +01:00
Justus Winter
1a176b92a8 gpgscm: Move the test runner to the Scheme library.
* tests/openpgp/run-tests.scm: Move most of the code...
* tests/gpgscm/tests.scm: ... here.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-13 15:09:26 +01:00
Justus Winter
fe36e63763 tests: Refactor test runner.
* tests/openpgp/run-tests.scm (locate-test): New function.
(test): Factor-out the code starting the child process.
(test::binary): New function.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-13 15:09:26 +01:00
Justus Winter
b778d8deed tests: Add a test for '--quick-addkey'.
* tests/openpgp/quick-key-manipulation.scm: Test '--quick-addkey'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-09 13:22:37 +01:00
Justus Winter
59f1562c25 tests: New test using all available compression algorithms.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/compression.scm: New file.
* tests/openpgp/defs.scm (all-compression-algos): New variable.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-09 13:13:45 +01:00
Justus Winter
dec2ae31a4 tests: Add test for '--quick-set-expire'.
* tests/openpgp/quick-key-manipulation.scm: Test '--quick-set-expire'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-07 15:12:19 +01:00
Justus Winter
92df40a3a2 tests: Improve quick key manipulation test.
* tests/openpgp/quick-key-manipulation.scm: Do not update the trust
database, rather be more specific when filtering the user ids.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-07 14:49:49 +01:00
Justus Winter
e352ead43f tests: Add test importing a revocation certificate.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/import-revocation-certificate.scm: New file.
* tests/openpgp/samplemsgs/revoke-2D727CC768697734.asc: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-06 15:33:25 +01:00
Justus Winter
5b5d881f47 tests: Rename 'error' to 'fail'.
* tests/gpgscm/tests.scm (error): Rename to 'fail'.  'error' is a
primitive function (an opcode) of the TinySCHEME vm, and 'error' is
also defined by R6RS.  Better avoid redefining that.  Fix all call
sites.
* tests/openpgp/4gb-packet.scm: Adapt.
* tests/openpgp/decrypt-multifile.scm: Likewise.
* tests/openpgp/ecc.scm: Likewise.
* tests/openpgp/export.scm: Likewise.
* tests/openpgp/gpgtar.scm: Likewise.
* tests/openpgp/gpgv-forged-keyring.scm: Likewise.
* tests/openpgp/import.scm: Likewise.
* tests/openpgp/issue2015.scm: Likewise.
* tests/openpgp/issue2346.scm: Likewise.
* tests/openpgp/issue2419.scm: Likewise.
* tests/openpgp/key-selection.scm: Likewise.
* tests/openpgp/mds.scm: Likewise.
* tests/openpgp/multisig.scm: Likewise.
* tests/openpgp/setup.scm: Likewise.
* tests/openpgp/signencrypt.scm: Likewise.
* tests/openpgp/ssh-import.scm: Likewise.
* tests/openpgp/tofu.scm: Likewise.
* tests/openpgp/verify.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-06 15:25:55 +01:00
Justus Winter
89ac071eb4 tests: Remove debugging display.
* tests/openpgp/tofu.scm: Remove debugging display.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-06 15:25:44 +01:00
Neal H. Walfield
87972fdef2 tests: Update distributed files
* tests/openpgp/Makefile.am (TEST_FILES): Remove tofu-keys.asc,
tofu-keys-secret.asc, tofu-2183839A-1.txt, tofu-BC15C85A-1.txt and
tofu-EE37CF96-1.txt.  Add tofu/conflicting/1C005AF3.gpg,
tofu/conflicting/1C005AF3-secret.gpg, tofu/conflicting/1C005AF3-1.txt,
tofu/conflicting/1C005AF3-2.txt, tofu/conflicting/1C005AF3-3.txt,
tofu/conflicting/1C005AF3-4.txt, tofu/conflicting/1C005AF3-5.txt,
tofu/conflicting/B662E42F.gpg, tofu/conflicting/B662E42F-secret.gpg,
tofu/conflicting/B662E42F-1.txt, tofu/conflicting/B662E42F-2.txt,
tofu/conflicting/B662E42F-3.txt, tofu/conflicting/B662E42F-4.txt,
tofu/conflicting/B662E42F-5.txt, tofu/conflicting/BE04EB2B.gpg,
tofu/conflicting/BE04EB2B-secret.gpg, tofu/conflicting/BE04EB2B-1.txt,
tofu/conflicting/BE04EB2B-2.txt, tofu/conflicting/BE04EB2B-3.txt,
tofu/conflicting/BE04EB2B-4.txt, tofu/conflicting/BE04EB2B-5.txt and
tofu/conflicting/README.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
Fixes-commit: d5b18d6
2016-12-06 14:26:36 +01:00
Neal H. Walfield
17c717d7c9 tests: Check the signature count in the TOFU TFS record.
* tests/openpgp/tofu.scm: Check the signature count in the TOFU TFS
record.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
2016-12-06 12:16:57 +01:00
Neal H. Walfield
d5b18d6c55 tests: Replace data used by the TOFU conflict test.
* tests/openpgp/tofu-2183839A-1.txt: Remove file.
* tests/openpgp/tofu-BC15C85A-1.txt: Remove file.
* tests/openpgp/tofu-EE37CF96-1.txt: Remove file.
* tests/openpgp/tofu-keys-secret.asc: Remove file.
* tests/openpgp/tofu-keys.asc: Remove file.
* tests/openpgp/tofu/conflicting/1C005AF3.gpg: New file.
* tests/openpgp/tofu/conflicting/1C005AF3-secret.gpg: New file.
* tests/openpgp/tofu/conflicting/1C005AF3-1.txt: New file.
* tests/openpgp/tofu/conflicting/1C005AF3-2.txt: New file.
* tests/openpgp/tofu/conflicting/1C005AF3-3.txt: New file.
* tests/openpgp/tofu/conflicting/1C005AF3-4.txt: New file.
* tests/openpgp/tofu/conflicting/1C005AF3-5.txt: New file.
* tests/openpgp/tofu/conflicting/B662E42F.gpg: New file.
* tests/openpgp/tofu/conflicting/B662E42F-secret.gpg: New file.
* tests/openpgp/tofu/conflicting/B662E42F-1.txt: New file.
* tests/openpgp/tofu/conflicting/B662E42F-2.txt: New file.
* tests/openpgp/tofu/conflicting/B662E42F-3.txt: New file.
* tests/openpgp/tofu/conflicting/B662E42F-4.txt: New file.
* tests/openpgp/tofu/conflicting/B662E42F-5.txt: New file.
* tests/openpgp/tofu/conflicting/BE04EB2B.gpg: New file.
* tests/openpgp/tofu/conflicting/BE04EB2B-secret.gpg: New file.
* tests/openpgp/tofu/conflicting/BE04EB2B-1.txt: New file.
* tests/openpgp/tofu/conflicting/BE04EB2B-2.txt: New file.
* tests/openpgp/tofu/conflicting/BE04EB2B-3.txt: New file.
* tests/openpgp/tofu/conflicting/BE04EB2B-4.txt: New file.
* tests/openpgp/tofu/conflicting/BE04EB2B-5.txt: New file.
* tests/openpgp/tofu/conflicting/README: New file.
* tests/openpgp/tofu.scm: Update accordingly.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>

There are two motivations for this change.  First, we decided that
test data should live in a subdirectory rather than in tests/openpgp.
Second, secret key material is password protected, and I don't
remember the password that I used.  (The new data is not password
protected.)  I have also added some new examples of signed messages.
2016-12-06 12:16:57 +01:00
Justus Winter
fae4d06b0c tests: New test for '--enarmor' and '--dearmor'.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/enarmor.scm: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-05 10:42:23 +01:00
Justus Winter
fbdfe6a514 tests,build: Fix distcheck.
* tests/openpgp/Makefile.am (sample_msgs): Add messages required for
the new test 'verify-multifile.scm'.

Fixes-commit: 12af8e84a3
Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-01 13:40:08 +01:00
Justus Winter
12af8e84a3 tests: Add test for '--verify --multifile'.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/verify-multifile.scm: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-12-01 11:16:31 +01:00
Justus Winter
3c0569e994 tests: Add test for '--encrypt --multifile'.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/encrypt-multifile.scm: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-30 11:29:50 +01:00
Justus Winter
bde4fddadc tests: Add test for '--decrypt --multifile'.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/decrypt-multifile.scm: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-29 14:45:56 +01:00
Justus Winter
47b8b9e2ce tests: Add test for the ssh key export.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
(sample_keys): Add new files.
* tests/openpgp/samplekeys/authenticate-only.pub.asc: New file.
* tests/openpgp/samplekeys/authenticate-only.sec.asc: Likewise.
* tests/openpgp/ssh-export.scm: Likewise.

GnuPG-bug-id: 2848
Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-28 13:48:49 +01:00
Justus Winter
cc1d213426 tests: Rename ssh test.
* tests/openpgp/ssh.scm: Rename to 'ssh-import.scm'.
* tests/openpgp/Makefile (XTESTS): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-28 13:48:19 +01:00
Neal H. Walfield
44c17bcb00 g10: If the set of UTKs changes, invalidate any changed policies.
* g10/trustdb.c (tdb_utks): New function.
* g10/tofu.c (check_utks): New function.
(initdb): Call it.
* tests/openpgp/tofu.scm: Modify test to check the effective policy of
keys whose effective policy changes when we change the set of UTKs.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>

If the set of ultimately trusted keys changes, then it is possible
that a binding's effective policy changes.  To deal with this, we
detect when the set of ultimately trusted keys changes and invalidate
all cached policies.
2016-11-22 15:24:05 +01:00
Justus Winter
893a3f7fb4 tests: Delay querying the avaliable algorithms.
* tests/openpgp/defs.scm: Set verbosity earlier, turn 'all-*-algos'
into promises.
* tests/openpgp/conventional-mdc.scm: Force the promises.
* tests/openpgp/conventional.scm: Likewise.
* tests/openpgp/encrypt-dsa.scm: Likewise.
* tests/openpgp/encrypt.scm: Likewise.
* tests/openpgp/gpgtar.scm: Likewise.
* tests/openpgp/sigs.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-22 12:09:47 +01:00
Neal H. Walfield
037f9de092 g10: Cache the effective policy. Recompute it when required.
* g10/tofu.c (initdb): Add column effective_policy to the bindings
table.
(record_binding): New parameters effective_policy and set_conflict.
Save the effective policy.  If SET_CONFLICT is set, then set conflict
according to CONFLICT.  Otherwise, preserve the current value of
conflict.  Update callers.
(get_trust): Don't compute the effective policy here...
(get_policy): ... do it here, if it was not cached.  Take new
parameters, PK, the public key, and NOW, the time that the operation
started.  Update callers.
(show_statistics): New parameter PK.  Pass it to get_policy.  Update
callers.
(tofu_notice_key_changed): New function.
* g10/gpgv.c (tofu_notice_key_changed): New stub.
* g10/import.c (import_revoke_cert): Take additional argument CTRL.
Pass it to keydb_update_keyblock.
* g10/keydb.c (keydb_update_keyblock): Take additional argument CTRL.
Update callers.
[USE_TOFU]: Call tofu_notice_key_changed.
* g10/test-stubs.c (tofu_notice_key_changed): New stub.
* tests/openpgp/tofu.scm: Assume that manually setting a binding's
policy to auto does not cause the tofu engine to forget about any
conflict.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>

We now store the computed policy in the tofu DB (in the
effective_policy column of the bindings table) to avoid computing it
every time, which is expensive.  Further, policy is never overridden
in case of a conflict.  Instead, we detect a conflict if CONFLICT is
not empty.

This change is backwards compatible to existing DBs.  The only minor
incompatibility is that unresolved conflicts won't be automatically
resolved in case we import a direct signature, or cross signatures.
2016-11-21 22:47:30 +01:00
Justus Winter
1062953d51 tests: Fix environment setup.
* tests/openpgp/defs.scm (setup-legacy-environment): Do not call
'setup-environment' because that will start the agent, and hence
register the atexit function twice.

Fixes: a55393cb5f
Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-08 16:15:32 +01:00
Justus Winter
2a7615c48e tests: Log and display output from tests when run in parallel.
* tests/openpgp/run-tests.scm (test): Add field 'logfd'.
(test::new, test::set-*): Adapt accordingly.
(test::set-logfd): New function.
(test::open-log-file): Likewise.
(test::run-sync): Use the new function.
(test::run-async): Likewise.
(test::report): Replay the log.
(run-tests-parallel): Reverse the results to restore the original
order.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-08 16:03:16 +01:00
Justus Winter
4dd4801bfa tests: Simplify test.
* tests/openpgp/issue2417.scm: Simplify.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-08 16:03:16 +01:00
Justus Winter
dd13b2a561 tests,w32: Make cleanup more robust.
* tests/openpgp/run-tests.scm (run-tests-parallel): Catch errors when
removing the working directory.  On Windows this can fail if there is
still a process using one of the files there.
(run-tests-sequential): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-08 16:02:55 +01:00
Justus Winter
26df829fa2 tests: Write a log file for each test.
* tests/openpgp/Makefile.am (CLEANFILES): Delete logs.
* tests/openpgp/run-tests.scm (test::run-sync): Write logs.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 17:44:34 +01:00
Justus Winter
a55393cb5f tests: Move environment creation and teardown into each test.
* tests/gpgscm/tests.scm (log): New function.
* tests/openpgp/run-tests.scm (run-tests-parallel): Do not run the
startup and teardown scripts.
(run-tests-sequential): Likewise.
* tests/openpgp/setup.scm: Move all functions...
* tests/openpgp/defs.scm: ... here and make them less verbose.
(setup-environment): New function.
(setup-legacy-environment): Likewise.
(start-agent): Make less verbose, run 'stop-agent' at interpreter
exit.
(stop-agent): Make less verbose.
* tests/openpgp/finish.scm: Drop file.
* tests/openpgp/Makefile.am (EXTRA_DIST): Drop removed file.
* tests/openpgp/4gb-packet.scm: Use 'setup-environment' or
'setup-legacy-environment' as appropriate.
* tests/openpgp/armdetach.scm: Likewise.
* tests/openpgp/armdetachm.scm: Likewise.
* tests/openpgp/armencrypt.scm: Likewise.
* tests/openpgp/armencryptp.scm: Likewise.
* tests/openpgp/armor.scm: Likewise.
* tests/openpgp/armsignencrypt.scm: Likewise.
* tests/openpgp/armsigs.scm: Likewise.
* tests/openpgp/clearsig.scm: Likewise.
* tests/openpgp/conventional-mdc.scm: Likewise.
* tests/openpgp/conventional.scm: Likewise.
* tests/openpgp/decrypt-dsa.scm: Likewise.
* tests/openpgp/decrypt.scm: Likewise.
* tests/openpgp/default-key.scm: Likewise.
* tests/openpgp/detach.scm: Likewise.
* tests/openpgp/detachm.scm: Likewise.
* tests/openpgp/ecc.scm: Likewise.
* tests/openpgp/encrypt-dsa.scm: Likewise.
* tests/openpgp/encrypt.scm: Likewise.
* tests/openpgp/encryptp.scm: Likewise.
* tests/openpgp/export.scm: Likewise.
* tests/openpgp/finish.scm: Likewise.
* tests/openpgp/genkey1024.scm: Likewise.
* tests/openpgp/gpgtar.scm: Likewise.
* tests/openpgp/gpgv-forged-keyring.scm: Likewise.
* tests/openpgp/import.scm: Likewise.
* tests/openpgp/issue2015.scm: Likewise.
* tests/openpgp/issue2417.scm: Likewise.
* tests/openpgp/issue2419.scm: Likewise.
* tests/openpgp/key-selection.scm: Likewise.
* tests/openpgp/mds.scm: Likewise.
* tests/openpgp/multisig.scm: Likewise.
* tests/openpgp/quick-key-manipulation.scm: Likewise.
* tests/openpgp/seat.scm: Likewise.
* tests/openpgp/shell.scm: Likewise.
* tests/openpgp/signencrypt-dsa.scm: Likewise.
* tests/openpgp/signencrypt.scm: Likewise.
* tests/openpgp/sigs-dsa.scm: Likewise.
* tests/openpgp/sigs.scm: Likewise.
* tests/openpgp/ssh.scm: Likewise.
* tests/openpgp/tofu.scm: Likewise.
* tests/openpgp/use-exact-key.scm: Likewise.
* tests/openpgp/verify.scm: Likewise.
* tests/openpgp/version.scm: Likewise.
* tests/openpgp/issue2346.scm: Likewise and simplify.
--

The previous Bourne Shell-based test suite created the environment
before running all tests, and tore it down after executing them.  When
we created the Scheme-based test suite, we kept this design at first,
but introduced a way to run each test in its own environment to
prevent tests from interfering with each other.  Nevertheless, every
test started out with the same environment.

Move the creation of the test environment into each test.  This gives
us finer control over the environment each test is run in.  It also
makes it possible to run each test by simply executing it using gpgscm
without the use of the runner.  Furthermore, it has the neat
side-effect of speeding up the test suite if run in parallel.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 16:36:36 +01:00
Justus Winter
ac078469cb tests: Do not allow tests to be run in a shared environment.
* tests/openpgp/README: Update.
* tests/openpgp/run-tests.scm (run-tests-parallel-shared): Drop
function.
(run-tests-parallel-isolated): Rename to 'run-tests-parallel'.
(run-tests-sequential-shared): Drop function.
(run-tests-sequential-isolated): Rename to 'run-tests-sequential'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 14:57:51 +01:00
Justus Winter
37751d2b19 tests: Fix build.
* tests/openpgp/Makefile.am: Drop dependency on 'mk-tdata'.

Fixes: 70215ff470
Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 14:10:38 +01:00
Justus Winter
70215ff470 tests,tools: Reimplement 'mk-tdata' in Scheme.
* tests/openpgp/defs.scm (tools): Drop 'mk-tdata'.
* tests/openpgp/setup.scm (make-test-data): New function.
* tests/openpgp/verify.scm: Avoid 'mk-tdata'.
* tools/Makefile.am (noinst_PROGRAMS): Drop 'mk-tdata'.
* tools/mk-tdata.c: Drop file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-07 13:28:55 +01:00
Werner Koch
4d7dc432b5
Change all http://www.gnu.org in license notices to https://
--
2016-11-05 12:02:19 +01:00
Justus Winter
ab89164be0 g10: Improve and unify key selection for -r and --locate-keys.
* g10/getkey.c (struct pubkey_cmp_cookie): New type.
(key_is_ok, uid_is_ok, subkey_is_ok): New functions.
(pubkey_cmp): Likewise.
(get_best_pubkey_byname): Likewise.
* g10/keydb.h (get_best_pubkey_byname): New prototype.
* g10/keylist.c (locate_one): Use the new function.
* g10/pkclist.c (find_and_check_key): Likewise.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
(TEST_FILES): Add new files.
* tests/openpgp/key-selection.scm: New file.
* tests/openpgp/key-selection/0.asc: Likewise.
* tests/openpgp/key-selection/1.asc: Likewise.
* tests/openpgp/key-selection/2.asc: Likewise.
* tests/openpgp/key-selection/3.asc: Likewise.
* tests/openpgp/key-selection/4.asc: Likewise.
--

When a name resembling a mail address is given to either --locate-keys
or --recipient, rank the search results and use only the most relevant
key.

This also lets us query which key will be used for encryption using
--locate-keys.  However, note that --locate-keys may also return keys
incapable of encryption, though it will prefer keys that have an
encryption subkey.

GnuPG-bug-id: 2359
Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-03 15:04:18 +01:00
Justus Winter
1ec07cbc20 gpgscm,tests: Add new functions to the test environment.
* tests/gpgscm/lib.scm (first, last, powerset): New functions.
* tests/gpgscm/tests.scm (interactive-shell): New function.
* tests/openpgp/Makefile.am (EXTRA_DIST): Add new file.
* tests/openpgp/README: Document 'interactive-shell'.
* tests/openpgp/shell.scm: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-11-03 14:43:23 +01:00
Daniel Kahn Gillmor
68b59bbc42 Spelling: correct spelling of "passphrase".
There were several different variant spellings of "passphrase".  This
should fix them all for all English text.

I did notice that po/it.po contains multiple instances of
"passhprase", which also looks suspect to me, but i do not know
Italian, so i did not try to correct it.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-11-02 12:53:58 +01:00
Werner Koch
21b318452a
tests: Improve portability of fake-pinentry.
* tests/openpgp/fake-pinentry.c: Make all functions static.
(get_passphrase): s/unlink/remove/ because that is standard C.
(spacep): Rename to whitespace and change all callers.
(main): Move macro out of if-then chain.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-10-26 08:34:18 +02:00
Justus Winter
852b8f0b89 agent,tests,w32: Fix relaying pinentry user data, fix fake-pinentry.
* agent/call-pinentry.c (start_pinentry): Also send the user data
using an Assuan 'OPTION' command.
* tests/openpgp/fake-pinentry.c (get_passphrase): Fix updating
passphrase file.
(spacep): Include newline characters.
(rstrip): New function.
(main): Handle Windows line endings.  Handle the userdata option, and
restart with the new options.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-25 17:07:08 +02:00
Justus Winter
f88f11a256 tests: Do not autostart gpg-agents on teardown.
* tests/openpgp/defs.c (stop-agent): Use '--no-autostart' when calling
gpg-connect-agent.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-25 17:06:05 +02:00
Justus Winter
71158d8d5f tests: Simplify test.
* tests/openpgp/quick-key-manipulation.scm: Avoid creating a temporary
home directory, just make the uids unique.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-20 17:01:24 +02:00
Justus Winter
ca9597f080 tests: Flush stdout in the fake pinentry.
* tests/openpgp/fake-pinentry.c (reply): Flush stdout.

Fixes-commit: 94504b3d5a
Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-20 17:01:24 +02:00
Justus Winter
bf37916a23 tests,w32: Cope with Windows line endings.
* tests/openpgp/issue2015.scm: Rstrip line before comparison.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-20 17:01:23 +02:00
Justus Winter
2d794779e0 tests: Create and remove socket directories.
* tests/openpgp/defs.scm (start-agent): Move function here and create
the socket directory prior to starting the agent.
(stop-agent): Move function here and remove the socket directory.
* tests/openpgp/finish.scm: Adapt.
* tests/openpgp/setup.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-20 17:01:23 +02:00
Neal H. Walfield
0c56ad5a8d tests: Use shorter filenames.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-1.gpg: Rename from this...
* tests/openpgp/tofu/cross-sigs/EC38277E-1.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-1.txt: Rename from this...
* tests/openpgp/tofu/cross-sigs/EC38277E-1.txt: .. to this.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-2.gpg: Rename from this...
* tests/openpgp/tofu/cross-sigs/EC38277E-2.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-2.txt: Rename from this...
* tests/openpgp/tofu/cross-sigs/EC38277E-2.txt: .. to this.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-3.txt: Rename from this...
* tests/openpgp/tofu/cross-sigs/EC38277E-3.txt: .. to this.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-secret.gpg: Rename from
  this...
* tests/openpgp/tofu/cross-sigs/EC38277E-secret.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-1.gpg: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-1.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-1.txt: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-1.txt: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-2.gpg: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-2.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-2.txt: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-2.txt: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-3.gpg: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-3.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-3.txt: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-3.txt: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-4.gpg: Rename from this...
* tests/openpgp/tofu/cross-sigs/871C2247-4.gpg: .. to this.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-secret.gpg: Rename from
  this...
* tests/openpgp/tofu/cross-sigs/871C2247-secret.gpg: .. to this.
* tests/openpgp/Makefile.am (TEST_FILES): Update accordingly.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
Fixed-commit: d2d936fbe8
2016-10-13 21:45:44 +02:00
Neal H. Walfield
95d0f3e5ee g10: Be more careful when checking if a binding is signed by a UTK.
* g10/tofu.c (signed_by_utk): When checking if a key is signed by an
ultimately trusted key, only consider the signatures on the specified
user id.
* tests/openpgp/tofu.scm: Add test for the above.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2016-10-13 21:14:55 +02:00
Neal H. Walfield
d2d936fbe8 tests: Add test data to TEST_FILES.
* tests/openpgp/Makefile.am (TEST_FILES): Add new test data.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
Fixes-commit: 4c0389f8eb
2016-10-13 14:26:53 +02:00
Neal H. Walfield
4c0389f8eb g10: Be more careful when checking cross signatures.
* g10/tofu.c (cross_sigs): When checking cross signatures, only
consider the signatures on the specified user id.
* tests/openpgp/tofu.scm: Add test for the above.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-1.gpg:
  New file.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-1.txt: New file.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-2.gpg: New file.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-2.txt: New file.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-3.txt: New file.
* tests/openpgp/tofu/cross-sigs/
  1938C3A0E4674B6C217AC0B987DB2814EC38277E-secret.gpg: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-1.gpg: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-1.txt: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-2.gpg: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-2.txt: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-3.gpg: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-3.txt: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-4.gpg: New file.
* tests/openpgp/tofu/cross-sigs/
  DC463A16E42F03240D76E8BA8B48C6BD871C2247-secret.gpg: New file.
* tests/openpgp/tofu/cross-sigs/README: New file.

--
Signed-off-by: Neal H. Walfield
2016-10-13 12:44:59 +02:00
Neal H. Walfield
2282c3b761 tests: Remove support for deprecated functionality.
* tests/openpgp/tofu.scm: Don't remove tofu.d.  It's deprecated.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2016-10-13 12:30:12 +02:00
Justus Winter
cbbf0a7a8d tests: Rework test environment setup.
* tests/openpgp/setup.scm: Import one keyring at a time.  This works
around a yet to be investigated hang on Windows.  It is also much
prettier.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-07 16:25:55 +02:00
Justus Winter
1f76f8d8bc tests: Improve handling of Windows newlines.
* tests/gpgscm/lib.scm (string-split-newlines): New function.
* tests/openpgp/default-key.scm: Use new function.
* tests/openpgp/defs.scm: Likewise.
* tests/openpgp/export.scm: Likewise.
* tests/openpgp/import.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-07 16:25:55 +02:00
Justus Winter
949e70115e tests,w32: Avoid using 'glob'.
* tests/openpgp/setup.scm: Avoid 'glob' which is not available on
mingw.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-10-04 13:23:17 +02:00
Neal H. Walfield
df5353b95e g10: When adding a user id, make sure the keyblock has been prepared.
* g10/keyedit.c (keyedit_quick_adduid): Call merge_keys_and_selfsig on
KEYBLOCK before adding the user id.
* tests/openpgp/quick-key-manipulation.scm: Make sure that the key
capabilities don't change when adding a user id.
(key-data): New function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
GnuPG-bug-id: 2697
2016-09-22 21:32:31 +02:00
Justus Winter
7e0379a754 tests: Add documentation, make interactive debugging possible.
* tests/openpgp/README: Add documentation about debugging and
interfacing with GnuPG.
* tests/openpgp/run-tests.scm (test::run-sync): Hand stdin to the
child so that we can use a repl in the tests.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-20 15:55:02 +02:00
Justus Winter
c644962fcf tests: Drop the old shell-based tests.
--
Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-20 15:55:02 +02:00
Justus Winter
6c4c0e3ac2 tests: Port the quick key manipulation test to Scheme.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/quick-key-manipulation.scm: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-20 15:33:57 +02:00
Justus Winter
49fae88fd1 tests: Remove list of tests from the test runner.
* tests/openpgp/run-tests.scm: Drop hardcoded list.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-20 15:33:57 +02:00
Justus Winter
988a04b98d tests: Reduce runtime of excessive test.
* tests/openpgp/conventional-mdc.scm: Use only two plaintexts when
iterating over all cipher algorithms.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-20 15:33:57 +02:00
Justus Winter
ab483eff9a tests: Refine exception handling.
* tests/gpgscm/init.scm (catch): Bind all arguments to '*error*' in
the error handler, update and fix comment.
(*error-hook*): Revert to original definition.
* tests/gpgscm/tests.scm (tr:do): Adapt accordingly.
* tests/openpgp/issue2419.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-19 18:49:17 +02:00
NIIBE Yutaka
7305d27f36 Fix comment and format.
* agent/protect-tool.c (main): Fix comment.
* doc/DETAILS (colon listings): Fix list.
* tests/openpgp/multisig.test: Fix comment.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2016-09-17 16:16:41 +09:00
Daniel Kahn Gillmor
0d67241e31 Fix more spelling
* NEWS, acinclude.m4, agent/command-ssh.c, agent/command.c,
  agent/gpg-agent.c, agent/keyformat.txt, agent/protect-tool.c,
  common/asshelp.c, common/b64enc.c, common/recsel.c, doc/DETAILS,
  doc/HACKING, doc/Notes, doc/TRANSLATE, doc/dirmngr.texi,
  doc/faq.org, doc/gpg-agent.texi, doc/gpg.texi, doc/gpgsm.texi,
  doc/instguide.texi, g10/armor.c, g10/gpg.c, g10/keyedit.c,
  g10/mainproc.c, g10/pkclist.c, g10/tofu.c, g13/sh-cmd.c,
  g13/sh-dmcrypt.c, kbx/keybox-init.c, m4/pkg.m4, sm/call-dirmngr.c,
  sm/gpgsm.c, tests/Makefile.am, tests/gpgscm/Manual.txt,
  tests/gpgscm/scheme.c, tests/openpgp/gpgv-forged-keyring.scm,
  tests/openpgp/multisig.test, tests/openpgp/verify.scm,
  tests/pkits/README, tools/applygnupgdefaults,
  tools/gpg-connect-agent.c, tools/mime-maker.c, tools/mime-parser.c:
  minor spelling cleanup.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-09-17 16:00:37 +09:00
Justus Winter
aa81e32df7 tests: Simplify tofu test.
* tests/openpgp/tofu.scm: Simplify now that we only have one db
format.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-12 11:07:48 +02:00
Neal H. Walfield
a937eef2d4 tests: Don't use --tofu-db-format.
* tests/openpgp/tofu.scm: Remove use of --tofu-db-format, which is
deprecated.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2016-09-07 11:02:51 +02:00
Justus Winter
213b3cf465 tests: Fix test.
* tests/openpgp/multisig.scm: Add missing parenthesis.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-06 16:46:31 +02:00
Justus Winter
46c4333c37 tests: Speed up the test suite.
* tests/openpgp/run-tests.scm (test::run-sync): Pass additional
arguments to the test.
(test::run-sync-quiet): Likewise.
(test::run-async): Likewise.
(run-tests-{parallel,sequential}-isolated): Create a tarball of the
gnupghome, then extract it for each test.
* tests/openpgp/setup.scm: Refactor into functions, add an interface
to tar-up the created environment, and untar it multiple times.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-05 17:26:50 +02:00
Justus Winter
65a7563edb tests: Update README.
* tests/openpgp/README: Update.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-05 14:05:19 +02:00
Justus Winter
059c79d8b4 tests: Pass flags to test driver.
* tests/openpgp/Makefile.am (xcheck): Pass flags to 'run-tests.scm'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-09-05 14:05:19 +02:00
Werner Koch
0a5a854510
gpg: Fix false negatives in Ed25519 signature verification.
* g10/pkglue.c (pk_verify): Fix Ed25519 signatrue values.
* tests/openpgp/verify.scm (msg_ed25519_rshort): New
(msg_ed25519_sshort): New.
("Checking that a valid Ed25519 signature is verified as such"): New.
--

About one out of 256 signature won't verify due to stripped zero
bytes.  See the source comment for details.

Reported-by: Andre Heinecke
Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-25 16:18:00 +02:00
Werner Koch
19d12be3ce
gpg: New option --with-tofu-info.
* g10/gpg.c (oWithTofuInfo): New.
(opts): Add --with-tofu-info.
(main): Set opt.with_tofu_info.
* g10/options.h (struct opt): Add field WITH_TOFU_INFO.
* g10/tofu.c (show_statistics): Add optional arg OUTFP and enter
special mode if not NULL.  Change all callers.
(tofu_write_tfs_record): New.
* g10/keylist.c (list_keyblock_colon): Do not print the tofu policy as
part of the "uid" record.  Print a new "tfs" record if the new option
is set.
* tests/openpgp/tofu.scm (getpolicy): Change from UID to TFS record.
--

A separate option is required to avoid slowing down key listings.
Foer example the current code takes for a keylisting in tofu+pgp mode
17 seconds while it takes more than 5 minutes if the option is used.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-25 09:37:56 +02:00
Justus Winter
a6acf1f6b3 tests: Fix distcheck.
* tests/openpgp/issue2417.scm: Copy configuration.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 17:57:32 +02:00
Werner Koch
5b59999ce0
gpg: Remove tofu database format "split".
* g10/options.h (struct opt): Remove field tofu_db_format.
* g10/gpg.h (server_control_s): Add fields tofu.batch_update_ref and
tofu.batch_update_started.
* g10/gpg.c (parse_tofu_db_format): Remove.
(main): Make option --tofu-db-format obsolete.
* g10/tofu.c: Major rework.  Remove the pretty complicated and slower
split format and with that all the caching.  Use the dbs struct
directly.  Move global vars for batch update into CTRL.  Change
calling conventions of some function to take CTRL or DBS pointers
instead of  the former low-level database pointer.
--

The split database format might have been nice for use with Unison but
it bypasses the concept of a relational database by doing parts of
this itself and also risking deadlocks.  Working with the Tofu
database for debugging or experiments is also not possible with parts
of the database logic implemented in gpg.

The Tofu support is quite new and we can assume that it is not in real
use now.  Thus we better remove that now so that we do not need to
maintain it for all future.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-10 16:55:04 +02:00
Justus Winter
a27410a251 g10: Fix opening of trust database.
* g10/tdbio.c (tdbio_set_dbname): This function explicitly checks for
the file size, but handled the case of a zero-sized file incorrectly
by returning success.  Fix this by initializing the database in that
case.
* tests/openpgp/Makefile.am (XTESTS): Add new test.
* tests/openpgp/issue2417.scm: New file.

GnuPG-bug-id: 2417
Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 16:50:29 +02:00
Justus Winter
194b1e979c tests: Fix distcheck.
* tests/openpgp/Makefile.am (EXTRA_DIST): Explicitly add setup and
teardown scripts now that they no longer are included in the list of
tests.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 11:59:42 +02:00
Justus Winter
d9240a3a46 tests: Improve temporary directory handling.
* tests/gpgscm/ffi.c (ffi_init): Rename 'mkdtemp'.
* tests/gpgscm/tests.scm (mkdtemp): New function that uses a sensible
location and template if no arguments are given.
(with-temporary-working-directory): Simplify accordingly.
(make-temporary-file): Likewise.
* tests/openpgp/run-tests.scm (run-tests-parallel-isolated): Likewise.
(run-tests-sequential-isolated): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 11:59:42 +02:00
Justus Winter
e13f1ea8ff tests: Run each test in a clean environment.
* tests/openpgp/Makefile.am (TESTS_ENVIRONMENT): Drop obsolete
variables, add 'srcdir', use absolute paths.
(TESTS): Rename to 'XTESTS' to avoid emitting the automake test
runner.  Drop 'setup.scm' and 'finish.scm'.
(xcheck): New target that runs 'run-tests.scm', our Scheme test suite
runner.  It will run each test in a clean environment, isolated from
the other tests.
(EXTRA_DIST): Adapt accordingly.
* tests/openpgp/README: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 09:42:00 +02:00
Justus Winter
b2b21580b6 tests: Make ssh test more robust.
* tests/openpgp/ssh.scm: Drop the 'MD5:' which was not printed by
previous ssh versions.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-10 07:58:24 +02:00
NIIBE Yutaka
7dcad0d350 tests: Add openpgp/gpgv-forged-keyring.scm.
* tests/openpgp/gpgv-forged-keyring.scm: New.
* tests/openpgp/forged-keyring.gpg: New.
* tests/openpgp/Makefile.am (TESTS): Add gpgv-forged-keyring.scm.
* tests/openpgp/defs.scm (tools): Add GPGV.
(GPGV): New.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2016-08-08 13:24:02 +09:00
Werner Koch
0c2a745a2b
tests: Use gpgconf to set the ssh socket envvar.
* tests/openpgp/ssh.scm ("SSH_AUTH_SOCK"): Use gpgconf.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-08-04 13:04:28 +02:00
Justus Winter
05cb30052c tests: Update list of tests in Scheme test runner.
* tests/openpgp/run-tests.scm: Add missing tests.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-04 12:10:47 +02:00
Justus Winter
3566544d04 tests: Fix path to fake-pinentry.
* tests/openpgp/defs.scm: Correctly compute the path to fake-pinentry.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-04 12:09:52 +02:00
Daniel Kahn Gillmor
cd45cf782b Fix spelling and grammar.
* agent/learncard.c: s/coccured/occurred/
* doc/dirmngr.texi: s/ommitted/omitted/, s/orginally/originally/,
  s/reponses/responses/i
* doc/gpg-agent.texi, doc/dirmngr.texi, doc/gpg.texi: Fix "allows
  to" to more conventional english usage.
* doc/tools.texi, g10/gpgcommpose.c, tests/openpgp/armor.scm,
  tests/openpgp/armor.test: s/occured/occurred/
* tools/gpgsplit.c: s/calcualting/calculating/
* sm/server.c: s/formated/formatted/

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-08-03 16:54:01 +02:00
Justus Winter
c971ff0823 tests: Distribute standalone test runner.
* tests/openpgp/Makefile.am (EXTRA_DIST): Add missing file
'run-tests.scm'.

GnuPG-bug-id: 2431
Signed-off-by: Justus Winter <justus@g10code.com>
2016-08-01 11:08:43 +02:00
Justus Winter
9e799b0e4f tests: Fix distcheck.
* tests/openpgp/Makefile.am (sample_msgs): New variable.
(EXTRA_DIST): Also ship the sample msgs.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-28 18:11:50 +02:00
Justus Winter
b2572b0c38 common: Fix iobuf_peek corner case.
Previously, iobuf_peek on a file smaller than 'buflen' would hang.

* common/iobuf.c (underflow): Generalize by adding a target parameter.
(iobuf_peek): Use this to prevent looping here.
* tests/openpgp/Makefile.am (TESTS): Add new test.
* tests/openpgp/setup.scm (dearmor): Move function...
* tests/openpgp/defs.scm (dearmor): ... here.
* tests/openpgp/issue2419.scm: New file.
* tests/openpgp/samplemsgs/issue2419.asc: Likewise.

GnuPG-bug-id: 2419
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-26 18:37:37 +02:00
Justus Winter
66c0dab3c7 tests: Fix distcheck.
* tests/openpgp/Makefile.am (samplekeys): Add missing key.

Fixes-commit: 4ba11251
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-26 16:03:06 +02:00
Justus Winter
f17aecbcd9 gpgscm: Make the verbose setting more useful.
* tests/gpgscm/ffi.c (do_get_verbose): New function.
(do_set_verbose): Likewise.
(ffi_init): Turn *verbose* into a function, add *set-verbose!*.
* tests/gpgscm/tests.scm (call): Adapt accordingly.
(call-with-io): Dump output if *verbose* is high.
(pipe-do): Adapt accordingly.
* tests/openpgp/defs.scm: Set verbosity according to environment.
* tests/openpgp/run-tests.scm (test): Adapt accordingly.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-26 15:53:50 +02:00
Justus Winter
4ba11251af g10: Fix key import statistics.
'transfer_secret_keys' collects statistics on a subkey-basis, while
the other code does not.  This leads to inflated numbers when
importing secret keys.  E.g. 'count' is incremented by the main
parsing loop in 'import', and again in 'transfer_secret_keys', leading
to a total of 3 if one key with two secret subkeys is imported.

* g10/import.c (import_secret_one): Adjust to the fact that
'transfer_secret_keys' collects subkey statistics.
* tests/openpgp/Makefile.am (TESTS): Add new test.
* tests/openpgp/issue2346.scm: New file.
* tests/openpgp/samplekeys/issue2346.gpg: Likewise.

GnuPG-bug-id: 2346
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-25 12:50:35 +02:00
Justus Winter
270f7f7b8b agent: Add known keys to sshcontrol.
* agent/command-ssh.c (ssh_identity_register): Add a key to sshcontrol
even if it is already in the private key store.
* tests/openpgp/ssh.scm: Test this.

GnuPG-bug-id: 2316
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-19 16:51:16 +02:00
Justus Winter
d7a405de83 tests: Add test for ssh support.
* tests/gpgscm/tests.scm (path-expand): New function.
* tests/openpgp/Makefile.am (TESTS): Add new test.
(sample_keys): Add new keys.
(CLEANFILES): Clean ssh socket and control file.
* tests/openpgp/fake-pinentry.c (main): Add a default passphrase.
* tests/openpgp/gpg-agent.conf.tmpl: Enable ssh support.
* tests/openpgp/samplekeys/ssh-dsa.key: New file.
* tests/openpgp/samplekeys/ssh-ecdsa.key: Likewise.
* tests/openpgp/samplekeys/ssh-ed25519.key: Likewise.
* tests/openpgp/samplekeys/ssh-rsa.key: Likewise.
* tests/openpgp/ssh.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-19 16:38:21 +02:00
Justus Winter
f474249366 agent: Fix passphrase cache lookups.
CACHE_MODE_ANY is supposed to match any cache mode except
CACHE_MODE_IGNORE, but the code used '==' to compare cache modes.

* agent/cache.c (cache_mode_equal): New function.
(agent_set_cache): Use the new function to compare cache modes.
(agent_get_cache): Likewise.
* tests/openpgp/Makefile.am (TESTS): Add new test.
* tests/openpgp/issue2015.scm: New file.

GnuPG-bug-id: 2015
Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-18 12:51:38 +02:00
Justus Winter
12a887050a tests: Check for gpgtar.
* tests/migrations/extended-pkf.scm: Skip test if gpgtar is not built.
* tests/migrations/from-classic.scm: Likewise.
* tests/openpgp/gpgtar.scm: Fix check for gpgtar.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-15 11:59:57 +02:00
Werner Koch
5811b5c685
tests: 3 more sample messages
--
2016-07-13 18:20:06 +02:00
Justus Winter
2f61aa0ff1 gpgscm: Capture output of spawned processes.
* tests/gpgscm/tests.scm (call-check): Capture stdout and stderr, and
return stdout if the child exited successfully, or include stderr in
the error.
* tests/openpgp/version.scm: Demonstrate this by checking the stdout.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-07 16:18:10 +02:00
Werner Koch
a479804c86
gpg: New options --recipient-file and --hidden-recipient-file.
* g10/gpg.c (oRecipientFile, oHiddenRecipientFile): New.
(opts): Add options --recipient-file and --hidden-recipient-file.
(main): Implement them.  Also remove duplicate code from similar
options.
* g10/keydb.h (PK_LIST_FROM_FILE): New.
(PK_LIST_SHIFT): Bump up.
* g10/pkclist.c (expand_group): Take care of PK_LIST_FROM_FILE.
(find_and_check_key): Add and implement arg FROM_FILE.
(build_pk_list): Pass new value for new arg.
* g10/getkey.c (get_pubkey_fromfile): New.
* g10/gpgv.c (read_key_from_file): New stub.
* g10/test-stubs.c (read_key_from_file): New stub.
* g10/server.c (cmd_recipient): Add flag --file.
* g10/import.c (read_key_from_file): New.

* tests/openpgp/defs.scm (key-file1): New.
(key-file2): New.
* tests/openpgp/setup.scm: Add their private keys and import the
key-file1.
* tests/openpgp/encrypt.scm: Add new test.

--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-07-06 15:35:19 +02:00
Justus Winter
8270580a5a tests: Honor environment variable 'TMP'.
This fixes problems with long socket names, e.g. when doing distcheck.

* tests/gpgscm/tests.scm (path-join): New function.
(with-temporary-working-directory): Honor 'TMP'.
(make-temporary-file): Likewise.
* tests/migrations/Makefile.am (TMP): Default to '/tmp'.
(TESTS_ENVIRONMENT): Set 'TMP'.
* tests/openpgp/Makefile.am (TMP): Default to '/tmp'.
(TESTS_ENVIRONMENT): Set 'TMP'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-05 16:25:21 +02:00
Justus Winter
0b8a335879 tools/gpgtar: Provide --create and --extract.
* tools/gpgtar.c (cmd_and_opt_values): New values.
(opts): New actions.
(parse_arguments): Handle new actions.
* tests/openpgp/gpgtar.scm: Test new interface.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-07-05 15:18:30 +02:00
Daniel Kahn Gillmor
55d112eeb0
g10: Implement gpg --quick-revuid
* g10/revoke.c (get_default_uid_revocation_reason): New.
* g10/keyedit.c (menu_revuid): Break out creation of uid revocation
into new function core_revuid.
* g10/keyedit.c (keyedit_quick_revuid): New. Selects key and
uid, invokes core_revuid.
* g10/gpg.c (main): Handle --quick-revuid argument.
* doc/gpg.texi: Document --quick-revuid.

--

This functionality is a counterpart to --quick-adduid, and will be
useful for projects that depend programmatically on gpg to revoke user
IDs (one such example is "monkeysphere-host revoke-servicename").

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

- Minor re-indentation work.
- Changed a "0 == memcmp" to "!memcmp"
- Removed tests/openpgp/quick-key-manipulation.test from the
  Makefile.  This test needs to be converted to gpgscm.
- Removed example from whats-new-in-2.1.txt because that is generated.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-30 11:45:13 +02:00
Werner Koch
0fc80208db
Add another collection of sample keys
--
2016-06-28 15:53:59 +02:00
Justus Winter
e584d6468a tests/openpgp: Fake the system time for the tofu test.
The keys in the tofu test are set to expire on 2016-09-17.  Fake the
system time for this test.

This commit includes changes to the old test as well, for those who
need to backport it.

* tests/openpgp/gpg-agent.conf.tmpl: Drop trailing newlines.
* tests/openpgp/tofu.scm: Fake system time.
* tests/openpgp/tofu.test: Likewise.

GnuPG-bug-id: 2393
Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-23 17:42:30 +02:00
Justus Winter
1e822654c1 tests/openpgp: Improve tests.
* tests/openpgp/multisig.scm: Simplify test.
* tests/openpgp/setup.scm (dearmor): Use pipe.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-23 17:14:07 +02:00
Werner Koch
679aadb03e
tests: Add four more sample messages for the two new keys to the repo.
--

These are uncompressed signed messages
2016-06-23 09:38:12 +02:00
Werner Koch
da63f15d98
tests: Add a set of sample messages for the two new keys to the repo.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-22 11:25:22 +02:00
Werner Koch
ea78b37f0d
tests: Add two more sample keys for OpenPGP.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-22 11:25:22 +02:00
Justus Winter
0340fcdac8 tests/openpgp: Port the remaining tests to Scheme.
* tests/openpgp/Makefile.am (TESTS): Add new tests.
* tests/openpgp/defs.scm (gpg-with-colons): New function.
(get-config): Use new function.
* tests/openpgp/export.scm: New file.
* tests/openpgp/tofu.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-21 16:22:11 +02:00
Werner Koch
ce1689ea07
tests: Make make distcheck work again.
* Makefile.am (tests): Remove test code which would led to doubling
calls to for e.g. "make distclean".
* tests/Makefile.am: Typo fixes.
* tests/gpgscm/Makefile.am (EXTRA_DIST): Fix name of License file.
Add repl.scm.
(check): Replace by check-local because check is a standard automake
target.
* tests/openpgp/Makefile.am (TESTS_ENVIRONMENT): Replace gmake0sim by
automake generated macro.
(EXTRA_DIST): Add defs.scm

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-17 21:16:37 +02:00
Justus Winter
9609cb20e4 tests/openpgp: Reimplement tests in Scheme.
* Makefile.am: Build the test infrastructure on Windows.
* tests/openpgp/Makefile.am (required_pgms): Add gpgscm.
(TESTS_ENVIRONMENT): Make sure gpgscm and the libraries are found.
(TESTS): Replace tests with the new Scheme implementations.
* tests/openpgp/4gb-packet.scm: New file.
* tests/openpgp/README: Likewise.
* tests/openpgp/armdetach.scm: Likewise.
* tests/openpgp/armdetachm.scm: Likewise.
* tests/openpgp/armencrypt.scm: Likewise.
* tests/openpgp/armencryptp.scm: Likewise.
* tests/openpgp/armor.scm: Likewise.
* tests/openpgp/armsignencrypt.scm: Likewise.
* tests/openpgp/armsigs.scm: Likewise.
* tests/openpgp/clearsig.scm: Likewise.
* tests/openpgp/conventional-mdc.scm: Likewise.
* tests/openpgp/conventional.scm: Likewise.
* tests/openpgp/decrypt-dsa.scm: Likewise.
* tests/openpgp/decrypt.scm: Likewise.
* tests/openpgp/default-key.scm: Likewise.
* tests/openpgp/defs.scm: Likewise.
* tests/openpgp/detach.scm: Likewise.
* tests/openpgp/detachm.scm: Likewise.
* tests/openpgp/ecc.scm: Likewise.
* tests/openpgp/encrypt-dsa.scm: Likewise.
* tests/openpgp/encrypt.scm: Likewise.
* tests/openpgp/encryptp.scm: Likewise.
* tests/openpgp/finish.scm: Likewise.
* tests/openpgp/genkey1024.scm: Likewise.
* tests/openpgp/gpgtar.scm: Likewise.
* tests/openpgp/import.scm: Likewise.
* tests/openpgp/mds.scm: Likewise.
* tests/openpgp/multisig.scm: Likewise.
* tests/openpgp/run-tests.scm: Likewise.
* tests/openpgp/seat.scm: Likewise.
* tests/openpgp/setup.scm: Likewise.
* tests/openpgp/signencrypt-dsa.scm: Likewise.
* tests/openpgp/signencrypt.scm: Likewise.
* tests/openpgp/sigs-dsa.scm: Likewise.
* tests/openpgp/sigs.scm: Likewise.
* tests/openpgp/use-exact-key.scm: Likewise.
* tests/openpgp/verify.scm: Likewise.
* tests/openpgp/version.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-06-17 11:57:12 +02:00
Werner Koch
4d7d292cd5
Add missing files so that make distcheck works again,
* tests/openpgp/Makefile.am (CLEANFILES): Add created file
"passphrases".
* tools/Makefile.am (EXTRA_DIST): Add no-libgcrypt.c.
--

dirmngr/Makefile uses a copy no-libgcrypt.c from tools/.  tools/ does
not anymore require no-libgcrypt.c but we keep it there in case we
eventually make use of it again.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-06-16 16:56:42 +02:00
Daniel Kahn Gillmor
c41c46fa84
g10: Export cleartext keys as cleartext
* g10/export.c (do_export_stream): If a key is stored by the agent in
cleartext, then try to export it as cleartext.
* tests/openpgp/export.test: For secret keys that are stored in
cleartext, test should try to export without pinentry interaction.
--

This restores the behavior of GnuPG 2.0 and 1.4 when exporting
passphraseless secret keys, and fixes the test suite accordingly.

GnuPG-bug-id: 2070, 2324
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2016-06-11 11:18:58 +02:00
Justus Winter
b9d1e099c3 tests: Test the pinentry interactions when exporting keys.
* tests/openpgp/export.test: Test pinentry interactions.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-05-23 16:06:53 +02:00
Justus Winter
4994153924 tests: Add support for a passphrase queue to fake pinentry.
* tests/openpgp/fake-pinentry.c (get_passphrase): New function.
(main): Add option --passphrasefile and read passphrases from it.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-05-23 16:06:53 +02:00
Justus Winter
41b10c66ec tests: Add logging to fake pinentry.
* tests/openpgp/fake-pinentry.c (log_stream): New variable.
(reply): New function.
(spacep,skip_options,option_value): Copy from common.
(main): Parse arguments, add --logfile option, write logfile.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-05-23 16:06:53 +02:00
Justus Winter
a54e89a585 tests: Add export test.
* tests/openpgp/Makefile.am (TESTS): Add new file.
* tests/openpgp/export.test: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-05-23 16:06:53 +02:00
Werner Koch
33aacc3d4b
tests: Silence output of some tests.
* common/t-exechelp.c (print_open_fds): Silence non-verbose output.
(test_close_all_fds): Ditto.
* common/t-session-env.c (show_stdnames): Indent output.
* g10/test.c (TEST): Silence non-verbose okay output.
(exit_tests): Ditto.
* tools/gpg-zip.in (tar_verbose_opt): Add option --quiet.
* tests/openpgp/gpgtar.test (GPGZIP): Pass option --quiet.
* tests/openpgp/mds.test: Indent MD5 notice.
* tests/openpgp/version.test: Indent --version output.

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-05-03 11:26:06 +02:00
Werner Koch
94504b3d5a
tests: Set fake-pinentry's stdout and stdin to _IOLBF.
* tests/openpgp/fake-pinentry.c (main): Call setvbuf.  Show passphrase
at startup.  Increase buffer.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-04-14 09:37:45 +02:00
Werner Koch
96bcd4220f
Now build "gpg" binary but install as "gpg2"
* configure.ac (USE_GPG2_HACK): New ac_define am_conditional.
* common/homedir.c (gnupg_module_name): Replace use of macro
NAME_OF_INSTALLED_GPG.
* g10/keygen.c (generate_keypair): Ditto.
* g10/Makefile.am (bin_PROGRAMS): Remove.
(noinst_PROGRAMS): Add gpg or gpg2 and gpgv or gpg2.
(gpg2_hack_list): New.
(use_gpg2_hack): New.
(gpg2_SOURCES): Rename to gpg_SOURCES.
(gpgv2_SOURCES): Rename to gpgv_SOURCES.
(gpg2_LDADD): Rename to gpg_LDADD.
(gpgv2_LDADD): Rename to gpgv_LDADD.
(gpg2_LDFLAGS): Rename to gpg_LDFLAGS.
(gpgv2_LDFLAGS): Rename to gpgv2_LDFLAGS.
(install-exec-hook): Remove WinCE specific rules and add new rules.
(uninstall-local): Uninstall gpg/gpg2 and gpgv/gpgv2.
* tests/openpgp/Makefile.am (required_pgms): s/gpg2/gpg/.
* tests/openpgp/defs.inc: Ditto.
* tests/openpgp/gpgtar.test: Ditto.
* tests/openpgp/mkdemodirs: Ditto.
* tests/openpgp/signdemokey: Ditto.

* Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Remove obsolete
--enable-mailto, add --enable-gpg2-is-gpg.
--

Although we need to duplicate some automake generated code this method
allows to easily switch the name of the installed target using the
configure option "--enable-gpg2-is-gpg".

Signed-off-by: Werner Koch <wk@gnupg.org>
2016-04-04 18:40:25 +02:00
Werner Koch
c6ed863491
tests: Add missing file.
* tests/openpgp/Makefile.am (TEST_FILES): Add plain-largeo.asc.
--

Fixes-commit: 785a7f463e
2016-04-04 18:40:25 +02:00
Justus Winter
dd5902cc45 tests: Fix default key test.
* tests/openpgp/default-key.test: Avoid using the option
'--trust-model' unconditionally.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-04-04 13:10:28 +02:00
Justus Winter
a883d4c0f8 tests/openpgp: Skip gpgtar test if it has not been built.
* tests/openpgp/gpgtar.test: Check if executable exists.

GnuPG-bug-id: 2261
Signed-off-by: Justus Winter <justus@g10code.com>
2016-03-03 12:24:24 +01:00
Uldis Anšmits
1cdb744d91 tests/openpgp: Make tests more portable.
* tests/openpgp/default-key.test: Avoid 'grep -q'.
* tests/openpgp/gpgtar.test: Avoid 'grep -qe' and 'diff -q'.
* tests/openpgp/use-exact-key.test: Avoid 'grep -q'.

GnuPG-bug-id: 2262
Signed-off-by: Justus Winter <justus@g10code.com>
2016-03-02 17:59:38 +01:00
Justus Winter
ede0061feb tests/openpgp: Qualify executables with extension.
* tests/openpgp/Makefile.am (required_pgms): Qualify executables with
'$EXEEXT'.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-02-23 11:58:52 +01:00
Justus Winter
01dcc2cf2f tests/openpgp: Reimplement 'pinentry.sh' in c.
* tests/openpgp/Makefile.am: Build new program.
* tests/openpgp/defs.inc: Use the new program.
* tests/openpgp/fake-pinentry.c: New file.
--
Building an executable that does not require an interpreter makes it
easier to use on Windows.

Signed-off-by: Justus Winter <justus@g10code.com>
2016-02-23 11:58:52 +01:00