struct pgp_keyinfo
{
char *keyid;
+ char *fingerprint;
struct pgp_uid *address;
int flags;
short keylen;
struct pgp_keyinfo *parent;
struct pgp_signature *sigs;
struct pgp_keyinfo *next;
-
- short fp_len; /* length of fingerprint.
- * 20 for sha-1, 16 for md5.
- */
- unsigned char fingerprint[20]; /* large enough to hold SHA-1 and RIPEMD160
- hashes (20 bytes), MD5 hashes just use the
- first 16 bytes */
};
/* Note, that pgp_key_t is now pointer and declared in crypt.h */
return 0;
}
+static char *binary_fingerprint_to_string (unsigned char *buff, size_t length)
+{
+ int i;
+ char *fingerprint, *pf;
+
+ pf = fingerprint = (char *)safe_malloc ((length * 2) + 1);
+
+ for (i = 0; i < length; i++)
+ {
+ sprintf (pf, "%02X", buff[i]);
+ pf += 2;
+ }
+ *pf = 0;
+
+ return fingerprint;
+}
+
/* The actual key ring parser */
static void pgp_make_pgp2_fingerprint (unsigned char *buff,
if (dump_fingerprints)
{
/* j now points to the key material, which we need for the fingerprint */
- p->fp_len = MD5_DIGEST_LENGTH;
pgp_make_pgp2_fingerprint (&buff[j], digest);
- memcpy (p->fingerprint, digest, MD5_DIGEST_LENGTH);
+ p->fingerprint = binary_fingerprint_to_string (digest, MD5_DIGEST_LENGTH);
}
- else /* just to be usre */
- memset (p->fingerprint, 0, MD5_DIGEST_LENGTH);
expl = 0;
for (i = 0; i < 2; i++)
skip_bignum (buff, l, j, &j, 1);
pgp_make_pgp3_fingerprint (buff, j, digest);
- p->fp_len = SHA_DIGEST_LENGTH;
+ if (dump_fingerprints)
+ {
+ p->fingerprint = binary_fingerprint_to_string (digest, SHA_DIGEST_LENGTH);
+ }
for (k = 0; k < 2; k++)
{
static void print_fingerprint (pgp_key_t p)
{
- int i = 0;
-
- printf ("fpr:::::::::");
- for (i = 0; i < p->fp_len; i++)
- printf ("%02X", p->fingerprint[i]);
- printf (":\n");
+ if (!p->fingerprint)
+ return;
+ printf ("fpr:::::::::%s:\n", p->fingerprint);
} /* print_fingerprint() */