X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb.c;h=3acf7112bd110a9a8ebf3ef308d32144dbcda427;hb=d43d055372a663f85055bf255356271fdfe105e1;hp=a9e4cef30bd9907349ee82025016ab26ce6a3162;hpb=8e58a1769ce5e492dd68904dfc81b6e077fc2a3a;p=onak.git diff --git a/keydb.c b/keydb.c index a9e4cef..3acf711 100644 --- a/keydb.c +++ b/keydb.c @@ -32,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) { @@ -51,7 +51,7 @@ char *keyid2uid(uint64_t keyid) if (buf[0] == 0) { return NULL; } else { - return buf; + return strdup(buf); } } #endif @@ -70,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) { @@ -82,3 +82,30 @@ struct ll *getkeysigs(uint64_t keyid) 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. If the key isn't found a keyid of 0 is returned. + */ +uint64_t getfullkeyid(uint64_t keyid) +{ + struct openpgp_publickey *publickey = NULL; + + if (keyid < 0x100000000LL) { + fetch_key(keyid, &publickey, false); + if (publickey != NULL) { + keyid = get_keyid(publickey); + free_publickey(publickey); + publickey = NULL; + } else { + keyid = 0; + } + } + + return keyid; +} +#endif