gnupg.git
3 days agogpg: Start using OCB mode by default with Libgcrypt 1.9. master
Werner Koch [Fri, 16 Nov 2018 08:19:10 +0000 (09:19 +0100)]
gpg: Start using OCB mode by default with Libgcrypt 1.9.

* g10/main.h (GCRYPT_VERSION_NUMBER): Fix type in condition.
--

GnuPG-bug-id: 4259
Signed-off-by: Werner Koch <wk@gnupg.org>
3 days agodoc: Add NEWS item from recent 2.2 releases.
Werner Koch [Fri, 16 Nov 2018 07:30:47 +0000 (08:30 +0100)]
doc: Add NEWS item from recent 2.2 releases.

--

4 days agocard: Display UIF setting.
NIIBE Yutaka [Thu, 15 Nov 2018 04:57:31 +0000 (13:57 +0900)]
card: Display UIF setting.

* g10/call-agent.h (agent_card_info_s): Add UIF fields.
* g10/call-agent.c (learn_status_cb): Put UIF DOs info.
* g10/card-util.c (current_card_status): Output for UIF.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
4 days agoscd: Make "learn" report about KDF data object.
NIIBE Yutaka [Thu, 15 Nov 2018 04:31:12 +0000 (13:31 +0900)]
scd: Make "learn" report about KDF data object.

* scd/app-openpgp.c (do_learn_status): Report KDF attr.
* g10/card-util.c (current_card_status): Output KDF for with_colons.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
4 days agocard: Display if KDF is enabled or not.
NIIBE Yutaka [Thu, 15 Nov 2018 03:19:02 +0000 (12:19 +0900)]
card: Display if KDF is enabled or not.

* g10/call-agent.h (kdf_do_enabled): New field.
* g10/call-agent.c (learn_status_cb): Set kdf_do_enabled if available.
* g10/card-util.c (current_card_status): Inform the availability.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
5 days agoMerge branch 'seckey-sync-work' into master
Werner Koch [Wed, 14 Nov 2018 12:37:41 +0000 (13:37 +0100)]
Merge branch 'seckey-sync-work' into master

--

5 days agoRemove the gpg-zip script.
Werner Koch [Wed, 14 Nov 2018 12:17:49 +0000 (13:17 +0100)]
Remove the gpg-zip script.

* tools/gpg-zip.in: Remove.
* m4/tar-ustar.m4: Remove.
--

Note that the script was even not anymore installed.  See also
GnuPG-bug-id: 4252

Signed-off-by: Werner Koch <wk@gnupg.org>
5 days agoagent: Simplify agent_popup_message_stop.
NIIBE Yutaka [Wed, 14 Nov 2018 01:45:15 +0000 (10:45 +0900)]
agent: Simplify agent_popup_message_stop.

* agent/call-pinentry.c (agent_popup_message_stop): Just kill it.

--

By checking if it's alive or not, we can lower a risk of sending
SIGINT to a wrong process on unusual condition when PID is re-used to
a different process.

That's true, however, since it's alive usually, simply sending SIGINT
is enough here.

Note that here is a race condition for detecting if process is active
or not;  A process can die just after being detected alive.

Moreover, when the process of pinentry accidentally died already, it
should have caused return of assuan_transact and the thread of
popup_message_thread likely already set popup_finished=1.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
6 days agodirmngr: Support the new WKD draft with the openpgpkey subdomain.
Werner Koch [Tue, 13 Nov 2018 10:35:39 +0000 (11:35 +0100)]
dirmngr: Support the new WKD draft with the openpgpkey subdomain.

* dirmngr/server.c (proc_wkd_get): Implement new openpgpkey subdomain
method.

Signed-off-by: Werner Koch <wk@gnupg.org>
6 days agopo: Clarify a translator's note.
Werner Koch [Mon, 12 Nov 2018 17:13:31 +0000 (18:13 +0100)]
po: Clarify a translator's note.

--

6 days agobuild: Update libgcrypt.m4 and ntbtls.m4.
NIIBE Yutaka [Tue, 13 Nov 2018 02:37:37 +0000 (11:37 +0900)]
build: Update libgcrypt.m4 and ntbtls.m4.

* m4/libgcrypt.m4: Update from master.
* m4/ntbtls.m4: Update from master.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
7 days agodirmngr: Add FLUSHCRLs command
Andre Heinecke [Wed, 24 Oct 2018 08:40:42 +0000 (10:40 +0200)]
dirmngr: Add FLUSHCRLs command

Summary:
* dirmngr/crlcache.c (crl_cache_flush): Also deinit the cache.
* dirmngr/server.c (hlp_flushcrls, cmd_flushcrls): New.
(register_commands): Add FLUSHCRLS.

--
This allows it to flush the CRL cache of a running dirmngr
server. This can be useful to debug / analyze CRL issues.

GnuPG-Bug-Id: T3967

Differential Revision: https://dev.gnupg.org/D469

Signed-off-by: Andre Heinecke <aheinecke@intevation.de>
(cherry picked from commit 00321a025f90990a71b60b4689ede1f38fbde347)

7 days agocommon: Prepare for parsing mail sub-addresses.
Werner Koch [Mon, 12 Nov 2018 06:44:33 +0000 (07:44 +0100)]
common: Prepare for parsing mail sub-addresses.

* common/mbox-util.c (mailbox_from_userid): Add arg subaddress and
implement.  Change all callers to pass false for it.

* common/t-mbox-util.c (run_mbox_no_sub_test): New.
(run_filter): Add arg no_sub.
(main): Call new test and add option --no-sub.
--

Some stats: In the about 5300000 keys on the SKS servers we found 3055
unique mailboxes with a '+' in it.  After removing leading and
trailing '+' as well as multiple '+' (e.g. "c++" or "foo+bar+baz")
2697 were left which seem to be valid sub-addresses.

To filter mailboxes out from a line delimited list with
user-ids (e.g. an SQL output), the command

   t-mbox-util --verbose --filter

can be used; to output w/o sub-addresses add --no-sub.

GnuPG-bug-id: 4200
Signed-off-by: Werner Koch <wk@gnupg.org>
8 days agogpg: Fix format string in gpgcompose.c
Werner Koch [Sun, 11 Nov 2018 11:20:34 +0000 (12:20 +0100)]
gpg: Fix format string in gpgcompose.c

--

For size_t  use "%zu"
For ssize_t use "%zd"

Signed-off-by: Werner Koch <wk@gnupg.org>
8 days agocommon: Add --filter option to t-mbox-util.
Werner Koch [Sun, 11 Nov 2018 11:01:42 +0000 (12:01 +0100)]
common: Add --filter option to t-mbox-util.

