gnupg.git
3 years agogpgconf: Enhance --list-dirs.
Werner Koch [Mon, 11 Jul 2016 11:05:37 +0000 (13:05 +0200)]
gpgconf: Enhance --list-dirs.

* tools/gpgconf.c (main) <aListDir>: Factor code out to ...
(list_dirs): new.  Rewrite to use a table.  Allow selection of a
items.  Add "agent-ssh-socket".
--

This change makes the use of gpgconf in scripts easier.  For example,
to set the envvar with the name of the socket used by ssh, it is now
possible to do this:

  SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"

which guarantees that the right name is used.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpgv: Tweak default options for extra security.
NIIBE Yutaka [Sat, 9 Jul 2016 01:20:02 +0000 (10:20 +0900)]
gpgv: Tweak default options for extra security.

* g10/gpgv.c (main): Set opt.no_sig _cache, so that it doesn't depend on
cached status.  Similarly, set opt.flags.require_cross_cert for backsig
validation for subkey signature.

--

It is common that an organization distributes binary keyrings with
signature cache (Tag 12, Trust Packet) and people use gpgv to validate
signature with such keyrings.  In such a use case, it is possible that
the key validation itself is skipped.

For the purpose of gpgv validation of signatures, we should not depend
on signature cache in keyrings (if any), but we should validate the key
by its self signature for primary key, and back signature for subkey.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
3 years agogpg: Add export options "export-pka" and "export-dane".
Werner Koch [Thu, 7 Jul 2016 15:02:58 +0000 (17:02 +0200)]
gpg: Add export options "export-pka" and "export-dane".

* g10/options.h (EXPORT_PKA_FORMAT): New.
* g10/keylist.c (list_keyblock_pka): Do not use DANE flag.
* g10/export.c: Include zb32.h.
(parse_export_options): Add options "export-pka" and "export-dane".
(do_export): Do not armor if either of these option is set.
(print_pka_or_dane_records): New.
(do_export_stream): Implement new options.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: Split a too large export function.
Werner Koch [Thu, 7 Jul 2016 12:16:21 +0000 (14:16 +0200)]
gpg: Split a too large export function.

* g10/export.c (do_export_stream): Factor some code out to ...
(do_export_one_keyblock): new.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpgscm: Capture output of spawned processes.
Justus Winter [Thu, 7 Jul 2016 14:18:10 +0000 (16:18 +0200)]
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>
3 years agodoc: Escape file names in generated macros.
Werner Koch [Wed, 6 Jul 2016 17:35:15 +0000 (19:35 +0200)]
doc: Escape file names in generated macros.

* doc/mkdefsinc.c (print_filename): New.
(main): Use it here.
--

Our Jenkins uses an @ in directory names and thus our builds break.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agowks: Let the server take the encrytion key from the file.
Werner Koch [Wed, 6 Jul 2016 13:50:57 +0000 (15:50 +0200)]
wks: Let the server take the encrytion key from the file.

* tools/gpg-wks-server.c (encrypt_stream): Change arg 'fingerprint' to
'keyfile'.
(store_key_as_pending): Add arg 'r_fname' to make of the keyfile.
(send_confirmation_request): Add arg 'keyfile'.
(process_new_key): Pass on the name of the keyfile.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: New options --recipient-file and --hidden-recipient-file.
Werner Koch [Wed, 6 Jul 2016 12:03:50 +0000 (14:03 +0200)]
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>
3 years agogpg: New option --no-keyring.
Werner Koch [Wed, 6 Jul 2016 13:33:40 +0000 (15:33 +0200)]
gpg: New option --no-keyring.

* g10/gpg.c (oNoKeyring): New.
(opts): Add "--no-keyring".
(main): Do not register any keyring if the option is used.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: Document use of node flags in import.c and remove unused args.
Werner Koch [Wed, 6 Jul 2016 08:35:36 +0000 (10:35 +0200)]
gpg: Document use of node flags in import.c and remove unused args.

* g10/import.c (NODE_GOOD_SELFSIG): New.  Use instead of 1.
(NODE_BAD_SELFSIG): New.  Use instead of 2.
(NODE_DELETION_MARK): New.  Use instead of 4.
(NODE_FLAG_A): New.  Use to mark new nodes in merge_blocks.
(chk_self_sigs): Remove unused args FNAME and PK.
(import_one): Adjust call.  Simplify error return because
chk_self_sigs does not return an error code.
(append_uid, append_key, merge_sigs, merge_keysigs): Remove unsued
args FNAME and KEYID.
(merge_blocks, import_one, import_secret_one)
(import_revoke_cert): Remove unused arg FNAME.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: Get rid of an unused arg in a function in getkey.c.
Werner Koch [Wed, 6 Jul 2016 06:46:14 +0000 (08:46 +0200)]
gpg: Get rid of an unused arg in a function in getkey.c.

