X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=keyindex.c;h=8277866d5ab31d4d2b038005303d00de5ef92689;hb=3b5b9db0bc2dbe93b3b79e722997606c71ecafb9;hp=5911cac81736ae53f9b66bca1348ff59edda6b74;hpb=5913c95f2c7abf4c3cb06e27d384d80fb4c83547;p=onak.git 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);