gnupg.git
19 months agog10: remove skeleton options files dkg/no-skel-files
Daniel Kahn Gillmor [Mon, 17 Apr 2017 14:51:55 +0000 (10:51 -0400)]
g10: remove skeleton options files

* build-aux/speed/w32/inst.nsi: stop installing skeleton files.
* doc/gpg.texi: stop documenting skeleton files.
* g10/Makefile.am: stop installing skeleton files.
* g10/openfile.c (copy_options_file): Remove.
(try_make_homedir): do not call copy_options_file()

The defaults for gpg and dirmngr are good.  Both programs should work
fine for the simple case without any config file.  The skeleton config
files were being copied at first use (when the defaults are fine).
But when the user needs to fiddle with them (after they've become
sophisticated users), they're likely out of date because gpg has been
upgraded since then.  So they're used for documentation, but they're
stale documentation, which is probably worse than a clean empty file.

--

GnuPG-bug-id: 3086
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
19 months agoagent: More minor change.
NIIBE Yutaka [Mon, 17 Apr 2017 11:03:36 +0000 (20:03 +0900)]
agent: More minor change.

* agent/command.c (cmd_pksign): Remove redundant assignment.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
19 months agoagent: Minor cleanup.
NIIBE Yutaka [Mon, 17 Apr 2017 07:43:36 +0000 (16:43 +0900)]
agent: Minor cleanup.

* agent/command-ssh.c (ssh_key_to_protected_buffer): Not touch ERR.
* agent/command.c (cmd_genkey, cmd_import_key): Clean up.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
19 months agotests: Minor memory fix.
NIIBE Yutaka [Mon, 17 Apr 2017 00:44:37 +0000 (09:44 +0900)]
tests: Minor memory fix.

* tests/openpgp/fake-pinentry.c (get_passphrase): Free the memory.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
19 months agog10: Fix parse_ring_trust.
NIIBE Yutaka [Mon, 17 Apr 2017 00:33:19 +0000 (09:33 +0900)]
g10: Fix parse_ring_trust.

* g10/parse-packet.c (parse_ring_trust): Fix condition.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
19 months agog10: Minor fixes.
NIIBE Yutaka [Mon, 17 Apr 2017 00:15:13 +0000 (09:15 +0900)]
g10: Minor fixes.

* g10/export.c (cleartext_secret_key_to_openpgp): No initialization.
(do_export_one_keyblock): Initialize with GPG_ERR_NOT_FOUND.
* g10/getkey.c (get_best_pubkey_byname): Add non-null check.
* g10/tofu.c (tofu_set_policy): ERR initialize to 0.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
19 months agog10: Fix import/export filter property match.
NIIBE Yutaka [Mon, 17 Apr 2017 00:08:31 +0000 (09:08 +0900)]
g10: Fix import/export filter property match.

* g10/import.c (impex_filter_getval): Fix to "else if".

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agoagent: Clean up error initialize/return.
NIIBE Yutaka [Fri, 14 Apr 2017 03:54:06 +0000 (12:54 +0900)]
agent: Clean up error initialize/return.

* agent/call-pinentry.c (start_pinentry): Return RC.
* agent/command-ssh.c (ssh_handler_request_identities): Don't set ERR.
* agent/findkey.c (try_unprotect_cb): Return ERR.
(unprotect): Don't set RC.
* agent/gpg-agent.c (handle_connections): Don't set fd.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agodirmngr: More fix for test program.
NIIBE Yutaka [Fri, 14 Apr 2017 00:18:41 +0000 (09:18 +0900)]
dirmngr: More fix for test program.

* dirmngr/t-http.c (main): Care about no TLS.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agodirmngr: More fix for Windows.
NIIBE Yutaka [Thu, 13 Apr 2017 23:32:49 +0000 (08:32 +0900)]
dirmngr: More fix for Windows.

* dirmngr/http.c (simple_cookie_read, simple_cookie_write): Only
valid with HTTP_USE_NTBTLS.
(_my_socket_new): Simply cast to int since it's for debug.
(_my_socket_ref, _my_socket_unref): Likewise.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agodirmngr: Fix http.c for sockaddr_storage.
NIIBE Yutaka [Thu, 13 Apr 2017 05:46:57 +0000 (14:46 +0900)]
dirmngr: Fix http.c for sockaddr_storage.

dirmngr/http.c (use_socks): Use sockaddr_storage.
(my_sock_new_for_addr, connect_server): Likewise.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agodirmngr: Fix alignment of ADDR.
NIIBE Yutaka [Thu, 13 Apr 2017 05:33:33 +0000 (14:33 +0900)]
dirmngr: Fix alignment of ADDR.

* dirmngr/dns-stuff.h (dns_addrinfo_s): Use struct sockaddr_storage
for size and alignment.
* dirmngr/dns-stuff.c (resolve_name_libdns): Follow the change.
(resolve_dns_name): Use struct sockaddr_storage.
(resolve_addr_standard, resolve_dns_addr): Likewise.
(resolve_dns_addr): Likewise.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agodirmngr: Fix thread key type.
NIIBE Yutaka [Thu, 13 Apr 2017 04:06:38 +0000 (13:06 +0900)]
dirmngr: Fix thread key type.

* dirmngr/dirmngr.c (my_tlskey_current_fd): Use npth_key_t.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agocommon, g10: Fix enumeration types.
NIIBE Yutaka [Thu, 13 Apr 2017 03:54:52 +0000 (12:54 +0900)]
common, g10: Fix enumeration types.

