From fd595c9d3642dba437fbe0f6e25d7aaaae095f94 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 1 Mar 2018 19:03:23 +0100 Subject: gpg: Print the keygrip with --card-status * g10/call-agent.h (agent_card_info_s): Add fields grp1, grp2 and grp3. * g10/call-agent.c (unhexify_fpr): Allow for space as delimiter. (learn_status_cb): Parse KEYPARIINFO int the grpX fields. * g10/card-util.c (print_keygrip): New. (current_card_status): Print "grp:" records or with --with-keygrip a human readable keygrip. -- Suggested-by: Peter Lebbing Signed-off-by: Werner Koch --- g10/call-agent.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'g10/call-agent.c') diff --git a/g10/call-agent.c b/g10/call-agent.c index 545b2448a..f29e1b131 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -381,10 +381,11 @@ unhexify_fpr (const char *hexstr, unsigned char *fpr) for (s=hexstr, n=0; hexdigitp (s); s++, n++) ; - if (*s || (n != 40)) + if ((*s && *s != ' ') || (n != 40)) return 0; /* no fingerprint (invalid or wrong length). */ for (s=hexstr, n=0; *s; s += 2, n++) fpr[n] = xtoi_2 (s); + return 1; /* okay */ } @@ -625,6 +626,24 @@ learn_status_cb (void *opaque, const char *line) else if (no == 3) parm->fpr3time = strtoul (line, NULL, 10); } + else if (keywordlen == 11 && !memcmp (keyword, "KEYPAIRINFO", keywordlen)) + { + const char *hexgrp = line; + int no; + + while (*line && !spacep (line)) + line++; + while (spacep (line)) + line++; + if (strncmp (line, "OPENPGP.", 8)) + ; + else if ((no = atoi (line+8)) == 1) + unhexify_fpr (hexgrp, parm->grp1); + else if (no == 2) + unhexify_fpr (hexgrp, parm->grp2); + else if (no == 3) + unhexify_fpr (hexgrp, parm->grp3); + } else if (keywordlen == 6 && !memcmp (keyword, "CA-FPR", keywordlen)) { int no = atoi (line); -- cgit v1.2.3