58 |
burn_passphrase (char **pwd) |
burn_passphrase (char **pwd) |
59 |
{ |
{ |
60 |
char *pass = *pwd; |
char *pass = *pwd; |
61 |
|
|
62 |
wipememory (pass, strlen (pass)); |
wipememory (pass, strlen (pass)); |
63 |
delete []pass; |
delete []pass; |
64 |
*pwd = NULL; |
*pwd = NULL; |
179 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
180 |
return FALSE; |
return FALSE; |
181 |
|
|
|
case WM_SYSCOMMAND: |
|
|
if (LOWORD (wparam) == SC_CLOSE) { |
|
|
c->cancel = 1; |
|
|
EndDialog (dlg, TRUE); |
|
|
} |
|
|
break; |
|
|
|
|
182 |
case WM_COMMAND: |
case WM_COMMAND: |
183 |
switch (HIWORD (wparam)) { |
switch (HIWORD (wparam)) { |
184 |
case BN_CLICKED: |
case BN_CLICKED: |
218 |
} |
} |
219 |
res = gpgme_op_decrypt_result (c->gpg); |
res = gpgme_op_decrypt_result (c->gpg); |
220 |
if (!res) |
if (!res) |
221 |
res_sig = gpgme_op_sign_result (c->gpg); |
res_sig = gpgme_op_sign_result (c->gpg); |
222 |
if (!c->is_card && reg_prefs.cache_time > 0 && |
if (!c->is_card && reg_prefs.cache_time > 0 && |
223 |
(res || res_sig)) { |
(res || res_sig)) { |
224 |
if (agent_get_cache (c->keyid, &item)) |
if (agent_get_cache (c->keyid, &item)) |
234 |
SetDlgItemText (dlg, item_ctrl_id (c->gpg_cmd), ""); |
SetDlgItemText (dlg, item_ctrl_id (c->gpg_cmd), ""); |
235 |
c->cancel = 1; |
c->cancel = 1; |
236 |
EndDialog (dlg, FALSE); |
EndDialog (dlg, FALSE); |
237 |
return FALSE; |
return TRUE; |
238 |
} |
} |
239 |
break; |
break; |
240 |
} |
} |
344 |
int rc = 0; |
int rc = 0; |
345 |
|
|
346 |
if (!c) { |
if (!c) { |
347 |
log_debug ("passphrase_cb: error '!c'\r\n"); |
log_debug ("passphrase_cb: error no valid callback\r\n"); |
348 |
return gpg_error (GPG_ERR_INV_ARG); |
return gpg_error (GPG_ERR_INV_ARG); |
349 |
} |
} |
350 |
c->bad_pwd = prev_was_bad? 1 : 0; |
c->bad_pwd = prev_was_bad? 1 : 0; |
412 |
if (rc == -1) { |
if (rc == -1) { |
413 |
if (!WriteFile (hd, "\n", 1, &n, NULL)) |
if (!WriteFile (hd, "\n", 1, &n, NULL)) |
414 |
log_debug ("passphrase_cb: WriteFile() failed ec=%d\n", w32_errno); |
log_debug ("passphrase_cb: WriteFile() failed ec=%d\n", w32_errno); |
415 |
|
log_debug ("passphrase_cb: could not create dialog box\n"); |
416 |
return 0; |
return 0; |
417 |
} |
} |
418 |
c->pwd_init = 0; |
c->pwd_init = 0; |
482 |
} |
} |
483 |
|
|
484 |
|
|
485 |
/* Simple check to measure passphrase (@pass) quality. |
/* _Simple_ check to measure passphrase (@pass) quality. |
486 |
Return value: 0 on success. */ |
Return value: 0 on success. */ |
487 |
int |
int |
488 |
check_passwd_quality (const char *pass, int strict) |
check_passwd_quality (const char *pass, int strict) |
489 |
{ |
{ |
490 |
int i, nd=0, nc=0, n; |
int i, nd=0, nc=0, n; |
491 |
|
|
492 |
|
/* A good passphrase should be at least 8 characters. */ |
493 |
n = strlen (pass); |
n = strlen (pass); |
494 |
if (n < 8) |
if (n < 8) |
495 |
return -1; |
return -1; |
496 |
|
|
497 |
for (i=0; i < n; i++) { |
for (i=0; i < n; i++) { |
498 |
if (isdigit (pass[i])) |
if (isdigit (pass[i])) |
499 |
nd++; |
nd++; |
500 |
if (isalpha (pass[i])) |
if (isalpha (pass[i])) |
501 |
nc++; |
nc++; |
502 |
} |
} |
503 |
|
|
504 |
/* check that the passphrase contains letters and numbers. */ |
/* Check that the passphrase contains letters and numbers. */ |
505 |
if (nd == n || nc == n) |
if (nd == n || nc == n) |
506 |
return -1; |
return -1; |
507 |
|
|