summaryrefslogtreecommitdiffstats
path: root/agent (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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 <dkg@fifthhorseman.net>
* dirmngr: Add a CSRF expection for pm.meWerner Koch2019-05-091-2/+2
| | | | | | -- 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* 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 <wk@gnupg.org>
* agent: Allow other ssh fingerprint algos in KEYINFO.Werner Koch2019-03-261-4/+20
| | | | | | | * agent/command.c (cmd_keyinfo): Allow for --ssh-fpr=ALGO. Default to the standard algo. Signed-off-by: Werner Koch <wk@gnupg.org>
* agent: Re-introduce --enable-extended-key-format.Werner Koch2019-03-063-4/+15
| | | | | | | | | | | | | * agent/gpg-agent.c (oEnableExtendedKeyFormat): Re-introduce. (parse_rereadable_options): Handle it in a special way. * agent/protect.c (agent_protect): Be safe and set use_ocb only to 1 or 0. * tools/gpgconf-comp.c: Add --enable-extended-key-format again. -- This is required for backward compatible with profiles. Signed-off-by: Werner Koch <wk@gnupg.org>
* agent: Default to extended key format.Werner Koch2019-03-061-9/+13
| | | | | | | | | | | | | | | * agent/gpg-agent.c (oDisableExtendedKeyFormat, oNoop): New. (oEnableExtendedKeyFormat): Remove. (opts): Make --enable-extended-key-format a dummy option. Add disable-extended-key-format. (parse_rereadable_options): Implement oDisableExtendedKeyFormat. -- Extended key format is supported since vesion 2.1.12 which should have long been replaced by a newer version inh all installations. Thus for 2.3 we will make use of the extended-key-format by default. Signed-off-by: Werner Koch <wk@gnupg.org>
* agent: Fix detection of exit of scdaemon.NIIBE Yutaka2019-03-061-62/+80
| | | | | | | | | | | | | | * agent/call-scd.c (start_scd): Acquire START_SCD_LOCK for SCD_LOCAL_LIST. Move common case code to fast path. Release START_SCD_LOCK before calling unlock_scd. When new CTX is allocated, clear INVALID flag. (agent_reset_scd): Serialize the access to SCD_LOCAL_LIST by START_SCD_LOCK. -- GnuPG-bug-id: 4377 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd:piv: Implement import of private keys for Yubikeys.Werner Koch2019-03-052-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | * scd/app-piv.c (concat_tlv_list): Add arg 'secure' and adjust callers. (writekey_rsa, writekey_ecc): New. (do_writekey): New. (do_writecert): Provide a better error message for an empty cert. (app_select_piv): Register do_writekey. * scd/iso7816.c (iso7816_send_apdu): New. * scd/app-common.h (APP_WRITEKEY_FLAG_FORCE): New. * agent/command.c (cmd_keytocard): Make the timestamp optional. * tools/card-call-scd.c (inq_writekey_parms): Remove. (scd_writekey): Rewrite. * tools/gpg-card.c (cmd_writekey): New. (enum cmdids): Add cmdWRITEKEY. (dispatch_command, interactive_loop): Call cmd_writekey. -- This has been tested with gpgsm and RSA keys. For ECC keys only partly tested using the sample OpenPGP nistp256 and nistp384 keys because gpgsm does not yet support ECC certificates and thus we can't write the certificates to the cert object after a writekey. Note that they nevertheless show up in "gpgcard list" because gpg-card searches for them in gpg and gpgsm. However, this does not work completely. Signed-off-by: Werner Koch <wk@gnupg.org>
* agent: Minor change to the KEYTOCARD command.Werner Koch2019-03-054-71/+56
| | | | | | | | | | * agent/command.c (cmd_keytocard): Make timestamp optional. Use modern parser function. * agent/call-scd.c (agent_card_writekey): Rename an arg and for clarity return gpg_error_t instead of int. * agent/divert-scd.c (divert_writekey): Ditto. Signed-off-by: Werner Koch <wk@gnupg.org>
* agent: PKSIGN should return signature in same format for card.NIIBE Yutaka2019-02-271-46/+36
| | | | | | | | | | | | | | * agent/pksign.c (agent_pksign_do): -- It's best to keep same data format by libgcrypt. For card (due to historical reasons), gpg-agent or scdaemon used to prefix 0x00 when it starts 0x80, so that it can be parsed signed MPI as well as unsigned MPI. It used to do nothing for preceding zeros. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* agent: Fix for suggested Libgcrypt use.Werner Koch2019-02-251-1/+16
| | | | | | | | | | | | * agent/divert-scd.c (divert_pkdecrypt): Skip a flags parameter. -- The libgcrypt docs say that a "flags" parameter should always be used in the input of pkdecrypt. Thus we should allow that parameter also when parsing an s-expression to figure out the algorithm for use with scdaemon. Signed-off-by: Werner Koch <wk@gnupg.org>
* agent: Terminate pinentry process gracefully, by watching socket.NIIBE Yutaka2019-02-191-4/+81
| | | | | | | | | | | | | | * agent/call-pinentry.c (watch_sock): New. (do_getpin): Spawn the watching thread. -- While we don't have npth_cancel (and it's difficult to implement it correctly), this is a kind of best compromise allowing a thread's polling when pinentry is active. GnuPG-bug-id: 2011 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* agent: Minor change for pinentry status handling.NIIBE Yutaka2019-02-191-11/+7
| | | | | | | | * agent/call-pinentry.c (struct entry_parm_s): Add status. (do_getpin): Use param->status. (agent_askpin): Copy param->status. to pininfo. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* agent: Factor out the getpin interaction.NIIBE Yutaka2019-02-191-42/+37
| | | | | | | * agent/call-pinentry.c (do_getpin): New. (agent_askpin, agent_get_passphrase): Use do_getpin. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* agent: Clear bogus pinentry cache, when it causes an error.NIIBE Yutaka2019-01-283-21/+39
| | | | | | | | | | | | | | | | * agent/agent.h (PINENTRY_STATUS_*): Expose to public. (struct pin_entry_info_s): Add status. * agent/call-pinentry.c (agent_askpin): Clearing the ->status before the loop, let the assuan_transact set ->status. When failure with PINENTRY_STATUS_PASSWORD_FROM_CACHE, it returns soon. * agent/findkey.c (unprotect): Clear the pinentry cache, when it causes an error. -- GnuPG-bug-id: 4348 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* gpg: Move S2K encoding function to a shared file.Werner Koch2019-01-261-3/+1
| | | | | | | | | | | | | | | | * g10/passphrase.c (encode_s2k_iterations): Move function to ... * common/openpgp-s2k.c: new file. Remove default intialization code. * common/openpgpdefs.h (S2K_DECODE_COUNT): New to keep only one copy. * g10/call-agent.c (agent_get_s2k_count): Change to return the count and print an error. * agent/protect.c: Include openpgpdefs.h * g10/card-util.c (gen_kdf_data): Adjust for changes * g10/gpgcompose.c: Include call-agent.h. (sk_esk): Adjust for changes. * g10/passphrase (passphrase_to_dek): Adjust for changes. * g10/main.h (S2K_DECODE_COUNT): Remove macro. Signed-off-by: Werner Koch <wk@gnupg.org>
* agent: Support --mode=ssh option for CLEAR_PASSPHRASE.NIIBE Yutaka2019-01-251-8/+10
| | | | | | | | | * agent/command.c (cmd_clear_passphrase): Add support for SSH. -- GnuPG-bug-id: 4340 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* common: Extend function percent_data_escape.Werner Koch2019-01-241-1/+1
| | | | | | | | | | | | * common/percent.c (percent_data_escape): Add new args prefix and plus_escape. * agent/command.c (cmd_put_secret): Adjust for changed function * common/t-percent.c (test_percent_data_escape): Extend test for the prefix. (test_percent_data_escape_plus): new test for the plus escaping. Signed-off-by: Werner Koch <wk@gnupg.org>
* ssh: Simplify the curve name lookup.Werner Koch2019-01-171-84/+54
| | | | | | | | | | | | | | | | | | | | | * agent/command-ssh.c (struct ssh_key_type_spec): Add field alt_curve_name. (ssh_key_types): Add some alternate curve names. (ssh_identifier_from_curve_name): Lookup also bey alternative names and return the canonical name. (ssh_key_to_blob): Simplify the ECDSA case by using gcry_pk_get_curve instead of the explicit mapping. (ssh_receive_key): Likewise. Use ssh_identifier_from_curve_name to validate the curve name. Remove the reverse mapping because since GnuPG-2.2 Libgcrypt 1.7 is required. (ssh_handler_request_identities): Log an error message. -- This change will make it easier to support other curves, in particular those from tokens. Libgcrypt has a large list of alias names which we now use to to make the mapping more flexible. Signed-off-by: Werner Koch <wk@gnupg.org>
* agent: Make the S2K calibration time runtime configurabe.Werner Koch2018-12-113-7/+34
| | | | | | | | | | | | | | | | | | * agent/protect.c (s2k_calibration_time): New file global var. (calibrate_s2k_count): Use it here. (get_calibrated_s2k_count): Replace function static var by ... (s2k_calibrated_count): new file global var. (set_s2k_calibration_time): New function. * agent/gpg-agent.c (oS2KCalibration): New const. (opts): New option --s2k-calibration. (parse_rereadable_options): Parse that option. -- Note that using an unrelistic high value (like 60000) takes quite some time for calibration. GnuPG-bug-id: 3399 Signed-off-by: Werner Koch <wk@gnupg.org>
* scd: Add strerror to new error message.Werner Koch2018-11-301-1/+1
| | | | | | * agent/call-scd.c (wait_child_thread): Add %s. Signed-off-by: Werner Koch <wk@gnupg.org>
* agent: Better serialization for scdaemon access.NIIBE Yutaka2018-11-271-19/+16
| | | | | | | | | | | | | * agent/call-scd.c (unlock_scd): Move lock before accessing IN_USE. (wait_child_thread): Add log_info for Windows, and fixed log_error message. -- The old code is still valid with cooperate threads, but this is better. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* agent: Have a thread to wait for the child process of scdaemon.NIIBE Yutaka2018-11-263-89/+97
| | | | | | | | * agent/call-scd.c (wait_child_thread): New. (start_scd): Create a thread for wait_child_thread. (agent_scd_check_aliveness): Remove. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* agent: Defer calling assuan_release when it's still in use.NIIBE Yutaka2018-11-261-22/+40
| | | | | | | | | | * agent/call-scd.c (struct scd_local_s): Remove LOCK, introduce IN_USE and INVALID flags. (unlock_scd): Call assuan_release when CTX is invalid. (start_scd): Set IN_USE. (agent_scd_check_aliveness): Don't call assuan_release when it's in use. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* agent: Clean up SCDaemon management.NIIBE Yutaka2018-11-261-8/+1
| | | | | | | | * agent/call-scd.c (struct scd_local_s): Remove ctrl_backlink. (start_scd): Don't assign to the field. (agent_scd_check_aliveness): Fix typo in comment. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* agent: Simplify agent_popup_message_stop.NIIBE Yutaka2018-11-141-8/+0
| | | | | | | | | | | | | | | | | | | | | | * 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>
* po: Clarify a translator's note.Werner Koch2018-11-131-7/+9
| | | | --
* all: fix more spelling errorsDaniel Kahn Gillmor2018-10-251-3/+3
|
* all: fix spelling and typosDaniel Kahn Gillmor2018-10-245-7/+7
| | | | Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
* agent: Fix possible release of unitialize var in a genkey error case.Werner Koch2018-10-241-1/+1
| | | | | | | | * agent/command.c (cmd_genkey): Initialize 'value'. -- GnuPG-bug-id: 4222 Signed-off-by: Werner Koch <wk@gnupg.org>
* ssh: Fix possible infinite loop in case of an read error.Werner Koch2018-10-241-3/+4
| | | | | | | | | * 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>
* agent: Fix build regression for Windows.Werner Koch2018-10-222-8/+15
| | | | | | | | | | | | | * 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>
* agent: Fix message for ACK button.NIIBE Yutaka2018-10-121-13/+35
| | | | | | * agent/divert-scd.c (getpin_cb): Display correct message. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* agent: Support --ack option for POPUPPINPADPROMPT.NIIBE Yutaka2018-10-111-1/+1
| | | | | | | | | | | | | | | * 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>
* agent: Fix error code check from npth_mutex_init.NIIBE Yutaka2018-09-101-2/+6
| | | | | | | | | | | | | * 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>
* agent: New commands PUT_SECRET and GET_SECRET.Werner Koch2018-07-023-12/+237
| | | | | | | | | | | | | | | | | | | | * agent/agent.h (CACHE_MODE_DATA): New const. * agent/cache.c (DEF_CACHE_TTL_DATA): new. (housekeeping): Tweak for CACHE_MODE_DATA. (cache_mode_equal): Ditto. (agent_get_cache): Ditto. (agent_put_cache): Implement CACHE_MODE_DATA. * agent/command.c (MAXLEN_PUT_SECRET): New. (parse_ttl): New. (cmd_get_secret): New. (cmd_put_secret): New. (register_commands): Register new commands. -- These commands allow to store secrets in memory for the lifetime of the gpg-agent process. Signed-off-by: Werner Koch <wk@gnupg.org>
* agent: Fix segv running in --server modeWerner Koch2018-07-021-9/+14
| | | | | | | | | | | | * agent/command.c (start_command_handler): Do not write to CLIENT_CREDS after an error. -- assuan_get_peercred is special insofar that it returns a pointer into CTX. Writing data via this pointer should never be done. Fixes-commit: 28aa6890588cc108639951bb4bef03ac17743046 Signed-off-by: Werner Koch <wk@gnupg.org>
* agent: Add DBUS_SESSION_BUS_ADDRESS et al. to the startup list.Werner Koch2018-06-061-7/+7
| | | | | | | | | | | | | | | * agent/gpg-agent.c (agent_copy_startup_env): Replace explicit list with the standard list. -- Although the function agent_copy_startup_env is newer than session_env_list_stdenvnames the latter was not used. When DBUS_SESSION_BUS_ADDRESS was added to the latter it was forgotten to add it to the former as well. Having all stdnames here seems to be the Right Thing (tm) to do. GnuPG-bug-id: 3947 Signed-off-by: Werner Koch <wk@gnupg.org>
* Merge branch 'STABLE-BRANCH-2-2' into masterWerner Koch2018-05-131-0/+18
|\ | | | | | | | | | | | | | | | | | | -- Resolved Conflicts: NEWS - removed configure.ac - removed Signed-off-by: Werner Koch <wk@gnupg.org>
| * agent,dirmngr: Add "getenv" to the getinfo command.Werner Koch2018-04-121-0/+18
| | | | | | | | | | | | | | | | | | | | | | * agent/command.c (cmd_getinfo): Add sub-command getenv. * dirmngr/server.c (cmd_getinfo): Ditto. -- It is sometimes helpful to be able to inspect certain envvars in a running agent. For example "http_proxy". Signed-off-by: Werner Koch <wk@gnupg.org>
* | Merge branch 'STABLE-BRANCH-2-2' into masterWerner Koch2018-04-102-9/+41
|\| | | | | | | | | | | | | | | | | -- Fixed conflicts: NEWS - keep master configure.ac - merge g10/card-util.c - mostly 2.2 g10/sig-check.c - 2.2
| * agent: Improve the unknown ssh flag detection.Werner Koch2018-04-101-24/+31
| | | | | | | | | | | | | | | | * agent/command-ssh.c (ssh_handler_sign_request): Simplify detection of flags. -- Signed-off-by: Werner Koch <wk@gnupg.org>
| * agent: unknown flags on ssh signing requests cause an error.Daniel Kahn Gillmor2018-04-101-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * agent/command-ssh.c (ssh_handler_sign_request): if a flag is passed during an signature request that we do not know how to apply, return GPG_ERR_UNKNOWN_OPTION. -- https://tools.ietf.org/html/draft-miller-ssh-agent-02#section-4.5 says: If the agent does not support the requested flags, or is otherwise unable or unwilling to generate the signature (e.g. because it doesn't have the specified key, or the user refused confirmation of a constrained key), it must reply with a SSH_AGENT_FAILURE message. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net> GnuPG-bug-id: 3880
| * agent: change documentation reference for ssh-agent protocol.Daniel Kahn Gillmor2018-04-101-2/+4
| | | | | | | | | | | | | | | | | | | | * agent/command-ssh.c: repoint documentation reference. -- Damien Miller is now documenting the ssh-agent protocol via the IETF. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
| * agent: Support SSH signature flags.NIIBE Yutaka2018-04-061-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | * agent/command-ssh.c (SSH_AGENT_RSA_SHA2_256): New. (SSH_AGENT_RSA_SHA2_512): New. (ssh_handler_sign_request): Override SPEC when FLAGS is specified. -- GnuPG-bug-id: 3880 Reported-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net> Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
| * agent,scd: Use pointer to represent HANDLE.NIIBE Yutaka2018-03-271-2/+2
| | | | | | | | | | | | | | * agent/call-scd.c [HAVE_W32_SYSTEM] (start_scd): Format with %p. * scd/command.c [HAVE_W32_SYSTEM] (option_handler): Use void *. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* | Merge branch 'STABLE-BRANCH-2-2' into masterWerner Koch2018-03-278-43/+66
|\|