Browse Subversion Repository
Diff of /branches/ssh_chacha20poly1305/ttssh2/ttxssh/ttxssh.c
Parent Directory
| Revision Log
| Patch
| 94 |
|
|
| 95 |
static TInstVar FAR *pvar; |
static TInstVar FAR *pvar; |
| 96 |
|
|
| 97 |
|
typedef struct { |
| 98 |
|
int cnt; |
| 99 |
|
HWND dlg; |
| 100 |
|
enum hostkey_type type; |
| 101 |
|
} cbarg_t; |
| 102 |
|
|
| 103 |
/* WIN32 allows multiple instances of a DLL */ |
/* WIN32 allows multiple instances of a DLL */ |
| 104 |
static TInstVar InstVar; |
static TInstVar InstVar; |
| 105 |
|
|
| 2681 |
public_key.rsa = NULL; |
public_key.rsa = NULL; |
| 2682 |
} |
} |
| 2683 |
|
|
| 2684 |
|
static BOOL generate_ssh_key(enum hostkey_type type, int bits, void (*cbfunc)(int, int, void *), void *cbarg) |
|
static BOOL generate_ssh_key(enum hostkey_type type, int bits) |
|
| 2685 |
{ |
{ |
| 2686 |
// if SSH key already is generated, should free the resource. |
// if SSH key already is generated, should free the resource. |
| 2687 |
free_ssh_key(); |
free_ssh_key(); |
| 2691 |
RSA *pub = NULL; |
RSA *pub = NULL; |
| 2692 |
|
|
| 2693 |
// private key |
// private key |
| 2694 |
priv = RSA_generate_key(bits, 35, NULL, NULL); |
priv = RSA_generate_key(bits, 35, cbfunc, cbarg); |
| 2695 |
if (priv == NULL) |
if (priv == NULL) |
| 2696 |
goto error; |
goto error; |
| 2697 |
private_key.rsa = priv; |
private_key.rsa = priv; |
| 2714 |
DSA *pub = NULL; |
DSA *pub = NULL; |
| 2715 |
|
|
| 2716 |
// private key |
// private key |
| 2717 |
priv = DSA_generate_parameters(bits, NULL, 0, NULL, NULL, NULL, NULL); |
priv = DSA_generate_parameters(bits, NULL, 0, NULL, NULL, cbfunc, cbarg); |
| 2718 |
if (priv == NULL) |
if (priv == NULL) |
| 2719 |
goto error; |
goto error; |
| 2720 |
if (!DSA_generate_key(priv)) { |
if (!DSA_generate_key(priv)) { |
| 3163 |
return SSH_scp_transaction(pvar, remotefile, localfile, FROMREMOTE); |
return SSH_scp_transaction(pvar, remotefile, localfile, FROMREMOTE); |
| 3164 |
} |
} |
| 3165 |
|
|
| 3166 |
|
static void keygen_progress(int phase, int count, cbarg_t *cbarg) { |
| 3167 |
|
char buff[1024]; |
| 3168 |
|
static char msg[1024]; |
| 3169 |
|
|
| 3170 |
|
switch (phase) { |
| 3171 |
|
case 0: |
| 3172 |
|
if (count == 0) { |
| 3173 |
|
UTIL_get_lang_msg("MSG_KEYGEN_GENERATING", pvar, "generating key"); |
| 3174 |
|
strncpy_s(msg, sizeof(msg), pvar->ts->UIMsg, _TRUNCATE); |
| 3175 |
|
} |
| 3176 |
|
if (cbarg->type == KEY_DSA && count %10 != 0) { |
| 3177 |
|
return; |
| 3178 |
|
} |
| 3179 |
|
_snprintf_s(buff, sizeof(buff), _TRUNCATE, "%s %d/4 (%d)", msg, cbarg->cnt*2+1, count); |
| 3180 |
|
break; |
| 3181 |
|
case 1: |
| 3182 |
|
if (count < 0) { |
| 3183 |
|
return; |
| 3184 |
|
} |
| 3185 |
|
_snprintf_s(buff, sizeof(buff), _TRUNCATE, "%s %d/4 (%d)", msg, cbarg->cnt*2+2, count); |
| 3186 |
|
break; |
| 3187 |
|
case 2: |
| 3188 |
|
return; |
| 3189 |
|
break; |
| 3190 |
|
case 3: |
| 3191 |
|
if (count == 0) { |
| 3192 |
|
cbarg->cnt = 1; |
| 3193 |
|
return; |
| 3194 |
|
} |
| 3195 |
|
else { |
| 3196 |
|
UTIL_get_lang_msg("MSG_KEYGEN_GENERATED", pvar, "key generated"); |
| 3197 |
|
_snprintf_s(buff, sizeof(buff), _TRUNCATE, "%s", pvar->ts->UIMsg); |
| 3198 |
|
} |
| 3199 |
|
break; |
| 3200 |
|
default: |
| 3201 |
|
return; |
| 3202 |
|
} |
| 3203 |
|
|
| 3204 |
|
SetDlgItemText(cbarg->dlg, IDC_KEYGEN_PROGRESS_LABEL, buff); |
| 3205 |
|
return; |
| 3206 |
|
} |
| 3207 |
|
|
| 3208 |
static BOOL CALLBACK TTXKeyGenerator(HWND dlg, UINT msg, WPARAM wParam, |
static BOOL CALLBACK TTXKeyGenerator(HWND dlg, UINT msg, WPARAM wParam, |
| 3209 |
LPARAM lParam) |
LPARAM lParam) |
| 3257 |
SendDlgItemMessage(dlg, IDC_CONFIRM_LABEL, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
SendDlgItemMessage(dlg, IDC_CONFIRM_LABEL, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
| 3258 |
SendDlgItemMessage(dlg, IDC_KEY_EDIT, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
SendDlgItemMessage(dlg, IDC_KEY_EDIT, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
| 3259 |
SendDlgItemMessage(dlg, IDC_CONFIRM_EDIT, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
SendDlgItemMessage(dlg, IDC_CONFIRM_EDIT, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
| 3260 |
|
SendDlgItemMessage(dlg, IDC_KEYGEN_PROGRESS_LABEL, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
| 3261 |
SendDlgItemMessage(dlg, IDC_SAVE_PUBLIC_KEY, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
SendDlgItemMessage(dlg, IDC_SAVE_PUBLIC_KEY, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
| 3262 |
SendDlgItemMessage(dlg, IDC_SAVE_PRIVATE_KEY, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
SendDlgItemMessage(dlg, IDC_SAVE_PRIVATE_KEY, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
| 3263 |
SendDlgItemMessage(dlg, IDOK, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
SendDlgItemMessage(dlg, IDOK, WM_SETFONT, (WPARAM)DlgKeygenFont, MAKELPARAM(TRUE,0)); |
| 3291 |
case IDOK: // key generate button pressed |
case IDOK: // key generate button pressed |
| 3292 |
{ |
{ |
| 3293 |
int bits; |
int bits; |
| 3294 |
|
cbarg_t cbarg; |
| 3295 |
|
|
| 3296 |
|
cbarg.cnt = 0; |
| 3297 |
|
cbarg.type = key_type; |
| 3298 |
|
cbarg.dlg = dlg; |
| 3299 |
|
|
| 3300 |
// passphrase edit box disabled(default) |
// passphrase edit box disabled(default) |
| 3301 |
EnableWindow(GetDlgItem(dlg, IDC_KEY_EDIT), FALSE); |
EnableWindow(GetDlgItem(dlg, IDC_KEY_EDIT), FALSE); |
| 3315 |
return TRUE; |
return TRUE; |
| 3316 |
} |
} |
| 3317 |
|
|
| 3318 |
if (generate_ssh_key(key_type, bits)) { |
if (generate_ssh_key(key_type, bits, keygen_progress, &cbarg)) { |
| 3319 |
// passphrase edit box disabled(default) |
// passphrase edit box disabled(default) |
| 3320 |
EnableWindow(GetDlgItem(dlg, IDC_KEY_EDIT), TRUE); |
EnableWindow(GetDlgItem(dlg, IDC_KEY_EDIT), TRUE); |
| 3321 |
EnableWindow(GetDlgItem(dlg, IDC_CONFIRM_EDIT), TRUE); |
EnableWindow(GetDlgItem(dlg, IDC_CONFIRM_EDIT), TRUE); |
|
|
Legend:
| Removed from v.3200 |
|
| changed lines |
| |
Added in v.3201 |
|
|
| |