version 1.109, 2014/02/02 03:44:31 |
version 1.110, 2014/06/24 01:13:21 |
|
|
#include "authfile.h" |
#include "authfile.h" |
#include "pathnames.h" |
#include "pathnames.h" |
#include "misc.h" |
#include "misc.h" |
|
#include "ssherr.h" |
|
|
/* argv0 */ |
/* argv0 */ |
extern char *__progname; |
extern char *__progname; |
|
|
Key *private, *cert; |
Key *private, *cert; |
char *comment = NULL; |
char *comment = NULL; |
char msg[1024], *certpath = NULL; |
char msg[1024], *certpath = NULL; |
int fd, perms_ok, ret = -1; |
int r, fd, perms_ok, ret = -1; |
Buffer keyblob; |
Buffer keyblob; |
|
|
if (strcmp(filename, "-") == 0) { |
if (strcmp(filename, "-") == 0) { |
|
|
close(fd); |
close(fd); |
|
|
/* At first, try empty passphrase */ |
/* At first, try empty passphrase */ |
private = key_parse_private(&keyblob, filename, "", &comment); |
if ((r = sshkey_parse_private_fileblob(&keyblob, filename, "", |
|
&private, &comment)) != 0 && r != SSH_ERR_KEY_WRONG_PASSPHRASE) |
|
fatal("Cannot parse %s: %s", filename, ssh_err(r)); |
if (comment == NULL) |
if (comment == NULL) |
comment = xstrdup(filename); |
comment = xstrdup(filename); |
/* try last */ |
/* try last */ |
if (private == NULL && pass != NULL) |
if (private == NULL && pass != NULL) { |
private = key_parse_private(&keyblob, filename, pass, NULL); |
if ((r = sshkey_parse_private_fileblob(&keyblob, filename, pass, |
|
&private, &comment)) != 0 && |
|
r != SSH_ERR_KEY_WRONG_PASSPHRASE) |
|
fatal("Cannot parse %s: %s", filename, ssh_err(r)); |
|
} |
if (private == NULL) { |
if (private == NULL) { |
/* clear passphrase since it did not work */ |
/* clear passphrase since it did not work */ |
clear_pass(); |
clear_pass(); |
|
|
buffer_free(&keyblob); |
buffer_free(&keyblob); |
return -1; |
return -1; |
} |
} |
private = key_parse_private(&keyblob, filename, pass, |
if ((r = sshkey_parse_private_fileblob(&keyblob, |
&comment); |
filename, pass, &private, &comment)) != 0 && |
|
r != SSH_ERR_KEY_WRONG_PASSPHRASE) |
|
fatal("Cannot parse %s: %s", |
|
filename, ssh_err(r)); |
if (private != NULL) |
if (private != NULL) |
break; |
break; |
clear_pass(); |
clear_pass(); |