* common/openpgpdefs.h (CIPHER_ALGO_PRIVATE10, PUBKEY_ALGO_PRIVATE10)
(DIGEST_ALGO_PRIVATE10, COMPRESS_ALGO_PRIVATE10): New.
* g10/misc.c (map_pk_gcry_to_openpgp): Add type conversion.
(map_cipher_openpgp_to_gcry, openpgp_cipher_algo_name)
(openpgp_pk_test_algo2, map_md_openpgp_to_gcry)
(pubkey_get_npkey): Add default handling.

--

Compilers may emit code assuming the maximum value of enum type.
According to OpenPGP specification, there are cases for private uses.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agodirmngr: More fix for Windows.
NIIBE Yutaka [Thu, 13 Apr 2017 00:52:19 +0000 (09:52 +0900)]
dirmngr: More fix for Windows.

* dirmngr/dns.c (socket_fd_t, STDCALL): New.
(dns_te_initname): Use.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agodirmngr: Fix type of sock.
NIIBE Yutaka [Wed, 12 Apr 2017 11:50:50 +0000 (20:50 +0900)]
dirmngr: Fix type of sock.

* dirmngr/http.c (send_request): Use assuan_fd_t for SOCK.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agotools: Fix condition for gpg-connect-agent.
NIIBE Yutaka [Wed, 12 Apr 2017 07:01:16 +0000 (16:01 +0900)]
tools: Fix condition for gpg-connect-agent.

* tools/gpg-connect-agent.c (start_agent): Add paren.

--

The intention is comparing the error code depending opt.use_dirmngr.
Considering C Operator Precedence, we should have paren here.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agodirmngr: Fix possible null reference.
NIIBE Yutaka [Wed, 12 Apr 2017 06:58:11 +0000 (15:58 +0900)]
dirmngr: Fix possible null reference.

* dirmngr/dns.c (dns_error_t dns_trace_fput): Check NULL.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agocommon: Simplify format_text.
NIIBE Yutaka [Wed, 12 Apr 2017 05:47:30 +0000 (14:47 +0900)]
common: Simplify format_text.

* common/stringhelp.c (format_text): Don't allow IN_PLACE formatting.
* common/stringhelp.h: Change the API with no IN_PLACE.
* common/t-stringhelp.c (test_format_text): Follow the change.
* g10/gpgcompose.c (show_help): Likewise.
* g10/tofu.c (format_conflict_msg_part1, ask_about_binding)
(show_statistics, show_warning): Likewise.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agogpgscm: Fix test program.
NIIBE Yutaka [Wed, 12 Apr 2017 03:05:53 +0000 (12:05 +0900)]
gpgscm: Fix test program.

* tests/gpgscm/t-child.c (main): Fix for setmode.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agodirmngr: Fix plus1_ns.
NIIBE Yutaka [Wed, 12 Apr 2017 02:44:10 +0000 (11:44 +0900)]
dirmngr: Fix plus1_ns.

* dirmngr/dns.c (plus1_ns): Fix the initial implementation.

--

Fixes-commit: 64904ce627b6b0661acf15b5b70103c4842bb0f3
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agoscd: Handle unexpected suspend/resume by CCID driver.
NIIBE Yutaka [Wed, 12 Apr 2017 02:21:08 +0000 (11:21 +0900)]
scd: Handle unexpected suspend/resume by CCID driver.

* scd/ccid-driver.c (bulk_in): Handle unexpected failure.

--

GnuPG-bug-id: 3083
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agodirmngr: Fix dns-stuff.c in another way.
NIIBE Yutaka [Wed, 12 Apr 2017 01:19:27 +0000 (10:19 +0900)]
dirmngr: Fix dns-stuff.c in another way.

* dirmngr/dns-stuff.c (T_CERT): Define our own.

--

T_CERT may be defined by another enum type even if the value is same.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agoRevert "dirmngr: Fix dns-stuff.c."
NIIBE Yutaka [Wed, 12 Apr 2017 01:00:37 +0000 (10:00 +0900)]
Revert "dirmngr: Fix dns-stuff.c."

This reverts commit 1538523156be568046f632d1775eae30ea8bd556.

20 months agodirmngr: Fix dns-stuff.c.
NIIBE Yutaka [Wed, 12 Apr 2017 00:48:27 +0000 (09:48 +0900)]
dirmngr: Fix dns-stuff.c.

* dirmngr/dns-stuff.c: Don't include arpa/nameser.h.

--

It is not needed at all.  T_CERT may be defined by different type of
ns_type.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agoagent: Simplify stream_read_cstring.
NIIBE Yutaka [Wed, 12 Apr 2017 00:24:48 +0000 (09:24 +0900)]
agent: Simplify stream_read_cstring.

* agent/command-ssh.c (stream_read_cstring): Just call
stream_read_string.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agodirmngr: Use a function to increment network short.
NIIBE Yutaka [Wed, 12 Apr 2017 00:11:20 +0000 (09:11 +0900)]
dirmngr: Use a function to increment network short.

* dirmngr/dns.c (plus1_ns): New.
(dns_p_push): Use it.

--

On OpenBSD, htons and ntohs are expanded to GCC's statement
expressions where local variable is allowed.  Consecutive use
of htons and ntohs causes problem of variable name.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agog10: Minor clean up for export.c.
NIIBE Yutaka [Tue, 11 Apr 2017 23:47:23 +0000 (08:47 +0900)]
g10: Minor clean up for export.c.

