22 |
#endif |
#endif |
23 |
|
|
24 |
#include <windows.h> |
#include <windows.h> |
25 |
|
#include <time.h> |
26 |
|
|
27 |
#include "resource.h" |
#include "resource.h" |
28 |
#include "wptTypes.h" |
#include "wptTypes.h" |
246 |
err = gpgme_op_genkey (ctx, params, NULL, NULL); |
err = gpgme_op_genkey (ctx, params, NULL, NULL); |
247 |
if (!err) { |
if (!err) { |
248 |
res = gpgme_op_genkey_result (ctx); |
res = gpgme_op_genkey_result (ctx); |
249 |
*fpr = res->fpr? m_strdup (res->fpr) : NULL; |
*fpr = res && res->fpr? m_strdup (res->fpr) : NULL; |
250 |
} |
} |
251 |
gpgme_release (ctx); |
gpgme_release (ctx); |
252 |
return err; |
return err; |
301 |
} |
} |
302 |
name = get_filesave_dlg (dlg, _("Destination for Secret Keyring"), |
name = get_filesave_dlg (dlg, _("Destination for Secret Keyring"), |
303 |
NULL, "secring.gpg"); |
NULL, "secring.gpg"); |
304 |
if( name ) { |
if (name) { |
305 |
keyring = make_filename (path, "secring", "gpg"); |
keyring = make_filename (path, "secring", "gpg"); |
306 |
if (!CopyFile (keyring, name, FALSE)) |
if (!CopyFile (keyring, name, FALSE)) |
307 |
log_box (_("Key Generation"), MB_ERR, |
log_box (_("Key Generation"), MB_ERR, |
332 |
} |
} |
333 |
|
|
334 |
|
|
335 |
|
time_t w32_mktime (SYSTEMTIME *st); |
336 |
|
|
337 |
/* Check that the given date lies not in the past. |
/* Check that the given date lies not in the past. |
338 |
Return value: 1 on success. */ |
Return value: 1 on success. */ |
339 |
int |
int |
340 |
keygen_check_date (SYSTEMTIME *st) |
keygen_check_date (SYSTEMTIME *st) |
341 |
{ |
{ |
342 |
SYSTEMTIME t; |
time_t dat, now; |
343 |
|
|
344 |
GetSystemTime (&t); |
dat = w32_mktime (st); |
345 |
if (st->wYear > t.wYear || st->wMonth > t.wMonth) |
now = time (NULL); |
346 |
|
if (dat >= now) |
347 |
return 1; |
return 1; |
348 |
else if (st->wYear < t.wYear || st->wMonth < t.wMonth || st->wDay < t.wDay) |
return 0; |
|
return 0; |
|
|
return 1; |
|
349 |
} |
} |
350 |
|
|
351 |
|
|
364 |
int cancel = 0; |
int cancel = 0; |
365 |
char *p; |
char *p; |
366 |
|
|
367 |
switch ( msg ) { |
switch (msg) { |
368 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
369 |
if (lparam != 0) |
if (lparam != 0) |
370 |
ctx = (genkey_s *)lparam; |
ctx = (genkey_s *)lparam; |
440 |
_("Key Generation"), MB_INFO); |
_("Key Generation"), MB_INFO); |
441 |
free_if_alloc (utf8_name); |
free_if_alloc (utf8_name); |
442 |
free_if_alloc (utf8_comment); |
free_if_alloc (utf8_comment); |
443 |
return FALSE; |
return TRUE; |
444 |
} |
} |
445 |
keytype = SendDlgItemMessage (dlg, IDC_KEYGEN_KEYTYPE, CB_GETCURSEL, 0, 0) + 1; |
keytype = SendDlgItemMessage (dlg, IDC_KEYGEN_KEYTYPE, CB_GETCURSEL, 0, 0) + 1; |
446 |
if (IsDlgButtonChecked (dlg, IDC_KEYGEN_EXPNEVER)) |
if (IsDlgButtonChecked (dlg, IDC_KEYGEN_EXPNEVER)) |
447 |
expire = NULL; |
expire = NULL; |
448 |
else { |
else { |
449 |
DateTime_GetSystemtime (GetDlgItem (dlg, IDC_KEYGEN_EXPDATE), &st); |
DateTime_GetSystemtime (GetDlgItem (dlg, IDC_KEYGEN_EXPDATE), &st); |
450 |
|
if (!keygen_check_date (&st)) { |
451 |
|
free_if_alloc (utf8_name); |
452 |
|
free_if_alloc (utf8_comment); |
453 |
|
msg_box (dlg, _("The date you have chosen lies in the past."), |
454 |
|
_("Key Generation"), MB_ERR); |
455 |
|
return TRUE; |
456 |
|
} |
457 |
_snprintf (t, DIM (t)-1, "%04d-%02d-%02d", st.wYear, st.wMonth, st.wDay); |
_snprintf (t, DIM (t)-1, "%04d-%02d-%02d", st.wYear, st.wMonth, st.wDay); |
458 |
expire = t; |
expire = t; |
459 |
} |
} |
484 |
keygen_cb_dlg_create (); |
keygen_cb_dlg_create (); |
485 |
err = gpg_genkey (p, keygen_cb, &fpr); |
err = gpg_genkey (p, keygen_cb, &fpr); |
486 |
sfree_if_alloc (pwd); |
sfree_if_alloc (pwd); |
487 |
if (p) { |
sfree_if_alloc (p); /* burn the passphrase! */ |
|
wipememory (p, strlen (p)); /* burn the passphrase! */ |
|
|
free_if_alloc (p); |
|
|
} |
|
488 |
keygen_cb_dlg_destroy (1); |
keygen_cb_dlg_destroy (1); |
489 |
if (err) { |
if (err) { |
490 |
free_if_alloc (fpr); |
free_if_alloc (fpr); |
547 |
center_window (dlg, NULL); |
center_window (dlg, NULL); |
548 |
break; |
break; |
549 |
|
|
|
case WM_SYSCOMMAND: |
|
|
if (LOWORD (wparam) == SC_CLOSE) |
|
|
EndDialog (dlg, FALSE); |
|
|
|
|
550 |
case WM_COMMAND: |
case WM_COMMAND: |
551 |
switch (LOWORD( wparam)) { |
switch (LOWORD( wparam)) { |
552 |
case IDC_KEYWIZARD_EXPERT: |
case IDC_KEYWIZARD_EXPERT: |
593 |
keygen_cb_dlg_create(); |
keygen_cb_dlg_create(); |
594 |
err = gpg_genkey (p, keygen_cb, &fpr); |
err = gpg_genkey (p, keygen_cb, &fpr); |
595 |
keygen_cb_dlg_destroy (1); |
keygen_cb_dlg_destroy (1); |
596 |
if (p) { |
sfree_if_alloc (p); |
|
wipememory (p, strlen (p)); |
|
|
free_if_alloc (p); |
|
|
} |
|
597 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
598 |
if (err) { |
if (err) { |
599 |
msg_box (dlg, gpgme_strerror( err ), _("Key Generation Wizard"), MB_ERR); |
msg_box (dlg, gpgme_strerror( err ), _("Key Generation Wizard"), MB_ERR); |