aboutsummaryrefslogtreecommitdiffstats
path: root/g10/getkey.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* g10: Remove unused function get_seckey_byfprint.Neal H. Walfield2015-09-161-36/+0
| | | | | | | | * g10/keydb.h (get_seckey_byfprint): Remove prototype. * g10/getkey.c (get_seckey_byfprint): Remove function. -- Signed-off-by: Neal H. Walfield <[email protected]>.
* g10: Simplify get_seckey_byname: it was never called with NAME not NULL.Neal H. Walfield2015-09-161-7/+2
| | | | | | | | | | | | * 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 <[email protected]>.
* g10: Eliminate the redundant function get_keyblock_byfprint.Neal H. Walfield2015-09-161-30/+0
| | | | | | | | | * 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 <[email protected]>.
* g10: Simplify semantics of get_pubkey_byname.Neal H. Walfield2015-09-161-8/+6
| | | | | | | | | | | * 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 <[email protected]>. Currently, no caller invokes get_pubkey_byname with PK==NULL and R_KEYBLOCK != NULL. Thus, this change does not change any behavior.
* g10: Eliminate the redundant function get_pubkey_byname.Neal H. Walfield2015-09-161-30/+2
| | | | | | | | * 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 <[email protected]>.
* g10: Eliminate the redundant function get_pubkey_end.Neal H. Walfield2015-09-161-19/+12
| | | | | | | | | * 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 <[email protected]>.
* g10: Eliminate the redundant function get_pubkey_next.Neal H. Walfield2015-09-161-6/+0
| | | | | | | | | | * 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 <[email protected]>.
* kbx: Change skipfnc's prototype so that we can provide all information.Neal H. Walfield2015-09-161-10/+21
| | | | | | | | | | | | | | | | * 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 <[email protected]>. 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.
* g10: Remove unused function (get_pubkey_bynames).Neal H. Walfield2015-09-161-16/+1
| | | | | | | | * g10/keydb.h (get_pubkey_bynames): Remove prototype. * g10/getkey.c (get_pubkey_bynames): Remove function. -- Signed-off-by: Neal H. Walfield <[email protected]>.
* g10: Simplify code. Turn struct getkey_ctx_s.found_key into an argumentNeal H. Walfield2015-09-161-30/+48
| | | | | | | | | | | | | * 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 <[email protected]>.
* g10: Remove unused field struct getkey_ctx_s.kbpos.Neal H. Walfield2015-09-161-2/+0
| | | | | | | | * g10/getkey.c (struct getkey_ctx_s): Remove field kbpos. (getkey_end): Don't clear CTX->KBPOS. -- Signed-off-by: Neal H. Walfield <[email protected]>.
* g10: Simplify code: remove field struct getkey_ctx_s.keyblock.Neal H. Walfield2015-09-161-13/+12
| | | | | | | | | | * 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 <[email protected]>.
* doc: Minor comment fixes.Werner Koch2015-09-091-5/+6
| | | | --
* g10: Remove unused field req_algo.Neal H. Walfield2015-09-021-4/+0
| | | | | | | | | | * 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 <[email protected]>.
* common: Don't assume on-disk layout matches in-memory layout.Neal H. Walfield2015-08-211-2/+2
| | | | | | | | | | | * g10/packet.h (PKT_signature): Change revkey's type from a struct revocation_key ** to a struct revocation_key *. Update users. -- revkey was a pointer into the raw data. But, C doesn't guarantee that there is no padding. Thus, we copy the data. Signed-off-by: Neal H. Walfield <[email protected]>.
* gpg: Properly handle legacy keys while looking for a secret key.Werner Koch2015-08-041-1/+8
| | | | | | | | | | * g10/getkey.c (have_secret_key_with_kid): Skip legacy keys. -- This fixes GnuPG-bug-id: 2031 Signed-off-by: Werner Koch <[email protected]>
* gpg: Fix endless loop for expired keys given by fpr.Werner Koch2015-07-311-0/+5
| | | | | | | | | | * g10/getkey.c (lookup): Disable keydb caching when continuing a search. -- Caches are Fierce Creatures. Reported-by: Patrick Brunschwig
* gpg: Do not return "Legacy Key" from lookup if a key is expired.Werner Koch2015-07-291-1/+2
| | | | | | | | | | | | * g10/getkey.c (lookup): Map GPG_ERR_LEGACY_KEY. -- If an expired key is directly followed by a legacy key in the keyring, the lookup function incorrectly returned "legacy key" instead of "unusable key". We fix it by handling not found identical to a legacy key if the last finish lookup failed. Signed-off-by: Werner Koch <[email protected]>
* Don't segfault if the first 'auto-key-locate' option is 'clear'.Neal H. Walfield2015-07-161-0/+3
| | | | | | | | | * g10/getkey.c (free_akl): If AKL is NULL, just return. -- Signed-off-by: Neal H. Walfield <[email protected]>. Reported-by: Sami Farin. GnuPG-bug-id: 2045
* gpg: Improve 'General key info' line of --card-status.Werner Koch2015-05-071-3/+19
| | | | | | | | | | | | | | | | | * g10/keylist.c (print_pubkey_info): Print either "pub" or "sub". * g10/getkey.c (get_pubkey_byfprint): Add optional arg R_KEYBLOCK. * g10/keyid.c (keyid_from_fingerprint): Adjust for change. * g10/revoke.c (gen_desig_revoke): Adjust for change. * g10/card-util.c (card_status): Simplify by using new arg. Align card-no string. * g10/card-util.c (card_status): Remove not used GnuPG-1 code. -- This now prints "sub" if the first used card key is actually a subkey. Signed-off-by: Werner Koch <[email protected]>
* gpg: Merge duplicated code for get_user_id et al.Werner Koch2015-04-061-57/+45
| | | | | | | | | * g10/getkey.c (get_user_id_string): Add args mode and r_LEN. (get_user_id_string_native): Add new args. (get_long_user_id_string, get_user_id): Rewrite using get_user_id_string. Signed-off-by: Werner Koch <[email protected]>
* Fix use of DBG_CACHE and DBG_LOOKUPWerner Koch2015-04-061-16/+16
| | | | | | * dirmngr/dirmngr.h (DBG_LOOKUP_VALUE): Change to 8192. * g10/options.h (DBG_LOOKUP_VALUE, DBG_LOOKUP): New. * g10/getkey.c: Use DBG_LOOKUP instead of DBG_CACHE at most places.
* gpg: Switch to a hash and CERT record based PKA system.Werner Koch2015-02-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * common/dns-cert.c (get_dns_cert): Make r_key optional. * common/pka.c: Rewrite for the new hash based lookup. * common/t-pka.c: New. * configure.ac: Remove option --disable-dns-pka. (USE_DNS_PKA): Remove ac_define. * g10/getkey.c (parse_auto_key_locate): Always include PKA. -- Note that although PKA is now always build, it will only work if support for looking up via DNS has not been disabled. The new PKA only works with the IPGP DNS certtype and shall be used only to retrieve the fingerprint and optional the key for the first time. Due to the security problems with DNSSEC the former assumption to validate the key using DNSSEC is not anymore justified. Instead an additional layer (e.g. Trust-On-First-Use) needs to be implemented to track change to the key. Having a solid way of getting a key matching a mail address is however a must have. More work needs to go into a redefinition of the --verify-options pka-lookups and pka-trust-increase. The auto-key-locate mechanism should also be able to continue key fetching with another methods once the fingerprint has been retrieved with PKA. Signed-off-by: Werner Koch <[email protected]>
* Move new mailbox.c source file to common/.Werner Koch2015-02-251-1/+1
| | | | | | | | | | | * g10/mailbox.c: Move to ... * common/mbox-util.c: new file. * common/mbox-util.h: New. Include where needed. * g10/t-mailbox.c: Move to ... * common/t-mbox-util.c: new file. -- This will make it easier to use the code by other modules in common/.
* gpg: Skip legacy keys while searching keyrings.Werner Koch2015-02-231-2/+37
| | | | | | | | | * g10/getkey.c (search_modes_are_fingerprint): New. (lookup): Skip over legacy keys. -- GnuPG-bug-id: 1847 Signed-off-by: Werner Koch <[email protected]>
* gpg: Replace remaining uses of stdio by estream.Werner Koch2015-02-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | * g10/sign.c (sign_file): Use log_printf instead of stderr. * g10/tdbdump.c (export_ownertrust): Use estream fucntions. (import_ownertrust): Ditto. * g10/tdbio.c (tdbio_dump_record): Ditto. Change arg to estream_t. -- Reported-by: Guilhem Moulin <[email protected]> Needed for unattended key edits with --status-fd, because since 2.1 status prompts are preceded by es_fflush (in cpr.c:do_get_from_fd) not fflush(3), so the standard output may not be flushed before each prompt. (Which breaks scripts using select(2) to multiplex between the standard and status outputs.) His patch only affected print_and_check_one_sig_colon() but there are many more places where stdio and estream are mixed. This patch now replaces most of them in g10/. At some places stdio is still used, but that is local to a function and should not have side effects. Signed-off-by: Werner Koch <[email protected]>
* Use inline functions to convert buffer data to scalars.Werner Koch2015-02-111-6/+8
| | | | | | | | | | | | | | | * common/host2net.h (buf16_to_ulong, buf16_to_uint): New. (buf16_to_ushort, buf16_to_u16): New. (buf32_to_size_t, buf32_to_ulong, buf32_to_uint, buf32_to_u32): New. -- Commit 91b826a38880fd8a989318585eb502582636ddd8 was not enough to avoid all sign extension on shift problems. Hanno Böck found a case with an invalid read due to this problem. To fix that once and for all almost all uses of "<< 24" and "<< 8" are changed by this patch to use an inline function from host2net.h. Signed-off-by: Werner Koch <[email protected]>
* gpg: Add dedicated error code for PGP-2 keys.Werner Koch2015-01-221-3/+2
| | | | | | | | | | | | * g10/parse-packet.c (parse_key): Return GPG_ERR_LEGACY_KEY for PGP2 keys. * g10/import.c (read_block): Simplify by checking GPG_ERR_LEGACY_KEY. * g10/getkey.c (lookup): Silence error message for PGP-2 keys. * common/util.h (GPG_ERR_LEGACY_KEY): Add replacement for older libgpg-error. Signed-off-by: Werner Koch <[email protected]>
* gpg: Replace remaining old error code macros by GPG_ERR_.Werner Koch2015-01-221-23/+26
| | | | | | | | | * g10/gpg.h (g10_errstr): Remove macro and change all occurrences by gpg_strerror. (G10ERR_): Remove all macros and change all occurrences by their GPG_ERR_ counterparts. Signed-off-by: Werner Koch <[email protected]>
* gpg: Remove an unused variable.Werner Koch2015-01-221-2/+0
| | | | * g10/getkey.c (getkey_ctx_s): Remove last_rc.
* gpg: Remove unused args from a function.Werner Koch2015-01-051-1/+1
| | | | | | | * g10/keyserver.c (parse_keyserver_uri): Remove args configname and configlineno. Change all callers. Signed-off-by: Werner Koch <[email protected]>
* gpg: Fix endless loop in keylisting with fingerprint.Werner Koch2014-11-021-0/+6
| | | | | | | * g10/getkey.c (getkey_next): Disable cache. -- Signed-off-by: Werner Koch <[email protected]>
* gpg: Minor cleanup for key listing related code.Werner Koch2014-11-021-16/+10
| | | | | | | | | * g10/getkey.c (get_pubkey_next): Divert to getkey_next. (get_pubkey_end): Move code to getkey_end. * g10/keydb.c (keydb_search_reset): Add a debug statement. (dump_search_desc): Add arg HD and print the handle. Signed-off-by: Werner Koch <[email protected]>
* gpg: Fix testing for secret key availability.Werner Koch2014-10-311-1/+0
| | | | | | | | | | | | * g10/getkey.c (have_secret_key_with_kid): Do not change the search mode. -- The search mode was accidentally changed to search-next after finding the first keyblock. The intention was to look for a duplicate keyid in the keydb which works by not doing a keydb_search_reset. Signed-off-by: Werner Koch <[email protected]>
* gpg: Remove commented code.Werner Koch2014-10-311-143/+0
| | | | --
* gpg: Fix informative printing of user ids.Werner Koch2014-10-131-20/+91
| | | | | | | | | | | | | | | | | | | | | | * g10/getkey.c (keyid_list): Add field "fpr". (cache_user_id): Store fpr and check for dups only by fpr. (get_pubkey_byfpr): New. (get_user_id_string): Make static and use xasprintf. (get_long_user_id_string): Use xasprintf. (get_user_id_byfpr): New. (get_user_id_byfpr_native): New. * g10/keyid.c (fingerprint_from_pk): Make arg RET_LEN optional. * g10/import.c (import_one): Use get_user_id_byfpr_native. -- We now cache the userids using the fingerprint. This allows to print the correct user id for keys with a duplicated key id. We should eventually start to retire the use of all the old keyid based functions. However, at some places we only have the keyid and thus some of them will need to be kept (maybe changed with an indication to show that more than several user ids are matching). Signed-off-by: Werner Koch <[email protected]>
* gpg: Fix bug parsing a zero length user id.Werner Koch2014-06-021-1/+4
| | | | | | | | | | | | | | | | | * g10/getkey.c (get_user_id): Do not call xmalloc with 0. * common/xmalloc.c (xmalloc, xcalloc): Take extra precaution not to pass 0 to the arguments. -- The problem did not occur in 1.x because over there the xmalloc makes sure to allocate at least one byte. With 2.x for most calls the xmalloc of Libgcrypt is used and Libgcrypt returns an error insteead of silent allocating a byte. Thus gpg 2.x bailed out with an "Fatal: out of core while allocating 0 bytes". The extra code in xmalloc.c is for more robustness for the other xmalloc calls.
* gpg: Re-enable secret key deletion.Werner Koch2014-04-151-0/+32
| | | | | | | * g10/call-agent.c (agent_delete_key): New. * g10/keydb.h (FORMAT_KEYDESC_DELKEY): New. * g10/passphrase.c (gpg_format_keydesc): Support new format. * g10/delkey.c (do_delete_key): Add secret key deletion.
* gpg: New mechanism "clear" for --auto-key-locate.Werner Koch2014-03-171-2/+9
| | | | * g10/getkey.c (parse_auto_key_locate): Implement "clear".
* gpg: Use only OpenPGP public key algo ids and add the EdDSA algo id.Werner Koch2014-01-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * common/sexputil.c (get_pk_algo_from_canon_sexp): Change to return a string. * g10/keygen.c (check_keygrip): Adjust for change. * sm/certreqgen-ui.c (check_keygrip): Likewise. * agent/pksign.c (do_encode_dsa): Remove bogus map_pk_openpgp_to_gcry. * g10/misc.c (map_pk_openpgp_to_gcry): Remove. (openpgp_pk_test_algo): Change to a wrapper for openpgp_pk_test_algo2. (openpgp_pk_test_algo2): Rewrite. (openpgp_pk_algo_usage, pubkey_nbits): Add support for EdDSA. (openpgp_pk_algo_name): Rewrite to remove need for gcry calls. (pubkey_get_npkey, pubkey_get_nskey): Ditto. (pubkey_get_nsig, pubkey_get_nenc): Ditto. * g10/keygen.c(do_create_from_keygrip): Support EdDSA. (common_gen, gen_ecc, ask_keysize, generate_keypair): Ditto. * g10/build-packet.c (do_key): Ditto. * g10/export.c (transfer_format_to_openpgp): Ditto. * g10/getkey.c (cache_public_key): Ditto. * g10/import.c (transfer_secret_keys): Ditto. * g10/keylist.c (list_keyblock_print, list_keyblock_colon): Ditto. * g10/mainproc.c (proc_pubkey_enc): Ditto. * g10/parse-packet.c (parse_key): Ditto, * g10/sign.c (hash_for, sign_file, make_keysig_packet): Ditto. * g10/keyserver.c (print_keyrec): Use openpgp_pk_algo_name. * g10/pkglue.c (pk_verify, pk_encrypt, pk_check_secret_key): Use only OpenPGP algo ids and support EdDSA. * g10/pubkey-enc.c (get_it): Use only OpenPGP algo ids. * g10/seskey.c (encode_md_value): Ditto. -- This patch separates Libgcrypt and OpenPGP public key algorithms ids and in most cases completely removes the Libgcrypt ones. This is useful because for Libgcrypt we specify the algorithm in the S-expressions and the public key ids are not anymore needed. This patch also adds some support for PUBKEY_ALGO_EDDSA which will eventually be used instead of merging EdDSA with ECDSA. As of now an experimental algorithm id is used but the plan is to write an I-D so that we can get a new id from the IETF. Note that EdDSA (Ed25519) does not yet work and that more changes are required. The ECC support is still broken right now. Needs to be fixed. Signed-off-by: Werner Koch <[email protected]>
* Merge branch 'master' into key-storage-workkey-storage-workWerner Koch2013-03-201-1/+7
|\ | | | | | | --
| * gpg: Distinguish between missing and cleared key flags.Werner Koch2013-03-191-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/cipher.h (PUBKEY_USAGE_NONE): New. * g10/getkey.c (parse_key_usage): Set new flag. -- We do not want to use the default capabilities (derived from the algorithm) if any key flags are given in a signature. Thus if key flags are used in any way, the default key capabilities are never used. This allows to create a key with key flags set to all zero so it can't be used. This better reflects common sense.
* | gpg: Remove a function wrapper.Werner Koch2013-01-081-2/+2
| | | | | | | | | | | | * g10/keydb.h (keydb_search): Remove macro. * g10/keydb.c (keydb_search2): Rename to keydb_search. Change all callers.
* | gpg: Allow generation of more than 4096 keys in one run.Werner Koch2013-01-071-6/+20
| | | | | | | | | | | | | | | | | | | | | | * g10/getkey.c (cache_public_key): Make room in the cache if needed. -- To create the selfsigs, the key generation code makes use of the key cache. However, after 4096 the cache is filled up and then disabled. Thus generating more than 4096 keys in one run was not possible. We now clear the first half the inserted keys every time the cache gets full.
* | gpg: First working support for keyboxes.Werner Koch2012-12-281-2/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/getkey.c (get_pubkey_fast): Improve the assertion. * kbx/keybox.h: Include iobuf.h. * kbx/keybox-blob.c (keyboxblob_uid): Add field OFF. (KEYBOX_WITH_OPENPGP): Remove use of this macro. (pgp_create_key_part_single): New. (pgp_temp_store_kid): Change to use the keybox-openpgp parser. (pgp_create_key_part): Ditto. (pgp_create_uid_part): Ditto. (pgp_create_sig_part): Ditto. (pgp_create_blob_keyblock): Ditto. (_keybox_create_openpgp_blob): Ditto. * kbx/keybox-search.c (keybox_get_keyblock): New. * kbx/keybox-update.c (keybox_insert_keyblock): New. * g10/keydb.c (parse_keyblock_image): (keydb_get_keyblock): Support keybox. (build_keyblock_image): New. (keydb_insert_keyblock): Support keybox. * kbx/kbxutil.c (import_openpgp, main): Add option --dry-run and print a kbx file to stdout. * kbx/keybox-file.c (_keybox_read_blob2): Allow keyblocks up to 10^6 bytes. -- Import and key listing does now work with the keybox format. It is still quite slow and signature caching is completely missing. Increasing the maximum allowed length for a keyblock was required due to a 700k keyblock which inhibited kbxutil to list the file. kbxutil's option name --import-openpgp is not quite appropriate because it only creates KBX blobs from OpenPGP data.
* Change all quotes in strings and comments to the new GNU standard.Werner Koch2012-06-051-2/+2
| | | | | | | | | | | | | | | | | | | The asymmetric quotes used by GNU in the past (`...') don't render nicely on modern systems. We now use two \x27 characters ('...'). The proper solution would be to use the correct Unicode symmetric quotes here. However this has the disadvantage that the system requires Unicode support. We don't want that today. If Unicode is available a generated po file can be used to output proper quotes. A simple sed script like the one used for en@quote is sufficient to change them. The changes have been done by applying sed -i "s/\`\([^'\`]*\)'/'\1'/g" to most files and fixing obvious problems by hand. The msgid strings in the po files were fixed with a similar command.
* Re-indentation of keydb.c and error code changes.Werner Koch2011-04-291-5/+5
| | | | | | Returning -1 as an error code is not very clean given that gpg error has more descriptive error codes. Thus we now return GPG_ERR_NOT_FOUND for all search operations and adjusted all callers.
* Fix regression in gpg's mail address parsing.Werner Koch2011-04-251-1/+1
| | | | | | Since 2009-12-08 gpg was not able to find email addresses indicated by a leading '<'. This happened when I merged the user id classification code of gpgsm and gpg.
* Nuked almost all trailing white space.post-nuke-of-trailing-wsWerner Koch2011-02-041-11/+11
| | | | | | | | We better do this once and for all instead of cluttering all future commits with diffs of trailing white spaces. In the majority of cases blank or single lines are affected and thus this change won't disturb a git blame too much. For future commits the pre-commit scripts checks that this won't happen again.
* Integrating http://code.google.com/p/gnupg-ecc/source/detail?r=15 .Andrey Jivsov2011-01-061-1/+4
| | | | | | | | | | The following works: gpg2 --gen-key (ECC) gpg2 --list-keys gpg2 --list-packets ~/.gnupg/pubring.gpg gpg2 --list-packets <private key from http://sites.google.com/site/brainhub/pgpecckeys> ECDH doesn't work yet as the code must be re-written to adjust for gpg-agent refactoring.