* g10/export.c (export_ssh_key): Check IDENTIFIER for error.
Release base64 thing on error of get_membuf.

--

Compiler (older) may misunderstand the variable IDENTIFIER is not
initialized, while good one can do better analysys on the value for
ERR (and thus, IDENTIFIER).

On the error of get_membuf, still, b64enc_finish should be called,
even if it lost the ERR value.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agog13: Include sys/sysmacros.h if available.
NIIBE Yutaka [Tue, 11 Apr 2017 10:59:07 +0000 (19:59 +0900)]
g13: Include sys/sysmacros.h if available.

* configure.ac: Add test for sys/sysmacros.h.
* g13/sh-dmcrypt.c: Include sys/sysmacros.h.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agotests: Fix distcheck.
Justus Winter [Tue, 11 Apr 2017 09:50:54 +0000 (11:50 +0200)]
tests: Fix distcheck.

* tests/gpgscm/Makefile.am (EXTRA_DIST): Add 'gnupg.scm'.

Fixes-commit: ccd2187212c12b84c86a10fd4417a16536243179
Signed-off-by: Justus Winter <justus@g10code.com>
20 months agotests: Avoid relying on implicit gpg commands.
Justus Winter [Tue, 11 Apr 2017 09:37:37 +0000 (11:37 +0200)]
tests: Avoid relying on implicit gpg commands.

* tests/openpgp/armdetach.scm: Always use an explicit command instead
of relying on gpg to guess what we want.
* 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/compression.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/detach.scm: Likewise.
* tests/openpgp/detachm.scm: Likewise.
* tests/openpgp/ecc.scm: Likewise.
* tests/openpgp/encrypt-dsa.scm: Likewise.
* tests/openpgp/encrypt-multifile.scm: Likewise.
* tests/openpgp/encrypt.scm: Likewise.
* tests/openpgp/encryptp.scm: Likewise.
* tests/openpgp/seat.scm: Likewise.
* tests/openpgp/signencrypt-dsa.scm: Likewise.
* tests/openpgp/signencrypt.scm: Likewise.
* tests/openpgp/sigs-dsa.scm: Likewise.
* tests/openpgp/sigs.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agotests: Make tests more robust.
Justus Winter [Tue, 11 Apr 2017 08:46:09 +0000 (10:46 +0200)]
tests: Make tests more robust.

* tests/openpgp/defs.scm (have-opt-always-trust): Execute in empty
ephemeral home directory.  This prevents gpg from picking up the
configuration from the current gnupghome (if any).
* tests/migrations/common.scm (untar-armored): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agotests: Move common functionality.
Justus Winter [Tue, 11 Apr 2017 08:43:52 +0000 (10:43 +0200)]
tests: Move common functionality.

* tests/openpgp/defs.scm (with-home-directory,
with-ephemeral-home-directory): Move...
* tests/gpgscm/gnupg.scm: ... to this new file.
* tests/gpgscm/main.c (main): Load the new file.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agodirmngr: Fix build for Windows.
NIIBE Yutaka [Tue, 11 Apr 2017 07:12:34 +0000 (16:12 +0900)]
dirmngr: Fix build for Windows.

* dirmngr/ldap-wrapper-ce.c (outstream_cookie_writer): Use
gpgrt_ssize_t.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agog10,tools: Fix bzlib.h include order.
NIIBE Yutaka [Tue, 11 Apr 2017 04:52:19 +0000 (13:52 +0900)]
g10,tools: Fix bzlib.h include order.

* g10/compress-bz2.c: Include bzlib.h after gcrypt.h.
* tools/gpgsplit.c: Likewise.

--

bzlib.h may include windows.h on Windows.  It is better
after gcrypt.h which may include winsock2.h.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agog10: Minor clean up for TOFU.
NIIBE Yutaka [Tue, 11 Apr 2017 03:51:47 +0000 (12:51 +0900)]
g10: Minor clean up for TOFU.

* g10/tofu.c (ask_about_binding): Fix for qualifier.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agocommon: Portability fix for logging.c.
NIIBE Yutaka [Tue, 11 Apr 2017 02:53:52 +0000 (11:53 +0900)]
common: Portability fix for logging.c.

* common/logging.c (S_IRGRP, S_IWGRP, S_IROTH, S_IWOTH): Avoid
duplicated definition.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agotools: Portability fix for gpgparsemail.
NIIBE Yutaka [Tue, 11 Apr 2017 02:23:05 +0000 (11:23 +0900)]
tools: Portability fix for gpgparsemail.

* tools/rfc822parse.c (my_stpcpy): Rename from stpcpy.

--

When HAVE_STPCPY is not defined (no definition in libc), still,
compiler may have definition as a built-in function (for some specific
case like second argument is constant).  In that case, having stpcpy
implementation with the same name but different signature ("static"
qualifier) is not good.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agogpgscm: Fix opcode dispatch.
Justus Winter [Wed, 5 Apr 2017 14:56:46 +0000 (16:56 +0200)]
gpgscm: Fix opcode dispatch.

* tests/gpgscm/scheme.c (opexe_0): Consider 'op', not 'sc->op'.  The
former is the opcode we are currently executing.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Mmap script files.
Justus Winter [Wed, 5 Apr 2017 12:11:57 +0000 (14:11 +0200)]
gpgscm: Mmap script files.