* g10/getkey.c (pk_from_block): Remove unused arg CTX.  Change all
callers.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: Change calling convention for a function in getkey.c
Werner Koch [Wed, 6 Jul 2016 06:53:49 +0000 (08:53 +0200)]
gpg: Change calling convention for a function in getkey.c

* g10/getkey.c (merge_selfsigs): Remove arg CTX.  Add args REQ_USAGE
and WANT_EXACT.
(finish_lookup): Adjust caller.  Set LOOKUP_NOT_SELECTED here...
(lookup): and not here.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: Fix possible out-of-bounds read in is_armored.
Werner Koch [Tue, 5 Jul 2016 16:49:06 +0000 (18:49 +0200)]
gpg: Fix possible out-of-bounds read in is_armored.

* g10/armor.c (check_input): Call is_armored only if LEN >= 2.
(unarmor_pump): Use a 2 byte buffer for is_armored.
--

Fixes-commit: 605276ef8cd449bfd574ae6c498fa5d7d265c5c7
Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agotests: Honor environment variable 'TMP'.
Justus Winter [Tue, 5 Jul 2016 14:25:21 +0000 (16:25 +0200)]
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>
3 years agogpgscm: Improve robustness and compatibility.
Justus Winter [Tue, 5 Jul 2016 14:24:13 +0000 (16:24 +0200)]
gpgscm: Improve robustness and compatibility.

* tests/gpgscm/ffi.c (do_getenv): Avoid gccism.
(do_mkdtemp): Handle errors.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agotests/migrations: Fix distcheck.
Justus Winter [Tue, 5 Jul 2016 13:13:25 +0000 (15:13 +0200)]
tests/migrations: Fix distcheck.

* tests/migrations/Makefile.am (TESTS): Rename test.
(TEST_FILES): Update list.
(EXTRA_DIST): Add common.scm.
* tests/migrations/common.scm (GPGTAR): New variable.
(dearmor): Rename and untar archive.
* tests/migrations/extended-private-key-format.scm: Rename.
(setup): Update.
* tests/migrations/extended-pkf.tar.asc: New file.
* tests/migrations/extended-private-key-format.gpghome: Delete.
* tests/migrations/from-classic.gpghome: Likewise.
* tests/migrations/from-classic.scm (setup): Update.
* tests/migrations/from-classic.tar.asc: New file.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agotools/gpgtar: Provide --create and --extract.
Justus Winter [Tue, 5 Jul 2016 12:29:29 +0000 (14:29 +0200)]
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>
3 years agog10: Fix out-of-bounds read.
Justus Winter [Tue, 5 Jul 2016 10:38:15 +0000 (12:38 +0200)]
g10: Fix out-of-bounds read.

* g10/armor.c (use_armor_filter): We need two bytes for 'is_armored'.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agowks: Add command --read to gpg-wks-client.
Werner Koch [Mon, 4 Jul 2016 09:28:58 +0000 (11:28 +0200)]
wks: Add command --read to gpg-wks-client.

* tools/gpg-wks-client.c (aRead): New.
(opts): Add command "--read".
(main): Implement that.
--

This command allows to process alread decrypted Web Key Service
messages.  It can for example be used in /etc/mailcap

--8<---------------cut here---------------start------------->8---
application/vnd.gnupg.wks; gpg-wks-client -v --read --send;\
      needsterminal; description=Web Key Service message
--8<---------------cut here---------------end--------------->8---

to allow Mutt to process confirmation requests.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agotests: Add a gettime test for sizeof (time_t) > 4.
Werner Koch [Mon, 4 Jul 2016 08:00:34 +0000 (10:00 +0200)]
tests: Add a gettime test for sizeof (time_t) > 4.

* common/t-gettime.c (test_isotime2epoch): Add 4 more tests.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: Avoid spurious failures on keyblocks with no or only deleted nodes.
Werner Koch [Sun, 3 Jul 2016 09:55:21 +0000 (11:55 +0200)]
gpg: Avoid spurious failures on keyblocks with no or only deleted nodes.

* g10/import.c (write_keyblock_to_output): Clear ERR on success.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agowks: Let the client only export the requested UID.
Werner Koch [Sun, 3 Jul 2016 08:27:39 +0000 (10:27 +0200)]
wks: Let the client only export the requested UID.

* tools/gpg-wks-client.c (get_key): Export only the requested uid.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agotools: Call sendmail directly from the wks tools.
Werner Koch [Sat, 2 Jul 2016 22:41:30 +0000 (00:41 +0200)]
tools: Call sendmail directly from the wks tools.

