summaryrefslogtreecommitdiffstats
path: root/scd/app-openpgp.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2024-01-30 15:50:09 +0100
committerWerner Koch <wk@gnupg.org>2024-01-30 15:58:14 +0100
commit40b85d8e8cecadf35e51e84b30de4fac820d714b (patch)
tree6a5f16a20e6fce3233c06f78e532602eca00a456 /scd/app-openpgp.c
parentw32, msi: Fix directory of gpg-card, add keyboxd (diff)
downloadgnupg2-40b85d8e8cecadf35e51e84b30de4fac820d714b.tar.xz
gnupg2-40b85d8e8cecadf35e51e84b30de4fac820d714b.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 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: 2376cdff1318688d94c95fd01adc4b2139c4a8c7
Diffstat (limited to '')
-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 3bc709602..1f5d64e6a 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -3306,6 +3306,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;
@@ -3458,7 +3459,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)
{
@@ -3473,13 +3474,14 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
rc = gpg_error (GPG_ERR_BAD_RESET_CODE);
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;
@@ -3511,6 +3513,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)