mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-14 17:47:33 -05:00
Work towards wish `keyfile-diagnostic'. Many sshpubk.c keyfile-loading
functions have sprouted `**errorstr' arguments, which if non-NULL can return a textual error message. The interface additions are patchy and ad-hoc since this seemed to suit the style of the existing interfaces. I've since realised that most of this is masked by sanity-checking that gets done before these functions are called, but it will at least report MAC failures and the like (tested on Unix), which was the original point of the exercise. Note that not everyone who could be using this information is at the moment. [originally from svn r3430]
This commit is contained in:
23
ssh.c
23
ssh.c
@ -2602,7 +2602,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
||||
/* Load the public half of ssh->cfg.keyfile so we notice if it's in Pageant */
|
||||
if (!filename_is_null(ssh->cfg.keyfile)) {
|
||||
if (!rsakey_pubblob(&ssh->cfg.keyfile,
|
||||
&s->publickey_blob, &s->publickey_bloblen))
|
||||
&s->publickey_blob, &s->publickey_bloblen, NULL))
|
||||
s->publickey_blob = NULL;
|
||||
} else
|
||||
s->publickey_blob = NULL;
|
||||
@ -2888,11 +2888,15 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
||||
s->tried_publickey = 1;
|
||||
|
||||
{
|
||||
int ret = loadrsakey(&ssh->cfg.keyfile, &s->key, s->password);
|
||||
const char *error = NULL;
|
||||
int ret = loadrsakey(&ssh->cfg.keyfile, &s->key, s->password,
|
||||
&error);
|
||||
if (ret == 0) {
|
||||
c_write_str(ssh, "Couldn't load private key from ");
|
||||
c_write_str(ssh, filename_to_str(&ssh->cfg.keyfile));
|
||||
c_write_str(ssh, ".\r\n");
|
||||
c_write_str(ssh, " (");
|
||||
c_write_str(ssh, error);
|
||||
c_write_str(ssh, ").\r\n");
|
||||
continue; /* go and try password */
|
||||
}
|
||||
if (ret == -1) {
|
||||
@ -4586,7 +4590,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
||||
if (keytype == SSH_KEYTYPE_SSH2) {
|
||||
s->publickey_blob =
|
||||
ssh2_userkey_loadpub(&ssh->cfg.keyfile, NULL,
|
||||
&s->publickey_bloblen);
|
||||
&s->publickey_bloblen, NULL);
|
||||
} else {
|
||||
char *msgbuf;
|
||||
logeventf(ssh, "Unable to use this key file (%s)",
|
||||
@ -4916,7 +4920,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
||||
pub_blob =
|
||||
(unsigned char *)ssh2_userkey_loadpub(&ssh->cfg.keyfile,
|
||||
&algorithm,
|
||||
&pub_blob_len);
|
||||
&pub_blob_len,
|
||||
NULL);
|
||||
if (pub_blob) {
|
||||
ssh2_pkt_init(ssh, SSH2_MSG_USERAUTH_REQUEST);
|
||||
ssh2_pkt_addstring(ssh, s->username);
|
||||
@ -5093,14 +5098,18 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
|
||||
* We have our passphrase. Now try the actual authentication.
|
||||
*/
|
||||
struct ssh2_userkey *key;
|
||||
const char *error = NULL;
|
||||
|
||||
key = ssh2_load_userkey(&ssh->cfg.keyfile, s->password);
|
||||
key = ssh2_load_userkey(&ssh->cfg.keyfile, s->password,
|
||||
&error);
|
||||
if (key == SSH2_WRONG_PASSPHRASE || key == NULL) {
|
||||
if (key == SSH2_WRONG_PASSPHRASE) {
|
||||
c_write_str(ssh, "Wrong passphrase\r\n");
|
||||
s->tried_pubkey_config = FALSE;
|
||||
} else {
|
||||
c_write_str(ssh, "Unable to load private key\r\n");
|
||||
c_write_str(ssh, "Unable to load private key (");
|
||||
c_write_str(ssh, error);
|
||||
c_write_str(ssh, ")\r\n");
|
||||
s->tried_pubkey_config = TRUE;
|
||||
}
|
||||
/* Send a spurious AUTH_NONE to return to the top. */
|
||||
|
Reference in New Issue
Block a user