2 * PuTTY key generation front end.
11 #define PUTTY_DO_GLOBALS
17 #define WM_DONEKEY (WM_XUSER + 1)
19 #define DEFAULT_KEYSIZE 1024
21 /* ----------------------------------------------------------------------
22 * Progress report code. This is really horrible :-)
24 #define PHASE1TOTAL 0x10000
25 #define PHASE2TOTAL 0x10000
26 #define PHASE3TOTAL 0x04000
28 #define PHASE2START (PHASE1TOTAL)
29 #define PHASE3START (PHASE1TOTAL + PHASE2TOTAL)
30 #define TOTALTOTAL (PHASE1TOTAL + PHASE2TOTAL + PHASE3TOTAL)
31 #define PROGRESSBIGRANGE 65535
32 #define DIVISOR ((TOTALTOTAL + PROGRESSBIGRANGE - 1) / PROGRESSBIGRANGE)
33 #define PROGRESSRANGE (TOTALTOTAL / DIVISOR)
35 unsigned phase1param, phase1current, phase1n;
36 unsigned phase2param, phase2current, phase2n;
41 static void progress_update(void *param, int phase, int iprogress)
43 struct progress *p = (struct progress *) param;
44 unsigned progress = iprogress;
49 p->phase1param = 0x10000 + progress;
50 p->phase1current = 0x10000;
54 p->phase2param = 0x10000 + progress;
55 p->phase2current = 0x10000;
59 p->phase3mult = PHASE3TOTAL / progress;
62 while (p->phase1n < progress) {
64 p->phase1current *= p->phase1param;
65 p->phase1current /= 0x10000;
67 position = PHASE1START + 0x10000 - p->phase1current;
70 while (p->phase2n < progress) {
72 p->phase2current *= p->phase2param;
73 p->phase2current /= 0x10000;
75 position = PHASE2START + 0x10000 - p->phase2current;
78 position = PHASE3START + progress * p->phase3mult;
82 SendMessage(p->progbar, PBM_SETPOS, position / DIVISOR, 0);
87 #define PASSPHRASE_MAXLEN 512
89 struct PassphraseProcStruct {
95 * Dialog-box function for the passphrase box.
97 static int CALLBACK PassphraseProc(HWND hwnd, UINT msg,
98 WPARAM wParam, LPARAM lParam)
100 static char *passphrase = NULL;
101 struct PassphraseProcStruct *p;
105 SetForegroundWindow(hwnd);
106 SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
107 SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
112 { /* centre the window */
116 hw = GetDesktopWindow();
117 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
119 (rs.right + rs.left + rd.left - rd.right) / 2,
120 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
121 rd.right - rd.left, rd.bottom - rd.top, TRUE);
124 p = (struct PassphraseProcStruct *) lParam;
125 passphrase = p->passphrase;
127 SetDlgItemText(hwnd, 101, p->comment);
129 SetDlgItemText(hwnd, 102, passphrase);
132 switch (LOWORD(wParam)) {
142 case 102: /* edit box */
143 if ((HIWORD(wParam) == EN_CHANGE) && passphrase) {
144 GetDlgItemText(hwnd, 102, passphrase,
145 PASSPHRASE_MAXLEN - 1);
146 passphrase[PASSPHRASE_MAXLEN - 1] = '\0';
159 * Prompt for a key file. Assumes the filename buffer is of size
162 static int prompt_keyfile(HWND hwnd, char *dlgtitle,
163 char *filename, int save)
166 memset(&of, 0, sizeof(of));
167 #ifdef OPENFILENAME_SIZE_VERSION_400
168 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
170 of.lStructSize = sizeof(of);
173 of.lpstrFilter = "All Files\0*\0\0\0";
174 of.lpstrCustomFilter = NULL;
176 of.lpstrFile = filename;
178 of.nMaxFile = FILENAME_MAX;
179 of.lpstrFileTitle = NULL;
180 of.lpstrInitialDir = NULL;
181 of.lpstrTitle = dlgtitle;
184 return GetSaveFileName(&of);
186 return GetOpenFileName(&of);
190 * This function is needed to link with the DES code. We need not
191 * have it do anything at all.
193 void logevent(char *msg)
198 * Dialog-box function for the Licence box.
200 static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
201 WPARAM wParam, LPARAM lParam)
208 { /* centre the window */
212 hw = GetDesktopWindow();
213 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
215 (rs.right + rs.left + rd.left - rd.right) / 2,
216 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
217 rd.right - rd.left, rd.bottom - rd.top, TRUE);
222 switch (LOWORD(wParam)) {
236 * Dialog-box function for the About box.
238 static int CALLBACK AboutProc(HWND hwnd, UINT msg,
239 WPARAM wParam, LPARAM lParam)
246 { /* centre the window */
250 hw = GetDesktopWindow();
251 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
253 (rs.right + rs.left + rd.left - rd.right) / 2,
254 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
255 rd.right - rd.left, rd.bottom - rd.top, TRUE);
258 SetDlgItemText(hwnd, 100, ver);
261 switch (LOWORD(wParam)) {
266 EnableWindow(hwnd, 0);
267 DialogBox(hinst, MAKEINTRESOURCE(214), NULL, LicenceProc);
268 EnableWindow(hwnd, 1);
269 SetActiveWindow(hwnd);
281 * Thread to generate a key.
283 struct rsa_key_thread_params {
284 HWND progressbar; /* notify this with progress */
285 HWND dialog; /* notify this on completion */
286 int keysize; /* bits in key */
289 static DWORD WINAPI generate_rsa_key_thread(void *param)
291 struct rsa_key_thread_params *params =
292 (struct rsa_key_thread_params *) param;
293 struct progress prog;
294 prog.progbar = params->progressbar;
296 rsa_generate(params->key, params->keysize, progress_update, &prog);
298 PostMessage(params->dialog, WM_DONEKEY, 0, 0);
304 struct MainDlgState {
305 int collecting_entropy;
306 int generation_thread_exists;
308 int entropy_got, entropy_required, entropy_size;
311 char **commentptr; /* points to key.comment or ssh2key.comment */
312 struct ssh2_userkey ssh2key;
317 static void hidemany(HWND hwnd, const int *ids, int hideit)
320 ShowWindow(GetDlgItem(hwnd, *ids++), (hideit ? SW_HIDE : SW_SHOW));
324 static void setupbigedit1(HWND hwnd, int id, struct RSAKey *key)
329 dec1 = bignum_decimal(key->exponent);
330 dec2 = bignum_decimal(key->modulus);
331 buffer = smalloc(strlen(dec1) + strlen(dec2) +
332 strlen(key->comment) + 30);
333 sprintf(buffer, "%d %s %s %s",
334 bignum_bitcount(key->modulus), dec1, dec2, key->comment);
335 SetDlgItemText(hwnd, id, buffer);
341 static void setupbigedit2(HWND hwnd, int id, struct ssh2_userkey *key)
343 unsigned char *pub_blob;
348 pub_blob = key->alg->public_blob(key->data, &pub_len);
349 buffer = smalloc(strlen(key->alg->name) + 4 * ((pub_len + 2) / 3) +
350 strlen(key->comment) + 3);
351 strcpy(buffer, key->alg->name);
352 p = buffer + strlen(buffer);
355 while (i < pub_len) {
356 int n = (pub_len - i < 3 ? pub_len - i : 3);
357 base64_encode_atom(pub_blob + i, n, p);
362 strcpy(p, key->comment);
363 SetDlgItemText(hwnd, id, buffer);
369 * Dialog-box function for the main PuTTYgen dialog box.
371 static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
372 WPARAM wParam, LPARAM lParam)
375 controlidstart = 100,
381 IDC_PKSTATIC, IDC_KEYDISPLAY,
382 IDC_FPSTATIC, IDC_FINGERPRINT,
383 IDC_COMMENTSTATIC, IDC_COMMENTEDIT,
384 IDC_PASSPHRASE1STATIC, IDC_PASSPHRASE1EDIT,
385 IDC_PASSPHRASE2STATIC, IDC_PASSPHRASE2EDIT,
387 IDC_GENSTATIC, IDC_GENERATE,
388 IDC_LOADSTATIC, IDC_LOAD,
389 IDC_SAVESTATIC, IDC_SAVE,
391 IDC_TYPESTATIC, IDC_KEYSSH1, IDC_KEYSSH2RSA,
392 IDC_BITSSTATIC, IDC_BITS,
395 static const int nokey_ids[] = { IDC_NOKEY, 0 };
396 static const int generating_ids[] =
397 { IDC_GENERATING, IDC_PROGRESS, 0 };
398 static const int gotkey_ids[] = {
399 IDC_PKSTATIC, IDC_KEYDISPLAY,
400 IDC_FPSTATIC, IDC_FINGERPRINT,
401 IDC_COMMENTSTATIC, IDC_COMMENTEDIT,
402 IDC_PASSPHRASE1STATIC, IDC_PASSPHRASE1EDIT,
403 IDC_PASSPHRASE2STATIC, IDC_PASSPHRASE2EDIT, 0
405 static const char generating_msg[] =
406 "Please wait while a key is generated...";
407 static const char entropy_msg[] =
408 "Please generate some randomness by moving the mouse over the blank area.";
409 struct MainDlgState *state;
416 { /* centre the window */
420 hw = GetDesktopWindow();
421 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
423 (rs.right + rs.left + rd.left - rd.right) / 2,
424 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
425 rd.right - rd.left, rd.bottom - rd.top, TRUE);
428 state = smalloc(sizeof(*state));
429 state->generation_thread_exists = FALSE;
430 state->collecting_entropy = FALSE;
431 state->entropy = NULL;
432 state->key_exists = FALSE;
433 SetWindowLong(hwnd, GWL_USERDATA, (LONG) state);
435 struct ctlpos cp, cp2;
437 /* Accelerators used: acglops */
439 ctlposinit(&cp, hwnd, 10, 10, 10);
440 bartitle(&cp, "Public and private key generation for PuTTY",
442 beginbox(&cp, "Key", IDC_BOX_KEY);
444 statictext(&cp2, "No key.", IDC_NOKEY);
446 statictext(&cp2, "", IDC_GENERATING);
447 progressbar(&cp2, IDC_PROGRESS);
449 "&Public key for pasting into authorized_keys file:",
450 IDC_PKSTATIC, IDC_KEYDISPLAY, 7);
451 SendDlgItemMessage(hwnd, IDC_KEYDISPLAY, EM_SETREADONLY, 1, 0);
452 staticedit(&cp, "Key fingerprint:", IDC_FPSTATIC,
453 IDC_FINGERPRINT, 75);
454 SendDlgItemMessage(hwnd, IDC_FINGERPRINT, EM_SETREADONLY, 1,
456 staticedit(&cp, "Key &comment:", IDC_COMMENTSTATIC,
457 IDC_COMMENTEDIT, 75);
458 staticpassedit(&cp, "Key p&assphrase:", IDC_PASSPHRASE1STATIC,
459 IDC_PASSPHRASE1EDIT, 75);
460 staticpassedit(&cp, "C&onfirm passphrase:",
461 IDC_PASSPHRASE2STATIC, IDC_PASSPHRASE2EDIT, 75);
463 beginbox(&cp, "Actions", IDC_BOX_ACTIONS);
464 staticbtn(&cp, "Generate a public/private key pair",
465 IDC_GENSTATIC, "&Generate", IDC_GENERATE);
466 staticbtn(&cp, "Load an existing private key file",
467 IDC_LOADSTATIC, "&Load", IDC_LOAD);
468 staticbtn(&cp, "Save the generated key to a new file",
469 IDC_SAVESTATIC, "&Save", IDC_SAVE);
471 beginbox(&cp, "Parameters", IDC_BOX_PARAMS);
472 radioline(&cp, "Type of key to generate:", IDC_TYPESTATIC, 2,
473 "SSH&1 (RSA)", IDC_KEYSSH1,
474 "SSH2 &RSA", IDC_KEYSSH2RSA, NULL);
475 staticedit(&cp, "Number of &bits in a generated key:",
476 IDC_BITSSTATIC, IDC_BITS, 20);
479 CheckRadioButton(hwnd, IDC_KEYSSH1, IDC_KEYSSH2RSA, IDC_KEYSSH1);
480 SetDlgItemInt(hwnd, IDC_BITS, DEFAULT_KEYSIZE, FALSE);
483 * Initially, hide the progress bar and the key display,
484 * and show the no-key display. Also disable the Save
485 * button, because with no key we obviously can't save
488 hidemany(hwnd, nokey_ids, FALSE);
489 hidemany(hwnd, generating_ids, TRUE);
490 hidemany(hwnd, gotkey_ids, TRUE);
491 EnableWindow(GetDlgItem(hwnd, IDC_SAVE), 0);
495 state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA);
496 if (state->collecting_entropy &&
497 state->entropy && state->entropy_got < state->entropy_required) {
498 state->entropy[state->entropy_got++] = lParam;
499 state->entropy[state->entropy_got++] = GetMessageTime();
500 SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS,
501 state->entropy_got, 0);
502 if (state->entropy_got >= state->entropy_required) {
503 struct rsa_key_thread_params *params;
507 * Seed the entropy pool
509 random_add_heavynoise(state->entropy, state->entropy_size);
510 memset(state->entropy, 0, state->entropy_size);
511 sfree(state->entropy);
512 state->collecting_entropy = FALSE;
514 SetDlgItemText(hwnd, IDC_GENERATING, generating_msg);
515 SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0,
516 MAKELPARAM(0, PROGRESSRANGE));
517 SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, 0, 0);
519 params = smalloc(sizeof(*params));
520 params->progressbar = GetDlgItem(hwnd, IDC_PROGRESS);
521 params->dialog = hwnd;
522 params->keysize = state->keysize;
523 params->key = &state->key;
525 if (!CreateThread(NULL, 0, generate_rsa_key_thread,
526 params, 0, &threadid)) {
527 MessageBox(hwnd, "Out of thread resources",
528 "Key generation error",
529 MB_OK | MB_ICONERROR);
532 state->generation_thread_exists = TRUE;
538 switch (LOWORD(wParam)) {
539 case IDC_COMMENTEDIT:
540 if (HIWORD(wParam) == EN_CHANGE) {
541 state = (struct MainDlgState *)
542 GetWindowLong(hwnd, GWL_USERDATA);
543 if (state->key_exists) {
544 HWND editctl = GetDlgItem(hwnd, IDC_COMMENTEDIT);
545 int len = GetWindowTextLength(editctl);
546 if (*state->commentptr)
547 sfree(*state->commentptr);
548 *state->commentptr = smalloc(len + 1);
549 GetWindowText(editctl, *state->commentptr, len + 1);
551 setupbigedit2(hwnd, IDC_KEYDISPLAY,
554 setupbigedit1(hwnd, IDC_KEYDISPLAY, &state->key);
560 EnableWindow(hwnd, 0);
561 DialogBox(hinst, MAKEINTRESOURCE(213), NULL, AboutProc);
562 EnableWindow(hwnd, 1);
563 SetActiveWindow(hwnd);
567 (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA);
568 if (!state->generation_thread_exists) {
570 state->keysize = GetDlgItemInt(hwnd, IDC_BITS, &ok, FALSE);
572 state->keysize = DEFAULT_KEYSIZE;
573 /* If we ever introduce a new key type, check it here! */
574 state->ssh2 = !IsDlgButtonChecked(hwnd, IDC_KEYSSH1);
575 if (state->keysize < 256) {
576 int ret = MessageBox(hwnd,
577 "PuTTYgen will not generate a key"
578 " smaller than 256 bits.\n"
579 "Key length reset to 256. Continue?",
581 MB_ICONWARNING | MB_OKCANCEL);
584 state->keysize = 256;
585 SetDlgItemInt(hwnd, IDC_BITS, 256, FALSE);
587 hidemany(hwnd, nokey_ids, TRUE);
588 hidemany(hwnd, generating_ids, FALSE);
589 hidemany(hwnd, gotkey_ids, TRUE);
590 EnableWindow(GetDlgItem(hwnd, IDC_GENERATE), 0);
591 EnableWindow(GetDlgItem(hwnd, IDC_LOAD), 0);
592 EnableWindow(GetDlgItem(hwnd, IDC_SAVE), 0);
593 state->key_exists = FALSE;
594 SetDlgItemText(hwnd, IDC_GENERATING, entropy_msg);
595 state->collecting_entropy = TRUE;
598 * My brief statistical tests on mouse movements
599 * suggest that there are about 2.5 bits of
600 * randomness in the x position, 2.5 in the y
601 * position, and 1.7 in the message time, making
602 * 5.7 bits of unpredictability per mouse movement.
603 * However, other people have told me it's far less
604 * than that, so I'm going to be stupidly cautious
605 * and knock that down to a nice round 2. With this
606 * method, we require two words per mouse movement,
607 * so with 2 bits per mouse movement we expect 2
608 * bits every 2 words.
610 state->entropy_required = (state->keysize / 2) * 2;
611 state->entropy_got = 0;
612 state->entropy_size = (state->entropy_required *
613 sizeof(*state->entropy));
614 state->entropy = smalloc(state->entropy_size);
616 SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0,
617 MAKELPARAM(0, state->entropy_required));
618 SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, 0, 0);
623 (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA);
624 if (state->key_exists) {
625 char filename[FILENAME_MAX];
626 char passphrase[PASSPHRASE_MAXLEN];
627 char passphrase2[PASSPHRASE_MAXLEN];
628 GetDlgItemText(hwnd, IDC_PASSPHRASE1EDIT,
629 passphrase, sizeof(passphrase));
630 GetDlgItemText(hwnd, IDC_PASSPHRASE2EDIT,
631 passphrase2, sizeof(passphrase2));
632 if (strcmp(passphrase, passphrase2)) {
634 "The two passphrases given do not match.",
635 "PuTTYgen Error", MB_OK | MB_ICONERROR);
640 ret = MessageBox(hwnd,
641 "Are you sure you want to save this key\n"
642 "without a passphrase to protect it?",
644 MB_YESNO | MB_ICONWARNING);
648 if (prompt_keyfile(hwnd, "Save private key as:",
651 FILE *fp = fopen(filename, "r");
653 char buffer[FILENAME_MAX + 80];
655 sprintf(buffer, "Overwrite existing file\n%.*s?",
656 FILENAME_MAX, filename);
657 ret = MessageBox(hwnd, buffer, "PuTTYgen Warning",
658 MB_YESNO | MB_ICONWARNING);
663 ret = ssh2_save_userkey(filename, &state->ssh2key,
664 *passphrase ? passphrase :
667 ret = saversakey(filename, &state->key,
668 *passphrase ? passphrase : NULL);
671 MessageBox(hwnd, "Unable to save key file",
672 "PuTTYgen Error", MB_OK | MB_ICONERROR);
679 (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA);
680 if (!state->generation_thread_exists) {
681 char filename[FILENAME_MAX];
682 if (prompt_keyfile(hwnd, "Load private key:", filename, 0)) {
683 char passphrase[PASSPHRASE_MAXLEN];
688 struct PassphraseProcStruct pps;
689 struct RSAKey newkey1;
690 struct ssh2_userkey *newkey2;
692 ver = keyfile_version(filename);
694 MessageBox(NULL, "Couldn't load private key.",
695 "PuTTYgen Error", MB_OK | MB_ICONERROR);
701 needs_pass = rsakey_encrypted(filename, &comment);
704 ssh2_userkey_encrypted(filename, &comment);
705 pps.passphrase = passphrase;
706 pps.comment = comment;
710 dlgret = DialogBoxParam(hinst,
711 MAKEINTRESOURCE(210),
712 NULL, PassphraseProc,
722 loadrsakey(filename, &newkey1, passphrase);
725 ssh2_load_userkey(filename, passphrase);
726 if (newkey2 == SSH2_WRONG_PASSPHRASE)
737 MessageBox(NULL, "Couldn't load private key.",
738 "PuTTYgen Error", MB_OK | MB_ICONERROR);
739 } else if (ret == 1) {
740 EnableWindow(GetDlgItem(hwnd, IDC_GENERATE), 1);
741 EnableWindow(GetDlgItem(hwnd, IDC_LOAD), 1);
742 EnableWindow(GetDlgItem(hwnd, IDC_SAVE), 1);
744 * Now update the key controls with all the
748 SetDlgItemText(hwnd, IDC_PASSPHRASE1EDIT,
750 SetDlgItemText(hwnd, IDC_PASSPHRASE2EDIT,
757 state->commentptr = &state->key.comment;
758 state->key = newkey1;
761 * Set the key fingerprint.
763 savecomment = state->key.comment;
764 state->key.comment = NULL;
765 rsa_fingerprint(buf, sizeof(buf),
767 state->key.comment = savecomment;
769 SetDlgItemText(hwnd, IDC_FINGERPRINT, buf);
771 * Construct a decimal representation
772 * of the key, for pasting into
773 * .ssh/authorized_keys on a Unix box.
775 setupbigedit1(hwnd, IDC_KEYDISPLAY,
783 &state->ssh2key.comment;
784 state->ssh2key = *newkey2; /* structure copy */
787 savecomment = state->ssh2key.comment;
788 state->ssh2key.comment = NULL;
791 fingerprint(state->ssh2key.data);
792 state->ssh2key.comment = savecomment;
794 SetDlgItemText(hwnd, IDC_FINGERPRINT, fp);
797 setupbigedit2(hwnd, IDC_KEYDISPLAY,
800 SetDlgItemText(hwnd, IDC_COMMENTEDIT,
804 * Finally, hide the progress bar and show
807 hidemany(hwnd, nokey_ids, TRUE);
808 hidemany(hwnd, generating_ids, TRUE);
809 hidemany(hwnd, gotkey_ids, FALSE);
810 state->key_exists = TRUE;
818 state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA);
819 state->generation_thread_exists = FALSE;
820 state->key_exists = TRUE;
821 SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, PROGRESSRANGE,
823 EnableWindow(GetDlgItem(hwnd, IDC_GENERATE), 1);
824 EnableWindow(GetDlgItem(hwnd, IDC_LOAD), 1);
825 EnableWindow(GetDlgItem(hwnd, IDC_SAVE), 1);
827 state->ssh2key.data = &state->key;
828 state->ssh2key.alg = &ssh_rsa;
829 state->commentptr = &state->ssh2key.comment;
831 state->commentptr = &state->key.comment;
834 * Invent a comment for the key. We'll do this by including
835 * the date in it. This will be so horrifyingly ugly that
836 * the user will immediately want to change it, which is
839 *state->commentptr = smalloc(30);
845 strftime(*state->commentptr, 30, "rsa-key-%Y%m%d", tm);
849 * Now update the key controls with all the key data.
854 * Blank passphrase, initially. This isn't dangerous,
855 * because we will warn (Are You Sure?) before allowing
856 * the user to save an unprotected private key.
858 SetDlgItemText(hwnd, IDC_PASSPHRASE1EDIT, "");
859 SetDlgItemText(hwnd, IDC_PASSPHRASE2EDIT, "");
863 SetDlgItemText(hwnd, IDC_COMMENTEDIT, *state->commentptr);
865 * Set the key fingerprint.
867 savecomment = *state->commentptr;
868 *state->commentptr = NULL;
871 fp = state->ssh2key.alg->fingerprint(state->ssh2key.data);
872 SetDlgItemText(hwnd, IDC_FINGERPRINT, fp);
876 rsa_fingerprint(buf, sizeof(buf), &state->key);
877 SetDlgItemText(hwnd, IDC_FINGERPRINT, buf);
879 *state->commentptr = savecomment;
881 * Construct a decimal representation of the key, for
882 * pasting into .ssh/authorized_keys on a Unix box.
885 setupbigedit2(hwnd, IDC_KEYDISPLAY, &state->ssh2key);
887 setupbigedit1(hwnd, IDC_KEYDISPLAY, &state->key);
891 * Finally, hide the progress bar and show the key data.
893 hidemany(hwnd, nokey_ids, TRUE);
894 hidemany(hwnd, generating_ids, TRUE);
895 hidemany(hwnd, gotkey_ids, FALSE);
898 state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA);
906 int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
908 InitCommonControls();
911 return DialogBox(hinst, MAKEINTRESOURCE(201), NULL,
912 MainDlgProc) != IDOK;