1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Fix pinpad input support

This commit is contained in:
NIIBE Yutaka 2011-12-01 11:09:51 +09:00
parent 31f548a18a
commit 2c5d021912
2 changed files with 56 additions and 17 deletions

View File

@ -1,3 +1,8 @@
2011-12-01 Niibe Yutaka <gniibe@fsij.org>
* app-openpgp.c (do_change_pin): Fix pincb messages when
use_keypad == 1.
2011-11-29 Niibe Yutaka <gniibe@fsij.org> 2011-11-29 Niibe Yutaka <gniibe@fsij.org>
PC/SC pininput support for passphrase modification (2/2) PC/SC pininput support for passphrase modification (2/2)

View File

@ -1983,7 +1983,7 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
if (chvno == 2) if (chvno == 2)
set_resetcode = 1; set_resetcode = 1;
} }
else if (chvno == 1 || chvno == 3) else if (!use_keypad && (chvno == 1 || chvno == 3))
{ {
char *promptbuf = NULL; char *promptbuf = NULL;
const char *prompt; const char *prompt;
@ -1998,7 +1998,7 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
} }
else else
prompt = _("||Please enter the PIN"); prompt = _("||Please enter the PIN");
rc = pincb (pincb_arg, prompt, use_keypad ? NULL : &oldpinvalue); rc = pincb (pincb_arg, prompt, &oldpinvalue);
xfree (promptbuf); xfree (promptbuf);
promptbuf = NULL; promptbuf = NULL;
if (rc) if (rc)
@ -2008,7 +2008,7 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
goto leave; goto leave;
} }
if (!use_keypad && strlen (oldpinvalue) < minlen) if (strlen (oldpinvalue) < minlen)
{ {
log_info (_("PIN for CHV%d is too short;" log_info (_("PIN for CHV%d is too short;"
" minimum length is %d\n"), chvno, minlen); " minimum length is %d\n"), chvno, minlen);
@ -2044,16 +2044,18 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
goto leave; goto leave;
} }
if (!use_keypad)
{
rc = pincb (pincb_arg, rc = pincb (pincb_arg,
_("||Please enter the Reset Code for the card"), _("||Please enter the Reset Code for the card"),
use_keypad ? NULL : &resetcode); &resetcode);
if (rc) if (rc)
{ {
log_info (_("PIN callback returned error: %s\n"), log_info (_("PIN callback returned error: %s\n"),
gpg_strerror (rc)); gpg_strerror (rc));
goto leave; goto leave;
} }
if (!use_keypad && strlen (resetcode) < minlen) if (strlen (resetcode) < minlen)
{ {
log_info (_("Reset Code is too short; minimum length is %d\n"), log_info (_("Reset Code is too short; minimum length is %d\n"),
minlen); minlen);
@ -2061,6 +2063,7 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
goto leave; goto leave;
} }
} }
}
else else
{ {
rc = gpg_error (GPG_ERR_INV_ID); rc = gpg_error (GPG_ERR_INV_ID);
@ -2094,6 +2097,15 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
{ {
if (use_keypad) if (use_keypad)
{ {
rc = pincb (pincb_arg,
_("||Please enter the Reset Code for the card and New PIN"),
NULL);
if (rc)
{
log_info (_("PIN callback returned error: %s\n"),
gpg_strerror (rc));
goto leave;
}
rc = iso7816_reset_retry_counter_with_rc_kp (app->slot, 0x81, rc = iso7816_reset_retry_counter_with_rc_kp (app->slot, 0x81,
&pininfo); &pininfo);
pincb (pincb_arg, NULL, NULL); /* Dismiss the prompt. */ pincb (pincb_arg, NULL, NULL); /* Dismiss the prompt. */
@ -2120,6 +2132,12 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
if (use_keypad) if (use_keypad)
{ {
rc = pincb (pincb_arg, _("|RN|New Reset Code"), NULL); rc = pincb (pincb_arg, _("|RN|New Reset Code"), NULL);
if (rc)
{
log_info (_("PIN callback returned error: %s\n"),
gpg_strerror (rc));
goto leave;
}
rc = iso7816_put_data_kp (app->slot, 0xD3, &pininfo); rc = iso7816_put_data_kp (app->slot, 0xD3, &pininfo);
pincb (pincb_arg, NULL, NULL); /* Dismiss the prompt. */ pincb (pincb_arg, NULL, NULL); /* Dismiss the prompt. */
} }
@ -2138,6 +2156,12 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
if (use_keypad) if (use_keypad)
{ {
rc = pincb (pincb_arg, _("|N|New PIN"), NULL); rc = pincb (pincb_arg, _("|N|New PIN"), NULL);
if (rc)
{
log_info (_("PIN callback returned error: %s\n"),
gpg_strerror (rc));
goto leave;
}
rc = iso7816_reset_retry_counter_kp (app->slot, 0x81, &pininfo); rc = iso7816_reset_retry_counter_kp (app->slot, 0x81, &pininfo);
pincb (pincb_arg, NULL, NULL); /* Dismiss the prompt. */ pincb (pincb_arg, NULL, NULL); /* Dismiss the prompt. */
} }
@ -2174,6 +2198,16 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
if (use_keypad) if (use_keypad)
{ {
rc = pincb (pincb_arg,
chvno == 3 ?
_("||Please enter the Admin PIN and New Admin PIN") :
_("||Please enter the PIN and New PIN"), NULL);
if (rc)
{
log_info (_("PIN callback returned error: %s\n"),
gpg_strerror (rc));
goto leave;
}
rc = iso7816_change_reference_data_kp (app->slot, 0x80 + chvno, rc = iso7816_change_reference_data_kp (app->slot, 0x80 + chvno,
&pininfo); &pininfo);
pincb (pincb_arg, NULL, NULL); /* Dismiss the prompt. */ pincb (pincb_arg, NULL, NULL); /* Dismiss the prompt. */