X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb.c;h=c5b07c628dfd2040d3152311dc85bec31ce729ad;hb=39627dc8919cce4132cd21528f1e3c6c38aeae85;hp=2547b6b090cc8302b2378fa3805be637b686debd;hpb=4b8483ae278577a3adc8d84da81d77019704466f;p=onak.git diff --git a/keydb.c b/keydb.c index 2547b6b..c5b07c6 100644 --- a/keydb.c +++ b/keydb.c @@ -23,6 +23,7 @@ #include "mem.h" #include "parsekey.h" +#ifdef NEED_KEYID2UID /** * keyid2uid - Takes a keyid and returns the primary UID for it. * @keyid: The keyid to lookup. @@ -31,10 +32,10 @@ char *keyid2uid(uint64_t keyid) { struct openpgp_publickey *publickey = NULL; struct openpgp_signedpacket_list *curuid = NULL; - static char buf[1024]; + char buf[1024]; buf[0]=0; - if (fetch_key(keyid, &publickey) && publickey != NULL) { + if (fetch_key(keyid, &publickey, false) && publickey != NULL) { curuid = publickey->uids; while (curuid != NULL && buf[0] == 0) { if (curuid->packet->tag == 13) { @@ -50,10 +51,12 @@ char *keyid2uid(uint64_t keyid) if (buf[0] == 0) { return NULL; } else { - return buf; + return strdup(buf); } } +#endif +#ifdef NEED_GETKEYSIGS /** * getkeysigs - Gets a linked list of the signatures on a key. * @keyid: The keyid to get the sigs for. @@ -67,7 +70,7 @@ struct ll *getkeysigs(uint64_t keyid) struct openpgp_signedpacket_list *uids = NULL; struct openpgp_publickey *publickey = NULL; - fetch_key(keyid, &publickey); + fetch_key(keyid, &publickey, false); if (publickey != NULL) { for (uids = publickey->uids; uids != NULL; uids = uids->next) { @@ -75,6 +78,29 @@ struct ll *getkeysigs(uint64_t keyid) } free_publickey(publickey); } - + return sigs; } +#endif + +#ifdef NEED_GETFULLKEYID +/** + * getfullkeyid - Maps a 32bit key id to a 64bit one. + * @keyid: The 32bit keyid. + * + * This function maps a 32bit key id to the full 64bit one. It returns the + * full keyid. + */ +uint64_t getfullkeyid(uint64_t keyid) +{ + struct openpgp_publickey *publickey = NULL; + + if (keyid < 0x100000000LL) { + fetch_key(keyid, &publickey, false); + keyid = get_keyid(publickey); + free_publickey(publickey); + } + + return keyid; +} +#endif