Changeset View
Changeset View
Standalone View
Standalone View
b/agent/genkey.c
Context not available. | |||||
gpg_error_t err; | gpg_error_t err; | ||||
if (opt.enforce_passphrase_constraints) | if (opt.enforce_passphrase_constraints) | ||||
{ | /* Passphrase constraints errors are shown | ||||
err = agent_show_message (ctrl, desc, _("Enter new passphrase")); | * as error messages in password prompt */ | ||||
if (!err) | err = gpg_error (GPG_ERR_CANCELED); | ||||
err = gpg_error (GPG_ERR_CANCELED); | |||||
} | |||||
else | else | ||||
err = agent_get_confirmation (ctrl, desc, | err = agent_get_confirmation (ctrl, desc, | ||||
anyway_btn, _("Enter new passphrase"), 0); | anyway_btn, _("Enter new passphrase"), 0); | ||||
Context not available. | |||||
/* Check whether the passphrase PW is suitable. Returns 0 if the | /* Check whether the passphrase PW is suitable. Returns 0 if the | ||||
passphrase is suitable and true if it is not and the user should be | passphrase is suitable and true if it is not and the user should be | ||||
asked to provide a different one. If SILENT is set, no message are | asked to provide a different one. If SILENT is set, no message are | ||||
displayed. */ | displayed. If FAILED_CONSTRAINT is set and SILENT is not, the error | ||||
messages are returned */ | |||||
int | int | ||||
check_passphrase_constraints (ctrl_t ctrl, const char *pw, int silent) | check_passphrase_constraints (ctrl_t ctrl, const char *pw, int silent, char **failed_constraint) | ||||
{ | { | ||||
gpg_error_t err = 0; | gpg_error_t err = 0; | ||||
unsigned int minlen = opt.min_passphrase_len; | unsigned int minlen = opt.min_passphrase_len; | ||||
Context not available. | |||||
err = take_this_one_anyway2 (ctrl, desc, | err = take_this_one_anyway2 (ctrl, desc, | ||||
_("Yes, protection is not needed")); | _("Yes, protection is not needed")); | ||||
if (failed_constraint) | |||||
*failed_constraint = xstrdup (desc); | |||||
goto leave; | goto leave; | ||||
} | } | ||||
Context not available. | |||||
/* Show error messages. */ | /* Show error messages. */ | ||||
err = take_this_one_anyway (ctrl, msg); | err = take_this_one_anyway (ctrl, msg); | ||||
if (failed_constraint) | |||||
*failed_constraint = xtrystrdup (msg); | |||||
xfree (msg); | xfree (msg); | ||||
} | } | ||||
Context not available. | |||||
gpg_error_t err; | gpg_error_t err; | ||||
const char *text1 = prompt; | const char *text1 = prompt; | ||||
const char *text2 = _("Please re-enter this passphrase"); | const char *text2 = _("Please re-enter this passphrase"); | ||||
const char *initial_errtext = NULL; | char *initial_errtext = NULL; | ||||
struct pin_entry_info_s *pi, *pi2; | struct pin_entry_info_s *pi, *pi2; | ||||
*r_passphrase = NULL; | *r_passphrase = NULL; | ||||
Context not available. | |||||
next_try: | next_try: | ||||
err = agent_askpin (ctrl, text1, NULL, initial_errtext, pi, NULL, 0); | err = agent_askpin (ctrl, text1, NULL, initial_errtext, pi, NULL, 0); | ||||
xfree (initial_errtext); | |||||
initial_errtext = NULL; | initial_errtext = NULL; | ||||
if (!err) | if (!err) | ||||
{ | { | ||||
if (check_passphrase_constraints (ctrl, pi->pin, 0)) | if (check_passphrase_constraints (ctrl, pi->pin, 0, &initial_errtext)) | ||||
{ | { | ||||
pi->failed_tries = 0; | pi->failed_tries = 0; | ||||
pi2->failed_tries = 0; | pi2->failed_tries = 0; | ||||
Context not available. | |||||
if (err == -1) | if (err == -1) | ||||
{ /* The re-entered one did not match and the user did not | { /* The re-entered one did not match and the user did not | ||||
hit cancel. */ | hit cancel. */ | ||||
initial_errtext = _("does not match - try again"); | initial_errtext = xstrdup ("does not match - try again"); | ||||
goto next_try; | goto next_try; | ||||
} | } | ||||
} | } | ||||
Context not available. |