aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* gpg-agent: add new CACHE_MODE_EXPORTdkg/fix-T4522Daniel Kahn Gillmor2019-05-204-44/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | * agent/agent.h: define CACHE_MODE_EXPORT * agent/call-pinentry.c (agent_askpin, agent_get_passphrase): use "e/" as the prefix for SETKEYINFO when in CACHE_MODE_EXPORT. (agent_clear_passphrase): allow clearing the export cache. * agent/command.c (cmd_clear_passphrase): add --mode=export. (cmd_export_key): use CACHE_MODE_EXPORT. * tests/openpgp/export.scm: no need to feed passphrases during export, already cached. ---- We don't want secret keys to be able to be exported automatically based on the same system passphrase cache used by standard decryption or signing operations. So we introduce a "export" cache mode which can be used by EXPORT_KEY. I confess i don't fully understand the changes made to tests/openpgp/export.scm -- i'm not sure why the passphrase is already supplied in this case. Gnupg-Bug-Id: 4522 Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* gpg: Do not delete any keys if --dry-run is passed.Werner Koch2019-05-201-3/+3
| | | | | | | | | * g10/delkey.c (do_delete_key): Don't delete the keyblock on dry runs. Do not clear the ownertrust. Do not let the agent delete the key. -- Co-authored-by: Matheus Afonso Martins Moreira Signed-off-by: Werner Koch <[email protected]>
* gpg: Fix using --decrypt along with --use-embedded-filename.Werner Koch2019-05-174-5/+10
| | | | | | | | | | | | | | | | | * g10/options.h (opt): Add flags.dummy_outfile. * g10/decrypt.c (decrypt_message): Set this global flag instead of the fucntion local flag. * g10/plaintext.c (get_output_file): Ignore opt.output if that was used as a dummy option aslong with --use-embedded-filename. -- The problem here was that an explicit specified --decrypt, as meanwhile suggested, did not work with that dangerous --use-embedded-filename. In contrast it worked when gpg decrypted as a side-effect of parsing the data. GnuPG-bug-id: 4500 Signed-off-by: Werner Koch <[email protected]>
* gpg: Improve the photo image viewer selection.Werner Koch2019-05-173-36/+113
| | | | | | | | | | | | | | | | | | | | | | | | | * g10/exec.c (w32_system): Add "!ShellExecute" special. * g10/photoid.c (get_default_photo_command): Use the new ShellExecute under Windows and fallbac to 'display' and 'xdg-open' in the Unix case. (show_photos): Flush stdout so that the output is shown before the image pops up. -- For Unix this basically syncs the code with what we have in gpg 1.4. Note that xdg-open may not be used when running as root which we support here. For Windows we now use ShellExecute as this seems to be preferred over "cmd /c start"; however this does not solve the actual problem we had in the bug report. To solve that problem we resort to a wait parameter which defaults to 400ms. This works on my Windows-10 virtualized test box. If we can figure out which simple viewers are commonly installed on Windows we should enhance this patch to test for them. GnuPG-bug-id: 4334 Signed-off-by: Werner Koch <[email protected]>
* kbx: Fix an endless loop under Windows due to an incomplete fix.Werner Koch2019-05-161-2/+2
| | | | | | | | | | | | * kbx/keybox-search.c (keybox_search): We need to seek to the last position in all cases not just when doing a NEXT. -- This is because search from the beginning needs a keybox_search_reset. We can only make an exception for KEYDB_SEARCH_MODE_FIRST.. Fixes-commit: 49b236af0ecbb6df67513feb4b63851f2e159ea2 Signed-off-by: Werner Koch <[email protected]>
* gpgconf: Before --launch check that the config file is fine.Werner Koch2019-05-162-4/+15
| | | | | | | | * tools/gpgconf-comp.c (gc_component_launch): Check the conf file. * tools/gpgconf.c (gpgconf_failure): Call log_flush. -- GnuPG-bug-id: 4497 Signed-off-by: Werner Koch <[email protected]>
* scd: Remove unused cruft from GnuPG 1.xWerner Koch2019-05-164-78/+14
| | | | | | | | | * scd/apdu.c: Remove code used only by GnuPG 1. * scd/app-openpgp.c: Ditto. * scd/ccid-driver.c: Ditto. * scd/iso7816.c: Ditto. Signed-off-by: Werner Koch <[email protected]>
* agent,scd: Scan and load all public keys for availability.NIIBE Yutaka2019-05-162-7/+18
| | | | | | | * agent/divert-scd.c (ask_for_card): Scan by SERIALNO command. * scd/app-openpgp.c (do_with_keygrip): Make sure to load pubkey. Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Support scdaemon operation using KEYGRIP.NIIBE Yutaka2019-05-155-34/+215
| | | | | | | | | | | | | | | | | | | | | * agent/agent.h (struct card_key_info_s): New. (divert_pksign, divert_pkdecrypt): New API. * agent/call-scd.c (card_keyinfo_cb): New. (agent_card_free_keyinfo, agent_card_keyinfo): New. * agent/divert-scd.c (ask_for_card): Having GRIP argument, ask scdaemon with agent_card_keyinfo. (divert_pksign, divert_pkdecrypt): Ditto. * agent/pkdecrypt.c (agent_pkdecrypt): Supply GRIP. * agent/pksign.c (agent_pksign_do): Ditto. -- We are going to relax the requirment for SERIALNO of card. It's OK, when a card doesn't have recorded SERIALNO. If a card has a key with GRIP, it can be used. GnuPG-bug-id: 2291, 4301 Signed-off-by: NIIBE Yutaka <[email protected]>
* scd: Don't put newline at the end of status.NIIBE Yutaka2019-05-151-1/+1
| | | | | | * scd/command.c (send_keyinfo): Remove newline. Signed-off-by: NIIBE Yutaka <[email protected]>
* doc: Do not mention gpg's deprecated --keyserver option.Werner Koch2019-05-151-19/+15
| | | | | -- GnuPG-bug-id: 4466
* gpg: enable OpenPGP export of cleartext keys with commentsDaniel Kahn Gillmor2019-05-151-1/+4
| | | | | | | | | | | | | | | | * g10/export.c (cleartext_secret_key_to_openpgp): ignore trailing sublists in private-key S-expression. -- When gpg-agent learns about a private key from its ssh-agent interface, it stores its S-expression with the comment attached. The export mechanism for OpenPGP keys already in cleartext was too brittle because it would choke on these comments. This change lets it ignore any additional trailing sublists. Signed-off-by: Daniel Kahn Gillmor <[email protected]> Gnupg-Bug-Id: 4490
* gpgconf: Support --homedir for --launch.Werner Koch2019-05-152-16/+11
| | | | | | | | | | | | * tools/gpgconf-comp.c (gpg_agent_runtime_change): Simplify because gnupg_homedir already returns abd absolute name. (scdaemon_runtime_change): Ditto. (dirmngr_runtime_change): Ditto. (gc_component_launch): Support --homedir. -- GnuPG-bug-id: 4496 Signed-off-by: Werner Koch <[email protected]>
* sm: Add a couple of debug calls to the keydb module.Werner Koch2019-05-155-42/+226
| | | | | | | | | | | | | | * sm/gpgsm.h (DBG_CLOCK_VALUE, DBG_CLOCK): New. (DBG_LOOKUP_VALUE, DBG_LOOKUP): New. * sm/gpgsm.c: new debug flags "lookup" and "clock" * sm/keydb.c: Add log_clock calls to most functions. (keydb_search_desc_dump): New. (keydb_search) [DBG_LOOKUP]: Print descrh decription. * sm/keylist.c (list_cert_std): Flush FP in debug mode to better syncronize the output with the debug output -- Signed-off-by: Werner Koch <[email protected]>
* scd: Fix return value for KEYINFO command.NIIBE Yutaka2019-05-151-1/+4
| | | | | | * scd/command.c (cmd_keyinfo): Return GPG_ERR_NOT_FOUND if none. Signed-off-by: NIIBE Yutaka <[email protected]>
* kbx: Fix deadlock in gpgsm on Windows due to a sharing violation.Werner Koch2019-05-143-14/+42
| | | | | | | | | | | | * kbx/keybox-init.c (keybox_lock) [W32]: Use _keybox_close_file instead of fclose so that a close is done if the file is opened by another handle. * kbx/keybox-search.c (keybox_search): Remember the last offset and use that in NEXT search mode if we had to re-open the file. -- GnuPG-bug-id: 4505 Signed-off-by: Werner Koch <[email protected]>
* sm: Change keydb code to use the keybox locking.Werner Koch2019-05-146-50/+54
| | | | | | | | | | | | | | | | | | | | | | | * kbx/keybox-init.c (keybox_lock): New arg TIMEOUT. Change all callers to pass -1 when locking. * sm/keydb.c (struct resource_item): Remove LOCKANDLE. (struct keydb_handle): Add KEEP_LOCK. (keydb_add_resource): Use keybox locking instead of a separate dotlock for testing whether we can run a compress. (keydb_release): Reset KEEP_LOCK. (keydb_lock): Set KEEP_LOCK. (unlock_all): Take care of KEEP_LOCK. (lock_all): Use keybox_lock instead of dotlock fucntions. (keydb_delete): Remove arg UNLOCK. * sm/delete.c (delete_one): Adjust keydb_delete. Due to the KEEP_LOCK the keydb_release takes care of unlocking. -- This aligns the code more with g10/keydb.c and avoids the separate calls to dotlock_take. GnuPG-bug-id: 4505 Signed-off-by: Werner Koch <[email protected]>
* agent: Replace most assert by log_assert.Werner Koch2019-05-1417-60/+42
| | | | --
* agent: correct length for uri and comment on 64-bit big-endian platformsDaniel Kahn Gillmor2019-05-141-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | * agent/findkey.c (agent_public_key_from_file): pass size_t as int to gcry_sexp_build_array's %b. -- This is only a problem on big-endian systems where size_t is not the same size as an int. It was causing failures on debian's s390x, powerpc64, and sparc64 platforms. There may well be other failures with %b on those platforms in the codebase, and it probably needs an audit. Once you have a key in private-keys-v1.d/$KEYGRIP.key with a comment or a uri of reasonable length associated with it, this fix can be tested with: gpg-agent --server <<<"READKEY $KEYGRIP" On the failing platforms, the printed comment will be of length 0. Gnupg-bug-id: 4501 Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* doc: Minor edit for a gpg option.Werner Koch2019-05-141-2/+2
| | | | | -- GnuPG-bug-id: 4507
* gpg: Do not print a hint to use the deprecated --keyserver option.Werner Koch2019-05-141-3/+1
| | | | | | | | | | | | | | * g10/keyserver.c (keyserver_search): Remove a specialized error message. -- Dirmngr comes with a default keyserver and the suggestion to use gpg --keyserver is not good because that option is deprecated. An error message "No keyserver available" is sufficient. GnuPG-bug-id: 4512 Signed-off-by: Werner Koch <[email protected]>
* g10: Fix possible null dereference.NIIBE Yutaka2019-05-141-2/+2
| | | | | | | | | * g10/armor.c (armor_filter): Access ->d in the internal loop. -- GnuPG-bug-id: 4494 Signed-off-by: NIIBE Yutaka <[email protected]>
* gpg: Change update_keysig_packet to replace SHA-1 by SHA-256.Werner Koch2019-05-131-0/+11
| | | | | | | | | | | | | | | * g10/sign.c (update_keysig_packet): Convert digest algo when needed. -- Several gpg commands try to keep most properties of a key signature when updating (i.e. creating a new version of a key signature). This included the use of the current hash-algorithm. This patch changes this so that SHA-1 or RMD160 are replaced by SHA-256 if possible (i.e. for RSA signatures). Affected commands are for example --quick-set-expire and --quick-set-primary-uid. GnuPG-bug-id: 4508 Signed-off-by: Werner Koch <[email protected]>
* gpg: Cleanup use of make_keysig_packet.Werner Koch2019-05-137-44/+48
| | | | | | | | | | * g10/sign.c (make_keysig_packet): Remove obsolete arg diegst_algo which was always passed as 0. Change all callers. * g10/gpgcompose.c (signature): Warn when trying to set a digest algo. -- Signed-off-by: Werner Koch <[email protected]>
* build: Update m4/iconv.m4.NIIBE Yutaka2019-05-131-57/+165
| | | | | | | | | | | * m4/iconv.m4: Update from gettext 0.20.1. -- This includes fixes of file descriptor leaks. GnuPG-bug-id: 4504 Signed-off-by: NIIBE Yutaka <[email protected]>
* doc: correct documentation for gpgconf --killDaniel Kahn Gillmor2019-05-101-5/+6
| | | | | | * doc/tools.texi(gpgconf): Correct documentation for gpgconf --kill. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* dirmngr: Add a CSRF expection for pm.meWerner Koch2019-05-092-3/+4
| | | | | | -- Also comment typo fix.
* agent: If a Label is make sure that label is part of the prompt.Werner Koch2019-05-071-0/+40
| | | | | | | | | | | | | | * agent/findkey.c (has_comment_expando): New. (agent_key_from_file): Modify DESC_TEXT. -- A Label entry in the keyfile is always set manually and thus we can assume that the user wants to have this label in the prompt. In case the prompt template does not demand a comment this patch appends a comment to thhe template. This is a common case for on-disk keys used by gpg. Signed-off-by: Werner Koch <[email protected]>
* agent: Allow the use of "Label:" in a key file.Werner Koch2019-05-072-25/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * agent/findkey.c (linefeed_to_percent0A): New. (read_key_file): Add optional arg 'keymeta' and change all callers. (agent_key_from_file): Prefer "Label:" over the comment for protected keys. -- If in the extended key format an item Label: This is my key is found, "This is my key" will be displayed instead of the comment intially recorded in the s-expression. This is pretty useful for the ssh keys because often there is only the original file name recorded in the comment. If no Label is found or it is empty the S-expression comment is used. To show more than one line, the standard name-value syntax can be used, for example: Label: The Ssh key <blank line> <space>I registered on fencepost. Signed-off-by: Werner Koch <[email protected]>
* common: New functions nvc_delete_named and nvc_get_string.Werner Koch2019-05-073-0/+65
| | | | | | | * common/name-value.c (nvc_delete_named): New. (nvc_get_string): New. Signed-off-by: Werner Koch <[email protected]>
* scd: Support direct use of app with PKSIGN/PKAUTH/PKDECRYPT.NIIBE Yutaka2019-05-071-11/+76
| | | | | | | * scd/command.c (cmd_pksign, cmd_pkauth, cmd_pkdecrypt): When length of keyidstr is 40, it is considered as a keygrip for direct use. Signed-off-by: NIIBE Yutaka <[email protected]>
* doc: Minor doc fix to dirmngr.Werner Koch2019-05-031-3/+1
| | | | | | -- Reported-by: dkg
* agent: Put Token lines into the key files.Werner Koch2019-05-039-32/+121
| | | | | | | | | | | | | | | * agent/findkey.c (write_extended_private_key): Add args serialno and keyref. Write a Token line if that does not yet exist. (agent_write_private_key): Add args serialno and keyref and change all callers. (agent_write_shadow_key): Skip leading spaces. * agent/keyformat.txt: Improve extended key format docs. -- Noet that the extended key forma is the defaqult in 2.3. This patch is a first step to better handle tokens which carray the same key. Signed-off-by: Werner Koch <[email protected]>
* common: In private key mode write "Key:" always last in name-value.Werner Koch2019-05-031-13/+40
| | | | | | | | | | | | * common/name-value.c (nvc_write): Take care of Key. Factor some code out to ... (write_one_entry): new. -- The key item is in general not manual editable thus we put it at the end of a file. Signed-off-by: Werner Koch <[email protected]>
* gpg: Use just the addrspec from the Signer's UID.Werner Koch2019-05-031-0/+9
| | | | | | | | | | | | | * g10/parse-packet.c (parse_signature): Take only rthe addrspec from a Signer's UID subpacket. -- This is to address a problem in the currentr OpenKeychain which put the entire UID into the subpacket. For example our Tofu code can only use the addrspec and not the entire UID. Reported-by: Wiktor Kwapisiewicz <[email protected]> Signed-off-by: Werner Koch <[email protected]>
* tools: Some changes to the ccidmon.c debug helper.Werner Koch2019-04-301-16/+31
| | | | --
* sm: Add yet inactive options to support authenticodeWerner Koch2019-04-304-3/+142
| | | | | | | | | | | | * sm/gpgsm.c (opts): New options --authenticode and --attribute. * sm/gpgsm.h (opt): Add vars authenticode and attribute_list. * sm/sign.c (add_signed_attribute): New but inactive. (gpgsm_sign): Use new options. -- Because libksba 1.4 is not yet ready the new code is not yet active. Signed-off-by: Werner Koch <[email protected]>
* common,w32: Breakaway detached childs when in jobAndre Heinecke2019-04-291-0/+45
| | | | | | | | | | | | | | | | | | | * common/exechelp-w32.c (gnupg_spawn_process_detached): Add CREATE_BREAKAWAY_FROM_JOB creation flag if required. -- When the gpg process is assigned to a W32 "Job" the child processes are killed once the Job is finished. As we want our detached processes to linger e.g. gpg-agent the breakaway flag is required in that case. GnuPG-Bug-Id: T4333 Thanks to Jan Echternach for reporting this and providing a patch. Signed-off-by: Andre Heinecke <[email protected]>
* scd: Add new command: KEYINFO.NIIBE Yutaka2019-04-255-1/+159
| | | | | | | | | | | | | | | * scd/app-common.h (struct app_ctx_s): Add with_keygrip function. * scd/app-openpgp.c (do_with_keygrip): New. * scd/app.c (app_do_with_keygrip): New. * scd/command.c (cmd_keyinfo): New. (send_keyinfo): New. -- KEYGRIP_ACTION_LOOKUP is not yet used. It will be used for directly asking PK* action to determine an APP. Signed-off-by: NIIBE Yutaka <[email protected]>
* po: Update Japanese Translation.NIIBE Yutaka2019-04-231-149/+267
| | | | Signed-off-by: NIIBE Yutaka <[email protected]>
* scd: Allow KEYGRIP as KEYIDSTR.NIIBE Yutaka2019-04-231-15/+52
| | | | | | | | | | | | * scd/app-openpgp.c (struct app_local_s): Add keygrip_str. (store_keygrip): New. (read_public_key): Call store_keygrip to hold keygrip. (get_public_key): Likewise. (send_keypair_info): Use stored keygrip_str. (check_keyidstr): Allow use of KEYGRIP. (do_check_pin): Allow use of KEYGRIP of signing slot. Signed-off-by: NIIBE Yutaka <[email protected]>
* scd: Factor out a function to check keyidstr.NIIBE Yutaka2019-04-221-126/+59
| | | | | | | * scd/app-openpgp.c (check_keyidstr): New. (do_sign, do_auth, do_decipher, do_check_pin): Use check_keyidstr. Signed-off-by: NIIBE Yutaka <[email protected]>
* gpgconf: correct capitalization of "Tor"Daniel Kahn Gillmor2019-04-191-1/+1
| | | | | | | | | | | | | | | | | * tools/gpgconf-comp.cb (gc_options_dirmngr): correct capitalization of Tor. -- https://www.torproject.org/docs/faq.html.en#WhyCalledTor says: > Note: even though it originally came from an acronym, Tor is not > spelled "TOR". Only the first letter is capitalized. In fact, we can > usually spot people who haven't read any of our website (and have > instead learned everything they know about Tor from news articles) by > the fact that they spell it wrong. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* g10: Fix double free when locating by mboxAndre Heinecke2019-04-181-2/+1
| | | | | | | | | | | | | | | | * g10/getkey.c (get_best_pubkey_byname): Set new.uid always to NULL after use. -- pubkey_cmp is not guranteed to set new.uid. So if the diff < 0 case is reached best is set to new. If then diff > 0 is reached without modifying new.uid e.g. if the key has no matching mboxes. new.uid is free'd even though the uid is still referenced in best. GnuPG-Bug-Id: T4462
* g10: Fix a memory leak.NIIBE Yutaka2019-04-171-0/+7
| | | | | | | | | | * g10/import.c (import): Care PNDING_PKT on error. -- GnuPG-bug-id: 4461 Reported-by: Philippe Antoine Signed-off-by: NIIBE Yutaka <[email protected]>
* common: Fix AWK portability.NIIBE Yutaka2019-04-162-7/+7
| | | | | | | | | | * common/Makefile.am: Use pkg_namespace. * common/mkstrtable.awk: Use pkg_namespace. Regexp fix. -- GnuPG-bug-Bug: 4459 Signed-off-by: NIIBE Yutaka <[email protected]>
* gpg: New caching functions.Werner Koch2019-04-135-119/+702
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/objcache.c: New. * g10/objcache.h: New. * g10/Makefile.am (common_source): Add them. * g10/gpg.c: Include objcache.h. (g10_exit): Call objcache_dump_stats. * g10/getkey.c: Include objcache.h. (get_primary_uid, release_keyid_list): Remove. (cache_user_id): Remove. (finish_lookup): Call the new cache_put_keyblock instead of cache_user_id. (get_user_id_string): Remove code for mode 2. (get_user_id): Implement using cache_get_uid_bykid. -- This generic caching module is better than the ad-hoc code we used in getkey.c. More cleanup in getkey is still required but it is a start. There is also a small performance increase with the new cache: With a large keyring and --list-sigs I get these numbers: | | before | after | |------+------------+------------| | real | 14m1.028s | 12m16.186s | | user | 2m18.484s | 1m36.040s | | sys | 11m42.420s | 10m40.044s | Note the speedup in the user time which is due to the improved cache algorithm. This is obvious, because the old cache was just a long linked list; the new cache are two hash tables. Signed-off-by: Werner Koch <[email protected]>
* gpg: Cache a once computed fingerprint in PKT_public_key.Werner Koch2019-04-122-72/+51
| | | | | | | | | | | | | | * g10/packet.h (PKT_public_key): Add fields fpr and fprlen. * g10/keyid.c (do_fingerprint_md): Remove. (compute_fingerprint): New. (keyid_from_pk): Simplify. (fingerprint_from_pk): Simplify. (hexfingerprint): Avoid using extra array. -- This is similar to what we are doing with the keyid for a long time. Signed-off-by: Werner Koch <[email protected]>
* gpg: Accept also armored data from the WKD.Werner Koch2019-04-111-2/+3
| | | | | | | | | | | * g10/keyserver.c (keyserver_import_wkd): Clear NO_ARMOR. -- We may even adjust the specs to allow that. It should not be a problem for any OpenPGP implementation because armored keys are very common and de-armoring code is de-facto a mandatory feature. Signed-off-by: Werner Koch <[email protected]>
* gpg: Set a limit of 5 to the number of keys imported from the WKD.Werner Koch2019-04-111-4/+21
| | | | | | | | | | | | | | | | | | | | | * g10/import.c (import): Limit the number of considered keys to 5. (import_one): Return the first fingerprint in case of WKD. -- The Web Key Directory should carry only one key. However, some providers like to put old or expired keys also into the WKD. I don't thunk that this is a good idea but I heard claims that this is needed for them to migrate existing key data bases. This patch puts a limit on 5 on it (we had none right now) and also fixes the issue that gpg could not work immediately with the requested key because the code uses the fingerprint of the key to use the imported key. Now the first key is used. On a second try (w/o accessing the WKD) the regular key selection mechanism would be in effect. I think this is the most conservative approach. Let's see whether it helps. Signed-off-by: Werner Koch <[email protected]>