* tools/send-mail.c, tools/send-mail.h: New.
* tools/wks-util.c: New.
* tools/Makefile.am (gpg_wks_server_SOURCES): Add them.
(gpg_wks_client_SOURCES): Ditto.
* tools/gpg-wks.h (opt): Add fields use_sendmail and output.
* tools/gpg-wks-client.c: Add options --send and --output.  Rename
command --send to --create.
(command_send, send_confirmation_response): Output via wks_send_mime.
* tools/gpg-wks-server.c:  Add options --send and --output.
(send_confirmation_request): Output via wks_send_mime.
(check_and_publish): Add hack for name-value bug.
--

With this code, a dedicated user on the server along with a procmail
script, it was possible to run a basic test.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agotools: Add options to gpg-wks-server.
Werner Koch [Sat, 2 Jul 2016 16:59:22 +0000 (18:59 +0200)]
tools: Add options to gpg-wks-server.

* tools/gpg-wks.h (opt): Add 'default_from' and 'extra_headers'.
* tools/gpg-wks-server.c (oFrom, oHeader): New.
(parse_arguments): Set them and check args.
(get_submission_address): New.
(send_confirmation_request): Set correct From address.  Add extra
headers.
(process_new_key): Return an error code.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agotools: Extend mime-maker.c:mime_maker_add_header.
Werner Koch [Sat, 2 Jul 2016 16:55:22 +0000 (18:55 +0200)]
tools: Extend mime-maker.c:mime_maker_add_header.

* tools/mime-maker.c (add_header): Check header name and allow
name-value syntax.
(mime_maker_add_header): Add mode for a syntax check.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agodoc: Describe filter expressions.
Werner Koch [Sat, 2 Jul 2016 14:18:50 +0000 (16:18 +0200)]
doc: Describe filter expressions.

* doc/gpg.texi: Remove some superfluous .E.
(FILTER EXPRESSIONS): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agoyat2m: Fix table formatting.
Werner Koch [Sat, 2 Jul 2016 14:17:25 +0000 (16:17 +0200)]
yat2m: Fix table formatting.

* doc/yat2m.c (proc_texi_cmd): Use .TQ for @itemx.  Print a .P at the
end of a level 0 table.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: New option --export-filter
Werner Koch [Fri, 1 Jul 2016 14:50:12 +0000 (16:50 +0200)]
gpg: New option --export-filter

* g10/gpg.c (oExportFilter): New.
(opts): Add --export-filter.
(main): Handle option.
* g10/export.c: Include recsel.h, init.h, and mbox-util.h.
(export_keep_uid): New global var.
(cleanup_export_globals): New.
(parse_and_set_export_filter): New.
(filter_getval): New.
(apply_keep_uid_filter): New.
(do_export_stream): Apply filter if set.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: New option --import-filter
Werner Koch [Fri, 1 Jul 2016 14:24:04 +0000 (16:24 +0200)]
gpg: New option --import-filter

* g10/gpg.c (oImportFilter): New.
(opts): Add --import-filter.
(main): Handle option.
* g10/import.c: Include recsel.h, init.h, and mbox-util.h.
(import_keep_uid): New global var.
(cleanup_import_globals): New.
(parse_and_set_import_filter): New.
(filter_getval): New.
(apply_keep_uid_filter): New.
(import_one): Apply filter if set.
--

Funny new option.  It can for example be used to export a key with
only one user id:

  gpg --no-options --import --import-options import-export \
      --import-filter keep-uid='mbox=wk@gnupg.org'         \
     < full-key.pub > key-with-one-uid.pub

More features will eventually be added.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: Allow to cache the mbox in a user id struct.
Werner Koch [Fri, 1 Jul 2016 13:40:56 +0000 (15:40 +0200)]
gpg: Allow to cache the mbox in a user id struct.

* g10/packet.h (PKT_user_id): Add field 'mbox'.
* g10/free-packet.c (free_user_id): Free that.
--

This will be required by the coming import filter.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: Make sure a user ID packet has always a terminating Nul in memory.
Werner Koch [Fri, 1 Jul 2016 13:18:59 +0000 (15:18 +0200)]
gpg: Make sure a user ID packet has always a terminating Nul in memory.

* g10/keygen.c (write_uid): Avoid overflow.
--

Also the actual length if the user ID is given by LEN, using NAME
diretcly is often more convenient.

3 years agocommon: Add function to select records etc.
Werner Koch [Thu, 30 Jun 2016 18:25:46 +0000 (20:25 +0200)]
common: Add function to select records etc.

* common/recsel.c, common/recsel.h: New.
* common/t-recsel.c: New.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agocommon: Smart up register_mem_cleanup_func.
Werner Koch [Fri, 1 Jul 2016 12:42:18 +0000 (14:42 +0200)]
common: Smart up register_mem_cleanup_func.

* common/init.c (register_mem_cleanup_func): Avoid double registration.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agocommon: Annotate semi-static allocation.
Justus Winter [Fri, 1 Jul 2016 12:09:58 +0000 (14:09 +0200)]
common: Annotate semi-static allocation.

