gpg: Simplify status message code from commit b30c15bf.
authorWerner Koch <wk@gnupg.org>
Wed, 23 Dec 2015 14:45:30 +0000 (15:45 +0100)
committerWerner Koch <wk@gnupg.org>
Wed, 23 Dec 2015 14:46:05 +0000 (15:46 +0100)
* g10/keygen.c (card_write_key_to_backup_file): Simplify by using
hexfingerprint.
--

Note that the extra blank added to FPRBUF in the old code was not
needed because write_status_text_and_buffer already ensures that
there will be a space.

Signed-off-by: Werner Koch <wk@gnupg.org>
g10/keygen.c

index 03fc53c..992e572 100644 (file)
@@ -3861,28 +3861,13 @@ card_write_key_to_backup_file (PKT_public_key *sk, const char *backup_dir)
     }
   else
     {
-      unsigned char array[MAX_FINGERPRINT_LEN];
-      char *fprbuf, *p;
-      size_t n;
-      int i;
+      char *fprbuf;
 
       iobuf_close (fp);
       iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)fname);
       log_info (_("Note: backup of card key saved to '%s'\n"), fname);
 
-      fingerprint_from_pk (sk, array, &n);
-      p = fprbuf = xmalloc (MAX_FINGERPRINT_LEN*2 + 1 + 1);
-      if (!p)
-        {
-          err = gpg_error_from_syserror ();
-          goto leave;
-        }
-
-      for (i=0; i < n ; i++, p += 2)
-        sprintf (p, "%02X", array[i]);
-      *p++ = ' ';
-      *p = 0;
-
+      fprbuf = hexfingerprint (sk, NULL, 0);
       write_status_text_and_buffer (STATUS_BACKUP_KEY_CREATED, fprbuf,
                                     fname, strlen (fname), 0);
       xfree (fprbuf);