32 |
|
|
33 |
|
|
34 |
struct passphrase_s { |
struct passphrase_s { |
35 |
char * title; |
char *title; /* title of the dialog. */ |
36 |
char pwd[256]; |
char pwd[256]; /* the actual passphrase. */ |
37 |
int strict; |
int strict; /* do a simple check how good the passphrase is. */ |
38 |
int repeat; |
int repeat; /* Indicate last try was wrong. */ |
39 |
int cancel; |
int cancel; /* 1 if user cancelled operation. */ |
40 |
}; |
}; |
41 |
|
|
42 |
|
|
43 |
|
/* Dialog procedure to request a passphrase from the user. */ |
44 |
static BOOL CALLBACK |
static BOOL CALLBACK |
45 |
passwd_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
passwd_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
46 |
{ |
{ |
52 |
pwd = (passphrase_s *)lparam; |
pwd = (passphrase_s *)lparam; |
53 |
if (pwd == NULL) |
if (pwd == NULL) |
54 |
dlg_fatal_error (dlg, "Could not get dialog param!"); |
dlg_fatal_error (dlg, "Could not get dialog param!"); |
55 |
#ifndef LANG_DE |
#ifndef LANG_DE |
56 |
SetWindowText (dlg, _("Passphrase Dialog")); |
SetWindowText (dlg, _("Passphrase Dialog")); |
57 |
#endif |
#endif |
58 |
CheckDlgButton (dlg, IDC_PASSWD_HIDE, BST_CHECKED); |
CheckDlgButton (dlg, IDC_PASSWD_HIDE, BST_CHECKED); |
59 |
if (pwd->title) |
if (pwd->title) |
60 |
SetWindowText (dlg, pwd->title); |
SetWindowText (dlg, pwd->title); |
63 |
else |
else |
64 |
SetDlgItemText (dlg, IDC_PASSWD_INFO, _("Enter Passphrase")); |
SetDlgItemText (dlg, IDC_PASSWD_INFO, _("Enter Passphrase")); |
65 |
SetFocus (GetDlgItem (dlg, IDC_PASSWD_PWD )); |
SetFocus (GetDlgItem (dlg, IDC_PASSWD_PWD )); |
66 |
center_window2 (dlg, HWND_TOPMOST); |
center_window2 (dlg, NULL, HWND_TOPMOST); |
67 |
center_window (dlg); |
center_window (dlg, NULL); |
68 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
69 |
return FALSE; |
return FALSE; |
70 |
|
|
89 |
"\n\nStill proceed?"), |
"\n\nStill proceed?"), |
90 |
_("Key Generation"), MB_ICONWARNING|MB_YESNO); |
_("Key Generation"), MB_ICONWARNING|MB_YESNO); |
91 |
if (id == IDNO) |
if (id == IDNO) |
92 |
return FALSE; |
return TRUE; |
93 |
} |
} |
94 |
SetDlgItemText (dlg, IDC_PASSWD_PWD, ""); |
SetDlgItemText (dlg, IDC_PASSWD_PWD, ""); |
95 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
97 |
|
|
98 |
case IDCANCEL: |
case IDCANCEL: |
99 |
pwd->cancel = 1; |
pwd->cancel = 1; |
100 |
EndDialog( dlg, FALSE ); |
EndDialog (dlg, FALSE); |
101 |
return FALSE; |
return TRUE; |
102 |
} |
} |
103 |
break; |
break; |
104 |
} |
} |
105 |
|
|
106 |
return FALSE; |
return FALSE; |
107 |
} /* passwd_dlg_proc */ |
} |
108 |
|
|
109 |
|
|
110 |
|
/* Request a passphrase from the user. @title is the title of the |
111 |
|
dialog and @ret_cancel is true if user cancelled the operation. |
112 |
|
Return value: the passphrase or NUL for an error. */ |
113 |
char* |
char* |
114 |
request_passphrase (const char *title, int flags, int *ret_cancel) |
request_passphrase (const char *title, int flags, int *ret_cancel) |
115 |
{ |
{ |
136 |
free_if_alloc (pass.title); |
free_if_alloc (pass.title); |
137 |
memset (&pass, 0, sizeof (pass)); |
memset (&pass, 0, sizeof (pass)); |
138 |
return p; |
return p; |
139 |
} /* request_passphrase */ |
} |
140 |
|
|
141 |
|
|
142 |
char * |
/* Request a passphrase from the user but also confirm the passphrase |
143 |
|
to make sure there is no typo. Arguments same as in the normal version |
144 |
|
of the function. */ |
145 |
|
char* |
146 |
request_passphrase2 (const char *title, int flags, int *ret_cancel) |
request_passphrase2 (const char *title, int flags, int *ret_cancel) |
147 |
{ |
{ |
148 |
char *pass1, *pass2; |
char *pass1, *pass2; |