* common/t-mbox-util.c (run_filter): New.
(main): Add option parser.

9 days agog10/mainproc: avoid extra hash contexts when decrypting AEAD input
Jussi Kivilinna [Fri, 9 Nov 2018 16:07:38 +0000 (18:07 +0200)]
g10/mainproc: avoid extra hash contexts when decrypting AEAD input

* g10/mainproc.c (mainproc_context): New member
'seen_pkt_encrypted_aead'.
(release_list): Clear 'seen_pkt_encrypted_aead'.
(proc_encrypted): Set 'seen_pkt_encrypted_aead'.
(have_seen_pkt_encrypted_aead): New.
(proc_plaintext): Do not enable extra hash contexts when decryption
AEAD input.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
10 days agog10/armor: optimize radix64 to binary conversion
Jussi Kivilinna [Thu, 8 Nov 2018 19:31:12 +0000 (21:31 +0200)]
g10/armor: optimize radix64 to binary conversion

* g10/armor.c (asctobin): Larger look-up table for fast path.
(initialize): Update 'asctobin' initialization.
(radix64_read): Add fast path for radix64 to binary conversion.
--

This patch adds fast path for radix64 to binary conversion in
armored decryption.

Benchmark results below, tested on Intel Core i7-4790K (turbo off).
Encrypted 2 GiB through pipe to ramfs file using AES128. Decrypt
ramfs file out through pipe to /dev/null.

before patch-set
----------------
               gpg process
armor:         user time    pipe transfer rate
 encrypt-aead:  13.8         140 MB/s
 decrypt-aead:  30.6         68 MB/s
 encrypt-cfb:   17.4         114 MB/s
 decrypt-cfb:   32.6         64 MB/s

after (decrypt+iobuf+crc+radix64 opt)
-------------------------------------
               gpg process
armor:         user time    pipe transfer rate
 decrypt-aead:  9.8          200 MB/s
 decrypt-cfb:   11.9         168 MB/s

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
10 days agog10/armor: optimize binary to radix64 conversion
Jussi Kivilinna [Thu, 8 Nov 2018 19:31:12 +0000 (21:31 +0200)]
g10/armor: optimize binary to radix64 conversion

* g10/armor.c (bintoasc): Change to read-only.
(initialize): Use const pointer for 'bintoasc'.
(armor_output_buf_as_radix64): New function for faster binary to
radix64 conversion.
(armor_filter): Use new conversion function.
--

This patch adds faster binary to radix64 conversion to speed up
armored encryption.

Benchmark results below, tested on Intel Core i7-4790K (turbo off).
Encrypted 2 GiB through pipe to ramfs file using AES128. Decrypt
ramfs file out through pipe to /dev/null.

before patch-set
----------------
               gpg process
armor:         user time    pipe transfer rate
 encrypt-aead:  13.8         140 MB/s
 decrypt-aead:  30.6         68 MB/s
 encrypt-cfb:   17.4         114 MB/s
 decrypt-cfb:   32.6         64 MB/s

after (decrypt+iobuf+crc+radix64 opt)
-------------------------------------
               gpg process
armor:         user time    pipe transfer rate
 encrypt-aead:  2.7          523 MB/s
 encrypt-cfb:   6.7          264 MB/s

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
10 days agog10/armor: use libgcrypt's CRC24 implementation
Jussi Kivilinna [Thu, 8 Nov 2018 19:31:12 +0000 (21:31 +0200)]
g10/armor: use libgcrypt's CRC24 implementation

* g10/armor.c (CRCINIT, CRCPOLY, CRCUPDATE, crc_table): Remove.
(new_armor_context): Open libgcrypt CRC24 context.
(release_armor_context): Close CRC24 context.
(initialize): Remove CRC table generation.
(get_afx_crc): New.
(check_input, fake_packet, radix64_read, armor_filter): Update to use
CRC24 context.
* g10/filter.h (armor_filter_context_t): Replace crc intermediate value
with libgcrypt md context pointer.
--

This patch changes armor filter to use optimized CRC24 implementation
from libgcrypt to speed up encryption and decryption.

Benchmark results below, tested on Intel Core i7-4790K (turbo off).
Encrypted 2 GiB through pipe to ramfs file using AES128. Decrypt
ramfs file out through pipe to /dev/null.

before patch-set
----------------
               gpg process
armor:         user time    pipe transfer rate
 encrypt-aead:  13.8         140 MB/s
 decrypt-aead:  30.6         68 MB/s
 encrypt-cfb:   17.4         114 MB/s
 decrypt-cfb:   32.6         64 MB/s

after (decrypt+iobuf+crc opt)
-----------------------------
               gpg process
armor:         user time    pipe transfer rate
 encrypt-aead:  8.7          211 MB/s
 decrypt-aead:  17.6         116 MB/s
 encrypt-cfb:   12.6         153 MB/s
 decrypt-cfb:   19.6         105 MB/s

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
10 days agocommon/iobuf: optimize iobuf_read_line
Jussi Kivilinna [Thu, 8 Nov 2018 19:31:12 +0000 (21:31 +0200)]
common/iobuf: optimize iobuf_read_line

* common/iobuf.c (iobuf_read_line): Add fast path for finding '\n'
character in buffer.
--

This patch reduce per byte overhead in iobuf_read_line by avoiding
using iobuf_get when possible and use memchr to find '\n'. This
speeds armored decryption.

Benchmark results below, tested on Intel Core i7-4790K (turbo off).
Encrypted 2 GiB through pipe to ramfs file using AES128. Decrypt
ramfs file out through pipe to /dev/null.

before patch-set
----------------
               gpg process
armor:         user time    pipe transfer rate
 encrypt-aead:  13.8         140 MB/s
 decrypt-aead:  30.6         68 MB/s
 encrypt-cfb:   17.4         114 MB/s
 decrypt-cfb:   32.6         64 MB/s

after (decrypt+iobuf opt)
-------------------------
               gpg process
armor:         user time    pipe transfer rate
 decrypt-aead:  22.5         92 MB/s
 decrypt-cfb:   24.4         85 MB/s

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
10 days agog10/armor: remove unused unarmor_pump code
Jussi Kivilinna [Thu, 8 Nov 2018 19:31:12 +0000 (21:31 +0200)]
g10/armor: remove unused unarmor_pump code