* tests/gpgscm/main.c (load): Try to mmap the script.
* tests/gpgscm/scheme.c (scheme_load_memory): New function, a
generalization of 'scheme_load_string'.
* tests/gpgscm/scheme.h (scheme_load_memory): New prototype.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Refactor checking for opcode arguments.
Justus Winter [Mon, 3 Apr 2017 09:25:49 +0000 (11:25 +0200)]
gpgscm: Refactor checking for opcode arguments.

* tests/gpgscm/scheme.c (op_code_info): Fix type, add forward
declaration.
(check_arguments): New function.
(Eval_cycle): Use the new function.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Improve syntax dispatch.
Justus Winter [Wed, 29 Mar 2017 16:10:17 +0000 (18:10 +0200)]
gpgscm: Improve syntax dispatch.

* tests/gpgscm/scheme.c (assign_syntax): Add opcode parameter, store
opcode in the tag.
(syntaxnum): Add sc parameter, retrieve opcode from tag.
(opexe_0): Adapt callsite.
(scheme_init_custom_alloc): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Make tags mandatory.
Justus Winter [Wed, 29 Mar 2017 16:05:33 +0000 (18:05 +0200)]
gpgscm: Make tags mandatory.

* tests/gpgscm/opdefines.h: Make tags mandatory.
* tests/gpgscm/scheme.c: Likewise.
* tests/gpgscm/scheme.h: Likewise.
--

Tags provide a constant-time lookup mechanism for almost every object.
This is useful for the interpreter itself, and the code for tags is
tiny.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Add and use opcode for reversing a list in place.
Justus Winter [Tue, 4 Apr 2017 10:02:54 +0000 (12:02 +0200)]
gpgscm: Add and use opcode for reversing a list in place.

* tests/gpgscm/lib.scm (string-split-pln): Use 'reverse!'.
(string-rtrim): Likewise.
* tests/gpgscm/opdefines.h (reverse!): New opcode.
* tests/gpgscm/scheme.c (opexe_0): Handle new opcode.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Deduplicate code.
Justus Winter [Wed, 29 Mar 2017 15:09:01 +0000 (17:09 +0200)]
gpgscm: Deduplicate code.

* tests/gpgscm/scheme.c (oblist_add_by_name): Deduplicate.
(new_slot_spec_in_env): Likewise.

Fixes-commit: 6a3f857224eab108ae38e6259194b01b0ffdad8b
Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Move dispatch table into rodata.
Justus Winter [Wed, 29 Mar 2017 14:32:36 +0000 (16:32 +0200)]
gpgscm: Move dispatch table into rodata.

* tests/gpgscm/opdefines.h: Use 0 instead of NULL.
* tests/gpgscm/scheme.c (op_code_info): Use char arrays instead of
pointers, make arity parameters smaller.
(INF_ARG): Adapt.
(_OP_DEF): Likewise.
(dispatch_table): Likewise.
(procname): Likewise.
(Eval_cycle): Likewise.
(scheme_init_custom_alloc): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Use more threaded code.
Justus Winter [Wed, 29 Mar 2017 12:24:49 +0000 (14:24 +0200)]
gpgscm: Use more threaded code.

* tests/gpgscm/scheme.c (opexe_0): Use 's_thread_to' instead of
's_goto' wherever possible.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Remove now obsolete dispatcher function from the opcodes.
Justus Winter [Wed, 29 Mar 2017 12:11:58 +0000 (14:11 +0200)]
gpgscm: Remove now obsolete dispatcher function from the opcodes.

* tests/gpgscm/opdefines.h: Remove now obsolete dispatcher function
from the opcodes.
* tests/gpgscm/scheme-private.h (_OP_DEF): Adapt.
* tests/gpgscm/scheme.c (dispatch_func): Remove type declaration.
(op_code_info): Remove 'func'.
(_OP_DEF): Adapt.
(Eval_Cycle): Always call 'opexe_0'.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Merge 'opexe_6'.
Justus Winter [Wed, 29 Mar 2017 12:05:22 +0000 (14:05 +0200)]
gpgscm: Merge 'opexe_6'.

* tests/gpgscm/scheme.c (opexe_6): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--

Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Merge 'opexe_5'.
Justus Winter [Wed, 29 Mar 2017 11:57:54 +0000 (13:57 +0200)]
gpgscm: Merge 'opexe_5'.

* tests/gpgscm/scheme.c (opexe_5): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--

Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Merge 'opexe_4'.
Justus Winter [Wed, 29 Mar 2017 11:47:54 +0000 (13:47 +0200)]
gpgscm: Merge 'opexe_4'.

* tests/gpgscm/scheme.c (opexe_4): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--

Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Merge 'opexe_3'.
Justus Winter [Wed, 29 Mar 2017 11:45:25 +0000 (13:45 +0200)]
gpgscm: Merge 'opexe_3'.

* tests/gpgscm/scheme.c (opexe_3): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--

Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Merge 'opexe_2'.
Justus Winter [Wed, 29 Mar 2017 11:40:01 +0000 (13:40 +0200)]
gpgscm: Merge 'opexe_2'.

* tests/gpgscm/scheme.c (opexe_2): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--

Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Merge 'opexe_1'.
Justus Winter [Wed, 29 Mar 2017 11:32:38 +0000 (13:32 +0200)]
gpgscm: Merge 'opexe_1'.

* tests/gpgscm/scheme.c (opexe_1): Merge into 'opexe_0'.
* tests/gpgscm/opdefines.h: Adapt.
--

