1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-23 01:22:45 +02:00

card: Print PIN descriptions and fix number of printed retry counters.

* tools/gpg-card.h (struct card_info_s): Add fields nmaxlen, nchvinfo,
and chvlabels.
* tools/card-call-scd.c (release_card_info): Free chvlabels.
(learn_status_cb): Parse CHV-LABEL.  Set nmaxlen and nchvinfo.
* tools/gpg-card.c (list_retry_counter): Print CHV labels.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2021-03-18 11:29:31 +01:00
parent ef29a960bf
commit 1ac189f2df
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 15 additions and 1 deletions

View File

@ -161,6 +161,7 @@ release_card_info (card_info_t info)
info->kinfo = kinfo;
}
info->chvusage[0] = info->chvusage[1] = 0;
xfree (info->chvlabels); info->chvlabels = NULL;
for (i=0; i < DIM(info->supported_keyalgo); i++)
{
free_strlist (info->supported_keyalgo[i]);
@ -909,6 +910,11 @@ learn_status_cb (void *opaque, const char *line)
parm->chvusage[0] = byte1;
parm->chvusage[1] = byte2;
}
else if (!memcmp (keyword, "CHV-LABEL", keywordlen))
{
xfree (parm->chvlabels);
parm->chvlabels = xstrdup (line);
}
break;
case 10:
@ -948,6 +954,7 @@ learn_status_cb (void *opaque, const char *line)
while (spacep (p))
p++;
}
parm->nchvmaxlen = 3;
for (i=0; *p && i < 3; i++)
{
parm->chvinfo[i] = atoi (p);
@ -956,6 +963,7 @@ learn_status_cb (void *opaque, const char *line)
while (spacep (p))
p++;
}
parm->nchvinfo = 3;
}
else
{
@ -967,6 +975,7 @@ learn_status_cb (void *opaque, const char *line)
while (spacep (p))
p++;
}
parm->nchvinfo = i;
}
xfree (buf);

View File

@ -836,8 +836,10 @@ list_retry_counter (card_info_t info, estream_t fp)
const char *s;
int i;
if (info->chvlabels)
tty_fprintf (fp, "PIN labels .......: %s\n", info->chvlabels);
tty_fprintf (fp, "PIN retry counter :");
for (i=0; i < DIM (info->chvinfo); i++)
for (i=0; i < DIM (info->chvinfo) && i < info->nchvinfo; i++)
{
if (info->chvinfo[i] >= 0)
tty_fprintf (fp, " %d", info->chvinfo[i]);

View File

@ -172,8 +172,11 @@ struct card_info_s
required for each signing. Note that the
gpg-agent might cache it anyway. */
int is_v2; /* True if this is a v2 openpgp card. */
byte nchvmaxlen; /* Number of valid items in CHVMAXLEN. */
int chvmaxlen[4]; /* Maximum allowed length of a CHV. */
byte nchvinfo; /* Number of valid items in CHVINFO. */
int chvinfo[4]; /* Allowed retries for the CHV; 0 = blocked. */
char *chvlabels; /* Malloced String with CHV labels. */
unsigned char chvusage[2]; /* Data object 5F2F */
struct {
unsigned int ki:1; /* Key import available. */