* g10/armor.c (unarmor_state_e, unarmor_pump_s, unarmor_pump_new)
(unarmor_pump_release, unarmor_pump): Remove.
* g10/filter.h (UnarmorPump, unarmor_pump_new, unarmor_pump_release)
(unarmor_pump): Remove.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
10 days agog10/armor: fix eof checks in radix64_read
Jussi Kivilinna [Thu, 8 Nov 2018 19:31:12 +0000 (21:31 +0200)]
g10/armor: fix eof checks in radix64_read

* g10/armor.c (radix64_read): Check EOF with '!afx->buffer_len' instead
of 'c == -1', as 'c' is never set to this value.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
10 days agog10/decrypt-data: use iobuf_read for higher performance
Jussi Kivilinna [Thu, 8 Nov 2018 19:31:12 +0000 (21:31 +0200)]
g10/decrypt-data: use iobuf_read for higher performance

* g10/decrypt-data.c (fill_buffer): Use iobuf_read instead of iobuf_get
for reading data.
--

This patch reduces iobuf_read per byte processing overhead and speeds
up decryption.

Benchmark results below, tested on Intel Core i7-4790K (turbo off).
Encrypted 2 GiB through pipe to ramfs file using AES128. Decrypt
ramfs file out through pipe to /dev/null.

before patch-set
----------------
       gpg process
no-armor:      user time    pipe transfer rate
 encrypt-aead:  1.02         1.0 GB/s
 decrypt-aead:  10.8         185 MB/s
 encrypt-cfb:   4.8          342 MB/s
 decrypt-cfb:   12.7         157 MB/s

               gpg process
armor:         user time    pipe transfer rate
 encrypt-aead:  13.8         140 MB/s
 decrypt-aead:  30.6         68 MB/s
 encrypt-cfb:   17.4         114 MB/s
 decrypt-cfb:   32.6         64 MB/s

after (decrypt opt)
-------------------
               gpg process
no-armor:      user time    pipe transfer rate
 decrypt-aead:  7.3          263 MB/s
 decrypt-cfb:   9.3          211 MB/s

               gpg process
armor:         user time    pipe transfer rate
 decrypt-aead:  27.0         77 MB/s
 decrypt-cfb:   29.0         72 MB/s

Note: decryption results are much slower than encryption because of
extra SHA1 & RIPEMD160 hashing.

GnuPG-bug-id: 3786
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
10 days agog10/decrypt-data: use fill_buffer in more places
Jussi Kivilinna [Thu, 8 Nov 2018 19:31:12 +0000 (21:31 +0200)]
g10/decrypt-data: use fill_buffer in more places

* g10/decrypt-data.c (mdc_decode_filter, decode_filter): Use
fill_buffer.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
11 days agogpgcompose: Fix --sk-esk.
NIIBE Yutaka [Thu, 8 Nov 2018 11:52:38 +0000 (20:52 +0900)]
gpgcompose: Fix --sk-esk.

* g10/gpgcompose.c (sk_esk): Copy the result content correctly.
Don't forget to free the result.

--

Fixes-commit: 0131d4369a81a51bf7bb328cc81a3bb082ed1a94
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
11 days agog10: Fix log_debug formatting.
NIIBE Yutaka [Thu, 8 Nov 2018 03:14:23 +0000 (12:14 +0900)]
g10: Fix log_debug formatting.

* g10/cipher-aead.c (do_flush): No cast is correct.
* g10/decrypt-data.c (aead_underflow): No cast needed.
Use "%j" for uint64_t for chunklen.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
13 days agog10: Fix print_keygrip for smartcard.
NIIBE Yutaka [Tue, 6 Nov 2018 06:28:43 +0000 (15:28 +0900)]
g10: Fix print_keygrip for smartcard.

* g10/card-util.c (print_keygrip): Use tty_fprintf.

--

Reported-by: Joey Pabalinas <joeypabalinas@gmail.com>
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
13 days agowks: New option --with-colons for gpg-wks-client.
Werner Koch [Mon, 5 Nov 2018 19:58:27 +0000 (20:58 +0100)]
wks: New option --with-colons for gpg-wks-client.

* tools/gpg-wks.h (opt): Add field with_colons.
* tools/gpg-wks-client.c (oWithColons): New const.
(opts, parse_arguments): Add option --with-colons.
(main): Change aSupported to take several domains in --with-colons
mode.
(command_send): Factor policy getting code out to ...
(get_policy_and_sa): New function.
(command_supported): Make use of new function.
--

In addition to this the --create command now also supports a
submission address only in the policy file.  That means the
submission-address file is not anymore required and can be replaced by
the policy file.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 weeks agospeedo: Remove obsolete configure option of gpgme.
Werner Koch [Mon, 5 Nov 2018 11:47:44 +0000 (12:47 +0100)]
speedo: Remove obsolete configure option of gpgme.

* build-aux/speedo.mk (speedo_pkg_gpgme_configure): Remove
--disable-w32-qt option.
--

This option is obsolete since GPGME 1.7 (in 2016)

Signed-off-by: Werner Koch <wk@gnupg.org>
2 weeks agodirmngr: Fix LDAP port parsing.
Werner Koch [Mon, 5 Nov 2018 07:59:13 +0000 (08:59 +0100)]
dirmngr: Fix LDAP port parsing.

* dirmngr/misc.c (host_and_port_from_url): Fix bad port parsing and a
segv for a missing slash after the host name.
--

Reportted-by: Tomas Mraz
GnuPG-bug-id: 4230
Signed-off-by: Werner Koch <wk@gnupg.org>
2 weeks agobuild: Update *.m4 from libraries.
NIIBE Yutaka [Fri, 2 Nov 2018 04:06:43 +0000 (13:06 +0900)]
build: Update *.m4 from libraries.

* m4/gpg-error.m4: Update from master.
* m4/ksba.m4: Ditto.
* m4/libassuan.m4: Ditto.
* m4/libgcrypt.m4: Ditto.
* m4/npth.m4: Ditto.
* m4/ntbtls.m4: Ditto.

--

Do it again today.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 weeks agobuild: Update *.m4 from libraries.
NIIBE Yutaka [Tue, 30 Oct 2018 23:20:37 +0000 (08:20 +0900)]
build: Update *.m4 from libraries.

* m4/gpg-error.m4: Update from master.
* m4/ksba.m4: Ditto.
* m4/libassuan.m4: Ditto.
* m4/libgcrypt.m4: Ditto.
* m4/npth.m4: Ditto.
* m4/ntbtls.m4: Ditto.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
3 weeks agobuild: By default build wks-tools on all Unix platforms.
Werner Koch [Fri, 26 Oct 2018 12:54:52 +0000 (14:54 +0200)]
build: By default build wks-tools on all Unix platforms.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 weeks agowkd: Add option --directory to the server.
Werner Koch [Fri, 26 Oct 2018 12:44:32 +0000 (14:44 +0200)]
wkd: Add option --directory to the server.