* common/argparse.c (optfile_parse): Allow string arguments to leak.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix memory leak.
Justus Winter [Fri, 1 Jul 2016 12:09:01 +0000 (14:09 +0200)]
g10: Fix memory leak.

* g10/keyserver.c (parse_keyserver_uri): Free URI.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agotools/gpgtar: Annotate semi-static allocation.
Justus Winter [Fri, 1 Jul 2016 11:44:32 +0000 (13:44 +0200)]
tools/gpgtar: Annotate semi-static allocation.

* tools/gpgtar.c (shell_parse_argv): Annotate argument vector as
leaked.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix memory leak.
Justus Winter [Fri, 1 Jul 2016 11:43:01 +0000 (13:43 +0200)]
g10: Fix memory leak.

* g10/import.c (transfer_secret_keys): Release curve from the previous
iteration.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix build with disabled kbnode cache.
Justus Winter [Fri, 1 Jul 2016 10:50:29 +0000 (12:50 +0200)]
g10: Fix build with disabled kbnode cache.

* g10/kbnode.c (release_unused_nodes): Fix build with disabled kbnode
cache.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix memory leak.
Justus Winter [Fri, 1 Jul 2016 10:48:57 +0000 (12:48 +0200)]
g10: Fix memory leak.

* g10/trustdb.c (tdb_get_validity_core): Fix kbnode leak.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix memory leak.
Justus Winter [Fri, 1 Jul 2016 09:26:54 +0000 (11:26 +0200)]
g10: Fix memory leak.

* g10/keygen.c (keygen_set_std_prefs): Fix memory leak.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agoFix trivial memory leaks in tests.
Justus Winter [Fri, 1 Jul 2016 07:47:48 +0000 (09:47 +0200)]
Fix trivial memory leaks in tests.

* dirmngr/t-ldap-parse-uri.c (check_ldap_escape_filter): Free result.
* g10/t-stutter.c (main): Free file name.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agotools: Fix trivial memory leak.
Justus Winter [Thu, 30 Jun 2016 11:53:12 +0000 (13:53 +0200)]
tools: Fix trivial memory leak.

* tools/gpg-connect-agent.c (main): Fix trivial memory leak.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix memory leak.
Justus Winter [Thu, 30 Jun 2016 16:49:15 +0000 (18:49 +0200)]
g10: Fix memory leak.

* g10/export.c (do_export_stream): Free secret parameters.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix memory leak.
Justus Winter [Thu, 30 Jun 2016 16:45:02 +0000 (18:45 +0200)]
g10: Fix memory leak.

* g10/keygen.c (read_parameter_file): Free 'line'.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix memory leak.
Justus Winter [Thu, 30 Jun 2016 15:55:06 +0000 (17:55 +0200)]
g10: Fix memory leak.

* g10/sign.c (mk_notation_policy_etc): Free 'mbox'.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agocommon: Fix memory leak.
Justus Winter [Thu, 30 Jun 2016 15:38:48 +0000 (17:38 +0200)]
common: Fix memory leak.

* g10/textfilter.c (copy_clearsig_text): Free buffer.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agocommon: Fix memory leak.
Justus Winter [Thu, 30 Jun 2016 15:29:19 +0000 (17:29 +0200)]
common: Fix memory leak.

* common/iobuf.c (iobuf_set_partial_body_length_mode): Only create
context if necessary.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agocommon: Fix memory leak.
Justus Winter [Thu, 30 Jun 2016 15:23:48 +0000 (17:23 +0200)]
common: Fix memory leak.

* common/simple-pwquery.c (agent_open): Free socket path.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix keybox-related memory leaks.
Justus Winter [Thu, 30 Jun 2016 15:09:59 +0000 (17:09 +0200)]
g10: Fix keybox-related memory leaks.

* g10/keydb.c (keydb_release): Clear keyblock cache.
(keydb_get_keyblock): Revert previous change.
* kbx/keybox-blob.c (create_blob_finish): Free previous buffer, free
fixups after applying them.
(_keybox_release_blob): Free buffer.  Currently, the buffer has been
extracted before the keybox is released, but this is the right thing
to do here.

Fixes-commit: c57501cc
Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix memory leak.
Justus Winter [Thu, 30 Jun 2016 13:26:06 +0000 (15:26 +0200)]
g10: Fix memory leak.

* g10/compress.c (release_context): Free buffers.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix memory leak.
Justus Winter [Thu, 30 Jun 2016 12:00:46 +0000 (14:00 +0200)]
g10: Fix memory leak.

* g10/sign.c (write_plaintext_packet): Free packet.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix memory leak.
Justus Winter [Thu, 30 Jun 2016 11:41:10 +0000 (13:41 +0200)]
g10: Fix memory leak.

