aboutsummaryrefslogtreecommitdiffstats
path: root/g10/getkey.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* g10: Fix iteration over getkey results.Justus Winter2016-10-271-3/+6
| | | | | | | * g10/getkey.c (getkey_next): Return the public key in PK even if RET_KEYBLOCK is NULL. Signed-off-by: Justus Winter <[email protected]>
* Fix typos.Justus Winter2016-10-271-1/+1
| | | | | -- Signed-off-by: Justus Winter <[email protected]>
* g10: Assert preconditions.Justus Winter2016-10-271-0/+3
| | | | | | * g10/getkey.c (get_pubkey_byname): Assert preconditions. Signed-off-by: Justus Winter <[email protected]>
* gpg: Convey --quick option to dirmngr for --auto-key-retrieve.Werner Koch2016-10-271-1/+1
| | | | | | | | | | | | | | | | | | * g10/call-dirmngr.c (gpg_dirmngr_ks_get): Add arg 'quick'. (gpg_dirmngr_wkd_get): Ditto. * g10/keyserver.c (keyserver_get): Add arg 'quick'. (keyserver_get_chunk): Add arg 'quick'. (keyserver_import_fprint): Ditto. Change callers to pass 0 for it. (keyserver_import_keyid): Ditto. (keyserver_import_wkd): Ditto. * g10/mainproc.c (check_sig_and_print): Call the 3 fucntions with QUICK set. -- Note that this option has not yet been implemented by dirmngr. Dirmngr will simply ignore it for now. Signed-off-by: Werner Koch <[email protected]>
* gpg: Make decryption of -R work w/o --try-secret-key or --default-key.Werner Koch2016-08-291-10/+7
| | | | | | | | | | * g10/getkey.c (enum_secret_keys): At state 3 enumerate the keys in all cases not just when --try-all-secrets is used. -- Regression-due-to: 82b90eee100cf1c9680517059b2d35e295dd992a Reported-by: Carola Grunwald Signed-off-by: Werner Koch <[email protected]>
* More cleanup of "allow to".Daniel Kahn Gillmor2016-08-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * README, agent/command.c, agent/keyformat.txt, common/i18n.c, common/iobuf.c, common/keyserver.h, dirmngr/cdblib.c, dirmngr/ldap-wrapper.c, doc/DETAILS, doc/TRANSLATE, doc/announce-2.1.txt, doc/gpg.texi, doc/gpgsm.texi, doc/scdaemon.texi, doc/tools.texi, doc/whats-new-in-2.1.txt, g10/export.c, g10/getkey.c, g10/import.c, g10/keyedit.c, m4/ksba.m4, m4/libgcrypt.m4, m4/ntbtls.m4, po/ca.po, po/cs.po, po/da.po, po/de.po, po/el.po, po/eo.po, po/es.po, po/et.po, po/fi.po, po/fr.po, po/gl.po, po/hu.po, po/id.po, po/it.po, po/ja.po, po/nb.po, po/pl.po, po/pt.po, po/ro.po, po/ru.po, po/sk.po, po/sv.po, po/tr.po, po/uk.po, po/zh_CN.po, po/zh_TW.po, scd/app-p15.c, scd/ccid-driver.c, scd/command.c, sm/gpgsm.c, sm/sign.c, tools/gpgconf-comp.c, tools/gpgtar.h: replace "Allow to" with clearer text. In standard English, the normal construction is "${XXX} allows ${YYY} to" -- that is, the subject (${XXX}) of the sentence is allowing the object (${YYY}) to do something. When the object is missing, the phrasing sounds awkward, even if the object is implied by context. There's almost always a better construction that isn't as awkward. These changes should make the language a bit clearer. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* gpg: Make --try-all-secrets work for hidden recipientsDaiki Ueno2016-07-131-10/+50
| | | | | | | | | | | | | * g10/getkey.c (enum_secret_keys): Really enumerate all secret keys if --try-all-secrets is specified. -- GnuPG-bug-id: 1985 Signed-off-by: Daiki Ueno <[email protected]> - Add new arg CTRL to getkey_byname call. Signed-off-by: Werner Koch <[email protected]>
* gpg: New options --recipient-file and --hidden-recipient-file.Werner Koch2016-07-061-1/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/gpg.c (oRecipientFile, oHiddenRecipientFile): New. (opts): Add options --recipient-file and --hidden-recipient-file. (main): Implement them. Also remove duplicate code from similar options. * g10/keydb.h (PK_LIST_FROM_FILE): New. (PK_LIST_SHIFT): Bump up. * g10/pkclist.c (expand_group): Take care of PK_LIST_FROM_FILE. (find_and_check_key): Add and implement arg FROM_FILE. (build_pk_list): Pass new value for new arg. * g10/getkey.c (get_pubkey_fromfile): New. * g10/gpgv.c (read_key_from_file): New stub. * g10/test-stubs.c (read_key_from_file): New stub. * g10/server.c (cmd_recipient): Add flag --file. * g10/import.c (read_key_from_file): New. * tests/openpgp/defs.scm (key-file1): New. (key-file2): New. * tests/openpgp/setup.scm: Add their private keys and import the key-file1. * tests/openpgp/encrypt.scm: Add new test. -- Signed-off-by: Werner Koch <[email protected]>
* gpg: Get rid of an unused arg in a function in getkey.c.Werner Koch2016-07-061-10/+7
| | | | | | | * g10/getkey.c (pk_from_block): Remove unused arg CTX. Change all callers. Signed-off-by: Werner Koch <[email protected]>
* gpg: Change calling convention for a function in getkey.cWerner Koch2016-07-061-37/+40
| | | | | | | | | * g10/getkey.c (merge_selfsigs): Remove arg CTX. Add args REQ_USAGE and WANT_EXACT. (finish_lookup): Adjust caller. Set LOOKUP_NOT_SELECTED here... (lookup): and not here. Signed-off-by: Werner Koch <[email protected]>
* gpg: Emit new status line KEY_CONSIDERED.Werner Koch2016-05-171-82/+138
| | | | | | | | | | | | | * common/status.h (STATUS_KEY_CONSIDERED): New. * g10/getkey.c: Include status.h. (LOOKUP_NOT_SELECTED, LOOKUP_ALL_SUBKEYS_EXPIRED): New. (finish_lookup): Add arg R_FLAGS. Count expired and revoked keys and set flag. Check a requested usage before checking for expiraion or revocation. (print_status_key_considered): New. (lookup): Print new status. Signed-off-by: Werner Koch <[email protected]>
* gpg: Remove all assert.h and s/assert/log_assert/.Werner Koch2016-04-291-20/+19
| | | | Signed-off-by: Werner Koch <[email protected]>
* gpg: Add experimental AKL method "wkd" and option --with-wkd-hash.Werner Koch2016-04-271-13/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/getkey.c (parse_auto_key_locate): Add method "wkd". (get_pubkey_byname): Implement that method. Also rename a variable. * g10/call-dirmngr.c (gpg_dirmngr_wkd_get): New. * g10/keyserver.c (keyserver_import_wkd): New. * g10/test-stubs.c (keyserver_import_wkd): Add stub. * g10/gpgv.c (keyserver_import_wkd): Ditto. * g10/options.h (opt): Add field 'with_wkd_hash'. (AKL_WKD): New. * g10/gpg.c (oWithWKDHash): New. (opts): Add option --with-wkd-hash. (main): Set that option. * g10/keylist.c (list_keyblock_print): Implement that option. -- The Web Key Directory is an experimental feature to retrieve a key via https. It is similar to OpenPGP DANE but also uses an encryption to reveal less information about a key lookup. For example the URI to lookup the key for [email protected] is: https://example.org/.well-known/openpgpkey/ hu/example.org/iy9q119eutrkn8s1mk4r39qejnbu3n5q (line has been wrapped for rendering purposes). The hash is a z-Base-32 encoded SHA-1 hash of the mail address' local-part. The address [email protected] can be used for testing. Signed-off-by: Werner Koch <[email protected]>
* g10: Silence message if --quiet is given.Kevin J. McCarthy2016-03-101-1/+1
| | | | | | | * g10/getkey.c (parse_def_secret_key): Silence message if --quiet is given. Signed-off-by: Justus Winter <[email protected]>
* gpg: Make --auto-key-retrieve work with dirmngr configured server.Werner Koch2016-01-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | * g10/call-dirmngr.c (gpg_dirmngr_ks_list): Make R_KEYSERVER optional. * g10/keyserver.c (keyserver_any_configured): New. (keyserver_put): Remove arg keyserver because this will always receive opt.keyserver which is anyway used when connecting dirmngr. Do not check opt.keyserver. (keyserver_import_cert): Replace opt.keyserver by keyserver_any_configured. * g10/mainproc.c (check_sig_and_print): Ditto. * g10/import.c (revocation_present): Ditto. * g10/getkey.c (get_pubkey_byname): Ditto. * g10/gpgv.c (keyserver_any_configured): Add stub. * g10/test-stubs.c (keyserver_any_configured): Add stub. -- The keyserver should be configured in dirmngr.conf and thus we can't use opt.keyserver in gpg to decide whether a keyserver has been configured. GnuPG-bug-id: 2147 Signed-off-by: Werner Koch <[email protected]>
* gpg: Minor string changes.Werner Koch2016-01-181-1/+1
| | | | --
* gpg: Move documentation from keydb.h to keydb.c and getkey.c.Werner Koch2016-01-111-24/+321
| | | | | | | | | | | -- When using tags (e.g. GNU global) to navigate the source code it is way easier to have the documentation close to the function we are looking at. Having the documentation in the header file would require an extra manual lookup to understand the function. Signed-off-by: Werner Koch <[email protected]>
* gpg: Fix NULL de-ref for ambiguous key check in --export-ssh-keys.Werner Koch2016-01-111-1/+5
| | | | | | | | | | | * g10/getkey.c: Allow arg RET_KEYBLOCK to be NULL. -- This change adds the expected behavior for the getkey_next function to fix this NULL de-ref. GnuPG-bug-id: 2212 Signed-off-by: Werner Koch <[email protected]>
* gpg: Add an exact search flag to the PK struct.Werner Koch2016-01-081-4/+6
| | | | | | | | | * g10/getkey.c (merge_selfsigs_subkey): Clear exact flag. (finish_lookup): Set exact flag. * g10/packet.h (PKT_public_key): Add field flags.exact. -- Signed-off-by: Werner Koch <[email protected]>
* gpg: Avoid warnings about possible NULL deref.Werner Koch2016-01-071-1/+1
| | | | | | | | | | | | | * g10/getkey.c (cache_public_key): Protect deref of CE which actually can't happen. * g10/keygen.c (quickgen_set_para): s/sprintf/snprintf/. * g10/tofu.c (end_transaction, rollback_transaction): Allow NULL for DB. * g10/trustdb.c (update_min_ownertrust): Remove useless clearling of ERR. -- Signed-off-by: Werner Koch <[email protected]>
* gpg: Fix warnings about useless assignments.Werner Koch2016-01-071-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | * g10/armor.c (parse_hash_header): Remove duplicate var assignment. * g10/getkey.c (cache_user_id): Ditto. * g10/keygen.c (ask_curve): Ditto. This also fixes a small memory leak. * g10/keygen.c (proc_parameter_file): Remove useless assignment or pointer increment. (generate_keypair): Ditto. * g10/getkey.c (finish_lookup, lookup): Ditto. * g10/card-util.c (change_pin): Ditto. * g10/gpg.c (main) <aVerify>: Ditto. * g10/import.c (import): Ditto. (print_import_check): Ditto * g10/keyring.c (do_copy): Ditto. * g10/tdbio.c (tdbio_read_record): Ditto. * g10/trustdb.c (tdb_update_ownertrust): Ditto. (update_validity): Ditto. * g10/server.c (cmd_passwd): Remove useless call to skip_options. -- Signed-off-by: Werner Koch <[email protected]>
* gpg: Fix double free.Neal H. Walfield2016-01-041-9/+1
| | | | | | | | | | | * g10/getkey.c (get_pubkeys): Fix double free. -- Signed-off-by: Neal H. Walfield <[email protected]> Fixes-commit: 7195b943 Note: this error is not a security problem, because this code path is currently never executed.
* Revert commit 4654384fe7a4dcee113dacf27c398b13dea5d0be.Neal H. Walfield2016-01-041-1/+1
| | | | | | | | | -- Signed-off-by: Neal H. Walfield <[email protected]> Werner pointed out that a special error message is not needed: the error code (as displayed by gpg_strerror) will indicate what went wrong.
* gpg: Rename struct pubkey to pukey_s and add pubkey_t.Werner Koch2015-12-231-11/+11
| | | | | | | | | | | | | | | | | * g10/keydb.h (struct pubkey): Rename to pubkey_s. (pubkey_t): New. Change all struct pubkey_s to use this type. * g10/getkey.c (get_pubkeys): Rename arg keys to r_keys. -- It is common in GnuPG to use a suffix of _s for struct names. There is no technical need for this (actually this pattern comes from pre ANSI C compilers which had no separate namespaces) but it avoid surprises when reading the code. Adding the pubkey_t type is mainly to improve font locking by using the common suffix _t for a typedefed type. Signed-off-by: Werner Koch <[email protected]>
* gpg: Add standard free() semantic to pubkey_free.Werner Koch2015-12-231-3/+6
| | | | | | | | | * g10/getkey.c (pubkey_free): Check for NULL arg. -- We don't like surprises ;-) Signed-off-by: Werner Koch <[email protected]>
* gpg: Do not translate debug output.Werner Koch2015-12-231-3/+3
| | | | | | | | | * g10/getkey.c (parse_def_secret_key): Do not make strings passed to log_debug translatable. -- Debug output is intended to be used along with the source or to be send to the developers. Thus translations are at best not helpful.
* gpg: Fix error message.Neal H. Walfield2015-12-221-1/+1
| | | | | | | * g10/getkey.c (parse_def_secret_key): Fix error message. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Don't check for ambiguous keys.Neal H. Walfield2015-12-221-0/+276
| | | | | | | | | | | | | | | | | | | | | | | | | * g10/gpg.c (struct result): Move from here... * g10/keydb.h (struct pubkey): ... to here. Update users. * g10/gpg.c (check_user_ids): Move from here... * g10/getkey.c (get_pubkeys): ... to here. Update users. Use get_pubkey_byname to look up the keys (this also prunes invalid keys). (pubkey_free): New function. (pubkeys_free): New function. * g10/gpg.c (main): Don't check for ambiguous key specifications. -- Signed-off-by: Neal H. Walfield <[email protected]> Regression-due-to: e8c53fc This change not only moves the checks for ambiguous key specifications from gpg.c to getkey.c, it also disables the checks. The old code was too divorced from the actual key lookups and, as such, it reproduced the logic. Unfortunately, the reproduction was a poor one: despite fixing some inconsistencies (e.g., 10cca02), it still didn't deal with group expansion or the auto key lookup functionality. Given the amount of instability introduced by this change, we (Neal & Werner) decided it is better to defer introducing this functionality until 2.3.
* gpg: Display the key that is invalid, not the search description.Neal H. Walfield2015-12-221-6/+6
| | | | | | | | * g10/getkey.c (parse_def_secret_key): Display the key that is invalid, not the search description. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Reduce number of strings to translate.Werner Koch2015-12-151-10/+10
| | | | | | | | | | * g10/getkey.c (parse_def_secret_key): Do not make debug messages translatable. Make use of print_reported_error. -- This patch also passes all required arguments to log_debug ;-). Signed-off-by: Werner Koch <[email protected]>
* gpg: Fix --default-key checks.Neal H. Walfield2015-12-141-3/+59
| | | | | | | | | | | | * g10/getkey.c (parse_def_secret_key): Don't just check if a secret key is available for the public key, also consider subkeys. Also check that the key has the signing capability, is not revoked, is not expired and is not disabled. Print a warning if there was a least one value passed to --default-key and all were ignored. -- Signed-off-by: Neal H. Walfield <[email protected]> Regression-due-to: e16d7168
* gpg: Take care of keydb_new returning NULL.Werner Koch2015-12-031-5/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/keydb.c (keydb_new): Print an error message if needed. Also use xtrycalloc because we return an error anyway. * g10/delkey.c (do_delete_key): Handle error retruned by keydb_new. * g10/export.c (do_export_stream): Ditto. * g10/getkey.c (get_pubkey): Ditto. (get_pubkey_fast): Ditto. (get_pubkeyblock): Ditto. (get_seckey): Ditto. (key_byname): Ditto. (get_pubkey_byfprint): Ditto. (get_pubkey_byfprint_fast): Ditto. (parse_def_secret_key): Ditto. (have_secret_key_with_kid): Ditto. * g10/import.c (import_one): Ditto. (import_revoke_cert): Ditto. * g10/keyedit.c (keyedit_quick_adduid): Ditto. * g10/keygen.c (quick_generate_keypair): Ditto. (do_generate_keypair): Ditto. * g10/trustdb.c (validate_keys): Ditto. * g10/keyserver.c (keyidlist): Ditto. * g10/revoke.c (gen_desig_revoke): Ditto. (gen_revoke): Ditto. * g10/gpg.c (check_user_ids): Ditto. (main): Do not print an error message for keydb_new error. * g10/keylist.c (list_all): Use actual error code returned by keydb_new. * g10/t-keydb-get-keyblock.c (do_test): Abort on keydb_new error. * g10/t-keydb.c (do_test): Ditto. * g10/keyring.c (keyring_new): Actually return an error so that the existing keydb_new error checking makes sense for a keyring resource. (keyring_rebuild_cache): Take care of keyring_new returning an error. -- Commit 04a6b903 changed keydb_new to return an error. However the error was not checked at most places which we fix with this patch. To make things easier keydb_new prints an error message itself. Signed-off-by: Werner Koch <[email protected]>
* gpg: Change some error messages.Werner Koch2015-12-031-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/getkey.c (parse_def_secret_key): Change error message. Replace log_debug by log_info. * g10/gpg.c (check_user_ids): Make function static. Change error messages. (main): Change error messages. * g10/revoke.c (gen_revoke): Ditto. -- There are other smaller changes not described above. This change tries to avoid new error messages so not to increase the the number of translated strings or break too many existing translations. It also tries to use existing strings and changes the quoting to the most common style used in gpg. Key specifications should in general use double quotes. Other values should use single quotes. However. sometimes it is not easy to distinguish between values given on the command line and key specifications. According to old GNU coding standards diagnostics should not start capitalized - whether this is a good idea is a different thing but we used this rules for most strings. However, strings which are used interactively should be properly capitalized and end with a dot. Signed-off-by: Werner Koch <[email protected]>
* gpg: Change keydb_search to not return legacy keys.Neal H. Walfield2015-11-171-45/+2
| | | | | | | | | | | | | | | | | | | | * g10/keyring.c (keyring_search): Take new argument, ignore_legacy. If set, skip any legacy keys. Update callers. * g10/keydb.c (keydb_search): Skip any legacy keys. (keydb_search_first): Don't skip legacy keys. Treat them as an error. (keydb_search_next): Likewise. (keydb_search_fpr): Likewise. * g10/export.c (do_export_stream): Likewise. * g10/getkey.c (lookup): Likewise. (have_secret_key_with_kid): Likewise. * g10/keylist.c (list_all): Likewise. (keyring_rebuild_cache): Likewise. * g10/keyserver.c (keyidlist): Likewise. * g10/trustdb.c (validate_key_list): Likewise. -- Signed-off-by: Neal H. Walfield <[email protected]>
* Fix typos found using codespell.Justus Winter2015-11-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * agent/cache.c: Fix typos. * agent/call-pinentry.c: Likewise. * agent/call-scd.c: Likewise. * agent/command-ssh.c: Likewise. * agent/command.c: Likewise. * agent/divert-scd.c: Likewise. * agent/findkey.c: Likewise. * agent/gpg-agent.c: Likewise. * agent/w32main.c: Likewise. * common/argparse.c: Likewise. * common/audit.c: Likewise. * common/audit.h: Likewise. * common/convert.c: Likewise. * common/dotlock.c: Likewise. * common/exechelp-posix.c: Likewise. * common/exechelp-w32.c: Likewise. * common/exechelp-w32ce.c: Likewise. * common/exechelp.h: Likewise. * common/helpfile.c: Likewise. * common/i18n.h: Likewise. * common/iobuf.c: Likewise. * common/iobuf.h: Likewise. * common/localename.c: Likewise. * common/logging.c: Likewise. * common/openpgp-oid.c: Likewise. * common/session-env.c: Likewise. * common/sexputil.c: Likewise. * common/sysutils.c: Likewise. * common/t-sexputil.c: Likewise. * common/ttyio.c: Likewise. * common/util.h: Likewise. * dirmngr/cdblib.c: Likewise. * dirmngr/certcache.c: Likewise. * dirmngr/crlcache.c: Likewise. * dirmngr/dirmngr-client.c: Likewise. * dirmngr/dirmngr.c: Likewise. * dirmngr/dirmngr_ldap.c: Likewise. * dirmngr/dns-stuff.c: Likewise. * dirmngr/http.c: Likewise. * dirmngr/ks-engine-hkp.c: Likewise. * dirmngr/ks-engine-ldap.c: Likewise. * dirmngr/ldap-wrapper.c: Likewise. * dirmngr/ldap.c: Likewise. * dirmngr/misc.c: Likewise. * dirmngr/ocsp.c: Likewise. * dirmngr/validate.c: Likewise. * g10/encrypt.c: Likewise. * g10/getkey.c: Likewise. * g10/gpg.c: Likewise. * g10/gpgv.c: Likewise. * g10/import.c: Likewise. * g10/keydb.c: Likewise. * g10/keydb.h: Likewise. * g10/keygen.c: Likewise. * g10/keyid.c: Likewise. * g10/keylist.c: Likewise. * g10/keyring.c: Likewise. * g10/mainproc.c: Likewise. * g10/misc.c: Likewise. * g10/options.h: Likewise. * g10/packet.h: Likewise. * g10/parse-packet.c: Likewise. * g10/pkclist.c: Likewise. * g10/pkglue.c: Likewise. * g10/plaintext.c: Likewise. * g10/server.c: Likewise. * g10/sig-check.c: Likewise. * g10/sqlite.c: Likewise. * g10/tdbio.c: Likewise. * g10/test-stubs.c: Likewise. * g10/tofu.c: Likewise. * g10/trust.c: Likewise. * g10/trustdb.c: Likewise. * g13/create.c: Likewise. * g13/mountinfo.c: Likewise. * kbx/keybox-blob.c: Likewise. * kbx/keybox-file.c: Likewise. * kbx/keybox-init.c: Likewise. * kbx/keybox-search-desc.h: Likewise. * kbx/keybox-search.c: Likewise. * kbx/keybox-update.c: Likewise. * scd/apdu.c: Likewise. * scd/app-openpgp.c: Likewise. * scd/app-p15.c: Likewise. * scd/app.c: Likewise. * scd/ccid-driver.c: Likewise. * scd/command.c: Likewise. * scd/iso7816.c: Likewise. * sm/base64.c: Likewise. * sm/call-agent.c: Likewise. * sm/call-dirmngr.c: Likewise. * sm/certchain.c: Likewise. * sm/gpgsm.c: Likewise. * sm/import.c: Likewise. * sm/keydb.c: Likewise. * sm/minip12.c: Likewise. * sm/qualified.c: Likewise. * sm/server.c: Likewise. * tools/gpg-check-pattern.c: Likewise. * tools/gpgconf-comp.c: Likewise. * tools/gpgkey2ssh.c: Likewise. * tools/gpgparsemail.c: Likewise. * tools/gpgtar.c: Likewise. * tools/rfc822parse.c: Likewise. * tools/symcryptrun.c: Likewise. Signed-off-by: Justus Winter <[email protected]>
* gpg: Fix regression in --locate-keys (in 2.1.9).Werner Koch2015-11-131-1/+13
| | | | | | | | | | | | | | | | | | * g10/getkey.c (getkey_ctx_s): Add field "extra_list". (get_pubkey_byname): Store strings in the context. (getkey_end): Free EXTRA_LIST. -- This fixes a use-after-free bug. It showed up with: gpg --auto-key-locate local --locate-key [email protected] The key was shown but also all other following keys in the keyring. Bisecting showed d47e84946ee010917cfc3501062721b74afbb771 as culprit but the actual cause was a part of: Regression-due-to: b06f96ba4f57f55194efcd37a0e3a2aa5450b974 Signed-off-by: Werner Koch <[email protected]>
* gpg: Check for ambiguous or non-matching key specs.Neal H. Walfield2015-11-061-9/+0
| | | | | | | | | | | | | | | | | * g10/gpg.c (check_user_ids): New function. (main): Check that any user id specifications passed to --local-user and --remote-user correspond to exactly 1 user. Check that any user id specifications passed to --default-key correspond to at most 1 user. Warn if any user id specifications passed to --local-user or --default-user are possible ambiguous (are not specified by long keyid or fingerprint). * g10/getkey.c (parse_def_secret_key): Don't warn about possible ambiguous key descriptions here. -- Signed-off-by: Neal H. Walfield <[email protected]> GnuPG-bug-id: 1128 Debian-debug-id: 544490
* gpg: Add --encrypt-to-default-key.Neal H. Walfield2015-11-041-1/+1
| | | | | | | | | | | | | * g10/getkey.c (parse_def_secret_key): Drop the static qualifier and export the function. * g10/gpg.c (enum cmd_and_opt_values): Add value oEncryptToDefaultKey. (opts): Handle oEncryptToDefaultKey. (main): Likewise. * g10/options.h (opt): Add field encrypt_to_default_key. -- Signed-off-by: Neal H. Walfield <[email protected]> GnuPG-bug-id: 807
* gpg: Allow multiple --default-key options. Take the last available key.Neal H. Walfield2015-11-041-10/+89
| | | | | | | | | | | | | | | | | | | | | | | | | * g10/getkey.c (parse_def_secret_key): New function. (get_seckey_default): Add parameter ctrl. Update callers. Use parse_def_secret_key to get the default secret key, if any. (getkey_byname): Likewise. (enum_secret_keys): Likewise. * g10/options.h (opt): Change def_secret_key's type from a char * to a strlist_t. * g10/gpg.c (main): When processing --default-key, add the key to OPT.DEF_SECRET_KEY. * g10/gpgv.c (get_session_key): Add parameter ctrl. Update callers. * g10/mainproc.c (proc_pubkey_enc): Likewise. (do_proc_packets): Likewise. * g10/pkclist.c (default_recipient): Likewise. * g10/pubkey-enc.c (get_session_key): Likewise. * g10/sign.c (clearsign_file): Likewise. (sign_symencrypt_file): Likewise. * g10/skclist.c (build_sk_list): Likewise. * g10/test-stubs.c (get_session_key): Likewise. -- Signed-off-by: Neal H. Walield <[email protected]> GnuPG-bug-id: 806
* gpg: Add new --auto-key-locate mechanism "dane".Werner Koch2015-10-061-1/+10
| | | | | | | | | | | | | | | * g10/call-dirmngr.c (gpg_dirmngr_dns_cert): Allow fetching via DANE. * g10/keyserver.c (keyserver_import_cert): Add arg "dane_mode". * g10/options.h (AKL_DANE): New. * g10/getkey.c (get_pubkey_byname): Implement AKL_DANE. (parse_auto_key_locate): Ditto. -- To test this use gpg --auto-key-locate clear,dane,local --locate-key -v [email protected] Signed-off-by: Werner Koch <[email protected]>
* g10: Be more careful when merging self-signed data.Neal H. Walfield2015-09-161-3/+21
| | | | | | | | | | | * 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 <[email protected]>.
* g10: Simplify some complicated boolean expressions.Neal H. Walfield2015-09-161-8/+29
| | | | | | | * g10/getkey.c (finish_lookup): Simplify logic. -- Signed-off-by: Neal H. Walfield <[email protected]>.
* g10: Also mark revoked and expired keys as unusable.Neal H. Walfield2015-09-161-2/+6
| | | | | | | | * 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 <[email protected]>.
* g10: Release resources when returning an error in get_seckey.Neal H. Walfield2015-09-161-1/+5
| | | | | | | | * g10/getkey.c (get_seckey): If the key doesn't have a secret key, release *PK. -- Signed-off-by: Neal H. Walfield <[email protected]>.
* g10: Improve documentation and comments for getkey.c.Neal H. Walfield2015-09-161-173/+325
| | | | | | | | | * 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 <[email protected]>.
* g10: Remove unused function have_any_secret_key.Neal H. Walfield2015-09-161-14/+0
| | | | | | | * g10/getkey.c (have_any_secret_key): Remove function. -- Signed-off-by: Neal H. Walfield <[email protected]>.
* g10: Bring cache semantics closer to non-cache semantics.Neal H. Walfield2015-09-161-3/+7
| | | | | | | | * g10/getkey.c (get_pubkey_fast): When reading from the cache, only consider primary keys. -- Signed-off-by: Neal H. Walfield <[email protected]>.
* g10: Break out of the loop earlier.Neal H. Walfield2015-09-161-6/+9
| | | | | | | | | | * g10/getkey.c (have_secret_key_with_kid): Once we find the relevent key or subkey, stop searching. -- Signed-off-by: Neal H. Walfield <[email protected]>. Only a single key or subkey will ever be selected per keyblock.
* g10: Don't skip legacy keys if the search mode is KEYDB_SEARCH_MODE_NEXTNeal H. Walfield2015-09-161-1/+2
| | | | | | | | | | | | | * 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 <[email protected]>. 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.
* g10: Remove unused function get_seckeyblock_byfprint.Neal H. Walfield2015-09-161-29/+0
| | | | | | | | * g10/keydb.h (get_seckeyblock_byfprint): Remove prototype. * g10/getkey.c (get_seckeyblock_byfprint): Remove function. -- Signed-off-by: Neal H. Walfield <[email protected]>.