mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
pageant_get_keylist: use the new extended list if available.
Now the returned list of keys will have a flags word for each key, if the agent was willing to provide one.
This commit is contained in:
parent
39ec2837c8
commit
91c9caa3fe
66
pageant.c
66
pageant.c
@ -1805,6 +1805,7 @@ void pageant_forget_passphrases(void)
|
|||||||
|
|
||||||
typedef struct KeyListEntry {
|
typedef struct KeyListEntry {
|
||||||
ptrlen blob, comment;
|
ptrlen blob, comment;
|
||||||
|
uint32_t flags;
|
||||||
} KeyListEntry;
|
} KeyListEntry;
|
||||||
typedef struct KeyList {
|
typedef struct KeyList {
|
||||||
strbuf *raw_data;
|
strbuf *raw_data;
|
||||||
@ -1820,23 +1821,54 @@ static void keylist_free(KeyList *kl)
|
|||||||
sfree(kl);
|
sfree(kl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PageantClientOp *pageant_request_keylist_1(void)
|
||||||
|
{
|
||||||
|
PageantClientOp *pco = pageant_client_op_new();
|
||||||
|
put_byte(pco, SSH1_AGENTC_REQUEST_RSA_IDENTITIES);
|
||||||
|
if (pageant_client_op_query(pco) == SSH1_AGENT_RSA_IDENTITIES_ANSWER)
|
||||||
|
return pco;
|
||||||
|
pageant_client_op_free(pco);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PageantClientOp *pageant_request_keylist_2(void)
|
||||||
|
{
|
||||||
|
PageantClientOp *pco = pageant_client_op_new();
|
||||||
|
put_byte(pco, SSH2_AGENTC_REQUEST_IDENTITIES);
|
||||||
|
if (pageant_client_op_query(pco) == SSH2_AGENT_IDENTITIES_ANSWER)
|
||||||
|
return pco;
|
||||||
|
pageant_client_op_free(pco);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PageantClientOp *pageant_request_keylist_extended(void)
|
||||||
|
{
|
||||||
|
PageantClientOp *pco = pageant_client_op_new();
|
||||||
|
put_byte(pco, SSH2_AGENTC_EXTENSION);
|
||||||
|
put_stringpl(pco, extension_names[EXT_LIST_EXTENDED]);
|
||||||
|
if (pageant_client_op_query(pco) == SSH_AGENT_SUCCESS)
|
||||||
|
return pco;
|
||||||
|
pageant_client_op_free(pco);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static KeyList *pageant_get_keylist(unsigned ssh_version)
|
static KeyList *pageant_get_keylist(unsigned ssh_version)
|
||||||
{
|
{
|
||||||
static const unsigned char requests[] = {
|
PageantClientOp *pco;
|
||||||
0, SSH1_AGENTC_REQUEST_RSA_IDENTITIES, SSH2_AGENTC_REQUEST_IDENTITIES
|
bool list_is_extended = false;
|
||||||
}, responses[] = {
|
|
||||||
0, SSH1_AGENT_RSA_IDENTITIES_ANSWER, SSH2_AGENT_IDENTITIES_ANSWER
|
|
||||||
};
|
|
||||||
|
|
||||||
PageantClientOp *pco = pageant_client_op_new();
|
if (ssh_version == 1) {
|
||||||
put_byte(pco, requests[ssh_version]);
|
pco = pageant_request_keylist_1();
|
||||||
unsigned reply = pageant_client_op_query(pco);
|
} else {
|
||||||
|
if ((pco = pageant_request_keylist_extended()) != NULL)
|
||||||
if (reply != responses[ssh_version]) {
|
list_is_extended = true;
|
||||||
pageant_client_op_free(pco);
|
else
|
||||||
return NULL;
|
pco = pageant_request_keylist_2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pco)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
KeyList *kl = snew(KeyList);
|
KeyList *kl = snew(KeyList);
|
||||||
kl->nkeys = get_uint32(pco);
|
kl->nkeys = get_uint32(pco);
|
||||||
kl->keys = snewn(kl->nkeys, struct KeyListEntry);
|
kl->keys = snewn(kl->nkeys, struct KeyListEntry);
|
||||||
@ -1849,6 +1881,16 @@ static KeyList *pageant_get_keylist(unsigned ssh_version)
|
|||||||
kl->keys[i].blob = get_string(pco);
|
kl->keys[i].blob = get_string(pco);
|
||||||
}
|
}
|
||||||
kl->keys[i].comment = get_string(pco);
|
kl->keys[i].comment = get_string(pco);
|
||||||
|
|
||||||
|
if (list_is_extended) {
|
||||||
|
ptrlen key_ext_info = get_string(pco);
|
||||||
|
BinarySource src[1];
|
||||||
|
BinarySource_BARE_INIT_PL(src, key_ext_info);
|
||||||
|
|
||||||
|
kl->keys[i].flags = get_uint32(src);
|
||||||
|
} else {
|
||||||
|
kl->keys[i].flags = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kl->broken = get_err(pco);
|
kl->broken = get_err(pco);
|
||||||
|
Loading…
Reference in New Issue
Block a user