+static int db4_fetch_key_skshash(const struct skshash *hash,
+ struct openpgp_publickey **publickey)
+{
+ DBT key, data;
+ DBC *cursor = NULL;
+ uint64_t keyid = 0;
+ int ret = 0;
+
+ ret = skshashdb->cursor(skshashdb,
+ txn,
+ &cursor,
+ 0); /* flags */
+
+ memset(&key, 0, sizeof(key));
+ memset(&data, 0, sizeof(data));
+ key.data = (void *) hash->hash;
+ key.size = sizeof(hash->hash);
+ data.flags = DB_DBT_MALLOC;
+
+ ret = cursor->c_get(cursor,
+ &key,
+ &data,
+ DB_SET);
+
+ if (ret == 0) {
+ keyid = *(uint64_t *) data.data;
+
+ if (data.data != NULL) {
+ free(data.data);
+ data.data = NULL;
+ }
+ }
+
+ ret = cursor->c_close(cursor);
+ cursor = NULL;
+
+ return db4_fetch_key(keyid, publickey, false);
+}
+