aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2024-01-30 14:50:09 +0000
committerWerner Koch <[email protected]>2024-01-30 14:50:09 +0000
commitce69c103f433463181f2b26e90b9f0d96594e00d (patch)
treede52c660a1b74457a517bc623f868fc79c094999
parentPrepare NEWS for 2.2.43 (diff)
downloadgnupg-ce69c103f433463181f2b26e90b9f0d96594e00d.tar.gz
gnupg-ce69c103f433463181f2b26e90b9f0d96594e00d.zip
scd:openpgp: Allow PIN length of 6 also with a reset code.
* scd/app-openpgp.c (do_change_pin): Fix PIN length check. Add "R" flag to the reset code prompt. -- When using the reset code it was not possible to set a PIN of length 6. The "R" flags fixes a funny prompt. Fixes-commit: efe325ffdf21205b90f888c8f0248bbd4f61404b
-rw-r--r--scd/app-openpgp.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index 27da77294..0ce09e1a0 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -3087,6 +3087,7 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
char *pinvalue = NULL;
int reset_mode = !!(flags & APP_CHANGE_FLAG_RESET);
int set_resetcode = 0;
+ int use_resetcode = 0;
pininfo_t pininfo;
int use_pinpad = 0;
int minlen = 6;
@@ -3245,7 +3246,7 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
}
rc = pincb (pincb_arg,
- _("||Please enter the Reset Code for the card"),
+ _("|R|Please enter the Reset Code for the card"),
&resetcode);
if (rc)
{
@@ -3260,13 +3261,14 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
rc = gpg_error (GPG_ERR_BAD_PIN);
goto leave;
}
+ use_resetcode = 1;
}
else
{
rc = gpg_error (GPG_ERR_INV_ID);
goto leave;
}
- }
+ } /* End version 2 cards. */
if (chvno == 3)
app->did_chv3 = 0;
@@ -3298,6 +3300,17 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
goto leave;
}
}
+ else if (use_resetcode)
+ {
+ minlen = 6; /* Reset from the RC value to the PIN value. */
+ if (strlen (pinvalue) < minlen)
+ {
+ log_info (_("PIN for CHV%d is too short;"
+ " minimum length is %d\n"), 1, minlen);
+ rc = gpg_error (GPG_ERR_BAD_PIN);
+ goto leave;
+ }
+ }
else
{
if (chvno == 3)