* tools/gpg-wks-server.c (opts): Add '--directory',
(main): Explain how to set correct permissions.
(command_list_domains): Create an empty policy file and remove the
warning for an empty policy file.
--

Note that a policy file is meanwhile required and thus is is useful to
create it.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 weeks agokbx: Increase size of field for fingerprint.
NIIBE Yutaka [Fri, 26 Oct 2018 03:38:43 +0000 (12:38 +0900)]
kbx: Increase size of field for fingerprint.

* kbx/keybox-search-desc.h (fpr): Increase the size.

--

In the function keydb_search_fpr in g10/keydb.c, it is copied using
MAX_FINGERPRINT_LEN.  So, more size is required.

Fixes-commit: ecbbafb88d920e713439b6b1b8e1b41a6f8d0e38
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
3 weeks agoall: fix more spelling errors
Daniel Kahn Gillmor [Thu, 25 Oct 2018 20:52:58 +0000 (16:52 -0400)]
all: fix more spelling errors

3 weeks agoheaders: fix spelling
Daniel Kahn Gillmor [Thu, 25 Oct 2018 13:46:23 +0000 (09:46 -0400)]
headers: fix spelling

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
3 weeks agospeedo: Sign the windows installer with a timestamp.
Werner Koch [Thu, 25 Oct 2018 16:26:34 +0000 (18:26 +0200)]
speedo: Sign the windows installer with a timestamp.

--

3 weeks agodirmngr: Fix out of scope use of a var in the keyserver LDAP code.
Werner Koch [Thu, 25 Oct 2018 15:21:52 +0000 (17:21 +0200)]
dirmngr: Fix out of scope use of a var in the keyserver LDAP code.

* dirmngr/ks-engine-ldap.c (extract_attributes): Don't use a variabale
out of scope and cleanup the entire pgpKeySize block.
--

GnuPG-bug-id: 4229
Signed-off-by: Werner Koch <wk@gnupg.org>
3 weeks agog10,scd: Improve UIF support.
NIIBE Yutaka [Thu, 25 Oct 2018 07:20:20 +0000 (16:20 +0900)]
g10,scd: Improve UIF support.

* g10/call-agent.c (learn_status_cb): Parse "bt" flag.
* g10/call-agent.h: New member field "bt".
* g10/card-util.c (uif): Limit its access only when it is supported.
* scd/app-openpgp.c (do_setattr): Allow access to UIF objects only
when there is a button.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
3 weeks agoall: fix spelling and typos
Daniel Kahn Gillmor [Wed, 24 Oct 2018 19:56:18 +0000 (15:56 -0400)]
all: fix spelling and typos

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
3 weeks agodoc: fix spelling mistakes
Daniel Kahn Gillmor [Wed, 24 Oct 2018 18:39:56 +0000 (14:39 -0400)]
doc: fix spelling mistakes

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
3 weeks agoagent: Fix possible uninitalized use of CTX in simple_pwquery.
Werner Koch [Wed, 24 Oct 2018 18:22:17 +0000 (20:22 +0200)]
agent: Fix possible uninitalized use of CTX in simple_pwquery.

* common/simple-pwquery.c (agent_open): Clear CTX even on early error.
--

GnuPG-bug-id: 4223
Signed-off-by: Werner Koch <wk@gnupg.org>
3 weeks agoagent: Fix possible release of unitialize var in a genkey error case.
Werner Koch [Wed, 24 Oct 2018 18:16:26 +0000 (20:16 +0200)]
agent: Fix possible release of unitialize var in a genkey error case.

* agent/command.c (cmd_genkey): Initialize 'value'.
--

GnuPG-bug-id: 4222
Signed-off-by: Werner Koch <wk@gnupg.org>
3 weeks agossh: Fix possible infinite loop in case of an read error.
Werner Koch [Wed, 24 Oct 2018 18:11:33 +0000 (20:11 +0200)]
ssh: Fix possible infinite loop in case of an read error.

* agent/command-ssh.c (ssh_handler_add_identity): Handle other errors
than EOF.
--

GnuPG-bug-id: 4221
Signed-off-by: Werner Koch <wk@gnupg.org>
3 weeks agotools: Fix FILE memory leak in gpg-connect-agent.
Werner Koch [Wed, 24 Oct 2018 18:04:52 +0000 (20:04 +0200)]
tools: Fix FILE memory leak in gpg-connect-agent.

* tools/gpg-connect-agent.c (do_open): dup the fileno and close the
stream.

GnuPG-bug-id: 4220
Signed-off-by: Werner Koch <wk@gnupg.org>
3 weeks agosm: Use the correct string in an error message.
Werner Koch [Wed, 24 Oct 2018 17:55:19 +0000 (19:55 +0200)]
sm: Use the correct string in an error message.

* sm/gpgsm.c (main): Fix error message.
--

GnuPG-bug-id: 4219

3 weeks agogpg: Unfinished support for v5 signatures.
Werner Koch [Wed, 24 Oct 2018 14:18:27 +0000 (16:18 +0200)]
gpg: Unfinished support for v5 signatures.

* g10/parse-packet.c (parse_signature): Allow for v5 signatures.
* g10/sig-check.c (check_signature_end_simple): Support the 64bit v5
byte count.
* g10/sign.c (hash_sigversion_to_magic): Ditto.
(write_signature_packets): Request v5 sig for v5 keys.  Remove useless
condition.
(make_keysig_packet): Request v5 sig for v5 keys.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 weeks agoindent: Modernize g10/sign.c
Werner Koch [Wed, 24 Oct 2018 14:00:20 +0000 (16:00 +0200)]
indent: Modernize g10/sign.c

--

3 weeks agodirmngr: Prepare for updated WKD specs with ?l= param
Werner Koch [Mon, 22 Oct 2018 18:13:08 +0000 (20:13 +0200)]
dirmngr: Prepare for updated WKD specs with ?l= param

* dirmngr/server.c (proc_wkd_get): Tack the raw local address to the
request.
--

We append the raw non-canonicalized local address part to the hash.
Servers who serve the requests from static files will ignore the
parameters and a test with posteo shows that also services using a
database ignore the parameter.  The general idea is that service
providers may use their own canonicalization rules.  The problem is
that we currently filter the returned key for the full mail address
and thus we will never see a key if the service did a different
canonicalization than we.  So consider this to be an experiment.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 weeks agoagent: Fix build regression for Windows.
Werner Koch [Mon, 22 Oct 2018 15:24:58 +0000 (17:24 +0200)]
agent: Fix build regression for Windows.