Having separate functions to execute opcodes reduces our ability to
thread the code and prevents the dispatch_table from being moved to
rodata.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agoagent: Use "ll" length specifier when time_t is larger.
NIIBE Yutaka [Mon, 10 Apr 2017 06:04:57 +0000 (15:04 +0900)]
agent: Use "ll" length specifier when time_t is larger.

* agent/command.c (cmd_keytocard): Use KEYTOCARD_TIMESTAMP_FORMAT.

--

On a big-endian 32-bit platform which uses 64-bit time_t, it might go
wrong.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agoscd: Relax a condition for p15 driver.
NIIBE Yutaka [Mon, 10 Apr 2017 04:18:30 +0000 (13:18 +0900)]
scd: Relax a condition for p15 driver.

* scd/app-p15.c (read_ef_aodf): Fix.

--

Fixes-commit: 3c1ad96f1ce838daf2d861b33e6611f6d3043d25
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agoscd: Relax a condition for p15 driver.
NIIBE Yutaka [Mon, 10 Apr 2017 03:59:29 +0000 (12:59 +0900)]
scd: Relax a condition for p15 driver.

* scd/app-p15.c (read_ef_aodf): Remove possibly redundant condition.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agoscd: Remove "special transport" support.
NIIBE Yutaka [Mon, 10 Apr 2017 03:25:06 +0000 (12:25 +0900)]
scd: Remove "special transport" support.

* scd/ccid-driver.c (transports, my_sleep, prepare_special_transport)
(writen): Remove.
(ccid_dev_scan, ccid_dev_scan_finish, ccid_get_BAI): Only for USB.
(ccid_open_reader, do_close_reader, bulk_out, bulk_in, abort_cmd)
(ccid_poll, ccid_transceive): Likewise.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agogpgscm: Allocate small integers in the rodata section.
Justus Winter [Thu, 23 Mar 2017 14:21:36 +0000 (15:21 +0100)]
gpgscm: Allocate small integers in the rodata section.

* tests/gpgscm/Makefile.am (gpgscm_SOURCES): Add new file.
* tests/gpgscm/scheme-private.h (struct cell): Move number to the top
of the union so that we can initialize it.
(struct scheme): Remove 'integer_segment'.
* tests/gpgscm/scheme.c (initialize_small_integers): Remove function.
(small_integers): New variable.
(MAX_SMALL_INTEGER): Compute.
(mk_small_integer): Adapt.
(mark): Avoid marking objects already marked.  This allows us to run
the algorithm over objects in the rodata section if they are already
marked.
(scheme_init_custom_alloc): Remove initialization.
(scheme_deinit): Remove deallocation.
* tests/gpgscm/small-integers.h: New file.
--

Allocate small integers from a fixed pool in the rodata section.  This
spares us the initialization, and deduplicates integers across
different processes.  It also makes the integers immutable, increasing
memory safety.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Make global data constant when possible.
Justus Winter [Thu, 23 Mar 2017 11:50:27 +0000 (12:50 +0100)]
gpgscm: Make global data constant when possible.

* tests/gpgscm/scheme-private.h (struct scheme): Make 'vptr' const.
* tests/gpgscm/scheme.c (num_zero): Statically initialize and turn
into constant.
(num_one): Likewise.
(charnames): Change type so that it can be stored in rodata.
(is_ascii_name): Adapt slightly.
(assign_proc): Make argument const char *.
(op_code_info): Make some fields const char *.
(tests): Make const.
(dispatch_table): Make const.  At least it can be made read-only after
relocation.
(Eval_Cycle): Adapt slightly.
(vtbl): Make const.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Remove arbitrary limit on number of cell segments.
Justus Winter [Wed, 22 Mar 2017 15:22:57 +0000 (16:22 +0100)]
gpgscm: Remove arbitrary limit on number of cell segments.

* tests/gpgscm/scheme-private.h (struct scheme): Remove fixed-size
arrays for cell segments, replace them with a pointer to the new
'struct cell_segment' instead.
* tests/gpgscm/scheme.c (struct cell_segment): New definition.
(_alloc_cellseg): Allocate the header within the segment, return a
pointer to the header.
(_dealloc_cellseg): New function.
(alloc_cellseg): Insert the segments into a list.
(_get_cell): Allocate a new segment if less than a quarter of
CELL_SIGSIZE is recovered during garbage collection.
(initialize_small_integers): Adapt callsite.
(gc): Walk the list of segments.
(scheme_init_custom_alloc): Remove initialization of removed field.
(scheme_deinit): Adapt deallocation.
--

Previously the number of cells that could be allocated was a
compile-time limit.  Remove this limit.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Fix compact vector encoding.
Justus Winter [Fri, 7 Apr 2017 10:27:47 +0000 (12:27 +0200)]
gpgscm: Fix compact vector encoding.

* tests/gpgscm/scheme-private.h (struct cell): Use uintptr_t for
'_flags'.  This way, '_flags' has the size of a machine word.
--

The compact vector representation introduced in 49e2ae65 requires that
we can tell apart pointers and type flags.  This did not work on
64-bit big-endian architectures.

Fixes a crash on 64-bit big-endian architectures.

Hat-tip-to: gniibe
Fixes-commit: 49e2ae65e892f93be7f87cfaae3392b50a99e4b1
Signed-off-by: Justus Winter <justus@g10code.com>
20 months agodoc: Explain the '>' in a key listing.
Werner Koch [Fri, 7 Apr 2017 08:26:55 +0000 (10:26 +0200)]
doc: Explain the '>' in a key listing.

