diff options
author | Werner Koch <[email protected]> | 2024-06-05 07:10:47 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2024-06-05 08:01:43 +0000 |
commit | 9d618d1273120ca2cca97028730352768b0c1897 (patch) | |
tree | 042a53b6d053b20367d97a6d93dd961a4293564b /g10/keylist.c | |
parent | gpg: Autoload designated revoker key and ADSK when needed. (diff) | |
download | gnupg-9d618d1273120ca2cca97028730352768b0c1897.tar.gz gnupg-9d618d1273120ca2cca97028730352768b0c1897.zip |
gpg: Print designated revokers also in a standard listing.
* g10/keylist.c (print_revokers): Add arg with_colon, adjust callers,
add human printable format.
(list_keyblock_print): Call print_revokers.
--
Designated revokers were only printed in --with-colons mode. For
quick inspection of a key it is useful to see them right away.
Diffstat (limited to 'g10/keylist.c')
-rw-r--r-- | g10/keylist.c | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/g10/keylist.c b/g10/keylist.c index 81d6805a5..57d73bc4b 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -1555,6 +1555,8 @@ list_keyblock_print (ctrl_t ctrl, kbnode_t keyblock, int secret, int fpr, es_putc ('\n', es_stdout); } + print_revokers (es_stdout, 0, pk); + for (node = keyblock; node; node = node->next) { if (is_deleted_kbnode (node)) @@ -1784,28 +1786,43 @@ list_keyblock_simple (ctrl_t ctrl, kbnode_t keyblock) } +/* Print the revoker records. */ void -print_revokers (estream_t fp, PKT_public_key * pk) +print_revokers (estream_t fp, int colon_mode, PKT_public_key * pk) { - /* print the revoker record */ + int i, j; + const byte *p; + if (!pk->revkey && pk->numrevkeys) BUG (); - else - { - int i, j; - - for (i = 0; i < pk->numrevkeys; i++) - { - byte *p; - es_fprintf (fp, "rvk:::%d::::::", pk->revkey[i].algid); - p = pk->revkey[i].fpr; - for (j = 0; j < pk->revkey[i].fprlen; j++, p++) - es_fprintf (fp, "%02X", *p); - es_fprintf (fp, ":%02x%s:\n", + for (i = 0; i < pk->numrevkeys; i++) + { + if (colon_mode) + { + es_fprintf (fp, "rvk:::%d::::::", pk->revkey[i].algid); + p = pk->revkey[i].fpr; + for (j = 0; j < pk->revkey[i].fprlen; j++, p++) + es_fprintf (fp, "%02X", *p); + es_fprintf (fp, ":%02x%s:\n", pk->revkey[i].class, (pk->revkey[i].class & 0x40) ? "s" : ""); - } + } + else + { + es_fprintf (fp, "%*s%s", 6, "", _("Revocable by: ")); + p = pk->revkey[i].fpr; + es_write_hexstring (fp, pk->revkey[i].fpr, pk->revkey[i].fprlen, + 0, NULL); + if ((pk->revkey[i].class & 0x40)) + es_fprintf (fp, " %s", _("(sensitive)")); + /* Class bit 7 must always be set, bit 6 indicates sensitive + * and all others bits are reserved. */ + if (!(pk->revkey[i].class & ~0x40) + || (pk->revkey[i].class & ~(0x40|0x80))) + es_fprintf (fp, " (unknown class %02x)", pk->revkey[i].class); + es_fprintf (fp, "\n"); + } } } @@ -1967,7 +1984,7 @@ list_keyblock_colon (ctrl_t ctrl, kbnode_t keyblock, es_putc (':', es_stdout); /* End of field 20 (origin). */ es_putc ('\n', es_stdout); - print_revokers (es_stdout, pk); + print_revokers (es_stdout, 1, pk); print_fingerprint (ctrl, NULL, pk, 0); if (hexgrip) es_fprintf (es_stdout, "grp:::::::::%s:\n", hexgrip); |