* agent/command-ssh.c (get_client_info): Turn client_uid into an int.
Fix setting of it in case of a failed getsocketopt.
* agent/command.c (start_command_handler): Fix setting of the pid and
uid for Windows.
--

Fixes-commit: 28aa6890588cc108639951bb4bef03ac17743046
which obviously was only added to master.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 weeks agodirmngr: In verbose mode print the OCSP responder id.
Werner Koch [Mon, 22 Oct 2018 12:23:11 +0000 (14:23 +0200)]
dirmngr: In verbose mode print the OCSP responder id.

* dirmngr/ocsp.c (ocsp_isvalid): Print the responder id.

Signed-off-by: Werner Koch <wk@gnupg.org>
5 weeks agotools: Replace duplicated code in mime-maker.
Werner Koch [Mon, 15 Oct 2018 09:32:19 +0000 (11:32 +0200)]
tools: Replace duplicated code in mime-maker.

* tools/rfc822parse.c (HEADER_NAME_CHARS): New.  Taken from
mime-maker.c.
(rfc822_valid_header_name_p): New.  Based on code from mime-maker.c.
(rfc822_capitalize_header_name): New.  Copied from mime-maker.c.
(capitalize_header_name): Remove.  Replace calls by new func.
(my_toupper, my_strcasecmp): New.
* tools/mime-maker.c: Include rfc822parse.h.
(HEADER_NAME_CHARS, capitalize_header_name): Remove.
(add_header): Replace check and capitalization by new functions.
--

This is a straightforward change with two minor chnages:

- In rfc822parse.c the capitalization handles MIME-Version special.
- The check in mime-maker bow detects a zero-length name as invalid.

my_toupper and my_strcasecmp are introduced to allow standalone use
of that file.

Signed-off-by: Werner Koch <wk@gnupg.org>
5 weeks agoscd: Fix signing authentication status.
NIIBE Yutaka [Mon, 15 Oct 2018 02:10:15 +0000 (11:10 +0900)]
scd: Fix signing authentication status.

* scd/app-openpgp.c (do_sign): Clear DID_CHV1 after signing.

--

We have a corner case: In "not forced" situation and authenticated,
and it is changed to "forced", card implementaiton can actually accept
signing, but GnuPG requires authentication, because it is "forced".

GnuPG-bug-id: 4177
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
5 weeks agoagent: Fix message for ACK button.
NIIBE Yutaka [Fri, 12 Oct 2018 02:36:59 +0000 (11:36 +0900)]
agent: Fix message for ACK button.

* agent/divert-scd.c (getpin_cb): Display correct message.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
5 weeks agoscd: Support "acknowledge button" feature.
NIIBE Yutaka [Thu, 11 Oct 2018 06:41:49 +0000 (15:41 +0900)]
scd: Support "acknowledge button" feature.

* scd/apdu.c (set_prompt_cb): New member function.
(set_prompt_cb_ccid_reader): New function.
(open_ccid_reader): Initialize with set_prompt_cb_ccid_reader.
(apdu_set_prompt_cb): New.
* scd/app.c (lock_app, unlock_app): Add call to apdu_set_prompt_cb.
* ccid-driver.c (ccid_set_prompt_cb): New.
(bulk_in): Call ->prompt_cb when timer extension.
* scd/command.c (popup_prompt): New.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
5 weeks agoagent: Support --ack option for POPUPPINPADPROMPT.
NIIBE Yutaka [Thu, 11 Oct 2018 04:37:24 +0000 (13:37 +0900)]
agent: Support --ack option for POPUPPINPADPROMPT.

* agent/divert-scd.c (getpin_cb): Support --ack option.

--

We are now introducing "acknowledge button" feature to scdaemon,
so that we can support OpenPGPcard User Interaction Flag.

We will (re)use the mechanism of POPUPPINPADPROMPT for this.  Perhaps,
we will change the name of POPUPPINPADPROMPT, since it will be no
longer for PINPAD only.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
5 weeks agogpg: Don't take the a TOFU trust model from the trustdb,
Werner Koch [Wed, 10 Oct 2018 09:46:16 +0000 (11:46 +0200)]
gpg: Don't take the a TOFU trust model from the trustdb,

* g10/tdbio.c (tdbio_update_version_record): Never store a TOFU model.
(create_version_record): Don't init as TOFU.
(tdbio_db_matches_options): Don't indicate a change in case TOFU is
stored in an old trustdb file.
--

This change allows to switch between a tofu and pgp or tofu+pgp trust
model without an auto rebuild of the trustdb.  This also requires that
the tofu trust model is requested on the command line.  If TOFU will
ever be the default we need to tweak the model detection via TM_AUTO
by also looking into the TOFU data base,

GnuPG-bug-id: 4134

6 weeks agogpg: Fix extra check for sign usage of a data signature.
Werner Koch [Mon, 8 Oct 2018 14:14:17 +0000 (16:14 +0200)]
gpg: Fix extra check for sign usage of a data signature.

* g10/sig-check.c (check_signature_end_simple):
--

Obviously we should not ignore a back signature here.

Fixes-commit: 214b0077264e35c079e854a8b6374704aea45cd5
GnuPG-bug-id: 4014
Signed-off-by: Werner Koch <wk@gnupg.org>
6 weeks agogpg: Make --skip-hidden-recipients work again.
Werner Koch [Mon, 8 Oct 2018 13:38:37 +0000 (15:38 +0200)]
gpg: Make --skip-hidden-recipients work again.

* g10/pubkey-enc.c (get_session_key): Take care of
opt.skip_hidden_recipients.
--
This was lost due to
Fixes-commit: ce2f71760155b71a71418fe145a557c99bd52290
GnuPG-bug-id: 4169

Signed-off-by: Werner Koch <wk@gnupg.org>
6 weeks agogpg: Add new card vendor
Werner Koch [Thu, 4 Oct 2018 07:57:03 +0000 (09:57 +0200)]
gpg: Add new card vendor

--

6 weeks agogpg: New options import-drop-uids and export-drop-uids.
Werner Koch [Tue, 2 Oct 2018 09:02:08 +0000 (11:02 +0200)]
gpg: New options import-drop-uids and export-drop-uids.

* g10/options.h (IMPORT_DROP_UIDS): New.
(EXPORT_DROP_UIDS): New.
* g10/import.c (parse_import_options): Add option "import-drop-uids".
(import_one): Don't bail out with that options and no uids found.
Also remove all uids.
(remove_all_uids): New.
* g10/export.c (parse_export_options): Add option "export-drop-uids".
(do_export_one_keyblock): Implement option.
--