--

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agogpg: Fix printing of offline taken subkey.
Werner Koch [Fri, 7 Apr 2017 08:11:07 +0000 (10:11 +0200)]
gpg: Fix printing of offline taken subkey.

* g10/keylist.c (list_keyblock_print): Set SECRET to 2 and not 0x32.
--

Reported-by: Danielle McLean <dani@00dani.me>
Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agoscd: Internal CCID reader cleanup.
NIIBE Yutaka [Fri, 7 Apr 2017 04:30:35 +0000 (13:30 +0900)]
scd: Internal CCID reader cleanup.

* scd/ccid-reader.c (scan_usb_device): Only for scan mode, so, rename
from scan_or_find_usb_device.
(scan_devices): Likewise.  Remove support of special transport types.
(ccid_get_reader_list): Simplify.
(abort_cmd): Fix error return.
(send_escape_cmd): Fix for RESULTLEN == NULL.
(ccid_transceive_secure): Remove unnecessary var updates.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agoscd: Don't keep CCID reader open when card is not available.
NIIBE Yutaka [Fri, 7 Apr 2017 03:18:16 +0000 (12:18 +0900)]
scd: Don't keep CCID reader open when card is not available.

* scd/apdu.c (open_ccid_reader): Fail if no ATR.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agoagent: Serialize access to passphrase cache.
NIIBE Yutaka [Thu, 6 Apr 2017 23:39:26 +0000 (08:39 +0900)]
agent: Serialize access to passphrase cache.

* agent/cache.c (encryption_lock): Remove.
(cache_lock): New.  Now, we have coarse grain lock to serialize
entire cache access.
(initialize_module_cache): Use CACHE_LOCK.
(init_encryption, new_data): Remove ENCRYPTION_LOCK.
(agent_flush_cache, agent_put_cache, agent_get_cache): Lock the cache.

--

GnuPG-bug-id: 3027
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agogpgscm: Avoid mutating integer.
Justus Winter [Thu, 6 Apr 2017 14:24:49 +0000 (16:24 +0200)]
gpgscm: Avoid mutating integer.

* tests/gpgscm/scheme.c (opexe_5): Do not modify the integer in-place
while printing an vector.  Integer objects may be shared, so they must
not be mutated.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Initialize unused slots in vectors.
Justus Winter [Thu, 6 Apr 2017 14:21:48 +0000 (16:21 +0200)]
gpgscm: Initialize unused slots in vectors.

* tests/gpgscm/scheme.c (get_vector_object): Initialize unused slots
at the end of vectors.
--

They should not be used for anything, but let's just initialize them
to something benign to be sure.

GnuPG-bug-id: 3014
Signed-off-by: Justus Winter <justus@g10code.com>
20 months agotests: Fix distcheck.
Justus Winter [Thu, 6 Apr 2017 13:17:08 +0000 (15:17 +0200)]
tests: Fix distcheck.

* tests/Makefile.am (SUBDIRS): Add 'pkits' again.  Simply dropping it
makes 'make distcheck' unhappy.
* tests/pkits/Makefile.am (TESTS): Remove all tests.
--

Disable the 'pkits' tests in a way that keeps 'make distcheck' happy.
To run tests individually, do

  make -Ctests/pkits check TESTS=some-test

GnuPG-bug-id: 3067
Fixes-commit: af1c1a57e46a00a32d83c1a58c5f3ef6f4a1c1d1
Signed-off-by: Justus Winter <justus@g10code.com>
20 months agotests: Disable 'pkits' test suite.
Justus Winter [Thu, 6 Apr 2017 12:31:54 +0000 (14:31 +0200)]
tests: Disable 'pkits' test suite.

* tests/Makefile.am (SUBDIRS): Drop 'pkits'.
* tests/pkits/common.sh: Fix locating 'PKITS_data.tar.bz2'.
* tests/pkits/inittests: Likewise.
--

These tests are unmaintained and broken, and were previously only run
when doing in-tree builds, hence nobody noticed that they were badly
broken.

GnuPG-bug-id: 3067
Signed-off-by: Justus Winter <justus@g10code.com>
20 months agotests: Make test more robust.
Justus Winter [Thu, 6 Apr 2017 10:33:37 +0000 (12:33 +0200)]
tests: Make test more robust.

* tests/openpgp/4gb-packet.scm: Skip if we do not have BZIP2.
* tests/openpgp/defs.scm (have-compression-algo?): New function.

GnuPG-bug-id: 3028
Signed-off-by: Justus Winter <justus@g10code.com>
20 months agotests: Fix setup of ephemeral home directories.
Justus Winter [Wed, 5 Apr 2017 13:18:30 +0000 (15:18 +0200)]
tests: Fix setup of ephemeral home directories.

* tests/openpgp/defs.scm (with-ephemeral-home-directory): Set
GNUPGHOME and cwd to the ephemeral directory before calling the setup
function.

GnuPG-bug-id: 3047
Fixes-commit: 32b75fb7743f35936d7014fce33c90ba97dfa374
Signed-off-by: Justus Winter <justus@g10code.com>
20 months agotests: Fix setup of ephemeral home directories.
Justus Winter [Tue, 4 Apr 2017 12:32:04 +0000 (14:32 +0200)]
tests: Fix setup of ephemeral home directories.

