1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

pageant -a: upload an unencrypted key alongside an encrypted one.

Now, if you have a given key stored encrypted in your agent and you
say 'pageant -a [same key]' (without -E), Pageant will notice (via the
new extended key list request) that the key is currently encrypted in
the agent, and that you're trying to add it unencrypted. In this
situation it won't abort the attempt, and will try to add the key
anyway, so that it becomes decrypted in your agent.
This commit is contained in:
Simon Tatham 2020-12-15 13:46:39 +00:00
parent 1a8a6f76a4
commit da0dc28ab3

View File

@ -1975,12 +1975,29 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
} }
for (size_t i = 0; i < kl->nkeys; i++) { for (size_t i = 0; i < kl->nkeys; i++) {
/*
* If the key already exists in the agent, we're done
* ... *unless* it's encrypted in the agent and we're
* being asked to add it unencrypted, in which case we
* still want to upload the unencrypted version to
* cause the key to become decrypted.
*
* (Rationale: if you know in advance you're going to
* want it, and don't want to be interrupted at an
* unpredictable moment to be asked for the
* passphrase.)
*/
if (ptrlen_eq_ptrlen(ptrlen_from_strbuf(blob), if (ptrlen_eq_ptrlen(ptrlen_from_strbuf(blob),
kl->keys[i].blob)) { kl->keys[i].blob)) {
/* Key is already present; we can now leave. */ bool have_unencrypted =
keylist_free(kl); !(kl->keys[i].flags &
strbuf_free(blob); LIST_EXTENDED_FLAG_HAS_NO_CLEARTEXT_KEY);
return PAGEANT_ACTION_OK; if (have_unencrypted || add_encrypted) {
/* Key is already present; we can now leave. */
keylist_free(kl);
strbuf_free(blob);
return PAGEANT_ACTION_OK;
}
} }
} }