X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=keyindex.c;h=4dbb07414667a11921a7b870d20769342d821332;hb=b2f2bc60555e2d953069c40d8d3cdecfcec9ac29;hp=f3c36aafbf3527408894357ce80c1c7f6ecc2bd0;hpb=f8e9e43f90418ec6c8b5768a7981cbdabb64b198;p=onak.git diff --git a/keyindex.c b/keyindex.c index f3c36aa..4dbb074 100644 --- a/keyindex.c +++ b/keyindex.c @@ -138,7 +138,8 @@ unsigned int keylength(struct openpgp_packet *keydata) return length; } -int list_sigs(struct openpgp_packet_list *sigs, bool html) +int list_sigs(struct onak_dbctx *dbctx, + struct openpgp_packet_list *sigs, bool html) { char *uid = NULL; uint64_t sigid = 0; @@ -146,7 +147,7 @@ int list_sigs(struct openpgp_packet_list *sigs, bool html) while (sigs != NULL) { sigid = sig_keyid(sigs->packet); - uid = config.dbbackend->keyid2uid(sigid); + uid = dbctx->keyid2uid(dbctx, sigid); if (sigs->packet->data[0] == 4 && sigs->packet->data[1] == 0x30) { /* It's a Type 4 sig revocation */ @@ -188,7 +189,8 @@ int list_sigs(struct openpgp_packet_list *sigs, bool html) return 0; } -int list_uids(uint64_t keyid, struct openpgp_signedpacket_list *uids, +int list_uids(struct onak_dbctx *dbctx, + uint64_t keyid, struct openpgp_signedpacket_list *uids, bool verbose, bool html) { char buf[1024]; @@ -215,7 +217,7 @@ int list_uids(uint64_t keyid, struct openpgp_signedpacket_list *uids, } } if (verbose) { - list_sigs(uids->sigs, html); + list_sigs(dbctx, uids->sigs, html); } uids = uids->next; } @@ -223,7 +225,8 @@ int list_uids(uint64_t keyid, struct openpgp_signedpacket_list *uids, return 0; } -int list_subkeys(struct openpgp_signedpacket_list *subkeys, bool verbose, +int list_subkeys(struct onak_dbctx *dbctx, + struct openpgp_signedpacket_list *subkeys, bool verbose, bool html) { struct tm *created = NULL; @@ -270,7 +273,7 @@ int list_subkeys(struct openpgp_signedpacket_list *subkeys, bool verbose, } if (verbose) { - list_sigs(subkeys->sigs, html); + list_sigs(dbctx, subkeys->sigs, html); } subkeys = subkeys->next; } @@ -281,21 +284,21 @@ int list_subkeys(struct openpgp_signedpacket_list *subkeys, bool verbose, void display_fingerprint(struct openpgp_publickey *key) { int i = 0; - size_t length = 0; - unsigned char fp[20]; + struct openpgp_fingerprint fingerprint; - get_fingerprint(key->publickey, fp, &length); + get_fingerprint(key->publickey, &fingerprint); printf(" Key fingerprint ="); - for (i = 0; i < length; i++) { - if ((length == 16) || + for (i = 0; i < fingerprint.length; i++) { + if ((fingerprint.length == 16) || (i % 2 == 0)) { printf(" "); } - if (length == 20 && (i * 2) == length) { + if (fingerprint.length == 20 && + (i * 2) == fingerprint.length) { /* Extra space in the middle of a SHA1 fingerprint */ printf(" "); } - printf("%02X", fp[i]); + printf("%02X", fingerprint.fp[i]); } printf("\n"); @@ -337,7 +340,8 @@ void display_skshash(struct openpgp_publickey *key, bool html) * This function takes a list of OpenPGP public keys and displays an index * of them. Useful for debugging or the keyserver Index function. */ -int key_index(struct openpgp_publickey *keys, bool verbose, bool fingerprint, +int key_index(struct onak_dbctx *dbctx, + struct openpgp_publickey *keys, bool verbose, bool fingerprint, bool skshash, bool html) { struct openpgp_signedpacket_list *curuid = NULL; @@ -420,7 +424,7 @@ int key_index(struct openpgp_publickey *keys, bool verbose, bool fingerprint, display_fingerprint(keys); } if (verbose) { - list_sigs(curuid->sigs, html); + list_sigs(dbctx, curuid->sigs, html); } curuid = curuid->next; } else { @@ -431,9 +435,9 @@ int key_index(struct openpgp_publickey *keys, bool verbose, bool fingerprint, } } - list_uids(keyid, curuid, verbose, html); + list_uids(dbctx, keyid, curuid, verbose, html); if (verbose) { - list_subkeys(keys->subkeys, verbose, html); + list_subkeys(dbctx, keys->subkeys, verbose, html); } keys = keys->next; @@ -460,10 +464,9 @@ int mrkey_index(struct openpgp_publickey *keys) int type = 0; int length = 0; int i = 0; - size_t fplength = 0; - unsigned char fp[20]; int c; uint64_t keyid; + struct openpgp_fingerprint fingerprint; while (keys != NULL) { created_time = (keys->publickey->data[1] << 24) + @@ -483,10 +486,10 @@ int mrkey_index(struct openpgp_publickey *keys) type = keys->publickey->data[7]; break; case 4: - (void) get_fingerprint(keys->publickey, fp, &fplength); + (void) get_fingerprint(keys->publickey, &fingerprint); - for (i = 0; i < fplength; i++) { - printf("%02X", fp[i]); + for (i = 0; i < fingerprint.length; i++) { + printf("%02X", fingerprint.fp[i]); } type = keys->publickey->data[5];