17 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
*/ |
*/ |
|
|
|
20 |
#include <windows.h> |
#include <windows.h> |
21 |
|
|
22 |
#include "../resource.h" |
#include "../resource.h" |
31 |
#include "wptErrors.h" |
#include "wptErrors.h" |
32 |
#include "wptUTF8.h" |
#include "wptUTF8.h" |
33 |
|
|
34 |
|
/* All valid key generation combination. */ |
35 |
|
enum { |
36 |
|
GPG_KEYGEN_NONE = 0, |
37 |
|
GPG_KEYGEN_DSA_ELG = 1, |
38 |
|
GPG_KEYGEN_DSA_RSA = 2, |
39 |
|
GPG_KEYGEN_DSA_SIG = 3, |
40 |
|
GPG_KEYGEN_RSA_SIG = 4, |
41 |
|
GPG_KEYGEN_RSA = 5, |
42 |
|
GPG_KEYGEN_RSA_RSA = 6 /*PGP*/ |
43 |
|
}; |
44 |
|
|
45 |
|
|
46 |
|
static const char key_params[] = |
47 |
|
"<GnupgKeyParms format=\"internal\">\n" |
48 |
|
"Key-Type: %s\n" |
49 |
|
"Key-Length: %d\n" |
50 |
|
"Subkey-Type: %s\n" |
51 |
|
"Subkey-Length: %d\n" |
52 |
|
"Name-Real: %s\n" |
53 |
|
"Name-Email: %s\n" |
54 |
|
"Expire-Date: %s\n" |
55 |
|
"Passphrase: %s\n" |
56 |
|
"</GnupgKeyParms>\n"; |
57 |
|
|
58 |
|
static const char key_params_with_comment[] = |
59 |
|
"<GnupgKeyParms format=\"internal\">\n" |
60 |
|
"Key-Type: %s\n" |
61 |
|
"Key-Length: %d\n" |
62 |
|
"Subkey-Type: %s\n" |
63 |
|
"Subkey-Length: %d\n" |
64 |
|
"Name-Real: %s\n" |
65 |
|
"Name-Comment: %s\n" |
66 |
|
"Name-Email: %s\n" |
67 |
|
"Expire-Date: %s\n" |
68 |
|
"Passphrase: %s\n" |
69 |
|
"</GnupgKeyParms>\n"; |
70 |
|
|
71 |
|
static const char key_params_one[] = |
72 |
|
"<GnupgKeyParms format=\"internal\">\n" |
73 |
|
"Key-Type: %s\n" |
74 |
|
"Key-Length: %d\n" |
75 |
|
"Key-Usage: %s\n" |
76 |
|
"Name-Real: %s\n" |
77 |
|
"Name-Email: %s\n" |
78 |
|
"Expire-Date: %s\n" |
79 |
|
"Passphrase: %s\n" |
80 |
|
"</GnupgKeyParms>\n"; |
81 |
|
|
82 |
|
static const char key_params_one_with_comment[] = |
83 |
|
"<GnupgKeyParms format=\"internal\">\n" |
84 |
|
"Key-Type: %s\n" |
85 |
|
"Key-Length: %d\n" |
86 |
|
"Key-Usage: %s\n" |
87 |
|
"Name-Real: %s\n" |
88 |
|
"Name-Email: %s\n" |
89 |
|
"Name-Comment: %s\n" |
90 |
|
"Expire-Date: %s\n" |
91 |
|
"Passphrase: %s\n" |
92 |
|
"</GnupgKeyParms>\n"; |
93 |
|
|
94 |
|
|
95 |
|
/* Generate the GPG specific genkey params with the given information. |
96 |
|
@keytype: See valid combinations. |
97 |
|
@bits: Length in bits. |
98 |
|
@user: user-ID name |
99 |
|
@comment: comment for the user-ID. |
100 |
|
@email: email address. |
101 |
|
@expdata: date of expiration or NULL. |
102 |
|
@passphrase: the actual passphrase. |
103 |
|
Return value: the gen. params. */ |
104 |
|
static char* |
105 |
|
gpg_genkey_params (int keytype, int bits, |
106 |
|
const char *user, const char *comment, const char *email, |
107 |
|
const char *expdate, const char *passphrase) |
108 |
|
{ |
109 |
|
char *p = NULL; |
110 |
|
int addsize = strlen ("sign encrypt"); |
111 |
|
int size = 0; |
112 |
|
|
113 |
|
if (keytype == GPG_KEYGEN_NONE) |
114 |
|
return NULL; |
115 |
|
|
116 |
|
if( comment && *comment ) { |
117 |
|
size = strlen( key_params_with_comment ) |
118 |
|
+ 16 |
119 |
|
+ strlen( user ) |
120 |
|
+ addsize |
121 |
|
+ strlen( comment ) |
122 |
|
+ strlen( email ) |
123 |
|
+ strlen( passphrase ) + 32; |
124 |
|
} |
125 |
|
else { |
126 |
|
size = strlen( key_params ) |
127 |
|
+ 16 |
128 |
|
+ strlen( user ) |
129 |
|
+ strlen( email ) |
130 |
|
+ strlen( passphrase ) |
131 |
|
+ addsize |
132 |
|
+ 32; |
133 |
|
} |
134 |
|
if( expdate ) |
135 |
|
size += strlen( expdate ); |
136 |
|
p = (char *)malloc( size+1 ); |
137 |
|
if( !p ) |
138 |
|
return NULL; |
139 |
|
if( comment && *comment ) { |
140 |
|
switch( keytype ) { |
141 |
|
case GPG_KEYGEN_DSA_ELG: |
142 |
|
sprintf( p, key_params_with_comment, |
143 |
|
"DSA", 1024, "ELG-E", bits, user, comment, email, |
144 |
|
expdate ? expdate : "0", passphrase ); |
145 |
|
break; |
146 |
|
|
147 |
|
case GPG_KEYGEN_DSA_RSA: |
148 |
|
sprintf( p, key_params_with_comment, |
149 |
|
"DSA", 1024, "RSA", bits, user, comment, email, |
150 |
|
expdate ? expdate : "0", passphrase ); |
151 |
|
break; |
152 |
|
|
153 |
|
case GPG_KEYGEN_DSA_SIG: |
154 |
|
sprintf( p, key_params_one_with_comment, |
155 |
|
"DSA", 1024, "sign", |
156 |
|
user, comment, email, |
157 |
|
expdate ? expdate : "0", passphrase ); |
158 |
|
break; |
159 |
|
|
160 |
|
case GPG_KEYGEN_RSA_SIG: |
161 |
|
sprintf( p, key_params_one_with_comment, |
162 |
|
"RSA", bits, "sign", |
163 |
|
user, comment, email, |
164 |
|
expdate ? expdate : "0", passphrase ); |
165 |
|
break; |
166 |
|
|
167 |
|
case GPG_KEYGEN_RSA: |
168 |
|
sprintf( p, key_params_one_with_comment, |
169 |
|
"RSA", bits, "sign encrypt", |
170 |
|
user, comment, email, |
171 |
|
expdate ? expdate : "0", passphrase ); |
172 |
|
break; |
173 |
|
|
174 |
|
case GPG_KEYGEN_RSA_RSA: |
175 |
|
sprintf( p, key_params_with_comment, |
176 |
|
"RSA", bits, "RSA", bits, user, comment, email, |
177 |
|
expdate? expdate : "0", passphrase ); |
178 |
|
break; |
179 |
|
|
180 |
|
default: |
181 |
|
if (p) |
182 |
|
free (p); |
183 |
|
p = NULL; |
184 |
|
break; |
185 |
|
} |
186 |
|
} |
187 |
|
else { |
188 |
|
switch ( keytype ) { |
189 |
|
case GPG_KEYGEN_DSA_ELG: |
190 |
|
sprintf( p, key_params, |
191 |
|
"DSA", 1024, "ELG-E", bits, user, email, |
192 |
|
expdate ? expdate : "0", passphrase ); |
193 |
|
break; |
194 |
|
|
195 |
|
case GPG_KEYGEN_DSA_RSA: |
196 |
|
sprintf( p, key_params, |
197 |
|
"DSA", 1024, "RSA", bits, user, email, |
198 |
|
expdate ? expdate : "0", passphrase ); |
199 |
|
break; |
200 |
|
|
201 |
|
case GPG_KEYGEN_DSA_SIG: |
202 |
|
sprintf( p, key_params_one, |
203 |
|
"DSA", 1024, "sign", |
204 |
|
user, email, |
205 |
|
expdate ? expdate : "0", passphrase ); |
206 |
|
break; |
207 |
|
|
208 |
|
case GPG_KEYGEN_RSA_SIG: |
209 |
|
sprintf( p, key_params_one, |
210 |
|
"RSA", bits, "sign", |
211 |
|
user, email, |
212 |
|
expdate ? expdate : "0", passphrase ); |
213 |
|
break; |
214 |
|
|
215 |
|
case GPG_KEYGEN_RSA: |
216 |
|
sprintf( p, key_params_one, |
217 |
|
"RSA", bits, "sign encrypt", |
218 |
|
user, email, |
219 |
|
expdate ? expdate : "0", passphrase ); |
220 |
|
break; |
221 |
|
|
222 |
|
case GPG_KEYGEN_RSA_RSA: |
223 |
|
sprintf( p, key_params, |
224 |
|
"RSA", bits, "RSA", bits, user, email, |
225 |
|
expdate? expdate : "0", passphrase ); |
226 |
|
break; |
227 |
|
|
228 |
|
default: |
229 |
|
if (p) |
230 |
|
free (p); |
231 |
|
p = NULL; |
232 |
|
break; |
233 |
|
} |
234 |
|
} |
235 |
|
return p; |
236 |
|
} |
237 |
|
|
238 |
|
|
239 |
|
/* Generate a key with the given params @params. @prog_cb is a user defined |
240 |
|
progress callback which is called during the generation. |
241 |
|
@fpr will store the fingerprint of the generated key. |
242 |
|
Return value: 0 on success. */ |
243 |
|
gpgme_error_t |
244 |
|
gpg_genkey (const char *params, gpgme_progress_cb_t prog_cb, char **fpr) |
245 |
|
{ |
246 |
|
gpgme_error_t err = 0; |
247 |
|
gpgme_ctx_t ctx; |
248 |
|
gpgme_genkey_result_t res; |
249 |
|
|
250 |
|
err = gpgme_new(&ctx); |
251 |
|
if (err) |
252 |
|
return err; |
253 |
|
if (prog_cb) |
254 |
|
gpgme_set_progress_cb (ctx, prog_cb, NULL); |
255 |
|
err = gpgme_op_genkey (ctx, params, NULL, NULL); |
256 |
|
if (!err) { |
257 |
|
res = gpgme_op_genkey_result (ctx); |
258 |
|
*fpr = res->fpr? strdup (res->fpr) : NULL; |
259 |
|
} |
260 |
|
gpgme_release (ctx); |
261 |
|
return err; |
262 |
|
} |
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
/* Clear all dialog fields. */ |
267 |
static void |
static void |
268 |
clear_dlg_fields( HWND dlg ) |
clear_dlg_fields (HWND dlg) |
269 |
{ |
{ |
270 |
SetDlgItemText( dlg, IDC_KEYGEN_SUBKEYBITS, "" ); |
SetDlgItemText (dlg, IDC_KEYGEN_SUBKEYBITS, ""); |
271 |
SetDlgItemText( dlg, IDC_KEYGEN_NAME, "" ); |
SetDlgItemText (dlg, IDC_KEYGEN_NAME, ""); |
272 |
SetDlgItemText( dlg, IDC_KEYGEN_EMAIL, "" ); |
SetDlgItemText (dlg, IDC_KEYGEN_EMAIL, ""); |
273 |
SetDlgItemText( dlg, IDC_KEYGEN_COMMENT, "" ); |
SetDlgItemText (dlg, IDC_KEYGEN_COMMENT, ""); |
274 |
SetDlgItemText( dlg, IDC_KEYGEN_EXPDATE, "" ); |
SetDlgItemText (dlg, IDC_KEYGEN_EXPDATE, ""); |
275 |
SetDlgItemText( dlg, IDC_KEYGEN_PASSPHRASE, "" ); |
SetDlgItemText (dlg, IDC_KEYGEN_PASSPHRASE, ""); |
276 |
SetDlgItemText( dlg, IDC_KEYGEN_PWDCHECK, "" ); |
SetDlgItemText (dlg, IDC_KEYGEN_PWDCHECK, ""); |
277 |
} /* clear_dlg_fields */ |
} |
278 |
|
|
279 |
|
|
280 |
|
/* Ask the user if a keyring backup is wanted and if so, |
281 |
|
backup both keyrings to the selected folder. @dlg is |
282 |
|
the handle of the parent window.*/ |
283 |
static void |
static void |
284 |
ask_for_backup (HWND dlg) |
backup_keyrings (HWND dlg) |
285 |
{ |
{ |
286 |
int id; |
int id; |
287 |
char * path = NULL, * keyring = NULL; |
char *path = NULL, *keyring = NULL; |
288 |
const char * name; |
const char * name; |
289 |
|
|
290 |
path = get_gnupg_path (); |
path = get_gnupg_path (); |
291 |
if( !path ) |
if (!path) |
292 |
BUG( dlg ); |
BUG (dlg); |
293 |
id = msg_box( dlg, |
id = msg_box (dlg, |
294 |
_("It is STRONGLY recommend that you backup your keyrings because they both " |
_("It is STRONGLY recommend that you backup your keyrings because they both " |
295 |
"contain VERY important data.\nRemember that your hard disk can crash or the " |
"contain VERY important data.\nRemember that your hard disk can crash or the " |
296 |
"files can be deleted by accident; so it is a good\nidea to store them on " |
"files can be deleted by accident; so it is a good\nidea to store them on " |
297 |
"a different mass stoarge like a floppy or CDR!\n\n" |
"a different mass stoarge like a floppy or CDR!\n\n" |
298 |
"Backup your keyrings now?"), |
"Backup your keyrings now?"), |
299 |
_("WARNING - Important hint" ), MB_YESNO ); |
_("WARNING - Important hint" ), MB_YESNO); |
300 |
if( id == IDYES ) { |
if (id == IDYES) { |
301 |
name = get_filename_dlg( dlg, 1, _("Destination for Public Keyring"), NULL, "pubring.gpg" ); |
name = get_filename_dlg( dlg, 1, _("Destination for Public Keyring"), NULL, "pubring.gpg" ); |
302 |
if( name ) { |
if( name ) { |
303 |
keyring = make_filename( path, "pubring", "gpg" ); |
keyring = make_filename( path, "pubring", "gpg" ); |
319 |
} /* ask_for_backup */ |
} /* ask_for_backup */ |
320 |
|
|
321 |
|
|
322 |
|
/* Fill in all valid GPG algorithms. */ |
323 |
static void |
static void |
324 |
fill_keytype_box( HWND dlg ) |
fill_keytype_box (HWND dlg) |
325 |
{ |
{ |
326 |
HWND cb = GetDlgItem( dlg, IDC_KEYGEN_KEYTYPE ); |
HWND cb = GetDlgItem (dlg, IDC_KEYGEN_KEYTYPE ); |
327 |
|
|
328 |
#define addstr( cb, str ) \ |
#define addstr( cb, str ) \ |
329 |
SendMessage( (cb), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)(str) ) |
SendMessage( (cb), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)(str) ) |
335 |
addstr( cb, _("RSA and RSA (PGP)") ); |
addstr( cb, _("RSA and RSA (PGP)") ); |
336 |
SendMessage( cb, CB_SETCURSEL, 0, 0 ); |
SendMessage( cb, CB_SETCURSEL, 0, 0 ); |
337 |
#undef addstr |
#undef addstr |
338 |
} /* fill_keytype_box */ |
} |
|
|
|
|
|
|
|
static inline int |
|
|
get_keytype( HWND dlg ) |
|
|
{ |
|
|
HWND cb = GetDlgItem( dlg, IDC_KEYGEN_KEYTYPE ); |
|
|
return SendMessage( cb, CB_GETCURSEL, 0, 0 ) + 1; |
|
|
} /* get_keytype */ |
|
339 |
|
|
340 |
|
|
341 |
|
/* Check that the given date lies not in the past. |
342 |
|
Return value: 1 on success. */ |
343 |
int |
int |
344 |
keygen_check_date( SYSTEMTIME *st ) |
keygen_check_date (SYSTEMTIME *st) |
345 |
{ |
{ |
346 |
SYSTEMTIME t; |
SYSTEMTIME t; |
347 |
|
|
354 |
} /* keygen_check_date */ |
} /* keygen_check_date */ |
355 |
|
|
356 |
|
|
357 |
|
/* Dialog box procedure for key generation. */ |
358 |
BOOL CALLBACK |
BOOL CALLBACK |
359 |
keygen_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
keygen_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
360 |
{ |
{ |
374 |
if (lparam != NULL) |
if (lparam != NULL) |
375 |
ctx = (genkey_s *)lparam; |
ctx = (genkey_s *)lparam; |
376 |
hide = 1; |
hide = 1; |
377 |
#ifndef LANG_DE |
#ifndef LANG_DE |
378 |
SetWindowText( dlg, _("Key Generation") ); |
SetWindowText( dlg, _("Key Generation") ); |
379 |
SetDlgItemText( dlg, IDC_KEYGEN_INFO, |
SetDlgItemText( dlg, IDC_KEYGEN_INFO, |
380 |
_("NOTE: Key generation can be a lengthy process! Please wait until " |
_("NOTE: Key generation can be a lengthy process! Please wait until " |
389 |
SetDlgItemText( dlg, IDC_KEYGEN_KEYTYPEINF, _("Key &type") ); |
SetDlgItemText( dlg, IDC_KEYGEN_KEYTYPEINF, _("Key &type") ); |
390 |
SetDlgItemText (dlg, IDC_KEYGEN_CLEAR, _("&Never")); |
SetDlgItemText (dlg, IDC_KEYGEN_CLEAR, _("&Never")); |
391 |
SetDlgItemText (dlg, IDC_KEYGEN_HIDEPWD, _("&Hide Typing")); |
SetDlgItemText (dlg, IDC_KEYGEN_HIDEPWD, _("&Hide Typing")); |
392 |
#endif |
#endif |
393 |
SetDlgItemInt( dlg, IDC_KEYGEN_SUBKEYBITS, 2048, FALSE ); |
SetDlgItemInt( dlg, IDC_KEYGEN_SUBKEYBITS, 2048, FALSE ); |
394 |
CheckDlgButton (dlg, IDC_KEYGEN_HIDEPWD, BST_CHECKED); |
CheckDlgButton (dlg, IDC_KEYGEN_HIDEPWD, BST_CHECKED); |
395 |
CheckDlgButton (dlg, IDC_KEYGEN_EXPNEVER, BST_CHECKED); |
CheckDlgButton (dlg, IDC_KEYGEN_EXPNEVER, BST_CHECKED); |
396 |
EnableWindow (GetDlgItem (dlg, IDC_KEYGEN_EXPDATE), FALSE); |
EnableWindow (GetDlgItem (dlg, IDC_KEYGEN_EXPDATE), FALSE); |
397 |
fill_keytype_box( dlg ); |
fill_keytype_box( dlg ); |
398 |
center_window( dlg ); |
center_window( dlg, NULL ); |
399 |
SetForegroundWindow( dlg ); |
SetForegroundWindow( dlg ); |
400 |
return TRUE; |
return TRUE; |
401 |
|
|
460 |
_("Key Generation"), MB_INFO ); |
_("Key Generation"), MB_INFO ); |
461 |
return FALSE; |
return FALSE; |
462 |
} |
} |
463 |
keytype = get_keytype( dlg ); |
keytype = SendDlgItemMessage (dlg, IDC_KEYGEN_KEYTYPE, CB_GETCURSEL, 0, 0) + 1; |
464 |
if (IsDlgButtonChecked (dlg, IDC_KEYGEN_EXPNEVER)) |
if (IsDlgButtonChecked (dlg, IDC_KEYGEN_EXPNEVER)) |
465 |
expire = NULL; |
expire = NULL; |
466 |
else { |
else { |
513 |
utf8_name = wincp_to_utf8 (name, strlen (name)); |
utf8_name = wincp_to_utf8 (name, strlen (name)); |
514 |
if( !utf8_name ) |
if( !utf8_name ) |
515 |
BUG( dlg ); |
BUG( dlg ); |
516 |
p = gpgme_genkey_params( keytype, bits, utf8_name, NULL, email, expire, pwd ); |
p = gpg_genkey_params( keytype, bits, utf8_name, NULL, email, expire, pwd ); |
517 |
free( utf8_name ); |
free( utf8_name ); |
518 |
} |
} |
519 |
else { |
else { |
522 |
utf8_comment = wincp_to_utf8 (comment, strlen (comment)); |
utf8_comment = wincp_to_utf8 (comment, strlen (comment)); |
523 |
if( !utf8_name || !utf8_comment ) |
if( !utf8_name || !utf8_comment ) |
524 |
BUG( dlg ); |
BUG( dlg ); |
525 |
p = gpgme_genkey_params( keytype, bits, utf8_name, utf8_comment, email, expire, pwd ); |
p = gpg_genkey_params( keytype, bits, utf8_name, utf8_comment, email, expire, pwd ); |
526 |
free( utf8_name ); |
free( utf8_name ); |
527 |
free( utf8_comment ); |
free( utf8_comment ); |
528 |
} |
} |
529 |
keygen_cb_dlg_create( ); |
keygen_cb_dlg_create( ); |
530 |
err = gpgme_op_genkey_auto (p, keygen_cb, &fpr); |
err = gpg_genkey (p, keygen_cb, &fpr); |
531 |
memset( pwd, 0, sizeof pwd ); |
memset( pwd, 0, sizeof pwd ); |
532 |
memset( pwd2, 0, sizeof pwd2 ); |
memset( pwd2, 0, sizeof pwd2 ); |
533 |
if( p ) { |
if( p ) { |
537 |
keygen_cb_dlg_destroy( ); |
keygen_cb_dlg_destroy( ); |
538 |
keygen_cb( NULL, NULL, 0, 0, 0 ); /* flush */ |
keygen_cb( NULL, NULL, 0, 0, 0 ); /* flush */ |
539 |
if( err ) { |
if( err ) { |
540 |
safe_free (fpr); |
if (fpr) |
541 |
|
free (fpr); |
542 |
msg_box (dlg, gpgme_strerror( err ), _("Key Generation"), MB_ERR); |
msg_box (dlg, gpgme_strerror( err ), _("Key Generation"), MB_ERR); |
543 |
return FALSE; |
return FALSE; |
544 |
} |
} |
548 |
keycache_update (1, fpr); |
keycache_update (1, fpr); |
549 |
if (ctx->first_start == 0 && ctx != NULL) |
if (ctx->first_start == 0 && ctx != NULL) |
550 |
get_pubkey (fpr, &ctx->newkey); |
get_pubkey (fpr, &ctx->newkey); |
551 |
safe_free (fpr); |
if (fpr) |
552 |
|
free (fpr); |
553 |
|
|
554 |
clear_dlg_fields (dlg); |
clear_dlg_fields (dlg); |
555 |
ask_for_backup (dlg); |
backup_keyrings (dlg); |
556 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
557 |
return TRUE; |
return TRUE; |
558 |
|
|
573 |
keygen_wizard_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
keygen_wizard_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
574 |
{ |
{ |
575 |
static genkey_s *ctx; |
static genkey_s *ctx; |
576 |
static int pubkey_algo = GPGME_KEYGEN_DSA_ELG; |
static int pubkey_algo = GPG_KEYGEN_DSA_ELG; |
577 |
gpgme_error_t err; |
gpgme_error_t err; |
578 |
char name[128], email[128]; |
char name[128], email[128]; |
579 |
char * utf8_name, * p, *fpr=NULL; |
char * utf8_name, * p, *fpr=NULL; |
593 |
SetDlgItemText (dlg, IDC_KEYWIZARD_TEXT1INF, _("Every key pair must have a name associated with it. The name and\nemail address let your correspondents that your public key they are\nusing belongs to us.")); |
SetDlgItemText (dlg, IDC_KEYWIZARD_TEXT1INF, _("Every key pair must have a name associated with it. The name and\nemail address let your correspondents that your public key they are\nusing belongs to us.")); |
594 |
SetDlgItemText (dlg, IDC_KEYWIZARD_TEXT2INF, _("By accosiating an email address with your key pair, you will enable WinPT to assist your correspondents in selecting the correct public\nkey when communicating with you.")); |
SetDlgItemText (dlg, IDC_KEYWIZARD_TEXT2INF, _("By accosiating an email address with your key pair, you will enable WinPT to assist your correspondents in selecting the correct public\nkey when communicating with you.")); |
595 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
596 |
center_window (dlg); |
center_window (dlg, NULL); |
597 |
break; |
break; |
598 |
|
|
599 |
case WM_SYSCOMMAND: |
case WM_SYSCOMMAND: |
637 |
if( !utf8_name ) |
if( !utf8_name ) |
638 |
BUG( NULL ); |
BUG( NULL ); |
639 |
if (IsDlgButtonChecked (dlg, IDC_KEYWIZARD_USERSA)) |
if (IsDlgButtonChecked (dlg, IDC_KEYWIZARD_USERSA)) |
640 |
pubkey_algo = GPGME_KEYGEN_DSA_RSA; |
pubkey_algo = GPG_KEYGEN_DSA_RSA; |
641 |
p = gpgme_genkey_params (pubkey_algo, DFAULT_KEYSIZE, utf8_name, |
p = gpg_genkey_params (pubkey_algo, DFAULT_KEYSIZE, utf8_name, |
642 |
NULL, email, NULL, pass); |
NULL, email, NULL, pass); |
643 |
free( utf8_name ); |
free( utf8_name ); |
644 |
keygen_cb_dlg_create(); |
keygen_cb_dlg_create(); |
645 |
err = gpgme_op_genkey_auto (p, keygen_cb, &fpr); |
err = gpg_genkey (p, keygen_cb, &fpr); |
646 |
keygen_cb_dlg_destroy(); |
keygen_cb_dlg_destroy(); |
647 |
keygen_cb( NULL, NULL, 0, 0, 0 ); |
keygen_cb( NULL, NULL, 0, 0, 0 ); |
648 |
if( p ) { |
if( p ) { |
652 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
653 |
if( err ) { |
if( err ) { |
654 |
msg_box( dlg, gpgme_strerror( err ), _("Key Generation Wizard"), MB_ERR ); |
msg_box( dlg, gpgme_strerror( err ), _("Key Generation Wizard"), MB_ERR ); |
655 |
safe_free (fpr); |
if (fpr) |
656 |
|
free (fpr); |
657 |
return FALSE; |
return FALSE; |
658 |
} |
} |
659 |
status_box( dlg, _("Key Generation completed"), _("GnuPG Status") ); |
status_box( dlg, _("Key Generation completed"), _("GnuPG Status") ); |
662 |
keycache_update (1, fpr); |
keycache_update (1, fpr); |
663 |
if (ctx->first_start == 0 && ctx != NULL) |
if (ctx->first_start == 0 && ctx != NULL) |
664 |
get_pubkey (fpr, &ctx->newkey); |
get_pubkey (fpr, &ctx->newkey); |
665 |
safe_free (fpr); |
if (fpr) |
666 |
|
free (fpr); |
667 |
ask_for_backup (dlg); |
backup_keyrings (dlg); |
668 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
669 |
break; |
break; |
670 |
|
|