/**
* keyring_fetch_key - fetch a key given its index
*/
-static int keyring_fetch_key(struct onak_keyring_dbctx *privctx,
+static int keyring_fetch_key_idx(struct onak_keyring_dbctx *privctx,
unsigned int index,
struct openpgp_publickey **publickey)
{
return 1;
}
-static int keyring_fetch_key_fp(struct onak_dbctx *dbctx,
+/*
+ * We only index the primary fingerprint of the key, so will only return one
+ * key at most from this function.
+ */
+static int keyring_fetch_key(struct onak_dbctx *dbctx,
struct openpgp_fingerprint *fingerprint,
struct openpgp_publickey **publickey,
bool intrans)
}
if (i < privctx->count) {
- return keyring_fetch_key(privctx, i, publickey);
+ return keyring_fetch_key_idx(privctx, i, publickey);
}
return 0;
count = 0;
for (i = 0; i < privctx->count; i++) {
if (fingerprint2keyid(&privctx->keys[i].fp) == keyid) {
- if (keyring_fetch_key(privctx, i, publickey))
+ if (keyring_fetch_key_idx(privctx, i, publickey))
count++;
}
}
count = 0;
for (i = 0; i < privctx->count; i++) {
- if (keyring_fetch_key(privctx, i, &key)) {
+ if (keyring_fetch_key_idx(privctx, i, &key)) {
iterfunc(ctx, key);
free_publickey(key);
key = NULL;
* We need to fetch the key to calculate the
* fingerprint.
*/
- keyring_fetch_key(privctx, privctx->count - 1,
+ keyring_fetch_key_idx(privctx,
+ privctx->count - 1,
&key);
get_fingerprint(key->publickey,
&privctx->keys[privctx->count - 1].fp);
dbctx->cleanupdb = keyring_cleanupdb;
dbctx->starttrans = keyring_starttrans;
dbctx->endtrans = keyring_endtrans;
+ dbctx->fetch_key = keyring_fetch_key;
+ /* We don't index by subkey fingerprint, so fallback to fetch_key */
+ dbctx->fetch_key_fp = keyring_fetch_key;
dbctx->fetch_key_id = keyring_fetch_key_id;
- dbctx->fetch_key_fp = keyring_fetch_key_fp;
dbctx->fetch_key_text = keyring_fetch_key_text;
dbctx->store_key = keyring_store_key;
dbctx->update_keys = keyring_update_keys;