Commit Graph

5210 Commits

Author SHA1 Message Date
Werner Koch b4bc1c8b10
http: Add flag to force use of TOR (part 1)
* common/http.h (HTTP_FLAG_FORCE_TOR): New.
* common/http.c (http_raw_connect, send_request): Detect flag and
return an error for now.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-18 16:21:30 +02:00
NIIBE Yutaka f986b23e13 po: Update Japanese translation. 2015-09-17 17:08:27 +09:00
NIIBE Yutaka 6510df3a7c scd: Fix ccid-driver timeout for OpenPGPcard v2.1.
* scd/ccid-driver.c (CCID_CMD_TIMEOUT): New.
(ccid_transceive_apdu_level, ccid_transceive): Use.

--

It is reported that key generation causes timeout with OpenPGPcard
v2.1.  Ideally, timeout value could be determined at run-time by
examining card's ATR.  Compile-time fixed value is OK for internal
CCID driver.
2015-09-17 11:21:44 +09:00
Werner Koch 93d257c819
agent: New option --pinentry-invisible-char.
* agent/gpg-agent.c (oPinentryInvisibleChar): New.
(opts): Add option.
(parse_rereadable_options): Set option.
* agent/agent.h (opt): Add field pinentry_invisible_char.
* agent/call-pinentry.c (start_pinentry): Pass option to pinentry.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-16 21:24:14 +02:00
Werner Koch 9e65bbd255
g13: Move some code to a separate module.
* g13/g13-common.c, g13/g13-common.h: New.
* g13/Makefile.am (g13_SOURCES): Add new files.
* g13/g13.c (g13_errors_seen): Move to g13-common.c.
(cmdline_conttype): New.
(main): Use g13_init_signals and g13_install_emergency_cleanup.
(emergency_cleanup, g13_exit): Move to g13-common.c.
* g13/g13.h: Move OPT and some other code to g13-common.h.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-16 19:03:09 +02:00
Werner Koch 8eb3a1797a
gpg: Fix skip function dummy parameter.
* g10/trustdb.c (search_skipfnc): Fix dummy argument
--

This is required due to the prototype change in
commit 9acbeac236

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-16 19:02:35 +02:00
Werner Koch f71ed902de
gpg: Change last commit to avoid extra translations.
* g10/keyedit.c (keyedit_menu): Do not print usage hints in expert
mode.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-16 18:55:27 +02:00
Neal H. Walfield 172af881a1 g10: Improve error message.
* g10/keyedit.c (keyedit_menu): When complaining that a user ID or key
must be selected, indicate what command to use to do this.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:31 +02:00
Neal H. Walfield 6845737736 g10: Be more careful when merging self-signed data.
* g10/getkey.c (merge_selfsigs_main): Stop looking for self-signed
data belonging to the public key when we encounter an attribute packet
or a subkey packet, not just a user id packet.  When looking for
self-signed data belonging to a user id packet, stop when we see a
user attribute packet.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:30 +02:00
Neal H. Walfield c31e089129 g10: Simplify some complicated boolean expressions.
* g10/getkey.c (finish_lookup): Simplify logic.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:29 +02:00
Neal H. Walfield 77c2ad4a81 g10: Also mark revoked and expired keys as unusable.
* g10/getkey.c (skip_unusable): Also mark the key as unusable if it
has been revoked or has expired.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:29 +02:00
Neal H. Walfield 1b601de06a g10: Release resources when returning an error in get_seckey.
* g10/getkey.c (get_seckey): If the key doesn't have a secret key,
release *PK.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:28 +02:00
Neal H. Walfield cab581c486 g10: Improve documentation and comments for getkey.c.
* g10/getkey.c: Improve documentation and comments for most
functions.  Move documentation for public functions from here...
* g10/keydb.h: ... to here.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:28 +02:00
Neal H. Walfield 7333e704ef g10: Remove unused function have_any_secret_key.
* g10/getkey.c (have_any_secret_key): Remove function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:27 +02:00
Neal H. Walfield 5e233e12f5 g10: Bring cache semantics closer to non-cache semantics.
* g10/getkey.c (get_pubkey_fast): When reading from the cache, only
consider primary keys.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:26 +02:00
Neal H. Walfield 3940f10af7 g10: Break out of the loop earlier.
* g10/getkey.c (have_secret_key_with_kid): Once we find the relevent
key or subkey, stop searching.

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

