mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Unix Pageant: provide public-key extraction options.
I've decided against implementing an option exactly analogous to 'ssh-add -L' (printing the full public key of everything in the agent). Instead, you can identify a specific key to display in full, by any of the same means -d lets you use, and then print it in either of the public key formats we support.
This commit is contained in:
parent
8682246d33
commit
e533097e15
@ -1624,6 +1624,7 @@ int pageant_enum_keys(pageant_key_enum_fn_t callback, void *callback_ctx,
|
||||
p += n, keylistlen -= n;
|
||||
|
||||
cbkey.blob = rsa_public_blob(&rkey, &cbkey.bloblen);
|
||||
cbkey.comment = comment;
|
||||
cbkey.ssh_version = 1;
|
||||
callback(callback_ctx, fingerprint, comment, &cbkey);
|
||||
sfree(cbkey.blob);
|
||||
@ -1694,6 +1695,7 @@ int pageant_enum_keys(pageant_key_enum_fn_t callback, void *callback_ctx,
|
||||
p += n, keylistlen -= n;
|
||||
|
||||
cbkey.ssh_version = 2;
|
||||
cbkey.comment = comment;
|
||||
callback(callback_ctx, fingerprint, comment, &cbkey);
|
||||
sfree(fingerprint);
|
||||
sfree(comment);
|
||||
@ -1751,12 +1753,14 @@ struct pageant_pubkey *pageant_pubkey_copy(struct pageant_pubkey *key)
|
||||
ret->blob = snewn(key->bloblen, unsigned char);
|
||||
memcpy(ret->blob, key->blob, key->bloblen);
|
||||
ret->bloblen = key->bloblen;
|
||||
ret->comment = key->comment ? dupstr(key->comment) : NULL;
|
||||
ret->ssh_version = key->ssh_version;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void pageant_pubkey_free(struct pageant_pubkey *key)
|
||||
{
|
||||
sfree(key->comment);
|
||||
sfree(key->blob);
|
||||
sfree(key);
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ struct pageant_pubkey {
|
||||
* later */
|
||||
void *blob;
|
||||
int bloblen;
|
||||
char *comment;
|
||||
int ssh_version;
|
||||
};
|
||||
struct pageant_pubkey *pageant_pubkey_copy(struct pageant_pubkey *key);
|
||||
|
@ -240,7 +240,8 @@ typedef enum {
|
||||
KEYACT_CLIENT_DEL,
|
||||
KEYACT_CLIENT_DEL_ALL,
|
||||
KEYACT_CLIENT_LIST,
|
||||
KEYACT_CLIENT_LIST_FULL,
|
||||
KEYACT_CLIENT_PUBLIC_OPENSSH,
|
||||
KEYACT_CLIENT_PUBLIC
|
||||
} keyact;
|
||||
struct cmdline_key_action {
|
||||
struct cmdline_key_action *next;
|
||||
@ -564,8 +565,34 @@ void run_client(void)
|
||||
if (key)
|
||||
pageant_pubkey_free(key);
|
||||
break;
|
||||
case KEYACT_CLIENT_PUBLIC_OPENSSH:
|
||||
case KEYACT_CLIENT_PUBLIC:
|
||||
key = NULL;
|
||||
if (!(key = find_key(act->filename, &retstr))) {
|
||||
fprintf(stderr, "pageant: finding key '%s': %s\n",
|
||||
act->filename, retstr);
|
||||
sfree(retstr);
|
||||
errors = TRUE;
|
||||
} else {
|
||||
FILE *fp = stdout; /* FIXME: add a -o option? */
|
||||
|
||||
if (key->ssh_version == 1) {
|
||||
struct RSAKey rkey;
|
||||
memset(&rkey, 0, sizeof(rkey));
|
||||
rkey.comment = dupstr(key->comment);
|
||||
makekey(key->blob, key->bloblen, &rkey, NULL, 0);
|
||||
ssh1_write_pubkey(fp, &rkey);
|
||||
freersakey(&rkey);
|
||||
} else {
|
||||
ssh2_write_pubkey(fp, key->comment, key->blob,key->bloblen,
|
||||
(act->action == KEYACT_CLIENT_PUBLIC ?
|
||||
SSH_KEYTYPE_SSH2_PUBLIC_RFC4716 :
|
||||
SSH_KEYTYPE_SSH2_PUBLIC_OPENSSH));
|
||||
}
|
||||
pageant_pubkey_free(key);
|
||||
}
|
||||
break;
|
||||
case KEYACT_CLIENT_DEL_ALL:
|
||||
case KEYACT_CLIENT_LIST_FULL:
|
||||
fprintf(stderr, "NYI\n");
|
||||
errors = TRUE;
|
||||
break;
|
||||
@ -892,8 +919,10 @@ int main(int argc, char **argv)
|
||||
add_keyact(KEYACT_CLIENT_DEL_ALL, NULL);
|
||||
} else if (!strcmp(p, "-l")) {
|
||||
add_keyact(KEYACT_CLIENT_LIST, NULL);
|
||||
} else if (!strcmp(p, "-L")) {
|
||||
add_keyact(KEYACT_CLIENT_LIST_FULL, NULL);
|
||||
} else if (!strcmp(p, "--public")) {
|
||||
curr_keyact = KEYACT_CLIENT_PUBLIC;
|
||||
} else if (!strcmp(p, "--public-openssh")) {
|
||||
curr_keyact = KEYACT_CLIENT_PUBLIC_OPENSSH;
|
||||
} else if (!strcmp(p, "-X")) {
|
||||
life = LIFE_X11;
|
||||
} else if (!strcmp(p, "-T")) {
|
||||
|
Loading…
Reference in New Issue
Block a user