These options are required for experiments with changes to the
keyserver infrastructure.

Signed-off-by: Werner Koch <wk@gnupg.org>
6 weeks agocommon: Fix gnupg_reopen_std.
NIIBE Yutaka [Tue, 2 Oct 2018 05:22:24 +0000 (14:22 +0900)]
common: Fix gnupg_reopen_std.

* common/sysutils.c (gnupg_reopen_std): Use fcntl instead of fstat.

--

When gpg was invoked by a Perl web application on FreeBSD, fstat in
gnupg_reopen_std failed with EBADF.  Using fcntl, which is considered
lighter than fstat, it works fine.  Since uur purpose is to check if
file descriptor is valid or not, lighter operation is better.

Reported-by: Marcin Gryszkalis <mg@fork.pl>
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
7 weeks agog10,scd: Support UIF changing command.
NIIBE Yutaka [Thu, 27 Sep 2018 07:45:27 +0000 (16:45 +0900)]
g10,scd: Support UIF changing command.

* g10/card-util.c (uif, cmdUIF): New.
(card_edit): Add call to uif by cmdUIF.
* scd/app-openpgp.c (do_getattr): Support UIF-1, UIF-2, and UIF-3.
(do_setattr): Likewise.
(do_learn_status): Learn UIF-1, UIF-2, and UIF-3.

--

GnuPG-bug-id: 4158
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agog10: Fix memory leak for --card-status.
NIIBE Yutaka [Tue, 18 Sep 2018 00:34:00 +0000 (09:34 +0900)]
g10: Fix memory leak for --card-status.

* g10/card-util.c (card_status): Release memory of serial number.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agog10: Fix another memory leak.
NIIBE Yutaka [Thu, 13 Sep 2018 23:11:45 +0000 (08:11 +0900)]
g10: Fix another memory leak.

* g10/skclist.c (enum_secret_keys): Use SK_LIST instead of pubkey_t.

--

The use of pubkey_t was wrong.  The use is just a list of keys, not
with keyblock.  With SK_LIST, release_sk_list releases memory by
free_public_key.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agog10: Fix memory leak (more).
NIIBE Yutaka [Thu, 13 Sep 2018 23:02:16 +0000 (08:02 +0900)]
g10: Fix memory leak (more).

* g10/skclist.c (enum_secret_keys): Free SERIALNO on update.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agog10: Fix memory leak in enum_secret_keys.
NIIBE Yutaka [Thu, 13 Sep 2018 22:55:20 +0000 (07:55 +0900)]
g10: Fix memory leak in enum_secret_keys.

* g10/skclist.c (enum_secret_keys): Don't forget to call
free_public_key in the error return paths.

--

Reported-by: Philippe Antoine
GnuPG-bug-id: 4140
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agoRevert "dirmngr: hkp: Avoid potential race condition when some hosts die."
NIIBE Yutaka [Tue, 11 Sep 2018 05:04:37 +0000 (14:04 +0900)]
Revert "dirmngr: hkp: Avoid potential race condition when some hosts die."

This reverts commit 04b56eff118ec34432c368b87e724bce1ac683f9.

--

Now the access to hosttable is serialized correctly.

2 months agodirmngr: Serialize access to hosttable.
NIIBE Yutaka [Tue, 11 Sep 2018 04:54:49 +0000 (13:54 +0900)]
dirmngr: Serialize access to hosttable.

* dirmngr/dirmngr.h (ks_hkp_init): New.
* dirmngr/dirmngr.c (main): Call ks_hkp_init.
* dirmngr/ks-engine-hkp.c (ks_hkp_init): New.
(ks_hkp_mark_host): Serialize access to hosttable.
(ks_hkp_print_hosttable, make_host_part): Likewise.
(ks_hkp_housekeeping, ks_hkp_reload): Likewise.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agocommon: Use iobuf_get_noeof to avoid undefined behaviors.
NIIBE Yutaka [Mon, 10 Sep 2018 04:44:47 +0000 (13:44 +0900)]
common: Use iobuf_get_noeof to avoid undefined behaviors.

* common/iobuf.c (block_filter): Use iobuf_get_noeof.

--

When singed integer has negative value, left shift computation is
undefined in C.

GnuPG-bug-id: 4093
Reported-by: Philippe Antoine
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agoagent: Fix error code check from npth_mutex_init.
NIIBE Yutaka [Mon, 10 Sep 2018 00:16:50 +0000 (09:16 +0900)]
agent: Fix error code check from npth_mutex_init.

* agent/call-pinentry.c (initialize_module_call_pinentry): It's an
error when npth_mutex_init returns non-zero.

--

Actually, initialize_module_call_pinentry is only called once from
main.  So, this bug had no harm and having the static variable
INITIALIZED is not needed.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agodirmngr: Emit SOURCE status also on NO_DATA.
Werner Koch [Fri, 7 Sep 2018 09:48:18 +0000 (11:48 +0200)]
dirmngr: Emit SOURCE status also on NO_DATA.

* dirmngr/ks-engine-hkp.c (ks_hkp_search): Send SOURCE status also on
NO DATA error.
(ks_hkp_get): Ditto.
* g10/call-dirmngr.c (gpg_dirmngr_ks_search): Print "data source" info
also on error.
(gpg_dirmngr_ks_get): Ditto.
--

If a keyserver does not return any data it can be useful to know which
keyserver out of the pool answered.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 months agodirmngr: hkp: Avoid potential race condition when some hosts die.
Daniel Kahn Gillmor [Sat, 29 Oct 2016 05:25:05 +0000 (01:25 -0400)]
dirmngr: hkp: Avoid potential race condition when some hosts die.

* dirmngr/ks-engine-hkp.c (select_random_host): Use atomic pass
through the host table instead of risking out-of-bounds write.

--

Multiple threads may write to hosttable[x]->dead while
select_random_host() is running.  For example, a housekeeping thread
might clear the ->dead bit on some entries, or another connection to
dirmngr might manually mark a host as alive.

If one or more hosts are resurrected between the two loops over a
given table in select_random_host(), then the allocation of tbl might
not be large enough, resulting in a write past the end of tbl on the
second loop.

This change collapses the two loops into a single loop to avoid this
discrepancy: each host's "dead" bit is now only checked once.

As Werner points out, this isn't currently strictly necessary, since
npth will not switch threads unless a blocking system call is made,
and no blocking system call is made in these two loops.

However, in a subsequent change in this series, we will call a
function in this loop, and that function may sometimes write(2), or
call other functions, which may themselves block.  Keeping this as a
single-pass loop avoids the need to keep track of what might block and
what might not.

