X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/5913c95f2c7abf4c3cb06e27d384d80fb4c83547..8e454e9e224e84113a93ad22103613be4ff72b3f:/keyindex.c?ds=inline diff --git a/keyindex.c b/keyindex.c index 5911cac..8277866 100644 --- a/keyindex.c +++ b/keyindex.c @@ -21,6 +21,7 @@ #include "keyid.h" #include "keyindex.h" #include "keystructs.h" +#include "log.h" int list_sigs(struct openpgp_packet_list *sigs, bool html) { @@ -114,7 +115,8 @@ int list_subkeys(struct openpgp_signedpacket_list *subkeys, bool verbose, subkeys->packet->data[7]; break; default: - fprintf(stderr, "Unknown key type: %d\n", + logthing(LOGTHING_ERROR, + "Unknown key type: %d", subkeys->packet->data[0]); } @@ -138,6 +140,29 @@ int list_subkeys(struct openpgp_signedpacket_list *subkeys, bool verbose, return 0; } +void display_fingerprint(struct openpgp_publickey *key) +{ + int i = 0; + size_t length = 0; + unsigned char fp[20]; + + get_fingerprint(key->publickey, fp, &length); + printf(" Key fingerprint ="); + for (i = 0; i < length; i++) { + if ((length == 16) || + (i % 2 == 0)) { + printf(" "); + } + printf("%02X", fp[i]); + if ((i * 2) == length) { + printf(" "); + } + } + printf("\n"); + + return; +} + /** * key_index - List a set of OpenPGP keys. * @keys: The keys to display. @@ -182,7 +207,7 @@ int key_index(struct openpgp_publickey *keys, bool verbose, bool fingerprint, keys->publickey->data[7]; break; default: - fprintf(stderr, "Unknown key type: %d\n", + logthing(LOGTHING_ERROR, "Unknown key type: %d", keys->publickey->data[0]); } @@ -201,12 +226,18 @@ int key_index(struct openpgp_publickey *keys, bool verbose, bool fingerprint, (int) curuid->packet->length, curuid->packet->data); printf("%s\n", (html) ? txt2html(buf) : buf); + if (fingerprint) { + display_fingerprint(keys); + } if (verbose) { list_sigs(curuid->sigs, html); } curuid = curuid->next; } else { putchar('\n'); + if (fingerprint) { + display_fingerprint(keys); + } } list_uids(curuid, verbose, html);