struct openpgp_packet_list *packets = NULL;
struct openpgp_packet_list *list_end = NULL;
struct stats_key *keyinfoa, *keyinfob, *curkey;
- uint64_t fullhave, fullwant;
int pathlen = 0;
- fullhave = dbctx->getfullkeyid(dbctx, have);
- fullwant = dbctx->getfullkeyid(dbctx, want);
-
/*
* Make sure the keys we have and want are in the cache.
*/
- dbctx->cached_getkeysigs(dbctx, fullhave);
- dbctx->cached_getkeysigs(dbctx, fullwant);
+ dbctx->cached_getkeysigs(dbctx, have);
+ dbctx->cached_getkeysigs(dbctx, want);
- if ((keyinfoa = findinhash(fullhave)) == NULL) {
+ if ((keyinfoa = findinhash(have)) == NULL) {
return 1;
}
- if ((keyinfob = findinhash(fullwant)) == NULL) {
+ if ((keyinfob = findinhash(want)) == NULL) {
return 1;
}
*/
curkey = findinhash(keyinfoa->parent);
while (curkey != NULL && curkey->keyid != 0) {
- if (curkey->keyid != fullwant &&
+ if (curkey->keyid != want &&
dbctx->fetch_key_id(dbctx,
curkey->keyid,
&publickey, false)) {
/*
* Add the destination key to the list of returned keys.
*/
- if (dbctx->fetch_key_id(dbctx, fullwant, &publickey, false)) {
+ if (dbctx->fetch_key_id(dbctx, want, &publickey, false)) {
flatten_publickey(publickey,
&packets,
&list_end);
&fingerprint, false));
}
break;
- case KEYD_CMD_GETFULLKEYID:
- if (!keyd_write_reply(fd, KEYD_REPLY_OK)) {
- ret = 1;
- }
- if (ret == 0) {
- bytes = read(fd, &keyid, sizeof(keyid));
- if (bytes != sizeof(keyid)) {
- ret = 1;
- }
- }
- if (ret == 0) {
- keyid = dbctx->getfullkeyid(dbctx, keyid);
- cmd = sizeof(keyid);
- bytes = write(fd, &cmd, sizeof(cmd));
- if (bytes != sizeof(cmd)) {
- ret = 1;
- }
- }
- if (ret == 0) {
- bytes = write(fd, &keyid, sizeof(keyid));
- if (bytes != sizeof(keyid)) {
- ret = 1;
- }
- }
- break;
case KEYD_CMD_KEYITER:
if (!keyd_write_reply(fd, KEYD_REPLY_OK)) {
ret = 1;
return key->sigs;
}
-#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 generic_getfullkeyid(struct onak_dbctx *dbctx, uint64_t keyid)
-{
- struct openpgp_publickey *publickey = NULL;
-
- if (keyid < 0x100000000LL) {
- dbctx->fetch_key_id(dbctx, keyid, &publickey, false);
- if (publickey != NULL) {
- get_keyid(publickey, &keyid);
- free_publickey(publickey);
- publickey = NULL;
- } else {
- keyid = 0;
- }
- }
-
- return keyid;
-}
-#endif
-
#ifdef NEED_UPDATEKEYS
/**
* update_keys - Takes a list of public keys and updates them in the DB.
struct ll * (*cached_getkeysigs)(struct onak_dbctx *,
uint64_t keyid);
-/**
- * @brief Maps a 32 bit key id to a 64 bit one.
- * @param keyid The 32 bit keyid.
- *
- * This function maps a 32 bit key id to the full 64 bit one. It returns the
- * full keyid. If the key isn't found a keyid of 0 is returned.
- */
- uint64_t (*getfullkeyid)(struct onak_dbctx *, uint64_t keyid);
-
/**
* @brief call a function once for each key in the db.
* @param iterfunc The function to call.
return ret;
}
-/**
- * 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
- * first full keyid that has this short keyid. If the key isn't found a
- * keyid of 0 is returned.
- *
- * FIXME: This should either return the fingerprint or ideally go away
- * entirely.
- */
-static uint64_t db4_getfullkeyid(struct onak_dbctx *dbctx, uint64_t keyid)
-{
- struct onak_db4_dbctx *privctx = (struct onak_db4_dbctx *) dbctx->priv;
- DBT key, data;
- DBC *cursor = NULL;
- uint32_t shortkeyid = 0;
- int ret = 0;
- int i;
-
- if (keyid < 0x100000000LL) {
- ret = privctx->id32db->cursor(privctx->id32db,
- privctx->txn,
- &cursor,
- 0); /* flags */
-
- if (ret != 0) {
- return 0;
- }
-
- shortkeyid = keyid & 0xFFFFFFFF;
-
- memset(&key, 0, sizeof(key));
- memset(&data, 0, sizeof(data));
- key.data = &shortkeyid;
- key.size = sizeof(shortkeyid);
- data.flags = DB_DBT_MALLOC;
-
- ret = cursor->c_get(cursor,
- &key,
- &data,
- DB_SET);
-
- if (ret == 0) {
- keyid = 0;
- /* Only works for v4, not v3 or v5 */
- for (i = 12; i < 20; i++) {
- keyid <<= 8;
- keyid |= ((uint8_t *) data.data)[i];
- }
-
- if (data.data != NULL) {
- free(data.data);
- data.data = NULL;
- }
- }
-
- cursor->c_close(cursor);
- cursor = NULL;
- }
-
- return keyid;
-}
-
/**
* fetch_key_fp - Given a fingerprint fetch the key from storage.
*/
dbctx->getkeysigs = generic_getkeysigs;
dbctx->cached_getkeysigs = generic_cached_getkeysigs;
dbctx->keyid2uid = generic_keyid2uid;
- dbctx->getfullkeyid = db4_getfullkeyid;
dbctx->iterate_keys = db4_iterate_keys;
return dbctx;
keyid);
}
-static uint64_t dynamic_getfullkeyid(struct onak_dbctx *dbctx,
- uint64_t keyid)
-{
- struct onak_dynamic_dbctx *privctx =
- (struct onak_dynamic_dbctx *) dbctx->priv;
-
- return privctx->loadeddbctx->getfullkeyid(privctx->loadeddbctx, keyid);
-}
-
static int dynamic_iterate_keys(struct onak_dbctx *dbctx,
void (*iterfunc)(void *ctx, struct openpgp_publickey *key),
void *ctx)
dbctx->getkeysigs = dynamic_getkeysigs;
dbctx->cached_getkeysigs = dynamic_cached_getkeysigs;
dbctx->keyid2uid = dynamic_keyid2uid;
- dbctx->getfullkeyid = dynamic_getfullkeyid;
dbctx->iterate_keys = dynamic_iterate_keys;
}
*/
#define NEED_KEYID2UID 1
#define NEED_GETKEYSIGS 1
-#define NEED_GETFULLKEYID 1
#define NEED_UPDATEKEYS 1
#define NEED_GET_FP 1
#include "keydb.c"
dbctx->getkeysigs = generic_getkeysigs;
dbctx->cached_getkeysigs = generic_cached_getkeysigs;
dbctx->keyid2uid = generic_keyid2uid;
- dbctx->getfullkeyid = generic_getfullkeyid;
dbctx->iterate_keys = file_iterate_keys;
return dbctx;
dbctx->getkeysigs = generic_getkeysigs;
dbctx->cached_getkeysigs = generic_cached_getkeysigs;
dbctx->keyid2uid = generic_keyid2uid;
- dbctx->getfullkeyid = fs_getfullkeyid;
dbctx->iterate_keys = fs_iterate_keys;
return dbctx;
*/
#define NEED_KEYID2UID 1
#define NEED_GETKEYSIGS 1
-#define NEED_GETFULLKEYID 1
#define NEED_UPDATEKEYS 1
#include "keydb.c"
dbctx->getkeysigs = generic_getkeysigs;
dbctx->cached_getkeysigs = generic_cached_getkeysigs;
dbctx->keyid2uid = generic_keyid2uid;
- dbctx->getfullkeyid = generic_getfullkeyid;
dbctx->iterate_keys = hkp_iterate_keys;
if (!hkp_parse_url(privctx, dbcfg->location)) {
return (count > 0) ? 1 : 0;
}
-
-/**
- * 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.
- */
-static uint64_t keyd_getfullkeyid(struct onak_dbctx *dbctx, uint64_t keyid)
-{
- int keyd_fd = (intptr_t) dbctx->priv;
- uint32_t cmd = KEYD_CMD_GETFULLKEYID;
-
- if (keyd_send_cmd(keyd_fd, KEYD_CMD_GETFULLKEYID)) {
- write(keyd_fd, &keyid, sizeof(keyid));
- read(keyd_fd, &cmd, sizeof(cmd));
- if (cmd != sizeof(keyid)) {
- return 0;
- }
- read(keyd_fd, &keyid, sizeof(keyid));
- }
-
- return keyid;
-}
-
/**
* iterate_keys - call a function once for each key in the db.
* @iterfunc: The function to call.
dbctx->getkeysigs = generic_getkeysigs;
dbctx->cached_getkeysigs = generic_cached_getkeysigs;
dbctx->keyid2uid = generic_keyid2uid;
- dbctx->getfullkeyid = keyd_getfullkeyid;
dbctx->iterate_keys = keyd_iterate_keys;
return dbctx;
*/
#define NEED_KEYID2UID 1
#define NEED_GETKEYSIGS 1
-#define NEED_GETFULLKEYID 1
#define NEED_GET_FP 1
#include "keydb.c"
dbctx->getkeysigs = generic_getkeysigs;
dbctx->cached_getkeysigs = generic_cached_getkeysigs;
dbctx->keyid2uid = generic_keyid2uid;
- dbctx->getfullkeyid = generic_getfullkeyid;
dbctx->iterate_keys = keyring_iterate_keys;
return dbctx;
/*
* Include the basic keydb routines.
*/
-#define NEED_GETFULLKEYID 1
#define NEED_UPDATEKEYS 1
#define NEED_GET_FP 1
#include "keydb.c"
dbctx->getkeysigs = pg_getkeysigs;
dbctx->cached_getkeysigs = generic_cached_getkeysigs;
dbctx->keyid2uid = pg_keyid2uid;
- dbctx->getfullkeyid = generic_getfullkeyid;
dbctx->iterate_keys = pg_iterate_keys;
return dbctx;
*/
#define NEED_KEYID2UID 1
#define NEED_GETKEYSIGS 1
-#define NEED_GETFULLKEYID 1
#define NEED_UPDATEKEYS 1
#include "keydb.c"
return res;
}
-static uint64_t stacked_getfullkeyid(struct onak_dbctx *dbctx,
- uint64_t keyid)
-{
- struct onak_stacked_dbctx *privctx =
- (struct onak_stacked_dbctx *) dbctx->priv;
- struct onak_dbctx *backend =
- (struct onak_dbctx *) privctx->backends->object;
- uint64_t res = 0;
-
- res = backend->getfullkeyid(backend, keyid);
- if (res == 0) {
- res = generic_getfullkeyid(dbctx, keyid);
- }
-
- return res;
-}
-
static void stacked_cleanupdb(struct onak_dbctx *dbctx)
{
struct onak_stacked_dbctx *privctx =
dbctx->getkeysigs = stacked_getkeysigs;
dbctx->cached_getkeysigs = stacked_cached_getkeysigs;
dbctx->keyid2uid = stacked_keyid2uid;
- dbctx->getfullkeyid = stacked_getfullkeyid;
dbctx->iterate_keys = stacked_iterate_keys;
}
{
int optchar;
char *configfile = NULL;
- uint64_t keyid = 0x2DA8B985;
+ uint64_t keyid = 0x94FA372B2DA8B985;
struct onak_dbctx *dbctx;
while ((optchar = getopt(argc, argv, "c:")) != -1 ) {
dbctx = config.dbinit(config.backend, true);
if (dbctx != NULL) {
inithash();
- sixdegrees(dbctx, dbctx->getfullkeyid(dbctx, keyid));
+ sixdegrees(dbctx, keyid);
destroyhash();
dbctx->cleanupdb(dbctx);
} else {
uint64_t have, uint64_t want, bool html, int count)
{
struct stats_key *keyinfoa, *keyinfob, *curkey;
- uint64_t fullhave, fullwant;
int rec;
int pathnum;
char *uid;
- fullhave = dbctx->getfullkeyid(dbctx, have);
- fullwant = dbctx->getfullkeyid(dbctx, want);
-
/*
* Make sure the keys we have and want are in the cache.
*/
- (void) dbctx->cached_getkeysigs(dbctx, fullhave);
- (void) dbctx->cached_getkeysigs(dbctx, fullwant);
+ (void) dbctx->cached_getkeysigs(dbctx, have);
+ (void) dbctx->cached_getkeysigs(dbctx, want);
- if ((keyinfoa = findinhash(fullhave)) == NULL) {
+ if ((keyinfoa = findinhash(have)) == NULL) {
printf("Couldn't find key 0x%016" PRIX64 ".\n", have);
return;
}
- if ((keyinfob = findinhash(fullwant)) == NULL) {
+ if ((keyinfob = findinhash(want)) == NULL) {
printf("Couldn't find key 0x%016" PRIX64 ".\n", want);
return;
}
"User id not found])%s<BR>\n",
curkey->keyid,
curkey->keyid,
- (curkey->keyid == fullwant) ?
+ (curkey->keyid == want) ?
"" : " signs");
} else if (html && uid != NULL) {
printf("<a href=\"lookup?op=get&search="
curkey->keyid,
curkey->keyid,
txt2html(uid),
- (curkey->keyid == fullwant) ?
+ (curkey->keyid == want) ?
"" : " signs");
} else {
printf("0x%016" PRIX64 " (%s)%s\n",
(uid == NULL) ?
"[User id not found]" :
uid,
- (curkey->keyid == fullwant) ?
+ (curkey->keyid == want) ?
"" : " signs");
}
if (uid != NULL) {
{
int optchar;
char *configfile = NULL, *dir = NULL;
- uint64_t keyid = 0x2DA8B985;
+ uint64_t keyid = 0x94FA372B2DA8B985;
struct onak_dbctx *dbctx;
while ((optchar = getopt(argc, argv, "c:")) != -1 ) {
dbctx = config.dbinit(config.backend, true);
if (dbctx != NULL) {
inithash();
- wotsap(dbctx, dbctx->getfullkeyid(dbctx, keyid),
- dir ? dir : ".");
+ wotsap(dbctx, keyid, dir ? dir : ".");
destroyhash();
dbctx->cleanupdb(dbctx);
} else {