AGAIN. I really must stop doing that.
git-svn-id: svn://svn.tartarus.org/sgt/putty@1045
cda61777-01e9-0310-a592-
d414129be87e
#include <ctype.h>
#include <tchar.h>
#include <ctype.h>
#include <tchar.h>
-// FIXME
-#define DEBUG
-#ifdef DEBUG
-void dprintf(char *fmt, ...);
-#define debug(x) (dprintf x)
-#else
-#define debug(x)
-#endif
-
-
#include "ssh.h"
#include "tree234.h"
#include "ssh.h"
#include "tree234.h"
-debug(("ooh %d\n", __LINE__));
if (ver == 1)
needs_pass = rsakey_encrypted(filename, &comment);
else
needs_pass = ssh2_userkey_encrypted(filename, &comment);
if (ver == 1)
needs_pass = rsakey_encrypted(filename, &comment);
else
needs_pass = ssh2_userkey_encrypted(filename, &comment);
-debug(("ooh %d\n", __LINE__));
-debug(("ooh %d\n", __LINE__));
if (ver == 1)
rkey = smalloc(sizeof(*rkey));
if (ver == 1)
rkey = smalloc(sizeof(*rkey));
-debug(("ooh %d\n", __LINE__));
pps.passphrase = passphrase;
pps.comment = comment;
pps.passphrase = passphrase;
pps.comment = comment;
-debug(("ooh %d\n", __LINE__));
-debug(("ooh %d\n", __LINE__));
if (needs_pass) {
int dlgret;
dlgret = DialogBoxParam(instance, MAKEINTRESOURCE(210),
if (needs_pass) {
int dlgret;
dlgret = DialogBoxParam(instance, MAKEINTRESOURCE(210),
}
} else
*passphrase = '\0';
}
} else
*passphrase = '\0';
-debug(("ooh %d\n", __LINE__));
if (ver == 1)
ret = loadrsakey(filename, rkey, passphrase);
else {
if (ver == 1)
ret = loadrsakey(filename, rkey, passphrase);
else {
-debug(("ooh %d\n", __LINE__));
skey = ssh2_load_userkey(filename, passphrase);
skey = ssh2_load_userkey(filename, passphrase);
-debug(("ooh %d\n", __LINE__));
if (skey == SSH2_WRONG_PASSPHRASE)
ret = -1;
else if (!skey)
if (skey == SSH2_WRONG_PASSPHRASE)
ret = -1;
else if (!skey)
}
attempts++;
} while (ret == -1);
}
attempts++;
} while (ret == -1);
-debug(("ooh %d\n", __LINE__));
if (comment) sfree(comment);
if (comment) sfree(comment);
-debug(("ooh %d\n", __LINE__));
if (ret == 0) {
MessageBox(NULL, "Couldn't load private key.", APPNAME,
MB_OK | MB_ICONERROR);
if (ret == 0) {
MessageBox(NULL, "Couldn't load private key.", APPNAME,
MB_OK | MB_ICONERROR);
-debug(("ooh %d\n", __LINE__));
if (ver == 1) {
if (already_running) {
unsigned char *request, *response;
int reqlen, clen, resplen;
if (ver == 1) {
if (already_running) {
unsigned char *request, *response;
int reqlen, clen, resplen;
-debug(("ooh %d\n", __LINE__));
clen = strlen(rkey->comment);
clen = strlen(rkey->comment);
-debug(("ooh %d\n", __LINE__));
reqlen = 4 + 1 + /* length, message type */
4 + /* bit count */
reqlen = 4 + 1 + /* length, message type */
4 + /* bit count */
ssh1_bignum_length(rkey->q) +
4 + clen /* comment */
;
ssh1_bignum_length(rkey->q) +
4 + clen /* comment */
;
-debug(("ooh %d %d\n", __LINE__, reqlen));
request = smalloc(reqlen);
request = smalloc(reqlen);
-debug(("ooh %d\n", __LINE__));
-debug(("ooh %d\n", __LINE__));
request[4] = SSH1_AGENTC_ADD_RSA_IDENTITY;
request[4] = SSH1_AGENTC_ADD_RSA_IDENTITY;
-debug(("ooh %d\n", __LINE__));
reqlen = 5;
PUT_32BIT(request+reqlen, bignum_bitcount(rkey->modulus));
reqlen += 4;
reqlen = 5;
PUT_32BIT(request+reqlen, bignum_bitcount(rkey->modulus));
reqlen += 4;
reqlen += 4+clen;
PUT_32BIT(request, reqlen-4);
reqlen += 4+clen;
PUT_32BIT(request, reqlen-4);
-debug(("ooh %d\n", __LINE__));
agent_query(request, reqlen, &response, &resplen);
agent_query(request, reqlen, &response, &resplen);
-debug(("ooh %d\n", __LINE__));
if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS)
MessageBox(NULL, "The already running Pageant "
"refused to add the key.", APPNAME,
if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS)
MessageBox(NULL, "The already running Pageant "
"refused to add the key.", APPNAME,
if (already_running) {
unsigned char *request, *response;
int reqlen, alglen, clen, keybloblen, resplen;
if (already_running) {
unsigned char *request, *response;
int reqlen, alglen, clen, keybloblen, resplen;
-debug(("ooh %d\n", __LINE__));
alglen = strlen(skey->alg->name);
alglen = strlen(skey->alg->name);
-debug(("ooh %d\n", __LINE__));
clen = strlen(skey->comment);
clen = strlen(skey->comment);
-debug(("ooh %d\n", __LINE__));
-debug(("ooh %d\n", __LINE__));
keybloblen = skey->alg->openssh_fmtkey(skey->data, NULL, 0);
keybloblen = skey->alg->openssh_fmtkey(skey->data, NULL, 0);
-debug(("ooh %d\n", __LINE__));
-debug(("ooh %d\n", __LINE__));
reqlen = 4 + 1 + /* length, message type */
4 + alglen + /* algorithm name */
keybloblen + /* key data */
4 + clen /* comment */
;
reqlen = 4 + 1 + /* length, message type */
4 + alglen + /* algorithm name */
keybloblen + /* key data */
4 + clen /* comment */
;
-debug(("ooh %d\n", __LINE__));
-debug(("ooh %d\n", __LINE__));
request = smalloc(reqlen);
request = smalloc(reqlen);
-debug(("ooh %d\n", __LINE__));
request[4] = SSH2_AGENTC_ADD_IDENTITY;
request[4] = SSH2_AGENTC_ADD_IDENTITY;
-debug(("ooh %d\n", __LINE__));
-debug(("ooh %d\n", __LINE__));
PUT_32BIT(request+reqlen, alglen);
PUT_32BIT(request+reqlen, alglen);
-debug(("ooh %d\n", __LINE__));
-debug(("ooh %d\n", __LINE__));
memcpy(request+reqlen, skey->alg->name, alglen);
memcpy(request+reqlen, skey->alg->name, alglen);
-debug(("ooh %d\n", __LINE__));
-debug(("ooh %d\n", __LINE__));
reqlen += skey->alg->openssh_fmtkey(skey->data,
request+reqlen, keybloblen);
reqlen += skey->alg->openssh_fmtkey(skey->data,
request+reqlen, keybloblen);
-debug(("ooh %d\n", __LINE__));
PUT_32BIT(request+reqlen, clen);
PUT_32BIT(request+reqlen, clen);
-debug(("ooh %d\n", __LINE__));
memcpy(request+reqlen+4, skey->comment, clen);
memcpy(request+reqlen+4, skey->comment, clen);
-debug(("ooh %d\n", __LINE__));
PUT_32BIT(request, reqlen-4);
PUT_32BIT(request, reqlen-4);
-debug(("ooh %d\n", __LINE__));
reqlen += clen+4;
agent_query(request, reqlen, &response, &resplen);
reqlen += clen+4;
agent_query(request, reqlen, &response, &resplen);
-debug(("ooh %d\n", __LINE__));
if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS)
MessageBox(NULL, "The already running Pageant"
"refused to add the key.", APPNAME,
MB_OK | MB_ICONERROR);
if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS)
MessageBox(NULL, "The already running Pageant"
"refused to add the key.", APPNAME,
MB_OK | MB_ICONERROR);
-debug(("ooh %d\n", __LINE__));
} else {
if (add234(ssh2keys, skey) != skey) {
skey->alg->freekey(skey->data);
} else {
if (add234(ssh2keys, skey) != skey) {
skey->alg->freekey(skey->data);