Only a single key or subkey will ever be selected per keyblock.
2015-09-16 15:15:26 +02:00
Neal H. Walfield 50affffe93 g10: Don't skip legacy keys if the search mode is KEYDB_SEARCH_MODE_NEXT
* g10/getkey.c (lookup): Also don't skip legacy keys if the search
mode is KEYDB_SEARCH_MODE_NEXT.

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

We currently don't skip keys if the search mode is
KEYDB_SEARCH_MODE_FIRST.  Since we change KEYDB_SEARCH_MODE_FIRST to
KEYDB_SEARCH_MODE_NEXT (to avoid a reset), it only makes sense to have
the same semantics for KEYDB_SEARCH_MODE_NEXT.
2015-09-16 15:15:25 +02:00
Neal H. Walfield efbaa8f891 g10: Remove unused function get_seckeyblock_byfprint.
* g10/keydb.h (get_seckeyblock_byfprint): Remove prototype.
* g10/getkey.c (get_seckeyblock_byfprint): Remove function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:25 +02:00
Neal H. Walfield e2b300801e g10: Remove unused function get_seckey_byfprint.
* g10/keydb.h (get_seckey_byfprint): Remove prototype.
* g10/getkey.c (get_seckey_byfprint): Remove function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:24 +02:00
Neal H. Walfield 80dbf8006f g10: Simplify get_seckey_byname: it was never called with NAME not NULL.
* g10/keydb.h (get_seckey_byname): Rename from this...
(get_seckey_default): ... to this.  Drop the parameter name.  Update
users.
* g10/getkey.c (get_seckey_byname): Rename from this...
(get_seckey_default): ... to this.  Drop the parameter name.  Drop the
code which assumed that NAME is not NULL.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:23 +02:00
Neal H. Walfield dc69804ab0 g10: Eliminate the redundant function get_keyblock_byfprint.
* g10/keydb.h (get_keyblock_byfprint): Remove prototype.  Replace use
of this function with get_pubkey_byfprint.
* g10/getkey.c (get_pubkey_byname): Remove function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:23 +02:00
Neal H. Walfield 911fcca36d g10: Simplify semantics of get_pubkey_byname.
* g10/getkey.c (get_pubkey_byname): If R_KEYBLOCK is not NULL, return
the keyblock in R_KEYBLOCK independent of whether PK is set or not.

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

Currently, no caller invokes get_pubkey_byname with PK==NULL and
R_KEYBLOCK != NULL.  Thus, this change does not change any behavior.
2015-09-16 15:15:22 +02:00
Neal H. Walfield b4672e4d48 g10: Eliminate the redundant function get_pubkey_byname.
* g10/getkey.c (get_pubkey_byname): Remove function.
(lookup): Replace use of get_pubkey_byname by get_pubkey_byfprint.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:22 +02:00
Neal H. Walfield 65e58ae674 g10: Eliminate the redundant function get_pubkey_end.
* g10/keydb.h (get_pubkey_end): Remove declaration.  Replace use of
function with getkey_end.
* g10/getkey.c (get_pubkey_byname): Remove function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:21 +02:00
Neal H. Walfield be6743b2e1 g10: Eliminate the redundant function get_pubkey_next.
* g10/keydb.h (get_pubkey_next): Remove prototype.
* g10/getkey.c (get_pubkey_next): Remove function.
* g10/keylist.c (locate_one): Use getkey_next instead of
get_pubkey_next.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:20 +02:00
Neal H. Walfield 9acbeac236 kbx: Change skipfnc's prototype so that we can provide all information.
* kbx/keybox-search-desc.h (struct keydb_search_desc.skipfnc): Change
third parameter to be the index of the user id packet in the keyblock
rather than the packet itself.  Update users.

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