* g10/mainproc.c (release_list): Do not exit early if list is NULL,
there are other resources that must be released.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agogpgscm: Fix reallocating string ports.
Justus Winter [Thu, 30 Jun 2016 10:45:15 +0000 (12:45 +0200)]
gpgscm: Fix reallocating string ports.

* tests/gpgscm/scheme.c (realloc_port_string): Use memcpy because
Scheme strings may contain 0s.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agogpgscm: Free memory backing string ports.
Justus Winter [Thu, 30 Jun 2016 10:35:27 +0000 (12:35 +0200)]
gpgscm: Free memory backing string ports.

* tests/gpgscm/scheme.c (finalize_cell): Free memory backing string
ports.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agogpgscm: Use the allocator from libgcrypt.
Justus Winter [Thu, 30 Jun 2016 09:46:38 +0000 (11:46 +0200)]
gpgscm: Use the allocator from libgcrypt.

* tests/gpgscm/main.c (main): Use the allocator from libgcrypt.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agow32: Fix build.
Justus Winter [Thu, 30 Jun 2016 13:28:42 +0000 (15:28 +0200)]
w32: Fix build.

* g10/keyedit.c (keyedit_quick_revuid): Fix call to
'check_trustdb_stale'.

Fixes-commit: 55d112ee
Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Implement gpg --quick-revuid
Daniel Kahn Gillmor [Thu, 16 Jun 2016 22:05:57 +0000 (18:05 -0400)]
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>
3 years agotools: Add gpg-wks-client and gpg-wks-server.
Werner Koch [Wed, 29 Jun 2016 10:00:22 +0000 (12:00 +0200)]
tools: Add gpg-wks-client and gpg-wks-server.

* configure.ac: Add option --enable-wks-tools
* tools/gpg-wks-client.c: New.
* tools/gpg-wks-server.c: New.
* tools/gpg-wks.h: new.
* tools/wks-receive.c: New.
* tools/call-dirmngr.c, tools/call-dirmngr.h: New.
--

Note that this is just a starting point and not a finished
implementation.  Here is how to test the system using
foo@test.gnupg.org as example.

Prepare:

  mkdir /var/lib/gnupg/wks
  chmod o-rwx /var/lib/gnupg/wks
  mkdir /var/lib/gnupg/wks/test.gnupg.org

Run the protocol:

  ./gpg-wks-client -v  --send FPR USERID >x
  ./gpg-wks-server -v --receive  <x >y
  ./gpg-wks-client --receive <y >z
  ./gpg-wks-server -v --receive  <z

