aboutsummaryrefslogtreecommitdiffstats
path: root/g10/getkey.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2020-01-17 06:11:02 +0000
committerNIIBE Yutaka <[email protected]>2020-01-17 07:09:01 +0000
commit853d5b7677ea01f65c9bc5160cd8509b62f486f7 (patch)
tree848bb0adc423a9abbd67d716a641eb6b7849815f /g10/getkey.c
parentcard: Allow switching of cards and applications. (diff)
downloadgnupg-853d5b7677ea01f65c9bc5160cd8509b62f486f7.tar.gz
gnupg-853d5b7677ea01f65c9bc5160cd8509b62f486f7.zip
gpg: Prepare enhancement of agent_probe_secret_key.
* g10/call-agent.c (agent_probe_secret_key): Change semantics of return value. * g10/call-agent.h (agent_probe_secret_key): Change comment. * g10/delkey.c (do_delete_key): Follow the change. * g10/getkey.c (get_seckey, parse_def_secret_key): Likewise. (finish_lookup, have_secret_key_with_kid): Likewise. * g10/gpgv.c (agent_probe_secret_key): Likewise. * g10/keyedit.c (keyedit_menu, quick_find_keyblock): Likewise. (show_key_with_all_names_colon): Likewise. * g10/revoke.c (gen_desig_revoke, gen_revoke): Likewise * g10/test-stubs.c (agent_probe_secret_key): Likewise. -- GnuPG-bug-id: 3416 Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'g10/getkey.c')
-rw-r--r--g10/getkey.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/g10/getkey.c b/g10/getkey.c
index 3f1bd7e70..2e1c79a1a 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -610,9 +610,11 @@ get_seckey (ctrl_t ctrl, PKT_public_key *pk, u32 *keyid)
if (!err)
{
- err = agent_probe_secret_key (/*ctrl*/NULL, pk);
- if (err)
- release_public_key_parts (pk);
+ if (!agent_probe_secret_key (/*ctrl*/NULL, pk))
+ {
+ release_public_key_parts (pk);
+ err = gpg_error (GPG_ERR_NO_SECKEY);
+ }
}
return err;
@@ -1882,10 +1884,12 @@ parse_def_secret_key (ctrl_t ctrl)
continue;
}
- err = agent_probe_secret_key (ctrl, pk);
- if (! err)
- /* This is a valid key. */
- break;
+ if (agent_probe_secret_key (ctrl, pk))
+ {
+ /* This is a valid key. */
+ err = 0;
+ break;
+ }
}
while ((node = find_next_kbnode (node, PKT_PUBLIC_SUBKEY)));
@@ -3523,7 +3527,7 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact,
continue;
}
- if (want_secret && agent_probe_secret_key (NULL, pk))
+ if (want_secret && !agent_probe_secret_key (NULL, pk))
{
if (DBG_LOOKUP)
log_debug ("\tno secret key\n");
@@ -4219,7 +4223,7 @@ have_secret_key_with_kid (ctrl_t ctrl, u32 *keyid)
log_assert (node->pkt->pkttype == PKT_PUBLIC_KEY
|| node->pkt->pkttype == PKT_PUBLIC_SUBKEY);
- if (!agent_probe_secret_key (NULL, node->pkt->pkt.public_key))
+ if (agent_probe_secret_key (NULL, node->pkt->pkt.public_key))
result = 1; /* Secret key available. */
else
result = 0;