The keybox code doesn't work directly with keyblocks.  As such, the
matched user packet is not readily available to pass to
DESC[n].SKIPFNC.  But, we do know the index of the user id packet that
matched.  Thus, pass that instead.  If the skip function needs the
user id packet, it can use the key id to look up the key block and
find the appropriate packet.
2015-09-16 15:15:20 +02:00
Neal H. Walfield 83e17ab1b4 g10: Remove unused prototype (get_pubkey_byfpr).
* g10/keydb.h (get_pubkey_byfpr): Remove unused prototype.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:19 +02:00
Neal H. Walfield b06f96ba4f g10: Remove unused function (get_pubkey_bynames).
* g10/keydb.h (get_pubkey_bynames): Remove prototype.
* g10/getkey.c (get_pubkey_bynames): Remove function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:19 +02:00
Neal H. Walfield d47e84946e g10: Simplify code. Turn struct getkey_ctx_s.found_key into an argument
* g10/getkey.c (struct getkey_ctx_s): Remove field found_key.
(lookup): Add argument ret_found_key.  If not NULL, set it to the
found key.  Update callers.
(pk_from_block): Add argument found_key.  Use it instead of
CTX->FOUND_KEY.  Update callers.
(finish_lookup): Return a KBNODE (the found key) instead of an int.
Don't set CTX->FOUND_KEY.  Return the found key instead.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:18 +02:00
Neal H. Walfield c110e186e0 g10: Remove unused field struct getkey_ctx_s.kbpos.
* g10/getkey.c (struct getkey_ctx_s): Remove field kbpos.
(getkey_end): Don't clear CTX->KBPOS.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:17 +02:00
Neal H. Walfield 3798f73c07 g10: Simplify code: remove field struct getkey_ctx_s.keyblock.
* g10/getkey.c (struct getkey_ctx_s): Remove field keyblock.
(finish_lookup): Add parameter keyblock.  Update caller to pass this.
(lookup): Add new local variable keyblock.  Use this instead of
ctx->keyblock for referencing the keyblock.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-16 15:15:17 +02:00
NIIBE Yutaka 7d5999f096 agent: Fix registering SSH Key of Ed25519.
* agent/command-ssh.c (stream_read_string): Add the prefix of 0x40.

--

GnuPG-bug-id: 2096
2015-09-16 10:37:38 +09:00
NIIBE Yutaka faee25e670 po: Update Japanese translation. 2015-09-15 15:12:56 +09:00
Werner Koch e41b6579f7
Post release updates.
--
2015-09-10 21:05:35 +02:00
Werner Koch 311816f6cf
Release 2.1.8. 2015-09-10 18:12:23 +02:00
Werner Koch 7a0c3cc760
tests: Silence the 5gb-packet test.
* tests/openpgp/4gb-packet.test: Send output to /dev/null.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-10 18:12:22 +02:00
Werner Koch e92a8ab021
g10: Fix make distcheck problem.
* g10/test.c: Include string.h.
(prepend_srcdir): New.  Taken from Libgcrypt.
(test_free): New.
* g10/t-keydb.c (do_test): Malloc the filename.
* g10/Makefile.am (AM_CPPFLAGS): Remove -DSOURCE_DIR
(EXTRA_DIST): Add t-keydb-keyring.kbx.
--

Using SOURCE_DIR should in general work but we have seen problems when
doing this in Libgcrypt.  Using the srcdir variable gives us anyway
more flexibility and aligns with the way we do it in tests/openpgp.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-10 18:12:20 +02:00
Werner Koch fbf24cd09a
g10: Improve portability of the new test driver.
* g10/test.c: Include stdio.h and stdlib.h.
(verbose): New.
(print_results): Rename to exit_tests.
(main): Remove atexit and call exit_tests.  Set verbose.
(ASSERT, ABORT): Call exit_tests instead of exit.
--

