aboutsummaryrefslogtreecommitdiffstats
path: root/tools/card-call-scd.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-02-13 10:53:32 +0000
committerWerner Koch <[email protected]>2020-02-13 10:53:32 +0000
commite63f8bee4044e0cc9ebc1f9c0f9f6b63660d45e8 (patch)
treeb529112d204657b9f5fde19a1239f00fe8d25319 /tools/card-call-scd.c
parentscd:openpgp: Return key creation time as part of KEYPARIINFO. (diff)
downloadgnupg-e63f8bee4044e0cc9ebc1f9c0f9f6b63660d45e8.tar.gz
gnupg-e63f8bee4044e0cc9ebc1f9c0f9f6b63660d45e8.zip
card: Take the key creation time from the KEYPAIRINFO
* tools/card-call-scd.c (learn_status_cb): Adjust for recent change. -- This adjusts for the chnage in scdaemon. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tools/card-call-scd.c')
-rw-r--r--tools/card-call-scd.c63
1 files changed, 18 insertions, 45 deletions
diff --git a/tools/card-call-scd.c b/tools/card-call-scd.c
index 237f792f5..1737630a2 100644
--- a/tools/card-call-scd.c
+++ b/tools/card-call-scd.c
@@ -790,31 +790,6 @@ learn_status_cb (void *opaque, const char *line)
{
parm->disp_sex = *line == '1'? 1 : *line == '2' ? 2: 0;
}
- else if (!memcmp (keyword, "KEY-TIME", keywordlen))
- {
- /* The format of such a line is:
- * KEY-TIME <keyref> <timestamp>
- */
- const char *timestamp;
-
- line_buffer = pline = xstrdup (line);
-
- keyref = parse_keyref_helper (pline);
- while (*pline && !spacep (pline))
- pline++;
- if (*pline)
- *pline++ = 0; /* Terminate keyref. */
- while (spacep (pline)) /* Skip to the timestamp. */
- pline++;
- timestamp = pline;
-
- /* Check whether we already have an item for the keyref. */
- kinfo = find_kinfo (parm, keyref);
- if (!kinfo) /* No: new entry. */
- kinfo = create_kinfo (parm, keyref);
-
- kinfo->created = strtoul (timestamp, NULL, 10);
- }
else if (!memcmp (keyword, "KEY-ATTR", keywordlen))
{
char keyrefbuf[20];
@@ -968,33 +943,28 @@ learn_status_cb (void *opaque, const char *line)
else if (!memcmp (keyword, "KEYPAIRINFO", keywordlen))
{
/* The format of such a line is:
- * KEYPAIRINFO <hexgrip> <keyref> [usage]
+ * KEYPAIRINFO <hexgrip> <keyref> [usage] [keytime]
*/
- char *hexgrp, *usage;
+ char *fields[4];
+ int nfields;
+ const char *hexgrp, *usage;
+ time_t keytime;
line_buffer = pline = xstrdup (line);
- hexgrp = pline;
- while (*pline && !spacep (pline))
- pline++;
- while (spacep (pline))
- pline++;
+ if ((nfields = split_fields (line_buffer, fields, DIM (fields))) < 2)
+ goto leave; /* not enough args - invalid status line. */
- keyref = pline;
- while (*pline && !spacep (pline))
- pline++;
- if (*pline)
- {
- *pline++ = 0;
- while (spacep (pline))
- pline++;
- usage = pline;
- while (*pline && !spacep (pline))
- pline++;
- *pline = 0;
- }
+ hexgrp = fields[0];
+ keyref = fields[1];
+ if (nfields > 2)
+ usage = fields[2];
else
usage = "";
+ if (nfields > 3)
+ keytime = parse_timestamp (fields[3], NULL);
+ else
+ keytime = 0;
/* Check whether we already have an item for the keyref. */
kinfo = find_kinfo (parm, keyref);
@@ -1021,6 +991,8 @@ learn_status_cb (void *opaque, const char *line)
case 'e': kinfo->usage |= GCRY_PK_USAGE_ENCR; break;
}
}
+ /* Store the keytime. */
+ kinfo->created = keytime == (time_t)(-1)? 0 : (u32)keytime;
}
else if (!memcmp (keyword, "CARDVERSION", keywordlen))
{
@@ -1055,6 +1027,7 @@ learn_status_cb (void *opaque, const char *line)
break;
}
+ leave:
xfree (line_buffer);
return 0;
}