1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-05-24 16:43:28 +02:00

gpg: Simplify code to print VALIDSIG.

* g10/mainproc.c (check_sig_and_print): Use hexfingerprint and
write_status_printf.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-09-01 16:34:08 +02:00
parent 6bdadae005
commit fde9fa81d3
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -2104,35 +2104,26 @@ check_sig_and_print (CTX c, kbnode_t node)
} }
/* For good signatures print the VALIDSIG status line. */ /* For good signatures print the VALIDSIG status line. */
if (!rc && is_status_enabled ()) if (!rc && is_status_enabled () && pk)
{ {
if (pk) char pkhex[MAX_FINGERPRINT_LEN*2+1];
{ char mainpkhex[MAX_FINGERPRINT_LEN*2+1];
byte array[MAX_FINGERPRINT_LEN], *p;
char buf[MAX_FINGERPRINT_LEN*4+90], *bufp;
size_t i, n;
bufp = buf; hexfingerprint (pk, pkhex, sizeof pkhex);
fingerprint_from_pk (pk, array, &n); hexfingerprint (mainpk, mainpkhex, sizeof mainpkhex);
p = array;
for(i=0; i < n ; i++, p++, bufp += 2) /* TODO: Replace the reserved '0' in the field below with
sprintf (bufp, "%02X", *p ); bits for status flags (policy url, notation, etc.). */
/* TODO: Replace the reserved '0' in the field below write_status_printf (STATUS_VALIDSIG,
with bits for status flags (policy url, notation, "%s %s %lu %lu %d 0 %d %d %02X %s",
etc.). Remember to make the buffer larger to match! */ pkhex,
sprintf (bufp, " %s %lu %lu %d 0 %d %d %02X ", strtimestamp (sig->timestamp),
strtimestamp( sig->timestamp ), (ulong)sig->timestamp,
(ulong)sig->timestamp,(ulong)sig->expiredate, (ulong)sig->expiredate,
sig->version,sig->pubkey_algo,sig->digest_algo, sig->version, sig->pubkey_algo,
sig->sig_class); sig->digest_algo,
bufp = bufp + strlen (bufp); sig->sig_class,
if (!pk->flags.primary) mainpkhex);
fingerprint_from_pk (mainpk, array, &n);
p = array;
for (i=0; i < n ; i++, p++, bufp += 2)
sprintf(bufp, "%02X", *p );
write_status_text (STATUS_VALIDSIG, buf);
}
} }
/* For good signatures compute and print the trust information. /* For good signatures compute and print the trust information.