version 1.340, 2019/08/08 08:02:57 |
version 1.341, 2019/09/01 23:47:32 |
|
|
} |
} |
|
|
static struct sshkey * |
static struct sshkey * |
load_identity(char *filename) |
load_identity(char *filename, char **commentp) |
{ |
{ |
char *pass; |
char *pass; |
struct sshkey *prv; |
struct sshkey *prv; |
int r; |
int r; |
|
|
if ((r = sshkey_load_private(filename, "", &prv, NULL)) == 0) |
if (commentp != NULL) |
|
*commentp = NULL; |
|
if ((r = sshkey_load_private(filename, "", &prv, commentp)) == 0) |
return prv; |
return prv; |
if (r != SSH_ERR_KEY_WRONG_PASSPHRASE) |
if (r != SSH_ERR_KEY_WRONG_PASSPHRASE) |
fatal("Load key \"%s\": %s", filename, ssh_err(r)); |
fatal("Load key \"%s\": %s", filename, ssh_err(r)); |
|
|
pass = xstrdup(identity_passphrase); |
pass = xstrdup(identity_passphrase); |
else |
else |
pass = read_passphrase("Enter passphrase: ", RP_ALLOW_STDIN); |
pass = read_passphrase("Enter passphrase: ", RP_ALLOW_STDIN); |
r = sshkey_load_private(filename, pass, &prv, NULL); |
r = sshkey_load_private(filename, pass, &prv, commentp); |
explicit_bzero(pass, strlen(pass)); |
explicit_bzero(pass, strlen(pass)); |
free(pass); |
free(pass); |
if (r != 0) |
if (r != 0) |
|
|
if (stat(identity_file, &st) == -1) |
if (stat(identity_file, &st) == -1) |
fatal("%s: %s: %s", __progname, identity_file, strerror(errno)); |
fatal("%s: %s: %s", __progname, identity_file, strerror(errno)); |
if ((r = sshkey_load_public(identity_file, &k, NULL)) != 0) |
if ((r = sshkey_load_public(identity_file, &k, NULL)) != 0) |
k = load_identity(identity_file); |
k = load_identity(identity_file, NULL); |
switch (convert_format) { |
switch (convert_format) { |
case FMT_RFC4716: |
case FMT_RFC4716: |
do_convert_to_ssh2(pw, k); |
do_convert_to_ssh2(pw, k); |
|
|
struct sshkey *prv; |
struct sshkey *prv; |
struct stat st; |
struct stat st; |
int r; |
int r; |
|
char *comment = NULL; |
|
|
if (!have_identity) |
if (!have_identity) |
ask_filename(pw, "Enter file in which the key is"); |
ask_filename(pw, "Enter file in which the key is"); |
if (stat(identity_file, &st) == -1) |
if (stat(identity_file, &st) == -1) |
fatal("%s: %s", identity_file, strerror(errno)); |
fatal("%s: %s", identity_file, strerror(errno)); |
prv = load_identity(identity_file); |
prv = load_identity(identity_file, &comment); |
if ((r = sshkey_write(prv, stdout)) != 0) |
if ((r = sshkey_write(prv, stdout)) != 0) |
error("sshkey_write failed: %s", ssh_err(r)); |
error("sshkey_write failed: %s", ssh_err(r)); |
sshkey_free(prv); |
sshkey_free(prv); |
|
if (comment != NULL && *comment != '\0') |
|
fprintf(stdout, " %s", comment); |
fprintf(stdout, "\n"); |
fprintf(stdout, "\n"); |
|
free(comment); |
exit(0); |
exit(0); |
} |
} |
|
|
|
|
ca->flags |= SSHKEY_FLAG_EXT; |
ca->flags |= SSHKEY_FLAG_EXT; |
} else { |
} else { |
/* CA key is assumed to be a private key on the filesystem */ |
/* CA key is assumed to be a private key on the filesystem */ |
ca = load_identity(tmp); |
ca = load_identity(tmp, NULL); |
} |
} |
free(tmp); |
free(tmp); |
|
|