Calling exit from an exit handler is undefined behaviour.  It works on
Linux but other systems will hit an endless loop.  That is indeed
unfortunate but we can't do anything about it.  Calling _exit() would
be possible but that may lead to other problems.  Thus we change to
call a custom exit function :-(.

Using "make check verbose=1" is supported by tests/openpgp and thus
we add the same mechanism here.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-10 17:43:37 +02:00
Werner Koch cafcd4336a
po: Auto-update
--
2015-09-10 16:22:49 +02:00
Ineiev e086364f33
po: Update Russian translation
--
2015-09-10 16:16:39 +02:00
Werner Koch 19545e3a2d
dirmngr: Allow sending much larger keyblocks.
* dirmngr/server.c (MAX_CERT_LENGTH): Increase to 16k.
(MAX_KEYBLOCK_LENGTH): Increase to 20M.

Signed-off-by: Werner Koch <wk@gnupg.org>
2015-09-09 15:41:25 +02:00
Werner Koch 56bf1061f8
doc: Minor comment fixes.
--
2015-09-09 15:14:35 +02:00
NIIBE Yutaka f10b427d0e scd: Force key attribute change for writekey.
* scd/app-openpgp.c (change_rsa_keyattr): New.
(change_keyattr_from_string): Use change_rsa_keyattr.
(rsa_writekey): Call change_rsa_keyattr when different size.
(ecc_writekey): Try to change key attribute.
2015-09-07 13:49:47 +09:00
NIIBE Yutaka fd689e8542 scd: KEYNO cleanup.
* scd/app-openpgp.c (get_public_key, send_keypair_info, do_readkey)
(change_keyattr, change_keyattr_from_string, ecc_writekey, do_genkey)
(compare_fingerprint, check_against_given_fingerprint): KEYNO starts
from 0.
2015-09-07 13:09:01 +09:00
Neal H. Walfield bd0c902f1d g10: Remove unused field req_algo.
* g10/packet.h (PKT_public_key): Remove unused field req_algo.  Remove
users.
* g10/getkey.c (struct getkey_ctx_s): Remove unused field req_algo.
Remove users.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-02 15:08:58 +02:00
Neal H. Walfield 1f03d4cd94 g10: Use a symbolic constant instead of a literal.
* g10/trustdb.c (KEY_HASH_TABLE_SIZE): Define.
(new_key_hash_table): Use KEY_HASH_TABLE_SIZE instead of a literal.
(release_key_hash_table): Likewise.
(test_key_hash_table): Likewise.
(add_key_hash_table): Likewise.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-02 15:08:57 +02:00
Neal H. Walfield ee7ec1256b g10: Add test for keydb as well as new testing infrastructure.
* g10/Makefile.am (EXTRA_DIST): Add test.c.
(AM_CPPFLAGS): Add -DSOURCE_DIR="\"$(srcdir)\"".
(module_tests): Add t-keydb.
(t_keydb_SOURCES): New variable.
(t_keydb_LDADD): Likewise.
* g10/t-keydb.c: New file.
* g10/t-keydb-keyring.kbx: New file.
* g10/test-stubs.c: New file.
* g10/test.c: New file.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-02 15:08:57 +02:00
Neal H. Walfield 60bc518645 g10: Make the keyblock cache per-handle rather than global.
* g10/keydb.c (keyblock_cache): Don't declare this variable.  Instead...
(struct keyblock_cache): ... turn its type into this first class
object...
(struct keydb_handle): ... and instantiate it once per database
handle.  Update all users.
(keydb_rebuild_caches): Don't invalidate the keyblock cache.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-02 10:52:01 +02:00
Neal H. Walfield f076fa190e g10: If iobuf_seek fails when reading from the cache, do a hard read.
* g10/keydb.c (keydb_get_keyblock): If the iobuf_seek fails when
reading from the cache, then simply clear the cache and try reading
from the database.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-02 10:38:42 +02:00
Neal H. Walfield 219de84df9 iobuf: Reduce verbosity of test.
* common/t-iobuf.c (main): Reduce verbosity.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
2015-09-02 10:38:41 +02:00