GnuPG-bug-id: 2836
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2 months agog10: Fix memory leak.
NIIBE Yutaka [Fri, 7 Sep 2018 04:01:52 +0000 (13:01 +0900)]
g10: Fix memory leak.

* g10/import.c (read_block): Call free_packet to skip the packet.

--

Reported-by: Philippe Antoine
GnuPG-bug-id: 3916
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agogpgscm: Suppress warnings for GCC > 6.
NIIBE Yutaka [Thu, 6 Sep 2018 05:53:35 +0000 (14:53 +0900)]
gpgscm: Suppress warnings for GCC > 6.

* tests/gpgscm/scheme.c (CASE): Use unused attribute for GCC > 6.
(FALLTHROUGH): New for fallthrough.
(Eval_Cycle): Use FALLTHROUGH.  Remove not-needed comment of
fallthrough.

--

Since GCC combines C preprocessor macro expansion, the fallthrough
comment doesn't work well to suppress warnings for
-Wimplicit-fallthrough, near the macro CASE.  To handle this
problem, we use GCC's extension of unused label and fallthrough
attributes.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agoFix use of strncpy, which is actually good to use memcpy.
NIIBE Yutaka [Thu, 6 Sep 2018 02:41:13 +0000 (11:41 +0900)]
Fix use of strncpy, which is actually good to use memcpy.

* common/ssh-utils.c (get_fingerprint): Use memcpy.
* g10/build-packet.c (string_to_notation): Use memcpy.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agoartwork: State license of the logo
Werner Koch [Thu, 30 Aug 2018 08:33:28 +0000 (10:33 +0200)]
artwork: State license of the logo

--

2 months agogpg: Explain error message in key generation with --batch
Werner Koch [Wed, 29 Aug 2018 13:14:29 +0000 (15:14 +0200)]
gpg: Explain error message in key generation with --batch

* g10/keygen.c (generate_keypair): Show more info.
--

GnuPG-bug-id: 3912
Signed-off-by: Werner Koch <wk@gnupg.org>
2 months agodoc: Minor additions to the gpg man page
Werner Koch [Wed, 29 Aug 2018 13:04:44 +0000 (15:04 +0200)]
doc: Minor additions to the gpg man page

--

Includes a fix for
GnuPG-bug-id: 3906

Signed-off-by: Werner Koch <wk@gnupg.org>
2 months agogpg: Remove unused function get_pubkeys.
Werner Koch [Wed, 29 Aug 2018 09:53:59 +0000 (11:53 +0200)]
gpg: Remove unused function get_pubkeys.

* g10/getkey.c (get_pubkeys): Remove.
(pubkey_free): Remove and use code directly ...
(pubkeys_free): ... here.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 months agodoc: Show how to list envvars send to gpg-agent.
Werner Koch [Wed, 29 Aug 2018 07:53:06 +0000 (09:53 +0200)]
doc: Show how to list envvars send to gpg-agent.

--

GnuPG-bug: 3353
Signed-off-by: Werner Koch <wk@gnupg.org>
2 months agogpg: New option --known-notation.
Werner Koch [Wed, 29 Aug 2018 07:36:09 +0000 (09:36 +0200)]
gpg: New option --known-notation.

* g10/gpg.c (oKnownNotation): New const.
(opts): Add option --known-notation.
(main): Set option.
* g10/parse-packet.c (known_notations_list): New local var.
(register_known_notation): New.
(can_handle_critical_notation): Rewrite to handle the new feature.
Also print the name of unknown notations in verbose mode.
--

GnuPG-bug-id: 4060
Signed-off-by: Werner Koch <wk@gnupg.org>
2 months agogpg: Refresh expired keys originating from the WKD.
Werner Koch [Tue, 28 Aug 2018 13:22:35 +0000 (15:22 +0200)]
gpg: Refresh expired keys originating from the WKD.

* g10/getkey.c (getkey_ctx_s): New field found_via_akl.
(get_pubkey_byname): Set it.
(only_expired_enc_subkeys): New.
(get_best_pubkey_byname): Add support to refresh expired keys from the
WKD.
--

A little drawback of that code is that if the WKD has no update for an
expired key each access of the key will trigger a WKD lookup (unless
cached by the dirmngr).  To avoid this we need to record the last time
we have checked for an update but that would in turn require that we
update the keyring for each check.  We defer this until we have a
better key database which allows for fast updates of meta data.

Testing the code is currently a bit cumbersome because it requires to
update a key in the WKD several times.  Eventually we we need a
network emulation layer to provide sample data for the regression
tests.

GnuPG-bug-id: 2917
Signed-off-by: Werner Koch <wk@gnupg.org>
2 months agogpg: Remove unused arg from a function.
Werner Koch [Tue, 28 Aug 2018 13:11:10 +0000 (15:11 +0200)]
gpg: Remove unused arg from a function.

* g10/getkey.c (get_best_pubkey_byname): Remove unused arg 'no_akl'.
Change both callers.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 months agogpg: Prepare for longer card fingerprints.
Werner Koch [Mon, 27 Aug 2018 14:57:04 +0000 (16:57 +0200)]
gpg: Prepare for longer card fingerprints.

* g10/call-agent.h (agent_card_info_s): Rename the "*valid" fields to
"*len".
* g10/call-agent.c (unhexify_fpr): Change to take a FPRLEN and to
return the actual length.
(agent_release_card_info): Adjust for these changes.
* g10/card-util.c (print_sha1_fpr): Rename to print_shax_fpr and add
arg FPRLEN.  Change all callers to pass the length.
(print_sha1_fpr_colon): Rename to print_shax_fpr_colon and add arg
FPRLEN.  Change all callers to pass the length.
(fpr_is_zero): Add arg FPRLEN.
(fpr_is_ff): Ditto.
(show_card_key_info): Use the new functions.
* g10/skclist.c (enum_secret_keys): Use MAX_FINGERPRINT_LEN.
--

This is not needed right now but we should get rid of all hard coded
fingerprint lengths.  Thus this change.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 months agog10: Fix enum_secret_keys for card keys.
NIIBE Yutaka [Tue, 12 Jun 2018 07:20:21 +0000 (16:20 +0900)]
g10: Fix enum_secret_keys for card keys.

* g10/skclist.c (enum_secret_keys): Since "KEY-FPR" returns
fingerprint in binary, change it to hex string.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agog10: Prefer to available card keys for decryption.
NIIBE Yutaka [Tue, 12 Jun 2018 01:42:24 +0000 (10:42 +0900)]
g10: Prefer to available card keys for decryption.