You should also setup a cron job to rsync
/var/lib/gnupg/wks/test.gnupg.org/hu/* to the webserver.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agobuild: Improve GNUPG_BUILD_PROGRAM macro.
Werner Koch [Wed, 29 Jun 2016 09:39:49 +0000 (11:39 +0200)]
build: Improve GNUPG_BUILD_PROGRAM macro.

* acinclude.m4 (GNUPG_BUILD_PROGRAM): Allow for dash in options.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agotools: Add modules for MIME parsing and creating.
Werner Koch [Wed, 29 Jun 2016 09:02:36 +0000 (11:02 +0200)]
tools: Add modules for MIME parsing and creating.

* tools/mime-maker.c: New.
* tools/mime-maker.h: New.
* tools/mime-parser.c: New.
* tools/mime-parser.h: New.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpgscm: Fix memory leaks.
Justus Winter [Tue, 28 Jun 2016 16:13:40 +0000 (18:13 +0200)]
gpgscm: Fix memory leaks.

* tests/gpgscm/ffi-private.h (ffi_schemify_name): Fix prototype.
(ffi_define_function_name): Free schemified name.
(ffi_define_function): Likewise.
(ffi_define_constant): Likewise.
(ffi_define_variable_pointer): Likewise.
* tests/gpgscm/ffi.c (do_wait_processes): Free arrays.
(ffi_schemify_name): Fix type.
* tests/gpgscm/main.c (main): Free 'sc'.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agogpgscm: Free file names.
Justus Winter [Tue, 28 Jun 2016 16:10:01 +0000 (18:10 +0200)]
gpgscm: Free file names.

* tests/gpgscm/scheme.c (scheme_load_named_file): Free file name.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agogpgscm: Fix buffer overflow.
Justus Winter [Tue, 28 Jun 2016 16:08:01 +0000 (18:08 +0200)]
gpgscm: Fix buffer overflow.

* tests/gpgscm/scheme.c (store_string): Avoid writing past allocated
buffer.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix memory leaks.
Justus Winter [Tue, 28 Jun 2016 16:02:10 +0000 (18:02 +0200)]
g10: Fix memory leaks.

* g10/keydb.c (keydb_get_keyblock): Free 'sigstatus' and 'iobuf'.
* g10/t-keydb-get-keyblock.c: Fix trivial memory leaks.
* g10/t-keydb.c: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agocommon: Fix memory leaks.
Justus Winter [Tue, 28 Jun 2016 15:59:17 +0000 (17:59 +0200)]
common: Fix memory leaks.

* common/ccparray.c (ccparray_put): Free old array.
* common/stringhelp.c (do_make_filename): Free 'home'.
* common/t-convert.c: Fix trivial memory leaks.
* common/t-iobuf.c: Likewise.
* common/t-mbox-util.c: Likewise.
* common/t-name-value.c: Likewise.
* common/t-stringhelp.c: Likewise.
* common/t-strlist.c: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agodirmngr: add option to retrieve extra WKS info.
Werner Koch [Tue, 28 Jun 2016 13:50:38 +0000 (15:50 +0200)]
dirmngr: add option to retrieve extra WKS info.

* dirmngr/server.c (cmd_wkd_get): Add option --submission-address.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: Add hack to --quick-gen-key to create Curve25519 keys.
Werner Koch [Tue, 28 Jun 2016 13:49:11 +0000 (15:49 +0200)]
gpg: Add hack to --quick-gen-key to create Curve25519 keys.

* g10/keygen.c (quick_generate_keypair): Add special algo string
"test-default".
--

Well, this is a hack to quickly create keys with the algorithms we
will eventually use as defaults.  Usage:

  gpg -v --quick-gen-key --passphrase '' --batch USERID test-default

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agocommon: New function rfctimestamp.
Werner Koch [Tue, 28 Jun 2016 13:45:53 +0000 (15:45 +0200)]
common: New function rfctimestamp.

* common/gettime.c (rfctimestamp): New.
--

It is surprisingly hard to create an RFC-2822 compliant Date value.
The problem is that strftime uses the current locale but the RFC
requires that the English names are used.  This code is pretty simply
and avoid the extra problem of figuring out the correct timezone;
instead UTC is used.  For the planned use case this is anyway better.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agocommon: Add missing header file for clarity.
Werner Koch [Tue, 28 Jun 2016 13:42:58 +0000 (15:42 +0200)]
common: Add missing header file for clarity.

* common/zb32.c: Include zb32.h.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agoAdd another collection of sample keys
Werner Koch [Tue, 28 Jun 2016 07:40:35 +0000 (09:40 +0200)]
Add another collection of sample keys

--

3 years agotools/gpgtar: Fix handling of '-'.
Justus Winter [Tue, 28 Jun 2016 13:03:07 +0000 (15:03 +0200)]
tools/gpgtar: Fix handling of '-'.

* tools/gpgtar-extract.c (gpgtar_extract): Use stdin if file is '-'.
* tools/gpgtar-list.c (gpgtar_list): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agocommon: Close input stream.
Justus Winter [Tue, 28 Jun 2016 13:01:57 +0000 (15:01 +0200)]
common: Close input stream.

* common/exechelp-posix.c (gnupg_spawn_process): Also close the input
stream in the child.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agocommon: Fix copying data from the spawned child.
Justus Winter [Tue, 28 Jun 2016 12:38:35 +0000 (14:38 +0200)]
common: Fix copying data from the spawned child.

Fixes intermittent gpgtar failures.

* common/exectool.c (copy_buffer_do_copy): Initialize 'nwritten'.
(gnupg_exec_tool_stream): Loop until all data is copied.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agog10: Fix --list-packets.
NIIBE Yutaka [Tue, 28 Jun 2016 06:56:48 +0000 (15:56 +0900)]
g10: Fix --list-packets.

* g10/gpg.c (main): Call set_packet_list_mode after assignment of
opt.list_packets.
* g10/mainproc.c (do_proc_packets): Don't stop processing with
--list-packets as the comment says.
* g10/options.h (list_packets): Fix the comment.
* g10/parse-packet.c: Fix the condition for opt.list_packets.

--

Debian-bug-id: 828109
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
3 years agobuild: Add aclocal macro from pkg-config.
Werner Koch [Sat, 25 Jun 2016 15:39:38 +0000 (17:39 +0200)]
build: Add aclocal macro from pkg-config.

* m4/pkg.m4: New.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agoyat2m: Silence lint warnings and fix a printf format bug.
Werner Koch [Sat, 25 Jun 2016 08:41:21 +0000 (10:41 +0200)]
yat2m: Silence lint warnings and fix a printf format bug.

* doc/yat2m.c (ATTR_PRINTF, ATTR_NR_PRINTF, ATTR_MALLOC): New.
(die, err, inf, xmalloc, xcalloc): New prototypes with attributes.
(get_section_buffer): Take care of !N_SECTIONS.
(proc_texi_cmd): Cast precision format arg.
(proc_texi_buffer): Do not set IN_CMD when not used afterwards.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: New import option "import-export".
Werner Koch [Fri, 24 Jun 2016 11:11:37 +0000 (13:11 +0200)]
gpg: New import option "import-export".

* g10/import.c (parse_import_options): Add option "import-export".
(write_keyblock_to_output): New.
(import_one): Implement option.
--

We are now in the import export business.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: New import option "import-show".
Werner Koch [Thu, 23 Jun 2016 17:25:53 +0000 (19:25 +0200)]
gpg: New import option "import-show".

* g10/options.h (IMPORT_SHOW): New.
* g10/import.c (parse_import_options): Add "import-show".
(import_one): Implement that.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agogpg: Do not print the validity after key generation.
Werner Koch [Thu, 23 Jun 2016 17:22:13 +0000 (19:22 +0200)]
gpg: Do not print the validity after key generation.

* g10/keylist.c (struct keylist_context): Add field NO_VALIDITY.
(list_keyblock_print): Take care of it.
(list_keyblock_direct): Add arg NO_VALIDITY.
* g10/keygen.c (do_generate_keypair): Merge keyblock and print w/o
validity.
--

It will always be ultimate and by not printing it we avoid a lot of
garbage output due to the trustdb re-calculation.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agocommon: Fix possible small memory leak in b64dec.c.
Werner Koch [Thu, 23 Jun 2016 15:44:55 +0000 (17:44 +0200)]
common: Fix possible small memory leak in b64dec.c.

* common/b64dec.c (b64dec_finish): Always release TITLE.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agotests/openpgp: Fake the system time for the tofu test.
Justus Winter [Thu, 23 Jun 2016 15:24:23 +0000 (17:24 +0200)]
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>
3 years agogpgscm: Handle exceptions in the transformation monad.
Justus Winter [Thu, 23 Jun 2016 15:18:13 +0000 (17:18 +0200)]
gpgscm: Handle exceptions in the transformation monad.

* tests/gpgscm/tests.scm (pipe:do): Raise errors.
(tr:spawn): Catch and return errors.
(tr:call-with-content): Likewise.
(tr:{open,write-to,pipe-do,assert-identity,assert-weak-identity}):
Adapt.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agotests/openpgp: Improve tests.
Justus Winter [Thu, 23 Jun 2016 15:14:07 +0000 (17:14 +0200)]
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>
3 years agogpgscm: Add types for special objects.
Justus Winter [Thu, 23 Jun 2016 14:14:10 +0000 (16:14 +0200)]
gpgscm: Add types for special objects.

* tests/gpgscm/scheme.c (enum scheme_types): Add types for boolean,
nil, eof, and the sink object.
(type_to_string): Handle new types.
(scheme_init_custom_alloc): Give special objects a type.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agogpgscm: Fix Scheme initialization.
Justus Winter [Thu, 23 Jun 2016 12:10:00 +0000 (14:10 +0200)]
gpgscm: Fix Scheme initialization.

This potentially causes a crash if the garbage collector marks an eof
object.

* tests/gpgscm/scheme.c (scheme_init_custom_alloc): Initialize
'EOF_OBJ'.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agogpgscm: Fix manual.
Justus Winter [Thu, 23 Jun 2016 11:18:25 +0000 (13:18 +0200)]
gpgscm: Fix manual.

--
Signed-off-by: Justus Winter <justus@g10code.com>
3 years agocommon: Add dedicated private key functions to name-value.c.
Werner Koch [Thu, 23 Jun 2016 11:17:25 +0000 (13:17 +0200)]
common: Add dedicated private key functions to name-value.c.

* common/name-value.c (struct name_value_container): Add field
'private_key_mode'.
(my_error): New.  Use instead of gpg_error.
(nvc_new_private_key): New.
(nve_release): Add arg 'private_key_mode'.
(nvc_release): Call nve_release with private_key_mode flag.
(nvc_delete): Ditto.
(_nvc_add): Do no special case "Key:" in non-private_key_mode.
(nvc_get_private_key): Return error in non-private_key_mode.
(nvc_set_private_key): Ditto.
(nvc_parse):  Factor all code out to ...
(do_nvc_parse): new.  Add arg 'for_private_key'.
(nvc_parse_private_key): New.
* agent/findkey.c (write_extended_private_key): Replace nvc_parse by
nvc_parse_private_key.
(read_key_file): Ditto.

* common/t-name-value.c (private_key_mode): New variable.
(my_nvc_new): New.  Replace all callers.
(test_key_extraction): Take mode in account.
(run_tests): Ditto.
(run_modification_tests): Ditto.
(parse): Ditto.
(main): Add option --parse and rename --parse to --parse-key.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agocommon: Rename external symbols in name-value.c.
Werner Koch [Thu, 23 Jun 2016 10:12:50 +0000 (12:12 +0200)]
common: Rename external symbols in name-value.c.

* common/name-value.c, common/name-value.h: Rename symbol prefixes
from "pkc_" to "nvc_" and from "pke_" to "nve_".  Change all callers.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agocommon: Rename private-keys.c to name-value.c
Werner Koch [Thu, 23 Jun 2016 09:55:46 +0000 (11:55 +0200)]
common: Rename private-keys.c to name-value.c

* common/private-keys.c: Rename to name-value.c.
* common/private-keys.h: Rename to name-value.h.  Chage all users.
* common/t-private-keys.c: Rename to t-name-value.c.
* common/Makefile.am: Adjust accordingly.
--

The module is cool enough to be used for other purposes as well.  Thus
we better change the name.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agocommon: Change license of b64dec.c and b64enc.c to LGPLv2.1+
Werner Koch [Thu, 23 Jun 2016 07:21:45 +0000 (09:21 +0200)]
common: Change license of b64dec.c and b64enc.c to LGPLv2.1+

--

The code as solely been written by employees of g10 Code.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agocommon: Add PGP armor decoding to b64dec.
Werner Koch [Thu, 23 Jun 2016 07:20:24 +0000 (09:20 +0200)]
common: Add PGP armor decoding to b64dec.

* common/b64dec.c (decoder_states): Add new states.
(b64dec_proc): Handle PGP armored format.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agotests: Add four more sample messages for the two new keys to the repo.
Werner Koch [Wed, 22 Jun 2016 16:40:35 +0000 (18:40 +0200)]
tests: Add four more sample messages for the two new keys to the repo.

--

These are uncompressed signed messages

3 years agog10: Fix regression of card-edit/fetch.
NIIBE Yutaka [Thu, 23 Jun 2016 03:12:43 +0000 (12:12 +0900)]
g10: Fix regression of card-edit/fetch.

* g10/card-util.c (fetch_url): Call keyserver_fetch instead of
keyserver_import_fprint.

--
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
3 years agotests: Add a set of sample messages for the two new keys to the repo.
Werner Koch [Wed, 22 Jun 2016 09:21:50 +0000 (11:21 +0200)]
tests: Add a set of sample messages for the two new keys to the repo.

--

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agotests: Add two more sample keys for OpenPGP.
Werner Koch [Wed, 22 Jun 2016 09:20:35 +0000 (11:20 +0200)]
tests: Add two more sample keys for OpenPGP.

--

Signed-off-by: Werner Koch <wk@gnupg.org>
3 years agotests/migrations: Convert to Scheme and re-enable.
Justus Winter [Tue, 21 Jun 2016 16:10:18 +0000 (18:10 +0200)]
tests/migrations: Convert to Scheme and re-enable.

* configure.ac: Re-enable.
* tests/Makefile.am: Likewise.
* tests/migrations/Makefile.am (TESTS): Use Scheme tests.
* tests/migrations/common.scm: New file.
* tests/migrations/extended-private-key-format.scm: Likewise.
* tests/migrations/from-classic.scm: Likewise.
* tests/migrations/extended-private-key-format.test: Drop file.
* tests/migrations/from-classic.test: Drop file.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agogpgscm: Add more file handling functions.
Justus Winter [Tue, 21 Jun 2016 16:12:03 +0000 (18:12 +0200)]
gpgscm: Add more file handling functions.

* tests/gpgscm/ffi.c (do_glob): New function.
(ffi_init): Define new function.
* tests/gpgscm/tests.scm (basename-suffix): New function.x

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agotests/openpgp: Port the remaining tests to Scheme.
Justus Winter [Tue, 21 Jun 2016 11:20:29 +0000 (13:20 +0200)]
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>
3 years agogpgscm: Improve test framework.
Justus Winter [Tue, 21 Jun 2016 10:21:10 +0000 (12:21 +0200)]
gpgscm: Improve test framework.

* tests/gpgscm/lib.scm (echo): Move...
* tests/gpgscm/tests.scm (echo): ... here.
(info, error, skip): And use echo here.
(file-exists?): New function.
(tr:spawn): Check that source exists and if the sink has been created.
(tr:call-with-content): Hand in optional arguments.

Signed-off-by: Justus Winter <justus@g10code.com>
3 years agogpgscm: Use native string searching functions.
Justus Winter [Tue, 21 Jun 2016 10:12:56 +0000 (12:12 +0200)]
gpgscm: Use native string searching functions.

* tests/gpgscm/ffi-private.h: Handle character arguments.
* tests/gpgscm/ffi.c (do_string_index): New function.
(do_string_rindex): Likewise.
(do_string_contains): Likewise.
(ffi_init): Define new functions.
* tests/gpgscm/ffi.scm (ffi-define): New macro.
* tests/gpgscm/lib.scm (string-index): Use native function,
demonstrate behavior.
(string-rindex): Likewise.
(string-contains?): Likewise.
Demonstrate behavior of various other functions.
(read-all): Rework so that it can handle large files.

Signed-off-by: Justus Winter <justus@g10code.com>