summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
12b9e82)
GUIs of Pageant and PuTTYgen. With that and the prompts_t redesign,
there should no longer be any limit on passphrase length other than
the patience of the user.
git-svn-id: svn://svn.tartarus.org/sgt/putty@9320
cda61777-01e9-0310-a592-
d414129be87e
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
-#define PASSPHRASE_MAXLEN 512
-
struct PassphraseProcStruct {
struct PassphraseProcStruct {
static int CALLBACK PassphraseProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
static int CALLBACK PassphraseProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
- static char *passphrase = NULL;
+ static char **passphrase = NULL;
struct PassphraseProcStruct *p;
switch (msg) {
struct PassphraseProcStruct *p;
switch (msg) {
passphrase = p->passphrase;
if (p->comment)
SetDlgItemText(hwnd, 101, p->comment);
passphrase = p->passphrase;
if (p->comment)
SetDlgItemText(hwnd, 101, p->comment);
- *passphrase = 0;
- SetDlgItemText(hwnd, 102, passphrase);
+ burnstr(*passphrase);
+ *passphrase = dupstr("");
+ SetDlgItemText(hwnd, 102, *passphrase);
return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
return 0;
case 102: /* edit box */
if ((HIWORD(wParam) == EN_CHANGE) && passphrase) {
return 0;
case 102: /* edit box */
if ((HIWORD(wParam) == EN_CHANGE) && passphrase) {
- GetDlgItemText(hwnd, 102, passphrase,
- PASSPHRASE_MAXLEN - 1);
- passphrase[PASSPHRASE_MAXLEN - 1] = '\0';
+ burnstr(*passphrase);
+ *passphrase = GetDlgItemText_alloc(hwnd, 102);
void load_key_file(HWND hwnd, struct MainDlgState *state,
Filename *filename, int was_import_cmd)
{
void load_key_file(HWND hwnd, struct MainDlgState *state,
Filename *filename, int was_import_cmd)
{
- char passphrase[PASSPHRASE_MAXLEN];
int needs_pass;
int type, realtype;
int ret;
const char *errmsg = NULL;
char *comment;
int needs_pass;
int type, realtype;
int ret;
const char *errmsg = NULL;
char *comment;
- struct PassphraseProcStruct pps;
struct RSAKey newkey1;
struct ssh2_userkey *newkey2 = NULL;
struct RSAKey newkey1;
struct ssh2_userkey *newkey2 = NULL;
if (realtype == SSH_KEYTYPE_SSH1)
needs_pass = rsakey_encrypted(filename, &comment);
else if (realtype == SSH_KEYTYPE_SSH2)
needs_pass = ssh2_userkey_encrypted(filename, &comment);
else
needs_pass = import_encrypted(filename, realtype, &comment);
if (realtype == SSH_KEYTYPE_SSH1)
needs_pass = rsakey_encrypted(filename, &comment);
else if (realtype == SSH_KEYTYPE_SSH2)
needs_pass = ssh2_userkey_encrypted(filename, &comment);
else
needs_pass = import_encrypted(filename, realtype, &comment);
- pps.passphrase = passphrase;
- pps.comment = comment;
+ burnstr(passphrase);
+ passphrase = NULL;
+
if (needs_pass) {
int dlgret;
if (needs_pass) {
int dlgret;
+ struct PassphraseProcStruct pps;
+ pps.passphrase = &passphrase;
+ pps.comment = comment;
dlgret = DialogBoxParam(hinst,
MAKEINTRESOURCE(210),
NULL, PassphraseProc,
dlgret = DialogBoxParam(hinst,
MAKEINTRESOURCE(210),
NULL, PassphraseProc,
+ assert(passphrase != NULL);
+ passphrase = dupstr("");
if (type == SSH_KEYTYPE_SSH1) {
if (realtype == type)
ret = loadrsakey(filename, &newkey1, passphrase, &errmsg);
if (type == SSH_KEYTYPE_SSH1) {
if (realtype == type)
ret = loadrsakey(filename, &newkey1, passphrase, &errmsg);
MB_OK | MB_ICONINFORMATION);
}
}
MB_OK | MB_ICONINFORMATION);
}
}
(struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (state->key_exists) {
char filename[FILENAME_MAX];
(struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (state->key_exists) {
char filename[FILENAME_MAX];
- char passphrase[PASSPHRASE_MAXLEN];
- char passphrase2[PASSPHRASE_MAXLEN];
+ char *passphrase, *passphrase2;
int type, realtype;
if (state->ssh2)
int type, realtype;
if (state->ssh2)
- GetDlgItemText(hwnd, IDC_PASSPHRASE1EDIT,
- passphrase, sizeof(passphrase));
- GetDlgItemText(hwnd, IDC_PASSPHRASE2EDIT,
- passphrase2, sizeof(passphrase2));
+ passphrase = GetDlgItemText_alloc(hwnd, IDC_PASSPHRASE1EDIT);
+ passphrase2 = GetDlgItemText_alloc(hwnd, IDC_PASSPHRASE2EDIT);
if (strcmp(passphrase, passphrase2)) {
MessageBox(hwnd,
"The two passphrases given do not match.",
"PuTTYgen Error", MB_OK | MB_ICONERROR);
if (strcmp(passphrase, passphrase2)) {
MessageBox(hwnd,
"The two passphrases given do not match.",
"PuTTYgen Error", MB_OK | MB_ICONERROR);
+ burnstr(passphrase);
+ burnstr(passphrase2);
if (!*passphrase) {
int ret;
ret = MessageBox(hwnd,
if (!*passphrase) {
int ret;
ret = MessageBox(hwnd,
"without a passphrase to protect it?",
"PuTTYgen Warning",
MB_YESNO | MB_ICONWARNING);
"without a passphrase to protect it?",
"PuTTYgen Warning",
MB_YESNO | MB_ICONWARNING);
- if (ret != IDYES)
- break;
+ if (ret != IDYES) {
+ burnstr(passphrase);
+ break;
+ }
}
if (prompt_keyfile(hwnd, "Save private key as:",
filename, 1, (type == realtype))) {
}
if (prompt_keyfile(hwnd, "Save private key as:",
filename, 1, (type == realtype))) {
ret = MessageBox(hwnd, buffer, "PuTTYgen Warning",
MB_YESNO | MB_ICONWARNING);
sfree(buffer);
ret = MessageBox(hwnd, buffer, "PuTTYgen Warning",
MB_YESNO | MB_ICONWARNING);
sfree(buffer);
+ if (ret != IDYES) {
+ burnstr(passphrase);
"PuTTYgen Error", MB_OK | MB_ICONERROR);
}
}
"PuTTYgen Error", MB_OK | MB_ICONERROR);
}
}
}
break;
case IDC_SAVEPUB:
}
break;
case IDC_SAVEPUB:
};
static int cmpkeys_ssh2_asymm(void *av, void *bv);
};
static int cmpkeys_ssh2_asymm(void *av, void *bv);
-#define PASSPHRASE_MAXLEN 512
-
struct PassphraseProcStruct {
struct PassphraseProcStruct {
static int CALLBACK PassphraseProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
static int CALLBACK PassphraseProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
- static char *passphrase = NULL;
+ static char **passphrase = NULL;
struct PassphraseProcStruct *p;
switch (msg) {
struct PassphraseProcStruct *p;
switch (msg) {
passphrase = p->passphrase;
if (p->comment)
SetDlgItemText(hwnd, 101, p->comment);
passphrase = p->passphrase;
if (p->comment)
SetDlgItemText(hwnd, 101, p->comment);
- *passphrase = 0;
- SetDlgItemText(hwnd, 102, passphrase);
+ burnstr(*passphrase);
+ *passphrase = dupstr("");
+ SetDlgItemText(hwnd, 102, *passphrase);
return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
return 0;
case 102: /* edit box */
if ((HIWORD(wParam) == EN_CHANGE) && passphrase) {
return 0;
case 102: /* edit box */
if ((HIWORD(wParam) == EN_CHANGE) && passphrase) {
- GetDlgItemText(hwnd, 102, passphrase,
- PASSPHRASE_MAXLEN - 1);
- passphrase[PASSPHRASE_MAXLEN - 1] = '\0';
+ burnstr(*passphrase);
+ *passphrase = GetDlgItemText_alloc(hwnd, 102);
*/
static void add_keyfile(Filename *filename)
{
*/
static void add_keyfile(Filename *filename)
{
- char passphrase[PASSPHRASE_MAXLEN];
struct RSAKey *rkey = NULL;
struct ssh2_userkey *skey = NULL;
int needs_pass;
struct RSAKey *rkey = NULL;
struct ssh2_userkey *skey = NULL;
int needs_pass;
int attempts;
char *comment;
const char *error = NULL;
int attempts;
char *comment;
const char *error = NULL;
- struct PassphraseProcStruct pps;
int type;
int original_pass;
int type;
int original_pass;
attempts = 0;
if (type == SSH_KEYTYPE_SSH1)
rkey = snew(struct RSAKey);
attempts = 0;
if (type == SSH_KEYTYPE_SSH1)
rkey = snew(struct RSAKey);
- pps.passphrase = passphrase;
- pps.comment = comment;
+ burnstr(passphrase);
+ passphrase = NULL;
+
if (needs_pass) {
/* try all the remembered passphrases first */
char *pp = index234(passphrases, attempts);
if(pp) {
if (needs_pass) {
/* try all the remembered passphrases first */
char *pp = index234(passphrases, attempts);
if(pp) {
- strcpy(passphrase, pp);
+ passphrase = dupstr(pp);
+ struct PassphraseProcStruct pps;
+
+ pps.passphrase = &passphrase;
+ pps.comment = comment;
+
original_pass = 1;
dlgret = DialogBoxParam(hinst, MAKEINTRESOURCE(210),
NULL, PassphraseProc, (LPARAM) &pps);
original_pass = 1;
dlgret = DialogBoxParam(hinst, MAKEINTRESOURCE(210),
NULL, PassphraseProc, (LPARAM) &pps);
sfree(rkey);
return; /* operation cancelled */
}
sfree(rkey);
return; /* operation cancelled */
}
+
+ assert(passphrase != NULL);
+ passphrase = dupstr("");
+
if (type == SSH_KEYTYPE_SSH1)
ret = loadrsakey(filename, rkey, passphrase, &error);
else {
if (type == SSH_KEYTYPE_SSH1)
ret = loadrsakey(filename, rkey, passphrase, &error);
else {
attempts++;
} while (ret == -1);
attempts++;
} while (ret == -1);
- /* if they typed in an ok passphrase, remember it */
if(original_pass && ret) {
if(original_pass && ret) {
- char *pp = dupstr(passphrase);
- addpos234(passphrases, pp, 0);
+ /* If they typed in an ok passphrase, remember it */
+ addpos234(passphrases, passphrase, 0);
+ } else {
+ /* Otherwise, destroy it */
+ burnstr(passphrase);
if (comment)
sfree(comment);
if (comment)
sfree(comment);