* tests/openpgp/defs.scm (with-ephemeral-home-directory): Create
configuration files when we enter the context.
* tests/openpgp/setup.scm: Do not use an ephemeral home directory.
Tests should always use the cwd.
* tests/gpgsm/setup.scm: Likewise.
* tests/gpgsm/export.scm: Add explicit constructor function.
* tests/openpgp/decrypt-session-key.scm: Likewise.
* tests/openpgp/decrypt-unwrap-verify.scm: Likewise.
--

Previously, ephemeral homedirectories lacked a configuration, hence
GnuPG tried to start backend daemons using their installed locations.
Fix this by explicitly creating a suitable configuration.

GnuPG-bug-id: 3047
Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Fix copying values.
Justus Winter [Tue, 4 Apr 2017 15:36:45 +0000 (17:36 +0200)]
gpgscm: Fix copying values.

* tests/gpgscm/scheme.c (copy_value): New function.
(mk_tagged_value): Use new function.
(opexe_4): Likewise for OP_SAVE_FORCED.
--

Occasionally, we need to copy a value from one location in the storage
to another.  Scheme objects are fine.  Some primitive objects,
however, require finalization, usually to free resources.

For these values, we either make a copy or acquire a reference.

Fixes e.g. a double free if a delayed expression evaluating to a
string is forced.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Simplify get-output-string operation.
Justus Winter [Tue, 4 Apr 2017 15:38:50 +0000 (17:38 +0200)]
gpgscm: Simplify get-output-string operation.

* tests/gpgscm/scheme.c (opexe_4): Simplify 'get-output-string'.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpgscm: Simplify substring operation.
Justus Winter [Tue, 4 Apr 2017 12:28:45 +0000 (14:28 +0200)]
gpgscm: Simplify substring operation.

* tests/gpgscm/scheme.c (opexe_2): Simplify 'substring'.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agopo: Update Japanese translation.
NIIBE Yutaka [Tue, 4 Apr 2017 01:48:09 +0000 (10:48 +0900)]
po: Update Japanese translation.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agoagent: Minor fix for get_client_pid.
NIIBE Yutaka [Tue, 4 Apr 2017 01:39:00 +0000 (10:39 +0900)]
agent: Minor fix for get_client_pid.

* agent/command-ssh.c (get_client_pid): Use 0 to initialize.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
20 months agoPost release updates.
Werner Koch [Mon, 3 Apr 2017 19:54:53 +0000 (21:54 +0200)]
Post release updates.

--

20 months agoRelease 2.1.20 gnupg-2.1.20
Werner Koch [Mon, 3 Apr 2017 18:59:47 +0000 (20:59 +0200)]
Release 2.1.20

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agodirmngr: New option --disable-ipv6
Werner Koch [Mon, 3 Apr 2017 18:56:12 +0000 (20:56 +0200)]
dirmngr: New option --disable-ipv6

* dirmngr/dirmngr.h (struct opt): Add field 'disable_ipv6'.
* dirmngr/dirmngr.c (oDisableIPv6): New const.
(opts): New option --disable-ipv6.
(parse_rereadable_options): Set that option.
* dirmngr/dns-stuff.c (opt_disable_ipv6): New var.
(set_dns_disable_ipv6): New.
(resolve_name_standard): Make use of it.
* dirmngr/ks-engine-finger.c (ks_finger_fetch): Take care of
OPT.DISABLE_IPV6.
* dirmngr/ks-engine-hkp.c (map_host): Ditto.
(send_request): Ditto.
* dirmngr/ks-engine-http.c (ks_http_fetch): Ditto.
* dirmngr/ocsp.c (do_ocsp_request): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agodirmngr,w32: Silence the 'certificate already cached' message.
Werner Koch [Mon, 3 Apr 2017 18:34:13 +0000 (20:34 +0200)]
dirmngr,w32: Silence the 'certificate already cached' message.

* dirmngr/certcache.c (load_certs_from_w32_store): Silenece an info
message.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agodirmngr: Handle EIO which is sometimes returned by cookie functions.
Werner Koch [Mon, 3 Apr 2017 18:23:18 +0000 (20:23 +0200)]
dirmngr: Handle EIO which is sometimes returned by cookie functions.

* dirmngr/ks-engine-hkp.c (handle_send_request_error): Handle EIO.
--

Suggested-by: Andre Heinecke
Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agodirmngr: Always print a warning for a missing /etc/hosts.
Werner Koch [Mon, 3 Apr 2017 18:20:27 +0000 (20:20 +0200)]
dirmngr: Always print a warning for a missing /etc/hosts.

* dirmngr/dns-stuff.c (libdns_init): No Windows specific handling of a
missing /etc/hosts.
--

My last comment on this was flawed.  Windows seems to always have its
version of /etc/hosts.  Only the en passant fixed bad escaping led me
assume that this was the case.  Thanks to Andre for complaining about
my comment remark.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agodirmngr: Do not assume that /etc/hosts exists.
Werner Koch [Mon, 3 Apr 2017 17:10:50 +0000 (19:10 +0200)]
dirmngr: Do not assume that /etc/hosts exists.

* dirmngr/dns-stuff.c (libdns_init): Do not bail out.
--

A standard Windows installation does not have a hosts file and thus we
can't bail out here.  We should also not bail out on a Unix system
because /etc/hosts is just one method in  nsswitch.conf.

Fixes-commit: 88f1505f0613894d5544290a170119eb538921e5
Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agopo: Auto-update.
Werner Koch [Mon, 3 Apr 2017 15:12:26 +0000 (17:12 +0200)]
po: Auto-update.

--