* g10/skclist.c (enum_secret_keys): Add logic to prefer
decryption keys on cards.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agog10: Move enum_secret_keys to skclist.c.
NIIBE Yutaka [Tue, 12 Jun 2018 01:36:59 +0000 (10:36 +0900)]
g10: Move enum_secret_keys to skclist.c.

* g10/getkey.c (enum_secret_keys): Move to...
* g10/skclist.c (enum_secret_keys): ... here.

--

The function enum_secret_keys is not used by gpgv.c, but it is in
getkey.c.  Extending enum_secret_keys will require change of gpgv.c,
so moving the function to the file for gpg is better.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agog10: Fix comment of enum_secret_keys.
NIIBE Yutaka [Mon, 11 Jun 2018 06:02:57 +0000 (15:02 +0900)]
g10: Fix comment of enum_secret_keys.

* g10/getkey.c (enum_secret_keys): Fix comment for usage of
enum_secret_keys, following the previous change.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agog10: Enumerated keys for decryption should be unique.
NIIBE Yutaka [Mon, 11 Jun 2018 02:48:14 +0000 (11:48 +0900)]
g10: Enumerated keys for decryption should be unique.

* g10/getkey.c (enum_secret_keys): Collecting keys in the context,
check duplicate to make sure returning only unique keys.
* g10/pubkey-enc.c (get_session_key): Now, it's the responsibility of
enum_secret_keys to free keys.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 months agog10: Change decryption key selection for public key encryption.
NIIBE Yutaka [Mon, 27 Aug 2018 04:12:31 +0000 (13:12 +0900)]
g10: Change decryption key selection for public key encryption.

* g10/mainproc.c (struct mainproc_context): It's now pubkey_enc_list.
(do_proc_packets): Remove the first arg CTRL.  Fix call of
proc_pubkey_enc.
(release_list): Handle pubkey_enc_list.
(proc_pubkey_enc): Remove the first arg CTRL.  Simply put the packet
to pubkey_enc_list.
(print_pkenc_list): Remove the last arg FAILED.
(proc_encrypted): Only call print_pkenc_list once.
Handle DEK here.
(proc_packets, proc_signature_packets, proc_signature_packets_by_fd)
(proc_encryption_packets): Fix call of do_proc_packets.
* g10/packet.h (struct pubkey_enc_list): Define.
* g10/pubkey-enc.c (get_it): Change the second argument K.
(get_session_key): Select session key by LIST, using enum_secret_keys.
* g10/gpgv.c (get_session_key): Change the second argument K.
* g10/test-stubs.c (get_session_key): Likewise.

--

Collect all PKT_PUBKEY_ENC packets, and then, process the
PKT_ENCRYPTED* packet.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
3 months agog10: Fix undefined behavior when EOF in parsing packet for S2K.
NIIBE Yutaka [Fri, 10 Aug 2018 06:29:06 +0000 (15:29 +0900)]
g10: Fix undefined behavior when EOF in parsing packet for S2K.

* g10/parse-packet.c (parse_symkeyenc): Use iobuf_get_noeof.
(parse_key): Likewise.

--

When EOF comes at parsing s2k.count, it is possible the value will
be (unsigned long)-1.  Then, the result of S2K_DECODE_COUNT will be
undefined.  This patch fixes undefined behavior.

Reported-by: Philippe Antoine
GnuPG-bug-id: 4093
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
3 months agogpg: Set a limit for a WKD import of 256 KiB.
Werner Koch [Fri, 27 Jul 2018 15:35:00 +0000 (17:35 +0200)]
gpg: Set a limit for a WKD import of 256 KiB.

* g10/call-dirmngr.c (MAX_WKD_RESULT_LENGTH): New.
(gpg_dirmngr_wkd_get): Use it.
--

WKD should return only a single key with just one UID.  For key
rollover 2 keys may be send.  A total of 256 KiB seems to be a
generous limit here.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 months agodirmngr: Validate SRV records in WKD queries.
Werner Koch [Fri, 27 Jul 2018 10:23:38 +0000 (12:23 +0200)]
dirmngr: Validate SRV records in WKD queries.

* dirmngr/server.c (proc_wkd_get): Check the returned SRV record names
to mitigate rogue DNS servers.
--

I am not sure wether this really is very useful because the security
relies on a trustworthy DNS system anyway.  However, that check is
easy enough to do.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 months agocommon: New function to validate domain names.
Werner Koch [Fri, 27 Jul 2018 09:56:06 +0000 (11:56 +0200)]
common: New function to validate domain names.

* common/mbox-util.c (is_valid_domain_name): New.
* common/t-mbox-util.c (run_dns_test): New test.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 months agoscd: Add support for Trustica Cryptoucan.
Jiří Keresteš [Tue, 17 Jul 2018 15:11:42 +0000 (17:11 +0200)]
scd: Add support for Trustica Cryptoucan.

3 months agoRegister DCO for Jiri Kerestes.
NIIBE Yutaka [Thu, 26 Jul 2018 02:44:10 +0000 (11:44 +0900)]
Register DCO for Jiri Kerestes.

--

3 months agodirmngr: Print a WARNING status for DNS config problems.
Werner Koch [Wed, 25 Jul 2018 12:35:04 +0000 (14:35 +0200)]
dirmngr: Print a WARNING status for DNS config problems.

* dirmngr/dirmngr-status.h: New.
* dirmngr/dirmngr.h: Include dirmngr-status.h and move some prototypes
to that file.
* dirmngr/t-support.c: New.
* dirmngr/Makefile.am (dirmngr_SOURCES): Add dirmngr-status.h.
(t_common_src): Add t-support.c.
* dirmngr/server.c (dirmngr_status_printf): Bypass if CTRL is NULL.
* dirmngr/dns-stuff.c: Include dirmngr-status.h.
(libdns_init): Print WARNING status line.  Change call callers to take
and pass a CTRL argument.
* g10/call-dirmngr.c (ks_status_cb): Print info for new WARNING
status.
--

To test this you can change RESOLV_CONF_NAME in dns-stuff.c and run
gpg --recv-key -v SOMETHING.

Signed-off-by: Werner Koch <wk@gnupg.org>
3 months agogpg: Use 128 MiB as default AEAD chunk size.
Werner Koch [Tue, 24 Jul 2018 07:50:02 +0000 (09:50 +0200)]
gpg: Use 128 MiB as default AEAD chunk size.

* g10/gpg.c (oDebugAllowLargeChunks): New.
(opts): New option --debug-allow-large-chunks.
(main): Implement that option.
--

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