g10: Fix enum_secret_keys for card keys.
authorNIIBE Yutaka <gniibe@fsij.org>
Tue, 12 Jun 2018 07:20:21 +0000 (16:20 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Mon, 27 Aug 2018 07:25:05 +0000 (16:25 +0900)
* g10/skclist.c (enum_secret_keys): Since "KEY-FPR" returns
fingerprint in binary, change it to hex string.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
g10/skclist.c

index d40fe6d..fe24b4a 100644 (file)
@@ -331,6 +331,7 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
     strlist_t sl;
     strlist_t card_list;
     char *serialno;
+    char fpr2[43];
     struct agent_card_info_s info;
     kbnode_t keyblock;
     kbnode_t node;
@@ -350,7 +351,6 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
   if (!sk)
     {
       /* Free the context.  */
-      agent_release_card_info (&c->info);
       xfree (c->serialno);
       free_strlist (c->card_list);
       pubkeys_free (c->results);
@@ -419,14 +419,19 @@ enum_secret_keys (ctrl_t ctrl, void **context, PKT_public_key *sk)
                         }
 
                       xfree (serialno);
-                      agent_release_card_info (&c->info);
+                      c->info.fpr2valid = 0;
                       err = agent_scd_getattr ("KEY-FPR", &c->info);
                       if (err)
                         log_error ("error retrieving key fingerprint from card: %s\n",
                                    gpg_strerror (err));
 
                       if (c->info.fpr2valid)
-                        name = c->info.fpr2;
+                        {
+                          c->fpr2[0] = '0';
+                          c->fpr2[1] = 'x';
+                          bin2hex (c->info.fpr2, 20, c->fpr2+2);
+                          name = c->fpr2;
+                        }
                       c->sl = c->sl->next;
                     }
                   else