20 months agopo: Update the German translation
Werner Koch [Mon, 3 Apr 2017 15:11:24 +0000 (17:11 +0200)]
po: Update the German translation

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agopo: Update Russian translation
Ineiev [Mon, 3 Apr 2017 15:03:36 +0000 (17:03 +0200)]
po: Update Russian translation

--

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agodoc: Add two example profiles.
Werner Koch [Mon, 3 Apr 2017 14:53:01 +0000 (16:53 +0200)]
doc: Add two example profiles.

--

20 months agogpgconf: Add --enable-extended-key-format for the agent.
Werner Koch [Mon, 3 Apr 2017 14:52:37 +0000 (16:52 +0200)]
gpgconf: Add --enable-extended-key-format for the agent.

* tools/gpgconf-conf.c: Add option.
* agent/gpg-agent.c (main) <aGPGConfList>: Add option.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agogpgscm: Slightly improve the procedure dispatch.
Justus Winter [Thu, 30 Mar 2017 10:19:01 +0000 (12:19 +0200)]
gpgscm: Slightly improve the procedure dispatch.

* tests/gpgscm/scheme.c (procnum): Procedures always have an integer
number, so we can safely use the cheaper 'ivalue_unchecked'.

Signed-off-by: Justus Winter <justus@g10code.com>
20 months agogpg: Handle critical marked 'Reason for Revocation'.
Werner Koch [Mon, 3 Apr 2017 06:51:52 +0000 (08:51 +0200)]
gpg: Handle critical marked 'Reason for Revocation'.

* g10/parse-packet.c (can_handle_critical): Add
SIGSUBPKT_REVOC_REASON.
--

Some software seems to mark that subpacket as criticial.  Although gpg
has no special treatment for a revocation reasons (except for
--list-packets) we can accept a criticial marked anyway.  There are no
mandatary rules specified on how to handle a revocation reason.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agoagent: Use OCB for key protection with --enable-extended-key-format.
Werner Koch [Sun, 2 Apr 2017 18:02:55 +0000 (20:02 +0200)]
agent: Use OCB for key protection with --enable-extended-key-format.

* agent/protect.c (PROT_DEFAULT_TO_OCB): Remove macro.
(agent_protect): Make the default protection mode depend on the extend
key format option.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agokbx: Unify blob reading functions.
Werner Koch [Sat, 1 Apr 2017 09:10:47 +0000 (11:10 +0200)]
kbx: Unify blob reading functions.

* kbx/keybox-file.c (_keybox_read_blob): Remove.
(_keybox_read_blob2): Rename to ....
(_keybox_read_blob): this.  Make arg options.  Change all callers.
* kbx/keybox-search.c (keybox_search): Factor fopen call out to ...
(open_file): new.
(keybox_seek): Als use open_file.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agogpg: Avoid multiple open calls to the keybox file.
Werner Koch [Fri, 31 Mar 2017 18:44:05 +0000 (20:44 +0200)]
gpg: Avoid multiple open calls to the keybox file.

* g10/keydb.h (KEYDB_HANDLE): Move typedef to ...
* g10/gpg.h: here.
(struct server_control_s): Add field 'cached_getkey_kdb'.
* g10/gpg.c (gpg_deinit_default_ctrl): Release that keydb handle.
* g10/getkey.c (getkey_end): Cache keydb handle.
(get_pubkey): Use cached keydb handle.
* kbx/keybox-search.c (keybox_search_reset): Use lseek instead of
closing the file.
--

Before this patch a "gpg --check-sigs" opened and closed the keybox
file for almost every signature check.  By caching the keydb handle
and using lseek(2) this can be limited to just 2 times.  This might
speed up things on Windows.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agogpg: Pass CTRL also to getkey_end.
Werner Koch [Fri, 31 Mar 2017 18:35:28 +0000 (20:35 +0200)]
gpg: Pass CTRL also to getkey_end.

* g10/getkey.c (getkey_end): Add arg CTRL.  Change all callers.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agogpg: Print more stats for the keydb and the signature cache.
Werner Koch [Fri, 31 Mar 2017 18:03:43 +0000 (20:03 +0200)]
gpg: Print more stats for the keydb and the signature cache.

* g10/sig-check.c (sig_check_dump_stats): New.
(cache_stats): New struct.
(check_key_signature2): Update stats.
* g10/gpg.c (g10_exit): Call new function.
* g10/keydb.c (kid_not_found_cache_count): Replace by ...
(kid_not_found_stats): ... new struct.  Change users.
(keydb_stats): New struct.  Update the counters.
(keydb_dump_stats): Print all stats.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agogpg: Assert that an opaque parameter is really what we expect.
Werner Koch [Fri, 31 Mar 2017 18:06:54 +0000 (20:06 +0200)]
gpg: Assert that an opaque parameter is really what we expect.

* g10/gpg.h (SERVER_CONTROL_MAGIC): New const.
(server_control_s): Add field 'magic'.
* g10/gpg.c (gpg_init_default_ctrl): Init MAGIC.
* g10/import.c (impex_filter_getval): Assert MAGIC.

Signed-off-by: Werner Koch <wk@gnupg.org>
20 months agogpg: Pass CTRL to many more functions.
Werner Koch [Fri, 31 Mar 2017 18:03:52 +0000 (20:03 +0200)]
gpg: Pass CTRL to many more functions.

--

For proper operations as a server we need to avoid global variables.
Thus we need to pass the session state CTRL to most functions.  Quite
a lot of changes but fortunately straightforward to do.

Signed-off-by: Werner Koch <wk@gnupg.org>