|
Lines 271-283
ask_filename(struct passwd *pw, const char *prompt)
Link Here
|
| 271 |
} |
271 |
} |
| 272 |
|
272 |
|
| 273 |
static struct sshkey * |
273 |
static struct sshkey * |
| 274 |
load_identity(char *filename) |
274 |
load_identity(char *filename, char **commentp) |
| 275 |
{ |
275 |
{ |
| 276 |
char *pass; |
276 |
char *pass; |
| 277 |
struct sshkey *prv; |
277 |
struct sshkey *prv; |
| 278 |
int r; |
278 |
int r; |
| 279 |
|
279 |
|
| 280 |
if ((r = sshkey_load_private(filename, "", &prv, NULL)) == 0) |
280 |
if (commentp != NULL) |
|
|
281 |
*commentp = NULL; |
| 282 |
if ((r = sshkey_load_private(filename, "", &prv, commentp)) == 0) |
| 281 |
return prv; |
283 |
return prv; |
| 282 |
if (r != SSH_ERR_KEY_WRONG_PASSPHRASE) |
284 |
if (r != SSH_ERR_KEY_WRONG_PASSPHRASE) |
| 283 |
fatal("Load key \"%s\": %s", filename, ssh_err(r)); |
285 |
fatal("Load key \"%s\": %s", filename, ssh_err(r)); |
|
Lines 285-291
load_identity(char *filename)
Link Here
|
| 285 |
pass = xstrdup(identity_passphrase); |
287 |
pass = xstrdup(identity_passphrase); |
| 286 |
else |
288 |
else |
| 287 |
pass = read_passphrase("Enter passphrase: ", RP_ALLOW_STDIN); |
289 |
pass = read_passphrase("Enter passphrase: ", RP_ALLOW_STDIN); |
| 288 |
r = sshkey_load_private(filename, pass, &prv, NULL); |
290 |
r = sshkey_load_private(filename, pass, &prv, commentp); |
| 289 |
explicit_bzero(pass, strlen(pass)); |
291 |
explicit_bzero(pass, strlen(pass)); |
| 290 |
free(pass); |
292 |
free(pass); |
| 291 |
if (r != 0) |
293 |
if (r != 0) |
|
Lines 379-385
do_convert_to(struct passwd *pw)
Link Here
|
| 379 |
if (stat(identity_file, &st) == -1) |
381 |
if (stat(identity_file, &st) == -1) |
| 380 |
fatal("%s: %s: %s", __progname, identity_file, strerror(errno)); |
382 |
fatal("%s: %s: %s", __progname, identity_file, strerror(errno)); |
| 381 |
if ((r = sshkey_load_public(identity_file, &k, NULL)) != 0) |
383 |
if ((r = sshkey_load_public(identity_file, &k, NULL)) != 0) |
| 382 |
k = load_identity(identity_file); |
384 |
k = load_identity(identity_file, NULL); |
| 383 |
switch (convert_format) { |
385 |
switch (convert_format) { |
| 384 |
case FMT_RFC4716: |
386 |
case FMT_RFC4716: |
| 385 |
do_convert_to_ssh2(pw, k); |
387 |
do_convert_to_ssh2(pw, k); |
|
Lines 752-767
do_print_public(struct passwd *pw)
Link Here
|
| 752 |
struct sshkey *prv; |
754 |
struct sshkey *prv; |
| 753 |
struct stat st; |
755 |
struct stat st; |
| 754 |
int r; |
756 |
int r; |
|
|
757 |
char *comment = NULL; |
| 755 |
|
758 |
|
| 756 |
if (!have_identity) |
759 |
if (!have_identity) |
| 757 |
ask_filename(pw, "Enter file in which the key is"); |
760 |
ask_filename(pw, "Enter file in which the key is"); |
| 758 |
if (stat(identity_file, &st) == -1) |
761 |
if (stat(identity_file, &st) == -1) |
| 759 |
fatal("%s: %s", identity_file, strerror(errno)); |
762 |
fatal("%s: %s", identity_file, strerror(errno)); |
| 760 |
prv = load_identity(identity_file); |
763 |
prv = load_identity(identity_file, &comment); |
| 761 |
if ((r = sshkey_write(prv, stdout)) != 0) |
764 |
if ((r = sshkey_write(prv, stdout)) != 0) |
| 762 |
error("sshkey_write failed: %s", ssh_err(r)); |
765 |
error("sshkey_write failed: %s", ssh_err(r)); |
| 763 |
sshkey_free(prv); |
766 |
sshkey_free(prv); |
|
|
767 |
if (comment != NULL && *comment != '\0') |
| 768 |
fprintf(stdout, " %s", comment); |
| 764 |
fprintf(stdout, "\n"); |
769 |
fprintf(stdout, "\n"); |
|
|
770 |
free(comment); |
| 765 |
exit(0); |
771 |
exit(0); |
| 766 |
} |
772 |
} |
| 767 |
|
773 |
|
|
Lines 1721-1727
do_ca_sign(struct passwd *pw, const char *ca_key_path, int prefer_agent,
Link Here
|
| 1721 |
ca->flags |= SSHKEY_FLAG_EXT; |
1727 |
ca->flags |= SSHKEY_FLAG_EXT; |
| 1722 |
} else { |
1728 |
} else { |
| 1723 |
/* CA key is assumed to be a private key on the filesystem */ |
1729 |
/* CA key is assumed to be a private key on the filesystem */ |
| 1724 |
ca = load_identity(tmp); |
1730 |
ca = load_identity(tmp, NULL); |
| 1725 |
} |
1731 |
} |
| 1726 |
free(tmp); |
1732 |
free(tmp); |
| 1727 |
|
1733 |
|